summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-02-27 15:22:55 +0100
committerThiago Macieira <thiago.macieira@nokia.com>2010-02-27 15:22:55 +0100
commit3f626c3e14f2fe5fdecc38d4265d74f8315b3490 (patch)
tree357b32156e211a33841e44b7a224313c7072ee46
parent57ce77e953b618739f6f1aec67f8e0de97e05b08 (diff)
parent6396e7a15079cb157caef319348a0bcd0b95a6a7 (diff)
Merge remote branch 'origin/master' into 4.7
Conflicts: src/corelib/kernel/qmetatype.cpp src/declarative/graphicsitems/qdeclarativeevents.cpp src/declarative/graphicsitems/qdeclarativeflickable.cpp src/declarative/graphicsitems/qdeclarativegridview.cpp src/declarative/qml/qdeclarativescript.cpp src/declarative/util/qdeclarativeanimation.cpp src/declarative/util/qdeclarativebehavior.cpp src/declarative/util/qdeclarativeeasefollow.cpp src/declarative/util/qdeclarativefontloader.cpp src/declarative/util/qdeclarativelistmodel.cpp src/declarative/util/qdeclarativespringfollow.cpp src/declarative/util/qdeclarativestategroup.cpp src/declarative/util/qdeclarativesystempalette.cpp src/declarative/util/qdeclarativetimer.cpp src/declarative/util/qmlstateoperations.cpp src/multimedia/qml/qdeclarativeaudio.cpp src/multimedia/qml/qdeclarativevideo.cpp
-rwxr-xr-xconfigure22
-rwxr-xr-xconfigure.exebin1221632 -> 1223168 bytes
-rw-r--r--demos/declarative/calculator/calculator.qml4
-rw-r--r--demos/declarative/flickr/common/ImageDetails.qml14
-rw-r--r--demos/declarative/flickr/common/MediaLineEdit.qml2
-rw-r--r--demos/declarative/flickr/common/Star.qml2
-rw-r--r--demos/declarative/flickr/flickr-desktop.qml12
-rw-r--r--demos/declarative/flickr/flickr-mobile.qml10
-rw-r--r--demos/declarative/flickr/mobile/GridDelegate.qml12
-rw-r--r--demos/declarative/flickr/mobile/ImageDetails.qml12
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml2
-rw-r--r--demos/declarative/minehunt/main.cpp23
-rw-r--r--demos/declarative/minehunt/minehunt.qml2
-rw-r--r--demos/declarative/snake/snake.qml4
-rw-r--r--demos/declarative/twitter/content/HomeTitleBar.qml2
-rw-r--r--demos/declarative/twitter/content/MultiTitleBar.qml2
-rw-r--r--demos/declarative/twitter/content/TitleBar.qml2
-rw-r--r--demos/declarative/twitter/twitter.qml2
-rw-r--r--demos/declarative/webbrowser/content/FlickableWebView.qml29
-rw-r--r--demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml59
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml12
-rw-r--r--demos/embedded/desktopservices/contenttab.cpp14
-rw-r--r--doc/doc.pri2
-rw-r--r--doc/src/declarative/animation.qdoc14
-rw-r--r--doc/src/declarative/basictypes.qdoc2
-rw-r--r--doc/src/declarative/declarativeui.qdoc8
-rw-r--r--doc/src/declarative/dynamicobjects.qdoc4
-rw-r--r--doc/src/declarative/elements.qdoc6
-rw-r--r--doc/src/declarative/example-slideswitch.qdoc4
-rw-r--r--doc/src/declarative/examples.qdoc4
-rw-r--r--doc/src/declarative/extending-examples.qdoc12
-rw-r--r--doc/src/declarative/extending.qdoc99
-rw-r--r--doc/src/declarative/focus.qdoc4
-rw-r--r--doc/src/declarative/globalobject.qdoc6
-rw-r--r--doc/src/declarative/integrating.qdoc12
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc4
-rw-r--r--doc/src/declarative/measuring-performance.qdoc6
-rw-r--r--doc/src/declarative/modules.qdoc6
-rw-r--r--doc/src/declarative/network.qdoc8
-rw-r--r--doc/src/declarative/qdeclarativedebugging.qdoc120
-rw-r--r--doc/src/declarative/qdeclarativedocument.qdoc190
-rw-r--r--doc/src/declarative/qdeclarativei18n.qdoc95
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc351
-rw-r--r--doc/src/declarative/qdeclarativemodels.qdoc341
-rw-r--r--doc/src/declarative/qdeclarativereference.qdoc95
-rw-r--r--doc/src/declarative/qdeclarativestates.qdoc127
-rw-r--r--doc/src/declarative/qmldebugging.qdoc120
-rw-r--r--doc/src/declarative/qmldocument.qdoc190
-rw-r--r--doc/src/declarative/qmli18n.qdoc95
-rw-r--r--doc/src/declarative/qmlintro.qdoc351
-rw-r--r--doc/src/declarative/qmlmodels.qdoc341
-rw-r--r--doc/src/declarative/qmlreference.qdoc95
-rw-r--r--doc/src/declarative/qmlruntime.qdoc99
-rw-r--r--doc/src/declarative/qmlstates.qdoc127
-rw-r--r--doc/src/declarative/qmlviewer.qdoc99
-rw-r--r--doc/src/declarative/qtbinding.qdoc78
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc14
-rw-r--r--doc/src/declarative/scope.qdoc14
-rw-r--r--doc/src/development/qmake-manual.qdoc9
-rw-r--r--doc/src/examples/scribble.qdoc5
-rw-r--r--doc/src/files-and-resources/datastreamformat.qdoc19
-rw-r--r--doc/src/platforms/emb-directfb-EmbLinux.qdoc8
-rw-r--r--doc/src/snippets/code/doc_src_qmake-manual.qdoc13
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp2
-rw-r--r--examples/declarative/animations/easing.qml88
-rw-r--r--examples/declarative/animations/property-animation.qml8
-rw-r--r--examples/declarative/behaviours/test.qml6
-rw-r--r--examples/declarative/border-image/content/MyBorderImage.qml8
-rw-r--r--examples/declarative/connections/connections.qml14
-rw-r--r--examples/declarative/extending/adding/main.cpp10
-rw-r--r--examples/declarative/extending/adding/person.cpp1
-rw-r--r--examples/declarative/extending/adding/person.h2
-rw-r--r--examples/declarative/extending/attached/birthdayparty.cpp7
-rw-r--r--examples/declarative/extending/attached/birthdayparty.h6
-rw-r--r--examples/declarative/extending/attached/main.cpp15
-rw-r--r--examples/declarative/extending/attached/person.cpp4
-rw-r--r--examples/declarative/extending/attached/person.h2
-rw-r--r--examples/declarative/extending/binding/birthdayparty.cpp6
-rw-r--r--examples/declarative/extending/binding/birthdayparty.h6
-rw-r--r--examples/declarative/extending/binding/happybirthday.cpp3
-rw-r--r--examples/declarative/extending/binding/happybirthday.h12
-rw-r--r--examples/declarative/extending/binding/main.cpp17
-rw-r--r--examples/declarative/extending/binding/person.cpp4
-rw-r--r--examples/declarative/extending/binding/person.h2
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h6
-rw-r--r--examples/declarative/extending/coercion/main.cpp15
-rw-r--r--examples/declarative/extending/coercion/person.cpp6
-rw-r--r--examples/declarative/extending/coercion/person.h2
-rw-r--r--examples/declarative/extending/default/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/default/birthdayparty.h6
-rw-r--r--examples/declarative/extending/default/main.cpp13
-rw-r--r--examples/declarative/extending/default/person.cpp3
-rw-r--r--examples/declarative/extending/default/person.h2
-rw-r--r--examples/declarative/extending/extended/lineedit.cpp3
-rw-r--r--examples/declarative/extending/extended/main.cpp11
-rw-r--r--examples/declarative/extending/extending.pro13
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.h6
-rw-r--r--examples/declarative/extending/grouped/main.cpp14
-rw-r--r--examples/declarative/extending/grouped/person.cpp4
-rw-r--r--examples/declarative/extending/grouped/person.h2
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h6
-rw-r--r--examples/declarative/extending/properties/main.cpp11
-rw-r--r--examples/declarative/extending/properties/person.cpp1
-rw-r--r--examples/declarative/extending/properties/person.h2
-rw-r--r--examples/declarative/extending/signal/birthdayparty.cpp6
-rw-r--r--examples/declarative/extending/signal/birthdayparty.h6
-rw-r--r--examples/declarative/extending/signal/main.cpp15
-rw-r--r--examples/declarative/extending/signal/person.cpp4
-rw-r--r--examples/declarative/extending/signal/person.h2
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp6
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h6
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.cpp3
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.h11
-rw-r--r--examples/declarative/extending/valuesource/main.cpp17
-rw-r--r--examples/declarative/extending/valuesource/person.cpp4
-rw-r--r--examples/declarative/extending/valuesource/person.h2
-rw-r--r--examples/declarative/fonts/hello.qml2
-rw-r--r--examples/declarative/imageprovider/main.cpp23
-rw-r--r--examples/declarative/layouts/Button.qml2
-rw-r--r--examples/declarative/layouts/positioners.qml16
-rw-r--r--examples/declarative/listview/recipes.qml6
-rw-r--r--examples/declarative/objectlistmodel/main.cpp17
-rw-r--r--examples/declarative/package/Delegate.qml44
-rw-r--r--examples/declarative/package/view.qml35
-rw-r--r--examples/declarative/parallax/qml/ParallaxView.qml4
-rw-r--r--examples/declarative/parallax/qml/Smiley.qml8
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/Clock.qml (renamed from examples/declarative/plugins/files/Clock.qml)0
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/center.png (renamed from examples/declarative/plugins/files/center.png)bin765 -> 765 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/clock.png (renamed from examples/declarative/plugins/files/clock.png)bin20653 -> 20653 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/hour.png (renamed from examples/declarative/plugins/files/hour.png)bin625 -> 625 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/minute.png (renamed from examples/declarative/plugins/files/minute.png)bin625 -> 625 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/qmldir2
-rw-r--r--examples/declarative/plugins/plugin.cpp15
-rw-r--r--examples/declarative/plugins/plugins.pro22
-rw-r--r--examples/declarative/plugins/plugins.qml1
-rw-r--r--examples/declarative/progressbar/progressbars.qml2
-rw-r--r--examples/declarative/scrollbar/display.qml5
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml2
-rw-r--r--examples/declarative/sql/hello.qml2
-rw-r--r--examples/declarative/states/transitions.qml8
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial3.qml2
-rw-r--r--examples/declarative/velocity/velocity.qml2
-rw-r--r--examples/declarative/webview/qdeclarative-in-html.qml32
-rw-r--r--examples/declarative/webview/qml-in-html.qml32
-rw-r--r--examples/declarative/xmldata/yahoonews.qml2
-rw-r--r--examples/network/http/httpwindow.cpp129
-rw-r--r--examples/network/http/httpwindow.h23
-rw-r--r--examples/network/http/main.cpp1
-rw-r--r--examples/network/loopback/dialog.cpp10
-rw-r--r--imports/Qt/multimedia/qmldir1
-rw-r--r--imports/Qt/widgets/qmldir1
-rw-r--r--mkspecs/aix-g++-64/qmake.conf1
-rw-r--r--mkspecs/aix-g++/qmake.conf1
-rw-r--r--mkspecs/aix-xlc-64/qmake.conf1
-rw-r--r--mkspecs/aix-xlc/qmake.conf1
-rw-r--r--mkspecs/common/qws.conf1
-rw-r--r--mkspecs/common/symbian/symbian.conf7
-rw-r--r--mkspecs/cygwin-g++/qmake.conf1
-rw-r--r--mkspecs/darwin-g++/qmake.conf1
-rw-r--r--mkspecs/features/default_post.prf11
-rw-r--r--mkspecs/features/qttest_p4.prf24
-rw-r--r--mkspecs/features/symbian/add_mmp_rules.prf33
-rw-r--r--mkspecs/freebsd-g++/qmake.conf1
-rw-r--r--mkspecs/freebsd-g++34/qmake.conf1
-rw-r--r--mkspecs/freebsd-g++40/qmake.conf1
-rw-r--r--mkspecs/freebsd-icc/qmake.conf1
-rw-r--r--mkspecs/hpux-acc-64/qmake.conf1
-rw-r--r--mkspecs/hpux-acc-o64/qmake.conf1
-rw-r--r--mkspecs/hpux-acc/qmake.conf1
-rw-r--r--mkspecs/hpux-g++-64/qmake.conf1
-rw-r--r--mkspecs/hpux-g++/qmake.conf1
-rw-r--r--mkspecs/hpuxi-acc-32/qmake.conf1
-rw-r--r--mkspecs/hpuxi-acc-64/qmake.conf1
-rw-r--r--mkspecs/hpuxi-g++-64/qmake.conf1
-rw-r--r--mkspecs/hurd-g++/qmake.conf1
-rw-r--r--mkspecs/irix-cc-64/qmake.conf1
-rw-r--r--mkspecs/irix-cc/qmake.conf1
-rw-r--r--mkspecs/irix-g++-64/qmake.conf1
-rw-r--r--mkspecs/irix-g++/qmake.conf1
-rw-r--r--mkspecs/linux-cxx/qmake.conf1
-rw-r--r--mkspecs/linux-ecc-64/qmake.conf1
-rw-r--r--mkspecs/linux-g++-32/qmake.conf1
-rw-r--r--mkspecs/linux-g++-64/qmake.conf1
-rw-r--r--mkspecs/linux-g++-maemo/qmake.conf1
-rw-r--r--mkspecs/linux-g++/qmake.conf1
-rw-r--r--mkspecs/linux-icc/qmake.conf1
-rw-r--r--mkspecs/linux-kcc/qmake.conf1
-rw-r--r--mkspecs/linux-llvm/qmake.conf1
-rw-r--r--mkspecs/linux-lsb-g++/qmake.conf1
-rw-r--r--mkspecs/linux-pgcc/qmake.conf1
-rw-r--r--mkspecs/lynxos-g++/qmake.conf1
-rw-r--r--mkspecs/macx-g++/qmake.conf1
-rw-r--r--mkspecs/macx-g++40/qmake.conf1
-rw-r--r--mkspecs/macx-g++42/qmake.conf1
-rw-r--r--mkspecs/macx-icc/qmake.conf1
-rw-r--r--mkspecs/macx-llvm/qmake.conf1
-rw-r--r--mkspecs/macx-xlc/qmake.conf1
-rw-r--r--mkspecs/netbsd-g++/qmake.conf1
-rw-r--r--mkspecs/openbsd-g++/qmake.conf1
-rw-r--r--mkspecs/qws/freebsd-generic-g++/qmake.conf1
-rw-r--r--mkspecs/qws/macx-generic-g++/qmake.conf1
-rw-r--r--mkspecs/qws/solaris-generic-g++/qmake.conf1
-rw-r--r--mkspecs/sco-cc/qmake.conf1
-rw-r--r--mkspecs/sco-g++/qmake.conf1
-rw-r--r--mkspecs/solaris-cc-64/qmake.conf1
-rw-r--r--mkspecs/solaris-cc/qmake.conf1
-rw-r--r--mkspecs/solaris-g++-64/qmake.conf1
-rw-r--r--mkspecs/solaris-g++/qmake.conf1
-rw-r--r--mkspecs/symbian-abld/qmake.conf1
-rw-r--r--mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm2
-rw-r--r--mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm8
-rw-r--r--mkspecs/symbian-sbsv2/flm/qt/qmake_post_link.flm2
-rw-r--r--mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm3
-rw-r--r--mkspecs/symbian-sbsv2/flm/qt/qt.xml2
-rw-r--r--mkspecs/symbian-sbsv2/qmake.conf1
-rw-r--r--mkspecs/tru64-cxx/qmake.conf1
-rw-r--r--mkspecs/tru64-g++/qmake.conf1
-rw-r--r--mkspecs/unixware-cc/qmake.conf1
-rw-r--r--mkspecs/unixware-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/linux-scratchbox2-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/qnx-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/qws/qnx-641/qmake.conf1
-rw-r--r--mkspecs/unsupported/qws/qnx-generic-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/qws/qnx-ppc-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf1
-rw-r--r--mkspecs/unsupported/vxworks-ppc-g++/qmake.conf1
-rw-r--r--mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf1
-rw-r--r--mkspecs/unsupported/vxworks-simpentium-g++/qmake.conf1
-rw-r--r--qmake/generators/makefile.cpp14
-rw-r--r--qmake/generators/makefile.h3
-rw-r--r--qmake/generators/metamakefile.cpp48
-rw-r--r--qmake/generators/metamakefile.h5
-rw-r--r--qmake/generators/projectgenerator.cpp9
-rw-r--r--qmake/generators/symbian/initprojectdeploy_symbian.cpp109
-rw-r--r--qmake/generators/symbian/initprojectdeploy_symbian.h2
-rw-r--r--qmake/generators/symbian/symmake.cpp86
-rw-r--r--qmake/generators/symbian/symmake.h4
-rw-r--r--qmake/generators/symbian/symmake_abld.cpp53
-rw-r--r--qmake/generators/symbian/symmake_abld.h2
-rw-r--r--qmake/generators/symbian/symmake_sbsv2.cpp47
-rw-r--r--qmake/generators/symbian/symmake_sbsv2.h2
-rw-r--r--qmake/generators/win32/winmakefile.cpp17
-rw-r--r--qmake/generators/win32/winmakefile.h1
-rw-r--r--qmake/main.cpp2
-rw-r--r--qmake/option.cpp58
-rw-r--r--qmake/option.h13
-rw-r--r--qmake/project.cpp208
-rw-r--r--qmake/project.h8
-rw-r--r--qmake/property.cpp3
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_wince.c281
-rw-r--r--src/corelib/concurrent/qfuturewatcher.cpp7
-rw-r--r--src/corelib/global/qglobal.h5
-rw-r--r--src/corelib/global/qlibraryinfo.cpp6
-rw-r--r--src/corelib/global/qlibraryinfo.h3
-rw-r--r--src/corelib/io/qdatastream.cpp5
-rw-r--r--src/corelib/io/qdir.cpp7
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp4
-rw-r--r--src/corelib/io/qresource.cpp9
-rw-r--r--src/corelib/io/qurl.cpp25
-rw-r--r--src/corelib/kernel/qmetatype.cpp26
-rw-r--r--src/corelib/kernel/qmetatype.h8
-rw-r--r--src/corelib/kernel/qvariant.cpp57
-rw-r--r--src/corelib/kernel/qvariant.h12
-rw-r--r--src/corelib/tools/qeasingcurve.cpp69
-rw-r--r--src/corelib/tools/qeasingcurve.h11
-rw-r--r--src/corelib/tools/qhash.h3
-rw-r--r--src/corelib/tools/qlist.h34
-rw-r--r--src/corelib/tools/qmap.h3
-rw-r--r--src/corelib/tools/qscopedpointer.cpp55
-rw-r--r--src/declarative/3rdparty/qlistmodelinterface.cpp4
-rw-r--r--src/declarative/QmlChanges.txt18
-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.pro3
-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.cpp440
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p.h106
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h97
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects.cpp174
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects_p.h65
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents.cpp194
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents_p_p.h137
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp1336
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h209
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h191
-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.cpp1738
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h223
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp377
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h101
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p_p.h79
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp221
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h99
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h86
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp2845
-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.cpp2730
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h306
-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.cpp1299
-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.cpp987
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h135
-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.cpp335
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater_p.h104
-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.cpp1291
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h255
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview.cpp1338
-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.cpp174
-rw-r--r--src/declarative/graphicsitems/qmlgraphicseffects_p.h65
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsevents.cpp194
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsevents_p_p.h137
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp1325
-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.cpp1724
-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.cpp167
-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.cpp1244
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles_p.h247
-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.cpp866
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h192
-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.cpp1103
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h246
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp1319
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h281
-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.g3096
-rw-r--r--src/declarative/qml/parser/qdeclarativejsast.cpp955
-rw-r--r--src/declarative/qml/parser/qdeclarativejsast_p.h2685
-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.cpp992
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar_p.h210
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp1163
-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.cpp1857
-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.h312
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp308
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h137
-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.cpp2793
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h338
-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.cpp1938
-rw-r--r--src/declarative/qml/qdeclarativeengine.h112
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h342
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp458
-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.h68
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp99
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.h73
-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.h157
-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.cpp409
-rw-r--r--src/declarative/qml/qdeclarativelist.h147
-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/qdeclarativemetatype.cpp1140
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h149
-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.h359
-rw-r--r--src/declarative/qml/qdeclarativeparserstatus.cpp81
-rw-r--r--src/declarative/qml/qdeclarativeparserstatus.h75
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h214
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp1306
-rw-r--r--src/declarative/qml/qdeclarativeproperty.h138
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h142
-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.cpp88
-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.h398
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass.cpp148
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass_p.h86
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp852
-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.h155
-rw-r--r--src/declarative/qml/qml.pri237
-rw-r--r--src/declarative/qml/qmlbinding.cpp308
-rw-r--r--src/declarative/qml/qmlbinding.h132
-rw-r--r--src/declarative/qml/qmlbinding_p.h89
-rw-r--r--src/declarative/qml/qmlboundsignal.cpp264
-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.cpp2774
-rw-r--r--src/declarative/qml/qmlcompiler_p.h337
-rw-r--r--src/declarative/qml/qmlcomponent.cpp799
-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.h146
-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/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.cpp1755
-rw-r--r--src/declarative/qml/qmlengine.h111
-rw-r--r--src/declarative/qml/qmlengine_p.h328
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp457
-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.cpp830
-rw-r--r--src/declarative/qml/qmlexpression.h118
-rw-r--r--src/declarative/qml/qmlexpression_p.h187
-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.cpp1230
-rw-r--r--src/declarative/qml/qmlmetaproperty.h147
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h124
-rw-r--r--src/declarative/qml/qmlmetatype.cpp1153
-rw-r--r--src/declarative/qml/qmlmetatype.h281
-rw-r--r--src/declarative/qml/qmlmoduleplugin.cpp112
-rw-r--r--src/declarative/qml/qmlmoduleplugin.h86
-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.cpp413
-rw-r--r--src/declarative/qml/qmlpropertycache_p.h193
-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.cpp88
-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.cpp636
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h340
-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.cpp185
-rw-r--r--src/declarative/qml/qmlwatcher_p.h94
-rw-r--r--src/declarative/qml/qmlworkerscript.cpp1045
-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.cpp2611
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h501
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h391
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp193
-rw-r--r--src/declarative/util/qdeclarativebehavior_p.h92
-rw-r--r--src/declarative/util/qdeclarativebind.cpp203
-rw-r--r--src/declarative/util/qdeclarativebind_p.h95
-rw-r--r--src/declarative/util/qdeclarativeconnections.cpp245
-rw-r--r--src/declarative/util/qdeclarativeconnections_p.h98
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter.cpp373
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter_p.h117
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp537
-rw-r--r--src/declarative/util/qdeclarativeeasefollow_p.h114
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp231
-rw-r--r--src/declarative/util/qdeclarativefontloader_p.h96
-rw-r--r--src/declarative/util/qdeclarativelistaccessor.cpp138
-rw-r--r--src/declarative/util/qdeclarativelistaccessor_p.h80
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp985
-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.cpp194
-rw-r--r--src/declarative/util/qdeclarativepackage_p.h104
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp642
-rw-r--r--src/declarative/util/qdeclarativepixmapcache_p.h107
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp486
-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.cpp465
-rw-r--r--src/declarative/util/qdeclarativespringfollow_p.h112
-rw-r--r--src/declarative/util/qdeclarativestate.cpp483
-rw-r--r--src/declarative/util/qdeclarativestate_p.h183
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h153
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp441
-rw-r--r--src/declarative/util/qdeclarativestategroup_p.h95
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp989
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h216
-rw-r--r--src/declarative/util/qdeclarativestyledtext.cpp347
-rw-r--r--src/declarative/util/qdeclarativestyledtext_p.h69
-rw-r--r--src/declarative/util/qdeclarativesystempalette.cpp304
-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.cpp314
-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.cpp283
-rw-r--r--src/declarative/util/qdeclarativetransitionmanager_p_p.h85
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp122
-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.cpp797
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h176
-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.cpp2446
-rw-r--r--src/declarative/util/qmlanimation_p.h466
-rw-r--r--src/declarative/util/qmlanimation_p_p.h364
-rw-r--r--src/declarative/util/qmlbehavior.cpp192
-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.cpp537
-rw-r--r--src/declarative/util/qmleasefollow_p.h114
-rw-r--r--src/declarative/util/qmlfontloader.cpp230
-rw-r--r--src/declarative/util/qmlfontloader_p.h95
-rw-r--r--src/declarative/util/qmllistaccessor.cpp138
-rw-r--r--src/declarative/util/qmllistaccessor_p.h80
-rw-r--r--src/declarative/util/qmllistmodel.cpp1014
-rw-r--r--src/declarative/util/qmllistmodel_p.h107
-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.cpp185
-rw-r--r--src/declarative/util/qmlpackage_p.h88
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp611
-rw-r--r--src/declarative/util/qmlpixmapcache_p.h107
-rw-r--r--src/declarative/util/qmlpropertychanges.cpp469
-rw-r--r--src/declarative/util/qmlpropertychanges_p.h84
-rw-r--r--src/declarative/util/qmlpropertymap.cpp279
-rw-r--r--src/declarative/util/qmlpropertymap.h90
-rw-r--r--src/declarative/util/qmlspringfollow.cpp465
-rw-r--r--src/declarative/util/qmlspringfollow_p.h112
-rw-r--r--src/declarative/util/qmlstate.cpp483
-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.cpp441
-rw-r--r--src/declarative/util/qmlstategroup_p.h95
-rw-r--r--src/declarative/util/qmlstateoperations.cpp837
-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.h68
-rw-r--r--src/declarative/util/qmlsystempalette.cpp304
-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.cpp314
-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.cpp556
-rw-r--r--src/declarative/util/qmlview.h112
-rw-r--r--src/declarative/util/qmlxmllistmodel.cpp719
-rw-r--r--src/declarative/util/qmlxmllistmodel_p.h136
-rw-r--r--src/declarative/util/qnumberformat.cpp3
-rw-r--r--src/declarative/util/qnumberformat_p.h2
-rw-r--r--src/declarative/util/util.pri116
-rw-r--r--src/declarative/widgets/graphicslayouts.cpp319
-rw-r--r--src/declarative/widgets/graphicslayouts_p.h168
-rw-r--r--src/declarative/widgets/graphicswidgets.cpp117
-rw-r--r--src/declarative/widgets/graphicswidgets_p.h68
-rw-r--r--src/declarative/widgets/widgets.pri9
-rw-r--r--src/gui/dialogs/qcolordialog_mac.mm10
-rw-r--r--src/gui/dialogs/qfontdialog.cpp64
-rw-r--r--src/gui/dialogs/qfontdialog.h3
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm148
-rw-r--r--src/gui/dialogs/qfontdialog_p.h6
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp27
-rw-r--r--src/gui/image/qnativeimage.cpp2
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp40
-rw-r--r--src/gui/itemviews/qabstractproxymodel.cpp1
-rw-r--r--src/gui/kernel/qapplication_s60.cpp8
-rw-r--r--src/gui/kernel/qapplication_win.cpp5
-rw-r--r--src/gui/kernel/qkeymapper_p.h6
-rw-r--r--src/gui/kernel/qkeymapper_s60.cpp298
-rw-r--r--src/gui/kernel/qwidget.cpp43
-rw-r--r--src/gui/kernel/qwidget_mac.mm14
-rw-r--r--src/gui/kernel/qwidget_p.h2
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp7
-rw-r--r--src/gui/widgets/qabstractslider.cpp53
-rw-r--r--src/gui/widgets/qdockarealayout.cpp3
-rw-r--r--src/gui/widgets/qlineedit_p.cpp2
-rw-r--r--src/multimedia/audio/qaudioinput.cpp74
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp121
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp42
-rw-r--r--src/multimedia/audio/qaudiooutput.cpp78
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp64
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp62
-rw-r--r--src/multimedia/qml/multimediadeclarative.cpp70
-rw-r--r--src/multimedia/qml/multimediadeclarative.h60
-rw-r--r--src/multimedia/qml/multimediaqml.cpp68
-rw-r--r--src/multimedia/qml/multimediaqml.h60
-rw-r--r--src/multimedia/qml/qdeclarativeaudio.cpp327
-rw-r--r--src/multimedia/qml/qdeclarativeaudio_p.h173
-rw-r--r--src/multimedia/qml/qdeclarativemediabase.cpp413
-rw-r--r--src/multimedia/qml/qdeclarativemediabase_p.h168
-rw-r--r--src/multimedia/qml/qdeclarativevideo.cpp945
-rw-r--r--src/multimedia/qml/qdeclarativevideo_p.h204
-rw-r--r--src/multimedia/qml/qml.pri16
-rw-r--r--src/multimedia/qml/qmlaudio.cpp327
-rw-r--r--src/multimedia/qml/qmlaudio_p.h173
-rw-r--r--src/multimedia/qml/qmlgraphicsvideo.cpp945
-rw-r--r--src/multimedia/qml/qmlgraphicsvideo_p.h204
-rw-r--r--src/multimedia/qml/qmlmediabase.cpp413
-rw-r--r--src/multimedia/qml/qmlmediabase_p.h168
-rw-r--r--src/multimedia/qml/qsoundeffect_p.h2
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp18
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp2
-rw-r--r--src/network/access/qnetworkaccessdatabackend.cpp7
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp9
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp2
-rw-r--r--src/network/access/qnetworkrequest.cpp2
-rw-r--r--src/network/kernel/qhostinfo.cpp2
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp4
-rw-r--r--src/network/socket/qabstractsocket.cpp10
-rw-r--r--src/opengl/qgl.cpp2
-rw-r--r--src/openvg/qpaintengine_vg.cpp128
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp12
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp6
-rw-r--r--src/plugins/bearer/symbian/symbian.pro1
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp23
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h3
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp89
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h3
-rw-r--r--src/plugins/imageformats/tiff/tiff.pro5
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/multimedia.cpp63
-rw-r--r--src/plugins/qdeclarativemodules/multimedia/multimedia.pro15
-rw-r--r--src/plugins/qdeclarativemodules/qdeclarativemodules.pro6
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp260
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h226
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp40
-rw-r--r--src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h68
-rw-r--r--src/plugins/qdeclarativemodules/widgets/widgets.cpp138
-rw-r--r--src/plugins/qdeclarativemodules/widgets/widgets.pro20
-rw-r--r--src/plugins/qmlmodules/multimedia/multimedia.cpp71
-rw-r--r--src/plugins/qmlmodules/multimedia/multimedia.pro11
-rw-r--r--src/plugins/qmlmodules/qmlmodules.pro4
-rw-r--r--src/script/api/qscriptengine.cpp2
-rw-r--r--src/script/api/qscriptengine_p.h12
-rw-r--r--src/svg/qgraphicssvgitem.cpp4
-rw-r--r--tests/auto/auto.pro12
-rw-r--r--tests/auto/declarative/declarative.pro108
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp11
-rw-r--r--tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml1
-rw-r--r--tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp10
-rw-r--r--tests/auto/declarative/layouts/data/layouts.qml1
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp33
-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/qmlgraphicsborderimage/data/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.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml3
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/trimming.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp135
-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.cpp843
-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/declarativeToString.qml (renamed from tests/auto/declarative/qmlecmascript/data/qmlToString.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/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.cpp85
-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.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml16
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp223
-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/displaygrid.qml39
-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/data/setindex.qml33
-rw-r--r--tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp1022
-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/data/colors1.png (renamed from tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp253
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png (renamed from tests/auto/declarative/qmlimageprovider/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png (renamed from tests/auto/declarative/qmlimageprovider/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/qmlObject.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/autoNotifyConnection.qml6
-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.txt1
-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/qmlAttachedPropertiesObjectMethod.1.qml (renamed from tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.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.txt1
-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.txt1
-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.txt1
-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/data/subdir/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/qtest/declarative/qmllanguage/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.cpp62
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h554
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1406
-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/qmllist/data/MyType.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml (renamed from tests/auto/declarative/qmllist/data/engineTypes.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml (renamed from tests/auto/declarative/qmllist/data/variantToList.qml)0
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro5
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp580
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/displaylist.qml43
-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.qml119
-rw-r--r--tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro8
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp1413
-rw-r--r--tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml6
-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/qdeclarativemetatype/qdeclarativemetatype.pro6
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp378
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir1
-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.cpp85
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro6
-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.pro5
-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.qml33
-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/displaypath.qml60
-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.cpp529
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png (renamed from tests/auto/declarative/qmlpixmapcache/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png (renamed from tests/auto/declarative/qmlpixmapcache/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.qml39
-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/qdeclarativeproperty/qdeclarativeproperty.pro5
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp1322
-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/basicChanges4.qml19
-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/reset.qml20
-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.cpp969
-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.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml6
-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.cpp48
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h156
-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.html12
-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.qml33
-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.cpp513
-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.qml13
-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/data/test-connection.qml10
-rw-r--r--tests/auto/declarative/qmlconnection/data/test-connection2.qml3
-rw-r--r--tests/auto/declarative/qmlconnection/data/test-connection3.qml3
-rw-r--r--tests/auto/declarative/qmlconnection/data/trimming.qml10
-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.cpp82
-rw-r--r--tests/auto/declarative/qmlecmascript/testtypes.h592
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp1659
-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.cpp459
-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/data/flickable02.qml14
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml14
-rw-r--r--tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml16
-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.cpp967
-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.cpp321
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/data/listview.qml119
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp1374
-rw-r--r--tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml5
-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.cpp139
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp122
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp491
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro7
-rw-r--r--tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp417
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp387
-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.cpp798
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro8
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp663
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/data/forward.html12
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro10
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/testtypes.cpp49
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/testtypes.h64
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp396
-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/data/component.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.10.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.12.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/data/script.9.errors.txt1
-rw-r--r--tests/auto/declarative/qmllanguage/qmllanguage.pro14
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.cpp59
-rw-r--r--tests/auto/declarative/qmllanguage/testtypes.h545
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp1383
-rw-r--r--tests/auto/declarative/qmllist/qmllist.pro5
-rw-r--r--tests/auto/declarative/qmllist/tst_qmllist.cpp574
-rw-r--r--tests/auto/declarative/qmllistmodel/qmllistmodel.pro6
-rw-r--r--tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp338
-rw-r--r--tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro5
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp1136
-rw-r--r--tests/auto/declarative/qmlmetatype/qmlmetatype.pro6
-rw-r--r--tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp371
-rw-r--r--tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp84
-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.cpp911
-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.cpp45
-rw-r--r--tests/auto/declarative/qmlvaluetypes/testtypes.h152
-rw-r--r--tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp588
-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.cpp203
-rw-r--r--tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp12
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp52
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h52
-rw-r--r--tests/auto/declarative/sql/tst_sql.cpp18
-rw-r--r--tests/auto/declarative/visual/Package_Views/packageviews.qml2
-rw-r--r--tests/auto/declarative/visual/animation/easing/easing.qml84
-rw-r--r--tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml4
-rw-r--r--tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml2
-rw-r--r--tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml4
-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.qml38
-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.pngbin0 -> 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.qml37
-rw-r--r--tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml91
-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.qml79
-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.qml71
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml)0
-rw-r--r--tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml (renamed from tests/auto/declarative/visual/qmlgraphicstext/baseline/data/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-MAC/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-MAC/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-MAC/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-MAC/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/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/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/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/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.qml35
-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-X11/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-X11/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-X11/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-X11/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-X11/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-X11/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-X11/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/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/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/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/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/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/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/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.qml35
-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-X11/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-X11/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-X11/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-X11/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-X11/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-X11/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-X11/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/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/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/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/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/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/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/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/qmlgraphicsborderimage/content/MyBorderImage.qml38
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml37
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml91
-rw-r--r--tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml79
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml35
-rw-r--r--tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml35
-rw-r--r--tests/auto/declarative/visual/qmlspringfollow/follow.qml71
-rw-r--r--tests/auto/declarative/visual/tst_visual.cpp20
-rw-r--r--tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp82
-rw-r--r--tests/auto/qdatastream/tst_qdatastream.cpp69
-rw-r--r--tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro4
-rw-r--r--tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp1200
-rw-r--r--tests/auto/qdeclarativevideo/qdeclarativevideo.pro4
-rw-r--r--tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp911
-rw-r--r--tests/auto/qeasingcurve/tst_qeasingcurve.cpp61
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp36
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp26
-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/auto/qpropertyanimation/tst_qpropertyanimation.cpp29
-rw-r--r--tests/auto/qscriptstring/tst_qscriptstring.cpp6
-rw-r--r--tests/auto/qscriptvalue/qscriptvalue.pro7
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp18
-rw-r--r--tests/auto/qurl/tst_qurl.cpp4
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp2
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt11963
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp173
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc5
-rw-r--r--tests/benchmarks/corelib/io/qdir/tree/tree.pro11
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro2
-rw-r--r--tests/benchmarks/declarative/binding/binding.pro6
-rw-r--r--tests/benchmarks/declarative/binding/testtypes.cpp5
-rw-r--r--tests/benchmarks/declarative/binding/testtypes.h10
-rw-r--r--tests/benchmarks/declarative/binding/tst_binding.cpp17
-rw-r--r--tests/benchmarks/declarative/creation/creation.pro9
-rw-r--r--tests/benchmarks/declarative/creation/tst_creation.cpp62
-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.cpp46
-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.pro9
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/testtypes.cpp43
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/testtypes.h81
-rw-r--r--tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp118
-rw-r--r--tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro11
-rw-r--r--tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp102
-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.cpp219
-rw-r--r--tests/benchmarks/declarative/qmltime/qmltime.pro8
-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/script.pro11
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp80
-rw-r--r--tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp2
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp7
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp6
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp6
-rw-r--r--tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp297
-rw-r--r--tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp6
-rw-r--r--tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp9
-rw-r--r--tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro2
-rw-r--r--tests/benchmarks/script/qscriptvalue/tst_qscriptvalue.cpp25
-rw-r--r--tools/assistant/lib/qhelpsearchresultwidget.cpp2
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp2
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp16
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h2
-rw-r--r--tools/configure/configureapp.cpp20
-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/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.h127
-rw-r--r--tools/qml/qfxtester.cpp381
-rw-r--r--tools/qml/qfxtester.h286
-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.cpp350
-rw-r--r--tools/qmlviewer/qfxtester.cpp378
-rw-r--r--tools/qmlviewer/qfxtester.h282
-rw-r--r--tools/qmlviewer/qmlfolderlistmodel.cpp418
-rw-r--r--tools/qmlviewer/qmlfolderlistmodel.h123
-rw-r--r--tools/qmlviewer/qmlviewer.cpp1465
-rw-r--r--tools/qmlviewer/qmlviewer.h193
-rw-r--r--tools/qmlviewer/qmlviewer.pro58
-rw-r--r--tools/qtestlib/wince/cetest/cetest.pro2
-rw-r--r--tools/qtestlib/wince/cetest/qmake_include.pri4
-rw-r--r--tools/tools.pro2
-rw-r--r--translations/assistant_de.ts494
-rw-r--r--translations/designer_de.ts58
-rw-r--r--translations/linguist_de.ts50
-rw-r--r--translations/qt_de.ts1121
-rw-r--r--translations/qt_help_de.ts181
-rw-r--r--translations/translations.pri2
2410 files changed, 160750 insertions, 142245 deletions
diff --git a/configure b/configure
index a25dee1448..231216505c 100755
--- a/configure
+++ b/configure
@@ -794,6 +794,7 @@ QT_INSTALL_HEADERS=
QT_INSTALL_LIBS=
QT_INSTALL_BINS=
QT_INSTALL_PLUGINS=
+QT_INSTALL_IMPORTS=
QT_INSTALL_DATA=
QT_INSTALL_TRANSLATIONS=
QT_INSTALL_SETTINGS=
@@ -1143,6 +1144,9 @@ while [ "$#" -gt 0 ]; do
plugindir)
QT_INSTALL_PLUGINS="$VAL"
;;
+ importdir)
+ QT_INSTALL_IMPORTS="$VAL"
+ ;;
datadir)
QT_INSTALL_DATA="$VAL"
;;
@@ -3204,6 +3208,17 @@ if [ -z "$QT_INSTALL_PLUGINS" ]; then #default
fi
QT_INSTALL_PLUGINS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_PLUGINS"`
+#imports
+if [ -z "$QT_INSTALL_IMPORTS" ]; then #default
+ if [ "$CFG_PREFIX_INSTALL" = "no" ]; then
+ if [ "$PLATFORM_MAC" = "yes" ]; then
+ QT_INSTALL_IMPORTS="/Developer/Applications/Qt/imports"
+ fi
+ fi
+ [ -z "$QT_INSTALL_IMPORTS" ] && QT_INSTALL_IMPORTS="$QT_INSTALL_PREFIX/imports" #fallback
+fi
+QT_INSTALL_IMPORTS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_IMPORTS"`
+
#data
if [ -z "$QT_INSTALL_DATA" ]; then #default
QT_INSTALL_DATA="$QT_INSTALL_PREFIX"
@@ -3367,6 +3382,8 @@ cat <<EOF
(default PREFIX/include)
-plugindir <dir> ...... Plugins will be installed to <dir>
(default PREFIX/plugins)
+ -importdir <dir> ...... Imports for QML will be installed to <dir>
+ (default PREFIX/imports)
-datadir <dir> ........ Data used by Qt programs will be installed to <dir>
(default PREFIX)
-translationdir <dir> . Translations of Qt programs will be installed to <dir>
@@ -4176,6 +4193,7 @@ HEADERS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_hdrspath=$QT_IN
LIBRARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_libspath=$QT_INSTALL_LIBS"`
BINARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_binspath=$QT_INSTALL_BINS"`
PLUGINS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_plugpath=$QT_INSTALL_PLUGINS"`
+IMPORTS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_impspath=$QT_INSTALL_IMPORTS"`
DATA_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_datapath=$QT_INSTALL_DATA"`
TRANSLATIONS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_trnspath=$QT_INSTALL_TRANSLATIONS"`
SETTINGS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_stngpath=$QT_INSTALL_SETTINGS"`
@@ -4200,6 +4218,7 @@ if [ ! -z "$QT_HOST_PREFIX" ]; then
HOSTLIBRARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_libspath=$QT_HOST_PREFIX/lib"`
HOSTBINARIES_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_binspath=$QT_HOST_PREFIX/bin"`
HOSTPLUGINS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_plugpath=$QT_HOST_PREFIX/plugins"`
+ HOSTIMPORTS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_impspath=$QT_HOST_PREFIX/IMPORTS"`
HOSTDATA_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_datapath=$QT_HOST_PREFIX"`
HOSTTRANSLATIONS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_trnspath=$QT_HOST_PREFIX/translations"`
HOSTSETTINGS_PATH_STR=`"$relpath/config.tests/unix/padstring" 268 "qt_stngpath=$QT_INSTALL_SETTINGS"`
@@ -4216,6 +4235,7 @@ static const char qt_configure_headers_path_str [256 + 12] = "$HOSTHEADERS_
static const char qt_configure_libraries_path_str [256 + 12] = "$HOSTLIBRARIES_PATH_STR";
static const char qt_configure_binaries_path_str [256 + 12] = "$HOSTBINARIES_PATH_STR";
static const char qt_configure_plugins_path_str [256 + 12] = "$HOSTPLUGINS_PATH_STR";
+static const char qt_configure_imports_path_str [256 + 12] = "$HOSTIMPORTS_PATH_STR";
static const char qt_configure_data_path_str [256 + 12] = "$HOSTDATA_PATH_STR";
static const char qt_configure_translations_path_str [256 + 12] = "$HOSTTRANSLATIONS_PATH_STR";
static const char qt_configure_settings_path_str [256 + 12] = "$HOSTSETTINGS_PATH_STR";
@@ -4233,6 +4253,7 @@ static const char qt_configure_headers_path_str [256 + 12] = "$HEADERS_PATH
static const char qt_configure_libraries_path_str [256 + 12] = "$LIBRARIES_PATH_STR";
static const char qt_configure_binaries_path_str [256 + 12] = "$BINARIES_PATH_STR";
static const char qt_configure_plugins_path_str [256 + 12] = "$PLUGINS_PATH_STR";
+static const char qt_configure_imports_path_str [256 + 12] = "$IMPORTS_PATH_STR";
static const char qt_configure_data_path_str [256 + 12] = "$DATA_PATH_STR";
static const char qt_configure_translations_path_str [256 + 12] = "$TRANSLATIONS_PATH_STR";
static const char qt_configure_settings_path_str [256 + 12] = "$SETTINGS_PATH_STR";
@@ -4257,6 +4278,7 @@ cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <<EOF
#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;
#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;
#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;
+#define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12;
#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;
#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;
#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;
diff --git a/configure.exe b/configure.exe
index f937ea2899..e310ee07bb 100755
--- a/configure.exe
+++ b/configure.exe
Binary files differ
diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml
index 54af7adb5f..66705e271c 100644
--- a/demos/declarative/calculator/calculator.qml
+++ b/demos/declarative/calculator/calculator.qml
@@ -118,7 +118,7 @@ Rectangle {
}
transitions: Transition {
- NumberAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 }
- NumberAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 }
+ NumberAnimation { properties: "x,y,width"; easing.type: "OutBounce"; duration: 500 }
+ NumberAnimation { properties: "opacity"; easing.type: "InOutQuad"; duration: 500 }
}
}
diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml
index 19cad065e4..f91b365b4c 100644
--- a/demos/declarative/flickr/common/ImageDetails.qml
+++ b/demos/declarative/flickr/common/ImageDetails.qml
@@ -50,7 +50,7 @@ Flipable {
LikeOMeter { x: 40; y: 250; rating: container.rating }
Flickable { id: flickable; x: 220; width: 480; height: 210; y: 130; clip: true
- viewportWidth: 480; viewportHeight: descriptionText.height
+ contentWidth: 480; contentHeight: descriptionText.height
WebView { id: descriptionText; width: parent.width
html: "<style TYPE=\"text/css\">body {color: white;} a:link {color: cyan; text-decoration: underline; }</style>" + container.photoDescription }
@@ -84,7 +84,7 @@ Flipable {
Flickable {
id: flick; width: container.width - 10; height: container.height - 10
x: 5; y: 5; clip: true;
- viewportWidth: imageContainer.width; viewportHeight: imageContainer.height
+ contentWidth: imageContainer.width; contentHeight: imageContainer.height
Item {
id: imageContainer
@@ -122,12 +122,12 @@ Flipable {
id: slider; x: 25; y: 374; visible: { bigImage.status == 1 && maximum > minimum }
onValueChanged: {
if (bigImage.width * value > flick.width) {
- var xoff = (flick.width/2 + flick.viewportX) * value / prevScale;
- flick.viewportX = xoff - flick.width/2;
+ var xoff = (flick.width/2 + flick.contentX) * value / prevScale;
+ flick.contentX = xoff - flick.width/2;
}
if (bigImage.height * value > flick.height) {
- var yoff = (flick.height/2 + flick.viewportY) * value / prevScale;
- flick.viewportY = yoff - flick.height/2;
+ var yoff = (flick.height/2 + flick.contentY) * value / prevScale;
+ flick.contentY = yoff - flick.height/2;
}
prevScale = value;
}
@@ -149,7 +149,7 @@ Flipable {
property: "smooth"
value: false
}
- NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
+ NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 500 }
PropertyAction {
target: bigImage
property: "smooth"
diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml
index 3dfd1f3a5d..9559f6ae1c 100644
--- a/demos/declarative/flickr/common/MediaLineEdit.qml
+++ b/demos/declarative/flickr/common/MediaLineEdit.qml
@@ -42,7 +42,7 @@ Item {
]
transitions: [
Transition {
- NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,width"; duration: 500; easing.type: "InOutQuad" }
}
]
diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml
index 8cd47b461a..748a5ecd87 100644
--- a/demos/declarative/flickr/common/Star.qml
+++ b/demos/declarative/flickr/common/Star.qml
@@ -38,7 +38,7 @@ Item {
Transition {
NumberAnimation {
properties: "opacity,scale,x,y"
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
}
}
]
diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml
index 1ca3cdc8d5..99216cb8da 100644
--- a/demos/declarative/flickr/flickr-desktop.qml
+++ b/demos/declarative/flickr/flickr-desktop.qml
@@ -21,9 +21,9 @@ Item {
angle: wrapper.PathView.angle ? wrapper.PathView.angle : 0
}
- Connection {
- sender: imageDetails; signal: "closed()"
- script: {
+ Connections {
+ target: imageDetails
+ onClosed: {
if (wrapper.state == 'Details') {
wrapper.state = '';
imageDetails.photoUrl = "";
@@ -86,14 +86,14 @@ Item {
from: "*"; to: "Details"
SequentialAnimation {
ParentAction { }
- NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" }
}
},
Transition {
from: "Details"; to: "*"
SequentialAnimation {
ParentAction { }
- NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing.type: "InOutQuad" }
PropertyAction { targets: wrapper; properties: "z" }
}
}
@@ -180,7 +180,7 @@ Item {
transitions: [
Transition {
from: "*"; to: "*"
- NumberAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" }
+ NumberAnimation { properties: "y"; duration: 1000; easing.type: "OutBounce"; easing.amplitude: 0.5 }
}
]
}
diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr-mobile.qml
index 0a89c4fb55..21e4c490c5 100644
--- a/demos/declarative/flickr/flickr-mobile.qml
+++ b/demos/declarative/flickr/flickr-mobile.qml
@@ -38,7 +38,7 @@ Item {
}
transitions: Transition {
- NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; duration: 500; easing.type: "InOutQuad" }
}
}
@@ -53,9 +53,9 @@ Item {
onButton2Clicked: if (screen.inListView == true) screen.inListView = false; else screen.inListView = true
}
- Connection {
- sender: imageDetails; signal: "closed()"
- script: {
+ Connections {
+ target: imageDetails
+ onClosed: {
if (background.state == "DetailedView") {
background.state = '';
imageDetails.photoUrl = "";
@@ -76,7 +76,7 @@ Item {
}
transitions: Transition {
- NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; duration: 500; easing.type: "InOutQuad" }
}
}
}
diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml
index 0f5b69c306..763457392c 100644
--- a/demos/declarative/flickr/mobile/GridDelegate.qml
+++ b/demos/declarative/flickr/mobile/GridDelegate.qml
@@ -23,7 +23,7 @@
Item {
anchors.centerIn: parent
scale: 0.0
- scale: Behavior { NumberAnimation { easing: "easeInOutQuad"} }
+ scale: Behavior { NumberAnimation { easing.type: "InOutQuad"} }
id: scaleMe
Rectangle { height: 79; width: 79; id: blackRect; anchors.centerIn: parent; color: "black"; smooth: true }
@@ -33,9 +33,9 @@
Image { source: "images/gloss.png" }
}
- Connection {
- sender: toolBar; signal: "button2Clicked()"
- script: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show';
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
}
states: [
@@ -55,13 +55,13 @@
Transition {
from: "Show"; to: "Details"
ParentAction { }
- NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" }
},
Transition {
from: "Details"; to: "Show"
SequentialAnimation {
ParentAction { }
- NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" }
PropertyAction { targets: wrapper; properties: "z" }
}
}
diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml
index 1963bf5e20..8749b4c614 100644
--- a/demos/declarative/flickr/mobile/ImageDetails.qml
+++ b/demos/declarative/flickr/mobile/ImageDetails.qml
@@ -57,7 +57,7 @@ Flipable {
Common.Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 }
Flickable {
id: flickable; anchors.fill: parent; clip: true
- viewportWidth: imageContainer.width; viewportHeight: imageContainer.height
+ contentWidth: imageContainer.width; contentHeight: imageContainer.height
Item {
id: imageContainer
@@ -97,12 +97,12 @@ Flipable {
}
onValueChanged: {
if (bigImage.width * value > flickable.width) {
- var xoff = (flickable.width/2 + flickable.viewportX) * value / prevScale;
- flickable.viewportX = xoff - flickable.width/2;
+ var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
}
if (bigImage.height * value > flickable.height) {
- var yoff = (flickable.height/2 + flickable.viewportY) * value / prevScale;
- flickable.viewportY = yoff - flickable.height/2;
+ var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
}
prevScale = value;
}
@@ -117,7 +117,7 @@ Flipable {
transitions: Transition {
SequentialAnimation {
PropertyAction { target: bigImage; property: "smooth"; value: false }
- NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
+ NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 500 }
PropertyAction { target: bigImage; property: "smooth"; value: !flickable.moving }
}
}
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index 07b9762d3b..0a06771df0 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -71,6 +71,6 @@ Item {
}
transitions: Transition {
- NumberAnimation { properties: "x"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad" }
}
}
diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp
index 0b862e3546..0e99731cf0 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>
@@ -92,7 +92,6 @@ private:
};
QML_DECLARE_TYPE(Tile);
-QML_DEFINE_TYPE(0,0,0,Tile,Tile);
class MyWidget : public QWidget
{
@@ -134,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;
@@ -163,17 +162,15 @@ 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);
- canvas->setSource(QUrl::fromLocalFile(fileName));
-
- QmlContext *ctxt = canvas->rootContext();
+ QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->addDefaultObject(this);
ctxt->setContextProperty("tiles", QVariant::fromValue<QList<Tile*>*>(&_tiles));//QTBUG-5675
- canvas->execute();
+ canvas->setSource(QUrl::fromLocalFile(fileName));
}
MyWidget::~MyWidget()
@@ -323,6 +320,8 @@ int main(int argc, char ** argv)
int width = 370;
int height = 480;
+ QML_REGISTER_TYPE(0,0,0,Tile,Tile);
+
for (int i = 1; i < argc; ++i) {
QString arg = argv[i];
if (arg == "-frameless") {
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index 92555c2048..617a6ed1eb 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -92,7 +92,7 @@ Item {
}
}
NumberAnimation {
- easing: "easeInOutQuad"
+ easing.type: "InOutQuad"
properties: "angle"
}
ScriptAction{
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 3bec7477ff..09b6b7fa89 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -172,14 +172,14 @@ Rectangle {
states: [
State {
name: "starting"
- when: startHeartbeatTimer.running;
+ when: startHeartbeatTimer.running
PropertyChanges {target: progressIndicator; width: 200}
PropertyChanges {target: title; opacity: 0}
PropertyChanges {target: progressBar; opacity: 1}
},
State {
name: "running"
- when: heartbeat.running
+ when: (heartbeat.running && !startHeartbeatTimer.running)
PropertyChanges {target: progressIndicator; width: 200}
PropertyChanges {target: title; opacity: 0}
PropertyChanges {target: skull; row: 0; column: 0; }
diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml
index 8054f2e52c..a206c87524 100644
--- a/demos/declarative/twitter/content/HomeTitleBar.qml
+++ b/demos/declarative/twitter/content/HomeTitleBar.qml
@@ -115,7 +115,7 @@ Item {
transitions: [
Transition {
from: "*"; to: "*"
- NumberAnimation { properties: "x,y,width,height"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,width,height"; easing.type: "InOutQuad" }
}
]
}
diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/content/MultiTitleBar.qml
index ef7de65a3e..e0205b8097 100644
--- a/demos/declarative/twitter/content/MultiTitleBar.qml
+++ b/demos/declarative/twitter/content/MultiTitleBar.qml
@@ -18,7 +18,7 @@ Item {
}
]
transitions: [
- Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } }
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" } }
]
}
diff --git a/demos/declarative/twitter/content/TitleBar.qml b/demos/declarative/twitter/content/TitleBar.qml
index 42a6115b68..149aa8268f 100644
--- a/demos/declarative/twitter/content/TitleBar.qml
+++ b/demos/declarative/twitter/content/TitleBar.qml
@@ -72,6 +72,6 @@ Item {
}
transitions: Transition {
- NumberAnimation { properties: "x"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad" }
}
}
diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml
index d2abf28688..b091b031a0 100644
--- a/demos/declarative/twitter/twitter.qml
+++ b/demos/declarative/twitter/twitter.qml
@@ -89,7 +89,7 @@ Item {
}
]
transitions: [
- Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } }
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: "InOutQuad" } }
]
}
}
diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml
index 7c46d4c8d4..76a5813f6e 100644
--- a/demos/declarative/webbrowser/content/FlickableWebView.qml
+++ b/demos/declarative/webbrowser/content/FlickableWebView.qml
@@ -2,6 +2,7 @@ import Qt 4.6
Flickable {
property alias title: webView.title
+ property alias icon: webView.icon
property alias progress: webView.progress
property alias url: webView.url
property alias back: webView.back
@@ -10,8 +11,8 @@ Flickable {
id: flickable
width: parent.width
- viewportWidth: Math.max(parent.width,webView.width*webView.scale)
- viewportHeight: Math.max(parent.height,webView.height*webView.scale)
+ contentWidth: Math.max(parent.width,webView.width*webView.scale)
+ contentHeight: Math.max(parent.height,webView.height*webView.scale)
anchors.top: headerSpace.bottom
anchors.bottom: footer.top
anchors.left: parent.left
@@ -53,10 +54,10 @@ Flickable {
if (centerX) {
var sc = zoom/contentsScale;
scaleAnim.to = sc;
- flickVX.from = flickable.viewportX
+ flickVX.from = flickable.contentX
flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width))
finalX.value = flickVX.to
- flickVY.from = flickable.viewportY
+ flickVY.from = flickable.contentY
flickVY.to = Math.max(0,Math.min(centerY-flickable.height/2,webView.height*sc-flickable.height))
finalY.value = flickVY.to
finalZoom.value = zoom
@@ -76,8 +77,8 @@ Flickable {
}
onUrlChanged: {
// got to topleft
- flickable.viewportX = 0
- flickable.viewportY = 0
+ flickable.contentX = 0
+ flickable.contentY = 0
if (url != null) { header.editUrl = url.toString(); }
}
onDoubleClick: {
@@ -104,14 +105,14 @@ Flickable {
property: "scale"
from: 1
to: 0 // set before calling
- easing: "easeLinear"
+ easing.type: "Linear"
duration: 200
}
NumberAnimation {
id: flickVX
target: flickable
- property: "viewportX"
- easing: "easeLinear"
+ property: "contentX"
+ easing.type: "Linear"
duration: 200
from: 0 // set before calling
to: 0 // set before calling
@@ -119,8 +120,8 @@ Flickable {
NumberAnimation {
id: flickVY
target: flickable
- property: "viewportY"
- easing: "easeLinear"
+ property: "contentY"
+ easing.type: "Linear"
duration: 200
from: 0 // set before calling
to: 0 // set before calling
@@ -136,19 +137,19 @@ Flickable {
property: "scale"
value: 1.0
}
- // Have to set the viewportXY, since the above 2
+ // Have to set the contentXY, since the above 2
// size changes may have started a correction if
// contentsScale < 1.0.
PropertyAction {
id: finalX
target: flickable
- property: "viewportX"
+ property: "contentX"
value: 0 // set before calling
}
PropertyAction {
id: finalY
target: flickable
- property: "viewportY"
+ property: "contentY"
value: 0 // set before calling
}
PropertyAction {
diff --git a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml
index e58ab0a492..94c94f255b 100644
--- a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml
+++ b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml
@@ -9,35 +9,44 @@ Image {
source: "pics/header.png"
width: parent.width
height: 60
- x: webView.viewportX < 0 ? -webView.viewportX : webView.viewportX > webView.viewportWidth-webView.width
- ? -webView.viewportX+webView.viewportWidth-webView.width : 0
- y: webView.viewportY < 0 ? -webView.viewportY : progressOff*
- (webView.viewportY>height?-height:-webView.viewportY)
- Text {
- id: headerText
-
- text: webView.title!='' || webView.progress == 1.0 ? webView.title : 'Loading...'
- elide: Text.ElideRight
-
- color: "white"
- styleColor: "black"
- style: Text.Raised
-
- font.family: "Helvetica"
- font.pointSize: 10
- font.bold: true
-
- anchors.left: header.left
- anchors.right: header.right
- anchors.leftMargin: 4
- anchors.rightMargin: 4
+ x: webView.contentX < 0 ? -webView.contentX : webView.contentX > webView.contentWidth-webView.width
+ ? -webView.contentX+webView.contentWidth-webView.width : 0
+ y: webView.contentY < 0 ? -webView.contentY : progressOff*
+ (webView.contentY>height?-height:-webView.contentY)
+ Row {
+ id: headerTitle
+
anchors.top: header.top
anchors.topMargin: 4
- horizontalAlignment: Text.AlignHCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ spacing: 6
+
+ Image {
+ id: headerIcon
+ pixmap: webView.icon
+ }
+
+ Text {
+ id: headerText
+
+ text: webView.title!='' || webView.progress == 1.0 ? webView.title : 'Loading...'
+ elide: Text.ElideRight
+ //width: parent.width - headerIcon.width-4
+
+ color: "white"
+ styleColor: "black"
+ style: Text.Raised
+
+ font.family: "Helvetica"
+ font.pointSize: 10
+ font.bold: true
+
+ horizontalAlignment: Text.AlignHCenter
+ }
}
Item {
width: parent.width
- anchors.top: headerText.bottom
+ anchors.top: headerTitle.bottom
anchors.topMargin: 2
anchors.bottom: parent.bottom
@@ -98,7 +107,7 @@ Image {
NumberAnimation {
targets: header
properties: "progressOff"
- easing: "easeInOutQuad"
+ easing.type: "InOutQuad"
duration: 300
}
}
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 934593c7be..6a427f42d1 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -30,10 +30,10 @@ Item {
anchors.bottom: footer.top
}
RectSoftShadow {
- x: -webView.viewportX
- y: -webView.viewportY
- width: webView.viewportWidth
- height: webView.viewportHeight+headerSpace.height
+ x: -webView.contentX
+ y: -webView.contentY
+ width: webView.contentWidth
+ height: webView.contentHeight+headerSpace.height
}
Item {
id: headerSpace
@@ -98,7 +98,7 @@ Item {
Transition {
NumberAnimation {
properties: "opacity"
- easing: "easeInOutQuad"
+ easing.type: "InOutQuad"
duration: 300
}
}
@@ -154,7 +154,7 @@ Item {
Transition {
NumberAnimation {
properties: "opacity"
- easing: "easeInOutQuad"
+ easing.type: "InOutQuad"
duration: 320
}
}
diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp
index 8714b9c5a1..fa9c586ac1 100644
--- a/demos/embedded/desktopservices/contenttab.cpp
+++ b/demos/embedded/desktopservices/contenttab.cpp
@@ -114,20 +114,6 @@ QUrl ContentTab::itemUrl(QListWidgetItem *item)
void ContentTab::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
- case Qt::Key_Up:
- if (currentRow() == 0) {
- setCurrentRow(count() - 1);
- } else {
- setCurrentRow(currentRow() - 1);
- }
- break;
- case Qt::Key_Down:
- if (currentRow() == (count() - 1)) {
- setCurrentRow(0);
- } else {
- setCurrentRow(currentRow() + 1);
- }
- break;
case Qt::Key_Select:
openItem(currentItem());
default:
diff --git a/doc/doc.pri b/doc/doc.pri
index 0fc4d722dc..aea5b08b8d 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 d80c3fa709..2b75211753 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
@@ -72,9 +72,9 @@ Rectangle {
y: 0
y: SequentialAnimation {
repeat: true
- NumberAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 }
+ NumberAnimation { to: 200-img.height; easing.type: "OutBounce"; duration: 2000 }
PauseAnimation { duration: 1000 }
- NumberAnimation { to: 0; easing: "easeOutQuad"; duration: 1000 }
+ NumberAnimation { to: 0; easing.type: "OutQuad"; duration: 1000 }
}
}
}
@@ -135,7 +135,7 @@ transitions: [
Transition {
NumberAnimation {
properties: "x,y"
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
duration: 200
}
}
@@ -156,7 +156,7 @@ Transition {
SequentialAnimation {
NumberAnimation {
duration: 1000
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
// animate myItem's x and y if they have changed in the state
target: myItem
properties: "x,y"
@@ -198,7 +198,7 @@ Transition {
ParallelAnimation {
NumberAnimation {
duration: 1000
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
targets: box1
properties: "x,y"
}
@@ -226,7 +226,7 @@ Rectangle {
id: redRect
color: "red"
width: 100; height: 100
- x: Behavior { NumberAnimation { duration: 300; easing: "InOutQuad" } }
+ x: Behavior { NumberAnimation { duration: 300; easing.type: "InOutQuad" } }
}
\endqml
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index a26081211b..c60847e266 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 1129f004c6..4b61bd95cb 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 7a489c0a8a..033c0d19a2 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 682a2ac487..1fd4dadbe5 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
@@ -88,6 +88,8 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l Binding
\o \l ListModel, \l ListElement
\o \l VisualItemModel
+\o \l VisualDataModel
+\o \l Package
\o \l XmlListModel and XmlRole
\o \l DateTimeFormatter
\o \l NumberFormatter
@@ -96,7 +98,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o
\list
\o \l Script
-\o \l Connection
+\o \l Connections
\o \l Component
\o \l Timer
\o \l QtObject
diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc
index d1b106677f..42351c53f4 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 04787319d3..b7da508213 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 b84ae0e19c..cc668385a7 100644
--- a/doc/src/declarative/extending-examples.qdoc
+++ b/doc/src/declarative/extending-examples.qdoc
@@ -69,7 +69,7 @@ Q_DECLARE_METATYPE() functionality.
The Person class implementation is quite basic. The property accessors simply
return members of the object instance.
-The implementation must also include the QML_DEFINE_TYPE() macro. This macro
+The implementation must also be registered using the QML_REGISTER_TYPE() macro. This macro
registers the Person class with QML as a type in the People library version 1.0,
and defines the mapping between the C++ and QML class names.
@@ -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
@@ -160,13 +160,13 @@ previous example. However, as we have repurposed the People class as a common
base for Boy and Girl, we want to prevent it from being instantiated from QML
directly - an explicit Boy or Girl should be instantiated instead.
-\snippet examples/declarative/extending/coercion/person.cpp 0
+\snippet examples/declarative/extending/coercion/main.cpp 0
While we want to disallow instantiating Person from within QML, it still needs
to be registered with the QML engine, so that it can be used as a property type
and other types can be coerced to it. To register a type, without defining a
-named mapping into QML, we use the QML_DEFINE_NOCREATE_TYPE() macro instead of
-the QML_DEFINE_TYPE() macro used previously.
+named mapping into QML, we call the QML_REGISTER_NOCREATE_TYPE() macro instead of
+the QML_REGISTER_TYPE() macro used previously.
\section2 Define Boy and Girl
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 0456f3fd80..5aaa7bdc2a 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -72,24 +72,23 @@ Custom C++ types are made available to QML using these two macros:
\quotation
\code
#define QML_DECLARE_TYPE(T)
-#define QML_DEFINE_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_DEFINE_TYPE()
-macro in the implementation file. QML_DEFINE_TYPE() must not be present in
-a header file.
+the type declaration (usually in its header file), and the QML_REGISTER_TYPE()
+macro called by the implementation.
Type \a T must be a concrete type that inherits QObject and has a default
constructor.
\endquotation
Types can be registered by libraries (such as Qt does), application code,
-or by plugins (see QmlModulePlugin).
+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
@@ -153,15 +152,14 @@ from registering a new QML type. The following macros are used instead:
\quotation
\code
#define QML_DECLARE_INTERFACE(T)
- #define QML_DEFINE_INTERFACE(T)
+ #define QML_REGISTER_INTERFACE(T)
\endcode
Register the C++ interface \a T with the QML system.
Generally the QML_DECLARE_INTERFACE() macro should be included immediately
following the interface declaration (usually in its header file), and the
-QML_DEFINE_INTERFACE() macro in an implementation file. QML_DEFINE_INTERFACE()
-must not be present in a header file.
+QML_REGISTER_INTERFACE() macro called by the implementation.
Following registration, QML can coerce objects that implement this interface
for assignment to appropriately typed properties.
@@ -169,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:
@@ -194,7 +192,7 @@ type used in the previous section, but the assignment is valid as both the Boy
and Girl objects inherit from Person.
To assign to a property, the property's type must have been registered with QML.
-Both the QML_DEFINE_TYPE() and QML_DEFINE_INTERFACE() macros already shown can
+Both the QML_REGISTER_TYPE() and QML_REGISTER_INTERFACE() macros already shown can
be used to register a type with QML. Additionally, if a type that acts purely
as a base class that cannot be instantiated from QML needs to be
registered these macros can be used:
@@ -202,18 +200,17 @@ registered these macros can be used:
\quotation
\code
#define QML_DECLARE_TYPE(T)
- #define QML_DEFINE_NOCREATE_TYPE(T)
+ #define QML_REGISTER_NOCREATE_TYPE(T)
\endcode
-Register the C++ type \a T with the QML system. QML_DEFINE_NOCREATE_TYPE()
-differs from QML_DEFINE_TYPE() in that it does not define a mapping between the
+Register the C++ type \a T with the QML system. QML_REGISTER_NOCREATE_TYPE()
+differs from QML_REGISTER_TYPE() in that it does not define a mapping between the
C++ class and a QML element name, so the type is not instantiable from QML, but
it is available for type coercion.
Generally the QML_DECLARE_TYPE() macro should be included immediately following
the type declaration (usually in its header file), and the
-QML_DEFINE_NOCREATE_TYPE() macro in the implementation file.
-QML_DEFINE_NOCREATE_TYPE() must not be present in a header file.
+QML_REGISTER_NOCREATE_TYPE() macro called from the implementation.
Type \a T must inherit QObject, but there are no restrictions on whether it is
concrete or the signature of its constructor.
@@ -375,6 +372,37 @@ object will only be returned if it has previously been created.
\l {Extending QML - Attached Properties Example} shows the complete code used to
implement the rsvp attached property.
+\section1 Memory Management and QVariant types
+
+It is an elements responsibility to ensure that it does not access or return
+pointers to invalid objects. QML makes the following guarentees:
+
+\list
+\o An object assigned to an QObject (or QObject-derived) pointer property will be
+valid at the time of assignment.
+
+Following assignment, it is the responsibility of the class to subsequently guard
+this pointer, either through a class specific method or the generic QPointer class.
+
+\o An object assigned to a QVariant will be valid at the time of assignment.
+
+When assigning an object to a QVariant property, QML will always use a QMetaType::QObjectStar
+typed QVariant. It is the responsibility of the class to guard the pointer. A
+general rule when writing a class that uses QVariant properties is to check the
+type of the QVariant when it is set and if the type is not handled by your class,
+reset it to an invalid variant.
+
+\o An object assigned to a QObject (or QObject-derived) list property will be
+valid at the time of assignment.
+
+Following assignment, it is the responsibility of the class to subsequently guard
+this pointer, either through a class specific method or the generic QPointer class.
+\endlist
+
+Elements should assume that any QML assigned object can be deleted at any time, and
+respond accordingly. If documented as such an element need not continue to work in
+this situation, but it must not crash.
+
\section1 Signal Support
\snippet examples/declarative/extending/signal/example.qml 0
@@ -393,9 +421,8 @@ C++ signature:
\snippet examples/declarative/extending/signal/birthdayparty.h 0
In classes with multiple signals with the same name, only the final signal
-is accessible as a signal property. Although QML provides an element,
-\l Connection, for accessing the other signals it is less elegant. For the best
-QML API, class developers should avoid overloading signal names.
+is accessible as a signal property. Note that signals with the same name
+but different parameters cannot be distinguished.
Signal parameters become accessible by name to the assigned script. An
unnamed parameter cannot be accessed, so care should be taken to name all the
@@ -433,8 +460,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:
@@ -526,18 +553,6 @@ to be used in bindings should have a NOTIFY signal instead.
\l {Extending QML - Binding Example} shows the BirthdayParty example updated to
include NOTIFY signals for use in binding.
-\section1 Binding and Script Properties
-
-While generally no changes are needed to a C++ class to use property
-binding, sometimes more advanced interaction between the binding engine and
-an object is desirable. To facilitate this, there is a special exception
-in the bind engine for allowing an object to access the binding directly.
-
-If a binding is assigned to a property with a type of QmlBinding
-pointer (ie. \c {QmlBinding *}), each time the binding value changes,
-a QmlBinding instance is assigned to that property. The QmlBinding instance
-allows the object to read the binding and to evaluate the binding's current value.
-
\section1 Extension Objects
\snippet examples/declarative/extending/extended/example.qml 0
@@ -566,11 +581,11 @@ the appropriate property on the extension object is used instead.
When an extended type is installed, one of the
\code
- #define QML_DEFINE_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QmlName,T, ExtendedT)
- #define QML_DEFINE_EXTENDED_NOCREATE_TYPE(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_DEFINE_TYPE or
-\c QML_DEFINE_NOCREATE_TYPE. The arguments are identical to the corresponding
+macros should be used instead of the regular \c QML_REGISTER_TYPE or
+\c QML_REGISTER_NOCREATE_TYPE. The arguments are identical to the corresponding
non-extension object macro, except for the ExtendedT parameter which is the type
of the extension object.
@@ -581,18 +596,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 6459a2e856..d7e890ce7f 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 fb336645d8..c718a6d3a3 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 b3d6306c57..c685d3d084 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 cde8eb8dcf..98183bbac8 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 8f6fe7db7b..cb608bf343 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 b2fd14903d..ab75f8daa6 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 QmlModulePlugin. 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 fc4761e0ba..e642257469 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 0000000000..3ef9ce7188
--- /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 0000000000..a210c98f14
--- /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 0000000000..9c10a46b6f
--- /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 0000000000..4d05a8ce8b
--- /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 0000000000..c0e028e2cc
--- /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 0000000000..01af7f5c88
--- /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 0000000000..0fea6f8cfa
--- /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 56bd7d2d66..0000000000
--- 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 977b4acafc..0000000000
--- 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 0803d6c851..0000000000
--- 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 b353e44978..0000000000
--- 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 4843a7b45c..0000000000
--- 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 107d5796c5..0000000000
--- 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 0000000000..6d3e10937b
--- /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 2118c2b998..0000000000
--- 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 c2b29d36ae..0000000000
--- 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 732ff86a39..66d537d116 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 343359cf58..ca1d596e83 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 f7093352fd..218af895e4 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/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc
index 6406193609..36bfcfeb42 100644
--- a/doc/src/development/qmake-manual.qdoc
+++ b/doc/src/development/qmake-manual.qdoc
@@ -1727,8 +1727,15 @@ distinction between shared and
\snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 139
+ There is also a convenience function for adding conditional rules
+ called \c{addMMPRules}. Suppose you need certain functionality
+ to require different library depending on architecture. This
+ can be specified with \c{addMMPRules} as follows:
+
+ \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 148
+
\note You should not use this variable to add MMP statements that are
- explicitly supported by their own variables, such as
+ explicitly supported by their own variables, such as
\c TARGET.EPOCSTACKSIZE.
Doing so could result in duplicate statements in the MMP file.
diff --git a/doc/src/examples/scribble.qdoc b/doc/src/examples/scribble.qdoc
index 3c6d1361db..5c664101df 100644
--- a/doc/src/examples/scribble.qdoc
+++ b/doc/src/examples/scribble.qdoc
@@ -74,9 +74,8 @@
\o \c MainWindow provides a menu above the \c ScribbleArea.
\endlist
- We will start by reviewing the \c ScribbleArea class, which
- contains the interesting, then we will take a look at the \c
- MainWindow class that uses it.
+ We will start by reviewing the \c ScribbleArea class. Then we will
+ review the \c MainWindow class, which uses \c ScribbleArea.
\section1 ScribbleArea Class Definition
diff --git a/doc/src/files-and-resources/datastreamformat.qdoc b/doc/src/files-and-resources/datastreamformat.qdoc
index 1c2d8875cc..bab2c2c3e0 100644
--- a/doc/src/files-and-resources/datastreamformat.qdoc
+++ b/doc/src/files-and-resources/datastreamformat.qdoc
@@ -47,7 +47,7 @@
The \l QDataStream allows you to serialize some of the Qt data types.
The table below lists the data types that QDataStream can serialize
and how they are represented. The format described below is
- \l{QDataStream::setVersion()}{version 8}.
+ \l{QDataStream::setVersion()}{version 12}.
It is always best to cast integers to a Qt integer type, such as
qint16 or quint32, when reading and writing. This ensures that
@@ -57,9 +57,9 @@
\table
\row \o bool
- \o \list
- \o boolean
- \endlist
+ \o \list
+ \o boolean
+ \endlist
\row \o qint8
\o \list
\o signed byte
@@ -145,6 +145,17 @@
\o Time (QTime)
\o 0 for Qt::LocalTime, 1 for Qt::UTC (quint8)
\endlist
+ \row \o QEasingCurve
+ \o \list
+ \o type (quint8)
+ \o func (quint64)
+ \o hasConfig (bool)
+ \o If hasConfig is true then these fields follow:
+ \o list
+ \o period (double)
+ \o amplitude (double)
+ \o overshoot (double)
+ \endlist
\row \o QFont
\o \list
\o The family (QString)
diff --git a/doc/src/platforms/emb-directfb-EmbLinux.qdoc b/doc/src/platforms/emb-directfb-EmbLinux.qdoc
index 74f2aaa82e..9e060f8dff 100644
--- a/doc/src/platforms/emb-directfb-EmbLinux.qdoc
+++ b/doc/src/platforms/emb-directfb-EmbLinux.qdoc
@@ -267,7 +267,8 @@ perform well.
\o QT_NO_DIRECTFB_IMAGEPROVIDER
\o By default Qt will use DirectFB to load QPixmaps from disk/memory. If
your DirectFB implementation does not support this it might make sense to
-define this.
+define this. If you see strange rendering issues with pixmaps that have an
+alpha channel defining this could solve the problem.
\row
\o QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
@@ -327,4 +328,9 @@ QT_DIRECTFB_DISABLE_RASTERFALLBACKS is defined, DirectFB will only return
instead of falling back to QRasterPaintEngine. Please note that these
defines should only be used when optimizing the application.
+\section2 Top level transparency
+\note DirectFB supports partially or fully transparent top level windows,
+either through QWidget::setWindowOpacity or through setting a non-opaque
+background brush. Note that for the latter it is not supported to change an
+opaque window to be transparent at runtime.
*/
diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc
index a48b53f854..5a04420ff6 100644
--- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc
+++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc
@@ -969,3 +969,16 @@ DEPLOYMENT.installer_header = 0x12345678
//! [147]
DEPLOYMENT.installer_header = "$${LITERAL_HASH}{\"My Application Installer\"},(0x12345678),1,0,0"
//! [147]
+
+//! [148]
+# Set conditional libraries
+LIB.MARM = "LIBRARY myarm.lib"
+LIB.WINSCW = "LIBRARY mywinscw.lib"
+LIB.default = "LIBRARY mydefault.lib"
+
+# Add the conditional MMP rules
+MYCONDITIONS = MARM WINSCW
+MYVARIABLES = LIB
+
+addMMPRules(MYCONDITIONS, MYVARIABLES)
+//! [148]
diff --git a/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp b/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp
index c068ba9521..4158388025 100644
--- a/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp
+++ b/doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp
@@ -128,7 +128,7 @@ private:
QScopedPointer<int, QScopedPointerArrayDeleter<int> > arrayPointer(new int[42]);
// this QScopedPointer frees its data using free():
-QScopedPointer<int, QScopedPointerPodDeleter<int> > podPointer(reinterpret_cast<int *>(malloc(42)));
+QScopedPointer<int, QScopedPointerPodDeleter> podPointer(reinterpret_cast<int *>(malloc(42)));
// this struct calls "myCustomDeallocator" to delete the pointer
struct ScopedPointerCustomDeleter
diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml
index 9b5bcc6c76..8f2655e5a7 100644
--- a/examples/declarative/animations/easing.qml
+++ b/examples/declarative/animations/easing.qml
@@ -6,47 +6,47 @@ Rectangle {
ListModel {
id: easingTypes
- ListElement { type: "easeLinear"; ballColor: "DarkRed" }
- ListElement { type: "easeInQuad"; ballColor: "IndianRed" }
- ListElement { type: "easeOutQuad"; ballColor: "Salmon" }
- ListElement { type: "easeInOutQuad"; ballColor: "Tomato" }
- ListElement { type: "easeOutInQuad"; ballColor: "DarkOrange" }
- ListElement { type: "easeInCubic"; ballColor: "Gold" }
- ListElement { type: "easeOutCubic"; ballColor: "Yellow" }
- ListElement { type: "easeInOutCubic"; ballColor: "PeachPuff" }
- ListElement { type: "easeOutInCubic"; ballColor: "Thistle" }
- ListElement { type: "easeInQuart"; ballColor: "Orchid" }
- ListElement { type: "easeOutQuart"; ballColor: "Purple" }
- ListElement { type: "easeInOutQuart"; ballColor: "SlateBlue" }
- ListElement { type: "easeOutInQuart"; ballColor: "Chartreuse" }
- ListElement { type: "easeInQuint"; ballColor: "LimeGreen" }
- ListElement { type: "easeOutQuint"; ballColor: "SeaGreen" }
- ListElement { type: "easeInOutQuint"; ballColor: "DarkGreen" }
- ListElement { type: "easeOutInQuint"; ballColor: "Olive" }
- ListElement { type: "easeInSine"; ballColor: "DarkSeaGreen" }
- ListElement { type: "easeOutSine"; ballColor: "Teal" }
- ListElement { type: "easeInOutSine"; ballColor: "Turquoise" }
- ListElement { type: "easeOutInSine"; ballColor: "SteelBlue" }
- ListElement { type: "easeInExpo"; ballColor: "SkyBlue" }
- ListElement { type: "easeOutExpo"; ballColor: "RoyalBlue" }
- ListElement { type: "easeInOutExpo"; ballColor: "MediumBlue" }
- ListElement { type: "easeOutInExpo"; ballColor: "MidnightBlue" }
- ListElement { type: "easeInCirc"; ballColor: "CornSilk" }
- ListElement { type: "easeOutCirc"; ballColor: "Bisque" }
- ListElement { type: "easeInOutCirc"; ballColor: "RosyBrown" }
- ListElement { type: "easeOutInCirc"; ballColor: "SandyBrown" }
- ListElement { type: "easeInElastic"; ballColor: "DarkGoldenRod" }
- ListElement { type: "easeOutElastic"; ballColor: "Chocolate" }
- ListElement { type: "easeInOutElastic"; ballColor: "SaddleBrown" }
- ListElement { type: "easeOutInElastic"; ballColor: "Brown" }
- ListElement { type: "easeInBack"; ballColor: "Maroon" }
- ListElement { type: "easeOutBack"; ballColor: "LavenderBlush" }
- ListElement { type: "easeInOutBack"; ballColor: "MistyRose" }
- ListElement { type: "easeOutInBack"; ballColor: "Gainsboro" }
- ListElement { type: "easeOutBounce"; ballColor: "Silver" }
- ListElement { type: "easeInBounce"; ballColor: "DimGray" }
- ListElement { type: "easeInOutBounce"; ballColor: "SlateGray" }
- ListElement { type: "easeOutInBounce"; ballColor: "DarkSlateGray" }
+ ListElement { type: "Linear"; ballColor: "DarkRed" }
+ ListElement { type: "InQuad"; ballColor: "IndianRed" }
+ ListElement { type: "OutQuad"; ballColor: "Salmon" }
+ ListElement { type: "InOutQuad"; ballColor: "Tomato" }
+ ListElement { type: "OutInQuad"; ballColor: "DarkOrange" }
+ ListElement { type: "InCubic"; ballColor: "Gold" }
+ ListElement { type: "OutCubic"; ballColor: "Yellow" }
+ ListElement { type: "InOutCubic"; ballColor: "PeachPuff" }
+ ListElement { type: "OutInCubic"; ballColor: "Thistle" }
+ ListElement { type: "InQuart"; ballColor: "Orchid" }
+ ListElement { type: "OutQuart"; ballColor: "Purple" }
+ ListElement { type: "InOutQuart"; ballColor: "SlateBlue" }
+ ListElement { type: "OutInQuart"; ballColor: "Chartreuse" }
+ ListElement { type: "InQuint"; ballColor: "LimeGreen" }
+ ListElement { type: "OutQuint"; ballColor: "SeaGreen" }
+ ListElement { type: "InOutQuint"; ballColor: "DarkGreen" }
+ ListElement { type: "OutInQuint"; ballColor: "Olive" }
+ ListElement { type: "InSine"; ballColor: "DarkSeaGreen" }
+ ListElement { type: "OutSine"; ballColor: "Teal" }
+ ListElement { type: "InOutSine"; ballColor: "Turquoise" }
+ ListElement { type: "OutInSine"; ballColor: "SteelBlue" }
+ ListElement { type: "InExpo"; ballColor: "SkyBlue" }
+ ListElement { type: "OutExpo"; ballColor: "RoyalBlue" }
+ ListElement { type: "InOutExpo"; ballColor: "MediumBlue" }
+ ListElement { type: "OutInExpo"; ballColor: "MidnightBlue" }
+ ListElement { type: "InCirc"; ballColor: "CornSilk" }
+ ListElement { type: "OutCirc"; ballColor: "Bisque" }
+ ListElement { type: "InOutCirc"; ballColor: "RosyBrown" }
+ ListElement { type: "OutInCirc"; ballColor: "SandyBrown" }
+ ListElement { type: "InElastic"; ballColor: "DarkGoldenRod" }
+ ListElement { type: "OutElastic"; ballColor: "Chocolate" }
+ ListElement { type: "InOutElastic"; ballColor: "SaddleBrown" }
+ ListElement { type: "OutInElastic"; ballColor: "Brown" }
+ ListElement { type: "InBack"; ballColor: "Maroon" }
+ ListElement { type: "OutBack"; ballColor: "LavenderBlush" }
+ ListElement { type: "InOutBack"; ballColor: "MistyRose" }
+ ListElement { type: "OutInBack"; ballColor: "Gainsboro" }
+ ListElement { type: "OutBounce"; ballColor: "Silver" }
+ ListElement { type: "InBounce"; ballColor: "DimGray" }
+ ListElement { type: "InOutBounce"; ballColor: "SlateGray" }
+ ListElement { type: "OutInBounce"; ballColor: "DarkSlateGray" }
}
Component {
@@ -80,8 +80,8 @@ Rectangle {
transitions: Transition {
ParallelAnimation {
- NumberAnimation { properties: "x"; easing: type; duration: 1000 }
- ColorAnimation { properties: "color"; easing: type; duration: 1000 }
+ NumberAnimation { properties: "x"; easing.type: type; duration: 1000 }
+ ColorAnimation { properties: "color"; easing.type: type; duration: 1000 }
}
}
}
@@ -89,7 +89,7 @@ Rectangle {
}
Flickable {
- anchors.fill: parent; viewportHeight: layout.height
+ anchors.fill: parent; contentHeight: layout.height
Column {
id: layout
anchors.left: parent.left; anchors.right: parent.right
diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml
index 9f76ee5b0c..537ee2685d 100644
--- a/examples/declarative/animations/property-animation.qml
+++ b/examples/declarative/animations/property-animation.qml
@@ -45,16 +45,16 @@ Item {
y: SequentialAnimation {
repeat: true
- // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
NumberAnimation {
from: smiley.minHeight; to: smiley.maxHeight
- easing: "easeOutExpo"; duration: 300
+ easing.type: "OutExpo"; duration: 300
}
- // Then move back to minHeight in 1 second, using the easeOutBounce easing function
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
NumberAnimation {
from: smiley.maxHeight; to: smiley.minHeight
- easing: "easeOutBounce"; duration: 1000
+ easing.type: "OutBounce"; duration: 1000
}
// Then pause for 500ms
diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml
index fc3f4bf33c..8fffd598c0 100644
--- a/examples/declarative/behaviours/test.qml
+++ b/examples/declarative/behaviours/test.qml
@@ -64,7 +64,8 @@ Rectangle {
property: "y"
from: 0
to: 10
- easing: "easeOutBounce(amplitude:30)"
+ easing.type: "OutBounce"
+ easing.amplitude: 30
duration: 250
}
NumberAnimation {
@@ -72,7 +73,8 @@ Rectangle {
property: "y"
from: 10
to: 0
- easing: "easeOutBounce(amplitude:30)"
+ easing.type: "OutBounce"
+ easing.amplitude: 30
duration: 250
}
}
diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml
index a57acc74f1..ca886e9c89 100644
--- a/examples/declarative/border-image/content/MyBorderImage.qml
+++ b/examples/declarative/border-image/content/MyBorderImage.qml
@@ -19,14 +19,14 @@ Item {
width: SequentialAnimation {
repeat: true
- NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing: "easeInOutQuad" }
+ NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" }
}
height: SequentialAnimation {
repeat: true
- NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" }
+ NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" }
}
border.top: container.margin
diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml
index 07f71bbab3..46923431e0 100644
--- a/examples/declarative/connections/connections.qml
+++ b/examples/declarative/connections/connections.qml
@@ -5,16 +5,12 @@ Rectangle {
id: window; color: "#646464"
width: 640; height: 480
- function turnLeft() {
- image.rotation -= 90
- }
- function turnRight() {
- image.rotation += 90
- }
+ property int angle: 0
Image {
id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center
- rotation: Behavior { NumberAnimation { easing: "easeOutCubic"; duration: 300 } }
+ rotation: window.angle
+ rotation: Behavior { NumberAnimation { easing.type: "OutCubic"; duration: 300 } }
}
Button {
@@ -26,6 +22,6 @@ Rectangle {
anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 }
}
- Connection { sender: leftButton; signal: "clicked()"; script: window.turnLeft() }
- Connection { sender: rightButton; signal: "clicked()"; script: window.turnRight() }
+ Connections { target: leftButton; onClicked: window.angle -= 90 }
+ Connections { target: rightButton; onClicked: window.angle += 90 }
}
diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp
index 74ea35ca34..76e0736157 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"
@@ -48,8 +48,10 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, Person, Person);
+
+ 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.cpp b/examples/declarative/extending/adding/person.cpp
index 9efa2b81c1..cdf08e0281 100644
--- a/examples/declarative/extending/adding/person.cpp
+++ b/examples/declarative/extending/adding/person.cpp
@@ -66,5 +66,4 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-QML_DEFINE_TYPE(People, 1,0, Person, Person);
// ![0]
diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h
index 691766b77e..fbaf2df2cf 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 ffdda571a2..d4f2675b6b 100644
--- a/examples/declarative/extending/attached/birthdayparty.cpp
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -55,8 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
-
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
{
@@ -72,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
@@ -92,4 +90,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h
index 9ba0f8b08d..d8ca2e1aa3 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 27a9287238..684d8d399d 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"
@@ -49,8 +49,15 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/attached/person.cpp
index 909505a9d2..0a9e508302 100644
--- a/examples/declarative/extending/attached/person.cpp
+++ b/examples/declarative/extending/attached/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/attached/person.h b/examples/declarative/extending/attached/person.h
index dd030911c0..0f86d8b76e 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 62b9c7b7e1..e5be2b9cf4 100644
--- a/examples/declarative/extending/binding/birthdayparty.cpp
+++ b/examples/declarative/extending/binding/birthdayparty.cpp
@@ -58,7 +58,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
}
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -77,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
@@ -113,4 +112,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h
index 8bdb76ae9f..84864427ad 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 38f3c08a7d..7d4d021804 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;
}
@@ -84,4 +84,3 @@ void HappyBirthday::advance()
m_target.write(m_lyrics.at(m_line));
}
-QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h
index 852bec7337..ee4d1ecc2e 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 ba38e82e91..873f8c970a 100644
--- a/examples/declarative/extending/binding/main.cpp
+++ b/examples/declarative/extending/binding/main.cpp
@@ -39,18 +39,27 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
+#include "happybirthday.h"
#include "person.h"
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/binding/person.cpp
index 50fb7545ab..9a2248f92d 100644
--- a/examples/declarative/extending/binding/person.cpp
+++ b/examples/declarative/extending/binding/person.cpp
@@ -100,7 +100,6 @@ void ShoeDescription::setPrice(qreal p)
m_price = p;
emit shoeChanged();
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -126,18 +125,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/binding/person.h b/examples/declarative/extending/binding/person.h
index e8aa6a86cb..1bec71c401 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 15a4ca9c3a..523a42dbf8 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
@@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
index 5a9eb08eb8..fffd407c80 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 ccbee830a5..1e2209f941 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"
@@ -49,8 +49,15 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+// ![0]
+ QML_REGISTER_NOCREATE_TYPE(Person);
+// ![0]
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/coercion/person.cpp
index 9eef8f703e..5b5203add6 100644
--- a/examples/declarative/extending/coercion/person.cpp
+++ b/examples/declarative/extending/coercion/person.cpp
@@ -65,22 +65,16 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-// ![0]
-QML_DEFINE_NOCREATE_TYPE(Person);
-// ![0]
-
// ![1]
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
// ![1]
diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h
index 9bb9a3d5a9..298ffb1a3f 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 15a4ca9c3a..523a42dbf8 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
@@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h
index f25f8c250c..49c20bd118 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 ccbee830a5..7d7f8a136f 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"
@@ -49,8 +49,13 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/default/person.cpp
index a0b49605e3..69216d3539 100644
--- a/examples/declarative/extending/default/person.cpp
+++ b/examples/declarative/extending/default/person.cpp
@@ -65,18 +65,15 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/default/person.h b/examples/declarative/extending/default/person.h
index 884dda3c7d..b3eceaab8d 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 ec86aad23d..417fbd9f27 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))
@@ -103,4 +103,3 @@ void LineEditExtension::setBottomMargin(int m)
}
QML_DECLARE_TYPE(QLineEdit);
-QML_DEFINE_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension);
diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp
index 9376af7983..5cbeea3bcc 100644
--- a/examples/declarative/extending/extended/main.cpp
+++ b/examples/declarative/extending/extended/main.cpp
@@ -39,17 +39,20 @@
**
****************************************************************************/
#include <QApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include <QLineEdit>
+#include "lineedit.h"
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
QLineEdit *edit = qobject_cast<QLineEdit *>(component.create());
if (edit) {
diff --git a/examples/declarative/extending/extending.pro b/examples/declarative/extending/extending.pro
new file mode 100644
index 0000000000..169c7abde2
--- /dev/null
+++ b/examples/declarative/extending/extending.pro
@@ -0,0 +1,13 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ adding \
+ attached \
+ binding \
+ coercion \
+ default \
+ extended \
+ grouped \
+ properties \
+ signal \
+ valuesource
diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp
index 15a4ca9c3a..523a42dbf8 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
@@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h
index fd0d955684..42439c4f1a 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 79aaab5f83..15a0bb55f9 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"
@@ -49,8 +49,14 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/grouped/person.cpp
index 909505a9d2..0a9e508302 100644
--- a/examples/declarative/extending/grouped/person.cpp
+++ b/examples/declarative/extending/grouped/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/grouped/person.h b/examples/declarative/extending/grouped/person.h
index 89ccedc95f..5dab37823f 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 23e6e58cae..14fd6a3ad4 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
@@ -72,4 +72,3 @@ Person *BirthdayParty::guest(int index) const
}
// ![0]
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
index e5d316ce1d..c4cb536ec2 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 97d790593c..ce69ad204e 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"
@@ -49,8 +49,11 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, Person, Person);
+
+ 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.cpp b/examples/declarative/extending/properties/person.cpp
index d1b8bf46ff..92c54f5847 100644
--- a/examples/declarative/extending/properties/person.cpp
+++ b/examples/declarative/extending/properties/person.cpp
@@ -65,4 +65,3 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-QML_DEFINE_TYPE(People, 1,0, Person, Person);
diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h
index 8d665f00a4..860a6076fe 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 d8686f0aab..65ff53016b 100644
--- a/examples/declarative/extending/signal/birthdayparty.cpp
+++ b/examples/declarative/extending/signal/birthdayparty.cpp
@@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -72,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
@@ -98,4 +97,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h
index 30ed43bf14..bcdc5138e5 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 eb3bb4b033..afc1a666e7 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"
@@ -49,8 +49,15 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/signal/person.cpp
index 909505a9d2..0a9e508302 100644
--- a/examples/declarative/extending/signal/person.cpp
+++ b/examples/declarative/extending/signal/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/signal/person.h b/examples/declarative/extending/signal/person.h
index dd030911c0..0f86d8b76e 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 a5b3fabf4f..99d98beba5 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.cpp
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -72,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
@@ -108,4 +107,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
index b5a0522e14..819a200cfd 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 fbbc9e91ad..7b9d05afc9 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;
}
@@ -79,4 +79,3 @@ void HappyBirthday::advance()
m_target.write(m_lyrics.at(m_line));
}
-QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h
index c02a7d78d4..3e68c35cc8 100644
--- a/examples/declarative/extending/valuesource/happybirthday.h
+++ b/examples/declarative/extending/valuesource/happybirthday.h
@@ -41,13 +41,14 @@
#ifndef HAPPYBIRTHDAY_H
#define HAPPYBIRTHDAY_H
-#include <QmlPropertyValueSource>
-#include <qml.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeMetaProperty>
+#include <qdeclarative.h>
#include <QStringList>
// ![0]
-class HappyBirthday : public QObject, public QmlPropertyValueSource
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
// ![0]
@@ -56,7 +57,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 +69,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 ba38e82e91..873f8c970a 100644
--- a/examples/declarative/extending/valuesource/main.cpp
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -39,18 +39,27 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
+#include "happybirthday.h"
#include "person.h"
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ 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.cpp b/examples/declarative/extending/valuesource/person.cpp
index 909505a9d2..0a9e508302 100644
--- a/examples/declarative/extending/valuesource/person.cpp
+++ b/examples/declarative/extending/valuesource/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h
index dd030911c0..0f86d8b76e 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/fonts/hello.qml b/examples/declarative/fonts/hello.qml
index c68247788a..fcc9580cbc 100644
--- a/examples/declarative/fonts/hello.qml
+++ b/examples/declarative/fonts/hello.qml
@@ -11,7 +11,7 @@ Rectangle {
font.letterSpacing: SequentialAnimation {
repeat: true;
- NumberAnimation { from: 100; to: 300; easing: "easeInQuad"; duration: 3000 }
+ NumberAnimation { from: 100; to: 300; easing.type: "InQuad"; duration: 3000 }
ScriptAction { script: {
container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/main.cpp
index 9526105a43..d9d4c1ad6a 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,8 +74,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlView view;
- view.setSource(QUrl("qrc:view.qml"));
+ QDeclarativeView view;
view.engine()->addImageProvider("colors", new ColorImageProvider);
@@ -88,10 +87,10 @@ 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.execute();
+ view.setSource(QUrl("qrc:view.qml"));
view.show();
return app.exec();
diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml
index 0bdb9fc1fc..7cbf68af20 100644
--- a/examples/declarative/layouts/Button.qml
+++ b/examples/declarative/layouts/Button.qml
@@ -17,6 +17,6 @@ Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.wid
transitions:
Transition{
- NumberAnimation { properties:"x,left"; easing:"easeInOutQuad"; duration:200 }
+ NumberAnimation { properties:"x,left"; easing.type:"InOutQuad"; duration:200 }
}
}
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml
index fefd964a63..7146702dd2 100644
--- a/examples/declarative/layouts/positioners.qml
+++ b/examples/declarative/layouts/positioners.qml
@@ -11,12 +11,12 @@ Rectangle {
y: 0
move: Transition {
NumberAnimation {
- properties: "y"; easing: "easeOutBounce"
+ properties: "y"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "y"; easing: "easeOutQuad"
+ properties: "y"; easing.type: "OutQuad"
}
}
Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
@@ -35,12 +35,12 @@ Rectangle {
y: 300
move: Transition {
NumberAnimation {
- properties: "x"; easing: "easeOutBounce"
+ properties: "x"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "x"; easing: "easeOutQuad"
+ properties: "x"; easing.type: "OutQuad"
}
}
Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
@@ -101,13 +101,13 @@ Rectangle {
move: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
@@ -136,13 +136,13 @@ Rectangle {
move: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index f848be0547..b76a9ab0e0 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -81,7 +81,7 @@ Rectangle {
Flickable {
id: flick
anchors.top: methodTitle.bottom; anchors.bottom: parent.bottom
- width: parent.width; viewportHeight: methodText.height; clip: true
+ width: parent.width; contentHeight: methodText.height; clip: true
Text { id: methodText; text: method; wrap: true; width: details.width }
}
Image {
@@ -114,7 +114,7 @@ Rectangle {
// Make the detailed view fill the entire list area
PropertyChanges { target: wrapper; height: list.height }
// Move the list so that this item is at the top.
- PropertyChanges { target: wrapper.ListView.view; explicit: true; viewportY: wrapper.y }
+ PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y }
// Disallow flicking while we're in detailed view
PropertyChanges { target: wrapper.ListView.view; interactive: false }
}
@@ -124,7 +124,7 @@ Rectangle {
ParallelAnimation {
ColorAnimation { property: "color"; duration: 500 }
NumberAnimation {
- duration: 300; properties: "detailsOpacity,x,viewportY,height,width"
+ duration: 300; properties: "detailsOpacity,x,contentY,height,width"
}
}
}
diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp
index 9e38bea480..b210570234 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,8 +58,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlView view;
- view.setSource(QUrl("qrc:view.qml"));
+ QDeclarativeView view;
QList<QObject*> dataList;
dataList.append(new DataObject("Item 1", "red"));
@@ -67,10 +66,10 @@ 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.execute();
+ view.setSource(QUrl("qrc:view.qml"));
view.show();
return app.exec();
diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml
new file mode 100644
index 0000000000..4109633c68
--- /dev/null
+++ b/examples/declarative/package/Delegate.qml
@@ -0,0 +1,44 @@
+import Qt 4.6
+
+//![0]
+Package {
+ Text { id: listDelegate; width: 200; height: 25; text: "Empty"; Package.name: "list" }
+ Text { id: gridDelegate; width: 100; height: 50; text: "Empty"; Package.name: "grid" }
+
+ Rectangle {
+ id: wrapper
+ width: 200; height: 25
+ color: "lightsteelblue"
+ Text { text: display; anchors.centerIn: parent }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: {
+ if (wrapper.state == "inList")
+ wrapper.state = "inGrid";
+ else
+ wrapper.state = "inList";
+ }
+ }
+ state: "inList"
+ states: [
+ State {
+ name: 'inList'
+ ParentChange { target: wrapper; parent: listDelegate }
+ },
+ State {
+ name: 'inGrid'
+ ParentChange { target: wrapper; parent: gridDelegate }
+ PropertyChanges { target: wrapper; x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height }
+ }
+ ]
+ transitions: [
+ Transition {
+ SequentialAnimation {
+ ParentAction { target: wrapper }
+ NumberAnimation { targets: wrapper; properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml
new file mode 100644
index 0000000000..07bba0c4d8
--- /dev/null
+++ b/examples/declarative/package/view.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Item {
+ width: 400
+ height: 200
+
+ ListModel {
+ id: myModel
+ ListElement { display: "One" }
+ ListElement { display: "Two" }
+ ListElement { display: "Three" }
+ ListElement { display: "Four" }
+ ListElement { display: "Five" }
+ ListElement { display: "Six" }
+ ListElement { display: "Seven" }
+ ListElement { display: "Eight" }
+ }
+ //![0]
+ VisualDataModel {
+ id: visualModel
+ delegate: Delegate {}
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ GridView {
+ x: 200; width: 200; height:200
+ cellHeight: 50
+ model: visualModel.parts.grid
+ }
+ //![0]
+}
diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml
index 811891bf26..5e58100f07 100644
--- a/examples/declarative/parallax/qml/ParallaxView.qml
+++ b/examples/declarative/parallax/qml/ParallaxView.qml
@@ -10,8 +10,8 @@ Item {
Image {
id: background
fillMode: Image.TileHorizontally
- x: -list.viewportX / 2
- width: Math.max(list.viewportWidth, parent.width)
+ x: -list.contentX / 2
+ width: Math.max(list.contentWidth, parent.width)
}
ListView {
diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml
index fc5b4fe2d7..81eadda85c 100644
--- a/examples/declarative/parallax/qml/Smiley.qml
+++ b/examples/declarative/parallax/qml/Smiley.qml
@@ -27,16 +27,16 @@ Item {
y: SequentialAnimation {
repeat: true
- // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
NumberAnimation {
from: smiley.minHeight; to: smiley.maxHeight
- easing: "easeOutExpo"; duration: 300
+ easing.type: "OutExpo"; duration: 300
}
- // Then move back to minHeight in 1 second, using the easeOutBounce easing function
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
NumberAnimation {
from: smiley.maxHeight; to: smiley.minHeight
- easing: "easeOutBounce"; duration: 1000
+ easing.type: "OutBounce"; duration: 1000
}
// Then pause for 500ms
diff --git a/examples/declarative/plugins/files/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
index 01ec686cbf..01ec686cbf 100644
--- a/examples/declarative/plugins/files/Clock.qml
+++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
diff --git a/examples/declarative/plugins/files/center.png b/examples/declarative/plugins/com/nokia/TimeExample/center.png
index 7fbd802a44..7fbd802a44 100644
--- a/examples/declarative/plugins/files/center.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/center.png
Binary files differ
diff --git a/examples/declarative/plugins/files/clock.png b/examples/declarative/plugins/com/nokia/TimeExample/clock.png
index 462edacc0e..462edacc0e 100644
--- a/examples/declarative/plugins/files/clock.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/clock.png
Binary files differ
diff --git a/examples/declarative/plugins/files/hour.png b/examples/declarative/plugins/com/nokia/TimeExample/hour.png
index f8061a1235..f8061a1235 100644
--- a/examples/declarative/plugins/files/hour.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/hour.png
Binary files differ
diff --git a/examples/declarative/plugins/files/minute.png b/examples/declarative/plugins/com/nokia/TimeExample/minute.png
index 1297ec7c2b..1297ec7c2b 100644
--- a/examples/declarative/plugins/files/minute.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/minute.png
Binary files differ
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/plugins/com/nokia/TimeExample/qmldir
new file mode 100644
index 0000000000..e9ef11530f
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/qmldir
@@ -0,0 +1,2 @@
+Clock 1.0 Clock.qml
+plugin qtimeexampleqmlplugin
diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp
index 820d4ebb2e..741f68ad33 100644
--- a/examples/declarative/plugins/plugin.cpp
+++ b/examples/declarative/plugins/plugin.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include <QtDeclarative/qmlmoduleplugin.h>
-#include <QtDeclarative/qml.h>
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
#include <qdebug.h>
#include <qdatetime.h>
#include <qbasictimer.h>
@@ -140,19 +140,14 @@ MinuteTimer *Time::timer=0;
QML_DECLARE_TYPE(Time);
-class QExampleQmlPlugin : public QmlModulePlugin
+class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
public:
- QStringList keys() const
- {
- return QStringList() << QLatin1String("com.nokia.TimeExample");
- }
-
- void defineModule(const QString& uri)
+ void registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample"));
- qmlRegisterType<Time>("com.nokia.TimeExample", 1, 0, "Time", "Time");
+ qmlRegisterType<Time>(uri, 1, 0, "Time");
}
};
diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro
index 84ab8da45c..c925ceaefa 100644
--- a/examples/declarative/plugins/plugins.pro
+++ b/examples/declarative/plugins/plugins.pro
@@ -1,15 +1,27 @@
TEMPLATE = lib
+DESTDIR = com/nokia/TimeExample
TARGET = qtimeexampleqmlplugin
CONFIG += qt plugin
QT += declarative
+VERSION = 1.0.0
SOURCES += plugin.cpp
-target.path += $$[QT_INSTALL_PLUGINS]/qmlmodules
-sources.files += files/Clock.qml files/qmldir files/background.png files/center.png files/clock-night.png files/clock.png files/hour.png files/minute.png
-sources.path += $$[QT_INSTALL_DATA]/qml/com/nokia/TimeExample
-INSTALLS += target sources
+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
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
-VERSION=1.0.0
+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 += qdeclarativesources sources target
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml
index dbeb001b25..44b552b669 100644
--- a/examples/declarative/plugins/plugins.qml
+++ b/examples/declarative/plugins/plugins.qml
@@ -1,5 +1,4 @@
import com.nokia.TimeExample 1.0 // import types from the plugin
-import 'files' // import types from the 'files' directory
Clock { // this class is defined in QML (files/Clock.qml)
diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml
index fdd4ca70c6..6530c3de1b 100644
--- a/examples/declarative/progressbar/progressbars.qml
+++ b/examples/declarative/progressbar/progressbars.qml
@@ -6,7 +6,7 @@ Rectangle {
width: 600; height: 405; color: "#edecec"
Flickable {
- anchors.fill: parent; viewportHeight: column.height + 20
+ anchors.fill: parent; contentHeight: column.height + 20
Column {
id: column; x: 10; y: 10; spacing: 10
Repeater {
diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml
index 536a8b79a6..84763d21a5 100644
--- a/examples/declarative/scrollbar/display.qml
+++ b/examples/declarative/scrollbar/display.qml
@@ -10,9 +10,10 @@ Rectangle {
Image {
id: picture
source: "pics/niagara_falls.jpg"
+ asynchronous: true
}
- viewportWidth: picture.width
- viewportHeight: picture.height
+ contentWidth: picture.width
+ contentHeight: picture.height
// Only show the scrollbars when the view is moving.
states: [
State {
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
index 930f47128a..758aee6568 100644
--- a/examples/declarative/slideswitch/content/Switch.qml
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -66,7 +66,7 @@ Item {
//![7]
transitions: Transition {
- NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 }
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad"; duration: 200 }
}
//![7]
}
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index 96e067563c..277dfeb42d 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/states/transitions.qml b/examples/declarative/states/transitions.qml
index 48d5f60212..8ad61ad217 100644
--- a/examples/declarative/states/transitions.qml
+++ b/examples/declarative/states/transitions.qml
@@ -51,16 +51,16 @@ Rectangle {
// transitions define how the properties change.
transitions: [
// When transitioning to 'Position1' move x,y over a duration of 1 second,
- // with easeOutBounce easing function.
+ // with OutBounce easing function.
Transition {
from: "*"; to: "Position1"
- NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 }
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce"; duration: 1000 }
},
// When transitioning to 'Position2' move x,y over a duration of 2 seconds,
- // with easeInOutQuad easing function.
+ // with InOutQuad easing function.
Transition {
from: "*"; to: "Position2"
- NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 }
+ NumberAnimation { properties: "x,y"; easing.type: "InOutQuad"; duration: 2000 }
},
// For any other state changes move x,y linearly over duration of 200ms.
Transition {
diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml
index 9eaa009466..b8a4f7709e 100644
--- a/examples/declarative/tutorials/helloworld/tutorial3.qml
+++ b/examples/declarative/tutorials/helloworld/tutorial3.qml
@@ -28,7 +28,7 @@ Rectangle {
transitions: Transition {
from: ""; to: "down"; reversible: true
ParallelAnimation {
- NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: "InOutQuad" }
ColorAnimation { duration: 500 }
}
}
diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml
index 50d69d8f08..0d1881e84a 100644
--- a/examples/declarative/velocity/velocity.qml
+++ b/examples/declarative/velocity/velocity.qml
@@ -96,7 +96,7 @@ Rectangle {
}
Flickable {
id: flickable
- anchors.fill: parent; viewportWidth: lay.width
+ anchors.fill: parent; contentWidth: lay.width
Row {
id: lay
Repeater {
diff --git a/examples/declarative/webview/qdeclarative-in-html.qml b/examples/declarative/webview/qdeclarative-in-html.qml
new file mode 100644
index 0000000000..77180ec18e
--- /dev/null
+++ b/examples/declarative/webview/qdeclarative-in-html.qml
@@ -0,0 +1,32 @@
+import Qt 4.6
+
+// The WebView supports QML data through the HTML OBJECT tag
+Rectangle {
+ color:"blue"
+ Flickable {
+ width: parent.width
+ height: parent.height/2
+ contentWidth: web.width*web.scale
+ contentHeight: web.height*web.scale
+ WebView {
+ id: web
+ width: 250
+ height: 420
+ zoomFactor: 0.75
+ smoothCache: true
+ settings.pluginsEnabled: true
+ html: "<html>\
+ <body bgcolor=white>\
+ These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75%\
+ and placed in a Flickable area...\
+ <table border=1>\
+ <tr><th>Duration <th>Color <th>Plugin\
+ <tr><td>500 <td>red <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=500 color=red />\
+ <tr><td>2000 <td>blue <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=2000 color=blue />\
+ <tr><td>1000 <td>green <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=1000 color=green />\
+ </table>\
+ </body>\
+ </html>"
+ }
+ }
+}
diff --git a/examples/declarative/webview/qml-in-html.qml b/examples/declarative/webview/qml-in-html.qml
deleted file mode 100644
index a2f2f2a035..0000000000
--- a/examples/declarative/webview/qml-in-html.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-import Qt 4.6
-
-// The WebView supports QML data through the HTML OBJECT tag
-Rectangle {
- color:"blue"
- Flickable {
- width: parent.width
- height: parent.height/2
- viewportWidth: web.width*web.scale
- viewportHeight: web.height*web.scale
- WebView {
- id: web
- width: 250
- height: 420
- zoomFactor: 0.75
- smoothCache: true
- settings.pluginsEnabled: true
- html: "<html>\
- <body bgcolor=white>\
- These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75%\
- and placed in a Flickable area...\
- <table border=1>\
- <tr><th>Duration <th>Color <th>Plugin\
- <tr><td>500 <td>red <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=500 color=red />\
- <tr><td>2000 <td>blue <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=2000 color=blue />\
- <tr><td>1000 <td>green <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=1000 color=green />\
- </table>\
- </body>\
- </html>"
- }
- }
-}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index b80e29c948..f7c269c54d 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -61,7 +61,7 @@ Rectangle {
transitions: Transition {
from: "*"; to: "Details"; reversible: true
SequentialAnimation {
- NumberAnimation { duration: 200; properties: "height"; easing: "easeOutQuad" }
+ NumberAnimation { duration: 200; properties: "height"; easing.type: "OutQuad" }
NumberAnimation { duration: 200; properties: "opacity" }
}
}
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index 95fc82f5e3..ec7cd331f3 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -49,9 +49,9 @@ HttpWindow::HttpWindow(QWidget *parent)
: QDialog(parent)
{
#ifndef QT_NO_OPENSSL
- urlLineEdit = new QLineEdit("https://");
+ urlLineEdit = new QLineEdit("https://qt.nokia.com/");
#else
- urlLineEdit = new QLineEdit("http://");
+ urlLineEdit = new QLineEdit("http://qt.nokia.com/");
#endif
urlLabel = new QLabel(tr("&URL:"));
@@ -70,21 +70,14 @@ HttpWindow::HttpWindow(QWidget *parent)
progressDialog = new QProgressDialog(this);
- http = new QHttp(this);
-
connect(urlLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enableDownloadButton()));
- connect(http, SIGNAL(requestFinished(int,bool)),
- this, SLOT(httpRequestFinished(int,bool)));
- connect(http, SIGNAL(dataReadProgress(int,int)),
- this, SLOT(updateDataReadProgress(int,int)));
- connect(http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)),
- this, SLOT(readResponseHeader(QHttpResponseHeader)));
- connect(http, SIGNAL(authenticationRequired(QString,quint16,QAuthenticator*)),
- this, SLOT(slotAuthenticationRequired(QString,quint16,QAuthenticator*)));
+
+ connect(&qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
+ this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
#ifndef QT_NO_OPENSSL
- connect(http, SIGNAL(sslErrors(QList<QSslError>)),
- this, SLOT(sslErrors(QList<QSslError>)));
+ connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
+ this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
#endif
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));
connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile()));
@@ -104,9 +97,21 @@ HttpWindow::HttpWindow(QWidget *parent)
urlLineEdit->setFocus();
}
+void HttpWindow::startRequest(QUrl url)
+{
+ reply = qnam.get(QNetworkRequest(url));
+ connect(reply, SIGNAL(finished()),
+ this, SLOT(httpFinished()));
+ connect(reply, SIGNAL(readyRead()),
+ this, SLOT(httpReadyRead()));
+ connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(updateDataReadProgress(qint64,qint64)));
+}
+
void HttpWindow::downloadFile()
{
- QUrl url(urlLineEdit->text());
+ url = urlLineEdit->text();
+
QFileInfo fileInfo(url.path());
QString fileName = fileInfo.fileName();
if (fileName.isEmpty())
@@ -132,35 +137,26 @@ void HttpWindow::downloadFile()
return;
}
- QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
- http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
-
- if (!url.userName().isEmpty())
- http->setUser(url.userName(), url.password());
-
- httpRequestAborted = false;
- QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
- if (path.isEmpty())
- path = "/";
- httpGetId = http->get(path, file);
progressDialog->setWindowTitle(tr("HTTP"));
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
downloadButton->setEnabled(false);
+
+ // schedule the request
+ httpRequestAborted = false;
+ startRequest(url);
}
void HttpWindow::cancelDownload()
{
statusLabel->setText(tr("Download canceled."));
httpRequestAborted = true;
- http->abort();
+ reply->abort();
downloadButton->setEnabled(true);
}
-void HttpWindow::httpRequestFinished(int requestId, bool error)
+void HttpWindow::httpFinished()
{
- if (requestId != httpGetId)
- return;
if (httpRequestAborted) {
if (file) {
file->close();
@@ -168,54 +164,58 @@ void HttpWindow::httpRequestFinished(int requestId, bool error)
delete file;
file = 0;
}
-
+ reply->deleteLater();
progressDialog->hide();
return;
}
- if (requestId != httpGetId)
- return;
-
progressDialog->hide();
+ file->flush();
file->close();
- if (error) {
+
+ QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (reply->error()) {
file->remove();
QMessageBox::information(this, tr("HTTP"),
tr("Download failed: %1.")
- .arg(http->errorString()));
+ .arg(reply->errorString()));
+ downloadButton->setEnabled(true);
+ } else if (!redirectionTarget.isNull()) {
+ QUrl newUrl = url.resolved(redirectionTarget.toUrl());
+ if (QMessageBox::question(this, tr("HTTP"),
+ tr("Redirect to %1 ?").arg(newUrl.toString()),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ url = newUrl;
+ reply->deleteLater();
+ file->open(QIODevice::WriteOnly);
+ file->resize(0);
+ startRequest(url);
+ return;
+ }
} else {
QString fileName = QFileInfo(QUrl(urlLineEdit->text()).path()).fileName();
statusLabel->setText(tr("Downloaded %1 to current directory.").arg(fileName));
+ downloadButton->setEnabled(true);
}
- downloadButton->setEnabled(true);
+ reply->deleteLater();
+ reply = 0;
delete file;
file = 0;
}
-void HttpWindow::readResponseHeader(const QHttpResponseHeader &responseHeader)
+void HttpWindow::httpReadyRead()
{
- switch (responseHeader.statusCode()) {
- case 200: // Ok
- case 301: // Moved Permanently
- case 302: // Found
- case 303: // See Other
- case 307: // Temporary Redirect
- // these are not error conditions
- break;
-
- default:
- QMessageBox::information(this, tr("HTTP"),
- tr("Download failed: %1.")
- .arg(responseHeader.reasonPhrase()));
- httpRequestAborted = true;
- progressDialog->hide();
- http->abort();
- }
+ // this slot gets called everytime the QNetworkReply has new data.
+ // We read all of its new data and write it into the file.
+ // That way we use less RAM than when reading it at the finished()
+ // signal of the QNetworkReply
+ if (file)
+ file->write(reply->readAll());
}
-void HttpWindow::updateDataReadProgress(int bytesRead, int totalBytes)
+void HttpWindow::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{
if (httpRequestAborted)
return;
@@ -229,14 +229,19 @@ void HttpWindow::enableDownloadButton()
downloadButton->setEnabled(!urlLineEdit->text().isEmpty());
}
-void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QAuthenticator *authenticator)
+void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
{
QDialog dlg;
Ui::Dialog ui;
ui.setupUi(&dlg);
dlg.adjustSize();
- ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(hostName));
-
+ ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host()));
+
+ // Did the URL have information? Fill the UI
+ // This is only relevant if the URL-supplied credentials were wrong
+ ui.userEdit->setText(url.userName());
+ ui.passwordEdit->setText(url.password());
+
if (dlg.exec() == QDialog::Accepted) {
authenticator->setUser(ui.userEdit->text());
authenticator->setPassword(ui.passwordEdit->text());
@@ -244,7 +249,7 @@ void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QA
}
#ifndef QT_NO_OPENSSL
-void HttpWindow::sslErrors(const QList<QSslError> &errors)
+void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
{
QString errorString;
foreach (const QSslError &error, errors) {
@@ -253,10 +258,10 @@ void HttpWindow::sslErrors(const QList<QSslError> &errors)
errorString += error.errorString();
}
- if (QMessageBox::warning(this, tr("HTTP Example"),
+ if (QMessageBox::warning(this, tr("HTTP"),
tr("One or more SSL errors has occurred: %1").arg(errorString),
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
- http->ignoreSslErrors();
+ reply->ignoreSslErrors();
}
}
#endif
diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h
index 9dca8a5f3f..83898af04d 100644
--- a/examples/network/http/httpwindow.h
+++ b/examples/network/http/httpwindow.h
@@ -43,18 +43,21 @@
#define HTTPWINDOW_H
#include <QDialog>
+#include <QNetworkAccessManager>
+#include <QUrl>
QT_BEGIN_NAMESPACE
class QDialogButtonBox;
class QFile;
-class QHttp;
-class QHttpResponseHeader;
class QLabel;
class QLineEdit;
class QProgressDialog;
class QPushButton;
class QSslError;
class QAuthenticator;
+class QNetworkReply;
+
+
QT_END_NAMESPACE
class HttpWindow : public QDialog
@@ -64,16 +67,18 @@ class HttpWindow : public QDialog
public:
HttpWindow(QWidget *parent = 0);
+ void startRequest(QUrl url);
+
private slots:
void downloadFile();
void cancelDownload();
- void httpRequestFinished(int requestId, bool error);
- void readResponseHeader(const QHttpResponseHeader &responseHeader);
- void updateDataReadProgress(int bytesRead, int totalBytes);
+ void httpFinished();
+ void httpReadyRead();
+ void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
void enableDownloadButton();
- void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *);
+ void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
#ifndef QT_NO_OPENSSL
- void sslErrors(const QList<QSslError> &errors);
+ void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
#endif
private:
@@ -85,7 +90,9 @@ private:
QPushButton *quitButton;
QDialogButtonBox *buttonBox;
- QHttp *http;
+ QUrl url;
+ QNetworkAccessManager qnam;
+ QNetworkReply *reply;
QFile *file;
int httpGetId;
bool httpRequestAborted;
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp
index ecbe100355..817b2be804 100644
--- a/examples/network/http/main.cpp
+++ b/examples/network/http/main.cpp
@@ -46,7 +46,6 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qWarning("The usage of QHttp is not recommended anymore, please use QNetworkAccessManager.");
HttpWindow httpWin;
httpWin.show();
return httpWin.exec();
diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp
index 27cff31919..b504e36ce8 100644
--- a/examples/network/loopback/dialog.cpp
+++ b/examples/network/loopback/dialog.cpp
@@ -44,12 +44,12 @@
#include "dialog.h"
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
static const int TotalBytes = 50 * 1024 * 1024;
#else
static const int TotalBytes = 5 * 1024 * 1024;
#endif
-static const int PayloadSize = 65536;
+static const int PayloadSize = 64 * 1024; // 64 KB
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
@@ -130,6 +130,7 @@ void Dialog::acceptConnection()
void Dialog::startTransfer()
{
+ // called when the TCP client connected to the loopback server
bytesToWrite = TotalBytes - (int)tcpClient.write(QByteArray(PayloadSize, '@'));
clientStatusLabel->setText(tr("Connected"));
}
@@ -155,8 +156,11 @@ void Dialog::updateServerProgress()
void Dialog::updateClientProgress(qint64 numBytes)
{
+ // callen when the TCP client has written some bytes
bytesWritten += (int)numBytes;
- if (bytesToWrite > 0)
+
+ // only write more if not finished and when the Qt write buffer is below a certain size.
+ if (bytesToWrite > 0 && tcpClient.bytesToWrite() <= 4*PayloadSize)
bytesToWrite -= (int)tcpClient.write(QByteArray(qMin(bytesToWrite, PayloadSize), '@'));
clientProgressBar->setMaximum(TotalBytes);
diff --git a/imports/Qt/multimedia/qmldir b/imports/Qt/multimedia/qmldir
new file mode 100644
index 0000000000..0e6f6563f6
--- /dev/null
+++ b/imports/Qt/multimedia/qmldir
@@ -0,0 +1 @@
+plugin multimedia
diff --git a/imports/Qt/widgets/qmldir b/imports/Qt/widgets/qmldir
new file mode 100644
index 0000000000..6f19878671
--- /dev/null
+++ b/imports/Qt/widgets/qmldir
@@ -0,0 +1 @@
+plugin widgets
diff --git a/mkspecs/aix-g++-64/qmake.conf b/mkspecs/aix-g++-64/qmake.conf
index 995178bb52..d9d9c38a58 100644
--- a/mkspecs/aix-g++-64/qmake.conf
+++ b/mkspecs/aix-g++-64/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/aix-g++/qmake.conf b/mkspecs/aix-g++/qmake.conf
index 969aa76699..5fc4c17633 100644
--- a/mkspecs/aix-g++/qmake.conf
+++ b/mkspecs/aix-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/aix-xlc-64/qmake.conf b/mkspecs/aix-xlc-64/qmake.conf
index a18aa9fed5..c67bd0b334 100644
--- a/mkspecs/aix-xlc-64/qmake.conf
+++ b/mkspecs/aix-xlc-64/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/aix-xlc/qmake.conf b/mkspecs/aix-xlc/qmake.conf
index 42f6f7e50a..e81fb661c6 100644
--- a/mkspecs/aix-xlc/qmake.conf
+++ b/mkspecs/aix-xlc/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/common/qws.conf b/mkspecs/common/qws.conf
index 0242db4c4a..96341a7a83 100644
--- a/mkspecs/common/qws.conf
+++ b/mkspecs/common/qws.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui network
diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf
index d2edbdbf78..5230513479 100644
--- a/mkspecs/common/symbian/symbian.conf
+++ b/mkspecs/common/symbian/symbian.conf
@@ -115,6 +115,7 @@ QMAKE_STRIPFLAGS_LIB += --strip-unneeded
load(qt_config)
load(symbian/platform_paths)
+load(add_mmp_rules)
symbian-abld {
# Versions of abld prior to Symbian^3 have a bug where you cannot remove something from the command line without replacing it
@@ -123,7 +124,7 @@ symbian-abld {
} else {
MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA = "OPTION_REPLACE ARMCC --export_all_vtbl // don't use --export_all_vtbl"
}
-MMP_RULES += PAGED
+MMP_RULES += PAGED BYTEPAIRCOMPRESSTARGET
MMP_RULES += $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA
SYMBIAN_PLATFORMS = WINSCW GCCE ARMV5 ARMV6
@@ -153,7 +154,7 @@ exists($${EPOCROOT}epoc32/release/winscw/udeb/z/system/install/series60v5.0.sis
S60_VERSION = 3.2
} else {
S60_VERSION = 3.1
- MMP_RULES -= PAGED
+ MMP_RULES -= PAGED BYTEPAIRCOMPRESSTARGET
}
}
@@ -171,4 +172,4 @@ symbian {
# [TODO] QMAKE_CXXFLAGS.GCCE += $${QMAKE_CXXFLAGS_FAST_VFP.GCCE}
}
}
-} \ No newline at end of file
+}
diff --git a/mkspecs/cygwin-g++/qmake.conf b/mkspecs/cygwin-g++/qmake.conf
index 9cbc3d7e76..af9881b51b 100644
--- a/mkspecs/cygwin-g++/qmake.conf
+++ b/mkspecs/cygwin-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/darwin-g++/qmake.conf b/mkspecs/darwin-g++/qmake.conf
index 72baa89ca0..995679ea82 100644
--- a/mkspecs/darwin-g++/qmake.conf
+++ b/mkspecs/darwin-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release link_prl native_precompiled_headers
QT += core gui
diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf
index 01074f4f8b..155bfc33c9 100644
--- a/mkspecs/features/default_post.prf
+++ b/mkspecs/features/default_post.prf
@@ -8,3 +8,14 @@ incredibuild_xge {
QMAKE_INCDIR += $$QMAKE_INCDIR_POST
QMAKE_LIBDIR += $$QMAKE_LIBDIR_POST
+
+# Let every project have a standard GNU `check' target
+!contains(QMAKE_EXTRA_TARGETS, check) {
+ # `make check' should iterate through all subdirs
+ contains(TEMPLATE, subdirs) {
+ check.CONFIG = recursive
+ check.recurse = $$SUBDIRS
+ check.recurse_target = check
+ }
+ QMAKE_EXTRA_TARGETS += check
+}
diff --git a/mkspecs/features/qttest_p4.prf b/mkspecs/features/qttest_p4.prf
index e0b22f2c74..53c0d74a76 100644
--- a/mkspecs/features/qttest_p4.prf
+++ b/mkspecs/features/qttest_p4.prf
@@ -20,12 +20,32 @@ check.path = .
macx: check.commands += ./$(QMAKE_TARGET).app/Contents/MacOS/$(QMAKE_TARGET)
else:unix: check.commands += ./$(QMAKE_TARGET)
else:win32: {
- CONFIG(debug, debug|release):check.commands += debug\\$(QMAKE_TARGET)
- else:check.commands += release\\$(QMAKE_TARGET)
+ CONFIG(debug, debug|release):check.commands += $(DESTDIR_TARGET)
+ else:check.commands += $(DESTDIR_TARGET)
}
embedded: check.commands += -qws
QMAKE_EXTRA_TARGETS += check
+!debug_and_release|build_pass {
+ check.depends = $(DESTDIR_TARGET)
+} else {
+ check.CONFIG = recursive
+ # In debug and release mode, only run the test once.
+ # Run debug if available, release otherwise.
+ debug_and_release {
+ check.target = dummy_check
+ check.recurse_target = check
+ debug {
+ real_check.depends = debug-check
+ real_check.target = check
+ QMAKE_EXTRA_TARGETS += real_check
+ } else {
+ real_check.depends = release-check
+ real_check.target = check
+ QMAKE_EXTRA_TARGETS += real_check
+ }
+ }
+}
target.path += $$[QT_INSTALL_PREFIX]/tests/qt4
INSTALLS += target
diff --git a/mkspecs/features/symbian/add_mmp_rules.prf b/mkspecs/features/symbian/add_mmp_rules.prf
new file mode 100644
index 0000000000..5384dbe961
--- /dev/null
+++ b/mkspecs/features/symbian/add_mmp_rules.prf
@@ -0,0 +1,33 @@
+# Arg1: List of conditions to generate block for
+# Arg2: List of variables containing rules to add
+defineTest(addMMPRules) {
+ unset(myConditions)
+ unset(myVariables)
+ unset(myIfDef)
+
+ myConditions = $$eval($$1) default
+ myVariables = $$eval($$2)
+ myIfDef = if
+
+ for(condition, $$list($$myConditions)) {
+ contains(condition, default) {
+ libBlock = "$${LITERAL_HASH}else"
+ } else {
+ libBlock = "$${LITERAL_HASH}$${myIfDef} defined($${condition})"
+ myIfDef = elif
+ }
+
+ for(var, $$list($$myVariables)) {
+ varVal = $$eval($${var}.$${condition})
+ isEmpty(varVal) {
+ # No value defined for current condition, so use default
+ varVal = $$eval($${var}.default)
+ }
+ !isEmpty(varVal): libBlock += "$$join(varVal,$$escape_expand(\n))"
+ }
+
+ MMP_RULES += $$libBlock
+ }
+ MMP_RULES += "$${LITERAL_HASH}endif"
+ export(MMP_RULES)
+}
diff --git a/mkspecs/freebsd-g++/qmake.conf b/mkspecs/freebsd-g++/qmake.conf
index acd2a6a5b6..51a1960451 100644
--- a/mkspecs/freebsd-g++/qmake.conf
+++ b/mkspecs/freebsd-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/freebsd-g++34/qmake.conf b/mkspecs/freebsd-g++34/qmake.conf
index 9627b460c1..3e6bf6a5b3 100644
--- a/mkspecs/freebsd-g++34/qmake.conf
+++ b/mkspecs/freebsd-g++34/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/freebsd-g++40/qmake.conf b/mkspecs/freebsd-g++40/qmake.conf
index e3a3c8632c..43d69802ac 100644
--- a/mkspecs/freebsd-g++40/qmake.conf
+++ b/mkspecs/freebsd-g++40/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/freebsd-icc/qmake.conf b/mkspecs/freebsd-icc/qmake.conf
index 60fa7ee67e..c9c3140104 100644
--- a/mkspecs/freebsd-icc/qmake.conf
+++ b/mkspecs/freebsd-icc/qmake.conf
@@ -28,6 +28,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/hpux-acc-64/qmake.conf b/mkspecs/hpux-acc-64/qmake.conf
index 8757459722..b138ef833e 100644
--- a/mkspecs/hpux-acc-64/qmake.conf
+++ b/mkspecs/hpux-acc-64/qmake.conf
@@ -46,6 +46,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/hpux-acc-o64/qmake.conf b/mkspecs/hpux-acc-o64/qmake.conf
index d4d2c7dc9b..b703540512 100644
--- a/mkspecs/hpux-acc-o64/qmake.conf
+++ b/mkspecs/hpux-acc-o64/qmake.conf
@@ -46,6 +46,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/hpux-acc/qmake.conf b/mkspecs/hpux-acc/qmake.conf
index 19ee00f94b..8223a07f28 100644
--- a/mkspecs/hpux-acc/qmake.conf
+++ b/mkspecs/hpux-acc/qmake.conf
@@ -25,6 +25,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/hpux-g++-64/qmake.conf b/mkspecs/hpux-g++-64/qmake.conf
index f76bd4e9ec..734a5f7afa 100644
--- a/mkspecs/hpux-g++-64/qmake.conf
+++ b/mkspecs/hpux-g++-64/qmake.conf
@@ -6,6 +6,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/hpux-g++/qmake.conf b/mkspecs/hpux-g++/qmake.conf
index 1ed2ee64a8..6935ea99bf 100644
--- a/mkspecs/hpux-g++/qmake.conf
+++ b/mkspecs/hpux-g++/qmake.conf
@@ -6,6 +6,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl plugin_no_soname
QT += core gui
diff --git a/mkspecs/hpuxi-acc-32/qmake.conf b/mkspecs/hpuxi-acc-32/qmake.conf
index 00b400f0de..93006e53dd 100644
--- a/mkspecs/hpuxi-acc-32/qmake.conf
+++ b/mkspecs/hpuxi-acc-32/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release plugin_no_soname
QT += core gui
diff --git a/mkspecs/hpuxi-acc-64/qmake.conf b/mkspecs/hpuxi-acc-64/qmake.conf
index feefd309dc..2fa1f01195 100644
--- a/mkspecs/hpuxi-acc-64/qmake.conf
+++ b/mkspecs/hpuxi-acc-64/qmake.conf
@@ -46,6 +46,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release plugin_no_soname
QT += core gui
diff --git a/mkspecs/hpuxi-g++-64/qmake.conf b/mkspecs/hpuxi-g++-64/qmake.conf
index e8fa053a57..05b069106a 100644
--- a/mkspecs/hpuxi-g++-64/qmake.conf
+++ b/mkspecs/hpuxi-g++-64/qmake.conf
@@ -11,6 +11,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/hurd-g++/qmake.conf b/mkspecs/hurd-g++/qmake.conf
index f213f2d5dc..6570e4079e 100644
--- a/mkspecs/hurd-g++/qmake.conf
+++ b/mkspecs/hurd-g++/qmake.conf
@@ -6,6 +6,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
QT += core gui
CONFIG += qt warn_on release link_prl
diff --git a/mkspecs/irix-cc-64/qmake.conf b/mkspecs/irix-cc-64/qmake.conf
index bf5febb048..4b651b2e96 100644
--- a/mkspecs/irix-cc-64/qmake.conf
+++ b/mkspecs/irix-cc-64/qmake.conf
@@ -35,6 +35,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/irix-cc/qmake.conf b/mkspecs/irix-cc/qmake.conf
index 99e8064326..0070d42a76 100644
--- a/mkspecs/irix-cc/qmake.conf
+++ b/mkspecs/irix-cc/qmake.conf
@@ -35,6 +35,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/irix-g++-64/qmake.conf b/mkspecs/irix-g++-64/qmake.conf
index d614b9dd35..56f02f105b 100644
--- a/mkspecs/irix-g++-64/qmake.conf
+++ b/mkspecs/irix-g++-64/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/irix-g++/qmake.conf b/mkspecs/irix-g++/qmake.conf
index 1f1df30298..c1eafdb76c 100644
--- a/mkspecs/irix-g++/qmake.conf
+++ b/mkspecs/irix-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/linux-cxx/qmake.conf b/mkspecs/linux-cxx/qmake.conf
index 633b738b38..879c78a06c 100644
--- a/mkspecs/linux-cxx/qmake.conf
+++ b/mkspecs/linux-cxx/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/linux-ecc-64/qmake.conf b/mkspecs/linux-ecc-64/qmake.conf
index 359d44be23..21f29604b7 100644
--- a/mkspecs/linux-ecc-64/qmake.conf
+++ b/mkspecs/linux-ecc-64/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/linux-g++-32/qmake.conf b/mkspecs/linux-g++-32/qmake.conf
index 44866cf812..1e5c50b987 100644
--- a/mkspecs/linux-g++-32/qmake.conf
+++ b/mkspecs/linux-g++-32/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/linux-g++-64/qmake.conf b/mkspecs/linux-g++-64/qmake.conf
index 4f8794f3f9..e7372cc205 100644
--- a/mkspecs/linux-g++-64/qmake.conf
+++ b/mkspecs/linux-g++-64/qmake.conf
@@ -6,6 +6,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/linux-g++-maemo/qmake.conf b/mkspecs/linux-g++-maemo/qmake.conf
index 38c26a6759..ca201bcc24 100644
--- a/mkspecs/linux-g++-maemo/qmake.conf
+++ b/mkspecs/linux-g++-maemo/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
CONFIG += nostrip
diff --git a/mkspecs/linux-g++/qmake.conf b/mkspecs/linux-g++/qmake.conf
index 47784e27f7..4b218960c8 100644
--- a/mkspecs/linux-g++/qmake.conf
+++ b/mkspecs/linux-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf
index 965de0c298..eeb24a382d 100644
--- a/mkspecs/linux-icc/qmake.conf
+++ b/mkspecs/linux-icc/qmake.conf
@@ -11,6 +11,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/linux-kcc/qmake.conf b/mkspecs/linux-kcc/qmake.conf
index 009c48602b..217572fd85 100644
--- a/mkspecs/linux-kcc/qmake.conf
+++ b/mkspecs/linux-kcc/qmake.conf
@@ -14,6 +14,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/linux-llvm/qmake.conf b/mkspecs/linux-llvm/qmake.conf
index 9c34377de7..73d6609165 100644
--- a/mkspecs/linux-llvm/qmake.conf
+++ b/mkspecs/linux-llvm/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/linux-lsb-g++/qmake.conf b/mkspecs/linux-lsb-g++/qmake.conf
index b603a16110..4b4deabc58 100644
--- a/mkspecs/linux-lsb-g++/qmake.conf
+++ b/mkspecs/linux-lsb-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/linux-pgcc/qmake.conf b/mkspecs/linux-pgcc/qmake.conf
index 756f1af941..19af8ee216 100644
--- a/mkspecs/linux-pgcc/qmake.conf
+++ b/mkspecs/linux-pgcc/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/lynxos-g++/qmake.conf b/mkspecs/lynxos-g++/qmake.conf
index 40f2b9f95e..eae330873b 100644
--- a/mkspecs/lynxos-g++/qmake.conf
+++ b/mkspecs/lynxos-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/macx-g++/qmake.conf b/mkspecs/macx-g++/qmake.conf
index 43550737e1..4464686b3e 100644
--- a/mkspecs/macx-g++/qmake.conf
+++ b/mkspecs/macx-g++/qmake.conf
@@ -7,6 +7,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl
QT += core gui
diff --git a/mkspecs/macx-g++40/qmake.conf b/mkspecs/macx-g++40/qmake.conf
index d6fd09d7ae..784f5fce58 100644
--- a/mkspecs/macx-g++40/qmake.conf
+++ b/mkspecs/macx-g++40/qmake.conf
@@ -7,6 +7,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl
QT += core gui
diff --git a/mkspecs/macx-g++42/qmake.conf b/mkspecs/macx-g++42/qmake.conf
index 06bbdcbb12..fb936973a7 100644
--- a/mkspecs/macx-g++42/qmake.conf
+++ b/mkspecs/macx-g++42/qmake.conf
@@ -7,6 +7,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl
QT += core gui
diff --git a/mkspecs/macx-icc/qmake.conf b/mkspecs/macx-icc/qmake.conf
index b7753d8216..00de6c437a 100644
--- a/mkspecs/macx-icc/qmake.conf
+++ b/mkspecs/macx-icc/qmake.conf
@@ -13,6 +13,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release link_prl app_bundle
QT += core gui
diff --git a/mkspecs/macx-llvm/qmake.conf b/mkspecs/macx-llvm/qmake.conf
index de8040c340..d46baeaa37 100644
--- a/mkspecs/macx-llvm/qmake.conf
+++ b/mkspecs/macx-llvm/qmake.conf
@@ -7,6 +7,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl
QT += core gui
diff --git a/mkspecs/macx-xlc/qmake.conf b/mkspecs/macx-xlc/qmake.conf
index 6a8c24659e..f84524bbdf 100644
--- a/mkspecs/macx-xlc/qmake.conf
+++ b/mkspecs/macx-xlc/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release app_bundle global_init_link_order lib_version_first plugin_no_soname link_prl
QT += core gui
diff --git a/mkspecs/netbsd-g++/qmake.conf b/mkspecs/netbsd-g++/qmake.conf
index 622baceb7d..1cb449f5cd 100644
--- a/mkspecs/netbsd-g++/qmake.conf
+++ b/mkspecs/netbsd-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/openbsd-g++/qmake.conf b/mkspecs/openbsd-g++/qmake.conf
index 4204f65f67..c948c90dc5 100644
--- a/mkspecs/openbsd-g++/qmake.conf
+++ b/mkspecs/openbsd-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/qws/freebsd-generic-g++/qmake.conf b/mkspecs/qws/freebsd-generic-g++/qmake.conf
index 19d6709ac4..6e30d4fe17 100644
--- a/mkspecs/qws/freebsd-generic-g++/qmake.conf
+++ b/mkspecs/qws/freebsd-generic-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release
QT += core gui network
diff --git a/mkspecs/qws/macx-generic-g++/qmake.conf b/mkspecs/qws/macx-generic-g++/qmake.conf
index b724cbc322..f753222ed2 100644
--- a/mkspecs/qws/macx-generic-g++/qmake.conf
+++ b/mkspecs/qws/macx-generic-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = macx
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui network
diff --git a/mkspecs/qws/solaris-generic-g++/qmake.conf b/mkspecs/qws/solaris-generic-g++/qmake.conf
index db83a572df..f5874c22eb 100644
--- a/mkspecs/qws/solaris-generic-g++/qmake.conf
+++ b/mkspecs/qws/solaris-generic-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui network
diff --git a/mkspecs/sco-cc/qmake.conf b/mkspecs/sco-cc/qmake.conf
index f682f49285..6eb5ca12ec 100644
--- a/mkspecs/sco-cc/qmake.conf
+++ b/mkspecs/sco-cc/qmake.conf
@@ -8,6 +8,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
QT += core gui
CONFIG += qt warn_on release link_prl
diff --git a/mkspecs/sco-g++/qmake.conf b/mkspecs/sco-g++/qmake.conf
index 268bf320d9..746cf2ceb0 100644
--- a/mkspecs/sco-g++/qmake.conf
+++ b/mkspecs/sco-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/solaris-cc-64/qmake.conf b/mkspecs/solaris-cc-64/qmake.conf
index d51d77a883..3d35d62e30 100644
--- a/mkspecs/solaris-cc-64/qmake.conf
+++ b/mkspecs/solaris-cc-64/qmake.conf
@@ -22,6 +22,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/solaris-cc/qmake.conf b/mkspecs/solaris-cc/qmake.conf
index 354b83cba1..0c97620111 100644
--- a/mkspecs/solaris-cc/qmake.conf
+++ b/mkspecs/solaris-cc/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/solaris-g++-64/qmake.conf b/mkspecs/solaris-g++-64/qmake.conf
index e89aff3f8c..587c630046 100644
--- a/mkspecs/solaris-g++-64/qmake.conf
+++ b/mkspecs/solaris-g++-64/qmake.conf
@@ -26,6 +26,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/solaris-g++/qmake.conf b/mkspecs/solaris-g++/qmake.conf
index bce0889686..08149807ea 100644
--- a/mkspecs/solaris-g++/qmake.conf
+++ b/mkspecs/solaris-g++/qmake.conf
@@ -9,6 +9,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/symbian-abld/qmake.conf b/mkspecs/symbian-abld/qmake.conf
index 499bf63cd3..33b897d1b8 100644
--- a/mkspecs/symbian-abld/qmake.conf
+++ b/mkspecs/symbian-abld/qmake.conf
@@ -5,5 +5,6 @@
#
MAKEFILE_GENERATOR = SYMBIAN_ABLD
+option(recursive)
include(../common/symbian/symbian.conf)
diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm
index 3defe304c9..3877edb28e 100644
--- a/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm
+++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm
@@ -7,14 +7,12 @@
# **
# ****************************************************************************/
-include $(FLMHOME)/metaflm.mk
SINGLETON:=$(call sanitise,TARGET_$(DEPLOY_TARGET))
CLEAN_TARGET:=
define qmake_emulator_deployment
$(ALLTARGET):: $(1)
-FINAL::$(1)
# Prevent duplicate targets from being created
$(SINGLETON):=1
diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm
index 79ab8cb823..daf33d499a 100644
--- a/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm
+++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_extra_pre_targetdep.flm
@@ -7,21 +7,17 @@
# **
# ****************************************************************************/
-include $(FLMHOME)/metaflm.mk
SINGLETON:=$(call sanitise,TARGET_$(PREDEP_TARGET))
define qmake_extra_pre_targetdep
-$(ALLTARGET):: $(PREDEP_TARGET)
EXPORT:: $(PREDEP_TARGET)
-LIBRARY:: $(PREDEP_TARGET)
-TARGET:: $(PREDEP_TARGET)
# Prevent duplicate targets from being created
$(SINGLETON):=1
-$(PREDEP_TARGET): $(DEPS)
- $(call startrule,qmake_extra_pre_targetdep) \
+$(PREDEP_TARGET): $(DEPS)
+ $(call startrule,qmake_extra_pre_targetdep,FORCESUCCESS) \
$(COMMAND) \
$(call endrule,qmake_extra_pre_targetdep)
endef
diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_post_link.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_post_link.flm
index 8ad89e7131..9612d2efcc 100644
--- a/mkspecs/symbian-sbsv2/flm/qt/qmake_post_link.flm
+++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_post_link.flm
@@ -7,7 +7,6 @@
# **
# ****************************************************************************/
-include $(FLMHOME)/metaflm.mk
POST_LINK_TARGET:=POST_LINK_$(PLATFORM_PATH)_$(CFG_PATH)_$(call sanitise,$(LINK_TARGET))
POST_LINK_DEP:=$(EPOCROOT)/epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/$(LINK_TARGET)
@@ -21,7 +20,6 @@ endef
define qmake_post_link
$(ALLTARGET):: $(POST_LINK_TARGET)
-FINAL:: $(POST_LINK_TARGET)
$(POST_LINK_TARGET): $(POST_LINK_DEP)
$(call startrule,qmake_post_link) \
diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm
index d952f8fc63..e0b65033d1 100644
--- a/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm
+++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_store_build.flm
@@ -7,7 +7,6 @@
# **
# ****************************************************************************/
-include $(FLMHOME)/metaflm.mk
SINGLETON:=$(call sanitise,TSTORE_SINGLETON_$(EXTENSION_ROOT))
@@ -27,7 +26,7 @@ VISUAL_CFG:=RELEASE
endif
define qmake_store_build
-FINAL:: $(STORE_BUILD_TARGET)
+$(ALLTARGET):: $(STORE_BUILD_TARGET)
$(STORE_BUILD_TARGET):
$(call startrule,qmake_store_build) \
diff --git a/mkspecs/symbian-sbsv2/flm/qt/qt.xml b/mkspecs/symbian-sbsv2/flm/qt/qt.xml
index 904f113365..0f7db3cfe6 100644
--- a/mkspecs/symbian-sbsv2/flm/qt/qt.xml
+++ b/mkspecs/symbian-sbsv2/flm/qt/qt.xml
@@ -16,7 +16,7 @@
<!-- Extension interfaces : replacements for Template Extension Makefiles -->
- <interface name="qt.qmake_extra_pre_targetdep" extends="Symbian.UserFLM"
+ <interface name="qt.qmake_extra_pre_targetdep.export" extends="Symbian.UserFLM"
flm="qmake_extra_pre_targetdep.flm">
<param name='PREDEP_TARGET' />
<param name='DEPS' default = '' />
diff --git a/mkspecs/symbian-sbsv2/qmake.conf b/mkspecs/symbian-sbsv2/qmake.conf
index 0a5e8782bf..585e645405 100644
--- a/mkspecs/symbian-sbsv2/qmake.conf
+++ b/mkspecs/symbian-sbsv2/qmake.conf
@@ -5,5 +5,6 @@
#
MAKEFILE_GENERATOR = SYMBIAN_SBSV2
+option(recursive)
include(../common/symbian/symbian.conf)
diff --git a/mkspecs/tru64-cxx/qmake.conf b/mkspecs/tru64-cxx/qmake.conf
index 8cef84d81b..88021df958 100644
--- a/mkspecs/tru64-cxx/qmake.conf
+++ b/mkspecs/tru64-cxx/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl plugin_no_soname
QT += core gui
diff --git a/mkspecs/tru64-g++/qmake.conf b/mkspecs/tru64-g++/qmake.conf
index 7749013eaf..71e5682485 100644
--- a/mkspecs/tru64-g++/qmake.conf
+++ b/mkspecs/tru64-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl plugin_no_soname
QT += core gui
diff --git a/mkspecs/unixware-cc/qmake.conf b/mkspecs/unixware-cc/qmake.conf
index 978aaa178a..5fb2b2cc3c 100644
--- a/mkspecs/unixware-cc/qmake.conf
+++ b/mkspecs/unixware-cc/qmake.conf
@@ -8,6 +8,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unixware-g++/qmake.conf b/mkspecs/unixware-g++/qmake.conf
index ce1a0f1c0b..b6a438a0b3 100644
--- a/mkspecs/unixware-g++/qmake.conf
+++ b/mkspecs/unixware-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unsupported/linux-scratchbox2-g++/qmake.conf b/mkspecs/unsupported/linux-scratchbox2-g++/qmake.conf
index 1ade6b9b84..28e7754066 100644
--- a/mkspecs/unsupported/linux-scratchbox2-g++/qmake.conf
+++ b/mkspecs/unsupported/linux-scratchbox2-g++/qmake.conf
@@ -12,6 +12,7 @@
# $staging/usr/lib/pkgconfig)
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
diff --git a/mkspecs/unsupported/qnx-g++/qmake.conf b/mkspecs/unsupported/qnx-g++/qmake.conf
index 2e568dcabc..37e7bceec0 100644
--- a/mkspecs/unsupported/qnx-g++/qmake.conf
+++ b/mkspecs/unsupported/qnx-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unsupported/qws/qnx-641/qmake.conf b/mkspecs/unsupported/qws/qnx-641/qmake.conf
index db333b77ea..12eaf1d301 100644
--- a/mkspecs/unsupported/qws/qnx-641/qmake.conf
+++ b/mkspecs/unsupported/qws/qnx-641/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unsupported/qws/qnx-generic-g++/qmake.conf b/mkspecs/unsupported/qws/qnx-generic-g++/qmake.conf
index 51fe69736c..62857bf220 100644
--- a/mkspecs/unsupported/qws/qnx-generic-g++/qmake.conf
+++ b/mkspecs/unsupported/qws/qnx-generic-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf b/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf
index fffb80fa67..dce60ea539 100644
--- a/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf
+++ b/mkspecs/unsupported/qws/qnx-i386-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unsupported/qws/qnx-ppc-g++/qmake.conf b/mkspecs/unsupported/qws/qnx-ppc-g++/qmake.conf
index 56a9c66aea..93d04ffffb 100644
--- a/mkspecs/unsupported/qws/qnx-ppc-g++/qmake.conf
+++ b/mkspecs/unsupported/qws/qnx-ppc-g++/qmake.conf
@@ -5,6 +5,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release link_prl
QT += core gui
diff --git a/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf b/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf
index a8f7e49b56..fc0b12587c 100644
--- a/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf
+++ b/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl vxworks
QT += core gui network
diff --git a/mkspecs/unsupported/vxworks-ppc-g++/qmake.conf b/mkspecs/unsupported/vxworks-ppc-g++/qmake.conf
index be8c13d0b6..80b5f3e088 100644
--- a/mkspecs/unsupported/vxworks-ppc-g++/qmake.conf
+++ b/mkspecs/unsupported/vxworks-ppc-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl vxworks
QT += core gui network
diff --git a/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf b/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf
index 6228a6be3a..be351725d9 100644
--- a/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf
+++ b/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl vxworks
QT += core gui network
diff --git a/mkspecs/unsupported/vxworks-simpentium-g++/qmake.conf b/mkspecs/unsupported/vxworks-simpentium-g++/qmake.conf
index 29e9c70c5d..83f46c052a 100644
--- a/mkspecs/unsupported/vxworks-simpentium-g++/qmake.conf
+++ b/mkspecs/unsupported/vxworks-simpentium-g++/qmake.conf
@@ -3,6 +3,7 @@
#
MAKEFILE_GENERATOR = UNIX
+TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl vxworks
QT += core gui network
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index ec712a06c1..a8c1c3cd6d 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -2152,12 +2152,14 @@ QString MakefileGenerator::buildArgs(const QString &outdir)
ret += " -nodependheuristics";
if(!Option::mkfile::qmakespec_commandline.isEmpty())
ret += " -spec " + specdir(outdir);
- if(Option::target_mode == Option::TARG_MACX_MODE)
- ret += " -macx";
- else if(Option::target_mode == Option::TARG_UNIX_MODE)
- ret += " -unix";
- else if(Option::target_mode == Option::TARG_WIN_MODE)
- ret += " -win32";
+ if (Option::target_mode_overridden) {
+ if (Option::target_mode == Option::TARG_MACX_MODE)
+ ret += " -macx";
+ else if (Option::target_mode == Option::TARG_UNIX_MODE)
+ ret += " -unix";
+ else if (Option::target_mode == Option::TARG_WIN_MODE)
+ ret += " -win32";
+ }
//configs
for(QStringList::Iterator it = Option::user_configs.begin();
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index d89c3b15bd..addb1f5ed3 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -247,7 +247,8 @@ public:
virtual bool supportsMergedBuilds() { return false; }
virtual bool mergeBuildProject(MakefileGenerator * /*other*/) { return false; }
virtual bool openOutput(QFile &, const QString &build) const;
- virtual bool isWindowsShell() const { return Option::target_mode == Option::TARG_WIN_MODE; }
+ virtual bool isWindowsShell() const { return Option::host_mode == Option::HOST_WIN_MODE; }
+ virtual bool isForSymbianSbsv2() const { return false; } // FIXME: killme - i'm ugly!
};
inline void MakefileGenerator::setNoIO(bool o)
diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp
index f48491ca80..bc8927c702 100644
--- a/qmake/generators/metamakefile.cpp
+++ b/qmake/generators/metamakefile.cpp
@@ -293,7 +293,15 @@ SubdirsMetaMakefileGenerator::init()
init_flag = true;
bool hasError = false;
- if(Option::recursive) {
+ // It might make sense to bequeath the CONFIG option to the recursed
+ // projects. OTOH, one would most likely have it in all projects anyway -
+ // either through a qmakespec, a .qmake.cache or explicitly - as otherwise
+ // running qmake in a subdirectory would have a different auto-recurse
+ // setting than in parent directories.
+ bool recurse = Option::recursive == Option::QMAKE_RECURSIVE_YES
+ || (Option::recursive == Option::QMAKE_RECURSIVE_DEFAULT
+ && project->isRecursive());
+ if(recurse) {
QString old_output_dir = Option::output_dir;
QString old_output = Option::output.fileName();
QString oldpwd = qmake_getpwd();
@@ -375,7 +383,7 @@ SubdirsMetaMakefileGenerator::init()
Subdir *self = new Subdir;
self->input_dir = qmake_getpwd();
self->output_dir = Option::output_dir;
- if(!Option::recursive || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir()))
+ if(!recurse || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir()))
self->output_file = Option::output.fileName();
self->makefile = new BuildsMetaMakefileGenerator(project, name, false);
self->makefile->init();
@@ -458,7 +466,7 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO)
} else if(gen == "PROJECTBUILDER" || gen == "XCODE") {
mkfile = new ProjectBuilderMakefileGenerator;
} else if(gen == "MSVC.NET") {
- if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1)
+ if (proj->first("TEMPLATE").startsWith("vc"))
mkfile = new VcprojGenerator;
else
mkfile = new NmakeMakefileGenerator;
@@ -478,6 +486,40 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO)
return mkfile;
}
+bool
+MetaMakefileGenerator::modesForGenerator(const QString &gen,
+ Option::HOST_MODE *host_mode, Option::TARG_MODE *target_mode)
+{
+ if (gen == "UNIX") {
+#ifdef Q_OS_MAC
+ *host_mode = Option::HOST_MACX_MODE;
+ *target_mode = Option::TARG_MACX_MODE;
+#else
+ *host_mode = Option::HOST_UNIX_MODE;
+ *target_mode = Option::TARG_UNIX_MODE;
+#endif
+ } else if (gen == "MSVC.NET" || gen == "MINGW" || gen == "BMAKE") {
+ *host_mode = Option::HOST_WIN_MODE;
+ *target_mode = Option::TARG_WIN_MODE;
+ } else if (gen == "PROJECTBUILDER" || gen == "XCODE") {
+ *host_mode = Option::HOST_MACX_MODE;
+ *target_mode = Option::TARG_MACX_MODE;
+ } else if (gen == "SYMBIAN_ABLD" || gen == "SYMBIAN_SBSV2") {
+#if defined(Q_OS_MAC)
+ *host_mode = Option::HOST_MACX_MODE;
+#elif defined(Q_OS_UNIX)
+ *host_mode = Option::HOST_UNIX_MODE;
+#else
+ *host_mode = Option::HOST_WIN_MODE;
+#endif
+ *target_mode = Option::TARG_SYMBIAN_MODE;
+ } else {
+ fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData());
+ return false;
+ }
+ return true;
+}
+
MetaMakefileGenerator *
MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op, bool *success)
{
diff --git a/qmake/generators/metamakefile.h b/qmake/generators/metamakefile.h
index 867511589b..e559c8e863 100644
--- a/qmake/generators/metamakefile.h
+++ b/qmake/generators/metamakefile.h
@@ -42,6 +42,8 @@
#ifndef METAMAKEFILE_H
#define METAMAKEFILE_H
+#include <option.h>
+
#include <qlist.h>
#include <qstring.h>
@@ -65,6 +67,9 @@ public:
static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true, bool *success = 0);
static MakefileGenerator *createMakefileGenerator(QMakeProject *proj, bool noIO = false);
+ static bool modesForGenerator(const QString &generator,
+ Option::HOST_MODE *host_mode, Option::TARG_MODE *target_mode);
+
inline QMakeProject *projectFile() const { return project; }
virtual bool init() = 0;
diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp
index 8622cd9fd4..d2256359db 100644
--- a/qmake/generators/projectgenerator.cpp
+++ b/qmake/generators/projectgenerator.cpp
@@ -111,7 +111,7 @@ ProjectGenerator::init()
add_depend = true;
if(dir.right(1) != Option::dir_sep)
dir += Option::dir_sep;
- if(Option::recursive) {
+ if(Option::recursive == Option::QMAKE_RECURSIVE_YES) {
QStringList files = QDir(dir).entryList(QDir::Files);
for(int i = 0; i < (int)files.count(); i++) {
if(files[i] != "." && files[i] != "..")
@@ -138,7 +138,7 @@ ProjectGenerator::init()
dir = regex.left(s+1);
regex = regex.right(regex.length() - (s+1));
}
- if(Option::recursive) {
+ if(Option::recursive == Option::QMAKE_RECURSIVE_YES) {
QStringList entries = QDir(dir).entryList(QDir::Dirs);
for(int i = 0; i < (int)entries.count(); i++) {
if(entries[i] != "." && entries[i] != "..") {
@@ -193,7 +193,7 @@ ProjectGenerator::init()
subdirs.append(nd);
}
}
- if(Option::recursive) {
+ if(Option::recursive == Option::QMAKE_RECURSIVE_YES) {
QStringList dirs = QDir(newdir).entryList(QDir::Dirs);
for(int i = 0; i < (int)dirs.count(); i++) {
QString nd = fileFixify(newdir + QDir::separator() + dirs[i]);
@@ -230,7 +230,8 @@ ProjectGenerator::init()
}
}
}
- if(Option::recursive && !knownDirs.contains(newdir, Qt::CaseInsensitive))
+ if(Option::recursive == Option::QMAKE_RECURSIVE_YES
+ && !knownDirs.contains(newdir, Qt::CaseInsensitive))
knownDirs.append(newdir);
}
}
diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.cpp b/qmake/generators/symbian/initprojectdeploy_symbian.cpp
index 0d501129ef..81c940840b 100644
--- a/qmake/generators/symbian/initprojectdeploy_symbian.cpp
+++ b/qmake/generators/symbian/initprojectdeploy_symbian.cpp
@@ -49,12 +49,18 @@
// Included from tools/shared
#include <symbian/epocroot.h>
-#define SYSBIN_DIR "\\sys\\bin"
+#define SYSBIN_DIR "/sys/bin"
#define SUFFIX_DLL "dll"
#define SUFFIX_EXE "exe"
#define SUFFIX_QTPLUGIN "qtplugin"
+static QString fixPathToEpocOS(const QString &src)
+{
+ QString ret = Option::fixPathToTargetOS(src);
+ return ret.replace('/', '\\');
+}
+
static bool isPlugin(const QFileInfo& info, const QString& devicePath)
{
// Libraries are plugins if deployment path is something else than
@@ -85,12 +91,12 @@ static void createPluginStub(const QFileInfo& info,
QStringList& generatedDirs,
QStringList& generatedFiles)
{
- QDir().mkpath(PLUGIN_STUB_DIR);
+ QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR));
if (!generatedDirs.contains(PLUGIN_STUB_DIR))
generatedDirs << PLUGIN_STUB_DIR;
// Plugin stubs must have different name from the actual plugins, because
// the toolchain for creating ROM images cannot handle non-binary .dll files properly.
- QFile stubFile(QDir(PLUGIN_STUB_DIR).filePath(info.completeBaseName() + "." SUFFIX_QTPLUGIN));
+ QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "/") + info.completeBaseName() + "." SUFFIX_QTPLUGIN);
if (stubFile.open(QIODevice::WriteOnly)) {
if (!generatedFiles.contains(stubFile.fileName()))
generatedFiles << stubFile.fileName();
@@ -104,7 +110,7 @@ static void createPluginStub(const QFileInfo& info,
}
QFileInfo stubInfo(stubFile);
deploymentList.append(CopyItem(Option::fixPathToLocalOS(stubInfo.absoluteFilePath()),
- Option::fixPathToLocalOS(devicePath + "\\" + stubInfo.fileName())));
+ fixPathToEpocOS(devicePath + "/" + stubInfo.fileName())));
}
QString generate_uid(const QString& target)
@@ -168,21 +174,29 @@ void initProjectDeploySymbian(QMakeProject* project,
foreach(QString item, project->values("DEPLOYMENT")) {
QString devicePath = project->first(item + ".path");
+ QString devicePathWithoutDrive = devicePath;
+
+ bool devicePathHasDriveLetter = false;
+ if (devicePath.size() > 1) {
+ devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':');
+ }
+
+ // Sometimes devicePath can contain disk but APP_RESOURCE_DIR does not,
+ // so remove the drive letter for comparison purposes.
+ if (devicePathHasDriveLetter)
+ {
+ devicePathWithoutDrive.remove(0,2);
+ }
if (!deployBinaries
- && !devicePath.isEmpty()
- && (0 == devicePath.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive)
- || 0 == devicePath.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) {
+ && !devicePathWithoutDrive.isEmpty()
+ && (0 == devicePathWithoutDrive.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive)
+ || 0 == devicePathWithoutDrive.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) {
// Do not deploy resources in emulator builds, as that seems to cause conflicts
// If there is ever a real need to deploy pre-built resources for emulator,
// BLD_INF_RULES.prj_exports can be used as a workaround.
continue;
}
- bool devicePathHasDriveLetter = false;
- if (devicePath.size() > 1) {
- devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':');
- }
-
if (devicePath.isEmpty() || devicePath == QLatin1String(".")) {
devicePath = targetPath;
}
@@ -190,24 +204,35 @@ void initProjectDeploySymbian(QMakeProject* project,
else if (!(devicePath.at(0) == QLatin1Char('/')
|| devicePath.at(0) == QLatin1Char('\\')
|| devicePathHasDriveLetter)) {
- // create output path
- devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath));
+ // Create output path
+ devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('/') + devicePath));
} else {
- if (0 == platform.compare(QLatin1String("winscw"), Qt::CaseInsensitive)) {
+ if (!platform.compare(QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM))) {
if (devicePathHasDriveLetter) {
- devicePath = epocRoot() + "epoc32\\winscw\\" + devicePath.remove(1, 1);
+ devicePath = epocRoot() + "epoc32/winscw/" + devicePath.remove(1, 1);
} else {
- devicePath = epocRoot() + "epoc32\\winscw\\c" + devicePath;
+ devicePath = epocRoot() + "epoc32/winscw/c" + devicePath;
}
} else {
- // Drive letter needed if targetpath contains one and it is not already in
- if (targetPathHasDriveLetter && !devicePathHasDriveLetter) {
- devicePath = deploymentDrive + devicePath;
+ if (!devicePathHasDriveLetter) {
+ if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) {
+ //For plugin deployment under ARM no needed drive letter
+ devicePath = epocRoot() + "epoc32/data/z" + devicePath;
+ } else if (targetPathHasDriveLetter) {
+ // Drive letter needed if targetpath contains one and it is not already in
+ devicePath = deploymentDrive + devicePath;
+ }
+ } else {
+ //it is necessary to delete drive letter for ARM deployment
+ if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) {
+ devicePath.remove(0,2);
+ devicePath = epocRoot() + "epoc32/data/z" + devicePath;
+ }
}
}
}
- devicePath.replace(QLatin1String("/"), QLatin1String("\\"));
+ devicePath.replace(QLatin1String("\\"), QLatin1String("/"));
if (!deployBinaries &&
0 == devicePath.right(8).compare(QLatin1String(SYSBIN_DIR), Qt::CaseInsensitive)) {
@@ -231,7 +256,7 @@ void initProjectDeploySymbian(QMakeProject* project,
dirSearch = true;
} else {
if (info.exists() || source.indexOf('*') != -1) {
- nameFilter = source.split('\\').last();
+ nameFilter = source.split(QDir::separator()).last();
searchPath = info.absolutePath();
} else {
// Entry was not found. That is ok if it is a binary, since those do not necessarily yet exist.
@@ -239,13 +264,19 @@ void initProjectDeploySymbian(QMakeProject* project,
if (isBinary(info)) {
if (deployBinaries) {
// Executables and libraries are deployed to \sys\bin
- QFileInfo releasePath(epocRoot() + QDir::toNativeSeparators("epoc32/release/" + platform + "/" + build + "/"));
+ QFileInfo targetPath(epocRoot() + "epoc32/release/" + platform + "/" + build + "/");
if(devicePathHasDriveLetter) {
- deploymentList.append(CopyItem(Option::fixPathToLocalOS(QDir(releasePath.absolutePath()).filePath(info.fileName()), false, true),
- Option::fixPathToLocalOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "\\") + info.fileName())));
+ deploymentList.append(CopyItem(
+ Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(),
+ false, true),
+ fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/")
+ + info.fileName())));
} else {
- deploymentList.append(CopyItem(Option::fixPathToLocalOS(QDir(releasePath.absolutePath()).filePath(info.fileName()), false, true),
- Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + info.fileName())));
+ deploymentList.append(CopyItem(
+ Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(),
+ false, true),
+ fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/")
+ + info.fileName())));
}
}
if (isPlugin(info, devicePath)) {
@@ -256,7 +287,7 @@ void initProjectDeploySymbian(QMakeProject* project,
// Generate deployment even if file doesn't exist, as this may be the case
// when generating .pkg files.
deploymentList.append(CopyItem(Option::fixPathToLocalOS(info.absoluteFilePath()),
- Option::fixPathToLocalOS(devicePath + "\\" + info.fileName())));
+ fixPathToEpocOS(devicePath + "/" + info.fileName())));
continue;
}
}
@@ -278,14 +309,26 @@ void initProjectDeploySymbian(QMakeProject* project,
// This deploys pre-built plugins. Other pre-built binaries will deploy normally,
// as they have SYSBIN_DIR target path.
if (deployBinaries) {
- deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "\\" + iterator.fileName()),
- Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "\\") + iterator.fileName())));
+ if (devicePathHasDriveLetter) {
+ deploymentList.append(CopyItem(
+ Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
+ fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/")
+ + iterator.fileName())));
+ } else {
+ deploymentList.append(CopyItem(
+ Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
+ fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/")
+ + iterator.fileName())));
+ }
}
- createPluginStub(info, devicePath + "\\" + absoluteItemPath.right(diffSize), deploymentList, generatedDirs, generatedFiles);
+ createPluginStub(info, devicePath + "/" + absoluteItemPath.right(diffSize),
+ deploymentList, generatedDirs, generatedFiles);
continue;
} else {
- deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "\\" + iterator.fileName()),
- Option::fixPathToLocalOS(devicePath + "\\" + absoluteItemPath.right(diffSize) + "\\" + iterator.fileName())));
+ deploymentList.append(CopyItem(
+ Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()),
+ fixPathToEpocOS(devicePath + "/" + absoluteItemPath.right(diffSize)
+ + "/" + iterator.fileName())));
}
}
}
diff --git a/qmake/generators/symbian/initprojectdeploy_symbian.h b/qmake/generators/symbian/initprojectdeploy_symbian.h
index b409225a04..c621915c7c 100644
--- a/qmake/generators/symbian/initprojectdeploy_symbian.h
+++ b/qmake/generators/symbian/initprojectdeploy_symbian.h
@@ -51,6 +51,8 @@
#include <stdlib.h>
#define PLUGIN_STUB_DIR "qmakepluginstubs"
+#define ROM_DEPLOYMENT_PLATFORM "rom"
+#define EMULATOR_DEPLOYMENT_PLATFORM "emulator"
struct CopyItem
{
diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp
index ac4bca342d..214f95cefa 100644
--- a/qmake/generators/symbian/symmake.cpp
+++ b/qmake/generators/symbian/symmake.cpp
@@ -64,7 +64,7 @@
#define BLD_INF_TAG_MMPFILES "prj_mmpfiles"
#define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
#define BLD_INF_TAG_EXTENSIONS "prj_extensions"
-#define BLD_INF_TAG_EXPORTS "prj_exports"
+#define BLD_INF_TAG_TESTEXTENSIONS "prj_testextensions"
#define RSS_RULES "RSS_RULES"
#define RSS_RULES_BASE "RSS_RULES."
@@ -101,11 +101,13 @@ QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const Q
{
static QString epocRootStr;
if (epocRootStr.isEmpty()) {
- QFileInfo efi(epocRoot());
- epocRootStr = efi.canonicalFilePath();
- if (epocRootStr.isEmpty()) {
+ epocRootStr = epocRoot();
+ QFileInfo efi(epocRootStr);
+ if (!efi.exists() || epocRootStr.isEmpty()) {
fprintf(stderr, "Unable to resolve epocRoot '%s' to real dir on current drive, defaulting to '/' for mmp paths\n", qPrintable(epocRoot()));
epocRootStr = "/";
+ } else {
+ epocRootStr = efi.absoluteFilePath();
}
if (!epocRootStr.endsWith("/"))
epocRootStr += "/";
@@ -129,33 +131,26 @@ QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const Q
return resultPath;
}
-QString SymbianMakefileGenerator::canonizePath(const QString& origPath)
+QString SymbianMakefileGenerator::absolutizePath(const QString& origPath)
{
- // Since current path gets appended almost always anyway, use it as default
- // for nonexisting paths.
- static QString defaultPath;
- if (defaultPath.isEmpty()) {
- QFileInfo fi(".");
- defaultPath = fi.canonicalFilePath();
- }
-
// Prepend epocroot to any paths beginning with "/epoc32/"
QString resultPath = QDir::fromNativeSeparators(origPath);
if (resultPath.startsWith("/epoc32/", Qt::CaseInsensitive))
resultPath = QDir::fromNativeSeparators(epocRoot()) + resultPath.mid(1);
QFileInfo fi(fileInfo(resultPath));
- if (fi.isDir()) {
- resultPath = fi.canonicalFilePath();
+
+ // Since origPath can be something given in HEADERS, we need to check if we are dealing
+ // with a file or a directory. In case the origPath doesn't yet exist, isFile() returns
+ // false and we default to assuming it is a dir.
+ if (fi.isFile()) {
+ resultPath = fi.absolutePath();
} else {
- resultPath = fi.canonicalPath();
+ resultPath = fi.absoluteFilePath();
}
resultPath = QDir::cleanPath(resultPath);
- if (resultPath.isEmpty())
- resultPath = defaultPath;
-
return resultPath;
}
@@ -687,7 +682,7 @@ void SymbianMakefileGenerator::initMmpVariables()
srcpaths << project->values("UI_DIR");
QDir current = QDir::current();
- QString canonizedCurrent = canonizePath(".");
+ QString absolutizedCurrent = absolutizePath(".");
for (int j = 0; j < srcpaths.size(); ++j) {
QFileInfo fi(fileInfo(srcpaths.at(j)));
@@ -695,10 +690,10 @@ void SymbianMakefileGenerator::initMmpVariables()
if (fi.suffix().startsWith("c")) {
if (fi.filePath().length() > fi.fileName().length()) {
appendIfnotExist(srcincpaths, fi.path());
- sources[canonizePath(fi.path())] += fi.fileName();
+ sources[absolutizePath(fi.path())] += fi.fileName();
} else {
- sources[canonizedCurrent] += fi.fileName();
- appendIfnotExist(srcincpaths, canonizedCurrent);
+ sources[absolutizedCurrent] += fi.fileName();
+ appendIfnotExist(srcincpaths, absolutizedCurrent);
}
}
}
@@ -712,7 +707,7 @@ void SymbianMakefileGenerator::initMmpVariables()
incpaths << project->values("UI_DIR");
for (int j = 0; j < incpaths.size(); ++j) {
- QString includepath = canonizePath(incpaths.at(j));
+ QString includepath = absolutizePath(incpaths.at(j));
appendIfnotExist(sysincspaths, includepath);
appendAbldTempDirs(sysincspaths, includepath);
}
@@ -754,15 +749,14 @@ void SymbianMakefileGenerator::initMmpVariables()
QStringList restrictedMmpKeywords;
bool inResourceBlock = false;
- overridableMmpKeywords << QLatin1String(MMP_TARGETTYPE);
+ overridableMmpKeywords << QLatin1String(MMP_TARGETTYPE) << QLatin1String(MMP_EPOCHEAPSIZE);
restrictableMmpKeywords << QLatin1String(MMP_TARGET) << QLatin1String(MMP_SECUREID)
<< QLatin1String(MMP_OPTION_CW) << QLatin1String(MMP_OPTION_ARMCC)
<< QLatin1String(MMP_OPTION_GCCE) << QLatin1String(MMP_LINKEROPTION_CW)
<< QLatin1String(MMP_LINKEROPTION_ARMCC) << QLatin1String(MMP_LINKEROPTION_GCCE)
<< QLatin1String(MMP_CAPABILITY) << QLatin1String(MMP_EPOCALLOWDLLDATA)
- << QLatin1String(MMP_EPOCHEAPSIZE) << QLatin1String(MMP_EPOCSTACKSIZE)
- << QLatin1String(MMP_UID) << QLatin1String(MMP_VENDORID)
- << QLatin1String(MMP_VERSION);
+ << QLatin1String(MMP_EPOCSTACKSIZE) << QLatin1String(MMP_UID)
+ << QLatin1String(MMP_VENDORID) << QLatin1String(MMP_VERSION);
foreach (QString item, project->values("MMP_RULES")) {
if (project->values(item).isEmpty()) {
@@ -932,6 +926,7 @@ void SymbianMakefileGenerator::addMacro(QTextStream& t, const QString& value)
void SymbianMakefileGenerator::writeMmpFileTargetPart(QTextStream& t)
{
bool skipTargetType = overriddenMmpKeywords.contains(MMP_TARGETTYPE);
+ bool skipEpocHeapSize = overriddenMmpKeywords.contains(MMP_EPOCHEAPSIZE);
if (targetType == TypeExe) {
t << MMP_TARGET "\t\t" << fixedTarget << ".exe" << endl;
@@ -983,7 +978,7 @@ void SymbianMakefileGenerator::writeMmpFileTargetPart(QTextStream& t)
if (0 != project->first("TARGET.EPOCSTACKSIZE").size())
t << MMP_EPOCSTACKSIZE "\t\t" << project->first("TARGET.EPOCSTACKSIZE") << endl;
- if (0 != project->values("TARGET.EPOCHEAPSIZE").size())
+ if (!skipEpocHeapSize && 0 != project->values("TARGET.EPOCHEAPSIZE").size())
t << MMP_EPOCHEAPSIZE "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl;
if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size())
t << MMP_EPOCALLOWDLLDATA << endl;
@@ -1362,7 +1357,7 @@ void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploy
// Add project mmps and old style extension makefiles
QString mmpTag;
- if (project->isActiveConfig("symbian_test"))
+ if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
mmpTag = QLatin1String(BLD_INF_TAG_TESTMMPFILES);
else
mmpTag = QLatin1String(BLD_INF_TAG_MMPFILES);
@@ -1385,35 +1380,22 @@ void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploy
t << item << endl;
userBldInfRules.remove(mmpTag);
- t << endl << BLD_INF_TAG_EXTENSIONS << endl << endl;
+ QString extensionTag;
+ if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
+ extensionTag = QLatin1String(BLD_INF_TAG_TESTEXTENSIONS);
+ else
+ extensionTag = QLatin1String(BLD_INF_TAG_EXTENSIONS);
+
+ t << endl << extensionTag << endl << endl;
// Generate extension rules
writeBldInfExtensionRulesPart(t, iconFile);
- userItems = userBldInfRules.value(BLD_INF_TAG_EXTENSIONS);
- foreach(QString item, userItems)
- t << item << endl;
- userBldInfRules.remove(BLD_INF_TAG_EXTENSIONS);
-
- t << endl << BLD_INF_TAG_EXPORTS << endl << endl;
-
- // Generate export rules
-
- // Export any deployed plugin stubs under /epoc32/data/z to support ROM builds
- for (int i = 0; i < depList.size(); ++i) {
- int index = depList.at(i).from.indexOf(PLUGIN_STUB_DIR);
- if (index != -1) {
- t << QString("%1 /epoc32/data/z%2")
- .arg(QString(depList.at(i).from).mid(index).replace('\\','/'))
- .arg(QString(depList.at(i).to).mid(2).replace('\\','/')) << endl;
- }
- }
-
- userItems = userBldInfRules.value(BLD_INF_TAG_EXPORTS);
+ userItems = userBldInfRules.value(extensionTag);
foreach(QString item, userItems)
t << item << endl;
- userBldInfRules.remove(BLD_INF_TAG_EXPORTS);
+ userBldInfRules.remove(extensionTag);
// Add rest of the user defined content
diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h
index 76fd98b6ca..fa55ae784b 100644
--- a/qmake/generators/symbian/symmake.h
+++ b/qmake/generators/symbian/symmake.h
@@ -49,9 +49,9 @@ QT_BEGIN_NAMESPACE
#define BLD_INF_FILENAME "bld.inf"
#define MAKEFILE_DEPENDENCY_SEPARATOR " \\\n\t"
-
#define QT_EXTRA_INCLUDE_DIR "tmp"
#define MAKE_CACHE_NAME ".make.cache"
+#define SYMBIAN_TEST_CONFIG "symbian_test"
class SymbianMakefileGenerator : public MakefileGenerator
{
@@ -84,7 +84,7 @@ protected:
void removeSpecialCharacters(QString& str);
QString fixPathForMmp(const QString& origPath, const QDir& parentDir);
- QString canonizePath(const QString& origPath);
+ QString absolutizePath(const QString& origPath);
virtual bool writeMakefile(QTextStream &t);
void generatePkgFile(const QString &iconFile, DeploymentList &depList);
diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp
index 81165f5ca1..42031b939f 100644
--- a/qmake/generators/symbian/symmake_abld.cpp
+++ b/qmake/generators/symbian/symmake_abld.cpp
@@ -59,6 +59,8 @@
#define FINALIZE_TARGET "finalize"
#define GENERATED_SOURCES_TARGET "generated_sources"
#define ALL_SOURCE_DEPS_TARGET "all_source_deps"
+#define DEPLOYMENT_TARGET "deployment"
+#define DEPLOYMENT_CLEAN_TARGET "deployment_clean"
#define WINSCW_DEPLOYMENT_TARGET "winscw_deployment"
#define WINSCW_DEPLOYMENT_CLEAN_TARGET "winscw_deployment_clean"
#define STORE_BUILD_TARGET "store_build"
@@ -112,25 +114,29 @@ void SymbianAbldMakefileGenerator::writeMkFile(const QString& wrapperFileName, b
QStringList wrapperTargets;
if (deploymentOnly) {
buildDeps.append(STORE_BUILD_TARGET);
- cleanDeps.append(DO_NOTHING_TARGET);
- cleanDepsWinscw.append(WINSCW_DEPLOYMENT_CLEAN_TARGET);
- finalDeps.append(DO_NOTHING_TARGET);
- finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET);
+ cleanDeps.append(DEPLOYMENT_CLEAN_TARGET);
+ cleanDepsWinscw.append(WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET);
+ finalDeps.append(DEPLOYMENT_TARGET);
+ finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET);
wrapperTargets << WINSCW_DEPLOYMENT_TARGET
<< WINSCW_DEPLOYMENT_CLEAN_TARGET
+ << DEPLOYMENT_TARGET
+ << DEPLOYMENT_CLEAN_TARGET
<< STORE_BUILD_TARGET;
} else {
buildDeps.append(CREATE_TEMPS_TARGET " " PRE_TARGETDEPS_TARGET " " STORE_BUILD_TARGET);
- cleanDeps.append(EXTENSION_CLEAN);
- cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET);
- finalDeps.append(FINALIZE_TARGET);
- finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET);
+ cleanDeps.append(EXTENSION_CLEAN " " DEPLOYMENT_CLEAN_TARGET);
+ cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET);
+ finalDeps.append(FINALIZE_TARGET " " DEPLOYMENT_TARGET);
+ finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET);
wrapperTargets << PRE_TARGETDEPS_TARGET
<< CREATE_TEMPS_TARGET
<< EXTENSION_CLEAN
<< FINALIZE_TARGET
<< WINSCW_DEPLOYMENT_CLEAN_TARGET
<< WINSCW_DEPLOYMENT_TARGET
+ << DEPLOYMENT_CLEAN_TARGET
+ << DEPLOYMENT_TARGET
<< STORE_BUILD_TARGET;
}
@@ -175,7 +181,7 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool
releasePlatforms.removeAll("winscw"); // No release for emulator
QString testClause;
- if (project->isActiveConfig("symbian_test"))
+ if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
testClause = QLatin1String(" test");
else
testClause = QLatin1String("");
@@ -369,7 +375,9 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool
qDeleteAll(subtargets);
}
- writeDeploymentTargets(t);
+ // Deploymend targets for both emulator and rom deployment
+ writeDeploymentTargets(t, false);
+ writeDeploymentTargets(t, true);
generateDistcleanTargets(t);
@@ -410,13 +418,21 @@ void SymbianAbldMakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t,
Q_UNUSED(iconTargetFile);
}
-bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t)
+bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t, bool isRom)
{
- t << WINSCW_DEPLOYMENT_TARGET ":" << endl;
+ if (isRom)
+ t << DEPLOYMENT_TARGET ":" << endl;
+ else
+ t << WINSCW_DEPLOYMENT_TARGET ":" << endl;
- QString remoteTestPath = epocRoot() + QLatin1String("epoc32\\winscw\\c\\private\\") + privateDirUid; // default 4 OpenC; 4 all Symbian too
+ QString remoteTestPath = epocRoot()
+ + QLatin1String(isRom ? "epoc32\\data\\z\\private\\" : "epoc32\\winscw\\c\\private\\")
+ + privateDirUid;
DeploymentList depList;
- initProjectDeploySymbian(project, depList, remoteTestPath, false, QLatin1String("winscw"), QLatin1String("udeb"), generatedDirs, generatedFiles);
+
+ initProjectDeploySymbian(project, depList, remoteTestPath, false,
+ QLatin1String(isRom ? ROM_DEPLOYMENT_PLATFORM : EMULATOR_DEPLOYMENT_PLATFORM),
+ QString(), generatedDirs, generatedFiles);
if (depList.size())
t << "\t-echo Deploying changed files..." << endl;
@@ -425,12 +441,17 @@ bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t)
// Xcopy prompts for selecting file or directory if target doesn't exist,
// and doesn't provide switch to force file selection. It does provide dir forcing, though,
// so strip the last part of the destination.
- t << "\t-$(XCOPY) \"" << depList.at(i).from << "\" \"" << depList.at(i).to.left(depList.at(i).to.lastIndexOf("\\") + 1) << "\"" << endl;
+ t << "\t-$(XCOPY) \"" << depList.at(i).from << "\" \""
+ << depList.at(i).to.left(depList.at(i).to.lastIndexOf("\\") + 1) << "\"" << endl;
}
t << endl;
- t << WINSCW_DEPLOYMENT_CLEAN_TARGET ":" << endl;
+ if (isRom)
+ t << DEPLOYMENT_CLEAN_TARGET ":" << endl;
+ else
+ t << WINSCW_DEPLOYMENT_CLEAN_TARGET ":" << endl;
+
QStringList cleanList;
for (int i = 0; i < depList.size(); ++i) {
cleanList.append(depList.at(i).to);
diff --git a/qmake/generators/symbian/symmake_abld.h b/qmake/generators/symbian/symmake_abld.h
index d0f38b0acd..f998b28bde 100644
--- a/qmake/generators/symbian/symmake_abld.h
+++ b/qmake/generators/symbian/symmake_abld.h
@@ -57,7 +57,7 @@ protected:
virtual void writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile);
virtual void appendAbldTempDirs(QStringList& sysincspaths, QString includepath);
- bool writeDeploymentTargets(QTextStream &t);
+ bool writeDeploymentTargets(QTextStream &t, bool isRom);
public:
diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp
index 4366f0e265..4391a649f2 100644
--- a/qmake/generators/symbian/symmake_sbsv2.cpp
+++ b/qmake/generators/symbian/symmake_sbsv2.cpp
@@ -90,6 +90,23 @@ void SymbianSbsv2MakefileGenerator::exportFlm()
}
}
+void SymbianSbsv2MakefileGenerator::writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t)
+{
+ for (int i = 0; i < depList.size(); ++i) {
+ t << "START EXTENSION qt/qmake_emulator_deployment" << endl;
+ QString fromItem = depList.at(i).from;
+ QString toItem = depList.at(i).to;
+ fromItem.replace("\\", "/");
+ toItem.replace("\\", "/");
+#if defined(Q_OS_WIN)
+ toItem.prepend(QDir::current().absolutePath().left(2)); // add drive
+#endif
+ t << "OPTION DEPLOY_SOURCE " << fromItem << endl;
+ t << "OPTION DEPLOY_TARGET " << toItem << endl;
+ t << "END" << endl;
+ }
+}
+
void SymbianSbsv2MakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly)
{
// Can't use extension makefile with sbsv2
@@ -109,7 +126,7 @@ void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, boo
releasePlatforms.removeAll("winscw"); // No release for emulator
QString testClause;
- if (project->isActiveConfig("symbian_test"))
+ if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
testClause = QLatin1String(".test");
else
testClause = QLatin1String("");
@@ -343,7 +360,7 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t
}
}
- t << "START EXTENSION qt/qmake_extra_pre_targetdep" << endl;
+ t << "START EXTENSION qt/qmake_extra_pre_targetdep.export" << endl;
t << "OPTION PREDEP_TARGET " << absoluteTarget << endl;
t << "OPTION DEPS " << absoluteDeps << endl;
@@ -363,27 +380,23 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t
t << endl;
- // Write winscw deployment rules
+ // Write deployment rules
QString remoteTestPath = epocRoot() + QLatin1String("epoc32/winscw/c/private/") + privateDirUid;
DeploymentList depList;
- initProjectDeploySymbian(project, depList, remoteTestPath, false, QLatin1String("winscw"), QLatin1String("udeb"), generatedDirs, generatedFiles);
+ //write emulator deployment
t << "#if defined(WINSCW)" << endl;
- for (int i = 0; i < depList.size(); ++i) {
- t << "START EXTENSION qt/qmake_emulator_deployment" << endl;
- QString fromItem = depList.at(i).from;
- QString toItem = depList.at(i).to;
- fromItem.replace("\\", "/");
- toItem.replace("\\", "/");
-#if defined(Q_OS_WIN)
- toItem.prepend(QDir::current().absolutePath().left(2)); // add drive
-#endif
- t << "OPTION DEPLOY_SOURCE " << fromItem << endl;
- t << "OPTION DEPLOY_TARGET " << toItem << endl;
- t << "END" << endl;
- }
+ initProjectDeploySymbian(project, depList, remoteTestPath, false,
+ QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM), QString(), generatedDirs, generatedFiles);
+ writeSbsDeploymentList(depList, t);
t << "#endif" << endl;
+ //write ROM deployment
+ remoteTestPath = epocRoot() + QLatin1String("epoc32/data/z/private/") + privateDirUid;
+ depList.clear();
+ initProjectDeploySymbian(project, depList, remoteTestPath, false,
+ QLatin1String(ROM_DEPLOYMENT_PLATFORM), QString(), generatedDirs, generatedFiles);
+ writeSbsDeploymentList(depList, t);
t << endl;
// Write post link rules
diff --git a/qmake/generators/symbian/symmake_sbsv2.h b/qmake/generators/symbian/symmake_sbsv2.h
index 5c31249080..286c91ca6a 100644
--- a/qmake/generators/symbian/symmake_sbsv2.h
+++ b/qmake/generators/symbian/symmake_sbsv2.h
@@ -56,6 +56,7 @@ protected:
virtual void writeMkFile(const QString& wrapperFileName, bool deploymentOnly);
virtual void writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile);
virtual void appendAbldTempDirs(QStringList& sysincspaths, QString includepath);
+ virtual bool isForSymbianSbsv2() const { return true; } // FIXME: killme - i'm ugly!
public:
@@ -64,6 +65,7 @@ public:
private:
void exportFlm();
+ void writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t);
QString extraTargetsCache;
QString extraCompilersCache;
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 9d3b4c62c6..9998c1f70a 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -764,6 +764,11 @@ QString Win32MakefileGenerator::getLibTarget()
return QString(project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".lib");
}
+QString Win32MakefileGenerator::getPdbTarget()
+{
+ return QString(project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".pdb");
+}
+
QString Win32MakefileGenerator::defaultInstall(const QString &t)
{
if((t != "target" && t != "dlltarget") ||
@@ -804,6 +809,18 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t)
uninst.append("\n\t");
uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
}
+ if(project->isActiveConfig("shared") && project->isActiveConfig("debug")) {
+ QString pdb_target = getPdbTarget();
+ pdb_target.remove('"');
+ QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + pdb_target;
+ QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + pdb_target, FileFixifyAbsolute));
+ if(!ret.isEmpty())
+ ret += "\n\t";
+ ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\"";
+ if(!uninst.isEmpty())
+ uninst.append("\n\t");
+ uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
+ }
}
if(t == "dlltarget" || project->values(t + ".CONFIG").indexOf("no_dll") == -1) {
diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h
index 5437524495..3a2e3a1ee8 100644
--- a/qmake/generators/win32/winmakefile.h
+++ b/qmake/generators/win32/winmakefile.h
@@ -83,6 +83,7 @@ protected:
virtual void processRcFileVar();
virtual void processFileTagsVar();
virtual QString getLibTarget();
+ virtual QString getPdbTarget();
};
inline Win32MakefileGenerator::~Win32MakefileGenerator()
diff --git a/qmake/main.cpp b/qmake/main.cpp
index 50f9272e22..42679a2e93 100644
--- a/qmake/main.cpp
+++ b/qmake/main.cpp
@@ -149,7 +149,7 @@ int runQMake(int argc, char **argv)
//setup pwd properly
debug_msg(1, "Resetting dir to: %s", oldpwd.toLatin1().constData());
qmake_setpwd(oldpwd); //reset the old pwd
- int di = fn.lastIndexOf(Option::dir_sep);
+ int di = fn.lastIndexOf(QDir::separator());
if(di != -1) {
debug_msg(1, "Changing dir to: %s", fn.left(di).toLatin1().constData());
if(!qmake_setpwd(fn.left(di)))
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 18f05410ac..6f0f46bd63 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -88,7 +88,7 @@ int Option::warn_level = WarnLogic;
int Option::debug_level = 0;
QFile Option::output;
QString Option::output_dir;
-bool Option::recursive = false;
+Option::QMAKE_RECURSIVE Option::recursive = Option::QMAKE_RECURSIVE_DEFAULT;
QStringList Option::before_user_vars;
QStringList Option::after_user_vars;
QStringList Option::user_configs;
@@ -96,13 +96,9 @@ QStringList Option::after_user_configs;
QString Option::user_template;
QString Option::user_template_prefix;
QStringList Option::shellPath;
-#if defined(Q_OS_WIN32)
-Option::TARG_MODE Option::target_mode = Option::TARG_WIN_MODE;
-#elif defined(Q_OS_MAC)
-Option::TARG_MODE Option::target_mode = Option::TARG_MACX_MODE;
-#else
-Option::TARG_MODE Option::target_mode = Option::TARG_UNIX_MODE;
-#endif
+Option::HOST_MODE Option::host_mode = Option::HOST_UNKNOWN_MODE;
+Option::TARG_MODE Option::target_mode = Option::TARG_UNKNOWN_MODE;
+bool Option::target_mode_overridden = false;
//QMAKE_*_PROPERTY stuff
QStringList Option::prop::properties;
@@ -126,7 +122,7 @@ QString Option::mkfile::qmakespec_commandline;
static Option::QMAKE_MODE default_mode(QString progname)
{
- int s = progname.lastIndexOf(Option::dir_sep);
+ int s = progname.lastIndexOf(QDir::separator());
if(s != -1)
progname = progname.right(progname.length() - (s + 1));
if(progname == "qmakegen")
@@ -184,9 +180,6 @@ bool usage(const char *a0)
" * processed as if it was in [files]. These assignments will be parsed *\n"
" * before [files]. *\n"
" -o file Write output to file\n"
- " -unix Run in unix mode\n"
- " -win32 Run in win32 mode\n"
- " -macx Run in Mac OS X mode\n"
" -d Increase debug level\n"
" -t templ Overrides TEMPLATE as templ\n"
" -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n"
@@ -223,7 +216,7 @@ Option::parseCommandLine(int argc, char **argv, int skip)
if(x == 1) {
bool specified = true;
if(opt == "project") {
- Option::recursive = true;
+ Option::recursive = Option::QMAKE_RECURSIVE_YES;
Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT;
} else if(opt == "prl") {
Option::mkfile::do_deps = false;
@@ -251,11 +244,20 @@ Option::parseCommandLine(int argc, char **argv, int skip)
} else if(opt == "tp" || opt == "template_prefix") {
Option::user_template_prefix = argv[++x];
} else if(opt == "macx") {
+ fprintf(stderr, "-macx is deprecated.\n");
+ Option::host_mode = HOST_MACX_MODE;
Option::target_mode = TARG_MACX_MODE;
+ Option::target_mode_overridden = true;
} else if(opt == "unix") {
+ fprintf(stderr, "-unix is deprecated.\n");
+ Option::host_mode = HOST_UNIX_MODE;
Option::target_mode = TARG_UNIX_MODE;
+ Option::target_mode_overridden = true;
} else if(opt == "win32") {
+ fprintf(stderr, "-win32 is deprecated.\n");
+ Option::host_mode = HOST_WIN_MODE;
Option::target_mode = TARG_WIN_MODE;
+ Option::target_mode_overridden = true;
} else if(opt == "d") {
Option::debug_level++;
} else if(opt == "version" || opt == "v" || opt == "-version") {
@@ -279,9 +281,9 @@ Option::parseCommandLine(int argc, char **argv, int skip)
} else if(opt == "Wnone") {
Option::warn_level = WarnNone;
} else if(opt == "r" || opt == "recursive") {
- Option::recursive = true;
- } else if(opt == "norecursive") {
- Option::recursive = false;
+ Option::recursive = Option::QMAKE_RECURSIVE_YES;
+ } else if(opt == "nr" || opt == "norecursive") {
+ Option::recursive = Option::QMAKE_RECURSIVE_NO;
} else if(opt == "config") {
Option::user_configs += argv[++x];
} else {
@@ -405,6 +407,7 @@ Option::init(int argc, char **argv)
#ifdef Q_OS_WIN
Option::dirlist_sep = ";";
Option::shellPath = detectShellPath();
+ Option::res_ext = ".res";
#else
Option::dirlist_sep = ":";
#endif
@@ -525,18 +528,23 @@ Option::init(int argc, char **argv)
}
//defaults for globals
- if(Option::target_mode == Option::TARG_WIN_MODE) {
- Option::dir_sep = "\\";
- Option::obj_ext = ".obj";
- Option::res_ext = ".res";
- } else {
- Option::dir_sep = "/";
- Option::obj_ext = ".o";
- }
- Option::qmake_abslocation = Option::fixPathToTargetOS(Option::qmake_abslocation);
+ if (Option::host_mode != Option::HOST_UNKNOWN_MODE)
+ applyHostMode();
return QMAKE_CMDLINE_SUCCESS;
}
+void Option::applyHostMode()
+{
+ if (Option::host_mode == Option::HOST_WIN_MODE) {
+ Option::dir_sep = "\\";
+ Option::obj_ext = ".obj";
+ } else {
+ Option::dir_sep = "/";
+ Option::obj_ext = ".o";
+ }
+ Option::qmake_abslocation = Option::fixPathToTargetOS(Option::qmake_abslocation);
+}
+
bool Option::postProcessProject(QMakeProject *project)
{
Option::cpp_ext = project->variables()["QMAKE_EXT_CPP"];
diff --git a/qmake/option.h b/qmake/option.h
index 514e442e2b..9bfdaede88 100644
--- a/qmake/option.h
+++ b/qmake/option.h
@@ -106,6 +106,7 @@ struct Option
//both of these must be called..
static int init(int argc=0, char **argv=0); //parse cmdline
+ static void applyHostMode();
static bool postProcessProject(QMakeProject *);
enum StringFixFlags {
@@ -148,10 +149,15 @@ struct Option
static QString output_dir;
static int debug_level;
static int warn_level;
- static bool recursive;
+ enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO };
+ static QMAKE_RECURSIVE recursive;
static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs;
- enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE };
+ enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE };
+ static HOST_MODE host_mode;
+ enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE,
+ TARG_SYMBIAN_MODE };
static TARG_MODE target_mode;
+ static bool target_mode_overridden;
static QString user_template, user_template_prefix;
static QStringList shellPath;
@@ -205,7 +211,8 @@ public:
TranslationsPath,
SettingsPath,
DemosPath,
- ExamplesPath
+ ExamplesPath,
+ ImportsPath
};
static QString location(LibraryLocation);
};
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 41931633fd..951ca33b0b 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -43,6 +43,7 @@
#include "property.h"
#include "option.h"
#include "cachekeys.h"
+#include "generators/metamakefile.h"
#include <qdatetime.h>
#include <qfile.h>
@@ -121,7 +122,7 @@ enum TestFunc { T_REQUIRES=1, T_GREATERTHAN, T_LESSTHAN, T_EQUALS,
T_EXISTS, T_EXPORT, T_CLEAR, T_UNSET, T_EVAL, T_CONFIG, T_SYSTEM,
T_RETURN, T_BREAK, T_NEXT, T_DEFINED, T_CONTAINS, T_INFILE,
T_COUNT, T_ISEMPTY, T_INCLUDE, T_LOAD, T_DEBUG, T_ERROR,
- T_MESSAGE, T_WARNING, T_IF };
+ T_MESSAGE, T_WARNING, T_IF, T_OPTION };
QMap<QString, TestFunc> qmake_testFunctions()
{
static QMap<QString, TestFunc> *qmake_test_functions = 0;
@@ -155,6 +156,7 @@ QMap<QString, TestFunc> qmake_testFunctions()
qmake_test_functions->insert("error", T_ERROR);
qmake_test_functions->insert("message", T_MESSAGE);
qmake_test_functions->insert("warning", T_WARNING);
+ qmake_test_functions->insert("option", T_OPTION);
}
return *qmake_test_functions;
}
@@ -507,69 +509,6 @@ static void qmake_error_msg(const QString &msg)
msg.toLatin1().constData());
}
-enum isForSymbian_enum {
- isForSymbian_NOT_SET = -1,
- isForSymbian_FALSE = 0,
- isForSymbian_ABLD = 1,
- isForSymbian_SBSV2 = 2,
-};
-
-static isForSymbian_enum isForSymbian_value = isForSymbian_NOT_SET;
-
-// Checking for symbian build is primarily determined from the qmake spec,
-// but if that is not specified, detect if symbian is the default spec
-// by checking the MAKEFILE_GENERATOR variable value.
-static void init_symbian(const QMap<QString, QStringList>& vars)
-{
- if (isForSymbian_value != isForSymbian_NOT_SET)
- return;
-
- QString spec = QFileInfo(Option::mkfile::qmakespec).fileName();
- if (spec.startsWith("symbian-abld", Qt::CaseInsensitive)) {
- isForSymbian_value = isForSymbian_ABLD;
- } else if (spec.startsWith("symbian-sbsv2", Qt::CaseInsensitive)) {
- isForSymbian_value = isForSymbian_SBSV2;
- } else {
- QStringList generatorList = vars["MAKEFILE_GENERATOR"];
-
- if (!generatorList.isEmpty()) {
- QString generator = generatorList.first();
- if (generator.startsWith("SYMBIAN_ABLD"))
- isForSymbian_value = isForSymbian_ABLD;
- else if (generator.startsWith("SYMBIAN_SBSV2"))
- isForSymbian_value = isForSymbian_SBSV2;
- else
- isForSymbian_value = isForSymbian_FALSE;
- } else {
- isForSymbian_value = isForSymbian_FALSE;
- }
- }
-
- // Force recursive on Symbian, as non-recursive is not really a viable option there
- if (isForSymbian_value != isForSymbian_FALSE)
- Option::recursive = true;
-}
-
-bool isForSymbian()
-{
- // If isForSymbian_value has not been initialized explicitly yet,
- // call initializer with dummy map to check qmake spec.
- if (isForSymbian_value == isForSymbian_NOT_SET)
- init_symbian(QMap<QString, QStringList>());
-
- return (isForSymbian_value != isForSymbian_FALSE);
-}
-
-bool isForSymbianSbsv2()
-{
- // If isForSymbian_value has not been initialized explicitly yet,
- // call initializer with dummy map to check qmake spec.
- if (isForSymbian_value == isForSymbian_NOT_SET)
- init_symbian(QMap<QString, QStringList>());
-
- return (isForSymbian_value == isForSymbian_SBSV2);
-}
-
/*
1) environment variable QMAKEFEATURES (as separated by colons)
2) property variable QMAKEFEATURES (as separated by colons)
@@ -595,22 +534,16 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0)
concat << base_concat + QDir::separator() + "macx";
concat << base_concat + QDir::separator() + "unix";
break;
+ default: // Can't happen, just make the compiler shut up
case Option::TARG_UNIX_MODE:
- {
- if (isForSymbian())
- concat << base_concat + QDir::separator() + "symbian";
- else
- concat << base_concat + QDir::separator() + "unix";
- break;
- }
+ concat << base_concat + QDir::separator() + "unix";
+ break;
case Option::TARG_WIN_MODE:
- {
- if (isForSymbian())
- concat << base_concat + QDir::separator() + "symbian";
- else
- concat << base_concat + QDir::separator() + "win32";
- break;
- }
+ concat << base_concat + QDir::separator() + "win32";
+ break;
+ case Option::TARG_SYMBIAN_MODE:
+ concat << base_concat + QDir::separator() + "symbian";
+ break;
}
concat << base_concat;
}
@@ -623,7 +556,7 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0)
feature_roots += splitPathList(prop->value("QMAKEFEATURES"));
if(!Option::mkfile::cachefile.isEmpty()) {
QString path;
- int last_slash = Option::mkfile::cachefile.lastIndexOf(Option::dir_sep);
+ int last_slash = Option::mkfile::cachefile.lastIndexOf(QDir::separator());
if(last_slash != -1)
path = Option::fixPathToLocalOS(Option::mkfile::cachefile.left(last_slash));
for(QStringList::Iterator concat_it = concat.begin();
@@ -766,6 +699,7 @@ QMakeProject::reset()
scope_blocks.push(ScopeBlock());
iterator = 0;
function = 0;
+ recursive = false;
}
bool
@@ -1356,16 +1290,7 @@ bool
QMakeProject::read(uchar cmd)
{
if(cfile.isEmpty()) {
- //find out where qmake (myself) lives
- if (!base_vars.contains("QMAKE_QMAKE")) {
- if (!Option::qmake_abslocation.isNull())
- base_vars["QMAKE_QMAKE"] = QStringList(Option::qmake_abslocation);
- else
- base_vars["QMAKE_QMAKE"] = QStringList("qmake");
- }
-
// hack to get the Option stuff in there
- base_vars["QMAKE_EXT_OBJ"] = QStringList(Option::obj_ext);
base_vars["QMAKE_EXT_CPP"] = Option::cpp_ext;
base_vars["QMAKE_EXT_C"] = Option::c_ext;
base_vars["QMAKE_EXT_H"] = Option::h_ext;
@@ -1456,8 +1381,7 @@ QMakeProject::read(uchar cmd)
fprintf(stderr, "Failure to read QMAKESPEC conf file %s.\n", spec.toLatin1().constData());
return false;
}
-
- init_symbian(base_vars);
+ validateModes();
if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty()) {
debug_msg(1, "QMAKECACHE file: reading %s", Option::mkfile::cachefile.toLatin1().constData());
@@ -1581,6 +1505,46 @@ QMakeProject::read(uchar cmd)
return true;
}
+void QMakeProject::validateModes()
+{
+ if (Option::host_mode == Option::HOST_UNKNOWN_MODE
+ || Option::target_mode == Option::TARG_UNKNOWN_MODE) {
+ Option::HOST_MODE host_mode;
+ Option::TARG_MODE target_mode;
+ const QStringList &gen = base_vars.value("MAKEFILE_GENERATOR");
+ if (gen.isEmpty()) {
+ fprintf(stderr, "%s:%d: Using OS scope before setting MAKEFILE_GENERATOR\n",
+ parser.file.toLatin1().constData(), parser.line_no);
+ } else if (MetaMakefileGenerator::modesForGenerator(gen.first(),
+ &host_mode, &target_mode)) {
+ if (Option::host_mode == Option::HOST_UNKNOWN_MODE) {
+ Option::host_mode = host_mode;
+ Option::applyHostMode();
+ }
+
+ if (Option::target_mode == Option::TARG_UNKNOWN_MODE) {
+ const QStringList &tgt = base_vars.value("TARGET_PLATFORM");
+ if (!tgt.isEmpty()) {
+ const QString &os = tgt.first();
+ if (os == "unix")
+ Option::target_mode = Option::TARG_UNIX_MODE;
+ else if (os == "macx")
+ Option::target_mode = Option::TARG_MACX_MODE;
+ else if (os == "symbian")
+ Option::target_mode = Option::TARG_SYMBIAN_MODE;
+ else if (os == "win32")
+ Option::target_mode = Option::TARG_WIN_MODE;
+ else
+ fprintf(stderr, "Unknown target platform specified: %s\n",
+ os.toLatin1().constData());
+ } else {
+ Option::target_mode = target_mode;
+ }
+ }
+ }
+ }
+}
+
bool
QMakeProject::isActiveConfig(const QString &x, bool regex, QMap<QString, QStringList> *place)
{
@@ -1593,26 +1557,26 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QMap<QString, QString
else if(x == "false")
return false;
+ if (x == "unix") {
+ validateModes();
+ return Option::target_mode == Option::TARG_UNIX_MODE
+ || Option::target_mode == Option::TARG_MACX_MODE
+ || Option::target_mode == Option::TARG_SYMBIAN_MODE;
+ } else if (x == "macx" || x == "mac") {
+ validateModes();
+ return Option::target_mode == Option::TARG_MACX_MODE;
+ } else if (x == "symbian") {
+ validateModes();
+ return Option::target_mode == Option::TARG_SYMBIAN_MODE;
+ } else if (x == "win32") {
+ validateModes();
+ return Option::target_mode == Option::TARG_WIN_MODE;
+ }
+
+ //mkspecs
static QString spec;
if(spec.isEmpty())
spec = QFileInfo(Option::mkfile::qmakespec).fileName();
-
- // Symbian is an exception to how scopes are resolved. Since we do not
- // have a separate target mode for Symbian, but we expect the scope to resolve
- // on other platforms we base it entirely on the mkspec. This means that
- // using a mkspec starting with 'symbian*' will resolve both the 'symbian'
- // and the 'unix' (because of Open C) scopes to true.
- if(isForSymbian() && (x == "symbian" || x == "unix"))
- return true;
-
- //mkspecs
- if((Option::target_mode == Option::TARG_MACX_MODE ||
- Option::target_mode == Option::TARG_UNIX_MODE) && x == "unix")
- return !isForSymbian();
- else if(Option::target_mode == Option::TARG_MACX_MODE && (x == "macx" || x == "mac"))
- return !isForSymbian();
- else if(Option::target_mode == Option::TARG_WIN_MODE && x == "win32")
- return !isForSymbian();
QRegExp re(x, Qt::CaseSensitive, QRegExp::Wildcard);
if((regex && re.exactMatch(spec)) || (!regex && spec == x))
return true;
@@ -1704,7 +1668,7 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QMap<QString, QStringL
if(file.indexOf(Option::dir_sep) == -1 || !QFile::exists(file)) {
static QStringList *feature_roots = 0;
if(!feature_roots) {
- init_symbian(base_vars);
+ validateModes();
feature_roots = new QStringList(qmake_feature_paths(prop));
qmakeAddCacheClear(qmakeDeleteCacheClear_QStringList, (void**)&feature_roots);
}
@@ -2768,6 +2732,21 @@ QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QMap<QSt
exit(2);
#endif
return true; }
+ case T_OPTION:
+ if (args.count() != 1) {
+ fprintf(stderr, "%s:%d: option() requires one argument.\n",
+ parser.file.toLatin1().constData(), parser.line_no);
+ return false;
+ }
+ if (args.first() == "recursive") {
+ recursive = true;
+ } else {
+ fprintf(stderr, "%s:%d: unrecognized option() argument '%s'.\n",
+ parser.file.toLatin1().constData(), parser.line_no,
+ args.first().toLatin1().constData());
+ return false;
+ }
+ return true;
default:
fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.toLatin1().constData(), parser.line_no,
func.toLatin1().constData());
@@ -3150,6 +3129,19 @@ QStringList &QMakeProject::values(const QString &_var, QMap<QString, QStringList
} else if (var == QLatin1String("QMAKE_DIR_SEP")) {
if (place[var].isEmpty())
return values("DIR_SEPARATOR", place);
+ } else if (var == QLatin1String("QMAKE_EXT_OBJ")) {
+ if (place[var].isEmpty()) {
+ var = ".BUILTIN." + var;
+ place[var] = QStringList(Option::obj_ext);
+ }
+ } else if (var == QLatin1String("QMAKE_QMAKE")) {
+ if (place[var].isEmpty()) {
+ var = ".BUILTIN." + var;
+ if (!Option::qmake_abslocation.isNull())
+ place[var] = QStringList(Option::qmake_abslocation);
+ else
+ place[var] = QStringList("qmake");
+ }
} else if (var == QLatin1String("EPOCROOT")) {
if (place[var].isEmpty())
place[var] = QStringList(epocRoot());
diff --git a/qmake/project.h b/qmake/project.h
index 1f53bf22ab..bfebed0be2 100644
--- a/qmake/project.h
+++ b/qmake/project.h
@@ -78,6 +78,7 @@ class QMakeProject
FunctionBlock *function;
QMap<QString, FunctionBlock*> testFunctions, replaceFunctions;
+ bool recursive;
bool own_prop;
QString pfile, cfile;
QMakeProperty *prop;
@@ -105,6 +106,7 @@ class QMakeProject
QStringList doVariableReplaceExpand(const QString &str, QMap<QString, QStringList> &place, bool *ok=0);
void init(QMakeProperty *, const QMap<QString, QStringList> *);
QStringList &values(const QString &v, QMap<QString, QStringList> &place);
+ void validateModes();
public:
QMakeProject() { init(0, 0); }
@@ -154,6 +156,8 @@ public:
QString first(const QString &v);
QMap<QString, QStringList> &variables();
+ bool isRecursive() const { return recursive; }
+
protected:
friend class MakefileGenerator;
bool read(const QString &file, QMap<QString, QStringList> &place);
@@ -192,10 +196,6 @@ inline QString QMakeProject::first(const QString &v)
inline QMap<QString, QStringList> &QMakeProject::variables()
{ return vars; }
-// Helper functions needed for Symbian
-bool isForSymbian();
-bool isForSymbianSbsv2();
-
QT_END_NAMESPACE
#endif // PROJECT_H
diff --git a/qmake/property.cpp b/qmake/property.cpp
index cab034f447..fde7c6560d 100644
--- a/qmake/property.cpp
+++ b/qmake/property.cpp
@@ -95,6 +95,8 @@ QMakeProperty::value(QString v, bool just_check)
return QLibraryInfo::location(QLibraryInfo::BinariesPath);
else if(v == "QT_INSTALL_PLUGINS")
return QLibraryInfo::location(QLibraryInfo::PluginsPath);
+ else if(v == "QT_INSTALL_IMPORTS")
+ return QLibraryInfo::location(QLibraryInfo::ImportsPath);
else if(v == "QT_INSTALL_TRANSLATIONS")
return QLibraryInfo::location(QLibraryInfo::TranslationsPath);
else if(v == "QT_INSTALL_CONFIGURATION")
@@ -191,6 +193,7 @@ QMakeProperty::exec()
specialProps.append("QT_INSTALL_LIBS");
specialProps.append("QT_INSTALL_BINS");
specialProps.append("QT_INSTALL_PLUGINS");
+ specialProps.append("QT_INSTALL_IMPORTS");
specialProps.append("QT_INSTALL_TRANSLATIONS");
specialProps.append("QT_INSTALL_CONFIGURATION");
specialProps.append("QT_INSTALL_EXAMPLES");
diff --git a/src/3rdparty/libtiff/libtiff/tif_wince.c b/src/3rdparty/libtiff/libtiff/tif_wince.c
new file mode 100644
index 0000000000..4e283daf69
--- /dev/null
+++ b/src/3rdparty/libtiff/libtiff/tif_wince.c
@@ -0,0 +1,281 @@
+/* $Id: tif_wince.c,v 1.1 2007-01-15 18:40:39 mloskot Exp $ */
+
+/*
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/*
+ * Windows CE-specific routines for TIFF Library.
+ * Adapted from tif_win32.c 01/10/2006 by Mateusz Loskot (mateusz@loskot.net)
+ */
+
+#ifndef _WIN32_WCE
+# error "Only Windows CE target is supported!"
+#endif
+
+#include "tiffiop.h"
+#include <windows.h>
+
+/* Turn off console support on Windows CE. */
+#undef TIF_PLATFORM_CONSOLE
+
+
+/*
+ * Open a TIFF file for read/writing.
+ */
+TIFF*
+TIFFOpen(const char* name, const char* mode)
+{
+ static const char module[] = "TIFFOpen";
+ thandle_t fd;
+ int m;
+ DWORD dwMode;
+ TIFF* tif;
+ size_t nLen;
+ size_t nWideLen;
+ wchar_t* wchName;
+
+ m = _TIFFgetMode(mode, module);
+
+ switch(m)
+ {
+ case O_RDONLY:
+ dwMode = OPEN_EXISTING;
+ break;
+ case O_RDWR:
+ dwMode = OPEN_ALWAYS;
+ break;
+ case O_RDWR|O_CREAT:
+ dwMode = OPEN_ALWAYS;
+ break;
+ case O_RDWR|O_TRUNC:
+ dwMode = CREATE_ALWAYS;
+ break;
+ case O_RDWR|O_CREAT|O_TRUNC:
+ dwMode = CREATE_ALWAYS;
+ break;
+ default:
+ return ((TIFF*)0);
+ }
+
+ /* On Windows CE, CreateFile is mapped to CreateFileW,
+ * but file path is passed as char-based string,
+ * so the path has to be converted to wchar_t.
+ */
+
+ nWideLen = 0;
+ wchName = NULL;
+ nLen = strlen(name) + 1;
+
+ nWideLen = MultiByteToWideChar(CP_ACP, 0, name, nLen, NULL, 0);
+ wchName = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen);
+ if (NULL == wchName)
+ {
+ TIFFErrorExt(0, module, "Memory allocation error!");
+ return ((TIFF *)0);
+ }
+ memset(wchName, 0, sizeof(wchar_t) * nWideLen);
+ MultiByteToWideChar(CP_ACP, 0, name, nLen, wchName, nWideLen);
+
+ fd = (thandle_t)CreateFile(wchName,
+ (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
+ (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ free(wchName);
+
+ if (fd == INVALID_HANDLE_VALUE) {
+ TIFFErrorExt(0, module, "%s: Cannot open", name);
+ return ((TIFF *)0);
+ }
+
+ /* TODO - mloskot: change to TIFFdOpenW and pass wchar path */
+
+ tif = TIFFFdOpen((int)fd, name, mode);
+ if(!tif)
+ CloseHandle(fd);
+ return tif;
+}
+
+/*
+ * Open a TIFF file with a Unicode filename, for read/writing.
+ */
+TIFF*
+TIFFOpenW(const wchar_t* name, const char* mode)
+{
+ static const char module[] = "TIFFOpenW";
+ thandle_t fd;
+ int m;
+ DWORD dwMode;
+ int mbsize;
+ char *mbname;
+ TIFF *tif;
+
+ m = _TIFFgetMode(mode, module);
+
+ switch(m) {
+ case O_RDONLY: dwMode = OPEN_EXISTING; break;
+ case O_RDWR: dwMode = OPEN_ALWAYS; break;
+ case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break;
+ case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break;
+ case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break;
+ default: return ((TIFF*)0);
+ }
+
+ /* On Windows CE, CreateFile is mapped to CreateFileW,
+ * so no conversion of wchar_t to char is required.
+ */
+
+ fd = (thandle_t)CreateFile(name,
+ (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE),
+ FILE_SHARE_READ, NULL, dwMode,
+ (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (fd == INVALID_HANDLE_VALUE) {
+ TIFFErrorExt(0, module, "%S: Cannot open", name);
+ return ((TIFF *)0);
+ }
+
+ mbname = NULL;
+ mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
+ if (mbsize > 0) {
+ mbname = (char *)_TIFFmalloc(mbsize);
+ if (!mbname) {
+ TIFFErrorExt(0, module,
+ "Can't allocate space for filename conversion buffer");
+ return ((TIFF*)0);
+ }
+
+ WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
+ NULL, NULL);
+ }
+
+ tif = TIFFFdOpen((int)fd,
+ (mbname != NULL) ? mbname : "<unknown>", mode);
+ if(!tif)
+ CloseHandle(fd);
+
+ _TIFFfree(mbname);
+
+ return tif;
+}
+
+static void
+Win32WarningHandler(const char* module, const char* fmt, va_list ap)
+{
+ /* On Windows CE, MessageBox is mapped to wide-char based MessageBoxW. */
+
+ size_t nWideLen = 0;
+ LPTSTR szWideTitle = NULL;
+ LPTSTR szWideMsg = NULL;
+
+ LPSTR szTitle;
+ LPSTR szTmp;
+ LPCSTR szTitleText = "%s Warning";
+ LPCSTR szDefaultModule = "LIBTIFF";
+ LPCSTR szTmpModule;
+
+ szTmpModule = (module == NULL) ? szDefaultModule : module;
+ if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED,
+ (strlen(szTmpModule) + strlen(szTitleText)
+ + strlen(fmt) + 128) * sizeof(char))) == NULL)
+ return;
+
+ sprintf(szTitle, szTitleText, szTmpModule);
+ szTmp = szTitle + (strlen(szTitle) + 2) * sizeof(char);
+ vsprintf(szTmp, fmt, ap);
+
+ /* Convert error message to Unicode. */
+
+ nWideLen = MultiByteToWideChar(CP_ACP, 0, szTitle, -1, NULL, 0);
+ szWideTitle = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen);
+ MultiByteToWideChar(CP_ACP, 0, szTitle, -1, szWideTitle, nWideLen);
+
+ nWideLen = MultiByteToWideChar(CP_ACP, 0, szTmp, -1, NULL, 0);
+ szWideMsg = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen);
+ MultiByteToWideChar(CP_ACP, 0, szTmp, -1, szWideMsg, nWideLen);
+
+ /* Display message */
+
+ MessageBox(GetFocus(), szWideMsg, szWideTitle, MB_OK | MB_ICONEXCLAMATION);
+
+ /* Free resources */
+
+ LocalFree(szTitle);
+ free(szWideMsg);
+ free(szWideTitle);
+}
+
+TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler;
+
+static void
+Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
+{
+ /* On Windows CE, MessageBox is mapped to wide-char based MessageBoxW. */
+
+ size_t nWideLen = 0;
+ LPTSTR szWideTitle = NULL;
+ LPTSTR szWideMsg = NULL;
+
+ LPSTR szTitle;
+ LPSTR szTmp;
+ LPCSTR szTitleText = "%s Error";
+ LPCSTR szDefaultModule = "LIBTIFF";
+ LPCSTR szTmpModule;
+
+ szTmpModule = (module == NULL) ? szDefaultModule : module;
+ if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED,
+ (strlen(szTmpModule) + strlen(szTitleText)
+ + strlen(fmt) + 128) * sizeof(char))) == NULL)
+ return;
+
+ sprintf(szTitle, szTitleText, szTmpModule);
+ szTmp = szTitle + (strlen(szTitle) + 2) * sizeof(char);
+ vsprintf(szTmp, fmt, ap);
+
+ /* Convert error message to Unicode. */
+
+ nWideLen = MultiByteToWideChar(CP_ACP, 0, szTitle, -1, NULL, 0);
+ szWideTitle = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen);
+ MultiByteToWideChar(CP_ACP, 0, szTitle, -1, szWideTitle, nWideLen);
+
+ nWideLen = MultiByteToWideChar(CP_ACP, 0, szTmp, -1, NULL, 0);
+ szWideMsg = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen);
+ MultiByteToWideChar(CP_ACP, 0, szTmp, -1, szWideMsg, nWideLen);
+
+ /* Display message */
+
+ MessageBox(GetFocus(), szWideMsg, szWideTitle, MB_OK | MB_ICONEXCLAMATION);
+
+ /* Free resources */
+
+ LocalFree(szTitle);
+ free(szWideMsg);
+ free(szWideTitle);
+}
+
+TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;
+
+
+/* vim: set ts=8 sts=8 sw=8 noet: */
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp
index 3065205b9e..3b808b84bf 100644
--- a/src/corelib/concurrent/qfuturewatcher.cpp
+++ b/src/corelib/concurrent/qfuturewatcher.cpp
@@ -499,6 +499,13 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
/*! \fn void QFutureWatcher::setFuture(const QFuture<T> &future)
Starts watching the given \a future.
+
+ One of the signals might be emitted for the current state of the
+ \a future. For example, if the future is already stopped, the
+ finished signal will be emitted.
+
+ To avoid a race condition, it is important to call this function
+ \i after doing the connections.
*/
/*! \fn QFuture<T> QFutureWatcher::future() const
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 7e7d7d8b15..4d48b60807 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -814,7 +814,7 @@ namespace QT_NAMESPACE {}
# define Q_WS_MAC32
# endif
# elif defined(Q_OS_SYMBIAN)
-# if (defined(__SERIES60_31__) || defined(__S60_32__) || defined(__S60_50__)) && !defined(QT_NO_S60)
+# if !defined(QT_NO_S60)
# define Q_WS_S60
# endif
# elif !defined(Q_WS_QWS)
@@ -2414,10 +2414,11 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
#if defined(Q_OS_SYMBIAN)
-#ifdef SYMBIAN_GRAPHICS_USE_GCE
+#ifdef SYMBIAN_BUILD_GCE
//RWsPointerCursor is fixed, so don't use low performance sprites
#define Q_SYMBIAN_FIXED_POINTER_CURSORS
#define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
+#define Q_SYMBIAN_WINDOW_SIZE_CACHE
//enabling new graphics resources
#define QT_SYMBIAN_SUPPORTS_SGIMAGE
#define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index d5041c92fb..94902259fd 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -266,6 +266,11 @@ QLibraryInfo::location(LibraryLocation loc)
path = QT_CONFIGURE_PLUGINS_PATH;
break;
#endif
+#ifdef QT_CONFIGURE_IMPORTS_PATH
+ case ImportsPath:
+ path = QT_CONFIGURE_IMPORTS_PATH;
+ break;
+#endif
#ifdef QT_CONFIGURE_DATA_PATH
case DataPath:
path = QT_CONFIGURE_DATA_PATH;
@@ -470,6 +475,7 @@ QLibraryInfo::location(LibraryLocation loc)
\value LibrariesPath The location of installed librarires.
\value BinariesPath The location of installed Qt binaries (tools and applications).
\value PluginsPath The location of installed Qt plugins.
+ \value ImportsPath The location of installed QML extensions to import.
\value DataPath The location of general Qt data.
\value TranslationsPath The location of translation information for Qt strings.
\value SettingsPath The location for Qt settings.
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index e64b760ff6..4a7ba063be 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -76,7 +76,8 @@ public:
TranslationsPath,
SettingsPath,
DemosPath,
- ExamplesPath
+ ExamplesPath,
+ ImportsPath
};
static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path()
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index fc35bfa27f..2731ae17b7 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -159,10 +159,9 @@ QT_BEGIN_NAMESPACE
\section1 Reading and writing Qt collection classes
- The Qt collection classes can also be serialized to a QDataStream.
+ The Qt container classes can also be serialized to a QDataStream.
These include QList, QLinkedList, QVector, QSet, QHash, and QMap.
- These classes have have stream operators declared as non-member of
- the class.
+ The stream operators are declared as non-members of the classes.
\target Serializing Qt Classes
\section1 Reading and writing other Qt classes.
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 7cfdddfd5d..505889e93f 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -960,13 +960,14 @@ void QDir::setNameFilters(const QStringList &nameFilters)
/*!
\obsolete
+
+ Use QDir::addSearchPath() with a prefix instead.
+
Adds \a path to the search paths searched in to find resources
that are not specified with an absolute path. The default search
path is to search only in the root (\c{:/}).
- Use QDir::addSearchPath() with a prefix instead.
-
- \sa {The Qt Resource System}, QResource::addSearchPath()
+ \sa {The Qt Resource System}
*/
void QDir::addResourceSearchPath(const QString &path)
{
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 9179485be7..d2fa744d55 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1270,7 +1270,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
int pageSize = getpagesize();
int extra = offset % pageSize;
- if (size + extra > (size_t)-1) {
+ if (quint64(size + extra) > quint64((size_t)-1)) {
q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL)));
return 0;
}
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 4e14ba8774..662100a3f8 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1003,8 +1003,8 @@ QByteArray QIODevice::readAll()
to a maximum of \a maxSize - 1 bytes, stores the characters in \a
data, and returns the number of bytes read. If a line could not be
read but no error ocurred, this function returns 0. If an error
- occurs, this function returns what it could the length of what
- could be read, or -1 if nothing was read.
+ occurs, this function returns the length of what could be read, or
+ -1 if nothing was read.
A terminating '\0' byte is always appended to \a data, so \a
maxSize must be larger than 1.
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index adfbb151f5..6d33c8bf38 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -555,16 +555,15 @@ QStringList QResource::children() const
/*!
\obsolete
+ Use QDir::addSearchPath() with a prefix instead.
+
Adds \a path to the search paths searched in to find resources that are
not specified with an absolute path. The \a path must be an absolute
path (start with \c{/}).
The default search path is to search only in the root (\c{:/}). The last
path added will be consulted first upon next QResource creation.
-
- Use QDir::addSearchPath() with a prefix instead.
*/
-
void
QResource::addSearchPath(const QString &path)
{
@@ -578,6 +577,10 @@ QResource::addSearchPath(const QString &path)
}
/*!
+ \obsolete
+
+ Use QDir::searchPaths() instead.
+
Returns the current search path list. This list is consulted when
creating a relative resource.
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 32f7ac248d..626bd3f61a 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -444,17 +444,19 @@ static bool QT_FASTCALL _unreserved(const char **ptr)
}
// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
-static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
+static bool QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
{
bool first = true;
+ bool isSchemeValid = true;
parseData->scheme = *ptr;
for (;;) {
char ch = **ptr;
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
;
- } else if (!first && ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.')) {
- ;
+ } else if ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.') {
+ if (first)
+ isSchemeValid = false;
} else {
break;
}
@@ -464,11 +466,14 @@ static void QT_FASTCALL _scheme(const char **ptr, QUrlParseData *parseData)
}
if (**ptr != ':') {
+ isSchemeValid = true;
*ptr = parseData->scheme;
} else {
parseData->schemeLength = *ptr - parseData->scheme;
++(*ptr); // skip ':'
}
+
+ return isSchemeValid;
}
// IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
@@ -3750,7 +3755,19 @@ void QUrlPrivate::parse(ParseOptions parseOptions) const
#endif
// optional scheme
- _scheme(ptr, &parseData);
+ bool isSchemeValid = _scheme(ptr, &parseData);
+
+ if (isSchemeValid == false) {
+ that->isValid = false;
+ char ch = *((*ptr)++);
+ that->errorInfo.setParams(*ptr, QT_TRANSLATE_NOOP(QUrl, "unexpected URL scheme"),
+ 0, ch);
+ QURL_SETFLAG(that->stateFlags, Validated | Parsed);
+#if defined (QURL_DEBUG)
+ qDebug("QUrlPrivate::parse(), unrecognized: %c%s", ch, *ptr);
+#endif
+ return;
+ }
// hierpart
_hierPart(ptr, &parseData);
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index fba8dd9b4a..779b69b10c 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -48,6 +48,7 @@
#include "qstringlist.h"
#include "qvector.h"
#include "qlocale.h"
+#include "qeasingcurve.h"
#ifdef QT_BOOTSTRAPPED
# ifndef QT_NO_GEOM_VARIANT
@@ -176,6 +177,7 @@ QT_BEGIN_NAMESPACE
\value QVector3D QVector3D
\value QVector4D QVector4D
\value QQuaternion QQuaternion
+ \value QEasingCurve QEasingCurve
\value User Base value for user types
@@ -259,6 +261,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("QPointF", QMetaType::QPointF),
QT_ADD_STATIC_METATYPE("QRegExp", QMetaType::QRegExp),
QT_ADD_STATIC_METATYPE("QVariantHash", QMetaType::QVariantHash),
+ QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve),
/* All GUI types */
QT_ADD_STATIC_METATYPE("QColorGroup", 63),
@@ -695,6 +698,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
stream << *static_cast<const NS(QRegExp)*>(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ stream << *static_cast<const NS(QEasingCurve)*>(data);
+ break;
+#endif
#ifdef QT3_SUPPORT
case QMetaType::QColorGroup:
#endif
@@ -892,6 +900,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
stream >> *static_cast< NS(QRegExp)*>(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ stream >> *static_cast< NS(QEasingCurve)*>(data);
+ break;
+#endif
#ifdef QT3_SUPPORT
case QMetaType::QColorGroup:
#endif
@@ -1036,6 +1049,10 @@ void *QMetaType::construct(int type, const void *copy)
case QMetaType::QRegExp:
return new NS(QRegExp)(*static_cast<const NS(QRegExp)*>(copy));
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ return new NS(QEasingCurve)(*static_cast<const NS(QEasingCurve)*>(copy));
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1127,6 +1144,10 @@ void *QMetaType::construct(int type, const void *copy)
case QMetaType::QRegExp:
return new NS(QRegExp);
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ return new NS(QEasingCurve);
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1282,6 +1303,11 @@ void QMetaType::destroy(int type, void *data)
delete static_cast< NS(QRegExp)* >(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ delete static_cast< NS(QEasingCurve)* >(data);
+ break;
+#endif
case QMetaType::Void:
break;
default: {
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index c23caed331..33126e8ed4 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -69,7 +69,7 @@ public:
QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
- QVariantHash = 28, LastCoreType = 28 /* QVariantHash */,
+ QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve,
FirstGuiType = 63 /* QColorGroup */,
#ifdef QT3_SUPPORT
@@ -81,12 +81,12 @@ public:
QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81,
QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85,
QQuaternion = 86,
- LastGuiType = 86 /* QQuaternion */,
+ LastGuiType = QQuaternion,
FirstCoreExtType = 128 /* VoidStar */,
VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132,
UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137,
- LastCoreExtType = 137 /* QWidgetStar */,
+ LastCoreExtType = QWidgetStar,
// This logic must match the one in qglobal.h
#if defined(QT_COORD_TYPE)
@@ -290,6 +290,7 @@ class QPointF;
#ifndef QT_NO_REGEXP
class QRegExp;
#endif
+class QEasingCurve;
class QWidget;
class QObject;
@@ -359,6 +360,7 @@ Q_DECLARE_BUILTIN_METATYPE(QPointF, QPointF)
#ifndef QT_NO_REGEXP
Q_DECLARE_BUILTIN_METATYPE(QRegExp, QRegExp)
#endif
+Q_DECLARE_BUILTIN_METATYPE(QEasingCurve, QEasingCurve)
#ifdef QT3_SUPPORT
Q_DECLARE_BUILTIN_METATYPE(QColorGroup, QColorGroup)
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index e1b5825522..227a60deaa 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -46,6 +46,7 @@
#include "qdebug.h"
#include "qmap.h"
#include "qdatetime.h"
+#include "qeasingcurve.h"
#include "qlist.h"
#include "qstring.h"
#include "qstringlist.h"
@@ -146,6 +147,11 @@ static void construct(QVariant::Private *x, const void *copy)
v_construct<QRegExp>(x, copy);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ v_construct<QEasingCurve>(x, copy);
+ break;
+#endif
case QVariant::Int:
x->data.i = copy ? *static_cast<const int *>(copy) : 0;
break;
@@ -259,6 +265,11 @@ static void clear(QVariant::Private *d)
v_clear<QRegExp>(d);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ v_clear<QEasingCurve>(d);
+ break;
+#endif
case QVariant::LongLong:
case QVariant::ULongLong:
case QVariant::Double:
@@ -317,6 +328,9 @@ static bool isNull(const QVariant::Private *d)
case QVariant::PointF:
return v_cast<QPointF>(d)->isNull();
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+#endif
case QVariant::Url:
case QVariant::Locale:
case QVariant::RegExp:
@@ -435,6 +449,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return *v_cast<QTime>(a) == *v_cast<QTime>(b);
case QVariant::DateTime:
return *v_cast<QDateTime>(a) == *v_cast<QDateTime>(b);
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ return *v_cast<QEasingCurve>(a) == *v_cast<QEasingCurve>(b);
+#endif
case QVariant::ByteArray:
return *v_cast<QByteArray>(a) == *v_cast<QByteArray>(b);
case QVariant::BitArray:
@@ -1097,6 +1115,11 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QVariant::DateTime:
dbg.nospace() << v.toDateTime();
break;
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ dbg.nospace() << v.toEasingCurve();
+ break;
+#endif
case QVariant::ByteArray:
dbg.nospace() << v.toByteArray();
break;
@@ -1265,6 +1288,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
\value Date a QDate
\value DateTime a QDateTime
\value Double a double
+ \value EasingCurve a QEasingCurve
\value Font a QFont
\value Hash a QVariantHash
\value Icon a QIcon
@@ -1483,6 +1507,12 @@ QVariant::QVariant(const char *val)
*/
/*!
+ \fn QVariant::QVariant(const QEasingCurve &val)
+
+ Constructs a new variant with an easing curve value, \a val.
+*/
+
+/*!
\fn QVariant::QVariant(const QByteArray &val)
Constructs a new variant with a bytearray value, \a val.
@@ -1681,6 +1711,10 @@ QVariant::QVariant(const QTime &val)
{ d.is_null = false; d.type = Time; v_construct<QTime>(&d, val); }
QVariant::QVariant(const QDateTime &val)
{ d.is_null = false; d.type = DateTime; v_construct<QDateTime>(&d, val); }
+#ifndef QT_BOOTSTRAPPED
+QVariant::QVariant(const QEasingCurve &val)
+{ d.is_null = false; d.type = EasingCurve; v_construct<QEasingCurve>(&d, val); }
+#endif
QVariant::QVariant(const QList<QVariant> &list)
{ d.is_null = false; d.type = List; v_construct<QVariantList>(&d, list); }
QVariant::QVariant(const QMap<QString, QVariant> &map)
@@ -1870,7 +1904,7 @@ QVariant::Type QVariant::nameToType(const char *name)
}
#ifndef QT_NO_DATASTREAM
-enum { MapFromThreeCount = 35 };
+enum { MapFromThreeCount = 36 };
static const ushort map_from_three[MapFromThreeCount] =
{
QVariant::Invalid,
@@ -1907,7 +1941,8 @@ static const ushort map_from_three[MapFromThreeCount] =
QVariant::KeySequence,
QVariant::Pen,
QVariant::LongLong,
- QVariant::ULongLong
+ QVariant::ULongLong,
+ QVariant::EasingCurve
};
/*!
@@ -2165,6 +2200,21 @@ QDateTime QVariant::toDateTime() const
}
/*!
+ \fn QEasingCurve QVariant::toEasingCurve() const
+
+ Returns the variant as a QEasingCurve if the variant has type() \l
+ EasingCurve; otherwise returns a default easing curve.
+
+ \sa canConvert(), convert()
+*/
+#ifndef QT_BOOTSTRAPPED
+QEasingCurve QVariant::toEasingCurve() const
+{
+ return qVariantToHelper<QEasingCurve>(d, EasingCurve, handler);
+}
+#endif
+
+/*!
\fn QByteArray QVariant::toByteArray() const
Returns the variant as a QByteArray if the variant has type() \l
@@ -2605,8 +2655,9 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QRegExp*/ 0,
-/*QHash*/ 0
+/*QHash*/ 0,
+/*QEasingCurve*/ 0
};
/*!
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 1a9e43a4ca..9628dbfa2d 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -60,6 +60,7 @@ class QBitArray;
class QDataStream;
class QDate;
class QDateTime;
+class QEasingCurve;
class QLine;
class QLineF;
class QLocale;
@@ -128,9 +129,10 @@ class Q_CORE_EXPORT QVariant
LineF = 24,
Point = 25,
PointF = 26,
- RegExp = 27,
+ RegExp = 27,
Hash = 28,
- LastCoreType = Hash,
+ EasingCurve = 29,
+ LastCoreType = EasingCurve,
// value 62 is internally reserved
#ifdef QT3_SUPPORT
@@ -219,6 +221,9 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QVariant(const QRegExp &regExp);
#endif
+#ifndef QT_BOOTSTRAPPED
+ QVariant(const QEasingCurve &easing);
+#endif
QVariant(Qt::GlobalColor color);
QVariant& operator=(const QVariant &other);
@@ -280,6 +285,9 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QRegExp toRegExp() const;
#endif
+#ifndef QT_BOOTSTRAPPED
+ QEasingCurve toEasingCurve() const;
+#endif
#ifdef QT3_SUPPORT
inline QT3_SUPPORT int &asInt();
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index b6a2df453d..d4b2c27254 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -600,11 +600,11 @@ QEasingCurve::QEasingCurve(Type type)
Construct a copy of \a other.
*/
QEasingCurve::QEasingCurve(const QEasingCurve &other)
-: d_ptr(new QEasingCurvePrivate)
+ : d_ptr(new QEasingCurvePrivate)
{
// ### non-atomic, requires malloc on shallow copy
*d_ptr = *other.d_ptr;
- if(other.d_ptr->config)
+ if (other.d_ptr->config)
d_ptr->config = other.d_ptr->config->copy();
}
@@ -629,7 +629,7 @@ QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other)
}
*d_ptr = *other.d_ptr;
- if(other.d_ptr->config)
+ if (other.d_ptr->config)
d_ptr->config = other.d_ptr->config->copy();
return *this;
@@ -845,6 +845,67 @@ QDebug operator<<(QDebug debug, const QEasingCurve &item)
}
return debug;
}
-#endif
+#endif // QT_NO_DEBUG_STREAM
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing)
+ \relates QEasingCurve
+
+ Writes the given \a easing curve to the given \a stream and returns a
+ reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing)
+{
+ stream << quint8(easing.d_ptr->type);
+ stream << quint64(quintptr(easing.d_ptr->func));
+
+ bool hasConfig = easing.d_ptr->config;
+ stream << hasConfig;
+ if (hasConfig) {
+ stream << easing.d_ptr->config->_p;
+ stream << easing.d_ptr->config->_a;
+ stream << easing.d_ptr->config->_o;
+ }
+ return stream;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
+ \relates QQuaternion
+
+ Reads an easing curve from the given \a stream into the given \a quaternion
+ and returns a reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
+{
+ QEasingCurve::Type type;
+ quint8 int_type;
+ stream >> int_type;
+ type = static_cast<QEasingCurve::Type>(int_type);
+ easing.setType(type);
+
+ quint64 ptr_func;
+ stream >> ptr_func;
+ easing.d_ptr->func = QEasingCurve::EasingFunction(quintptr(ptr_func));
+
+ bool hasConfig;
+ stream >> hasConfig;
+ if (hasConfig) {
+ QEasingCurveFunction *config = curveToFunctionObject(type);
+ stream >> config->_p;
+ stream >> config->_a;
+ stream >> config->_o;
+ easing.d_ptr->config = config;
+ }
+ return stream;
+}
+#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index ae8822ee57..173fba4f5b 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -100,13 +100,24 @@ public:
qreal valueForProgress(qreal progress) const;
private:
QEasingCurvePrivate *d_ptr;
+#ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
+#endif
+#ifndef QT_NO_DATASTREAM
+ friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&);
+ friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
+#endif
};
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index f1030ae0ec..3374c80bd6 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -625,6 +625,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const
{
QList<Key> res;
+ res.reserve(size()); // May be too much, but assume short lifetime
const_iterator i = begin();
if (i != end()) {
for (;;) {
@@ -644,6 +645,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::keys() const
{
QList<Key> res;
+ res.reserve(size());
const_iterator i = begin();
while (i != end()) {
res.append(i.key());
@@ -688,6 +690,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values() const
{
QList<T> res;
+ res.reserve(size());
const_iterator i = begin();
while (i != end()) {
res.append(i.value());
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 3a29e13ff4..c6dd106163 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -525,7 +525,8 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t)
PodNode cpy = *reinterpret_cast<const PodNode *>(&t);
Node *n = reinterpret_cast<Node *>(p.append());
QT_TRY {
- node_construct(n, *reinterpret_cast<const T *>(&cpy));
+ void *ptr = &cpy;
+ node_construct(n, *reinterpret_cast<T *>(ptr));
} QT_CATCH(...) {
--d->end;
QT_RETHROW;
@@ -559,7 +560,8 @@ inline void QList<T>::prepend(const T &t)
PodNode cpy = *reinterpret_cast<const PodNode *>(&t);
Node *n = reinterpret_cast<Node *>(p.prepend());
QT_TRY {
- node_construct(n, *reinterpret_cast<const T *>(&cpy));
+ void *ptr = &cpy;
+ node_construct(n, *reinterpret_cast<T *>(ptr));
} QT_CATCH(...) {
++d->begin;
QT_RETHROW;
@@ -593,7 +595,8 @@ inline void QList<T>::insert(int i, const T &t)
PodNode cpy = *reinterpret_cast<const PodNode *>(&t);
Node *n = reinterpret_cast<Node *>(p.insert(i));
QT_TRY {
- node_construct(n, *reinterpret_cast<const T *>(&cpy));
+ void *ptr = &cpy;
+ node_construct(n, *reinterpret_cast<T *>(ptr));
} QT_CATCH(...) {
p.remove(i);
QT_RETHROW;
@@ -808,15 +811,22 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::iterator QList<T>::erase(typename QList<
template <typename T>
Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l)
{
- Node *n = (d->ref != 1)
- ? detach_helper_grow(INT_MAX, l.size())
- : reinterpret_cast<Node *>(p.append2(l.p));
- QT_TRY{
- node_copy(n, reinterpret_cast<Node *>(p.end()), reinterpret_cast<Node *>(l.p.begin()));
- } QT_CATCH(...) {
- // restore the old end
- d->end -= int(reinterpret_cast<Node *>(p.end()) - n);
- QT_RETHROW;
+ if (!l.isEmpty()) {
+ if (isEmpty()) {
+ *this = l;
+ } else {
+ Node *n = (d->ref != 1)
+ ? detach_helper_grow(INT_MAX, l.size())
+ : reinterpret_cast<Node *>(p.append2(l.p));
+ QT_TRY {
+ node_copy(n, reinterpret_cast<Node *>(p.end()),
+ reinterpret_cast<Node *>(l.p.begin()));
+ } QT_CATCH(...) {
+ // restore the old end
+ d->end -= int(reinterpret_cast<Node *>(p.end()) - n);
+ QT_RETHROW;
+ }
+ }
}
return *this;
}
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 2e215471a0..df0ae460c3 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -773,6 +773,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QList<Key> QMap<Key, T>::uniqueKeys() const
{
QList<Key> res;
+ res.reserve(size()); // May be too much, but assume short lifetime
const_iterator i = begin();
if (i != end()) {
for (;;) {
@@ -792,6 +793,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QList<Key> QMap<Key, T>::keys() const
{
QList<Key> res;
+ res.reserve(size());
const_iterator i = begin();
while (i != end()) {
res.append(i.key());
@@ -836,6 +838,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values() const
{
QList<T> res;
+ res.reserve(size());
const_iterator i = begin();
while (i != end()) {
res.append(i.value());
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 12badf09ac..e7dd769fe7 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -225,4 +225,59 @@ QT_BEGIN_NAMESPACE
Swap this pointer with \a other.
*/
+/*!
+ \class QScopedArrayPointer
+
+ \brief The QScopedArrayPointer class stores a pointer to a
+ dynamically allocated array of objects, and deletes it upon
+ destruction.
+
+ \since 4.6
+ \reentrant
+ \ingroup misc
+
+ A QScopedArrayPointer is a QScopedPointer that defaults to
+ deleting the object it is pointing to with the delete[] operator. It
+ also features operator[] for convenience, so we can write:
+
+ \code
+ void foo()
+ {
+ QScopedArrayPointer<int> i(new int[10]);
+ i[2] = 42;
+ ...
+ return; // our integer array is now deleted using delete[]
+ }
+ \endcode
+*/
+
+/*!
+ \fn QScopedArrayPointer::QScopedArrayPointer(T *p = 0)
+
+ Constructs this QScopedArrayPointer instance and sets its pointer
+ to \a p.
+*/
+
+/*!
+ \fn T *QScopedArrayPointer::operator[](int i)
+
+ Provides access to entry \a i of the scoped pointer's array of
+ objects.
+
+ If the contained pointer is \c null, behavior is undefined.
+
+ \sa isNull()
+*/
+
+/*!
+ \fn T *QScopedArrayPointer::operator[](int i) const
+
+ Provides access to entry \a i of the scoped pointer's array of
+ objects.
+
+ If the contained pointer is \c null, behavior is undefined.
+
+ \sa isNull()
+*/
+
QT_END_NAMESPACE
diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp
index 939e98598b..50714cea85 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/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 06fa7209e1..34e48340e1 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,7 +1,17 @@
=============================================================================
The changes below are pre Qt 4.7.0 alpha
+Flickable: renamed viewportWidth -> contentWidth
+Flickable: renamed viewportHeight -> contentHeight
+Flickable: renamed viewportX -> contentX
+Flickable: renamed viewportY -> contentY
+Removed Flickable.reportedVelocitySmoothing
Renamed MouseRegion -> MouseArea
+Connection: syntax and rename:
+ Connection { sender: a; signal: foo(); script: xxx }
+ Connection { sender: a; signal: bar(); script: yyy }
+ becomes:
+ Connections { target: a; onFoo: xxx; onBar: yyy }
QmlView
-------
@@ -28,6 +38,14 @@ ListModel
- foo: true is now a bool (not string "true")
- foo: false is now a bool (not string "false" == true!)
+C++ API
+-------
+QML_DEFINE_... definition macros, previously global macros, are replaced by
+QML_REGISTER_... registration macros, which must be called explicitly. C++ API users
+should also consider using the QmlExtensionPlugin (previously named QmlModulePlugin)
+as a cleaner mechanism for publishing libraries of QML types, or the upcoming
+application plugin features of the qmlviewer / qmlruntime / qml.
+
PropertyAnimation
------------------
matchProperties and matchTargets have been renamed back to properties and targets.
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
index 261b2ff711..dedea55c39 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 0000000000..e4b7d4d7ef
--- /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 0000000000..f0c7a774eb
--- /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 0000000000..c23e32fcc2
--- /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 0000000000..4144a66b34
--- /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 0000000000..5908628b9a
--- /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 0000000000..a3ba40a790
--- /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 0000000000..d9bbdb565f
--- /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 0000000000..498edf386f
--- /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 32d8bbbbba..0000000000
--- 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 a1371d571f..0000000000
--- 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 ae42b5b18b..0000000000
--- 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 c3e6efff59..0000000000
--- 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 0f2a973ab6..0000000000
--- 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 42538f3013..0000000000
--- 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 7b21869c1c..0000000000
--- 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 33ddda0072..0000000000
--- 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 86a03705cd..4287e250ee 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
}
@@ -24,7 +24,6 @@ include(3rdparty/3rdparty.pri)
include(util/util.pri)
include(graphicsitems/graphicsitems.pri)
include(qml/qml.pri)
-include(widgets/widgets.pri)
include(debugger/debugger.pri)
symbian:TARGET.UID3=0x2001E623
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index e5343c6324..7a85f00309 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 0000000000..274d7788c3
--- /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 0000000000..0b97e8c3ed
--- /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 0000000000..d9d7ffa569
--- /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 0000000000..20b1de35a8
--- /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 0000000000..b2979fe21a
--- /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 0000000000..39bb3e5ecb
--- /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 0000000000..de16668b44
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -0,0 +1,440 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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();
+ emit sourceChanged(d->url);
+
+ if (isComponentComplete())
+ load();
+}
+
+void QDeclarativeBorderImage::load()
+{
+ Q_D(QDeclarativeBorderImage);
+ if (d->progress != 0.0) {
+ d->progress = 0.0;
+ emit progressChanged(d->progress);
+ }
+
+ if (d->url.isEmpty()) {
+ d->pix = QPixmap();
+ d->status = Null;
+ setImplicitWidth(0);
+ setImplicitHeight(0);
+ emit statusChanged(d->status);
+ 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);
+
+ static int sciReplyFinished = -1;
+ static int thisSciRequestFinished = -1;
+ if (sciReplyFinished == -1) {
+ sciReplyFinished =
+ QNetworkReply::staticMetaObject.indexOfSignal("finished()");
+ thisSciRequestFinished =
+ QDeclarativeBorderImage::staticMetaObject.indexOfSlot("sciRequestFinished()");
+ }
+
+ QMetaObject::connect(d->sciReply, sciReplyFinished, this,
+ thisSciRequestFinished, Qt::DirectConnection);
+ }
+ } else {
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, d->async);
+ 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 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, d->async);
+ if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl);
+ d->sciPendingPixmapCache = 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 =
+ QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
+ thisRequestFinished =
+ QDeclarativeBorderImage::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
+ 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 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, d->async);
+ } else {
+ d->pendingPixmapCache = false;
+ if (QDeclarativePixmapCache::get(d->url, &d->pix, d->async) != 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 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 0000000000..a759e67c8c
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage_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 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();
+
+protected:
+ virtual void load();
+
+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 0000000000..b9cf73a71f
--- /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 0000000000..ea1f9cc3db
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include <qdeclarative.h>
+
+#include <QtGui/qgraphicseffect.h>
+
+/*!
+ \qmlclass Blur QGraphicsBlurEffect
+ \since 4.7
+ \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
+ \since 4.7
+ \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
+ \since 4.7
+ \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
+ \since 4.7
+ \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 0000000000..73eec6a193
--- /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 0000000000..8be2f409f8
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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
+ \since 4.7
+ \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 0000000000..65ac8dee33
--- /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 0000000000..c54ddd0460
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -0,0 +1,1336 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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(600)
+ , 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(contentXChanged()));
+ QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(contentYChanged()));
+ QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange()));
+ QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange()));
+}
+
+/*
+ Returns the amount to overshoot by given a velocity.
+ Will be roughly in range 0 - size/4
+*/
+qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size)
+{
+ Q_Q(QDeclarativeFlickable);
+ if (maxVelocity <= 0)
+ return 0.0;
+
+ velocity = qAbs(velocity);
+ if (velocity > maxVelocity)
+ velocity = maxVelocity;
+ qreal dist = size / 4 * velocity / maxVelocity;
+ return dist;
+}
+
+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?overShootDistance(velocity,q->width()):0));
+ flickTargetX = minX;
+ } else {
+ const qreal maxX = q->maxXExtent();
+ if (_moveX.value() > maxX)
+ maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity,q->width()):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?overShootDistance(velocity,q->height()):0));
+ flickTargetY = minY;
+ } else {
+ const qreal maxY = q->maxYExtent();
+ if (_moveY.value() > maxY)
+ maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity,q->height()):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) {
+ qreal dist = q->minXExtent() - _moveX;
+ timeline.move(_moveX, q->minXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
+ _moveX.setValue(q->minXExtent());
+ }
+ }
+ //emit flickingChanged();
+ } else if (_moveX.value() < q->maxXExtent()) {
+ timeline.reset(_moveX);
+ if (fixupDuration) {
+ qreal dist = q->maxXExtent() - _moveX;
+ timeline.move(_moveX, q->maxXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
+ _moveX.setValue(q->maxXExtent());
+ }
+ //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) {
+ qreal dist = q->minYExtent() - _moveY;
+ timeline.move(_moveY, q->minYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } else {
+ _moveY.setValue(q->minYExtent());
+ }
+ }
+ //emit flickingChanged();
+ } else if (_moveY.value() < q->maxYExtent()) {
+ timeline.reset(_moveY);
+ if (fixupDuration) {
+ qreal dist = q->maxYExtent() - _moveY;
+ timeline.move(_moveY, q->maxYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ } 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
+ \since 4.7
+ \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; contentWidth: image.width; contentHeight: 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::contentX
+ \qmlproperty int Flickable::contentY
+
+ 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 contentY will be 100.
+*/
+qreal QDeclarativeFlickable::contentX() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return -d->_moveX.value();
+}
+
+void QDeclarativeFlickable::setContentX(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::contentY() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return -d->_moveY.value();
+}
+
+void QDeclarativeFlickable::setContentY(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
+
+ The instantaneous velocity of movement along the x and y axes, in pixels/sec.
+
+ The reported velocity is smoothed to avoid erratic output.
+*/
+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 contentHeight is not equal to the \e height of the Flickable.
+ Allows flicking horizontally if the \e contentWidth 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 whether the surface may overshoot the
+ Flickable's boundaries when flicked.
+
+ If overShoot is true 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::contentWidth
+ \qmlproperty int Flickable::contentHeight
+
+ The dimensions of the content (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; contentWidth: image.width; contentHeight: image.height
+ Image { id: image; source: "bigimage.png" }
+ }
+ \endcode
+*/
+qreal QDeclarativeFlickable::contentWidth() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->vWidth;
+}
+
+void QDeclarativeFlickable::setContentWidth(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 contentWidthChanged();
+ d->updateBeginningEnd();
+}
+
+void QDeclarativeFlickable::widthChange()
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->vWidth < 0) {
+ d->viewport->setWidth(width());
+ emit contentWidthChanged();
+ }
+ d->updateBeginningEnd();
+}
+
+void QDeclarativeFlickable::heightChange()
+{
+ Q_D(QDeclarativeFlickable);
+ if (d->vHeight < 0) {
+ d->viewport->setHeight(height());
+ emit contentHeightChanged();
+ }
+ d->updateBeginningEnd();
+}
+
+qreal QDeclarativeFlickable::contentHeight() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->vHeight;
+}
+
+void QDeclarativeFlickable::setContentHeight(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 contentHeightChanged();
+ 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();
+}
+
+/*!
+ \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 0000000000..46176884f7
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_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$
+**
+****************************************************************************/
+
+#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 contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
+ Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
+ Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
+ Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
+
+ Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
+ Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
+
+ 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 contentWidth() const;
+ void setContentWidth(qreal);
+
+ qreal contentHeight() const;
+ void setContentHeight(qreal);
+
+ qreal contentX() const;
+ void setContentX(qreal pos);
+
+ qreal contentY() const;
+ void setContentY(qreal pos);
+
+ bool isMoving() const;
+ bool isFlicking() const;
+
+ int pressDelay() const;
+ void setPressDelay(int delay);
+
+ 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 contentWidthChanged();
+ void contentHeightChanged();
+ void contentXChanged();
+ void contentYChanged();
+ void movingChanged();
+ void flickingChanged();
+ void movementStarted();
+ void movementEnded();
+ void flickStarted();
+ void flickEnded();
+ 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 0000000000..1ff4f927c6
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -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$
+**
+****************************************************************************/
+
+#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);
+
+ qreal overShootDistance(qreal velocity, qreal size);
+
+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 0000000000..b36127fa39
--- /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 0000000000..8b9c24c520
--- /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 0000000000..0323a5981a
--- /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 0000000000..1ad8b6e674
--- /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 0000000000..384a47b414
--- /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 0000000000..cd480b4f95
--- /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 0000000000..1977817796
--- /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 0000000000..95d7a4b1b7
--- /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 0000000000..5064a503d7
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -0,0 +1,1738 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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->contentY() : q->contentX();
+ }
+ void setPosition(qreal pos) {
+ Q_Q(QDeclarativeGridView);
+ if (flow == QDeclarativeGridView::LeftToRight)
+ q->setContentY(pos);
+ else
+ q->setContentX(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 = -1;
+ 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->setContentHeight(endPosition() - startPosition());
+ else
+ q->setContentWidth(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->setContentHeight(endPosition() - startPosition());
+ else
+ q->setContentWidth(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->setContentHeight(endPosition() - startPosition());
+ fixupY();
+ } else {
+ q->setContentWidth(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(QDeclarativeProperty(highlight->item, QLatin1String("x")));
+ highlightXAnimator->setDuration(150);
+ highlightXAnimator->setEnabled(autoHighlight);
+ highlightYAnimator = new QDeclarativeEaseFollow(q);
+ highlightYAnimator->setTarget(QDeclarativeProperty(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
+ \since 4.7
+ \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(modelReset()), this, SLOT(modelReset()));
+ 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(modelReset()), this, SLOT(modelReset()));
+ 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 (d->requestedIndex >= 0) // currently creating item
+ return;
+ 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) {
+ setContentWidth(-1);
+ setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ } else {
+ setContentHeight(-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::modelReset()
+{
+ Q_D(QDeclarativeGridView);
+ d->clear();
+ refill();
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ emit countChanged();
+}
+
+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 0000000000..b488475d3f
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -0,0 +1,223 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 modelReset();
+ 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 0000000000..99ab053470
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -0,0 +1,377 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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(pixmapChanged()), this, SLOT(updatePaintedGeometry()));
+}
+
+QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent)
+ : QDeclarativeImageBase(dd, parent)
+{
+}
+
+QDeclarativeImage::~QDeclarativeImage()
+{
+}
+
+/*!
+ \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) {
+ if (!d->pix.width() || !d->pix.height())
+ return;
+ qreal widthScale = width() / qreal(d->pix.width());
+ qreal heightScale = height() / qreal(d->pix.height());
+ 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.
+*/
+
+/*!
+ \qmlproperty bool Image::asynchronous
+
+ Specifies that images on the local filesystem should be loaded
+ asynchronously in a separate thread. The default value is
+ false, causing the user interface thread to block while the
+ image is loaded. Setting \a asynchronous to true is useful where
+ maintaining a responsive user interface is more desireable
+ than having images immediately visible.
+
+ Note that this property is only valid for images read from the
+ local filesystem. Images loaded via a network resource (e.g. HTTP)
+ are always loaded asynchonously.
+*/
+
+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 0000000000..fb77ac9fa5
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimage_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 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 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 0000000000..8102237e49
--- /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 0000000000..a8cce3f79f
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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;
+}
+
+
+bool QDeclarativeImageBase::asynchronous() const
+{
+ Q_D(const QDeclarativeImageBase);
+ return d->async;
+}
+
+void QDeclarativeImageBase::setAsynchronous(bool async)
+{
+ Q_D(QDeclarativeImageBase);
+ if (d->async != async) {
+ d->async = async;
+ emit asynchronousChanged();
+ }
+}
+
+
+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;
+ emit sourceChanged(d->url);
+
+ if (isComponentComplete())
+ load();
+}
+
+void QDeclarativeImageBase::load()
+{
+ Q_D(QDeclarativeImageBase);
+ if (d->progress != 0.0) {
+ d->progress = 0.0;
+ emit progressChanged(d->progress);
+ }
+
+ if (d->url.isEmpty()) {
+ d->pix = QPixmap();
+ d->status = Null;
+ setImplicitWidth(0);
+ setImplicitHeight(0);
+ emit statusChanged(d->status);
+ emit pixmapChanged();
+ update();
+ } else {
+ d->status = Loading;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, d->async);
+ 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 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, d->async) != 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 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);
+ }
+}
+
+void QDeclarativeImageBase::componentComplete()
+{
+ Q_D(QDeclarativeImageBase);
+ QDeclarativeItem::componentComplete();
+ if (d->url.isValid())
+ load();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
new file mode 100644
index 0000000000..c8c50acb61
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_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 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)
+ Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
+
+public:
+ ~QDeclarativeImageBase();
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
+ QUrl source() const;
+ virtual void setSource(const QUrl &url);
+
+ bool asynchronous() const;
+ void setAsynchronous(bool);
+
+Q_SIGNALS:
+ void sourceChanged(const QUrl &);
+ void statusChanged(Status);
+ void progressChanged(qreal progress);
+ void pixmapChanged();
+ void asynchronousChanged();
+
+protected:
+ virtual void load();
+ virtual void componentComplete();
+ 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 0000000000..2e062a8e69
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_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 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),
+ async(false)
+ {
+ }
+
+ QPixmap pix;
+ QDeclarativeImageBase::Status status;
+ QUrl url;
+ qreal progress;
+ bool pendingPixmapCache : 1;
+ bool async : 1;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
new file mode 100644
index 0000000000..c28280831a
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -0,0 +1,2845 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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.
+
+ \section 1 Property Change Signals
+
+ Most properties on Item and Item derivatives have a signal
+ emitted when they change. By convention, the signals are
+ named <propertyName>Changed, e.g. xChanged will be emitted when an item's
+ x property changes. Note that these also have signal handers e.g.
+ the onXChanged signal handler will be called when an item's x property
+ changes. For many properties in Item or Item derivatives this can be used
+ to add a touch of imperative logic to your application (when absolutely
+ necessary).
+
+ \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
+ rotation: 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;
+
+ 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;
+
+ 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;
+
+ 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;
+
+ 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 0000000000..3ae404d70a
--- /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 0000000000..81c568856f
--- /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 0000000000..4da3bf7a8a
--- /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 0000000000..f3b9385b07
--- /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 0000000000..5c4904016a
--- /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 0000000000..a23ea659cf
--- /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 0000000000..b35f2f53f0
--- /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 0000000000..c496c97795
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -0,0 +1,2730 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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->contentY() : q->contentX();
+ }
+ void setPosition(qreal pos) {
+ Q_Q(QDeclarativeListView);
+ if (orient == QDeclarativeListView::Vertical)
+ q->setContentY(pos);
+ else
+ q->setContentX(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->setContentHeight(endPosition() - startPosition() + 1);
+ } else {
+ q->setContentWidth(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(QDeclarativeProperty(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(QDeclarativeProperty(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/2);
+ 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/2);
+ 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?overShootDistance(velocity, q->width()):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?overShootDistance(velocity, q->width()):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 ? overShootDistance(v, q->width()) : 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?overShootDistance(velocity, q->height()):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?overShootDistance(velocity, q->height()):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 ? overShootDistance(v, q->height()) : 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(modelReset()), this, SLOT(modelReset()));
+ 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(modelReset()), this, SLOT(modelReset()));
+ 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 (d->requestedIndex >= 0) // currently creating item
+ return;
+ 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) {
+ setContentWidth(-1);
+ setFlickDirection(VerticalFlick);
+ } else {
+ setContentHeight(-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::modelReset()
+{
+ Q_D(QDeclarativeListView);
+ d->clear();
+ refill();
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ emit countChanged();
+}
+
+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 0000000000..5e3edb024c
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -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$
+**
+****************************************************************************/
+
+#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 modelReset();
+ 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 0000000000..bd89321702
--- /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 0000000000..65538a8d8b
--- /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 0000000000..fc5e66532d
--- /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 0000000000..ec7aa62e64
--- /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 MouseArea QDeclarativeMouseArea
+ \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 area.
+
+ 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 area.
+
+ 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 area.
+
+ 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 area.
+ \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 area.
+
+ \warning This property is not updated if the area 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 area 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 area 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 0000000000..33422e2765
--- /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 0000000000..d4871f258f
--- /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 0000000000..ab6007a955
--- /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 0000000000..cc616afffc
--- /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 0000000000..a15febb75b
--- /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 0000000000..1a58d3fb1d
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
@@ -0,0 +1,1299 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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<QPainter::Fragment, 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].x = particle.x - myX + halfPWidth;
+ pixmapData[i].y = 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].sourceLeft = sourceRect.left();
+ pixmapData[i].sourceTop = sourceRect.top();
+ pixmapData[i].width = sourceRect.width();
+ pixmapData[i].height = sourceRect.height();
+ }
+ p->drawPixmapFragments(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 0000000000..06acbb96c2
--- /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 0000000000..48f112a7ca
--- /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 0000000000..b3139f8d31
--- /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 0000000000..fb63867286
--- /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 0000000000..c131f4c95d
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -0,0 +1,987 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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(modelReset()), this, SLOT(modelReset()));
+ 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(modelReset()), this, SLOT(modelReset()));
+ 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 && d->items.count() > modelIndex; ++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::modelReset()
+{
+ Q_D(QDeclarativePathView);
+ d->regenerate();
+}
+
+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 0000000000..709a4fc2ef
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativepathview_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 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 modelReset();
+ 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 0000000000..ca50910696
--- /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 0000000000..1212e89cc4
--- /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 0000000000..ff6fc4bfb2
--- /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 0000000000..3a1edeec62
--- /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 0000000000..d534f2117a
--- /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 0000000000..7272962e17
--- /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 0000000000..b87c57fca6
--- /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 0000000000..e4cd499ad1
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -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$
+**
+****************************************************************************/
+
+#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(modelReset()), this, SLOT(modelReset()));
+ /*
+ 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(modelReset()), this, SLOT(modelReset()));
+ /*
+ 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();
+}
+
+void QDeclarativeRepeater::modelReset()
+{
+ 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 0000000000..db46699e58
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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);
+ void modelReset();
+
+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 0000000000..11773ff59b
--- /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 0000000000..dbc7568179
--- /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 0000000000..92b3f91da4
--- /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 0000000000..ca253df32c
--- /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 0000000000..cbea8f3b2b
--- /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 0000000000..a0c8abeef6
--- /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 0000000000..8e44b26b72
--- /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 0000000000..6183b1d997
--- /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 0000000000..002fac41a4
--- /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 0000000000..9919904326
--- /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 0000000000..f690ae2428
--- /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 0000000000..3d28f4096f
--- /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 0000000000..24026487f1
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -0,0 +1,1291 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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)));
+ QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
+ } 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)));
+ QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
+ 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;
+}
+
+/*!
+ \qmlproperty object VisualDataModel::parts
+
+ The \a parts property selects a VisualDataModel which creates
+ delegates from the part named. This is used in conjunction with
+ the Package element.
+
+ For example, the code below selects a model which creates
+ delegates named \e list from a Package:
+
+ \code
+ VisualDataModel {
+ id: visualModel
+ delegate: Package {
+ Item { Package.name: "list" }
+ }
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ \endcode
+
+ \sa Package
+*/
+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_modelReset()
+{
+ Q_D(QDeclarativeVisualDataModel);
+ emit modelReset();
+}
+
+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 0000000000..d34bcaf9cd
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 modelReset();
+ 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_modelReset();
+ 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 0000000000..a2b16ba65f
--- /dev/null
+++ b/src/declarative/graphicsitems/qdeclarativewebview.cpp
@@ -0,0 +1,1338 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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);
+
+ QWebSettings::enablePersistentStorage();
+
+ 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(titleChanged(QString)), this, SIGNAL(iconChanged()));
+ 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 0000000000..a65aab38bf
--- /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 0000000000..258b4729ba
--- /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 72b4717c1e..0000000000
--- 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 41911ff7eb..0000000000
--- 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 a2e41d31e8..0000000000
--- 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 4dea33c29c..0000000000
--- 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 a6cee0d389..0000000000
--- 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 5e04a936a1..0000000000
--- 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 25a220f59a..0000000000
--- 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 32dc38830e..0000000000
--- 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 b97ae6d08c..0000000000
--- 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 8cd4e6f2ce..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include <qml.h>
-
-#include <QtGui/qgraphicseffect.h>
-
-/*!
- \qmlclass Blur QGraphicsBlurEffect
- \since 4.7
- \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
- \since 4.7
- \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
- \since 4.7
- \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
- \since 4.7
- \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 4b94a14766..0000000000
--- 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 1fb5cd0e17..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp
+++ /dev/null
@@ -1,194 +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
- \since 4.7
- \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 0ed852abf6..0000000000
--- 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 69338901b6..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ /dev/null
@@ -1,1325 +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
- \since 4.7
- \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 580d01eb80..0000000000
--- 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 e58cc0cd32..0000000000
--- 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 f51c2030e7..0000000000
--- 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 2b9e44e12e..0000000000
--- 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 4d7af5482d..0000000000
--- 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 935b04ebc9..0000000000
--- 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 bba471a87f..0000000000
--- 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 ca53b01010..0000000000
--- 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 692f7a9857..0000000000
--- 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 e263aa08a2..0000000000
--- 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 e54ed8e1d8..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ /dev/null
@@ -1,1724 +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
- \since 4.7
- \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 bd18dafc42..0000000000
--- 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 6e93c52788..0000000000
--- 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 b8befebfcf..0000000000
--- 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 e404935635..0000000000
--- 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 c09b66188c..0000000000
--- 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 e8bda4cef3..0000000000
--- 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 d86785f82a..0000000000
--- 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 fce4e36706..0000000000
--- 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 891fc883a2..0000000000
--- 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 4860b83e66..0000000000
--- 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 a1c7b89780..0000000000
--- 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 9263f49a6d..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
+++ /dev/null
@@ -1,167 +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"
-
-#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)
-
-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 76fea7e6e0..0000000000
--- 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 b55bedad0c..0000000000
--- 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 fbc891db98..0000000000
--- 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 28b21c9061..0000000000
--- 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 c5b4aab3d6..0000000000
--- 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 b9780f2d7b..0000000000
--- 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 0ab67acff0..0000000000
--- 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 61dab5872b..0000000000
--- 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 07354f4a26..0000000000
--- 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 2e2f8c932d..0000000000
--- 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 fadb430a85..0000000000
--- 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 3daa0c64cd..0000000000
--- 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 f2f9be0a6f..0000000000
--- 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 7d49914d93..0000000000
--- 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 3f4521e78a..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ /dev/null
@@ -1,1244 +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 int ParticleMotionGravity::xattractor
- \qmlproperty int ParticleMotionGravity::yattractor
- These properties hold the x and y coordinates of the point attracting the particles.
-*/
-
-/*!
- \qmlproperty int 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::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 int QmlGraphicsParticleMotionWander::xvariance
- \qmlproperty int QmlGraphicsParticleMotionWander::yvariance
-
- These properties set the amount to wander in the x and y directions.
-*/
-
-/*!
- \qmlproperty int 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;
-}
-
-//---------------------------------------------------------------------------
-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);
- d->motion = motion;
-}
-
-/*!
- \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<QPainter::Fragment, 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].x = particle.x - myX + halfPWidth;
- pixmapData[i].y = 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].sourceLeft = sourceRect.left();
- pixmapData[i].sourceTop = sourceRect.top();
- pixmapData[i].width = sourceRect.width();
- pixmapData[i].height = sourceRect.height();
- }
- p->drawPixmapFragments(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 7f0f9cdd28..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
+++ /dev/null
@@ -1,247 +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(int xattractor READ xAttractor WRITE setXAttractor)
- Q_PROPERTY(int yattractor READ yAttractor WRITE setYAttractor)
- Q_PROPERTY(int acceleration READ acceleration WRITE setAcceleration)
-public:
- QmlGraphicsParticleMotionGravity(QObject *parent=0)
- : QmlGraphicsParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {}
-
- int xAttractor() const { return _xAttr; }
- void setXAttractor(int x) { _xAttr = x; }
-
- int yAttractor() const { return _yAttr; }
- void setYAttractor(int y) { _yAttr = y; }
-
- int acceleration() const { return int(_accel * 1000000); }
- void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; }
-
- virtual void advance(QmlGraphicsParticle &, int interval);
-
-private:
- int _xAttr;
- int _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(int xvariance READ xVariance WRITE setXVariance)
- int xVariance() const { return int(_xvariance * 1000); }
- void setXVariance(int var) { _xvariance = var / 1000.0; }
-
- Q_PROPERTY(int yvariance READ yVariance WRITE setYVariance)
- int yVariance() const { return int(_yvariance * 1000); }
- void setYVariance(int var) { _yvariance = var / 1000.0; }
-
- Q_PROPERTY(int pace READ pace WRITE setPace)
- int pace() const { return int(_pace * 1000); }
- void setPace(int pace) { _pace = pace / 1000.0; }
-
-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)
- 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();
-
-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 0da246fb7b..0000000000
--- 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 7ba5bbc5a3..0000000000
--- 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 acff7c83cd..0000000000
--- 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 9a2c24dd92..0000000000
--- 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 8273cccb56..0000000000
--- 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 c635833dcf..0000000000
--- 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 84af67d8a4..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ /dev/null
@@ -1,866 +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);
- d->moveTransition = mt;
-}
-
-QmlTransition *QmlGraphicsBasePositioner::add() const
-{
- Q_D(const QmlGraphicsBasePositioner);
- return d->addTransition;
-}
-
-void QmlGraphicsBasePositioner::setAdd(QmlTransition *add)
-{
- Q_D(QmlGraphicsBasePositioner);
- d->addTransition = add;
-}
-
-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"
- ease: "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::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 1fb687a259..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ /dev/null
@@ -1,192 +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)
- Q_PROPERTY(QmlTransition *add READ add WRITE setAdd)
-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();
-
-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)
- Q_PROPERTY(int columns READ columns WRITE setcolumns)
-public:
- QmlGraphicsGrid(QmlGraphicsItem *parent=0);
-
- int rows() const {return _rows;}
- void setRows(const int rows){_rows = rows;}
-
- int columns() const {return _columns;}
- void setcolumns(const int columns){_columns = columns;}
-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 e9b6aa86ab..0000000000
--- 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 adc4cf359e..0000000000
--- 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 66552f6e00..0000000000
--- 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 f91e7e2d88..0000000000
--- 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 23c3aae29b..0000000000
--- 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 2324916490..0000000000
--- 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 5680288980..0000000000
--- 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 1956939f7d..0000000000
--- 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 650be62ae5..0000000000
--- 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 57b44d21ec..0000000000
--- 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 ad3552475b..0000000000
--- 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 f67d57c013..0000000000
--- 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 364751d4ac..0000000000
--- 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 337cd9d415..0000000000
--- 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 7d4ca889be..0000000000
--- 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 d3c1f1fd2e..0000000000
--- 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 2b37b78a78..0000000000
--- 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 694ec9399e..0000000000
--- 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 19281958b6..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ /dev/null
@@ -1,1103 +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);
- e.setTrackChange(false);
- 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();
- 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;
-};
-
-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())
- 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);
- 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;
-}
-
-//---------------------------------------------------------------------------
-
-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();
-}
-
-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();
- }
-}
-
-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();
- }
-}
-
-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);
- e.setTrackChange(false);
- 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);
- e.setTrackChange(false);
- 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);
- 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 49f9b27c3e..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_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$
-**
-****************************************************************************/
-
-#ifndef QMLGRAPHICSVISUALDATAMODEL_H
-#define QMLGRAPHICSVISUALDATAMODEL_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qabstractitemmodel.h>
-
-QT_BEGIN_HEADER
-
-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_CLASSINFO("DefaultProperty", "delegate")
-public:
- QmlGraphicsVisualDataModel();
- QmlGraphicsVisualDataModel(QmlContext *);
- virtual ~QmlGraphicsVisualDataModel();
-
- QVariant model() const;
- void setModel(const QVariant &);
-
- QmlComponent *delegate() const;
- void setDelegate(QmlComponent *);
-
- 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);
-
-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 7d9bf52a65..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ /dev/null
@@ -1,1319 +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;
- 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);
- d->pressTime = ms;
-}
-
-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;
- }
-}
-
-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);
- delete d->newWindowComponent;
- d->newWindowComponent = newWindow;
-}
-
-
-/*!
- \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);
- delete d->newWindowParent;
- d->newWindowParent = parent;
-}
-
-/*!
- 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 30ba0e4c63..0000000000
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.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 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)
-
- Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime)
-
- 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)
- Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent)
-
- Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled)
-
-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 zoomFactorChanged();
-
- 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 e132cae428..0000000000
--- 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 45304798d5..fd4361c2df 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 0000000000..7cf81b2572
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -0,0 +1,3096 @@
+----------------------------------------------------------------------------
+--
+-- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+-- All rights 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"
+%token T_ON "on"
+
+--- 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_ON UiQualifiedId UiObjectInitializer ;
+/.
+case $rule_number: {
+ AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
+ sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ node->hasOnToken = true;
+ 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 JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier 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 JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier 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 JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier 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 JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier 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 JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier 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 JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier 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;
+}
+./
+
+JsIdentifier: T_ON ;
+/.
+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 0000000000..3b569a7123
--- /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 0000000000..c1945cefbb
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsast_p.h
@@ -0,0 +1,2685 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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),
+ hasOnToken(false)
+ { kind = K; }
+
+ virtual SourceLocation firstSourceLocation() const
+ {
+ if (hasOnToken && qualifiedTypeNameId)
+ return qualifiedTypeNameId->identifierToken;
+
+ return qualifiedId->identifierToken;
+ }
+
+ virtual SourceLocation lastSourceLocation() const
+ { return initializer->rbraceToken; }
+
+ virtual void accept0(Visitor *visitor);
+
+// attributes
+ UiQualifiedId *qualifiedId;
+ UiQualifiedId *qualifiedTypeNameId;
+ UiObjectInitializer *initializer;
+ SourceLocation colonToken;
+ bool hasOnToken;
+};
+
+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 0000000000..5a444b7e5f
--- /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 0000000000..d8002cfba7
--- /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 0000000000..82abbcf42a
--- /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 0000000000..7d39134f05
--- /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 0000000000..61188f7d03
--- /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 0000000000..7c901aeb0d
--- /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 0000000000..0677bc5917
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
@@ -0,0 +1,992 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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", "on", 0, 0, 0, 0, 0, 0, 0,
+ 0};
+
+const short QDeclarativeJSGrammar::lhs [] = {
+ 101, 101, 101, 101, 101, 101, 102, 108, 108, 111,
+ 111, 113, 112, 112, 112, 112, 112, 112, 112, 112,
+ 115, 110, 109, 118, 118, 119, 119, 120, 120, 117,
+ 106, 106, 106, 106, 106, 106, 106, 106, 126, 126,
+ 126, 127, 127, 128, 128, 106, 106, 106, 106, 106,
+ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+ 106, 106, 106, 116, 116, 116, 116, 116, 131, 131,
+ 131, 131, 131, 131, 131, 131, 131, 131, 131, 131,
+ 131, 131, 131, 131, 131, 131, 121, 133, 133, 133,
+ 133, 132, 132, 135, 135, 137, 137, 137, 137, 137,
+ 137, 138, 138, 138, 138, 138, 138, 138, 138, 138,
+ 138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
+ 138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
+ 138, 138, 139, 139, 114, 114, 114, 114, 114, 142,
+ 142, 143, 143, 143, 143, 141, 141, 144, 144, 145,
+ 145, 146, 146, 146, 147, 147, 147, 147, 147, 147,
+ 147, 147, 147, 147, 148, 148, 148, 148, 149, 149,
+ 149, 150, 150, 150, 150, 151, 151, 151, 151, 151,
+ 151, 151, 152, 152, 152, 152, 152, 152, 153, 153,
+ 153, 153, 153, 154, 154, 154, 154, 154, 155, 155,
+ 156, 156, 157, 157, 158, 158, 159, 159, 160, 160,
+ 161, 161, 162, 162, 163, 163, 164, 164, 165, 165,
+ 166, 166, 136, 136, 167, 167, 168, 168, 168, 168,
+ 168, 168, 168, 168, 168, 168, 168, 168, 104, 104,
+ 169, 169, 170, 170, 171, 171, 103, 103, 103, 103,
+ 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
+ 103, 122, 183, 183, 182, 182, 130, 130, 184, 184,
+ 185, 185, 187, 187, 186, 188, 191, 189, 189, 192,
+ 190, 190, 123, 124, 124, 125, 125, 172, 172, 172,
+ 172, 172, 172, 172, 173, 173, 173, 173, 174, 174,
+ 174, 174, 175, 175, 176, 178, 193, 193, 196, 196,
+ 194, 194, 197, 195, 177, 177, 177, 179, 179, 180,
+ 180, 180, 198, 199, 181, 181, 129, 140, 203, 203,
+ 200, 200, 201, 201, 204, 107, 205, 205, 105, 105,
+ 202, 202, 134, 134, 206};
+
+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, 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, 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, 172, 239,
+ 203, 211, 207, 151, 223, 199, 3, 136, 70, 152,
+ 215, 219, 140, 169, 150, 155, 135, 189, 176, 0,
+ 77, 78, 73, 341, 64, 343, 0, 0, 0, 0,
+ 75, 0, 0, 71, 74, 68, 0, 0, 65, 67,
+ 66, 76, 69, 0, 72, 0, 0, 165, 0, 0,
+ 152, 171, 154, 153, 0, 0, 0, 167, 168, 166,
+ 170, 0, 200, 0, 0, 0, 0, 190, 0, 0,
+ 0, 0, 0, 0, 180, 0, 0, 0, 174, 175,
+ 173, 178, 182, 181, 179, 177, 192, 191, 193, 0,
+ 208, 0, 204, 0, 0, 146, 133, 145, 134, 102,
+ 103, 104, 129, 105, 130, 106, 107, 108, 109, 110,
+ 111, 112, 113, 114, 115, 116, 117, 118, 131, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 132,
+ 0, 0, 144, 240, 147, 0, 148, 0, 149, 143,
+ 0, 236, 229, 227, 234, 235, 233, 232, 238, 231,
+ 230, 228, 237, 224, 0, 212, 0, 0, 216, 0,
+ 0, 220, 0, 0, 146, 138, 0, 137, 0, 142,
+ 156, 0, 342, 331, 332, 0, 329, 0, 330, 0,
+ 333, 247, 254, 253, 261, 249, 0, 250, 334, 0,
+ 340, 251, 252, 257, 255, 337, 335, 339, 258, 0,
+ 269, 0, 0, 0, 0, 341, 64, 0, 343, 65,
+ 241, 283, 66, 0, 0, 0, 270, 0, 0, 259,
+ 260, 0, 248, 256, 284, 285, 328, 338, 0, 299,
+ 300, 301, 302, 0, 295, 296, 297, 298, 325, 326,
+ 0, 0, 0, 0, 0, 288, 289, 245, 243, 205,
+ 213, 209, 225, 201, 246, 0, 152, 217, 221, 194,
+ 183, 0, 0, 202, 0, 0, 0, 0, 195, 0,
+ 0, 0, 0, 0, 187, 185, 188, 186, 184, 197,
+ 196, 198, 0, 210, 0, 206, 0, 244, 152, 0,
+ 226, 241, 242, 0, 241, 0, 0, 291, 0, 0,
+ 0, 293, 0, 214, 0, 0, 218, 0, 0, 222,
+ 281, 0, 273, 282, 276, 0, 280, 0, 241, 274,
+ 0, 241, 0, 0, 292, 0, 0, 0, 294, 342,
+ 331, 0, 0, 333, 0, 327, 0, 317, 0, 0,
+ 0, 287, 0, 286, 0, 344, 0, 101, 263, 266,
+ 0, 102, 269, 105, 130, 107, 108, 73, 112, 113,
+ 64, 114, 117, 71, 74, 65, 241, 66, 76, 120,
+ 69, 122, 72, 124, 125, 270, 127, 128, 132, 0,
+ 94, 0, 0, 96, 100, 98, 85, 97, 99, 0,
+ 95, 84, 264, 262, 140, 141, 146, 0, 139, 0,
+ 316, 0, 303, 304, 0, 315, 0, 0, 0, 306,
+ 311, 309, 312, 0, 0, 310, 311, 0, 307, 0,
+ 308, 265, 314, 0, 265, 313, 0, 318, 319, 0,
+ 265, 320, 321, 0, 0, 322, 0, 0, 0, 323,
+ 324, 158, 157, 0, 0, 0, 290, 0, 0, 0,
+ 305, 278, 271, 0, 279, 275, 0, 277, 267, 0,
+ 268, 272, 88, 0, 0, 92, 79, 0, 81, 90,
+ 0, 82, 91, 93, 83, 89, 80, 0, 86, 162,
+ 160, 164, 161, 159, 163, 6, 336, 4, 2, 62,
+ 87, 0, 0, 65, 67, 66, 31, 5, 0, 63,
+ 0, 41, 40, 39, 0, 0, 54, 0, 55, 0,
+ 60, 61, 0, 41, 0, 0, 0, 0, 0, 50,
+ 51, 0, 52, 0, 53, 0, 56, 57, 0, 0,
+ 0, 0, 0, 58, 59, 0, 48, 42, 49, 43,
+ 0, 0, 0, 0, 45, 0, 46, 47, 44, 0,
+ 0, 0, 30, 35, 36, 37, 38, 140, 265, 0,
+ 0, 102, 269, 105, 130, 107, 108, 73, 112, 113,
+ 64, 114, 117, 71, 74, 65, 241, 66, 76, 120,
+ 69, 122, 72, 124, 125, 270, 127, 128, 132, 140,
+ 0, 26, 0, 0, 32, 27, 33, 28, 24, 0,
+ 29, 25, 0, 34, 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, 345};
+
+const short QDeclarativeJSGrammar::goto_default [] = {
+ 7, 620, 207, 196, 205, 507, 495, 619, 638, 614,
+ 618, 616, 621, 22, 617, 18, 506, 609, 600, 562,
+ 508, 191, 195, 197, 201, 524, 550, 549, 200, 232,
+ 26, 474, 473, 356, 355, 9, 354, 357, 107, 17,
+ 145, 24, 13, 144, 19, 25, 57, 23, 8, 28,
+ 27, 269, 15, 263, 10, 259, 12, 261, 11, 260,
+ 20, 267, 21, 268, 14, 262, 258, 299, 411, 264,
+ 265, 202, 193, 192, 204, 233, 203, 208, 229, 230,
+ 194, 360, 359, 231, 463, 462, 321, 322, 465, 324,
+ 464, 323, 419, 423, 426, 422, 421, 441, 442, 185,
+ 199, 181, 184, 198, 206, 0};
+
+const short QDeclarativeJSGrammar::action_index [] = {
+ 314, 1273, 2404, 2404, 2307, 1001, 58, 98, 78, -101,
+ 95, 56, 4, 236, -101, 296, 86, -101, -101, 545,
+ 97, 115, 162, 197, -101, -101, -101, 447, 192, 1273,
+ -101, -101, -101, 369, -101, 2113, 1919, 1273, 1273, 1273,
+ -101, 732, 1273, -101, -101, -101, 1273, 1273, -101, -101,
+ -101, -101, -101, 1273, -101, 1273, 1273, -101, 1273, 1273,
+ 81, 195, -101, -101, 1273, 1273, 1273, -101, -101, -101,
+ 185, 1273, 283, 1273, 1273, 1273, 1273, 447, 1273, 1273,
+ 1273, 1273, 1273, 1273, 297, 1273, 1273, 1273, 107, 85,
+ 116, 297, 297, 297, 297, 191, 447, 447, 447, 1273,
+ 74, 1273, 102, 2016, 1273, 1273, -101, -101, -101, -101,
+ -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
+ -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
+ -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
+ 112, 1273, -101, -101, 92, 61, -101, 1273, -101, -101,
+ 1273, -101, -101, -101, -101, -101, -101, -101, -101, -101,
+ -101, -101, -101, -101, 1273, 36, 1273, 1273, 65, 62,
+ 1273, -101, 2016, 1273, 1273, -101, 127, -101, 42, -101,
+ -101, 57, -101, 294, 60, 35, -101, 259, -101, 32,
+ 2404, -101, -101, -101, -101, -101, 200, -101, -101, 33,
+ -101, -101, -101, -101, -101, -101, 2404, -101, -101, 436,
+ -101, 433, 100, 2307, 34, 369, 67, 45, 2598, 71,
+ 1273, -101, 72, 51, 1273, 59, -101, 54, 55, -101,
+ -101, 324, -101, -101, -101, -101, -101, -101, 88, -101,
+ -101, -101, -101, 76, -101, -101, -101, -101, -101, -101,
+ 5, 49, 1273, 104, 84, -101, -101, 1457, -101, 70,
+ 41, 1, -101, 287, 68, 46, 643, 73, 77, 364,
+ 297, 369, 1273, 238, 1273, 1273, 1273, 1273, 341, 1273,
+ 1273, 1273, 1273, 1273, 297, 175, 167, 161, 176, 348,
+ 315, 331, 1273, -13, 1273, 63, 1273, -101, 545, 1273,
+ -101, 1273, 64, 40, 1273, 2, 2307, -101, 1273, 152,
+ 2307, -101, 1273, 69, 1273, 1273, 75, 79, 1273, -101,
+ 44, 149, 66, -101, -101, 1273, -101, 369, 1273, -101,
+ 52, 1273, -54, 2307, -101, 1273, 151, 2307, -101, -29,
+ 369, -41, -11, 2404, -46, -101, 2307, -101, 1273, 131,
+ 2307, -5, 2307, -101, 8, 13, -55, -101, -101, 2307,
+ -51, 360, -2, 352, 119, 1273, 2307, 39, -19, 366,
+ 3, -24, 910, 6, 7, -101, 1367, -101, 11, -16,
+ -4, 1273, -6, -31, 1273, 9, 1273, -12, 17, 1273,
+ -101, 2210, 37, -101, -101, -101, -101, -101, -101, 1273,
+ -101, -101, -101, -101, 258, -101, 1273, -15, -101, 2307,
+ -101, 117, -101, -101, 2307, -101, 1273, 106, 16, -101,
+ 38, -101, 135, 96, 1273, -101, 135, 43, -101, 18,
+ -101, 2307, -101, 101, 2307, -101, 179, -101, -101, 99,
+ 2307, 31, -101, -7, -8, -101, 369, -34, -1, -101,
+ -101, -101, -101, 1273, 124, 2307, -101, 1273, 122, 2307,
+ -101, 25, -101, 207, -101, -101, 1273, -101, -101, 290,
+ -101, -101, -101, 114, 1733, -101, -101, 1826, -101, -101,
+ 1550, -101, -101, -101, -101, -101, -101, 103, -101, -101,
+ -101, -101, -101, -101, -101, -101, 2404, -101, -101, -101,
+ 221, -43, 704, 164, -26, 12, -101, -101, 188, -101,
+ 196, -101, -101, -101, 369, 183, -101, 1273, -101, 165,
+ -101, -101, 170, 0, 369, 160, 10, 369, 113, -101,
+ -101, 215, -101, 1273, -101, 225, -101, -101, 203, 369,
+ 28, 1273, 229, -101, -101, 202, -101, 218, -101, 30,
+ -21, 369, 199, 278, -101, 110, -101, -101, -101, 1640,
+ 1092, 583, -101, -101, -101, -101, -101, 284, 2501, 1919,
+ 14, 388, 29, 424, 93, 1273, 2307, 39, -9, 338,
+ 21, -3, 821, 24, 23, -101, 1367, -101, 48, 20,
+ 47, 1273, 50, 26, 1273, 53, 1273, 27, 22, 264,
+ 120, -101, 15, 813, -101, -101, -101, -101, -101, 1183,
+ -101, -101, 19, -101, -101, 498, -101, 249, -82, 902,
+ -101, -101, 118, 369, -101, 204, -101, 80, -101, -101,
+ 369, -101, -101, 82, -101, -101, -101, -101, -101, -101,
+
+ -106, 17, -83, 19, 24, 228, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -49,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, 101,
+ -106, -106, -106, 2, -106, -106, -2, 29, 107, 166,
+ -106, 204, 183, -106, -106, -106, 174, 169, -106, -106,
+ -106, -106, -106, 145, -106, 141, 137, -106, 152, 161,
+ -106, -106, -106, -106, 163, 158, 157, -106, -106, -106,
+ -106, 132, -106, 142, 138, 187, 178, -106, 167, 181,
+ 81, 82, 85, 83, -106, 93, 114, 96, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, 170,
+ -106, 74, -106, 109, 80, 51, -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, 25, -106, -106, -106, -106, -106, 41, -106, -106,
+ 50, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, 98, -106, 104, 43, -106, -106,
+ 42, -106, 221, 64, 117, -106, -106, -106, -106, -106,
+ -106, -106, -106, 54, -106, -106, -106, 55, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, 47, -106, -106, 38,
+ -106, 33, -106, 92, -106, 73, -106, -106, 88, -106,
+ 86, -106, -106, -106, 94, 23, -106, -106, -106, -106,
+ -106, -11, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, 22, -106, -106, -106, -106, 105, -106, -106,
+ -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, 7, 235, -106, 249, 219, 216, 222, -106, 124,
+ 125, 123, 122, 116, -106, -106, -106, -106, -106, -106,
+ -106, -106, 191, -106, 232, -106, 225, -106, -106, 231,
+ -106, 156, -106, -106, 130, -106, 91, -106, 5, -106,
+ 8, -106, 233, -106, 200, 189, -106, -106, 198, -106,
+ -106, -106, -106, -106, -106, 245, -106, 108, 95, -106,
+ -106, 298, -106, 195, -106, 89, -106, 71, -106, -106,
+ 120, -106, -106, -5, -106, -106, 52, -106, 53, -106,
+ 56, -106, 60, -106, -106, -106, -106, -106, -106, 39,
+ -106, 37, -106, 49, -106, 133, 69, -106, -106, 59,
+ -106, -106, 102, -106, -106, -106, 79, -106, -106, -106,
+ -106, 62, -106, 45, 67, -106, 75, -106, -106, 44,
+ -106, 1, -106, -106, -106, -106, -106, -106, -106, 46,
+ -106, -106, -106, -106, -106, -106, 115, -106, -106, 66,
+ -106, -106, -106, -106, 70, -106, 77, -106, -106, -106,
+ -106, -106, -9, -106, 72, -106, -38, -106, -106, -106,
+ -106, 97, -106, -106, 99, -106, -106, -106, -106, -106,
+ 40, -51, -106, -106, 36, -106, 34, -106, 63, -106,
+ -106, -106, -106, 35, -106, 48, -106, 58, -106, 57,
+ -106, -106, -106, -106, -106, -106, 28, -106, -106, 90,
+ -106, -106, -106, -106, 65, -106, -106, 159, -106, -106,
+ 61, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, 87, -106, -106, -106,
+ -106, -106, -13, -106, -106, -106, -106, -106, -106, -106,
+ -18, -106, -106, -106, -10, -106, -106, 0, -106, -106,
+ -106, -106, -106, -106, -4, -12, -106, -6, -106, -106,
+ -106, -106, -106, 3, -106, -106, -106, -106, -23, -14,
+ -106, 11, -106, -106, -106, -106, -106, 15, -106, -106,
+ -106, 16, 18, 14, -106, -106, -106, -106, -106, 292,
+ 399, 180, -106, -106, -106, -106, -106, -106, 26, 286,
+ 20, 21, -106, 30, -106, 177, 10, -106, -106, 31,
+ -106, -106, 193, -106, -106, -106, 32, -106, -106, -106,
+ -106, 27, -106, 13, 76, -106, 68, -106, -106, -106,
+ -106, -106, -106, 230, -106, -106, -106, -106, -106, 290,
+ -106, -106, -3, -106, -106, 6, -106, -106, 4, 270,
+ -106, -106, -106, 9, -106, -106, -106, -106, -106, -106,
+ 12, -106, -106, -106, -106, -106, -106, -106, -106, -106};
+
+const short QDeclarativeJSGrammar::action_info [] = {
+ 401, -123, 440, -121, 403, -129, 333, 340, 615, 345,
+ -96, 352, 348, -118, -100, 389, -126, 257, -99, 342,
+ 416, 391, 343, 510, 453, 440, 448, 257, -96, 446,
+ -100, -118, 440, 348, 527, 541, -129, 525, 552, 555,
+ 538, 545, 466, 424, 399, 408, -110, 560, 560, 420,
+ 431, 444, 560, 457, -121, -99, 416, -123, 457, 440,
+ -126, 325, 306, 453, 272, 190, 294, 164, 187, 170,
+ 257, 272, 141, 430, 346, 312, 296, 312, 409, 414,
+ 294, 348, 251, 101, 99, 252, 318, 416, 236, 292,
+ 453, 457, 440, 183, 141, 189, 71, 335, 639, 164,
+ 147, 304, 179, 71, 99, 443, 427, 301, 434, 141,
+ 0, 141, 141, 331, 141, 0, 0, 292, 58, 444,
+ 141, 149, 477, 62, 0, 58, 0, 314, 603, 59,
+ 141, 315, 141, 172, 63, 141, 59, 247, 246, 141,
+ 424, 629, 628, 635, 634, 256, 255, 58, 615, 242,
+ 241, 428, 173, 101, 249, 248, 58, 327, 59, 141,
+ 141, 249, 248, 488, 254, 166, 418, 59, 142, 167,
+ 478, 557, 556, 141, 530, 529, 604, 172, 413, 412,
+ 249, 248, 459, 177, 455, 172, 85, 141, 86, 511,
+ 517, 350, 85, 523, 86, 559, 173, 64, 174, 87,
+ 85, 85, 86, 86, 173, 87, 406, 64, 141, 64,
+ 328, 337, 310, 87, 87, 469, 85, 85, 86, 86,
+ 0, 560, 533, 0, 0, 511, 521, 520, 511, 87,
+ 87, 0, 511, 141, 0, 513, 172, 141, 547, 513,
+ 438, 437, 65, 0, 518, 516, 512, 511, 66, 0,
+ 512, 103, 65, 0, 65, 173, 274, 275, 66, 0,
+ 66, 235, 234, 548, 546, 632, 631, 0, 470, 468,
+ 104, 513, 105, 172, 513, 0, 534, 532, 513, 172,
+ 561, 0, 512, 276, 277, 512, 537, 536, 34, 512,
+ 544, 543, 173, 513, 406, 630, 625, -87, 173, 172,
+ 174, 73, 74, 0, 512, 274, 275, 34, 0, 0,
+ 626, 624, 0, 0, 73, 74, 0, -87, 173, 34,
+ 174, 0, 85, 34, 86, 48, 50, 49, 75, 76,
+ 0, 0, 276, 277, 0, 87, 0, 0, 279, 280,
+ 623, 75, 76, 0, 48, 50, 49, 281, 0, 0,
+ 282, 45, 283, 34, 279, 280, 48, 50, 49, 0,
+ 48, 50, 49, 281, 279, 280, 282, 34, 283, 0,
+ 45, 279, 280, 281, -341, 0, 282, 0, 283, 0,
+ 281, 34, 45, 282, 0, 283, 45, 279, 280, 34,
+ 48, 50, 49, 0, 0, 34, 281, 0, 34, 282,
+ 0, 283, -341, 0, 48, 50, 49, 6, 5, 4,
+ 1, 3, 2, 245, 244, 0, 45, 34, 48, 50,
+ 49, 240, 239, 0, 0, 0, 48, 50, 49, 0,
+ 45, 0, 48, 50, 49, 48, 50, 49, 0, 0,
+ 0, 0, 0, 0, 45, 0, 0, 0, 0, 240,
+ 239, 0, 45, 34, 48, 50, 49, 0, 45, 0,
+ 0, 45, 34, 0, 0, 34, 0, 0, 0, 0,
+ 78, 79, 0, 0, 0, 0, 0, 0, 80, 81,
+ 45, 0, 82, 0, 83, 245, 244, 0, 0, 0,
+ 48, 50, 49, 0, 245, 244, 0, 240, 239, 48,
+ 50, 49, 48, 50, 49, 0, 0, 0, 0, 0,
+ 30, 31, 0, 0, 0, 0, 45, 0, 0, 0,
+ 33, 0, 0, 0, 0, 45, 0, 34, 45, 0,
+ 0, 35, 36, 0, 37, 0, 0, 0, 0, 0,
+ 0, 502, 0, 0, 0, 44, 0, 0, 151, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 152, 0,
+ 0, 0, 153, 51, 48, 50, 49, 0, 52, 0,
+ 0, 154, 0, 155, 0, 0, 0, 0, 0, 43,
+ 54, 32, 0, 0, 156, 40, 157, 62, 0, 0,
+ 45, 0, 0, 0, 158, 30, 31, 159, 63, 0,
+ 0, 0, 0, 160, 0, 33, 0, 0, 0, 161,
+ 0, 0, 34, 0, 0, 0, 35, 36, 0, 37,
+ 0, 0, 0, 0, 0, 162, 502, 0, 0, 0,
+ 44, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 151, 0, 51, 48,
+ 50, 49, 0, 52, 0, 0, 152, 0, 0, 0,
+ 153, 0, 0, 0, 43, 54, 32, 0, 0, 154,
+ 40, 155, 0, 0, 308, 45, 0, 0, 0, 0,
+ 0, 0, 156, 0, 157, 62, 0, 0, 0, 0,
+ 0, 0, 158, 0, 0, 159, 63, 0, 0, 0,
+ 0, 160, 0, 0, 0, 0, 0, 161, 0, 0,
+ 0, 0, 0, 0, 0, 0, 30, 31, 0, 0,
+ 0, 0, 0, 162, 0, 0, 33, 0, 0, 0,
+ 0, 0, 0, 34, 0, 0, 0, 35, 36, 0,
+ 37, 0, 0, 0, 30, 31, 0, 502, 0, 0,
+ 0, 44, 0, 0, 33, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 0, 35, 36, 0, 37, 51,
+ 48, 50, 49, 0, 52, 41, 0, 0, 0, 44,
+ 0, 0, 0, 0, 0, 43, 54, 32, 0, 0,
+ 0, 40, 0, 0, 0, 0, 45, 51, 48, 50,
+ 49, 0, 52, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 43, 54, 32, 0, 0, 0, 40,
+ 0, 0, 0, 0, 45, 30, 31, 0, 0, 0,
+ 0, 0, 0, 30, 31, 33, 0, 0, 0, 0,
+ 0, 0, 34, 33, 0, 0, 35, 36, 0, 37,
+ 34, 0, 0, 0, 35, 36, 502, 37, 0, 0,
+ 44, 0, 0, 0, 41, 0, 0, 0, 44, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 51, 48,
+ 50, 49, 0, 52, 0, 0, 51, 48, 50, 49,
+ 0, 52, 0, 0, 43, 54, 32, 0, 0, 0,
+ 40, 0, 43, 54, 32, 45, 0, 0, 40, 0,
+ 0, 0, 0, 45, 30, 31, 0, 0, 0, 0,
+ 0, 0, 30, 31, 33, 0, 0, 0, 0, 0,
+ 0, 34, 33, 0, 0, 35, 36, 0, 37, 34,
+ 0, 0, 0, 35, 36, 502, 37, 0, 0, 44,
+ 0, 0, 0, 41, 0, 0, 0, 44, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 51, 48, 50,
+ 49, 0, 52, 0, 0, 51, 48, 50, 49, 0,
+ 52, 0, 0, 43, 54, 32, 0, 0, 0, 40,
+ 0, 43, 54, 32, 45, 0, 0, 40, 0, 0,
+ 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
+ 0, 501, 0, 30, 31, 0, 0, 0, 0, 0,
+ 0, 0, 0, 215, 0, 0, 0, 0, 0, 0,
+ 34, 0, 0, 0, 35, 36, 0, 37, 0, 0,
+ 0, 0, 0, 0, 502, 0, 0, 0, 44, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 51, 503, 505, 504,
+ 0, 52, 0, 0, 0, 0, 226, 0, 0, 0,
+ 0, 0, 43, 54, 32, 210, 0, 0, 40, 0,
+ 0, 0, 0, 45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 501, 0, 30, 31, 0, 0, 0, 0,
+ 0, 0, 0, 0, 215, 0, 0, 0, 0, 0,
+ 0, 34, 0, 0, 0, 35, 36, 0, 37, 0,
+ 0, 0, 0, 0, 0, 502, 0, 0, 0, 44,
+ 0, 0, 0, 0, 0, 0, 0, 607, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 51, 503, 505,
+ 504, 0, 52, 0, 0, 0, 0, 226, 0, 0,
+ 0, 0, 0, 43, 54, 32, 210, 0, 0, 40,
+ 0, 0, 0, 0, 45, 0, 0, 0, 0, 0,
+ 0, 0, 0, 501, 0, 30, 31, 0, 0, 0,
+ 0, 0, 0, 0, 0, 215, 0, 0, 0, 0,
+ 0, 0, 34, 0, 0, 0, 35, 36, 0, 37,
+ 0, 0, 0, 0, 0, 0, 502, 0, 0, 0,
+ 44, 0, 0, 0, 0, 0, 0, 0, 610, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 51, 503,
+ 505, 504, 0, 52, 0, 0, 0, 0, 226, 0,
+ 0, 0, 0, 0, 43, 54, 32, 210, 0, 0,
+ 40, 0, 0, 0, 0, 45, 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, 46, 0, 47, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 51, 48,
+ 50, 49, 0, 52, 0, 53, 0, 55, 0, 56,
+ 0, 0, 0, 0, 43, 54, 32, 0, 0, 0,
+ 40, 0, 0, 0, 0, 45, 0, 0, 0, 0,
+ 0, 0, 0, 0, -119, 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, 46, 0,
+ 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 51, 48, 50, 49, 0, 52, 0, 53,
+ 0, 55, 0, 56, 0, 0, 0, 0, 43, 54,
+ 32, 0, 0, 0, 40, 0, 0, 0, 0, 45,
+ 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, 46, 0,
+ 47, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 51, 48, 50, 49, 0, 52, 0, 53,
+ 0, 55, 271, 56, 0, 0, 0, 0, 43, 54,
+ 32, 0, 0, 0, 40, 0, 0, 0, 0, 45,
+ 0, 0, 0, 0, 0, 0, 0, 0, 483, 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, 46, 0, 47, 0, 0, 484, 0, 0, 0,
+ 0, 0, 0, 0, 0, 51, 48, 50, 49, 0,
+ 52, 0, 53, 0, 55, 0, 56, 0, 0, 0,
+ 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 45, 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,
+ 217, 0, 0, 568, 569, 0, 37, 0, 0, 0,
+ 38, 0, 39, 41, 42, 0, 0, 44, 0, 0,
+ 0, 46, 0, 47, 0, 0, 0, 0, 0, 0,
+ 0, 221, 0, 0, 0, 51, 48, 50, 49, 0,
+ 52, 0, 53, 0, 55, 0, 56, 0, 0, 0,
+ 0, 43, 54, 32, 0, 0, 0, 40, 0, 0,
+ 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
+ 0, 483, 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, 46, 0, 47, 0, 0, 486,
+ 0, 0, 0, 0, 0, 0, 0, 0, 51, 48,
+ 50, 49, 0, 52, 0, 53, 0, 55, 0, 56,
+ 0, 0, 0, 0, 43, 54, 32, 0, 0, 0,
+ 40, 0, 0, 0, 0, 45, 0, 0, 0, 0,
+ 0, 0, 0, 0, 475, 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, 46, 0, 47,
+ 0, 0, 481, 0, 0, 0, 0, 0, 0, 0,
+ 0, 51, 48, 50, 49, 0, 52, 0, 53, 0,
+ 55, 0, 56, 0, 0, 0, 0, 43, 54, 32,
+ 0, 0, 0, 40, 0, 0, 0, 0, 45, 0,
+ 0, 0, 0, 0, 0, 0, 0, 475, 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,
+ 46, 0, 47, 0, 0, 476, 0, 0, 0, 0,
+ 0, 0, 0, 0, 51, 48, 50, 49, 0, 52,
+ 0, 53, 0, 55, 0, 56, 0, 0, 0, 0,
+ 43, 54, 32, 0, 0, 0, 40, 0, 0, 0,
+ 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
+ 109, 110, 111, 0, 0, 113, 115, 116, 0, 0,
+ 117, 0, 118, 0, 0, 0, 120, 121, 122, 0,
+ 0, 0, 0, 0, 0, 34, 123, 124, 125, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 126,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 129, 0, 0, 0, 0,
+ 0, 0, 48, 50, 49, 130, 131, 132, 0, 134,
+ 135, 136, 137, 138, 139, 0, 0, 127, 133, 119,
+ 112, 114, 128, 0, 0, 0, 0, 0, 45, 0,
+ 0, 0, 0, 0, 0, 0, 0, 109, 110, 111,
+ 0, 0, 113, 115, 116, 0, 0, 117, 0, 118,
+ 0, 0, 0, 120, 121, 122, 0, 0, 0, 0,
+ 0, 0, 393, 123, 124, 125, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 126, 0, 0, 0,
+ 394, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 129, 0, 0, 0, 0, 0, 398, 395,
+ 397, 0, 130, 131, 132, 0, 134, 135, 136, 137,
+ 138, 139, 0, 0, 127, 133, 119, 112, 114, 128,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 109, 110, 111, 0, 0, 113,
+ 115, 116, 0, 0, 117, 0, 118, 0, 0, 0,
+ 120, 121, 122, 0, 0, 0, 0, 0, 0, 393,
+ 123, 124, 125, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 126, 0, 0, 0, 394, 0, 0,
+ 0, 0, 0, 0, 0, 396, 0, 0, 0, 129,
+ 0, 0, 0, 0, 0, 398, 395, 397, 0, 130,
+ 131, 132, 0, 134, 135, 136, 137, 138, 139, 0,
+ 0, 127, 133, 119, 112, 114, 128, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 209, 0, 0, 0, 0, 211, 0, 29, 30,
+ 31, 213, 0, 0, 0, 0, 0, 0, 214, 33,
+ 0, 0, 0, 0, 0, 0, 216, 217, 0, 0,
+ 218, 36, 0, 37, 0, 0, 0, 38, 0, 39,
+ 41, 42, 0, 0, 44, 0, 0, 0, 46, 0,
+ 47, 0, 0, 0, 0, 0, 220, 0, 221, 0,
+ 0, 0, 51, 219, 222, 49, 223, 52, 224, 53,
+ 225, 55, 226, 56, 227, 228, 0, 0, 43, 54,
+ 32, 210, 212, 0, 40, 0, 0, 0, 0, 45,
+ 0, 0, 0, 0, 0, 0, 0, 0, 209, 0,
+ 0, 0, 0, 211, 0, 29, 30, 31, 213, 0,
+ 0, 0, 0, 0, 0, 214, 215, 0, 0, 0,
+ 0, 0, 0, 216, 217, 0, 0, 218, 36, 0,
+ 37, 0, 0, 0, 38, 0, 39, 41, 42, 0,
+ 0, 44, 0, 0, 0, 46, 0, 47, 0, 0,
+ 0, 0, 0, 220, 0, 221, 0, 0, 0, 51,
+ 219, 222, 49, 223, 52, 224, 53, 225, 55, 226,
+ 56, 227, 228, 0, 0, 43, 54, 32, 210, 212,
+ 0, 40, 0, 0, 0, 0, 45, 0, 0, 0,
+ 0, 0, 0, 0, 0, 571, 110, 111, 0, 0,
+ 573, 115, 575, 30, 31, 576, 0, 118, 0, 0,
+ 0, 120, 578, 579, 0, 0, 0, 0, 0, 0,
+ 580, 581, 124, 125, 218, 36, 0, 37, 0, 0,
+ 0, 38, 0, 39, 582, 42, 0, 0, 584, 0,
+ 0, 0, 46, 0, 47, 0, 0, 0, 0, 0,
+ 586, 0, 221, 0, 0, 0, 588, 585, 587, 49,
+ 589, 590, 591, 53, 593, 594, 595, 596, 597, 598,
+ 0, 0, 583, 592, 577, 572, 574, 128, 40, 0,
+ 0, 0, 0, 45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 361, 110, 111, 0, 0, 363, 115, 365,
+ 30, 31, 366, 0, 118, 0, 0, 0, 120, 368,
+ 369, 0, 0, 0, 0, 0, 0, 370, 371, 124,
+ 125, 218, 36, 0, 37, 0, 0, 0, 38, 0,
+ 39, 372, 42, 0, 0, 374, 0, 0, 0, 46,
+ 0, 47, 0, -265, 0, 0, 0, 376, 0, 221,
+ 0, 0, 0, 378, 375, 377, 49, 379, 380, 381,
+ 53, 383, 384, 385, 386, 387, 388, 0, 0, 373,
+ 382, 367, 362, 364, 128, 40, 0, 0, 0, 0,
+ 45, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 522, 540, 539, 519, 461, 515, 535, 514, 309, 528,
+ 311, 531, 250, 526, 542, 636, 613, 182, 150, 622,
+ 16, 496, 320, 497, 627, 253, 498, 633, 358, 554,
+ 436, 558, 487, 472, 439, 302, 238, 392, 454, 606,
+ 551, 402, 358, 553, 439, 243, 182, 445, 243, 447,
+ 456, 237, 238, 238, 347, 429, 349, 450, 351, 460,
+ 143, 458, 353, 467, 243, 436, 439, 176, 410, 186,
+ 188, 250, 415, 338, 182, 433, 148, 171, 169, 390,
+ 417, 400, 302, 140, 449, 163, 146, 425, 339, 302,
+ 358, 237, 336, 307, 250, 344, 482, 436, 302, 358,
+ 485, 358, 0, 0, 0, 461, 0, 0, 0, 0,
+ 0, 60, 60, 451, 452, 404, 0, 0, 60, 60,
+ 60, 452, 451, 320, 106, 60, 60, 60, 102, 60,
+ 92, 93, 95, 302, 94, 186, 0, 60, 0, 0,
+ 60, 88, 60, 405, 90, 60, 108, 180, 60, 266,
+ 146, 60, 146, 489, 270, 407, 165, 178, 60, 302,
+ 60, 0, 89, 330, 168, 288, 60, 60, 60, 60,
+ 0, 287, 286, 284, 285, 471, 60, 60, 432, 180,
+ 435, 60, 60, 452, 72, 60, 60, 451, 96, 60,
+ 480, 494, 77, 500, 479, 329, 60, 334, 305, 61,
+ 612, 60, 60, 69, 68, 60, 404, 60, 70, 67,
+ 60, 60, 490, 60, 60, 493, 84, 404, 60, 341,
+ 492, 60, 60, 180, 303, 60, 100, 60, 98, 491,
+ 91, 60, 0, 298, 405, 60, 106, 97, 270, 0,
+ 270, 500, 298, 500, 60, 405, 605, 270, 293, 270,
+ 602, 0, 0, 0, 0, 317, 499, 509, 108, 175,
+ 60, 316, 0, 60, 319, 270, 60, 290, 270, 298,
+ 289, 270, 0, 291, 270, 298, 60, 60, 0, 60,
+ 270, 270, 270, 500, 270, 0, 637, 295, 273, 298,
+ 602, 297, 313, 60, 270, 611, 0, 300, 270, 599,
+ 278, 302, 601, 500, 0, 567, 602, 0, 0, 0,
+ 0, 326, 570, 563, 564, 565, 566, 0, 499, 509,
+ 0, 472, 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, 332, 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, 608, 0, 0, 0, 0, 0,
+ 0, 0, 500, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 499, 509, 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 [] = {
+ 55, 7, 33, 7, 55, 7, 60, 36, 90, 55,
+ 7, 16, 36, 7, 7, 7, 7, 36, 7, 60,
+ 36, 8, 33, 66, 36, 33, 60, 36, 7, 36,
+ 7, 7, 33, 36, 24, 7, 7, 37, 8, 60,
+ 66, 29, 17, 5, 7, 60, 7, 33, 33, 33,
+ 7, 20, 33, 36, 7, 7, 36, 7, 36, 33,
+ 7, 17, 60, 36, 1, 33, 79, 2, 8, 7,
+ 36, 1, 8, 55, 7, 2, 8, 2, 7, 7,
+ 79, 36, 77, 79, 48, 36, 7, 36, 55, 48,
+ 36, 36, 33, 36, 8, 60, 1, 31, 0, 2,
+ 8, 61, 60, 1, 48, 6, 10, 61, 7, 8,
+ -1, 8, 8, 61, 8, -1, -1, 48, 40, 20,
+ 8, 60, 8, 42, -1, 40, -1, 50, 8, 51,
+ 8, 54, 8, 15, 53, 8, 51, 61, 62, 8,
+ 5, 61, 62, 61, 62, 61, 62, 40, 90, 61,
+ 62, 55, 34, 79, 61, 62, 40, 8, 51, 8,
+ 8, 61, 62, 60, 60, 50, 60, 51, 56, 54,
+ 56, 61, 62, 8, 61, 62, 56, 15, 61, 62,
+ 61, 62, 60, 56, 60, 15, 25, 8, 27, 29,
+ 7, 60, 25, 29, 27, 7, 34, 12, 36, 38,
+ 25, 25, 27, 27, 34, 38, 36, 12, 8, 12,
+ 61, 60, 60, 38, 38, 8, 25, 25, 27, 27,
+ -1, 33, 7, -1, -1, 29, 61, 62, 29, 38,
+ 38, -1, 29, 8, -1, 75, 15, 8, 36, 75,
+ 61, 62, 57, -1, 61, 62, 86, 29, 63, -1,
+ 86, 15, 57, -1, 57, 34, 18, 19, 63, -1,
+ 63, 61, 62, 61, 62, 61, 62, -1, 61, 62,
+ 34, 75, 36, 15, 75, -1, 61, 62, 75, 15,
+ 92, -1, 86, 45, 46, 86, 61, 62, 29, 86,
+ 61, 62, 34, 75, 36, 91, 47, 33, 34, 15,
+ 36, 18, 19, -1, 86, 18, 19, 29, -1, -1,
+ 61, 62, -1, -1, 18, 19, -1, 33, 34, 29,
+ 36, -1, 25, 29, 27, 66, 67, 68, 45, 46,
+ -1, -1, 45, 46, -1, 38, -1, -1, 23, 24,
+ 91, 45, 46, -1, 66, 67, 68, 32, -1, -1,
+ 35, 92, 37, 29, 23, 24, 66, 67, 68, -1,
+ 66, 67, 68, 32, 23, 24, 35, 29, 37, -1,
+ 92, 23, 24, 32, 36, -1, 35, -1, 37, -1,
+ 32, 29, 92, 35, -1, 37, 92, 23, 24, 29,
+ 66, 67, 68, -1, -1, 29, 32, -1, 29, 35,
+ -1, 37, 36, -1, 66, 67, 68, 93, 94, 95,
+ 96, 97, 98, 61, 62, -1, 92, 29, 66, 67,
+ 68, 61, 62, -1, -1, -1, 66, 67, 68, -1,
+ 92, -1, 66, 67, 68, 66, 67, 68, -1, -1,
+ -1, -1, -1, -1, 92, -1, -1, -1, -1, 61,
+ 62, -1, 92, 29, 66, 67, 68, -1, 92, -1,
+ -1, 92, 29, -1, -1, 29, -1, -1, -1, -1,
+ 23, 24, -1, -1, -1, -1, -1, -1, 31, 32,
+ 92, -1, 35, -1, 37, 61, 62, -1, -1, -1,
+ 66, 67, 68, -1, 61, 62, -1, 61, 62, 66,
+ 67, 68, 66, 67, 68, -1, -1, -1, -1, -1,
+ 12, 13, -1, -1, -1, -1, 92, -1, -1, -1,
+ 22, -1, -1, -1, -1, 92, -1, 29, 92, -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, -1, -1, -1, 81,
+ 82, 83, -1, -1, 39, 87, 41, 42, -1, -1,
+ 92, -1, -1, -1, 49, 12, 13, 52, 53, -1,
+ -1, -1, -1, 58, -1, 22, -1, -1, -1, 64,
+ -1, -1, 29, -1, -1, -1, 33, 34, -1, 36,
+ -1, -1, -1, -1, -1, 80, 43, -1, -1, -1,
+ 47, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 3, -1, 65, 66,
+ 67, 68, -1, 70, -1, -1, 13, -1, -1, -1,
+ 17, -1, -1, -1, 81, 82, 83, -1, -1, 26,
+ 87, 28, -1, -1, 31, 92, -1, -1, -1, -1,
+ -1, -1, 39, -1, 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, -1, 12, 13, -1, -1,
+ -1, -1, -1, 80, -1, -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, 92, 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, 92, 12, 13, -1, -1, -1,
+ -1, -1, -1, 12, 13, 22, -1, -1, -1, -1,
+ -1, -1, 29, 22, -1, -1, 33, 34, -1, 36,
+ 29, -1, -1, -1, 33, 34, 43, 36, -1, -1,
+ 47, -1, -1, -1, 43, -1, -1, -1, 47, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 65, 66,
+ 67, 68, -1, 70, -1, -1, 65, 66, 67, 68,
+ -1, 70, -1, -1, 81, 82, 83, -1, -1, -1,
+ 87, -1, 81, 82, 83, 92, -1, -1, 87, -1,
+ -1, -1, -1, 92, 12, 13, -1, -1, -1, -1,
+ -1, -1, 12, 13, 22, -1, -1, -1, -1, -1,
+ -1, 29, 22, -1, -1, 33, 34, -1, 36, 29,
+ -1, -1, -1, 33, 34, 43, 36, -1, -1, 47,
+ -1, -1, -1, 43, -1, -1, -1, 47, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,
+ 68, -1, 70, -1, -1, 65, 66, 67, 68, -1,
+ 70, -1, -1, 81, 82, 83, -1, -1, -1, 87,
+ -1, 81, 82, 83, 92, -1, -1, 87, -1, -1,
+ -1, -1, 92, -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, -1, -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, 92, -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, 92, -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, 92, -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, 92, -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, 92,
+ -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, 92,
+ -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, 92, -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, 92, -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, 92, -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, 92, -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, 92, -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, 92, -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, -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,
+ -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, 92,
+ -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, 92, -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, 92, -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,
+ 92, -1, -1, -1, -1, -1, -1, -1, -1,
+
+ 13, 15, 25, 3, 15, 15, 3, 25, 3, 15,
+ 2, 15, 2, 25, 3, 11, 19, 15, 67, 13,
+ 3, 104, 15, 4, 15, 3, 2, 15, 2, 15,
+ 3, 15, 3, 35, 21, 3, 15, 36, 3, 19,
+ 25, 2, 2, 25, 21, 15, 15, 98, 15, 15,
+ 2, 4, 15, 15, 2, 93, 3, 21, 2, 2,
+ 35, 3, 2, 35, 15, 3, 21, 3, 2, 15,
+ 15, 2, 2, 2, 15, 3, 35, 35, 35, 35,
+ 3, 35, 3, 3, 21, 35, 35, 96, 15, 3,
+ 2, 4, 3, 2, 2, 100, 35, 3, 3, 2,
+ 35, 2, -1, -1, -1, 15, -1, -1, -1, -1,
+ -1, 44, 44, 46, 46, 13, -1, -1, 44, 44,
+ 44, 46, 46, 15, 15, 44, 44, 44, 54, 44,
+ 49, 49, 49, 3, 49, 15, -1, 44, -1, -1,
+ 44, 48, 44, 41, 48, 44, 37, 46, 44, 44,
+ 35, 44, 35, 46, 49, 40, 58, 40, 44, 3,
+ 44, -1, 48, 68, 60, 49, 44, 44, 44, 44,
+ -1, 49, 49, 49, 49, 85, 44, 44, 81, 46,
+ 81, 44, 44, 46, 52, 44, 44, 46, 50, 44,
+ 31, 46, 50, 13, 35, 87, 44, 2, 68, 47,
+ 20, 44, 44, 46, 46, 44, 13, 44, 47, 46,
+ 44, 44, 46, 44, 44, 46, 49, 13, 44, 99,
+ 46, 44, 44, 46, 68, 44, 56, 44, 50, 46,
+ 49, 44, -1, 44, 41, 44, 15, 50, 49, -1,
+ 49, 13, 44, 13, 44, 41, 16, 49, 57, 49,
+ 20, -1, -1, -1, -1, 66, 28, 29, 37, 38,
+ 44, 61, -1, 44, 66, 49, 44, 51, 49, 44,
+ 51, 49, -1, 51, 49, 44, 44, 44, -1, 44,
+ 49, 49, 49, 13, 49, -1, 16, 55, 53, 44,
+ 20, 66, 59, 44, 49, 5, -1, 66, 49, 13,
+ 51, 3, 16, 13, -1, 13, 20, -1, -1, -1,
+ -1, 66, 20, 21, 22, 23, 24, -1, 28, 29,
+ -1, 35, -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, 68, -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, 5, -1, -1, -1, -1, -1,
+ -1, -1, 13, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 28, 29, -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 0000000000..2b2e3d109a
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
@@ -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$
+**
+****************************************************************************/
+
+//
+// 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 {
+ EOF_SYMBOL = 0,
+ REDUCE_HERE = 100,
+ SHIFT_THERE = 99,
+ 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 = 96,
+ T_FEED_JS_PROGRAM = 98,
+ T_FEED_JS_SOURCE_ELEMENT = 97,
+ T_FEED_JS_STATEMENT = 95,
+ T_FEED_UI_OBJECT_MEMBER = 94,
+ T_FEED_UI_PROGRAM = 93,
+ 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_ON = 92,
+ 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 = 639,
+ RULE_COUNT = 345,
+ STATE_COUNT = 640,
+ TERMINAL_COUNT = 101,
+ NON_TERMINAL_COUNT = 106,
+
+ GOTO_INDEX_OFFSET = 640,
+ GOTO_INFO_OFFSET = 2699,
+ GOTO_CHECK_OFFSET = 2699
+ };
+
+ 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 0000000000..34163a4c98
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -0,0 +1,1163 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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;
+ else if (c[0] == QLatin1Char('o') && c[1] == QLatin1Char('n'))
+ return QDeclarativeJSGrammar::T_ON;
+ } 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 0000000000..71bd08c5c0
--- /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 0000000000..c8d52d065d
--- /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 0000000000..94637fdfcd
--- /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 0000000000..fd9e690c33
--- /dev/null
+++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp
@@ -0,0 +1,1857 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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: {
+ AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
+ sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
+ node->colonToken = loc(2);
+ node->hasOnToken = true;
+ sym(1).Node = node;
+} break;
+case 34:case 35:case 36:case 37:
+{
+ AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(),
+ sym(1).UiQualifiedId, sym(3).Statement);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 38:
+
+case 39: {
+ sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
+ break;
+}
+
+case 41: {
+ sym(1).Node = 0;
+} break;
+
+case 42: {
+ sym(1).Node = sym(1).UiParameterList->finish ();
+} break;
+
+case 43: {
+ AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
+ node->identifierToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 44: {
+ 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 46: {
+ 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 48: {
+ 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 50: {
+ 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 52: {
+ 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 54: {
+ 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 56: {
+ 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 58: {
+ 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 60: {
+ 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 61: {
+ sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
+} break;
+
+case 62: {
+ sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
+} break;
+
+case 64: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_PROPERTY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 65: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_SIGNAL]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 66: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 67: {
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ sym(1).sval = driver->intern(s.constData(), s.length());
+ break;
+}
+
+case 68: {
+ AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool());
+ node->thisToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 69: {
+ AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 70: {
+ AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool());
+ node->nullToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 71: {
+ AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool());
+ node->trueToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 72: {
+ AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool());
+ node->falseToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 73: {
+ AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+case 74:
+case 75: {
+ AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
+ node->literalToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 76: {
+ 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 77: {
+ 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 78: {
+ 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 79: {
+ 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 80: {
+ 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 81: {
+ 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 82: {
+ 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 83: {
+ 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 84: {
+ 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 85: {
+ 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 86: {
+ 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 87: {
+ sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression);
+} break;
+
+case 88: {
+ sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression);
+} break;
+
+case 89: {
+ 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 90: {
+ 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 91: {
+ AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool());
+ node->commaToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 92: {
+ AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 93: {
+ AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
+ sym(1).PropertyName, sym(3).Expression);
+ node->colonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 94: {
+ 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 95: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+case 96:
+case 97: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 98: {
+ AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 99: {
+ AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 100: {
+ AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
+ node->propertyNameToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+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:
+
+case 130:
+
+case 131:
+{
+ sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
+} break;
+
+case 136: {
+ 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 137: {
+ 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 138: {
+ 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 140: {
+ AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression);
+ node->newToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 141: {
+ 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 142: {
+ 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 143: {
+ 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 144: {
+ 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 145: {
+ sym(1).Node = 0;
+} break;
+
+case 146: {
+ sym(1).Node = sym(1).ArgumentList->finish();
+} break;
+
+case 147: {
+ sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
+} break;
+
+case 148: {
+ AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 152: {
+ AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
+ node->incrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 153: {
+ AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
+ node->decrementToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 155: {
+ AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
+ node->deleteToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 156: {
+ AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
+ node->voidToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 157: {
+ AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
+ node->typeofToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 158: {
+ AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
+ node->incrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 159: {
+ AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
+ node->decrementToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 160: {
+ AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
+ node->plusToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 161: {
+ AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
+ node->minusToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 162: {
+ AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
+ node->tildeToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 163: {
+ AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression);
+ node->notToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 165: {
+ 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 166: {
+ 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 167: {
+ 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 169: {
+ 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 170: {
+ 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 172: {
+ 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 173: {
+ 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 174: {
+ 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 176: {
+ 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 177: {
+ 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 178: {
+ 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 179: {
+ 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 180: {
+ 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 181: {
+ 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 183: {
+ 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 184: {
+ 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 185: {
+ 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 186: {
+ 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 187: {
+ 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 189: {
+ 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 190: {
+ 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 191: {
+ 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 192: {
+ 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 194: {
+ 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 195: {
+ 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 196: {
+ 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 197: {
+ 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 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::BitAnd, 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::BitXor, 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::BitOr, 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::And, 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::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 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::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 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 225: {
+ 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 226: {
+ sym(1).ival = QSOperator::Assign;
+} break;
+
+case 227: {
+ sym(1).ival = QSOperator::InplaceMul;
+} break;
+
+case 228: {
+ sym(1).ival = QSOperator::InplaceDiv;
+} break;
+
+case 229: {
+ sym(1).ival = QSOperator::InplaceMod;
+} break;
+
+case 230: {
+ sym(1).ival = QSOperator::InplaceAdd;
+} break;
+
+case 231: {
+ sym(1).ival = QSOperator::InplaceSub;
+} break;
+
+case 232: {
+ sym(1).ival = QSOperator::InplaceLeftShift;
+} break;
+
+case 233: {
+ sym(1).ival = QSOperator::InplaceRightShift;
+} break;
+
+case 234: {
+ sym(1).ival = QSOperator::InplaceURightShift;
+} break;
+
+case 235: {
+ sym(1).ival = QSOperator::InplaceAnd;
+} break;
+
+case 236: {
+ sym(1).ival = QSOperator::InplaceXor;
+} break;
+
+case 237: {
+ sym(1).ival = QSOperator::InplaceOr;
+} break;
+
+case 239: {
+ AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 240: {
+ sym(1).Node = 0;
+} break;
+
+case 243: {
+ AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 244: {
+ sym(1).Node = 0;
+} break;
+
+case 261: {
+ 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 262: {
+ sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement);
+} break;
+
+case 263: {
+ sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
+} break;
+
+case 264: {
+ sym(1).Node = 0;
+} break;
+
+case 265: {
+ sym(1).Node = sym(1).StatementList->finish ();
+} break;
+
+case 267: {
+ 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 268: {
+ sym(1).ival = T_CONST;
+} break;
+
+case 269: {
+ sym(1).ival = T_VAR;
+} break;
+
+case 270: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
+} break;
+
+case 271: {
+ AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(),
+ sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+ node->commaToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 272: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
+} break;
+
+case 273: {
+ sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
+} break;
+
+case 274: {
+ AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 275: {
+ AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 276: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+
+case 277: {
+ sym(1).Node = 0;
+} break;
+
+case 279: {
+ // ### TODO: AST for initializer
+ sym(1) = sym(2);
+} break;
+
+case 280: {
+ sym(1).Node = 0;
+} break;
+
+case 282: {
+ AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool());
+ node->semicolonToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 284: {
+ AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 285: {
+ 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 286: {
+ 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 288: {
+ 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 289: {
+ 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 290: {
+ 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 291: {
+ 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 292: {
+ 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 293: {
+ 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 295: {
+ AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool());
+ node->continueToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 297: {
+ 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 299: {
+ AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool());
+ node->breakToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 301: {
+ 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 303: {
+ 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 304: {
+ 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 305: {
+ 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 306: {
+ 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 307: {
+ 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 308: {
+ sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
+} break;
+
+case 309: {
+ sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
+} break;
+
+case 310: {
+ sym(1).Node = 0;
+} break;
+
+case 311: {
+ sym(1).Node = sym(1).CaseClauses->finish ();
+} break;
+
+case 312: {
+ 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 313: {
+ 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 314:
+case 315: {
+ 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 316: {
+ 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 318: {
+ 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 319: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 320: {
+ AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
+ node->tryToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 321: {
+ 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 322: {
+ 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 323: {
+ AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block);
+ node->finallyToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 325: {
+ AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool());
+ node->debuggerToken = loc(1);
+ node->semicolonToken = loc(2);
+ sym(1).Node = node;
+} break;
+
+case 326: {
+ 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 327: {
+ 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 328: {
+ AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 329: {
+ 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 330: {
+ sym(1).Node = 0;
+} break;
+
+case 331: {
+ sym(1).Node = sym(1).FormalParameterList->finish ();
+} break;
+
+case 332: {
+ sym(1).Node = 0;
+} break;
+
+case 334: {
+ sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
+} break;
+
+case 335: {
+ sym(1).Node = makeAstNode<AST::Program> (driver->nodePool(), sym(1).SourceElements->finish ());
+} break;
+
+case 336: {
+ sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
+} break;
+
+case 337: {
+ sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
+} break;
+
+case 338: {
+ sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
+} break;
+
+case 339: {
+ sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
+} break;
+
+case 340: {
+ sym(1).sval = 0;
+} break;
+
+case 342: {
+ 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 0000000000..3864398992
--- /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 76
+
+#define J_SCRIPT_REGEXPLITERAL_RULE2 77
+
+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 90949d5710..0000000000
--- 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 d3ceba6657..0000000000
--- 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 9de733c07f..0000000000
--- 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 2c42fd9d89..0000000000
--- 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 bd7439cfee..0000000000
--- 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 9007a2c557..0000000000
--- 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 84bb1c562a..0000000000
--- 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 ebfeb1b3d8..0000000000
--- 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 44574506f8..0000000000
--- 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 12071dbe3f..0000000000
--- 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 21fddba9cc..0000000000
--- 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 816542ffbb..0000000000
--- 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 8f95a904f4..0000000000
--- 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 5dffdc8353..0000000000
--- 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 2055a7e13c..0000000000
--- 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 856d06ded3..0000000000
--- 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 42fb422bba..0000000000
--- 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 0000000000..77b7484792
--- /dev/null
+++ b/src/declarative/qml/qdeclarative.h
@@ -0,0 +1,312 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVE_H
+#define QDECLARATIVE_H
+
+#include "qdeclarativeprivate.h"
+#include "qdeclarativeparserstatus.h"
+#include "qdeclarativepropertyvaluesource.h"
+#include "qdeclarativepropertyvalueinterceptor.h"
+#include "qdeclarativelist.h"
+
+#include <QtCore/qbytearray.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)
+
+template<typename T>
+int qmlRegisterType()
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0,
+
+ 0, 0, 0, 0, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ QDeclarativePrivate::create<T>,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType()
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0,
+
+ 0, 0, 0, 0, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T, typename E>
+int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativeAttachedPropertiesFunc attached = QDeclarativePrivate::attachedPropertiesFunc<E>();
+ const QMetaObject * attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<E>();
+ if (!attached) {
+ attached = QDeclarativePrivate::attachedPropertiesFunc<T>();
+ attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject<T>();
+ }
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ QDeclarativePrivate::create<T>,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ attached,
+ attachedMetaObject,
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ QDeclarativePrivate::createParent<E>, &E::staticMetaObject,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+template<typename T>
+int qmlRegisterInterface(const char *typeName)
+{
+ QByteArray name(typeName);
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterInterface interface = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+
+ qobject_interface_iid<T *>()
+ };
+
+ return QDeclarativePrivate::registerType(interface);
+}
+
+template<typename T>
+int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName, const char *typeName, QDeclarativeCustomParser *parser)
+{
+ QByteArray name(typeName);
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ QDeclarativePrivate::create<T>,
+
+ uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ parser
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
+#define QML_REGISTER_INTERFACE(INTERFACE) \
+ qmlRegisterInterface<INTERFACE>(#INTERFACE)
+
+#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, CLASS, EXTENSION) \
+ qmlRegisterExtendedType<CLASS,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME)
+
+#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,NAME,CLASS) \
+ qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #NAME)
+
+#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
+ qmlRegisterType<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);
+Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create);
+
+template<typename T>
+QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
+{
+ static int idx = -1;
+ return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create);
+}
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QObject)
+Q_DECLARE_METATYPE(QVariant)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVE_H
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
new file mode 100644
index 0000000000..88ca5cd643
--- /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 QDeclarativeProperty &prop)
+{
+ Q_D(QDeclarativeBinding);
+ d->bindingData()->property = prop;
+
+ update();
+}
+
+QDeclarativeProperty QDeclarativeBinding::property() const
+{
+ Q_D(const QDeclarativeBinding);
+ return d->bindingData()->property;
+}
+
+void QDeclarativeBinding::update(QDeclarativePropertyPrivate::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.propertyType() == qMetaTypeId<QDeclarativeBinding *>()) {
+
+ int idx = data->property.index();
+ 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() &&
+ !QDeclarativePropertyPrivate::write(data->property, 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, QDeclarativePropertyPrivate::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.index();
+}
+
+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, QDeclarativePropertyPrivate::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 0000000000..f66b9c7d62
--- /dev/null
+++ b/src/declarative/qml/qdeclarativebinding_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 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 "qdeclarativeproperty.h"
+#include "qdeclarativeproperty_p.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, QDeclarativePropertyPrivate::DontRemoveBinding); }
+ virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags) = 0;
+ virtual int propertyIndex() = 0;
+
+ void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); }
+ virtual void update(QDeclarativePropertyPrivate::WriteFlags) = 0;
+
+ void addToObject(QObject *);
+ void removeFromObject();
+
+protected:
+ void clear();
+
+private:
+ friend class QDeclarativeDeclarativeData;
+ friend class QDeclarativeProperty;
+ friend class QDeclarativePropertyPrivate;
+ 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 QDeclarativeProperty &);
+ QDeclarativeProperty property() const;
+
+ bool enabled() const;
+
+ // Inherited from QDeclarativeAbstractBinding
+ virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags);
+ virtual int propertyIndex();
+ virtual void update(QDeclarativePropertyPrivate::WriteFlags flags);
+ virtual QString expression() const;
+
+public Q_SLOTS:
+ void update() { update(QDeclarativePropertyPrivate::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 0000000000..041103ccb7
--- /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 "qdeclarativeproperty.h"
+#include "qdeclarativeexpression_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeBindingData : public QDeclarativeExpressionData
+{
+public:
+ QDeclarativeBindingData();
+ virtual ~QDeclarativeBindingData();
+
+ bool updating:1;
+ bool enabled:1;
+
+ QDeclarativeProperty 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 0000000000..ce396fd356
--- /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_p.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 0000000000..bba4eece63
--- /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 0000000000..ae4975c486
--- /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 0000000000..9f4a3de2bd
--- /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 0000000000..0fa49d1dfc
--- /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 0000000000..e9b6b45aa2
--- /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 0000000000..17937fdede
--- /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, QDeclarativePropertyPrivate::WriteFlags flags);
+ virtual int propertyIndex();
+ virtual void update(QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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(QDeclarativePropertyPrivate::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,
+ QDeclarativePropertyPrivate::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 (QDeclarativePropertyPrivate::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 0000000000..2e24371aaa
--- /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 0000000000..bdf16a3d36
--- /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 0000000000..5da207d915
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -0,0 +1,2793 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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_p.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 "qdeclarativeproperty_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;
+}
+
+QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name)
+{
+ Q_ASSERT(mo);
+ 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 method;
+ }
+
+ // If no signal is found, but the signal is of the form "onBlahChanged",
+ // return the notify signal for the property "Blah"
+ if (name.endsWith("Changed")) {
+ QByteArray propName = name.mid(0, name.length() - 7);
+ int propIdx = mo->indexOfProperty(propName.constData());
+ if (propIdx >= 0) {
+ QMetaProperty prop = mo->property(propIdx);
+ if (prop.hasNotifySignal())
+ return prop.notifySignal();
+ }
+ }
+
+ return QMetaMethod();
+}
+
+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).methodIndex();
+
+ 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 |= (QDeclarativePropertyPrivate::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 =
+ QDeclarativePropertyPrivate::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(QDeclarativePropertyPrivate::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 (QDeclarativePropertyPrivate::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 (QDeclarativePropertyPrivate::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 0000000000..2ea3366961
--- /dev/null
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -0,0 +1,338 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 &);
+
+ static QMetaMethod findSignalByName(const QMetaObject *, const QByteArray &name);
+
+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 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 0000000000..fe63ad2169
--- /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, QDeclarativePropertyPrivate::BypassInterceptor |
+ QDeclarativePropertyPrivate::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 0000000000..aec0480433
--- /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 0000000000..3155813fae
--- /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 0000000000..fb26af9f85
--- /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 0000000000..b90a598b4e
--- /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 0000000000..03d16b89d2
--- /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 0000000000..b244cd880d
--- /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 0000000000..0fb9bee2a5
--- /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 0000000000..829728073f
--- /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 0000000000..7deed0b9e0
--- /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 0000000000..26086ecdbf
--- /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 0000000000..67f096325a
--- /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 0000000000..99587a8f7e
--- /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_p.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 0000000000..b580db6af0
--- /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 0000000000..2c92419cc7
--- /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 0000000000..e730b920a6
--- /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 0000000000..5df711700e
--- /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 0000000000..6c81f3441b
--- /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 0000000000..6043eaddab
--- /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 0000000000..a065282e36
--- /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 0000000000..af75e98fe9
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -0,0 +1,1938 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "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 "qdeclarativetypenamecache_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(QDeclarativeProperty)
+
+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);
+
+ // 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);
+Q_GLOBAL_STATIC(QSet<QString>, qmlEnginePluginsWithRegisteredTypes);
+
+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;
+}
+
+QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
+ const QMetaObject *attachedMetaObject, bool create)
+{
+ if (*idCache == -1)
+ *idCache = QDeclarativeMetaType::attachedPropertiesFuncId(attachedMetaObject);
+
+ if (*idCache == -1 || !object)
+ return 0;
+
+ return qmlAttachedPropertiesObjectById(*idCache, object, create);
+}
+
+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;
+ QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+ if (!builtinPath.isEmpty())
+ paths += builtinPath;
+
+ 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(QDir(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;
+}
+
+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/imports and then load QML
+ that imports \c com.mycompany.Feature, then QDeclarativeEngine will look
+ in \c /opt/MyApp/lib/imports/com/mycompany/Feature/ for the components
+ provided by that module. A \c qmldir file is required for definiting the
+ type version mapping and possibly declarative extensions plugins.
+
+ The engine searches in the base directory of the qml file, then
+ the paths added via addImportPath(), then the paths specified in the
+ \c QML_IMPORT_PATH environment variable, then the builtin \c ImportsPath from
+ QLibraryInfo.
+
+*/
+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)
+{
+ QFileInfo fileInfo(fileName);
+ const QString absoluteFilePath = fileInfo.absoluteFilePath();
+ QPluginLoader loader(absoluteFilePath);
+
+ if (QDeclarativeExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(loader.instance())) {
+ const QByteArray bytes = uri.toUtf8();
+ const char *moduleId = bytes.constData();
+
+ // ### this code should probably be protected with a mutex.
+ if (! qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath)) {
+ // types should only be registered once (they're global).
+
+ qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath);
+ iface->registerTypes(moduleId);
+ }
+
+ QDeclarativeEnginePrivate *d = QDeclarativeEnginePrivate::get(this);
+
+ if (! d->initializedPlugins.contains(absoluteFilePath)) {
+ // things on the engine (eg. adding new global objects) have to be done for every engine.
+
+ // protect against double initialization
+ d->initializedPlugins.insert(absoluteFilePath);
+ iface->initializeEngine(this, moduleId);
+ }
+
+ 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 0000000000..fd6635854d
--- /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 0000000000..0359f98b58
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -0,0 +1,342 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeproperty_p.h"
+#include "qdeclarativepropertycache_p.h"
+#include "qdeclarativeobjectscriptclass_p.h"
+#include "qdeclarativecontextscriptclass_p.h"
+#include "qdeclarativevaluetypescriptclass_p.h"
+#include "qdeclarativemetatype_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;
+ QSet<QString> initializedPlugins;
+
+ 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 0000000000..09882cbddc
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -0,0 +1,458 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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_p.h"
+#include "qdeclarativeproperty.h"
+#include "qdeclarativeproperty_p.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 =
+ QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name));
+ 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 0000000000..89da399aaf
--- /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 0000000000..7e8aac0de6
--- /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 0000000000..04d5ff2bff
--- /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 0000000000..ae1e7905d0
--- /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 0000000000..911d328371
--- /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 0000000000..91ac4c07da
--- /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 0000000000..0fabd6de89
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeextensioninterface.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 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 registerTypes(const char *uri) = 0;
+ virtual void initializeEngine(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 0000000000..3d44d63384
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp
@@ -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$
+**
+****************************************************************************/
+
+#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::registerTypes(const char *uri)
+
+ Registers the QML types in the given \a uri.
+*/
+
+/*!
+ 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()
+{
+}
+
+/*!
+ \fn void QDeclarativeExtensionPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
+
+ Initializes the extension specified in the given \a engine.
+*/
+
+void QDeclarativeExtensionPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(uri);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.h b/src/declarative/qml/qdeclarativeextensionplugin.h
new file mode 100644
index 0000000000..c2ad79867c
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeextensionplugin.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 registerTypes(const char *uri) = 0;
+ virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri);
+};
+
+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 0000000000..bbdc91c8cb
--- /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 0000000000..5b06b42a2b
--- /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 0000000000..a33cf5e9a8
--- /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 0000000000..0861e9a5f1
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeguard_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 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>
+#include <QtCore/qvariant.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 0000000000..daa2e87b1d
--- /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 0000000000..6ee7bcf368
--- /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 0000000000..7dc61fd8d5
--- /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_p.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 0000000000..8f69f73686
--- /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 0000000000..cf485fe00c
--- /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 0000000000..d8af6a7155
--- /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 0000000000..8fa210f5a9
--- /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_p.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 0000000000..b57565e58e
--- /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 0000000000..9691f322a6
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -0,0 +1,409 @@
+/****************************************************************************
+**
+** 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 "qdeclarativeproperty_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;
+}
+
+/*!
+\class QDeclarativeListReference
+\brief The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties.
+
+QDeclarativeListReference allows programs to read from, and assign values to a QML list property in a
+simple and type safe way. A QDeclarativeListReference can be created by passing an object and property
+name or through a QDeclarativeProperty instance. These two are equivalant:
+
+\code
+QDeclarativeListReference ref1(object, "children");
+
+QDeclarativeProperty ref2(object, "children");
+QDeclarativeListReference ref2 = qvariant_cast<QDeclarativeListReference>(ref2.read());
+\endcode
+
+Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and
+canCount() allow programs to query whether an operation is supported on a given property.
+
+QML list properties are typesafe. Only QObject's that derive from the correct base class can be assigned to
+the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported.
+Attempting to add objects of the incorrect type to a list property will fail.
+
+Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure
+that it does not request an out of range element using the count() method before calling at().
+*/
+
+/*!
+Constructs an invalid instance.
+*/
+QDeclarativeListReference::QDeclarativeListReference()
+: d(0)
+{
+}
+
+/*!
+Constructs a QDeclarativeListReference for \a object's \a property. If \a property is not a list
+property, an invalid QDeclarativeListReference is created. If \a object is destroyed after
+the reference is constructed, it will automatically become invalid. That is, it is safe to hold
+QDeclarativeListReference instances even after \a object is deleted.
+
+Passing \a engine is required to access some QML created list properties. If in doubt, and an engine
+is available, pass it.
+*/
+QDeclarativeListReference::QDeclarativeListReference(QObject *object, const char *property, QDeclarativeEngine *engine)
+: d(0)
+{
+ if (!object || !property) return;
+
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *data =
+ QDeclarativePropertyCache::property(engine, object, 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 = object;
+ d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject();
+ d->propertyType = data->propType;
+
+ void *args[] = { &d->property, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex, args);
+}
+
+/*! \internal */
+QDeclarativeListReference::QDeclarativeListReference(const QDeclarativeListReference &o)
+: d(o.d)
+{
+ if (d) d->addref();
+}
+
+/*! \internal */
+QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarativeListReference &o)
+{
+ if (o.d) o.d->addref();
+ if (d) d->release();
+ d = o.d;
+ return *this;
+}
+
+/*! \internal */
+QDeclarativeListReference::~QDeclarativeListReference()
+{
+ if (d) d->release();
+}
+
+/*!
+Returns true if the instance refers to a valid list property, otherwise false.
+*/
+bool QDeclarativeListReference::isValid() const
+{
+ return d && d->object;
+}
+
+/*!
+Returns the list property's object. Returns 0 if the reference is invalid.
+*/
+QObject *QDeclarativeListReference::object() const
+{
+ if (isValid()) return d->object;
+ else return 0;
+}
+
+/*!
+Returns the QMetaObject for the elements stored in the list property. Returns 0 if the reference
+is invalid.
+
+The QMetaObject can be used ahead of time to determine whether a given instance can be added
+to a list.
+*/
+const QMetaObject *QDeclarativeListReference::listElementType() const
+{
+ if (isValid()) return d->elementType;
+ else return 0;
+}
+
+/*!
+Returns true if the list property can be appended to, otherwise false. Returns false if the
+reference is invalid.
+
+\sa append()
+*/
+bool QDeclarativeListReference::canAppend() const
+{
+ return (isValid() && d->property.append);
+}
+
+/*!
+Returns true if the list property can queried by index, otherwise false. Returns false if the
+reference is invalid.
+
+\sa at()
+*/
+bool QDeclarativeListReference::canAt() const
+{
+ return (isValid() && d->property.at);
+}
+
+/*!
+Returns true if the list property can be cleared, otherwise false. Returns false if the
+reference is invalid.
+
+\sa clear()
+*/
+bool QDeclarativeListReference::canClear() const
+{
+ return (isValid() && d->property.clear);
+}
+
+/*!
+Returns true if the list property can be queried for its element count, otherwise false.
+Returns false if the reference is invalid.
+
+\sa count()
+*/
+bool QDeclarativeListReference::canCount() const
+{
+ return (isValid() && d->property.count);
+}
+
+/*!
+Appends \a object to the list. Returns true if the operation succeeded, otherwise false.
+
+\sa canAppend()
+*/
+bool QDeclarativeListReference::append(QObject *object) const
+{
+ if (!canAppend()) return false;
+
+ if (object && !QDeclarativePropertyPrivate::canConvert(object->metaObject(), d->elementType))
+ return false;
+
+ d->property.append(&d->property, object);
+
+ return true;
+}
+
+/*!
+Returns the list element at \a index, or 0 if the operation failed.
+
+\sa canAt()
+*/
+QObject *QDeclarativeListReference::at(int index) const
+{
+ if (!canAt()) return 0;
+
+ return d->property.at(&d->property, index);
+}
+
+/*!
+Clears the list. Returns true if the operation succeeded, otherwise false.
+
+\sa canClear()
+*/
+bool QDeclarativeListReference::clear() const
+{
+ if (!canClear()) return false;
+
+ d->property.clear(&d->property);
+
+ return true;
+}
+
+/*!
+Returns the number of objects in the list, or 0 if the operation failed.
+*/
+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 0000000000..8d59384a64
--- /dev/null
+++ b/src/declarative/qml/qdeclarativelist.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 QDECLARATIVELIST_H
+#define QDECLARATIVELIST_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QObject;
+class QMetaObject;
+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 0000000000..45a805a838
--- /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 0000000000..ea04ad96ce
--- /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 0000000000..68c680d435
--- /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/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
new file mode 100644
index 0000000000..abbb9d6225
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -0,0 +1,1140 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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_p.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;
+ QObject *(*m_extFunc)(QObject *);
+ 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 index, const QDeclarativePrivate::RegisterInterface &interface)
+: d(new QDeclarativeTypePrivate)
+{
+ d->m_isInterface = true;
+ d->m_iid = interface.iid;
+ d->m_typeId = interface.typeId;
+ d->m_listId = interface.listId;
+ 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 index, const QDeclarativePrivate::RegisterType &type)
+: d(new QDeclarativeTypePrivate)
+{
+ QByteArray name = type.uri;
+ if (type.uri) name += '/';
+ name += type.elementName;
+
+ d->m_name = name;
+ d->m_version_maj = type.versionMajor;
+ d->m_version_min = type.versionMinor;
+ d->m_typeId = type.typeId;
+ d->m_listId = type.listId;
+ d->m_newFunc = type.create;
+ d->m_baseMetaObject = type.metaObject;
+ d->m_attachedPropertiesFunc = type.attachedPropertiesFunction;
+ d->m_attachedPropertiesType = type.attachedPropertiesMetaObject;
+ d->m_parserStatusCast = type.parserStatusCast;
+ d->m_propertyValueSourceCast = type.valueSourceCast;
+ d->m_propertyValueInterceptorCast = type.valueInterceptorCast;
+ d->m_extFunc = type.extensionObjectCreate;
+ d->m_index = index;
+ d->m_customParser = type.customParser;
+
+ if (type.extensionMetaObject)
+ d->m_extMetaObject = type.extensionMetaObject;
+}
+
+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 QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface)
+{
+ if (interface.version > 0) {
+ qWarning("Cannot mix incompatible QML versions.");
+ return -1;
+ }
+
+ QWriteLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+
+ int index = data->types.count();
+
+ QDeclarativeType *type = new QDeclarativeType(index, interface);
+
+ 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() <= interface.typeId)
+ data->interfaces.resize(interface.typeId + 16);
+ if (data->lists.size() <= interface.listId)
+ data->lists.resize(interface.listId + 16);
+ data->interfaces.setBit(interface.typeId, true);
+ data->lists.setBit(interface.listId, true);
+
+ return index;
+}
+
+int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &type)
+{
+ if (type.elementName) {
+ for (int ii = 0; type.elementName[ii]; ++ii) {
+ if (!isalnum(type.elementName[ii])) {
+ qWarning("QDeclarativeMetaType: Invalid QML element name %s", type.elementName);
+ return -1;
+ }
+ }
+ }
+
+ QWriteLocker lock(metaTypeDataLock());
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ int index = data->types.count();
+
+ QDeclarativeType *dtype = new QDeclarativeType(index, type);
+
+ data->types.append(dtype);
+ data->idToType.insert(dtype->typeId(), dtype);
+ data->idToType.insert(dtype->qListTypeId(), dtype);
+
+ if (!dtype->qmlTypeName().isEmpty())
+ data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
+
+ data->metaObjectToType.insert(dtype->baseMetaObject(), dtype);
+
+ if (data->objects.size() <= type.typeId)
+ data->objects.resize(type.typeId + 16);
+ if (data->lists.size() <= type.listId)
+ data->lists.resize(type.listId + 16);
+ data->objects.setBit(type.typeId, true);
+ data->lists.setBit(type.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 QDeclarativePropertyPrivate::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_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
new file mode 100644
index 0000000000..ec5c045305
--- /dev/null
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEMETATYPE_P_H
+#define QDECLARATIVEMETATYPE_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/qglobal.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qbitarray.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeType;
+class QDeclarativeCustomParser;
+class Q_DECLARATIVE_EXPORT QDeclarativeMetaType
+{
+public:
+ 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 QDeclarativeTypePrivate;
+ friend class QDeclarativeMetaTypeData;
+ friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &);
+ friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &);
+ QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
+ QDeclarativeType(int, const QDeclarativePrivate::RegisterType &);
+ ~QDeclarativeType();
+
+ QDeclarativeTypePrivate *d;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEMETATYPE_P_H
+
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
new file mode 100644
index 0000000000..9dd7d3974a
--- /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 0000000000..8c76013f92
--- /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 0000000000..542f4170c0
--- /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 = QDeclarativePropertyPrivate::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);
+ QDeclarativePropertyPrivate::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 0000000000..8023756cdf
--- /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 0000000000..5ac49d5314
--- /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 0000000000..aae507e0ca
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -0,0 +1,359 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.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 0000000000..ec6260e3c0
--- /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 0000000000..34528c11af
--- /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.h b/src/declarative/qml/qdeclarativeprivate.h
new file mode 100644
index 0000000000..01369d423d
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeprivate.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 QDECLARATIVEPRIVATE_H
+#define QDECLARATIVEPRIVATE_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
+#ifndef Q_OS_WIN
+#include <stdint.h>
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+typedef QObject *(*QDeclarativeAttachedPropertiesFunc)(QObject *);
+
+template <typename TYPE>
+class QDeclarativeTypeInfo
+{
+public:
+ enum {
+ hasAttachedProperties = 0
+ };
+};
+
+
+class QDeclarativeCustomParser;
+namespace QDeclarativePrivate
+{
+ template<typename T>
+ QObject *create() { return new T; }
+
+ template<typename T>
+ QObject *createParent(QObject *p) { return new T(p); }
+
+ 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 RegisterType {
+ int version;
+
+ int typeId;
+ int listId;
+ QObject *(*create)();
+
+ const char *uri;
+ int versionMajor;
+ int versionMinor;
+ const char *elementName;
+ const QMetaObject *metaObject;
+
+ QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction;
+ const QMetaObject *attachedPropertiesMetaObject;
+
+ int parserStatusCast;
+ int valueSourceCast;
+ int valueInterceptorCast;
+
+ QObject *(*extensionObjectCreate)(QObject *);
+ const QMetaObject *extensionMetaObject;
+
+ QDeclarativeCustomParser *customParser;
+ };
+
+ struct RegisterInterface {
+ int version;
+
+ int typeId;
+ int listId;
+
+ const char *iid;
+ };
+
+ int Q_DECLARATIVE_EXPORT registerType(const RegisterType &);
+ int Q_DECLARATIVE_EXPORT registerType(const RegisterInterface &);
+
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPRIVATE_H
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
new file mode 100644
index 0000000000..e1ec2cde2e
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -0,0 +1,1306 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeproperty.h"
+#include "qdeclarativeproperty_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 "qdeclarativecompiler_p.h"
+
+#include <QStringList>
+#include <QtCore/qdebug.h>
+
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\class QDeclarativeProperty
+\brief The QDeclarativeProperty class abstracts accessing properties on objects created from QML.
+
+As QML uses Qt's meta-type system all of the existing QMetaObject classes can be used to introspect
+and interact with objects created by QML. However, some of the new features provided by QML - such
+as type safety and attached properties - are most easily used through the QDeclarativeProperty class
+that simplifies some of their natural complexity.
+
+Unlike QMetaProperty which represents a property on a class type, QDeclarativeProperty encapsulates
+a property on a specific object instance. To read a property's value, programmers create a
+QDeclarativeProperty instance and call the read() method. Likewise to write a property value the
+write() method is used.
+
+\code
+
+QObject *object = declarativeComponent.create();
+
+QDeclarativeProperty property(object, "font.pixelSize");
+qWarning() << "Current pixel size:" << property.read().toInt();
+property.write(24);
+qWarning() << "Pixel size should now be 24:" << property.read().toInt();
+
+\endcode
+*/
+
+/*!
+ Create an invalid QDeclarativeProperty.
+*/
+QDeclarativeProperty::QDeclarativeProperty()
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+}
+
+/*! \internal */
+QDeclarativeProperty::~QDeclarativeProperty()
+{
+ delete d; d = 0;
+}
+
+/*!
+ Creates a QDeclarativeProperty for the default property of \a obj. If there is no
+ default property, an invalid QDeclarativeProperty will be created.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->initDefault(obj);
+}
+
+/*!
+ Creates a QDeclarativeProperty for the default property of \a obj. If there is no
+ default property, an invalid QDeclarativeProperty will be created.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeContext *ctxt)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->context = ctxt;
+ d->engine = ctxt?ctxt->engine():0;
+ d->initDefault(obj);
+}
+
+/*!
+ Creates a QDeclarativeProperty for the default property of \a obj. If there is no
+ default property, an invalid QDeclarativeProperty will be created.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeEngine *engine)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->context = 0;
+ d->engine = engine;
+ d->initDefault(obj);
+}
+
+/*!
+ Initialize from the default property of \a obj
+*/
+void QDeclarativePropertyPrivate::initDefault(QObject *obj)
+{
+ if (!obj)
+ return;
+
+ QMetaProperty p = QDeclarativeMetaType::defaultProperty(obj);
+ core.load(p);
+ if (core.isValid())
+ object = obj;
+}
+
+/*!
+ Creates a QDeclarativeProperty for the property \a name of \a obj.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->initProperty(obj, name);
+ if (!isValid()) d->object = 0;
+}
+
+/*!
+ Creates a QDeclarativeProperty for the property \a name of \a obj.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->context = ctxt;
+ d->engine = ctxt?ctxt->engine():0;
+ d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
+}
+
+/*!
+ Creates a QDeclarativeProperty for the property \a name of \a obj.
+ */
+QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeEngine *engine)
+: d(new QDeclarativePropertyPrivate)
+{
+ d->q = this;
+ d->context = 0;
+ d->engine = engine;
+ d->initProperty(obj, name);
+ if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
+}
+
+Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
+
+void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name)
+{
+ if (!obj) return;
+
+ QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
+
+ QStringList path = name.split(QLatin1Char('.'));
+ if (path.isEmpty()) return;
+
+ QObject *currentObject = obj;
+
+ // Everything up to the last property must be an "object type" property
+ for (int ii = 0; ii < path.count() - 1; ++ii) {
+ const QString &pathName = path.at(ii);
+
+ if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
+ if (data->type) {
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(data->type->index(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ } else {
+ Q_ASSERT(data->typeNamespace);
+ if ((ii + 1) == path.count()) return; // No type following the namespace
+
+ ++ii; data = data->typeNamespace->data(path.at(ii));
+ if (!data || !data->type) return; // Invalid type in namespace
+
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(data->type->index(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ }
+ } else {
+
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property =
+ QDeclarativePropertyCache::property(engine, obj, pathName, local);
+
+ if (!property) return; // Not a property
+ if (property->flags & QDeclarativePropertyCache::Data::IsFunction)
+ return; // Not an object property
+
+ if (ii == (path.count() - 2) && property->propType < (int)QVariant::UserType) {
+ // 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[property->propType];
+ if (!typeObject) return; // Not a value type
+
+ int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
+ if (idx == -1) return; // Value type property does not exist
+
+ QMetaProperty vtProp = typeObject->metaObject()->property(idx);
+
+ object = currentObject;
+ core = *property;
+ valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(vtProp);
+ valueType.valueTypeCoreIdx = idx;
+ valueType.valueTypePropType = vtProp.userType();
+
+ return;
+ } else {
+ if (!(property->flags & QDeclarativePropertyCache::Data::IsQObjectDerived))
+ return; // Not an object property
+
+ void *args[] = { &currentObject, 0 };
+ QMetaObject::metacall(currentObject, QMetaObject::ReadProperty, property->coreIndex, args);
+ if (!currentObject) return; // No value
+
+ }
+ }
+
+ }
+
+ const QString &terminal = path.last();
+
+ if (terminal.count() >= 3 &&
+ terminal.at(0) == QLatin1Char('o') &&
+ terminal.at(1) == QLatin1Char('n') &&
+ terminal.at(2).isUpper()) {
+
+ QString signalName = terminal.mid(2);
+ signalName[0] = signalName.at(0).toLower();
+
+ QMetaMethod method = QDeclarativeCompiler::findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
+ if (method.signature()) {
+ object = currentObject;
+ core.load(method);
+ return;
+ }
+ }
+
+ // Property
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property =
+ QDeclarativePropertyCache::property(engine, currentObject, terminal, local);
+ if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction)) {
+ object = currentObject;
+ core = *property;
+ }
+}
+
+/*!
+ Create a copy of \a other.
+*/
+QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other)
+: d(new QDeclarativePropertyPrivate(*other.d))
+{
+ d->q = this;
+}
+
+/*!
+ \enum QDeclarativeProperty::PropertyTypeCategory
+
+ This enum specifies a category of QML property.
+
+ \value InvalidCategory The property is invalid, or is a signal property.
+ \value List The property is a QDeclarativeListProperty list property
+ \value Object The property is a QObject derived type pointer
+ \value Normal The property is a normal value property.
+ */
+
+/*!
+ \enum QDeclarativeProperty::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.
+*/
+
+/*!
+ Returns the property category.
+*/
+QDeclarativeProperty::PropertyTypeCategory QDeclarativeProperty::propertyTypeCategory() const
+{
+ return d->propertyTypeCategory();
+}
+
+QDeclarativeProperty::PropertyTypeCategory
+QDeclarativePropertyPrivate::propertyTypeCategory() const
+{
+ uint type = q->type();
+
+ if (isValueType()) {
+ return QDeclarativeProperty::Normal;
+ } else if (type & QDeclarativeProperty::Property) {
+ int type = propertyType();
+ if (type == QVariant::Invalid)
+ return QDeclarativeProperty::InvalidCategory;
+ else if ((uint)type < QVariant::UserType)
+ return QDeclarativeProperty::Normal;
+ else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived)
+ return QDeclarativeProperty::Object;
+ else if (core.flags & QDeclarativePropertyCache::Data::IsQList)
+ return QDeclarativeProperty::List;
+ else
+ return QDeclarativeProperty::Normal;
+ } else {
+ return QDeclarativeProperty::InvalidCategory;
+ }
+}
+
+/*!
+ Returns the type name of the property, or 0 if the property has no type
+ name.
+*/
+const char *QDeclarativeProperty::propertyTypeName() const
+{
+ if (d->isValueType()) {
+
+ 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 QDeclarativeProperty represent the same
+ property.
+*/
+bool QDeclarativeProperty::operator==(const QDeclarativeProperty &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;
+}
+
+/*!
+ Returns the QVariant type of the property, or QVariant::Invalid if the
+ property has no QVariant type.
+*/
+int QDeclarativeProperty::propertyType() const
+{
+ return d->propertyType();
+}
+
+bool QDeclarativePropertyPrivate::isValueType() const
+{
+ return valueType.valueTypeCoreIdx != -1;
+}
+
+int QDeclarativePropertyPrivate::propertyType() const
+{
+ uint type = q->type();
+ if (isValueType()) {
+ return valueType.valueTypePropType;
+ } else if (type & QDeclarativeProperty::Property) {
+ if (core.propType == (int)QVariant::LastType)
+ return qMetaTypeId<QVariant>();
+ else
+ return core.propType;
+ } else {
+ return QVariant::Invalid;
+ }
+}
+
+/*!
+ Returns the type of the property.
+*/
+QDeclarativeProperty::Type QDeclarativeProperty::type() const
+{
+ if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction)
+ return SignalProperty;
+ else if (d->core.isValid())
+ return Property;
+ else
+ return Invalid;
+}
+
+/*!
+ Returns true if this QDeclarativeProperty represents a regular Qt property.
+*/
+bool QDeclarativeProperty::isProperty() const
+{
+ return type() & Property;
+}
+
+/*!
+ Returns true if this QDeclarativeProperty represents a QML signal property.
+*/
+bool QDeclarativeProperty::isSignalProperty() const
+{
+ return type() & SignalProperty;
+}
+
+/*!
+ Returns the QDeclarativeProperty's QObject.
+*/
+QObject *QDeclarativeProperty::object() const
+{
+ return d->object;
+}
+
+/*!
+ Assign \a other to this QDeclarativeProperty.
+*/
+QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty &other)
+{
+ d->context = other.d->context;
+ d->engine = other.d->engine;
+ d->object = other.d->object;
+
+ d->isNameCached = other.d->isNameCached;
+ d->core = other.d->core;
+ d->nameCache = other.d->nameCache;
+
+ d->valueType = other.d->valueType;
+
+ return *this;
+}
+
+/*!
+ Returns true if the property is writable, otherwise false.
+*/
+bool QDeclarativeProperty::isWritable() const
+{
+ QDeclarativeProperty::PropertyTypeCategory category = propertyTypeCategory();
+
+ 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 QDeclarativeProperty::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 QDeclarativeProperty::isResettable() const
+{
+ if (type() & Property && d->core.isValid() && d->object)
+ return d->core.flags & QDeclarativePropertyCache::Data::IsResettable;
+ else
+ return false;
+}
+
+/*!
+ Returns true if the QDeclarativeProperty refers to a valid property, otherwise
+ false.
+*/
+bool QDeclarativeProperty::isValid() const
+{
+ return type() != Invalid;
+}
+
+/*!
+ Return the name of this QML property.
+*/
+QString QDeclarativeProperty::name() const
+{
+ if (!d->isNameCached) {
+ // ###
+ if (!d->object) {
+ } else if (d->isValueType()) {
+ QString rv = d->core.name(d->object) + QLatin1Char('.');
+
+ QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->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 QDeclarativeProperty::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 QDeclarativeProperty::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 *
+QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that)
+{
+ if (!that.isProperty() || !that.d->object)
+ return 0;
+
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(that.d->object);
+ if (!data)
+ return 0;
+
+ if (!data->hasBindingBit(that.d->core.coreIndex))
+ return 0;
+
+ QDeclarativeAbstractBinding *binding = data->bindings;
+ while (binding) {
+ // ### This wont work for value types
+ if (binding->propertyIndex() == that.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 *
+QDeclarativePropertyPrivate::setBinding(const QDeclarativeProperty &that,
+ QDeclarativeAbstractBinding *newBinding,
+ WriteFlags flags)
+{
+ if (!that.isProperty() || !that.d->object) {
+ if (newBinding)
+ newBinding->destroy();
+ return 0;
+ }
+
+ return that.d->setBinding(that.d->object, that.d->core, newBinding, flags);
+}
+
+QDeclarativeAbstractBinding *
+QDeclarativePropertyPrivate::setBinding(QObject *object, const QDeclarativePropertyCache::Data &core,
+ QDeclarativeAbstractBinding *newBinding, 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 *
+QDeclarativePropertyPrivate::signalExpression(const QDeclarativeProperty &that)
+{
+ if (!(that.type() & QDeclarativeProperty::SignalProperty))
+ return 0;
+
+ const QObjectList &children = that.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() == that.index())
+ 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 *
+QDeclarativePropertyPrivate::setSignalExpression(const QDeclarativeProperty &that,
+ QDeclarativeExpression *expr)
+{
+ if (!(that.type() & QDeclarativeProperty::SignalProperty)) {
+ delete expr;
+ return 0;
+ }
+
+ const QObjectList &children = that.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() == that.index())
+ return signal->setExpression(expr);
+ }
+
+ if (expr) {
+ QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(that.d->object, that.method(), that.d->object);
+ return signal->setExpression(expr);
+ } else {
+ return 0;
+ }
+}
+
+/*!
+ Returns the property value.
+*/
+QVariant QDeclarativeProperty::read() const
+{
+ if (!d->object)
+ return QVariant();
+
+ if (type() & SignalProperty) {
+
+ return QVariant();
+
+ } else if (type() & Property) {
+
+ return d->readValueProperty();
+
+ }
+ return QVariant();
+}
+
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name);
+ p.read();
+\endcode
+*/
+QVariant QDeclarativeProperty::read(QObject *object, const QString &name)
+{
+ QDeclarativeProperty p(object, name);
+ return p.read();
+}
+
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, context);
+ p.read();
+\endcode
+*/
+QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeContext *ctxt)
+{
+ QDeclarativeProperty p(object, name, ctxt);
+ return p.read();
+}
+
+/*!
+Return the \a name property value of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, engine);
+ p.read();
+\endcode
+*/
+QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeEngine *engine)
+{
+ QDeclarativeProperty p(object, name, engine);
+ return p.read();
+}
+
+QVariant QDeclarativePropertyPrivate::readValueProperty()
+{
+ if(isValueType()) {
+
+ 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, engine));
+
+ } 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 QDeclarativePropertyPrivate::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 QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, WriteFlags flags)
+{
+ // Remove any existing bindings on this property
+ if (!(flags & DontRemoveBinding)) {
+ QDeclarativeAbstractBinding *binding = setBinding(*q, 0);
+ if (binding) binding->destroy();
+ }
+
+ bool rv = false;
+ if (isValueType()) {
+ 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 QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePropertyCache::Data &property,
+ const QVariant &value, QDeclarativeContext *context,
+ 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 (o && !canConvert(o->metaObject(), listType))
+ o = 0;
+ prop.append(&prop, (void *)o);
+ }
+ } else {
+ QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value);
+ if (o && !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 *QDeclarativePropertyPrivate::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 QDeclarativeProperty::write(const QVariant &value) const
+{
+ return QDeclarativePropertyPrivate::write(*this, value, 0);
+}
+
+/*!
+Writes \a value to the \a name property of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name);
+ p.write(value);
+\endcode
+*/
+bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value)
+{
+ QDeclarativeProperty p(object, name);
+ return p.write(value);
+}
+
+/*!
+Writes \a value to the \a name property of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, ctxt);
+ p.write(value);
+\endcode
+*/
+bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value,
+ QDeclarativeContext *ctxt)
+{
+ QDeclarativeProperty p(object, name, ctxt);
+ return p.write(value);
+}
+
+/*!
+Writes \a value to the \a name property of \a object. This method is equivalent to:
+\code
+ QDeclarativeProperty p(object, name, engine);
+ p.write(value);
+\endcode
+*/
+bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value,
+ QDeclarativeEngine *engine)
+{
+ QDeclarativeProperty p(object, name, engine);
+ return p.write(value);
+}
+
+/*!
+ Resets the property value.
+*/
+bool QDeclarativeProperty::reset() const
+{
+ if (isResettable()) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(d->object, QMetaObject::ResetProperty, d->core.coreIndex, args);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QDeclarativePropertyPrivate::write(const QDeclarativeProperty &that,
+ const QVariant &value, WriteFlags flags)
+{
+ if (that.d->object && that.type() & QDeclarativeProperty::Property &&
+ that.d->core.isValid() && that.isWritable())
+ return that.d->writeValueProperty(value, flags);
+ else
+ return false;
+}
+
+/*!
+ Returns true if the property has a change notifier signal, otherwise false.
+*/
+bool QDeclarativeProperty::hasNotifySignal() const
+{
+ if (type() & Property && 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 QDeclarativeProperty::needsNotifySignal() const
+{
+ return type() & Property && !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 QDeclarativeProperty::connectNotifySignal(QObject *dest, int method) const
+{
+ if (!(type() & Property) || !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 QDeclarativeProperty::connectNotifySignal(QObject *dest, const char *slot) const
+{
+ if (!(type() & Property) || !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 QDeclarativeProperty::index() const
+{
+ return d->core.coreIndex;
+}
+
+int QDeclarativePropertyPrivate::valueTypeCoreIndex(const QDeclarativeProperty &that)
+{
+ return that.d->valueType.valueTypeCoreIdx;
+}
+
+struct SerializedData {
+ bool isValueType;
+ QDeclarativePropertyCache::Data core;
+};
+
+struct ValueTypeSerializedData : public SerializedData {
+ QDeclarativePropertyCache::ValueTypeData valueType;
+};
+
+QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
+ const QMetaObject *subObject, int subIndex)
+{
+ QMetaProperty prop = metaObject->property(index);
+ QMetaProperty subProp = subObject->property(subIndex);
+
+ ValueTypeSerializedData sd;
+ sd.isValueType = true;
+ 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 QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index)
+{
+ SerializedData sd;
+ sd.isValueType = false;
+ sd.core.load(metaObject->property(index));
+
+ QByteArray rv((const char *)&sd, sizeof(sd));
+ return rv;
+}
+
+QDeclarativeProperty
+QDeclarativePropertyPrivate::restore(const QByteArray &data, QObject *object, QDeclarativeContext *ctxt)
+{
+ QDeclarativeProperty prop;
+
+ if (data.isEmpty())
+ return prop;
+
+ prop.d->object = object;
+ prop.d->context = ctxt;
+ prop.d->engine = ctxt?ctxt->engine():0;
+
+ const SerializedData *sd = (const SerializedData *)data.constData();
+ if (sd->isValueType) {
+ const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
+ prop.d->core = vt->core;
+ prop.d->valueType = vt->valueType;
+ } else {
+ prop.d->core = sd->core;
+ }
+
+ return prop;
+}
+
+/*!
+ Returns true if lhs and rhs refer to the same metaobject data
+*/
+bool QDeclarativePropertyPrivate::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 QDeclarativePropertyPrivate::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/qdeclarativeproperty.h b/src/declarative/qml/qdeclarativeproperty.h
new file mode 100644
index 0000000000..73bccf3cad
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeproperty.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 QDECLARATIVEPROPERTY_H
+#define QDECLARATIVEPROPERTY_H
+
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QObject;
+class QVariant;
+class QDeclarativeContext;
+class QDeclarativeEngine;
+
+class QDeclarativePropertyPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeProperty
+{
+public:
+ enum PropertyTypeCategory {
+ InvalidCategory,
+ List,
+ Object,
+ Normal
+ };
+
+ enum Type {
+ Invalid,
+ Property,
+ SignalProperty
+ };
+
+ QDeclarativeProperty();
+ ~QDeclarativeProperty();
+
+ QDeclarativeProperty(QObject *);
+ QDeclarativeProperty(QObject *, QDeclarativeContext *);
+ QDeclarativeProperty(QObject *, QDeclarativeEngine *);
+
+ QDeclarativeProperty(QObject *, const QString &);
+ QDeclarativeProperty(QObject *, const QString &, QDeclarativeContext *);
+ QDeclarativeProperty(QObject *, const QString &, QDeclarativeEngine *);
+
+ QDeclarativeProperty(const QDeclarativeProperty &);
+ QDeclarativeProperty &operator=(const QDeclarativeProperty &);
+
+ bool operator==(const QDeclarativeProperty &) const;
+
+ Type type() const;
+ bool isValid() const;
+ bool isProperty() const;
+ bool isSignalProperty() const;
+
+ int propertyType() const;
+ PropertyTypeCategory propertyTypeCategory() const;
+ const char *propertyTypeName() const;
+
+ QString name() const;
+
+ QVariant read() const;
+ static QVariant read(QObject *, const QString &);
+ static QVariant read(QObject *, const QString &, QDeclarativeContext *);
+ static QVariant read(QObject *, const QString &, QDeclarativeEngine *);
+
+ bool write(const QVariant &) const;
+ static bool write(QObject *, const QString &, const QVariant &);
+ static bool write(QObject *, const QString &, const QVariant &, QDeclarativeContext *);
+ static bool write(QObject *, const QString &, const QVariant &, QDeclarativeEngine *);
+
+ bool reset() const;
+
+ bool hasNotifySignal() const;
+ bool needsNotifySignal() const;
+ bool connectNotifySignal(QObject *dest, const char *slot) const;
+ bool connectNotifySignal(QObject *dest, int method) const;
+
+ bool isWritable() const;
+ bool isDesignable() const;
+ bool isResettable() const;
+ QObject *object() const;
+
+ int index() const;
+ QMetaProperty property() const;
+ QMetaMethod method() const;
+
+private:
+ friend class QDeclarativePropertyPrivate;
+ QDeclarativePropertyPrivate *d;
+};
+typedef QList<QDeclarativeProperty> QDeclarativeProperties;
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPROPERTY_H
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
new file mode 100644
index 0000000000..1fda7f4348
--- /dev/null
+++ b/src/declarative/qml/qdeclarativeproperty_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 QDECLARATIVEPROPERTY_P_H
+#define QDECLARATIVEPROPERTY_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 "qdeclarativeproperty.h"
+
+#include "qdeclarativepropertycache_p.h"
+#include "qdeclarativeguard_p.h"
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QDeclarativeEnginePrivate;
+class QDeclarativeExpression;
+class Q_AUTOTEST_EXPORT QDeclarativePropertyPrivate
+{
+public:
+ enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 };
+ Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
+
+ QDeclarativePropertyPrivate()
+ : q(0), context(0), engine(0), object(0), isNameCached(false) {}
+
+
+ QDeclarativePropertyPrivate(const QDeclarativePropertyPrivate &other)
+ : q(0), context(other.context), engine(other.engine), object(other.object),
+ isNameCached(other.isNameCached),
+ core(other.core), nameCache(other.nameCache),
+ valueType(other.valueType) {}
+
+ QDeclarativeProperty *q;
+ QDeclarativeContext *context;
+ QDeclarativeEngine *engine;
+ QDeclarativeGuard<QObject> object;
+
+ bool isNameCached:1;
+ QDeclarativePropertyCache::Data core;
+ QString nameCache;
+
+ // Describes the "virtual" value-type sub-property.
+ QDeclarativePropertyCache::ValueTypeData valueType;
+
+ void initProperty(QObject *obj, const QString &name);
+ void initDefault(QObject *obj);
+
+ QMetaMethod findSignal(QObject *, const QString &);
+
+ bool isValueType() const;
+ int propertyType() const;
+ QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const;
+
+ QVariant readValueProperty();
+ bool writeValueProperty(const QVariant &, 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 *, WriteFlags flags = 0);
+ static QDeclarativeAbstractBinding *setBinding(QObject *, const QDeclarativePropertyCache::Data &,
+ QDeclarativeAbstractBinding *,
+ WriteFlags flags = DontRemoveBinding);
+
+ static QByteArray saveValueType(const QMetaObject *, int,
+ const QMetaObject *, int);
+ static QByteArray saveProperty(const QMetaObject *, int);
+ static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContext *);
+
+ static bool equal(const QMetaObject *, const QMetaObject *);
+ static bool canConvert(const QMetaObject *from, const QMetaObject *to);
+
+
+ // "Public" (to QML) methods
+ static QDeclarativeAbstractBinding *binding(const QDeclarativeProperty &that);
+ static QDeclarativeAbstractBinding *setBinding(const QDeclarativeProperty &that,
+ QDeclarativeAbstractBinding *,
+ WriteFlags flags = DontRemoveBinding);
+ static QDeclarativeExpression *signalExpression(const QDeclarativeProperty &that);
+ static QDeclarativeExpression *setSignalExpression(const QDeclarativeProperty &that,
+ QDeclarativeExpression *) ;
+ static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags);
+ static int valueTypeCoreIndex(const QDeclarativeProperty &that);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags)
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEPROPERTY_P_H
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
new file mode 100644
index 0000000000..08b47b7dbc
--- /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 0000000000..68e6e6b074
--- /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 <QtScript/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 0000000000..3f6d805520
--- /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 QDeclarativeProperty &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 0000000000..3de5abca29
--- /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 QDeclarativeProperty;
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyValueInterceptor
+{
+public:
+ QDeclarativePropertyValueInterceptor();
+ virtual ~QDeclarativePropertyValueInterceptor();
+ virtual void setTarget(const QDeclarativeProperty &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 0000000000..b106d4f030
--- /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 QDeclarativeProperty &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 0000000000..70d2c0346b
--- /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 QDeclarativeProperty;
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyValueSource
+{
+public:
+ QDeclarativePropertyValueSource();
+ virtual ~QDeclarativePropertyValueSource();
+ virtual void setTarget(const QDeclarativeProperty &) = 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 0000000000..1decea1328
--- /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 0000000000..3f103b6ca7
--- /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 0000000000..943e35c6ff
--- /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 0000000000..1170b866fd
--- /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 0000000000..afc6e63250
--- /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 0000000000..33b168c69e
--- /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 0000000000..ac4b2c1ca3
--- /dev/null
+++ b/src/declarative/qml/qdeclarativescript.cpp
@@ -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$
+**
+****************************************************************************/
+
+// This is just a dummy file to include the documentation
+
+/*!
+ \qmlclass Script QDeclarativeScript
+ \since 4.7
+ \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 0000000000..d8733dba9d
--- /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 0000000000..f4c9cdd052
--- /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","JavaScript 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 0000000000..b8f77d1f3a
--- /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 0000000000..5b9afe9cfc
--- /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 0000000000..43bef4460d
--- /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 0000000000..855d62331a
--- /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 0000000000..d0b6c0b87a
--- /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 0000000000..f3497e52ee
--- /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 0000000000..7afdfd3113
--- /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 0000000000..f94f9441c2
--- /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 0000000000..eee5b77dd8
--- /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 0000000000..02370e0716
--- /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 0000000000..b6e3f514d2
--- /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 0000000000..01fa2141e7
--- /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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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 0000000000..cb153be5da
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -0,0 +1,398 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeproperty.h"
+#include "qdeclarativeproperty_p.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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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, QDeclarativePropertyPrivate::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 0000000000..9cb65f8976
--- /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 0000000000..31bd415a56
--- /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 0000000000..720b496a44
--- /dev/null
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -0,0 +1,852 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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
+ QDeclarativePropertyPrivate::WriteFlags flags = QDeclarativePropertyPrivate::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);
+
+ QDeclarativeProperty prop(target, QString::fromUtf8(pr));
+ if (prop.type() & QDeclarativeProperty::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.index(), 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);
+
+ QDeclarativeProperty mp =
+ QDeclarativePropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt);
+
+ int coreIndex = mp.index();
+
+ 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);
+
+ QDeclarativeProperty prop =
+ QDeclarativePropertyPrivate::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);
+ QDeclarativeProperty prop =
+ QDeclarativePropertyPrivate::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.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), 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,
+ QDeclarativePropertyPrivate::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 0000000000..951f6a7c89
--- /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 0000000000..d67c834d18
--- /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 & QDeclarativePropertyPrivate::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 0000000000..37c0b7acce
--- /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 0000000000..2f611956f7
--- /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 0000000000..4e3352f3b1
--- /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 0000000000..03151e4217
--- /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 0000000000..8ebd2c1d3d
--- /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 0000000000..3ba53f0f15
--- /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 0000000000..068cd0fb3e
--- /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 163d1981d0..0000000000
--- a/src/declarative/qml/qml.h
+++ /dev/null
@@ -1,155 +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)
-
-#if defined(Q_OS_SYMBIAN)
-#define QML_DEFINE_INTERFACE(INTERFACE) \
- static int defineInterface##INTERFACE = qmlRegisterInterface<INTERFACE>(#INTERFACE);
-
-#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \
- static int registerExtended##TYPE = qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE);
-
-#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE) \
- static int defineType##TYPE = qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE);
-
-#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \
- static int registerExtendedNoCreate##TYPE = qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE);
-
-#define QML_DEFINE_NOCREATE_TYPE(TYPE) \
- static int registerNoCreate##TYPE = qmlRegisterType<TYPE>(#TYPE);
-
-#else
-
-#define QML_DEFINE_INTERFACE(INTERFACE) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *,0,0>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE));
-
-#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN)>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE));
-
-#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN)>::instance(qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE));
-
-#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE));
-
-#define QML_DEFINE_NOCREATE_TYPE(TYPE) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0>::instance(qmlRegisterType<TYPE>(#TYPE));
-
-#endif
-
-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 2313c37819..aa1a34bf85 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -1,128 +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/qmlmoduleplugin.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/qdeclarativeproperty.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/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/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.h \
- $$PWD/qmlbinding_p.h \
- $$PWD/qmlmetaproperty.h \
- $$PWD/qmlmoduleplugin.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/qdeclarativeproperty.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_p.h \
+ $$PWD/qdeclarativeengine.h \
+ $$PWD/qdeclarativecontext.h \
+ $$PWD/qdeclarativeexpression.h \
+ $$PWD/qdeclarativestringconverters_p.h \
+ $$PWD/qdeclarativeclassfactory_p.h \
+ $$PWD/qdeclarativeinfo.h \
+ $$PWD/qdeclarativeproperty_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/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)
include(rewriter/rewriter.pri)
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
deleted file mode 100644
index feadd0f604..0000000000
--- 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.h"
-#include "qmlbinding_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
-
-QML_DEFINE_NOCREATE_TYPE(QmlBinding);
-
-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);
-}
-
-QmlBinding::QmlBinding(const QString &str, QObject *obj, QmlContext *ctxt, QObject *parent)
-: QmlExpression(ctxt, str, obj, *new QmlBindingPrivate)
-{
- setParent(parent);
-}
-
-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 QmlBinding::emitValueChanged()
-{
- update();
- // don't bother calling valueChanged()
-}
-
-void QmlBinding::setEnabled(bool e, QmlMetaProperty::WriteFlags flags)
-{
- Q_D(QmlBinding);
- d->bindingData()->enabled = e;
- setTrackChange(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.h b/src/declarative/qml/qmlbinding.h
deleted file mode 100644
index 151b71ce53..0000000000
--- a/src/declarative/qml/qmlbinding.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 QMLBINDING_H
-#define QMLBINDING_H
-
-#include "qml.h"
-#include "qmlpropertyvaluesource.h"
-#include "qmlexpression.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QMetaProperty>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_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_DECLARATIVE_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)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlBinding);
-
-QT_END_HEADER
-
-#endif // QMLBINDING_H
diff --git a/src/declarative/qml/qmlbinding_p.h b/src/declarative/qml/qmlbinding_p.h
deleted file mode 100644
index b4f88b5409..0000000000
--- a/src/declarative/qml/qmlbinding_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 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 "qmlbinding.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); }
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLBINDING_P_H
diff --git a/src/declarative/qml/qmlboundsignal.cpp b/src/declarative/qml/qmlboundsignal.cpp
deleted file mode 100644
index a0758990c3..0000000000
--- a/src/declarative/qml/qmlboundsignal.cpp
+++ /dev/null
@@ -1,264 +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);
- m_expression->setTrackChange(false);
-}
-
-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->setTrackChange(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 51d21d732d..0000000000
--- 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 2adff0998d..0000000000
--- 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 2ddadcf999..0000000000
--- 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 581d4a3666..0000000000
--- 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 50803f3e8f..0000000000
--- 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 7a8cf0e395..0000000000
--- 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 38fb2a35af..0000000000
--- 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.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 0120f56a31..0000000000
--- 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 bbae201f7e..0000000000
--- a/src/declarative/qml/qmlcompiler.cpp
+++ /dev/null
@@ -1,2774 +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.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;
-
- // TODO this will be enforced and return false
- if (val.at(0).isLetter() && !val.at(0).isLower()) {
- //return false;
- qWarning().nospace() << "id '" << val << "' is invalid: ids cannot start with uppercase letters. This will be enforced in an upcoming version of QML.";
- }
-
- 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","Invalid component specification"));
-
- if (!obj->scriptBlockObjects.isEmpty())
- COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), QCoreApplication::translate("QmlCompiler","Invalid component specification"));
-
- 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)
-{
- return output->indexForByteArray(QmlMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index, valueTypeProp->index, valueTypeProp->type));
-}
-
-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 744d397543..0000000000
--- 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 1bdc8837f3..0000000000
--- a/src/declarative/qml/qmlcomponent.cpp
+++ /dev/null
@@ -1,799 +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.h"
-#include "qmlbinding_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
-*/
-QML_DEFINE_TYPE(Qt,4,6,Component,QmlComponent);
-
-/*!
- \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 899648169b..0000000000
--- 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 b7a3038839..0000000000
--- 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 342c88aadd..0000000000
--- 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 71d6f1619b..0000000000
--- 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 2da5d34c0e..0000000000
--- 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 17183872bd..0000000000
--- 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 e96ed84d42..0000000000
--- 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 965eeed32f..0000000000
--- 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 4c71903ff8..0000000000
--- 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 c878f3c491..0000000000
--- 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 d781110a22..0000000000
--- 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 define
- itself in the meta type system with the macro:
-
- \code
- QML_DEFINE_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_DEFINE_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 7aebb0d895..0000000000
--- a/src/declarative/qml/qmlcustomparser_p.h
+++ /dev/null
@@ -1,146 +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;
-};
-
-#if defined(Q_OS_SYMBIAN)
-# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
- static int defineCustomType##NAME = qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE);
-#else
-# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN)>::instance(qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE));
-#endif
-
-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 52e7b4fa0b..0000000000
--- 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 efdc5fd08f..0000000000
--- 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/qmldom.cpp b/src/declarative/qml/qmldom.cpp
deleted file mode 100644
index c75a299041..0000000000
--- 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 8c7288e33e..0000000000
--- 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 9d955b0b7a..0000000000
--- 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 63ee7b1c4e..0000000000
--- a/src/declarative/qml/qmlengine.cpp
+++ /dev/null
@@ -1,1755 +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 "qmlmoduleplugin.h"
-#include "qmlbinding_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 "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 <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/qfactoryloader_p.h>
-#include <private/qobject_p.h>
-#include <private/qscriptdeclarativeclass_p.h>
-
-#include <private/qmlgraphicsitemsmodule_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)
-
-QML_DEFINE_TYPE(Qt,4,6,QtObject,QObject)
-/*!
- \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;
-
-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();
- }
- globalClass = new QmlGlobalScriptClass(&scriptEngine);
- fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
-}
-
-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<bool> isBuiltin; // Types provided by C++ code (including plugins)
- 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);
-
- if (isBuiltin.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 (vmajor) *vmajor = vmaj;
- if (vminor) *vminor = vmin;
- if (t) {
- 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());
- }
- }
- QString typespace = QString::fromUtf8(type)+QLatin1Char(' ');
- QStringList lines = qmldircontent.split(QLatin1Char('\n'));
- foreach (QString line, lines) {
- if (line.isEmpty() || line.at(0) == QLatin1Char('#'))
- continue;
- if (line.startsWith(typespace)) {
- int space1 = line.indexOf(QLatin1Char(' '));
- int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1;
- QString mapversions = line.mid(space1+1,space2<0?line.length()-space1-1:space2-space1-1);
- int dot = mapversions.indexOf(QLatin1Char('.'));
- int mapvmaj = mapversions.left(dot).toInt();
- if (mapvmaj<=vmaj) {
- if (mapvmaj<vmaj || vmin >= mapversions.mid(dot+1).toInt()) {
- QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-1);
- if (url_return)
- *url_return = url.resolved(QUrl(mapfile.toString()));
- 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;
- }
-};
-
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QmlModuleFactoryInterface_iid, QLatin1String("/qmlmodules")))
-
-class QmlImportsPrivate {
-public:
- QmlImportsPrivate() : ref(1)
- {
- }
-
- ~QmlImportsPrivate()
- {
- foreach (QmlEnginePrivate::ImportedNamespace* s, set.values())
- delete s;
- }
-
- 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)
- {
- 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;
- bool isbuiltin = false;
- if (importType == QmlScriptParser::Import::Library) {
- url.replace(QLatin1Char('.'),QLatin1Char('/'));
- bool found = false;
- foreach (QString p, importPath) {
- QString dir = p+QLatin1Char('/')+url;
- QFileInfo fi(dir+QLatin1String("/qmldir"));
- if (fi.isFile()) {
- url = QUrl::fromLocalFile(fi.absolutePath()).toString();
- found = true;
- break;
- }
- }
- if (!found) {
- // XXX assume it is a built-in type qualifier
- isbuiltin = true;
- }
- QFactoryLoader *l = loader();
- QmlModuleFactoryInterface *factory =
- qobject_cast<QmlModuleFactoryInterface*>(l->instance(uri));
- if (factory) {
- factory->defineModuleOnce(uri);
- isbuiltin = true;
- }
- } 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->isBuiltin.prepend(isbuiltin);
- 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->isBuiltin[0] && !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) {
- if (!set.isBuiltin.at(ii))
- continue;
-
- 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);
-}
-
-/*!
- \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
-
- 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
-{
- bool ok = imports->d->add(imports->d->base,qmldircontent,uri,prefix,vmaj,vmin,importType,fileImportPath);
- 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 64d0b9d4b7..0000000000
--- a/src/declarative/qml/qmlengine.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 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);
-
- 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 3fe799105e..0000000000
--- a/src/declarative/qml/qmlengine_p.h
+++ /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$
-**
-****************************************************************************/
-
-#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 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;
- };
-
- 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 *);
-};
-
-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 654157cddd..0000000000
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ /dev/null
@@ -1,457 +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.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 = new QmlExpression(context, expr, object);
- bool undefined = false;
- QVariant value = exprObj->value(&undefined);
- if (undefined)
- result = QLatin1String("<undefined>");
- else
- result = valueContents(value);
- delete exprObj;
- } 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 a6f296a33f..0000000000
--- 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 fc4bcd512a..0000000000
--- 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 8c4d78507b..0000000000
--- 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 3039fed260..0000000000
--- a/src/declarative/qml/qmlexpression.cpp
+++ /dev/null
@@ -1,830 +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(true), 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;
-}
-
-/*!
- Clear the expression.
-*/
-void QmlExpression::clearExpression()
-{
- setExpression(QString());
-}
-
-/*!
- 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 expression results in a constant value.
- QmlExpression::value() must have been invoked at least once before the
- return from this method is valid.
- */
-bool QmlExpression::isConstant() const
-{
- Q_D(const QmlExpression);
- return !d->data->guardList;
-}
-
-/*!
- Returns true if the changes are tracked in the expression's value.
-*/
-bool QmlExpression::trackChange() const
-{
- Q_D(const QmlExpression);
- return d->data->trackChange;
-}
-
-/*!
- Set whether changes are tracked in the expression's value to \a trackChange.
-
- If true, the QmlExpression will monitor properties involved in the
- expression's evaluation, and call 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
- called. This is more efficient if an application wants a "one off"
- evaluation of the expression.
-
- By default, trackChange is true.
-*/
-void QmlExpression::setTrackChange(bool trackChange)
-{
- Q_D(QmlExpression);
- d->data->trackChange = trackChange;
-}
-
-/*!
- 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()
-{
- 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.
-*/
-
-/*!
- Subclasses can capture the emission of the valueChanged() signal by overriding
- this function. They can choose whether to then call valueChanged().
-*/
-void QmlExpression::emitValueChanged()
-{
- emit 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 428eefae2c..0000000000
--- a/src/declarative/qml/qmlexpression.h
+++ /dev/null
@@ -1,118 +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 clearExpression();
- virtual void setExpression(const QString &);
- bool isConstant() const;
-
- bool trackChange() const;
- void setTrackChange(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;
-
-public Q_SLOTS:
- QVariant value(bool *isUndefined = 0);
-
-Q_SIGNALS:
- void valueChanged();
-
-protected:
- virtual void emitValueChanged();
-
- 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 e52a1996b3..0000000000
--- a/src/declarative/qml/qmlexpression_p.h
+++ /dev/null
@@ -1,187 +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();
- }
-
- 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/qmlglobal_p.h b/src/declarative/qml/qmlglobal_p.h
deleted file mode 100644
index 06ae6e6ebf..0000000000
--- 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 d2198b6c5f..0000000000
--- 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 d002da6a4c..0000000000
--- 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 0e90f79c0b..0000000000
--- 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 7f15d08fbe..0000000000
--- 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 52fe0669a5..0000000000
--- 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 1f3d434494..0000000000
--- 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 379f2111c8..0000000000
--- 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 e37ade753c..0000000000
--- 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 ea785b6eeb..0000000000
--- 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 2c2d494667..0000000000
--- 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 f38138f91a..0000000000
--- 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 4cd2120362..0000000000
--- 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 5528d8d406..0000000000
--- 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 4660e4728a..0000000000
--- 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 bb29763dec..0000000000
--- 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 07b09c38fc..0000000000
--- 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 7c273dc4d1..0000000000
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ /dev/null
@@ -1,1230 +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.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->core = other.d->core;
-
- 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.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 t = property.propType;
- int vt = value.userType();
-
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(context);
-
- if (t == QVariant::Url) {
-
- QUrl u;
- bool found = false;
- if (vt == QVariant::Url) {
- u = value.toUrl();
- found = true;
- } else if (vt == QVariant::ByteArray) {
- u = QUrl(QString::fromUtf8(value.toByteArray()));
- found = true;
- } else if (vt == 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 (vt == t) {
-
- void *a[] = { (void *)value.constData(), 0, &status, &flags };
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
-
- } else if (qMetaTypeId<QVariant>() == t) {
-
- 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, t);
-
- 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(vt != t);
-
- QVariant v = value;
- if (v.convert((QVariant::Type)t)) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- } else if ((uint)t >= QVariant::UserType && vt == QVariant::String) {
- QmlMetaType::StringConverter con = QmlMetaType::customStringConverter(t);
- if (!con)
- return false;
-
- QVariant v = con(value.toString());
- if (v.userType() == t) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- }
- } else if (vt == QVariant::String) {
- bool ok = false;
- QVariant v = QmlStringConverters::variantFromString(value.toString(), t, &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,
- int subIndex, int subType)
-{
- ValueTypeSerializedData sd;
- sd.type = QmlMetaProperty::ValueTypeProperty;
- sd.core.load(metaObject->property(index));
- sd.valueType.valueTypeCoreIdx = subIndex;
- sd.valueType.valueTypePropType = subType;
-
- 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 82266c8e2b..0000000000
--- 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 b99e5be723..0000000000
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ /dev/null
@@ -1,124 +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, int, 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 6db70d4d62..0000000000
--- 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 98d04c1c81..0000000000
--- 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/qmlmoduleplugin.cpp b/src/declarative/qml/qmlmoduleplugin.cpp
deleted file mode 100644
index 342074a340..0000000000
--- a/src/declarative/qml/qmlmoduleplugin.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmlmoduleplugin.h"
-#include "qstringlist.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlModulePlugin
- \since 4.7
- \brief The QmlModulePlugin class provides an abstract base for custom QML module plugins.
- \reentrant
- \ingroup plugins
-
- The QML module plugin is a simple plugin interface that makes it
- easy to add custom QML modules that can be loaded dynamically
- into applications.
-
- Writing a QML module plugin is achieved by subclassing this base
- class, reimplementing the pure virtual function keys(), and
- exporting the class with the Q_EXPORT_PLUGIN2() macro. See \l{How
- to Create Qt Plugins} for details.
-
- The strings returned by keys() should be the list of URIs of modules
- that the plugin registers.
-
- The plugin should register QML types with qmlRegisterType() when the
- defineModule() method is called.
-
- See the example in \c{examples/declarative/plugins}.
-*/
-
-/*!
- Constructs a QML module plugin with the given \a parent. This is
- invoked automatically by the Q_EXPORT_PLUGIN2() macro.
-*/
-QmlModulePlugin::QmlModulePlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys the QML module plugin.
-
- You never have to call this explicitly. Qt destroys a plugin
- automatically when it is no longer used.
-*/
-QmlModulePlugin::~QmlModulePlugin()
-{
-}
-
-/*!
- \fn void QmlModulePlugin::defineModule(const QString& uri)
-
- Subclasses must override this function to register types
- of the module \a uri, which will be one of the strings returned by keys().
-
- The plugin registers QML types with qmlRegisterType():
-
- \code
- qmlRegisterType<MyClass>("com.nokia.MyModule", 1, 0, "MyType", "MyClass");
- \endcode
-*/
-
-void QmlModulePlugin::defineModuleOnce(const QString& uri)
-{
- if (!defined.contains(uri)) {
- defined += uri;
- defineModule(uri);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlmoduleplugin.h b/src/declarative/qml/qmlmoduleplugin.h
deleted file mode 100644
index b28f1ad7a1..0000000000
--- a/src/declarative/qml/qmlmoduleplugin.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 QMLMODULEPLUGIN_H
-#define QMLMODULEPLUGIN_H
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qset.h>
-#include <QtCore/qbytearray.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-struct Q_DECLARATIVE_EXPORT QmlModuleFactoryInterface : public QFactoryInterface
-{
- virtual void defineModuleOnce(const QString& uri) = 0;
-};
-
-#define QmlModuleFactoryInterface_iid "com.nokia.Qt.QmlModuleFactoryInterface"
-
-Q_DECLARE_INTERFACE(QmlModuleFactoryInterface, QmlModuleFactoryInterface_iid)
-
-
-class Q_DECLARATIVE_EXPORT QmlModulePlugin : public QObject, public QmlModuleFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QmlModuleFactoryInterface:QFactoryInterface)
-public:
- explicit QmlModulePlugin(QObject *parent = 0);
- ~QmlModulePlugin();
-
- virtual void defineModule(const QString& uri) = 0;
-
-private:
- void defineModuleOnce(const QString& uri);
- QSet<QString> defined;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLMODULEPLUGIN_H
diff --git a/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp b/src/declarative/qml/qmlnetworkaccessmanagerfactory.cpp
deleted file mode 100644
index 455d09e96d..0000000000
--- 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 1660929b7b..0000000000
--- 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 15ece1da03..0000000000
--- 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.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 729f34f66e..0000000000
--- 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 f2690e2518..0000000000
--- 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 222229b884..0000000000
--- 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 315bc752ef..0000000000
--- 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 e4cfe8b68e..0000000000
--- 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 f85e2806ef..0000000000
--- 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
index e5ea07f525..0000000000
--- a/src/declarative/qml/qmlprivate.h
+++ /dev/null
@@ -1,211 +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 QMLPRIVATE_H
-#define QMLPRIVATE_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 *(*QmlAttachedPropertiesFunc)(QObject *);
-
-//template<typename T>
-//struct qml_hasAttached { static bool const value = false; };
-
-template <typename TYPE>
-class QmlTypeInfo
-{
-public:
- enum {
- hasAttachedProperties = 0
- };
-};
-
-
-namespace QmlPrivate
-{
- 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 = QmlTypeInfo<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 QmlAttachedPropertiesFunc 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 QmlAttachedPropertiesFunc func() {
- return &attachedProperties;
- }
- static inline const QMetaObject *metaObject() {
- return attachedPropertiesMetaObject(&T::qmlAttachedProperties);
- }
- };
-
- template<typename T>
- inline QmlAttachedPropertiesFunc 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 // QMLPRIVATE_H
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
deleted file mode 100644
index a3e655b6aa..0000000000
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ /dev/null
@@ -1,413 +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 "qmlpropertycache_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlbinding.h"
-#include "qdebug.h"
-
-Q_DECLARE_METATYPE(QScriptValue);
-
-QT_BEGIN_NAMESPACE
-
-void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
-{
- propType = p.userType();
- if (QVariant::Type(propType) == QVariant::LastType)
- propType = qMetaTypeId<QVariant>();
- coreIndex = p.propertyIndex();
- notifyIndex = p.notifySignalIndex();
-
- if (p.isConstant())
- flags |= Data::IsConstant;
- if (p.isWritable())
- flags |= Data::IsWritable;
- if (p.isResettable())
- flags |= Data::IsResettable;
-
- if (propType == qMetaTypeId<QmlBinding *>()) {
- flags |= Data::IsQmlBinding;
- } else if (propType == qMetaTypeId<QScriptValue>()) {
- flags |= Data::IsQScriptValue;
- } else if (p.isEnumType()) {
- flags |= Data::IsEnumType;
- } else {
- QmlMetaType::TypeCategory cat = engine ? QmlEnginePrivate::get(engine)->typeCategory(propType)
- : QmlMetaType::typeCategory(propType);
- if (cat == QmlMetaType::Object)
- flags |= Data::IsQObjectDerived;
- else if (cat == QmlMetaType::List)
- flags |= Data::IsQList;
- }
-}
-
-void QmlPropertyCache::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;
-}
-
-
-QmlPropertyCache::QmlPropertyCache(QmlEngine *e)
-: QmlCleanup(e), engine(e)
-{
-}
-
-QmlPropertyCache::~QmlPropertyCache()
-{
- clear();
-}
-
-void QmlPropertyCache::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();
-}
-
-QmlPropertyCache::Data QmlPropertyCache::create(const QMetaObject *metaObject,
- const QString &property)
-{
- Q_ASSERT(metaObject);
-
- QmlPropertyCache::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;
-}
-
-QmlPropertyCache *QmlPropertyCache::copy() const
-{
- QmlPropertyCache *cache = new QmlPropertyCache(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 QmlPropertyCache::append(QmlEngine *engine, const QMetaObject *metaObject,
- Data::Flag propertyFlags, Data::Flag methodFlags)
-{
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::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.
-QmlPropertyCache *QmlPropertyCache::create(QmlEngine *engine, const QMetaObject *metaObject)
-{
- Q_ASSERT(engine);
- Q_ASSERT(metaObject);
-
- QmlPropertyCache *cache = new QmlPropertyCache(engine);
- cache->update(engine, metaObject);
- return cache;
-}
-
-void QmlPropertyCache::update(QmlEngine *engine, const QMetaObject *metaObject)
-{
- Q_ASSERT(engine);
- Q_ASSERT(metaObject);
- QmlEnginePrivate *enginePriv = QmlEnginePrivate::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();
- }
-}
-
-QmlPropertyCache::Data *
-QmlPropertyCache::property(int index) const
-{
- if (index < 0 || index >= indexCache.count())
- return 0;
-
- return indexCache.at(index);
-}
-
-QmlPropertyCache::Data *
-QmlPropertyCache::property(const QString &str) const
-{
- return stringCache.value(str);
-}
-
-QString QmlPropertyCache::Data::name(QObject *object)
-{
- if (!object)
- return QString();
-
- return name(object->metaObject());
-}
-
-QString QmlPropertyCache::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 QmlPropertyCache::propertyNames() const
-{
- return stringCache.keys();
-}
-
-QmlPropertyCache::Data *QmlPropertyCache::property(QmlEngine *engine, QObject *obj,
- const QScriptDeclarativeClass::Identifier &name, Data &local)
-{
- QmlPropertyCache::Data *rv = 0;
-
- QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
-
- QmlPropertyCache *cache = 0;
- QmlDeclarativeData *ddata = QmlDeclarativeData::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 = QmlPropertyCache::create(obj->metaObject(), enginePrivate->objectClass->toString(name));
- if (local.isValid())
- rv = &local;
- }
-
- return rv;
-}
-
-QmlPropertyCache::Data *QmlPropertyCache::property(QmlEngine *engine, QObject *obj,
- const QString &name, Data &local)
-{
- QmlPropertyCache::Data *rv = 0;
-
- if (!engine) {
- local = QmlPropertyCache::create(obj->metaObject(), name);
- if (local.isValid())
- rv = &local;
- } else {
- QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine);
-
- QmlPropertyCache *cache = 0;
- QmlDeclarativeData *ddata = QmlDeclarativeData::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 = QmlPropertyCache::create(obj->metaObject(), name);
- if (local.isValid())
- rv = &local;
- }
- }
-
- return rv;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h
deleted file mode 100644
index 18eea8029d..0000000000
--- a/src/declarative/qml/qmlpropertycache_p.h
+++ /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$
-**
-****************************************************************************/
-
-#ifndef QMLPROPERTYCACHE_P_H
-#define QMLPROPERTYCACHE_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/qvector.h>
-
-#include <private/qscriptdeclarativeclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QMetaProperty;
-class QmlPropertyCache : public QmlRefCount, public QmlCleanup
-{
-public:
- QmlPropertyCache(QmlEngine *);
- virtual ~QmlPropertyCache();
-
- 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;
-
- void load(const QMetaProperty &, QmlEngine *engine = 0);
- void load(const QMetaMethod &);
- QString name(QObject *);
- QString name(const QMetaObject *);
- };
-
- struct ValueTypeData {
- inline ValueTypeData();
- inline bool operator==(const ValueTypeData &);
- 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(QmlEngine *, const QMetaObject *);
-
- QmlPropertyCache *copy() const;
- void append(QmlEngine *, const QMetaObject *, Data::Flag propertyFlags = Data::NoFlags,
- Data::Flag methodFlags = Data::NoFlags);
-
- static QmlPropertyCache *create(QmlEngine *, 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 QmlEngine *qmlEngine() const;
- static Data *property(QmlEngine *, QObject *, const QScriptDeclarativeClass::Identifier &, Data &);
- static Data *property(QmlEngine *, QObject *, const QString &, Data &);
-protected:
- virtual void clear();
-
-private:
- struct RData : public Data, public QmlRefCount {
- QScriptDeclarativeClass::PersistentIdentifier identifier;
- };
-
- typedef QVector<RData *> IndexCache;
- typedef QHash<QString, RData *> StringCache;
- typedef QHash<QScriptDeclarativeClass::Identifier, RData *> IdentifierCache;
-
- QmlEngine *engine;
- IndexCache indexCache;
- StringCache stringCache;
- IdentifierCache identifierCache;
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QmlPropertyCache::Data::Flags);
-
-QmlPropertyCache::Data::Data()
-: flags(0), propType(0), coreIndex(-1), notifyIndex(-1)
-{
-}
-
-bool QmlPropertyCache::Data::operator==(const QmlPropertyCache::Data &other)
-{
- return flags == other.flags &&
- propType == other.propType &&
- coreIndex == other.coreIndex &&
- notifyIndex == other.notifyIndex;
-}
-
-QmlPropertyCache::Data *
-QmlPropertyCache::property(const QScriptDeclarativeClass::Identifier &id) const
-{
- return identifierCache.value(id);
-}
-
-QmlPropertyCache::ValueTypeData::ValueTypeData()
-: valueTypeCoreIdx(-1), valueTypePropType(0)
-{
-}
-
-bool QmlPropertyCache::ValueTypeData::operator==(const ValueTypeData &o)
-{
- return valueTypeCoreIdx == o.valueTypeCoreIdx &&
- valueTypePropType == o.valueTypePropType;
-}
-
-QmlEngine *QmlPropertyCache::qmlEngine() const
-{
- return engine;
-}
-
-QT_END_NAMESPACE
-
-#endif // QMLPROPERTYCACHE_P_H
diff --git a/src/declarative/qml/qmlpropertyvalueinterceptor.cpp b/src/declarative/qml/qmlpropertyvalueinterceptor.cpp
deleted file mode 100644
index ea53e1603a..0000000000
--- a/src/declarative/qml/qmlpropertyvalueinterceptor.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmlpropertyvalueinterceptor.h"
-
-#include "qml.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlPropertyValueInterceptor
- \brief The QmlPropertyValueInterceptor 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 QmlPropertyValueInterceptor.
-*/
-QmlPropertyValueInterceptor::QmlPropertyValueInterceptor()
-{
-}
-
-QmlPropertyValueInterceptor::~QmlPropertyValueInterceptor()
-{
-}
-
-/*!
- \fn void QmlPropertyValueInterceptor::setTarget(const QmlMetaProperty &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 QmlPropertyValueInterceptor::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/qmlpropertyvalueinterceptor.h b/src/declarative/qml/qmlpropertyvalueinterceptor.h
deleted file mode 100644
index 74cd5fab8e..0000000000
--- a/src/declarative/qml/qmlpropertyvalueinterceptor.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 QMLPROPERTYVALUEINTERCEPTOR_H
-#define QMLPROPERTYVALUEINTERCEPTOR_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlMetaProperty;
-class Q_DECLARATIVE_EXPORT QmlPropertyValueInterceptor
-{
-public:
- QmlPropertyValueInterceptor();
- virtual ~QmlPropertyValueInterceptor();
- virtual void setTarget(const QmlMetaProperty &property) = 0;
- virtual void write(const QVariant &value) = 0;
-};
-Q_DECLARE_INTERFACE(QmlPropertyValueInterceptor, "com.trolltech.qml.QmlPropertyValueInterceptor")
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLPROPERTYVALUEINTERCEPTOR_H
diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp
deleted file mode 100644
index bccdfb7973..0000000000
--- a/src/declarative/qml/qmlpropertyvaluesource.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 "qmlpropertyvaluesource.h"
-
-#include "qml.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlPropertyValueSource
- \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings.
- \internal
- */
-
-/*!
- Constructs a QmlPropertyValueSource.
-*/
-QmlPropertyValueSource::QmlPropertyValueSource()
-{
-}
-
-QmlPropertyValueSource::~QmlPropertyValueSource()
-{
-}
-
-/*!
- \fn void QmlPropertyValueSource::setTarget(const QmlMetaProperty &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/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h
deleted file mode 100644
index fc53b8a337..0000000000
--- a/src/declarative/qml/qmlpropertyvaluesource.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 QMLPROPERTYVALUESOURCE_H
-#define QMLPROPERTYVALUESOURCE_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlMetaProperty;
-class Q_DECLARATIVE_EXPORT QmlPropertyValueSource
-{
-public:
- QmlPropertyValueSource();
- virtual ~QmlPropertyValueSource();
- virtual void setTarget(const QmlMetaProperty &) = 0;
-};
-Q_DECLARE_INTERFACE(QmlPropertyValueSource, "com.trolltech.qml.QmlPropertyValueSource")
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLPROPERTYVALUESOURCE_H
diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp
deleted file mode 100644
index 29aad3481e..0000000000
--- a/src/declarative/qml/qmlproxymetaobject.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmlproxymetaobject_p.h"
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-QmlProxyMetaObject::QmlProxyMetaObject(QObject *obj, QList<ProxyData> *mList)
-: metaObjects(mList), proxies(0), parent(0), object(obj)
-{
-#ifdef QMLPROXYMETAOBJECT_DEBUG
- qWarning() << "QmlProxyMetaObject" << 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 QMLPROXYMETAOBJECT_DEBUG
- const QMetaObject *mo = obj->metaObject();
- while(mo) {
- qWarning() << " " << mo->className();
- mo = mo->superClass();
- }
-#endif
-}
-
-QmlProxyMetaObject::~QmlProxyMetaObject()
-{
- if (parent)
- delete parent;
- parent = 0;
-
- if (proxies)
- delete [] proxies;
- proxies = 0;
-}
-
-int QmlProxyMetaObject::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/qmlproxymetaobject_p.h b/src/declarative/qml/qmlproxymetaobject_p.h
deleted file mode 100644
index 96cfbf59d4..0000000000
--- a/src/declarative/qml/qmlproxymetaobject_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 QMLPROXYMETAOBJECT_P_H
-#define QMLPROXYMETAOBJECT_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 "qml.h"
-
-#include <QtCore/QMetaObject>
-#include <QtCore/QObject>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlProxyMetaObject : public QAbstractDynamicMetaObject
-{
-public:
- struct ProxyData {
- typedef QObject *(*CreateFunc)(QObject *);
- QMetaObject *metaObject;
- CreateFunc createFunc;
- int propertyOffset;
- int methodOffset;
- };
-
- QmlProxyMetaObject(QObject *, QList<ProxyData> *);
- virtual ~QmlProxyMetaObject();
-
-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 // QMLPROXYMETAOBJECT_P_H
-
diff --git a/src/declarative/qml/qmlrefcount.cpp b/src/declarative/qml/qmlrefcount.cpp
deleted file mode 100644
index 76a6ab6d52..0000000000
--- a/src/declarative/qml/qmlrefcount.cpp
+++ /dev/null
@@ -1,70 +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 "qmlrefcount_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlRefCount::QmlRefCount()
-: refCount(1)
-{
-}
-
-QmlRefCount::~QmlRefCount()
-{
-}
-
-void QmlRefCount::addref()
-{
- Q_ASSERT(refCount > 0);
- ++refCount;
-}
-
-void QmlRefCount::release()
-{
- Q_ASSERT(refCount > 0);
- --refCount;
- if (refCount == 0)
- delete this;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmlrefcount_p.h b/src/declarative/qml/qmlrefcount_p.h
deleted file mode 100644
index 9b2f52bfeb..0000000000
--- a/src/declarative/qml/qmlrefcount_p.h
+++ /dev/null
@@ -1,80 +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 QMLREFCOUNT_P_H
-#define QMLREFCOUNT_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 QmlRefCount
-{
-public:
- QmlRefCount();
- virtual ~QmlRefCount();
- void addref();
- void release();
-
-private:
- int refCount;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLREFCOUNT_P_H
diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp
deleted file mode 100644
index d8a9350686..0000000000
--- a/src/declarative/qml/qmlrewrite.cpp
+++ /dev/null
@@ -1,215 +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 "qmlrewrite_p.h"
-
-#include "qmlglobal_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(rewriteDump, QML_REWRITE_DUMP);
-
-namespace QmlRewrite {
-
-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 QmlRewrite
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlrewrite_p.h b/src/declarative/qml/qmlrewrite_p.h
deleted file mode 100644
index 27140ba8ed..0000000000
--- a/src/declarative/qml/qmlrewrite_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 QMLREWRITE_P_H
-#define QMLREWRITE_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/qmljslexer_p.h"
-#include "parser/qmljsparser_p.h"
-#include "parser/qmljsnodepool_p.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace QmlRewrite {
-using namespace QmlJS;
-
-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 QmlRewrite
-
-QT_END_NAMESPACE
-
-#endif // QMLREWRITE_P_H
-
diff --git a/src/declarative/qml/qmlscript.cpp b/src/declarative/qml/qmlscript.cpp
deleted file mode 100644
index ef8bb93515..0000000000
--- a/src/declarative/qml/qmlscript.cpp
+++ /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$
-**
-****************************************************************************/
-
-// This is just a dummy file to include the documentation
-
-/*!
- \qmlclass Script QmlScript
- \since 4.7
- \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/qmlscriptclass_p.h b/src/declarative/qml/qmlscriptclass_p.h
deleted file mode 100644
index e7ccc1326d..0000000000
--- a/src/declarative/qml/qmlscriptclass_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 QMLSCRIPTCLASS_P_H
-#define QMLSCRIPTCLASS_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 QmlEngine;
-class QmlScriptClass : public QScriptDeclarativeClass
-{
-public:
- QmlScriptClass(QScriptEngine *);
-
- static QVariant toVariant(QmlEngine *, 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 // QMLSCRIPTCLASS_P_H
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
deleted file mode 100644
index c0d5cf9d44..0000000000
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ /dev/null
@@ -1,952 +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 "qmlscriptparser_p.h"
-
-#include "qmlparser_p.h"
-#include "parser/qmljsengine_p.h"
-#include "parser/qmljsparser_p.h"
-#include "parser/qmljslexer_p.h"
-#include "parser/qmljsnodepool_p.h"
-#include "parser/qmljsastvisitor_p.h"
-#include "parser/qmljsast_p.h"
-#include "qmlrewrite_p.h"
-
-#include <qfxperf_p_p.h>
-
-#include <QStack>
-#include <QCoreApplication>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QmlJS;
-using namespace QmlParser;
-
-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(QmlScriptParser *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);
-
- QmlParser::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:
- QmlScriptParser *_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(QmlScriptParser *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()) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","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) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","Invalid use of Script block"));
- error.setLine(typeLocation.startLine);
- error.setColumn(typeLocation.startColumn);
- _parser->_errors << error;
- return 0;
- }
- }
-
- Object *obj = new Object;
-
- if (!isScript) {
- QmlScriptParser::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)) {
- QmlParser::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;
- QmlScriptParser::Import import;
-
- if (node->fileName) {
- import.type = QmlScriptParser::Import::File;
- uri = node->fileName->asString();
- } else {
- import.type = QmlScriptParser::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()) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","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 == QmlScriptParser::Import::Library) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","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) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","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 {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","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) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","Unexpected property type modifier"));
- error.setLine(node->typeModifierToken.startLine);
- error.setColumn(node->typeModifierToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- if(!typeFound) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","Expected property type"));
- error.setLine(node->typeToken.startLine);
- error.setColumn(node->typeToken.startColumn);
- _parser->_errors << error;
- return false;
- }
-
- if (node->isReadonlyMember) {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","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) {
- QmlScriptParser::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;
-}
-
-QmlParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr)
-{
- if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) {
- return QmlParser::Variant(lit->value->asString());
- } else if (expr->kind == AST::Node::Kind_TrueLiteral) {
- return QmlParser::Variant(true);
- } else if (expr->kind == AST::Node::Kind_FalseLiteral) {
- return QmlParser::Variant(false);
- } else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) {
- return QmlParser::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 QmlParser::Variant(-lit->value, asString(expr));
- }
- }
-
- return QmlParser::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();
-
- QmlParser::Variant primitive;
-
- if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
- primitive = getVariant(stmt->expression);
- } else { // do binding
- primitive = QmlParser::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)
-{
- QmlParser::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 {
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser","QmlJS 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;
-
- QmlError error;
- error.setDescription(QCoreApplication::translate("QmlParser", "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 = QmlParser::Variant(source);
-
- obj->getDefaultProperty()->addValue(value);
- }
-
- return false;
-}
-
-} // end of anonymous namespace
-
-
-QmlScriptParser::QmlScriptParser()
-: root(0), data(0)
-{
-
-}
-
-QmlScriptParser::~QmlScriptParser()
-{
- clear();
-}
-
-class QmlScriptParserJsASTData
-{
-public:
- QmlScriptParserJsASTData(const QString &filename)
- : nodePool(filename, &engine) {}
-
- Engine engine;
- NodePool nodePool;
-};
-
-bool QmlScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QmlPerfTimer<QmlPerf::QmlParsing> pt;
-#endif
- clear();
-
- const QString fileName = url.toString();
-
- QTextStream stream(qmldata, QIODevice::ReadOnly);
- stream.setCodec("UTF-8");
- const QString code = stream.readAll();
-
- data = new QmlScriptParserJsASTData(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;
-
- QmlError 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<QmlScriptParser::TypeReference*> QmlScriptParser::referencedTypes() const
-{
- return _refTypes;
-}
-
-QList<QUrl> QmlScriptParser::referencedResources() const
-{
- return _refUrls;
-}
-
-Object *QmlScriptParser::tree() const
-{
- return root;
-}
-
-QList<QmlScriptParser::Import> QmlScriptParser::imports() const
-{
- return _imports;
-}
-
-QList<QmlError> QmlScriptParser::errors() const
-{
- return _errors;
-}
-
-void QmlScriptParser::clear()
-{
- if (root) {
- root->release();
- root = 0;
- }
- _imports.clear();
- qDeleteAll(_refTypes);
- _refTypes.clear();
- _errors.clear();
-
- if (data) {
- delete data;
- data = 0;
- }
-}
-
-QmlScriptParser::TypeReference *QmlScriptParser::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 QmlScriptParser::setTree(Object *tree)
-{
- Q_ASSERT(! root);
-
- root = tree;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h
deleted file mode 100644
index b420b9a822..0000000000
--- a/src/declarative/qml/qmlscriptparser_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 QMLSCRIPTPARSER_P_H
-#define QMLSCRIPTPARSER_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 "qmlparser_p.h"
-
-#include <QtCore/QList>
-#include <QtCore/QUrl>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QByteArray;
-
-class QmlScriptParserJsASTData;
-class QmlScriptParser
-{
-public:
- class Import
- {
- public:
- Import() : type(Library) {}
-
- enum Type { Library, File };
- Type type;
-
- QString uri;
- QString qualifier;
- QString version;
-
- QmlParser::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<QmlParser::Object*> refObjects;
- };
-
- QmlScriptParser();
- ~QmlScriptParser();
-
- bool parse(const QByteArray &data, const QUrl &url = QUrl());
-
- QList<TypeReference*> referencedTypes() const;
- QList<QUrl> referencedResources() const;
-
- QmlParser::Object *tree() const;
- QList<Import> imports() const;
-
- void clear();
-
- QList<QmlError> errors() const;
-
-// ### private:
- TypeReference *findOrCreateType(const QString &name);
- void setTree(QmlParser::Object *tree);
-
- void setScriptFile(const QString &filename) {_scriptFile = filename; }
- QString scriptFile() const { return _scriptFile; }
-
-// ### private:
- QList<QmlError> _errors;
-
- QmlParser::Object *root;
- QList<Import> _imports;
- QList<TypeReference*> _refTypes;
- QList<QUrl> _refUrls;
- QString _scriptFile;
- QmlScriptParserJsASTData *data;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLSCRIPTPARSER_P_H
diff --git a/src/declarative/qml/qmlscriptstring.cpp b/src/declarative/qml/qmlscriptstring.cpp
deleted file mode 100644
index a80f66bdb3..0000000000
--- a/src/declarative/qml/qmlscriptstring.cpp
+++ /dev/null
@@ -1,155 +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 "qmlscriptstring.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlScriptStringPrivate : public QSharedData
-{
-public:
- QmlScriptStringPrivate() : context(0), scope(0) {}
-
- QmlContext *context;
- QObject *scope;
- QString script;
-};
-
-/*!
-\class QmlScriptString
- \since 4.7
-\brief The QmlScriptString class encapsulates a script and its context.
-
-The QmlScriptString 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 QmlScriptString, 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.
-*/
-QmlScriptString::QmlScriptString()
-: d(new QmlScriptStringPrivate)
-{
-}
-
-/*!
-Copy \a other.
-*/
-QmlScriptString::QmlScriptString(const QmlScriptString &other)
-: d(other.d)
-{
-}
-
-/*!
-\internal
-*/
-QmlScriptString::~QmlScriptString()
-{
-}
-
-/*!
-Assign \a other to this.
-*/
-QmlScriptString &QmlScriptString::operator=(const QmlScriptString &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
-Return the context for the script.
-*/
-QmlContext *QmlScriptString::context() const
-{
- return d->context;
-}
-
-/*!
-Sets the \a context for the script.
-*/
-void QmlScriptString::setContext(QmlContext *context)
-{
- d->context = context;
-}
-
-/*!
-Returns the scope object for the script.
-*/
-QObject *QmlScriptString::scopeObject() const
-{
- return d->scope;
-}
-
-/*!
-Sets the scope \a object for the script.
-*/
-void QmlScriptString::setScopeObject(QObject *object)
-{
- d->scope = object;
-}
-
-/*!
-Returns the script text.
-*/
-QString QmlScriptString::script() const
-{
- return d->script;
-}
-
-/*!
-Sets the \a script text.
-*/
-void QmlScriptString::setScript(const QString &script)
-{
- d->script = script;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmlscriptstring.h b/src/declarative/qml/qmlscriptstring.h
deleted file mode 100644
index 1789eb515e..0000000000
--- a/src/declarative/qml/qmlscriptstring.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 QMLSCRIPTSTRING_H
-#define QMLSCRIPTSTRING_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 QmlContext;
-class QmlScriptStringPrivate;
-class Q_DECLARATIVE_EXPORT QmlScriptString
-{
-public:
- QmlScriptString();
- QmlScriptString(const QmlScriptString &);
- ~QmlScriptString();
-
- QmlScriptString &operator=(const QmlScriptString &);
-
- QmlContext *context() const;
- void setContext(QmlContext *);
-
- QObject *scopeObject() const;
- void setScopeObject(QObject *);
-
- QString script() const;
- void setScript(const QString &);
-
-private:
- QSharedDataPointer<QmlScriptStringPrivate> d;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlScriptString);
-
-QT_END_HEADER
-
-#endif // QMLSCRIPTSTRING_H
-
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp
deleted file mode 100644
index 4e0e0fb967..0000000000
--- a/src/declarative/qml/qmlsqldatabase.cpp
+++ /dev/null
@@ -1,428 +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 "qmlsqldatabase_p.h"
-
-#include "qmlengine.h"
-#include "qmlengine_p.h"
-#include "qmlrefcount_p.h"
-#include "qmlengine_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 QmlSqlQueryScriptClass: public QScriptClass {
-public:
- QmlSqlQueryScriptClass(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 QmlSqlQueryScriptClassPropertyIterator : 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)
-{
- QmlScriptEngine *qmlengine = static_cast<QmlScriptEngine*>(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,QmlEngine::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();
- QmlScriptEngine *qmlengine = static_cast<QmlScriptEngine*>(engine);
- if (!qmlengine->sqlQueryClass)
- qmlengine->sqlQueryClass = new QmlSqlQueryScriptClass(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,QmlEngine::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,QmlEngine::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,QmlEngine::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,QmlEngine::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,QmlEngine::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,QmlEngine::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/qmlsqldatabase_p.h b/src/declarative/qml/qmlsqldatabase_p.h
deleted file mode 100644
index 0fd275bba8..0000000000
--- a/src/declarative/qml/qmlsqldatabase_p.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 QMLSQLDATABASE_P_H
-#define QMLSQLDATABASE_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 // QMLSQLDATABASE_P_H
-
diff --git a/src/declarative/qml/qmlstringconverters.cpp b/src/declarative/qml/qmlstringconverters.cpp
deleted file mode 100644
index 6ba70d3a53..0000000000
--- a/src/declarative/qml/qmlstringconverters.cpp
+++ /dev/null
@@ -1,276 +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 "qmlstringconverters_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 QmlStringConverters::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 QmlStringConverters::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 QmlStringConverters::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 QmlStringConverters::dateFromString(const QString &s, bool *ok)
-{
- QDate d = QDate::fromString(s, Qt::ISODate);
- if (ok) *ok = d.isValid();
- return d;
-}
-
-QTime QmlStringConverters::timeFromString(const QString &s, bool *ok)
-{
- QTime t = QTime::fromString(s, Qt::ISODate);
- if (ok) *ok = t.isValid();
- return t;
-}
-
-QDateTime QmlStringConverters::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 QmlStringConverters::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 QmlStringConverters::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 QmlStringConverters::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 QmlStringConverters::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/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h
deleted file mode 100644
index c83a1de810..0000000000
--- a/src/declarative/qml/qmlstringconverters_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 QMLSTRINGCONVERTERS_P_H
-#define QMLSTRINGCONVERTERS_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 QmlStringConverters
-{
- 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 // QMLSTRINGCONVERTERS_P_H
diff --git a/src/declarative/qml/qmltypenamecache.cpp b/src/declarative/qml/qmltypenamecache.cpp
deleted file mode 100644
index eef3baea78..0000000000
--- a/src/declarative/qml/qmltypenamecache.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmltypenamecache_p.h"
-
-#include "qmlengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QmlTypeNameCache::QmlTypeNameCache(QmlEngine *e)
-: QmlCleanup(e), engine(e)
-{
-}
-
-QmlTypeNameCache::~QmlTypeNameCache()
-{
- clear();
-}
-
-void QmlTypeNameCache::clear()
-{
- qDeleteAll(stringCache);
- stringCache.clear();
- identifierCache.clear();
- engine = 0;
-}
-
-void QmlTypeNameCache::add(const QString &name, QmlType *type)
-{
- if (stringCache.contains(name))
- return;
-
- QmlEnginePrivate *ep = QmlEnginePrivate::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 QmlTypeNameCache::add(const QString &name, QmlTypeNameCache *typeNamespace)
-{
- if (stringCache.contains(name))
- return;
-
- QmlEnginePrivate *ep = QmlEnginePrivate::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();
-}
-
-QmlTypeNameCache::Data *QmlTypeNameCache::data(const QString &id) const
-{
- return stringCache.value(id);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmltypenamecache_p.h b/src/declarative/qml/qmltypenamecache_p.h
deleted file mode 100644
index e578277c6c..0000000000
--- a/src/declarative/qml/qmltypenamecache_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 QMLTYPENAMECACHE_P_H
-#define QMLTYPENAMECACHE_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 <private/qscriptdeclarativeclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlType;
-class QmlEngine;
-class QmlTypeNameCache : public QmlRefCount, public QmlCleanup
-{
-public:
- QmlTypeNameCache(QmlEngine *);
- virtual ~QmlTypeNameCache();
-
- struct Data {
- inline Data();
- inline ~Data();
- QmlType *type;
- QmlTypeNameCache *typeNamespace;
- };
-
- void add(const QString &, QmlType *);
- void add(const QString &, QmlTypeNameCache *);
-
- 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;
- QmlEngine *engine;
-};
-
-QmlTypeNameCache::Data::Data()
-: type(0), typeNamespace(0)
-{
-}
-
-QmlTypeNameCache::Data::~Data()
-{
- if (typeNamespace) typeNamespace->release();
-}
-
-QmlTypeNameCache::Data *QmlTypeNameCache::data(const QScriptDeclarativeClass::Identifier &id) const
-{
- return identifierCache.value(id);
-}
-
-QT_END_NAMESPACE
-
-#endif // QMLTYPENAMECACHE_P_H
-
diff --git a/src/declarative/qml/qmltypenamescriptclass.cpp b/src/declarative/qml/qmltypenamescriptclass.cpp
deleted file mode 100644
index 32a7a25d5d..0000000000
--- a/src/declarative/qml/qmltypenamescriptclass.cpp
+++ /dev/null
@@ -1,166 +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 "qmltypenamescriptclass_p.h"
-
-#include "qmlengine_p.h"
-#include "qmltypenamecache_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct TypeNameData : public QScriptDeclarativeClass::Object {
- TypeNameData(QObject *o, QmlType *t, QmlTypeNameScriptClass::TypeNameMode m) : object(o), type(t), typeNamespace(0), mode(m) {}
- TypeNameData(QObject *o, QmlTypeNameCache *n, QmlTypeNameScriptClass::TypeNameMode m) : object(o), type(0), typeNamespace(n), mode(m) {
- if (typeNamespace) typeNamespace->addref();
- }
- ~TypeNameData() {
- if (typeNamespace) typeNamespace->release();
- }
-
- QObject *object;
- QmlType *type;
- QmlTypeNameCache *typeNamespace;
- QmlTypeNameScriptClass::TypeNameMode mode;
-};
-
-QmlTypeNameScriptClass::QmlTypeNameScriptClass(QmlEngine *bindEngine)
-: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)),
- engine(bindEngine), object(0), type(0)
-{
-}
-
-QmlTypeNameScriptClass::~QmlTypeNameScriptClass()
-{
-}
-
-QScriptValue QmlTypeNameScriptClass::newObject(QObject *object, QmlType *type, TypeNameMode mode)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- return QScriptDeclarativeClass::newObject(scriptEngine, this, new TypeNameData(object, type, mode));
-}
-
-QScriptValue QmlTypeNameScriptClass::newObject(QObject *object, QmlTypeNameCache *ns, TypeNameMode mode)
-{
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
-
- return QScriptDeclarativeClass::newObject(scriptEngine, this, new TypeNameData(object, ns, mode));
-}
-
-QScriptClass::QueryFlags
-QmlTypeNameScriptClass::queryProperty(Object *obj, const Identifier &name,
- QScriptClass::QueryFlags flags)
-{
- Q_UNUSED(flags);
-
- TypeNameData *data = (TypeNameData *)obj;
-
- object = 0;
- type = 0;
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
-
- if (data->typeNamespace) {
-
- QmlTypeNameCache::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;
-}
-
-QmlTypeNameScriptClass::ScriptValue
-QmlTypeNameScriptClass::property(Object *obj, const Identifier &name)
-{
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- QScriptEngine *scriptEngine = QmlEnginePrivate::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 QmlTypeNameScriptClass::setProperty(Object *o, const Identifier &n, const QScriptValue &v)
-{
- Q_ASSERT(object);
- Q_ASSERT(!type);
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(engine);
- ep->objectClass->setProperty(((TypeNameData *)o)->object, n, v);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmltypenamescriptclass_p.h b/src/declarative/qml/qmltypenamescriptclass_p.h
deleted file mode 100644
index fd5752d965..0000000000
--- a/src/declarative/qml/qmltypenamescriptclass_p.h
+++ /dev/null
@@ -1,93 +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 QMLTYPENAMESCRIPTCLASS_P_H
-#define QMLTYPENAMESCRIPTCLASS_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 <QtScript/qscriptclass.h>
-
-#include <private/qmlscriptclass_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlType;
-class QmlTypeNameCache;
-class QmlTypeNameScriptClass : public QmlScriptClass
-{
-public:
- QmlTypeNameScriptClass(QmlEngine *);
- ~QmlTypeNameScriptClass();
-
- enum TypeNameMode { IncludeEnums, ExcludeEnums };
- QScriptValue newObject(QObject *, QmlType *, TypeNameMode = IncludeEnums);
- QScriptValue newObject(QObject *, QmlTypeNameCache *, 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:
- QmlEngine *engine;
- QObject *object;
- QmlType *type;
- quint32 enumValue;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLTYPENAMESCRIPTCLASS_P_H
-
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
deleted file mode 100644
index 33c3e7667c..0000000000
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ /dev/null
@@ -1,636 +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 "qmlvaluetype_p.h"
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QmlValueTypeFactory::QmlValueTypeFactory()
-{
- // ### Optimize
- for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
- valueTypes[ii] = valueType(ii);
-}
-
-QmlValueTypeFactory::~QmlValueTypeFactory()
-{
- for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
- delete valueTypes[ii];
-}
-
-QmlValueType *QmlValueTypeFactory::valueType(int t)
-{
- switch (t) {
- case QVariant::Point:
- return new QmlPointValueType;
- case QVariant::PointF:
- return new QmlPointFValueType;
- case QVariant::Size:
- return new QmlSizeValueType;
- case QVariant::SizeF:
- return new QmlSizeFValueType;
- case QVariant::Rect:
- return new QmlRectValueType;
- case QVariant::RectF:
- return new QmlRectFValueType;
- case QVariant::Vector3D:
- return new QmlVector3DValueType;
- case QVariant::Font:
- return new QmlFontValueType;
- default:
- return 0;
- }
-}
-
-QmlValueType::QmlValueType(QObject *parent)
-: QObject(parent)
-{
-}
-
-QmlPointFValueType::QmlPointFValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlPointFValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &point, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlPointFValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &point, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlPointFValueType::value()
-{
- return QVariant(point);
-}
-
-void QmlPointFValueType::setValue(QVariant value)
-{
- point = qvariant_cast<QPointF>(value);
-}
-
-qreal QmlPointFValueType::x() const
-{
- return point.x();
-}
-
-qreal QmlPointFValueType::y() const
-{
- return point.y();
-}
-
-void QmlPointFValueType::setX(qreal x)
-{
- point.setX(x);
-}
-
-void QmlPointFValueType::setY(qreal y)
-{
- point.setY(y);
-}
-
-QmlPointValueType::QmlPointValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlPointValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &point, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlPointValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &point, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlPointValueType::value()
-{
- return QVariant(point);
-}
-
-void QmlPointValueType::setValue(QVariant value)
-{
- point = qvariant_cast<QPoint>(value);
-}
-
-int QmlPointValueType::x() const
-{
- return point.x();
-}
-
-int QmlPointValueType::y() const
-{
- return point.y();
-}
-
-void QmlPointValueType::setX(int x)
-{
- point.setX(x);
-}
-
-void QmlPointValueType::setY(int y)
-{
- point.setY(y);
-}
-
-QmlSizeFValueType::QmlSizeFValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlSizeFValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &size, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlSizeFValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &size, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlSizeFValueType::value()
-{
- return QVariant(size);
-}
-
-void QmlSizeFValueType::setValue(QVariant value)
-{
- size = qvariant_cast<QSizeF>(value);
-}
-
-qreal QmlSizeFValueType::width() const
-{
- return size.width();
-}
-
-qreal QmlSizeFValueType::height() const
-{
- return size.height();
-}
-
-void QmlSizeFValueType::setWidth(qreal w)
-{
- size.setWidth(w);
-}
-
-void QmlSizeFValueType::setHeight(qreal h)
-{
- size.setHeight(h);
-}
-
-QmlSizeValueType::QmlSizeValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlSizeValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &size, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlSizeValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &size, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlSizeValueType::value()
-{
- return QVariant(size);
-}
-
-void QmlSizeValueType::setValue(QVariant value)
-{
- size = qvariant_cast<QSize>(value);
-}
-
-int QmlSizeValueType::width() const
-{
- return size.width();
-}
-
-int QmlSizeValueType::height() const
-{
- return size.height();
-}
-
-void QmlSizeValueType::setWidth(int w)
-{
- size.setWidth(w);
-}
-
-void QmlSizeValueType::setHeight(int h)
-{
- size.setHeight(h);
-}
-
-QmlRectFValueType::QmlRectFValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlRectFValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &rect, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlRectFValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &rect, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlRectFValueType::value()
-{
- return QVariant(rect);
-}
-
-void QmlRectFValueType::setValue(QVariant value)
-{
- rect = qvariant_cast<QRectF>(value);
-}
-
-qreal QmlRectFValueType::x() const
-{
- return rect.x();
-}
-
-qreal QmlRectFValueType::y() const
-{
- return rect.y();
-}
-
-void QmlRectFValueType::setX(qreal x)
-{
- rect.moveLeft(x);
-}
-
-void QmlRectFValueType::setY(qreal y)
-{
- rect.moveTop(y);
-}
-
-qreal QmlRectFValueType::width() const
-{
- return rect.width();
-}
-
-qreal QmlRectFValueType::height() const
-{
- return rect.height();
-}
-
-void QmlRectFValueType::setWidth(qreal w)
-{
- rect.setWidth(w);
-}
-
-void QmlRectFValueType::setHeight(qreal h)
-{
- rect.setHeight(h);
-}
-
-QmlRectValueType::QmlRectValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlRectValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &rect, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlRectValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &rect, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlRectValueType::value()
-{
- return QVariant(rect);
-}
-
-void QmlRectValueType::setValue(QVariant value)
-{
- rect = qvariant_cast<QRect>(value);
-}
-
-int QmlRectValueType::x() const
-{
- return rect.x();
-}
-
-int QmlRectValueType::y() const
-{
- return rect.y();
-}
-
-void QmlRectValueType::setX(int x)
-{
- rect.moveLeft(x);
-}
-
-void QmlRectValueType::setY(int y)
-{
- rect.moveTop(y);
-}
-
-int QmlRectValueType::width() const
-{
- return rect.width();
-}
-
-int QmlRectValueType::height() const
-{
- return rect.height();
-}
-
-void QmlRectValueType::setWidth(int w)
-{
- rect.setWidth(w);
-}
-
-void QmlRectValueType::setHeight(int h)
-{
- rect.setHeight(h);
-}
-
-QmlVector3DValueType::QmlVector3DValueType(QObject *parent)
-: QmlValueType(parent)
-{
-}
-
-void QmlVector3DValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &vector, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlVector3DValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &vector, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlVector3DValueType::value()
-{
- return QVariant(vector);
-}
-
-void QmlVector3DValueType::setValue(QVariant value)
-{
- vector = qvariant_cast<QVector3D>(value);
-}
-
-qreal QmlVector3DValueType::x() const
-{
- return vector.x();
-}
-
-qreal QmlVector3DValueType::y() const
-{
- return vector.y();
-}
-
-qreal QmlVector3DValueType::z() const
-{
- return vector.z();
-}
-
-void QmlVector3DValueType::setX(qreal x)
-{
- vector.setX(x);
-}
-
-void QmlVector3DValueType::setY(qreal y)
-{
- vector.setY(y);
-}
-
-void QmlVector3DValueType::setZ(qreal z)
-{
- vector.setZ(z);
-}
-
-QmlFontValueType::QmlFontValueType(QObject *parent)
-: QmlValueType(parent), hasPixelSize(false)
-{
-}
-
-void QmlFontValueType::read(QObject *obj, int idx)
-{
- void *a[] = { &font, 0 };
- QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
-}
-
-void QmlFontValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
-{
- int status = -1;
- void *a[] = { &font, 0, &status, &flags };
- QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
-}
-
-QVariant QmlFontValueType::value()
-{
- return QVariant(font);
-}
-
-void QmlFontValueType::setValue(QVariant value)
-{
- font = qvariant_cast<QFont>(value);
-}
-
-
-QString QmlFontValueType::family() const
-{
- return font.family();
-}
-
-void QmlFontValueType::setFamily(const QString &family)
-{
- font.setFamily(family);
-}
-
-bool QmlFontValueType::bold() const
-{
- return font.bold();
-}
-
-void QmlFontValueType::setBold(bool b)
-{
- font.setBold(b);
-}
-
-QmlFontValueType::FontWeight QmlFontValueType::weight() const
-{
- return (QmlFontValueType::FontWeight)font.weight();
-}
-
-void QmlFontValueType::setWeight(QmlFontValueType::FontWeight w)
-{
- font.setWeight((QFont::Weight)w);
-}
-
-bool QmlFontValueType::italic() const
-{
- return font.italic();
-}
-
-void QmlFontValueType::setItalic(bool b)
-{
- font.setItalic(b);
-}
-
-bool QmlFontValueType::underline() const
-{
- return font.underline();
-}
-
-void QmlFontValueType::setUnderline(bool b)
-{
- font.setUnderline(b);
-}
-
-bool QmlFontValueType::overline() const
-{
- return font.overline();
-}
-
-void QmlFontValueType::setOverline(bool b)
-{
- font.setOverline(b);
-}
-
-bool QmlFontValueType::strikeout() const
-{
- return font.strikeOut();
-}
-
-void QmlFontValueType::setStrikeout(bool b)
-{
- font.setStrikeOut(b);
-}
-
-qreal QmlFontValueType::pointSize() const
-{
- return font.pointSizeF();
-}
-
-void QmlFontValueType::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 QmlFontValueType::pixelSize() const
-{
- return font.pixelSize();
-}
-
-void QmlFontValueType::setPixelSize(int size)
-{
- if (size >=0) {
- font.setPixelSize(size);
- hasPixelSize = true;
- } else {
- hasPixelSize = false;
- }
-}
-
-QmlFontValueType::Capitalization QmlFontValueType::capitalization() const
-{
- return (QmlFontValueType::Capitalization)font.capitalization();
-}
-
-void QmlFontValueType::setCapitalization(QmlFontValueType::Capitalization c)
-{
- font.setCapitalization((QFont::Capitalization)c);
-}
-
-qreal QmlFontValueType::letterSpacing() const
-{
- return font.letterSpacing();
-}
-
-void QmlFontValueType::setLetterSpacing(qreal size)
-{
- font.setLetterSpacing(QFont::PercentageSpacing, size);
-}
-
-qreal QmlFontValueType::wordSpacing() const
-{
- return font.wordSpacing();
-}
-
-void QmlFontValueType::setWordSpacing(qreal size)
-{
- font.setWordSpacing(size);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
deleted file mode 100644
index 0a152e8ab8..0000000000
--- a/src/declarative/qml/qmlvaluetype_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 QMLVALUETYPE_P_H
-#define QMLVALUETYPE_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 <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qfont.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_DECLARATIVE_EXPORT QmlValueType : public QObject
-{
- Q_OBJECT
-public:
- QmlValueType(QObject *parent = 0);
- virtual void read(QObject *, int) = 0;
- virtual void write(QObject *, int, QmlMetaProperty::WriteFlags flags) = 0;
- virtual QVariant value() = 0;
- virtual void setValue(QVariant) = 0;
-};
-
-class Q_DECLARATIVE_EXPORT QmlValueTypeFactory
-{
-public:
- QmlValueTypeFactory();
- ~QmlValueTypeFactory();
- static QmlValueType *valueType(int);
-
- QmlValueType *valueTypes[QVariant::UserType - 1];
- QmlValueType *operator[](int idx) const { return valueTypes[idx]; }
-};
-
-class Q_AUTOTEST_EXPORT QmlPointFValueType : public QmlValueType
-{
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_OBJECT
-public:
- QmlPointFValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlPointValueType : public QmlValueType
-{
- Q_PROPERTY(int x READ x WRITE setX)
- Q_PROPERTY(int y READ y WRITE setY)
- Q_OBJECT
-public:
- QmlPointValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlSizeFValueType : public QmlValueType
-{
- Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_OBJECT
-public:
- QmlSizeFValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlSizeValueType : public QmlValueType
-{
- Q_PROPERTY(int width READ width WRITE setWidth)
- Q_PROPERTY(int height READ height WRITE setHeight)
- Q_OBJECT
-public:
- QmlSizeValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlRectFValueType : public QmlValueType
-{
- 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:
- QmlRectFValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlRectValueType : public QmlValueType
-{
- 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:
- QmlRectValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlVector3DValueType : public QmlValueType
-{
- 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:
- QmlVector3DValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 QmlFontValueType : public QmlValueType
-{
- 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 };
-
- QmlFontValueType(QObject *parent = 0);
-
- virtual void read(QObject *, int);
- virtual void write(QObject *, int, QmlMetaProperty::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 // QMLVALUETYPE_P_H
diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp
deleted file mode 100644
index 0a92014db4..0000000000
--- a/src/declarative/qml/qmlvaluetypescriptclass.cpp
+++ /dev/null
@@ -1,148 +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 "qmlvaluetypescriptclass_p.h"
-
-#include "qmlengine_p.h"
-#include "qmlguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-struct QmlValueTypeReference : public QScriptDeclarativeClass::Object {
- QmlValueType *type;
- QmlGuard<QObject> object;
- int property;
-};
-
-QmlValueTypeScriptClass::QmlValueTypeScriptClass(QmlEngine *bindEngine)
-: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine)
-{
-}
-
-QmlValueTypeScriptClass::~QmlValueTypeScriptClass()
-{
-}
-
-QScriptValue QmlValueTypeScriptClass::newObject(QObject *object, int coreIndex, QmlValueType *type)
-{
- QmlValueTypeReference *ref = new QmlValueTypeReference;
- ref->type = type;
- ref->object = object;
- ref->property = coreIndex;
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- return QScriptDeclarativeClass::newObject(scriptEngine, this, ref);
-}
-
-QScriptClass::QueryFlags
-QmlValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name,
- QScriptClass::QueryFlags)
-{
- QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(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;
-}
-
-QmlValueTypeScriptClass::ScriptValue QmlValueTypeScriptClass::property(Object *obj, const Identifier &)
-{
- QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
-
- QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
- ref->type->read(ref->object, ref->property);
- QVariant rv = p.read(ref->type);
-
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- return Value(scriptEngine, static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv));
-}
-
-void QmlValueTypeScriptClass::setProperty(Object *obj, const Identifier &,
- const QScriptValue &value)
-{
- QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
-
- QVariant v = QmlScriptClass::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 QmlValueTypeScriptClass::toVariant(Object *obj, bool *ok)
-{
- QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj);
-
- if (ok) *ok = true;
-
- if (ref->object) {
- ref->type->read(ref->object, ref->property);
- return ref->type->value();
- } else {
- return QVariant();
- }
-}
-
-QVariant QmlValueTypeScriptClass::toVariant(const QScriptValue &value)
-{
- Q_ASSERT(scriptClass(value) == this);
-
- return toVariant(object(value), 0);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/qml/qmlvaluetypescriptclass_p.h b/src/declarative/qml/qmlvaluetypescriptclass_p.h
deleted file mode 100644
index 12aef49b04..0000000000
--- a/src/declarative/qml/qmlvaluetypescriptclass_p.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 QMLVALUETYPESCRIPTCLASS_P_H
-#define QMLVALUETYPESCRIPTCLASS_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>
-
-QT_BEGIN_NAMESPACE
-
-class QmlEngine;
-class QmlValueType;
-class QmlValueTypeScriptClass : public QmlScriptClass
-{
-public:
- QmlValueTypeScriptClass(QmlEngine *);
- ~QmlValueTypeScriptClass();
-
- QScriptValue newObject(QObject *object, int coreIndex, QmlValueType *);
-
- 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:
- QmlEngine *engine;
- int m_lastIndex;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLVALUETYPESCRIPTCLASS_P_H
-
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
deleted file mode 100644
index 8655809dc4..0000000000
--- a/src/declarative/qml/qmlvme.cpp
+++ /dev/null
@@ -1,851 +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 "qmlvme_p.h"
-
-#include "qmlcompiler_p.h"
-#include "qmlboundsignal_p.h"
-#include "qmlstringconverters_p.h"
-#include "qmetaobjectbuilder_p.h"
-#include "qmldeclarativedata_p.h"
-#include "qml.h"
-#include "qmlcustomparser_p.h"
-#include "qmlengine.h"
-#include "qmlcontext.h"
-#include "qmlcomponent.h"
-#include "qmlbinding.h"
-#include "qmlengine_p.h"
-#include "qmlcomponent_p.h"
-#include "qmlvmemetaobject_p.h"
-#include "qmlbinding_p.h"
-#include "qmlcontext_p.h"
-#include "qmlcompiledbindings_p.h"
-#include "qmlglobal_p.h"
-#include "qmlscriptstring.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
-
-QmlVME::QmlVME()
-{
-}
-
-#define VME_EXCEPTION(desc) \
- { \
- QmlError 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;
- QmlListProperty<void> qListProperty;
-};
-
-QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledData *comp,
- int start, int count,
- const QBitField &bindingSkipList)
-{
- QmlVMEStack<QObject *> stack;
-
- if (start == -1) start = 0;
- if (count == -1) count = comp->bytecode.count();
-
- return run(stack, ctxt, comp, start, count, bindingSkipList);
-}
-
-void QmlVME::runDeferred(QObject *object)
-{
- QmlDeclarativeData *data = QmlDeclarativeData::get(object);
-
- if (!data || !data->context || !data->deferredComponent)
- return;
-
- QmlContext *ctxt = data->context;
- QmlCompiledData *comp = data->deferredComponent;
- int start = data->deferredIdx + 1;
- int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount;
- QmlVMEStack<QObject *> stack;
- stack.push(object);
-
- run(stack, ctxt, comp, start, count, QBitField());
-}
-
-QObject *QmlVME::run(QmlVMEStack<QObject *> &stack, QmlContext *ctxt,
- QmlCompiledData *comp,
- int start, int count,
- const QBitField &bindingSkipList)
-{
- Q_ASSERT(comp);
- Q_ASSERT(ctxt);
- const QList<QmlCompiledData::TypeReference> &types = comp->types;
- const QList<QString> &primitives = comp->primitives;
- const QList<QByteArray> &datas = comp->datas;
- const QList<QmlCompiledData::CustomTypeData> &customTypeData = comp->customTypeData;
- const QList<int> &intData = comp->intData;
- const QList<float> &floatData = comp->floatData;
- const QList<QmlPropertyCache *> &propertyCaches = comp->propertyCaches;
- const QList<QmlParser::Object::ScriptBlock> &scripts = comp->scripts;
- const QList<QUrl> &urls = comp->urls;
-
- QmlEnginePrivate::SimpleList<QmlAbstractBinding> bindValues;
- QmlEnginePrivate::SimpleList<QmlParserStatus> parserStatus;
-
- QmlVMEStack<ListInstance> qliststack;
-
- vmeErrors.clear();
- QmlEnginePrivate *ep = QmlEnginePrivate::get(ctxt->engine());
- QmlContextPrivate *cp = (QmlContextPrivate *)QObjectPrivate::get(ctxt);
-
- int status = -1; //for dbus
- QmlMetaProperty::WriteFlags flags = QmlMetaProperty::BypassInterceptor;
-
- for (int ii = start; !isError() && ii < (start + count); ++ii) {
- const QmlInstruction &instr = comp->bytecode.at(ii);
-
- switch(instr.type) {
- case QmlInstruction::Init:
- {
- if (instr.init.bindingsSize)
- bindValues = QmlEnginePrivate::SimpleList<QmlAbstractBinding>(instr.init.bindingsSize);
- if (instr.init.parserStatusSize)
- parserStatus = QmlEnginePrivate::SimpleList<QmlParserStatus>(instr.init.parserStatusSize);
- if (instr.init.contextCache != -1)
- cp->setIdPropertyData(comp->contextCaches.at(instr.init.contextCache));
- if (instr.init.compiledBinding != -1)
- cp->optimizedBindings = new QmlCompiledBindings(datas.at(instr.init.compiledBinding).constData(), ctxt);
- }
- break;
-
- case QmlInstruction::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("QmlVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className)));
- }
-
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(o);
- Q_ASSERT(ddata);
- ddata->outerContext = ctxt;
- ddata->lineNumber = instr.line;
- ddata->columnNumber = instr.create.column;
-
- if (instr.create.data != -1) {
- QmlCustomParser *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 {
- QmlGraphics_setParent_noEvent(o, parent);
- // o->setParent(parent);
- }
- }
- stack.push(o);
- }
- break;
-
- case QmlInstruction::SetId:
- {
- QObject *target = stack.top();
- cp->setIdProperty(instr.setId.index, target);
- }
- break;
-
-
- case QmlInstruction::SetDefault:
- {
- QObject *target = stack.top();
- ctxt->addDefaultObject(target);
- }
- break;
-
- case QmlInstruction::CreateComponent:
- {
- QObject *qcomp = new QmlComponent(ctxt->engine(), comp, ii + 1, instr.createComponent.count, stack.isEmpty() ? 0 : stack.top());
-
- QmlEngine::setContextForObject(qcomp, ctxt);
- QmlDeclarativeData *ddata = QmlDeclarativeData::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 QmlInstruction::StoreMetaObject:
- {
- QObject *target = stack.top();
-
- QMetaObject mo;
- const QByteArray &metadata = datas.at(instr.storeMeta.data);
- QMetaObjectBuilder::fromRelocatableData(&mo, 0, metadata);
-
- const QmlVMEMetaData *data =
- (const QmlVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData();
-
- (void)new QmlVMEMetaObject(target, &mo, data, comp);
-
- QmlDeclarativeData *ddata = QmlDeclarativeData::get(target, true);
- if (ddata->propertyCache) ddata->propertyCache->release();
- ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache);
- ddata->propertyCache->addref();
- }
- break;
-
- case QmlInstruction::StoreVariant:
- {
- QObject *target = stack.top();
- // XXX - can be more efficient
- QVariant v = QmlStringConverters::variantFromString(primitives.at(instr.storeString.value));
- void *a[] = { &v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeString.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::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 QmlInstruction::AssignCustomType:
- {
- QObject *target = stack.top();
- QmlCompiledData::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex);
- const QString &primitive = primitives.at(data.index);
- QmlMetaType::StringConverter converter =
- QmlMetaType::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("QmlVME","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 QmlInstruction::AssignSignalObject:
- {
- // XXX optimize
-
- QObject *assign = stack.pop();
- QObject *target = stack.top();
- int sigIdx = instr.assignSignalObject.signal;
- const QByteArray &pr = datas.at(sigIdx);
-
- QmlMetaProperty prop(target, QString::fromUtf8(pr));
- if (prop.type() & QmlMetaProperty::SignalProperty) {
-
- QMetaMethod method = QmlMetaType::defaultMethod(assign);
- if (method.signature() == 0)
- VME_EXCEPTION(QCoreApplication::translate("QmlVME","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("QmlVME","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("QmlVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr)));
- }
-
-
- }
- break;
-
- case QmlInstruction::StoreSignal:
- {
- QObject *target = stack.top();
- // XXX scope
- QMetaMethod signal =
- target->metaObject()->method(instr.storeSignal.signalIndex);
-
- QmlBoundSignal *bs = new QmlBoundSignal(target, signal, target);
- QmlExpression *expr =
- new QmlExpression(ctxt, primitives.at(instr.storeSignal.value), target);
- expr->setSourceLocation(comp->name, instr.line);
- bs->setExpression(expr);
- }
- break;
-
- case QmlInstruction::StoreScript:
- {
- QObject *target = stack.top();
- cp->addScript(scripts.at(instr.storeScript.value), target);
- }
- break;
-
- case QmlInstruction::StoreScriptString:
- {
- QObject *target = stack.top();
- QObject *scope = stack.at(stack.count() - 1 - instr.storeScriptString.scope);
- QmlScriptString 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 QmlInstruction::BeginObject:
- {
- QObject *target = stack.top();
- QmlParserStatus *status = reinterpret_cast<QmlParserStatus *>(reinterpret_cast<char *>(target) + instr.begin.castValue);
- parserStatus.append(status);
- status->d = &parserStatus.values[parserStatus.count - 1];
-
- status->classBegin();
- }
- break;
-
- case QmlInstruction::StoreBinding:
- {
- QObject *target =
- stack.at(stack.count() - 1 - instr.assignBinding.owner);
- QObject *context =
- stack.at(stack.count() - 1 - instr.assignBinding.context);
-
- QmlMetaProperty mp =
- QmlMetaPropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt);
-
- int coreIndex = mp.coreIndex();
-
- if (stack.count() == 1 && bindingSkipList.testBit(coreIndex))
- break;
-
- QmlBinding *bind = new QmlBinding((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 QmlInstruction::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;
-
- QmlAbstractBinding *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 QmlInstruction::StoreValueSource:
- {
- QObject *obj = stack.pop();
- QmlPropertyValueSource *vs = reinterpret_cast<QmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue);
- QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner);
-
- QmlMetaProperty prop =
- QmlMetaPropertyPrivate::restore(datas.at(instr.assignValueSource.property), target, ctxt);
- obj->setParent(target);
- vs->setTarget(prop);
- }
- break;
-
- case QmlInstruction::StoreValueInterceptor:
- {
- QObject *obj = stack.pop();
- QmlPropertyValueInterceptor *vi = reinterpret_cast<QmlPropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue);
- QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner);
- QmlMetaProperty prop =
- QmlMetaPropertyPrivate::restore(datas.at(instr.assignValueInterceptor.property), target, ctxt);
- obj->setParent(target);
- vi->setTarget(prop);
- QmlVMEMetaObject *mo = static_cast<QmlVMEMetaObject *>((QMetaObject*)target->metaObject());
- mo->registerInterceptor(prop.coreIndex(), prop.valueTypeCoreIndex(), vi);
- }
- break;
-
- case QmlInstruction::StoreObjectQList:
- {
- QObject *assign = stack.pop();
-
- const ListInstance &list = qliststack.top();
- list.qListProperty.append((QmlListProperty<void>*)&list.qListProperty, assign);
- }
- break;
-
- case QmlInstruction::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 = QmlMetaType::interfaceIId(type);
- if (iid)
- ptr = assign->qt_metacast(iid);
- if (!ptr)
- VME_EXCEPTION(QCoreApplication::translate("QmlVME","Cannot assign object to list"));
-
-
- list.qListProperty.append((QmlListProperty<void>*)&list.qListProperty, ptr);
- }
- break;
-
- case QmlInstruction::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 QmlInstruction::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 = QmlMetaType::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("QmlVME","Cannot assign object to interface property"));
- }
- break;
-
- case QmlInstruction::FetchAttached:
- {
- QObject *target = stack.top();
-
- QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.fetchAttached.id, target);
-
- if (!qmlObject)
- VME_EXCEPTION(QCoreApplication::translate("QmlVME","Unable to create attached object"));
-
- stack.push(qmlObject);
- }
- break;
-
- case QmlInstruction::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 QmlInstruction::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("QmlVME","Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.fetch.property).name())));
-
- stack.push(obj);
- }
- break;
-
- case QmlInstruction::PopQList:
- {
- qliststack.pop();
- }
- break;
-
- case QmlInstruction::Defer:
- {
- if (instr.defer.deferCount) {
- QObject *target = stack.top();
- QmlDeclarativeData *data =
- QmlDeclarativeData::get(target, true);
- comp->addref();
- data->deferredComponent = comp;
- data->deferredIdx = ii;
- ii += instr.defer.deferCount;
- }
- }
- break;
-
- case QmlInstruction::PopFetchedObject:
- {
- stack.pop();
- }
- break;
-
- case QmlInstruction::FetchValueType:
- {
- QObject *target = stack.top();
- QmlValueType *valueHandler =
- ep->valueTypes[instr.fetchValue.type];
- valueHandler->read(target, instr.fetchValue.property);
- stack.push(valueHandler);
- }
- break;
-
- case QmlInstruction::PopValueType:
- {
- QmlValueType *valueHandler =
- static_cast<QmlValueType *>(stack.pop());
- QObject *target = stack.top();
- valueHandler->write(target, instr.fetchValue.property, QmlMetaProperty::BypassInterceptor);
- }
- break;
-
- default:
- qFatal("QmlCompiledData: Internal error - unknown instruction %d", instr.type);
- break;
- }
- }
-
- if (isError()) {
- if (!stack.isEmpty()) {
- delete stack.at(0);
- }
-
- QmlEnginePrivate::clear(bindValues);
- QmlEnginePrivate::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 QmlVME::isError() const
-{
- return !vmeErrors.isEmpty();
-}
-
-QList<QmlError> QmlVME::errors() const
-{
- return vmeErrors;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h
deleted file mode 100644
index ae7dd7f9a2..0000000000
--- a/src/declarative/qml/qmlvme_p.h
+++ /dev/null
@@ -1,119 +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 QMLVME_P_H
-#define QMLVME_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 "qbitfield_p.h"
-
-#include <QtCore/QString>
-#include <QtCore/QStack>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QmlInstruction;
-class QmlCompiledData;
-class QmlCompiledData;
-class QmlContext;
-
-template<typename T, int N = 128>
-class QmlVMEStack {
-public:
- QmlVMEStack() : index(-1), maxSize(N), data(fixedData) {}
- ~QmlVMEStack() { 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 QmlVME
-{
-public:
- QmlVME();
-
- QObject *run(QmlContext *, QmlCompiledData *,
- int start = -1, int count = -1,
- const QBitField & = QBitField());
- void runDeferred(QObject *);
-
- bool isError() const;
- QList<QmlError> errors() const;
-
-private:
- QObject *run(QmlVMEStack<QObject *> &, QmlContext *, QmlCompiledData *,
- int start, int count, const QBitField &);
- QList<QmlError> vmeErrors;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLVME_P_H
diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp
deleted file mode 100644
index 4886680e15..0000000000
--- a/src/declarative/qml/qmlvmemetaobject.cpp
+++ /dev/null
@@ -1,366 +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 "qmlvmemetaobject_p.h"
-
-#include "qml.h"
-#include "qmlrefcount_p.h"
-#include "qmlexpression.h"
-#include "qmlexpression_p.h"
-#include "qmlcontext_p.h"
-
-#include <QColor>
-#include <QDate>
-#include <QtCore/qlist.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj,
- const QMetaObject *other,
- const QmlVMEMetaData *meta,
- QmlCompiledData *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<QmlListProperty<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(QmlListProperty<QObject>(obj, listProperties.last(), list_append,
- list_count, list_at, list_clear));
- } else if (t != -1) {
- data[ii] = QVariant((QVariant::Type)t);
- }
- }
-}
-
-QmlVMEMetaObject::~QmlVMEMetaObject()
-{
- compiledData->release();
- delete parent;
- qDeleteAll(listProperties);
- delete [] data;
- delete [] methods;
-}
-
-int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
-{
- int id = _id;
- if(c == QMetaObject::WriteProperty) {
- int flags = *reinterpret_cast<int*>(a[3]);
- if (!(flags & QmlMetaProperty::BypassInterceptor)
- && !aInterceptors.isEmpty()
- && aInterceptors.testBit(id)) {
- QPair<int, QmlPropertyValueInterceptor*> pair = interceptors.value(id);
- int valueIndex = pair.first;
- QmlPropertyValueInterceptor *vi = pair.second;
- int type = property(id).userType();
-
- if (type != QVariant::Invalid) {
- if (valueIndex != -1) {
- QmlEnginePrivate *ep = ctxt?QmlEnginePrivate::get(ctxt->engine()):0;
- QmlValueType *valueType = 0;
- if (ep) valueType = ep->valueTypes[type];
- else valueType = QmlValueTypeFactory::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<QmlListProperty<QObject> >()) {
- *reinterpret_cast<QmlListProperty<QObject> *>(a[0]) =
- data[id].value<QmlListProperty<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) {
-
- QmlVMEMetaData::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;
- QmlContextPrivate *ctxtPriv =
- (QmlContextPrivate *)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
-
- QmlEnginePrivate *ep = QmlEnginePrivate::get(ctxt->engine());
-
- QScriptValue function = method(id);
-
- QScriptValueList args;
- QmlVMEMetaData::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 QmlVMEMetaObject::method(int index)
-{
- if (!methods)
- methods = new QScriptValue[metaData->methodCount];
-
- if (!methods[index].isValid()) {
- QmlVMEMetaData::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] = QmlExpressionPrivate::evalInObjectScope(ctxt, object, code);
- }
-
- return methods[index];
-}
-
-void QmlVMEMetaObject::listChanged(int id)
-{
- activate(object, methodOffset + id, 0);
-}
-
-void QmlVMEMetaObject::list_append(QmlListProperty<QObject> *prop, QObject *o)
-{
- List *list = static_cast<List *>(prop->data);
- list->append(o);
- QMetaObject::activate(prop->object, list->notifyIndex, 0);
-}
-
-int QmlVMEMetaObject::list_count(QmlListProperty<QObject> *prop)
-{
- return static_cast<List *>(prop->data)->count();
-}
-
-QObject *QmlVMEMetaObject::list_at(QmlListProperty<QObject> *prop, int index)
-{
- return static_cast<List *>(prop->data)->at(index);
-}
-
-void QmlVMEMetaObject::list_clear(QmlListProperty<QObject> *prop)
-{
- List *list = static_cast<List *>(prop->data);
- list->clear();
- QMetaObject::activate(prop->object, list->notifyIndex, 0);
-}
-
-void QmlVMEMetaObject::registerInterceptor(int index, int valueIndex, QmlPropertyValueInterceptor *interceptor)
-{
- if (aInterceptors.isEmpty())
- aInterceptors.resize(propertyCount() + metaData->propertyCount);
- aInterceptors.setBit(index);
- interceptors.insert(index, qMakePair(valueIndex, interceptor));
-}
-
-QScriptValue QmlVMEMetaObject::vmeMethod(int index)
-{
- if (index < methodOffset) {
- Q_ASSERT(parent);
- return static_cast<QmlVMEMetaObject *>(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/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h
deleted file mode 100644
index 3eb776e00a..0000000000
--- a/src/declarative/qml/qmlvmemetaobject_p.h
+++ /dev/null
@@ -1,157 +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 QMLVMEMETAOBJECT_P_H
-#define QMLVMEMETAOBJECT_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/QMetaObject>
-#include <QtCore/QBitArray>
-#include <QtCore/QPair>
-
-#include <private/qobject_p.h>
-
-#include "qmlguard_p.h"
-#include "qmlcompiler_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#define QML_ALIAS_FLAG_PTR 0x00000001
-
-struct QmlVMEMetaData
-{
- 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(QmlVMEMetaData));
- }
-
- AliasData *aliasData() const {
- return (AliasData *)(propertyData() + propertyCount);
- }
-
- MethodData *methodData() const {
- return (MethodData *)(aliasData() + aliasCount);
- }
-};
-
-class QmlRefCount;
-class QmlVMEMetaObject : public QAbstractDynamicMetaObject
-{
-public:
- QmlVMEMetaObject(QObject *obj, const QMetaObject *other, const QmlVMEMetaData *data,
- QmlCompiledData *compiledData);
- ~QmlVMEMetaObject();
-
- void registerInterceptor(int index, int valueIndex, QmlPropertyValueInterceptor *interceptor);
- QScriptValue vmeMethod(int index);
-protected:
- virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
-
-private:
- QObject *object;
- QmlCompiledData *compiledData;
- QmlGuard<QmlContext> ctxt;
-
- const QmlVMEMetaData *metaData;
- int propOffset;
- int methodOffset;
-
- QVariant *data;
- QBitArray aConnected;
- QBitArray aInterceptors;
- QHash<int, QPair<int, QmlPropertyValueInterceptor*> > 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(QmlListProperty<QObject> *, QObject *);
- static int list_count(QmlListProperty<QObject> *);
- static QObject *list_at(QmlListProperty<QObject> *, int);
- static void list_clear(QmlListProperty<QObject> *);
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLVMEMETAOBJECT_P_H
diff --git a/src/declarative/qml/qmlwatcher.cpp b/src/declarative/qml/qmlwatcher.cpp
deleted file mode 100644
index 59503de87f..0000000000
--- a/src/declarative/qml/qmlwatcher.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmlwatcher_p.h"
-
-#include "qmlexpression.h"
-#include "qmlcontext.h"
-#include "qml.h"
-
-#include <qmldebugservice_p.h>
-
-#include <QtCore/qmetaobject.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QmlWatchProxy : public QObject
-{
- Q_OBJECT
-public:
- QmlWatchProxy(int id,
- QObject *object,
- int debugId,
- const QMetaProperty &prop,
- QmlWatcher *parent = 0);
-
- QmlWatchProxy(int id,
- QmlExpression *exp,
- int debugId,
- QmlWatcher *parent = 0);
-
-public slots:
- void notifyValueChanged();
-
-private:
- friend class QmlWatcher;
- int m_id;
- QmlWatcher *m_watch;
- QObject *m_object;
- int m_debugId;
- QMetaProperty m_property;
-
- QmlExpression *m_expr;
-};
-
-QmlWatchProxy::QmlWatchProxy(int id,
- QmlExpression *exp,
- int debugId,
- QmlWatcher *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()));
-}
-
-QmlWatchProxy::QmlWatchProxy(int id,
- QObject *object,
- int debugId,
- const QMetaProperty &prop,
- QmlWatcher *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 = QmlWatchProxy::staticMetaObject.indexOfMethod("notifyValueChanged()");
-
- if (prop.hasNotifySignal())
- QMetaObject::connect(m_object, prop.notifySignalIndex(), this, refreshIdx);
-}
-
-void QmlWatchProxy::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);
-}
-
-
-QmlWatcher::QmlWatcher(QObject *parent)
- : QObject(parent)
-{
-}
-
-bool QmlWatcher::addWatch(int id, quint32 debugId)
-{
- QObject *object = QmlDebugService::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 QmlWatcher::addWatch(int id, quint32 debugId, const QByteArray &property)
-{
- QObject *object = QmlDebugService::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 QmlWatcher::addWatch(int id, quint32 objectId, const QString &expr)
-{
- QObject *object = QmlDebugService::objectForId(objectId);
- QmlContext *context = qmlContext(object);
- if (context) {
- QmlExpression *exprObj = new QmlExpression(context, expr, object);
- QmlWatchProxy *proxy = new QmlWatchProxy(id, exprObj, objectId, this);
- exprObj->setParent(proxy);
- m_proxies[id].append(proxy);
- proxy->notifyValueChanged();
- return true;
- }
- return false;
-}
-
-void QmlWatcher::removeWatch(int id)
-{
- if (!m_proxies.contains(id))
- return;
-
- QList<QPointer<QmlWatchProxy> > proxies = m_proxies.take(id);
- qDeleteAll(proxies);
-}
-
-void QmlWatcher::addPropertyWatch(int id, QObject *object, quint32 debugId, const QMetaProperty &property)
-{
- QmlWatchProxy *proxy = new QmlWatchProxy(id, object, debugId, property, this);
- m_proxies[id].append(proxy);
-
- proxy->notifyValueChanged();
-}
-
-QT_END_NAMESPACE
-
-#include <qmlwatcher.moc>
diff --git a/src/declarative/qml/qmlwatcher_p.h b/src/declarative/qml/qmlwatcher_p.h
deleted file mode 100644
index 57b358d746..0000000000
--- a/src/declarative/qml/qmlwatcher_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 QMLWATCHER_P_H
-#define QMLWATCHER_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 QmlWatchProxy;
-class QmlExpression;
-class QmlContext;
-class QMetaProperty;
-
-class QmlWatcher : public QObject
-{
- Q_OBJECT
-public:
- QmlWatcher(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 QmlWatchProxy;
- void addPropertyWatch(int id, QObject *object, quint32 objectId, const QMetaProperty &property);
-
- QHash<int, QList<QPointer<QmlWatchProxy> > > m_proxies;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLWATCHER_P_H
diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp
deleted file mode 100644
index a2e8c7a2bd..0000000000
--- a/src/declarative/qml/qmlworkerscript.cpp
+++ /dev/null
@@ -1,1045 +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 "qmlworkerscript_p.h"
-
-#include "qmlengine_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/qmlinfo.h>
-#include "qmlnetworkaccessmanagerfactory.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 QmlWorkerScriptEnginePrivate : public QObject
-{
-public:
- QmlWorkerScriptEnginePrivate(QmlEngine *eng);
-
- struct ScriptEngine : public QmlScriptEngine
- {
- ScriptEngine(QmlWorkerScriptEnginePrivate *parent) : QmlScriptEngine(0), p(parent), accessManager(0) {}
- ~ScriptEngine() { delete accessManager; }
- QmlWorkerScriptEnginePrivate *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 QmlWorkerScriptEnginePrivate *get(QScriptEngine *e) {
- return static_cast<ScriptEngine *>(e)->p;
- }
-
- QmlEngine *qmlengine;
-
- QMutex m_lock;
- QWaitCondition m_wait;
-
- struct WorkerScript {
- WorkerScript();
-
- int id;
- bool initialized;
- QmlWorkerScript *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 QmlWorkerListModelAgent : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count);
-
-public:
- QmlWorkerListModelAgent(QmlWorkerListModel *);
- ~QmlWorkerListModelAgent();
-
- 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(QmlWorkerListModelAgent *_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;
- }
-
- QmlWorkerListModelAgent *a;
- };
-protected:
- virtual bool event(QEvent *);
-
-private:
- friend class QmlWorkerScriptEnginePrivate;
- friend class QmlWorkerListModel;
- 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;
- QmlWorkerListModel *m_model;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QmlWorkerListModelAgent::VariantRef);
-
-QT_BEGIN_NAMESPACE
-
-QmlWorkerScriptEnginePrivate::QmlWorkerScriptEnginePrivate(QmlEngine *engine)
-: workerEngine(0), qmlengine(engine), m_nextId(0)
-{
-}
-
-QScriptValue QmlWorkerScriptEnginePrivate::onMessage(QScriptContext *ctxt, QScriptEngine *engine)
-{
- QmlWorkerScriptEnginePrivate *p = QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEnginePrivate::sendMessage(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if (!ctxt->argumentCount())
- return engine->undefinedValue();
-
- QmlWorkerScriptEnginePrivate *p = QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEnginePrivate::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()) {
- QmlWorkerListModel *lm = qobject_cast<QmlWorkerListModel *>(value.toQObject());
- if (lm) {
- QmlWorkerListModelAgent::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 QmlWorkerScriptEnginePrivate::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<QmlWorkerListModelAgent::VariantRef>()) {
- QmlWorkerListModelAgent::VariantRef vr = qvariant_cast<QmlWorkerListModelAgent::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;
-}
-
-QmlWorkerScriptEngine::QmlWorkerScriptEngine(QmlEngine *parent)
-: QThread(parent), d(new QmlWorkerScriptEnginePrivate(parent))
-{
- d->m_lock.lock();
- start(QThread::LowPriority);
- d->m_wait.wait(&d->m_lock);
- d->moveToThread(this);
- d->m_lock.unlock();
-}
-
-QmlWorkerScriptEngine::~QmlWorkerScriptEngine()
-{
- qDeleteAll(d->workers);
- delete d; d = 0;
-}
-
-QmlWorkerScriptEnginePrivate::WorkerScript::WorkerScript()
-: id(-1), initialized(false), owner(0)
-{
-}
-
-int QmlWorkerScriptEngine::registerWorkerScript(QmlWorkerScript *owner)
-{
- QmlWorkerScriptEnginePrivate::WorkerScript *script = new QmlWorkerScriptEnginePrivate::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 QmlWorkerScriptEngine::removeWorkerScript(int id)
-{
- QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));
-}
-
-void QmlWorkerScriptEngine::executeUrl(int id, const QUrl &url)
-{
- QCoreApplication::postEvent(d, new WorkerLoadEvent(id, url));
-}
-
-void QmlWorkerScriptEngine::sendMessage(int id, const QVariant &data)
-{
- QCoreApplication::postEvent(d, new WorkerDataEvent(id, data));
-}
-
-void QmlWorkerScriptEngine::run()
-{
- d->m_lock.lock();
-
- d->workerEngine = new QmlWorkerScriptEnginePrivate::ScriptEngine(d);
-
- d->m_wait.wakeAll();
-
- d->m_lock.unlock();
-
- exec();
-
- delete d->workerEngine; d->workerEngine = 0;
-}
-
-QmlWorkerScript::QmlWorkerScript(QObject *parent)
-: QObject(parent), m_engine(0), m_scriptId(-1)
-{
-}
-
-QmlWorkerScript::~QmlWorkerScript()
-{
- if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId);
-}
-
-QUrl QmlWorkerScript::source() const
-{
- return m_source;
-}
-
-void QmlWorkerScript::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 QmlWorkerScript::sendMessage(const QScriptValue &message)
-{
- if (!m_engine) {
- qWarning("QmlWorkerScript: Attempt to send message before WorkerScript establishment");
- return;
- }
-
- m_engine->sendMessage(m_scriptId, QmlWorkerScriptEnginePrivate::scriptValueToVariant(message));
-}
-
-void QmlWorkerScript::componentComplete()
-{
- if (!m_engine) {
- QmlEngine *engine = qmlEngine(this);
- if (!engine) {
- qWarning("QmlWorkerScript: componentComplete() called without qmlEngine() set");
- return;
- }
-
- m_engine = QmlEnginePrivate::get(engine)->getWorkerScriptEngine();
- m_scriptId = m_engine->registerWorkerScript(this);
-
- if (m_source.isValid())
- m_engine->executeUrl(m_scriptId, m_source);
- }
-}
-
-bool QmlWorkerScript::event(QEvent *event)
-{
- if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
- QmlEngine *engine = qmlEngine(this);
- if (engine) {
- QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
- QScriptValue value =
- QmlWorkerScriptEnginePrivate::variantToScriptValue(workerEvent->data(), scriptEngine);
- emit message(value);
- }
- return true;
- } else {
- return QObject::event(event);
- }
-}
-
-QML_DEFINE_TYPE(Qt, 4, 6, WorkerScript, QmlWorkerScript);
-
-void QmlWorkerListModelAgent::Data::clearChange()
-{
- changes.clear();
-}
-
-void QmlWorkerListModelAgent::Data::insertChange(int index, int count)
-{
- Change c = { Change::Inserted, index, count, 0 };
- changes << c;
-}
-
-void QmlWorkerListModelAgent::Data::removeChange(int index, int count)
-{
- Change c = { Change::Removed, index, count, 0 };
- changes << c;
-}
-
-void QmlWorkerListModelAgent::Data::changedChange(int index, int count)
-{
- Change c = { Change::Changed, index, count, 0 };
- changes << c;
-}
-
-QmlWorkerListModelAgent::QmlWorkerListModelAgent(QmlWorkerListModel *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;
-}
-
-QmlWorkerListModelAgent::~QmlWorkerListModelAgent()
-{
-}
-
-void QmlWorkerListModelAgent::addref()
-{
- m_ref.ref();
-}
-
-void QmlWorkerListModelAgent::release()
-{
- bool del = !m_ref.deref();
-
- if (del)
- delete this;
-}
-
-int QmlWorkerListModelAgent::count() const
-{
- return data.values.count();
-}
-
-void QmlWorkerListModelAgent::clear()
-{
- data.clearChange();
- data.removeChange(0, data.values.count());
- data.values.clear();
-}
-
-void QmlWorkerListModelAgent::remove(int index)
-{
- if (data.values.count() <= index)
- return;
-
- data.values.removeAt(index);
- data.removeChange(index, 1);
-}
-
-void QmlWorkerListModelAgent::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 QmlWorkerListModelAgent::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 QmlWorkerListModelAgent::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 QmlWorkerListModelAgent::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 QmlWorkerListModelAgent::sync()
-{
- Sync *s = new Sync;
- s->data = data;
- data.changes.clear();
- QCoreApplication::postEvent(this, s);
-}
-
-bool QmlWorkerListModelAgent::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);
-}
-
-QmlWorkerListModel::QmlWorkerListModel(QObject *parent)
-: QListModelInterface(parent), m_agent(0)
-{
-}
-
-QmlWorkerListModel::~QmlWorkerListModel()
-{
- if (m_agent) {
- m_agent->m_model = 0;
- m_agent->release();
- }
-}
-
-void QmlWorkerListModel::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 QmlWorkerListModel::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 QmlWorkerListModel::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 QmlWorkerListModel::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 QmlWorkerListModel::get(int index) const
-{
- QmlEngine *engine = qmlEngine(this);
- if (!engine || m_values.count() <= index)
- return QScriptValue();
-
- QScriptEngine *scriptEngine = QmlEnginePrivate::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 QmlWorkerListModel::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());
- }
-}
-
-QmlWorkerListModelAgent *QmlWorkerListModel::agent()
-{
- if (!m_agent)
- m_agent = new QmlWorkerListModelAgent(this);
-
- return m_agent;
-}
-
-QList<int> QmlWorkerListModel::roles() const
-{
- return m_roles.keys();
-}
-
-QString QmlWorkerListModel::toString(int role) const
-{
- return m_roles.value(role);
-}
-
-int QmlWorkerListModel::count() const
-{
- return m_values.count();
-}
-
-QHash<int,QVariant> QmlWorkerListModel::data(int index, const QList<int> &) const
-{
- if (m_values.count() <= index)
- return QHash<int, QVariant>();
- else
- return m_values.at(index);
-}
-
-QVariant QmlWorkerListModel::data(int index, int role) const
-{
- if (m_values.count() <= index)
- return QVariant();
- else
- return m_values.at(index).value(role);
-}
-
-QT_END_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel)
-
-#include "qmlworkerscript.moc"
-
-
diff --git a/src/declarative/qml/qmlworkerscript_p.h b/src/declarative/qml/qmlworkerscript_p.h
deleted file mode 100644
index 7698a21474..0000000000
--- a/src/declarative/qml/qmlworkerscript_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 QMLWORKERSCRIPT_P_H
-#define QMLWORKERSCRIPT_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 "qmlparserstatus.h"
-#include <private/qlistmodelinterface_p.h>
-
-#include <QtCore/qthread.h>
-#include <QtScript/qscriptvalue.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlWorkerScript;
-class QmlWorkerScriptEnginePrivate;
-class QmlWorkerScriptEngine : public QThread
-{
-Q_OBJECT
-public:
- QmlWorkerScriptEngine(QmlEngine *parent = 0);
- virtual ~QmlWorkerScriptEngine();
-
- int registerWorkerScript(QmlWorkerScript *);
- void removeWorkerScript(int);
- void executeUrl(int, const QUrl &);
- void sendMessage(int, const QVariant &);
-
-protected:
- virtual void run();
-
-private:
- QmlWorkerScriptEnginePrivate *d;
-};
-
-class QmlWorkerScript : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
-
- Q_INTERFACES(QmlParserStatus)
-public:
- QmlWorkerScript(QObject *parent = 0);
- virtual ~QmlWorkerScript();
-
- 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:
- QmlWorkerScriptEngine *m_engine;
- int m_scriptId;
- QUrl m_source;
-};
-
-class QmlWorkerListModelAgent;
-class QmlWorkerListModel : public QListModelInterface
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
-public:
- QmlWorkerListModel(QObject * = 0);
- virtual ~QmlWorkerListModel();
-
- 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 &);
-
- QmlWorkerListModelAgent *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 QmlWorkerListModelAgent;
-
- QHash<int, QString> m_roles;
- QHash<QString, int> m_strings;
- QList<QHash<int, QVariant> > m_values;
-
- QmlWorkerListModelAgent *m_agent;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlWorkerScript);
-QML_DECLARE_TYPE(QmlWorkerListModel);
-
-#endif // QMLWORKERSCRIPT_P_H
diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
deleted file mode 100644
index eda2d9e7da..0000000000
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ /dev/null
@@ -1,1631 +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 "qmlxmlhttprequest_p.h"
-
-#include "qmlengine.h"
-#include "qmlengine_p.h"
-#include "qmlrefcount_p.h"
-#include "qmlengine_p.h"
-#include "qmlexpression_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 QmlRefCount, public NodeImpl
-{
-public:
- DocumentImpl() : root(0) { type = Document; }
- virtual ~DocumentImpl() {
- if (root) delete root;
- }
-
- QString version;
- QString encoding;
- bool isStandalone;
-
- NodeImpl *root;
-
- void addref() { QmlRefCount::addref(); }
- void release() { QmlRefCount::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 (!QmlScriptEngine::get(engine)->namedNodeMapClass)
- QmlScriptEngine::get(engine)->namedNodeMapClass= new NamedNodeMapClass(engine);
-
- instance.setScriptClass(QmlScriptEngine::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 (!QmlScriptEngine::get(engine)->nodeListClass)
- QmlScriptEngine::get(engine)->nodeListClass= new NodeListClass(engine);
-
- instance.setScriptClass(QmlScriptEngine::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 QmlXMLHttpRequest : public QObject
-{
-Q_OBJECT
-public:
- enum State { Unsent = 0,
- Opened = 1, HeadersReceived = 2,
- Loading = 3, Done = 4 };
-
- QmlXMLHttpRequest(QNetworkAccessManager *manager);
- virtual ~QmlXMLHttpRequest();
-
- 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; }
-};
-
-QmlXMLHttpRequest::QmlXMLHttpRequest(QNetworkAccessManager *manager)
-: m_state(Unsent), m_errorFlag(false), m_sendFlag(false),
- m_redirectCount(0), m_network(0), m_nam(manager)
-{
-}
-
-QmlXMLHttpRequest::~QmlXMLHttpRequest()
-{
- destroyNetwork();
-}
-
-bool QmlXMLHttpRequest::sendFlag() const
-{
- return m_sendFlag;
-}
-
-bool QmlXMLHttpRequest::errorFlag() const
-{
- return m_errorFlag;
-}
-
-quint32 QmlXMLHttpRequest::readyState() const
-{
- return m_state;
-}
-
-int QmlXMLHttpRequest::replyStatus() const
-{
- return m_status;
-}
-
-QString QmlXMLHttpRequest::replyStatusText() const
-{
- return m_statusText;
-}
-
-QScriptValue QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::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 QmlXMLHttpRequest::responseBody() const
-{
- return QString::fromUtf8(m_responseEntityBody);
-}
-
-QScriptValue QmlXMLHttpRequest::dispatchCallback(QScriptValue *me)
-{
- QScriptValue v = me->property(QLatin1String("callback"));
- return v.call();
-}
-
-void QmlXMLHttpRequest::printError(const QScriptValue& sv)
-{
- QmlError error;
- QmlExpressionPrivate::exceptionToError(sv.engine(), error);
- qWarning().nospace() << qPrintable(error.toString());
-}
-
-void QmlXMLHttpRequest::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();
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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 = QmlScriptEngine::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)
-{
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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() != QmlXMLHttpRequest::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();
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(dataObject.toQObject());
- if (!request)
- THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (request->readyState() != QmlXMLHttpRequest::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();
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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)
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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() != QmlXMLHttpRequest::Loading &&
- request->readyState() != QmlXMLHttpRequest::Done &&
- request->readyState() != QmlXMLHttpRequest::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)
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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() != QmlXMLHttpRequest::Loading &&
- request->readyState() != QmlXMLHttpRequest::Done &&
- request->readyState() != QmlXMLHttpRequest::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)
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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)
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject());
- if (!request)
- THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (request->readyState() == QmlXMLHttpRequest::Unsent ||
- request->readyState() == QmlXMLHttpRequest::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)
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject());
- if (!request)
- THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (request->readyState() == QmlXMLHttpRequest::Unsent ||
- request->readyState() == QmlXMLHttpRequest::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)
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject());
- if (!request)
- THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (request->readyState() != QmlXMLHttpRequest::Loading &&
- request->readyState() != QmlXMLHttpRequest::Done)
- return QScriptValue(QString());
- else
- return QScriptValue(request->responseBody());
-}
-
-static QScriptValue qmlxmlhttprequest_responseXML(QScriptContext *context, QScriptEngine *engine)
-{
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject());
- if (!request)
- THROW_REFERENCE("Not an XMLHttpRequest object");
-
- if (request->readyState() != QmlXMLHttpRequest::Loading &&
- request->readyState() != QmlXMLHttpRequest::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();
- QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(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 QmlXMLHttpRequest(QmlScriptEngine::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 <qmlxmlhttprequest.moc>
diff --git a/src/declarative/qml/qmlxmlhttprequest_p.h b/src/declarative/qml/qmlxmlhttprequest_p.h
deleted file mode 100644
index 59cb211b56..0000000000
--- a/src/declarative/qml/qmlxmlhttprequest_p.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 QMLXMLHTTPREQUEST_P_H
-#define QMLXMLHTTPREQUEST_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 // QMLXMLHTTPREQUEST_P_H
-
diff --git a/src/declarative/qml/rewriter/rewriter.cpp b/src/declarative/qml/rewriter/rewriter.cpp
index f84893682e..b458a8d361 100644
--- a/src/declarative/qml/rewriter/rewriter.cpp
+++ b/src/declarative/qml/rewriter/rewriter.cpp
@@ -41,11 +41,11 @@
#include "rewriter_p.h"
-#include <qmljsast_p.h>
+#include <qdeclarativejsast_p.h>
QT_QML_BEGIN_NAMESPACE
-using namespace QmlJS;
+using namespace QDeclarativeJS;
void Rewriter::replace(const AST::SourceLocation &loc, const QString &text)
{ replace(loc.offset, loc.length, text); }
@@ -77,8 +77,8 @@ QString Rewriter::textAt(const AST::SourceLocation &loc) const
QString Rewriter::textAt(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc) const
{ return _code.mid(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset); }
-void Rewriter::accept(QmlJS::AST::Node *node)
-{ QmlJS::AST::Node::acceptChild(node, this); }
+void Rewriter::accept(QDeclarativeJS::AST::Node *node)
+{ QDeclarativeJS::AST::Node::acceptChild(node, this); }
void Rewriter::moveTextBefore(const AST::SourceLocation &firstLoc,
const AST::SourceLocation &lastLoc,
diff --git a/src/declarative/qml/rewriter/rewriter_p.h b/src/declarative/qml/rewriter/rewriter_p.h
index 36e8df78a2..d1445d80ac 100644
--- a/src/declarative/qml/rewriter/rewriter_p.h
+++ b/src/declarative/qml/rewriter/rewriter_p.h
@@ -44,7 +44,7 @@
#include "textwriter_p.h"
-#include <qmljsastvisitor_p.h>
+#include <qdeclarativejsastvisitor_p.h>
#include <QtCore/QList>
#include <QtCore/QString>
@@ -52,7 +52,7 @@
QT_BEGIN_HEADER
QT_QML_BEGIN_NAMESPACE
-namespace QmlJS {
+namespace QDeclarativeJS {
////////////////////////////////////////////////////////////////////////////////
// Replacement
@@ -145,7 +145,7 @@ private:
QList<Replacement> _replacementList;
};
-} // end of namespace QmlJS
+} // end of namespace QDeclarativeJS
QT_QML_END_NAMESPACE
QT_END_HEADER
diff --git a/src/declarative/qml/rewriter/textwriter.cpp b/src/declarative/qml/rewriter/textwriter.cpp
index cd3f26aa21..e63d24c619 100644
--- a/src/declarative/qml/rewriter/textwriter.cpp
+++ b/src/declarative/qml/rewriter/textwriter.cpp
@@ -43,7 +43,7 @@
QT_QML_BEGIN_NAMESPACE
-using namespace QmlJS;
+using namespace QDeclarativeJS;
TextWriter::TextWriter()
:string(0), cursor(0)
diff --git a/src/declarative/qml/rewriter/textwriter_p.h b/src/declarative/qml/rewriter/textwriter_p.h
index 43ef669941..c712626167 100644
--- a/src/declarative/qml/rewriter/textwriter_p.h
+++ b/src/declarative/qml/rewriter/textwriter_p.h
@@ -42,7 +42,7 @@
#ifndef TEXTWRITER_H
#define TEXTWRITER_H
-#include <qmljsglobal_p.h>
+#include <qdeclarativejsglobal_p.h>
#include <QtCore/QString>
#include <QtCore/QList>
@@ -51,7 +51,7 @@
QT_BEGIN_HEADER
QT_QML_BEGIN_NAMESPACE
-namespace QmlJS {
+namespace QDeclarativeJS {
class TextWriter
{
@@ -93,7 +93,7 @@ public:
};
-} // end of namespace QmlJS
+} // end of namespace QDeclarativeJS
QT_QML_END_NAMESPACE
QT_END_HEADER
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
new file mode 100644
index 0000000000..d0a1299cee
--- /dev/null
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -0,0 +1,2611 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeanimation_p.h"
+#include "qdeclarativeanimation_p_p.h"
+
+#include "qdeclarativebehavior_p.h"
+#include "qdeclarativestateoperations_p.h"
+
+#include <qdeclarativepropertyvaluesource.h>
+#include <qdeclarative.h>
+#include <qdeclarativeinfo.h>
+#include <qdeclarativeexpression.h>
+#include <qdeclarativestringconverters_p.h>
+#include <qdeclarativeglobal_p.h>
+#include <qdeclarativemetatype_p.h>
+#include <qdeclarativeproperty_p.h>
+
+#include <qvariant.h>
+#include <qcolor.h>
+#include <qfile.h>
+#include <QParallelAnimationGroup>
+#include <QSequentialAnimationGroup>
+#include <QtCore/qset.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qmath.h>
+
+#include <private/qvariantanimation_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Animation QDeclarativeAbstractAnimation
+ \since 4.7
+ \brief The Animation element is the base of all QML animations.
+
+ The Animation element cannot be used directly in a QML file. It exists
+ to provide a set of common properties and methods, available across all the
+ other animation types that inherit from it. Attempting to use the Animation
+ element directly will result in an error.
+*/
+
+/*!
+ \class QDeclarativeAbstractAnimation
+ \internal
+*/
+
+QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QObject *parent)
+: QObject(*(new QDeclarativeAbstractAnimationPrivate), parent)
+{
+}
+
+QDeclarativeAbstractAnimation::~QDeclarativeAbstractAnimation()
+{
+}
+
+QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent)
+: QObject(dd, parent)
+{
+}
+
+/*!
+ \qmlproperty bool Animation::running
+ This property holds whether the animation is currently running.
+
+ The \c running property can be set to declaratively control whether or not
+ an animation is running. The following example will animate a rectangle
+ whenever the \l MouseArea is pressed.
+
+ \code
+ Rectangle {
+ width: 100; height: 100
+ x: NumberAnimation {
+ running: myMouse.pressed
+ from: 0; to: 100
+ }
+ MouseArea { id: myMouse }
+ }
+ \endcode
+
+ Likewise, the \c running property can be read to determine if the animation
+ is running. In the following example the text element will indicate whether
+ or not the animation is running.
+
+ \code
+ NumberAnimation { id: myAnimation }
+ Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }
+ \endcode
+
+ Animations can also be started and stopped imperatively from JavaScript
+ using the \c start() and \c stop() methods.
+
+ By default, animations are not running. Though, when the animations are assigned to properties,
+ as property value sources, they are set to running by default.
+*/
+bool QDeclarativeAbstractAnimation::isRunning() const
+{
+ Q_D(const QDeclarativeAbstractAnimation);
+ return d->running;
+}
+
+//commence is called to start an animation when it is used as a
+//simple animation, and not as part of a transition
+void QDeclarativeAbstractAnimationPrivate::commence()
+{
+ Q_Q(QDeclarativeAbstractAnimation);
+
+ QDeclarativeStateActions actions;
+ QDeclarativeProperties properties;
+ q->transition(actions, properties, QDeclarativeAbstractAnimation::Forward);
+
+ q->qtAnimation()->start();
+ if (q->qtAnimation()->state() != QAbstractAnimation::Running) {
+ running = false;
+ emit q->completed();
+ }
+}
+
+QDeclarativeProperty QDeclarativeAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
+{
+ QDeclarativeProperty prop(obj, str, qmlContext(infoObj));
+ if (!prop.isValid()) {
+ qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
+ return QDeclarativeProperty();
+ } else if (!prop.isWritable()) {
+ qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str);
+ return QDeclarativeProperty();
+ }
+ return prop;
+}
+
+void QDeclarativeAbstractAnimation::setRunning(bool r)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ if (!d->componentComplete) {
+ d->running = r;
+ if (r == false)
+ d->avoidPropertyValueSourceStart = true;
+ return;
+ }
+
+ if (d->running == r)
+ return;
+
+ if (d->group || d->disableUserControl) {
+ qWarning("QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ return;
+ }
+
+ d->running = r;
+ if (d->running) {
+ if (d->alwaysRunToEnd && d->repeat
+ && qtAnimation()->state() == QAbstractAnimation::Running) {
+ qtAnimation()->setLoopCount(-1);
+ }
+
+ if (!d->connectedTimeLine) {
+ QObject::connect(qtAnimation(), SIGNAL(finished()),
+ this, SLOT(timelineComplete()));
+ d->connectedTimeLine = true;
+ }
+ d->commence();
+ emit started();
+ } else {
+ if (d->alwaysRunToEnd) {
+ if (d->repeat)
+ qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1);
+ } else
+ qtAnimation()->stop();
+
+ emit completed();
+ }
+
+ emit runningChanged(d->running);
+}
+
+/*!
+ \qmlproperty bool Animation::paused
+ This property holds whether the animation is currently paused.
+
+ The \c paused property can be set to declaratively control whether or not
+ an animation is paused.
+
+ Animations can also be paused and resumed imperatively from JavaScript
+ using the \c pause() and \c resume() methods.
+
+ By default, animations are not paused.
+*/
+bool QDeclarativeAbstractAnimation::isPaused() const
+{
+ Q_D(const QDeclarativeAbstractAnimation);
+ return d->paused;
+}
+
+void QDeclarativeAbstractAnimation::setPaused(bool p)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ if (d->paused == p)
+ return;
+
+ if (d->group || d->disableUserControl) {
+ qWarning("QDeclarativeAbstractAnimation: setPaused() cannot be used on non-root animation nodes");
+ return;
+ }
+
+ d->paused = p;
+ if (d->paused)
+ qtAnimation()->pause();
+ else
+ qtAnimation()->resume();
+
+ emit pausedChanged(d->paused);
+}
+
+void QDeclarativeAbstractAnimation::classBegin()
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ d->componentComplete = false;
+}
+
+void QDeclarativeAbstractAnimation::componentComplete()
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ d->componentComplete = true;
+ if (d->running) {
+ d->running = false;
+ setRunning(true);
+ }
+}
+
+/*!
+ \qmlproperty bool Animation::alwaysRunToEnd
+ This property holds whether the animation should run to completion when it is stopped.
+
+ If this true the animation will complete its current iteration when it
+ is stopped - either by setting the \c running property to false, or by
+ calling the \c stop() method. The \c complete() method is not effected
+ by this value.
+
+ This behavior is most useful when the \c repeat property is set, as the
+ animation will finish playing normally but not restart.
+
+ By default, the alwaysRunToEnd property is not set.
+*/
+bool QDeclarativeAbstractAnimation::alwaysRunToEnd() const
+{
+ Q_D(const QDeclarativeAbstractAnimation);
+ return d->alwaysRunToEnd;
+}
+
+void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ if (d->alwaysRunToEnd == f)
+ return;
+
+ d->alwaysRunToEnd = f;
+ emit alwaysRunToEndChanged(f);
+}
+
+/*!
+ \qmlproperty bool Animation::repeat
+ This property holds whether the animation should repeat.
+
+ If set, the animation will continuously repeat until it is explicitly
+ stopped - either by setting the \c running property to false, or by calling
+ the \c stop() method.
+
+ In the following example, the rectangle will spin indefinately.
+
+ \code
+ Rectangle {
+ rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
+ }
+ \endcode
+*/
+bool QDeclarativeAbstractAnimation::repeat() const
+{
+ Q_D(const QDeclarativeAbstractAnimation);
+ return d->repeat;
+}
+
+void QDeclarativeAbstractAnimation::setRepeat(bool r)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ if (r == d->repeat)
+ return;
+
+ d->repeat = r;
+ int lc = r ? -1 : 1;
+ qtAnimation()->setLoopCount(lc);
+ emit repeatChanged(r);
+}
+
+int QDeclarativeAbstractAnimation::currentTime()
+{
+ return qtAnimation()->currentLoopTime();
+}
+
+void QDeclarativeAbstractAnimation::setCurrentTime(int time)
+{
+ qtAnimation()->setCurrentTime(time);
+}
+
+QDeclarativeAnimationGroup *QDeclarativeAbstractAnimation::group() const
+{
+ Q_D(const QDeclarativeAbstractAnimation);
+ return d->group;
+}
+
+void QDeclarativeAbstractAnimation::setGroup(QDeclarativeAnimationGroup *g)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ if (d->group == g)
+ return;
+ if (d->group)
+ static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this);
+
+ d->group = g;
+
+ if (d->group && !static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this))
+ static_cast<QDeclarativeAnimationGroupPrivate *>(d->group->d_func())->animations.append(this);
+
+ //if (g) //if removed from a group, then the group should no longer be the parent
+ setParent(g);
+}
+
+/*!
+ \qmlmethod Animation::start()
+ \brief Starts the animation.
+
+ If the animation is already running, calling this method has no effect. The
+ \c running property will be true following a call to \c start().
+*/
+void QDeclarativeAbstractAnimation::start()
+{
+ setRunning(true);
+}
+
+/*!
+ \qmlmethod Animation::pause()
+ \brief Pauses the animation.
+
+ If the animation is already paused, calling this method has no effect. The
+ \c paused property will be true following a call to \c pause().
+*/
+void QDeclarativeAbstractAnimation::pause()
+{
+ setPaused(true);
+}
+
+/*!
+ \qmlmethod Animation::resume()
+ \brief Resumes a paused animation.
+
+ If the animation is not paused, calling this method has no effect. The
+ \c paused property will be false following a call to \c resume().
+*/
+void QDeclarativeAbstractAnimation::resume()
+{
+ setPaused(false);
+}
+
+/*!
+ \qmlmethod Animation::stop()
+ \brief Stops the animation.
+
+ If the animation is not running, calling this method has no effect. The
+ \c running property will be false following a call to \c stop().
+
+ Normally \c stop() stops the animation immediately, and the animation has
+ no further influence on property values. In this example animation
+ \code
+ Rectangle {
+ x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ }
+ \endcode
+ was stopped at time 250ms, the \c x property will have a value of 50.
+
+ However, if the \c alwaysRunToEnd property is set, the animation will
+ continue running until it completes and then stop. The \c running property
+ will still become false immediately.
+*/
+void QDeclarativeAbstractAnimation::stop()
+{
+ setRunning(false);
+}
+
+/*!
+ \qmlmethod Animation::restart()
+ \brief Restarts the animation.
+
+ This is a convenience method, and is equivalent to calling \c stop() and
+ then \c start().
+*/
+void QDeclarativeAbstractAnimation::restart()
+{
+ stop();
+ start();
+}
+
+/*!
+ \qmlmethod Animation::complete()
+ \brief Stops the animation, jumping to the final property values.
+
+ If the animation is not running, calling this method has no effect. The
+ \c running property will be false following a call to \c complete().
+
+ Unlike \c stop(), \c complete() immediately fast-forwards the animation to
+ its end. In the following example,
+ \code
+ Rectangle {
+ x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ }
+ \endcode
+ calling \c stop() at time 250ms will result in the \c x property having
+ a value of 50, while calling \c complete() will set the \c x property to
+ 100, exactly as though the animation had played the whole way through.
+*/
+void QDeclarativeAbstractAnimation::complete()
+{
+ if (isRunning()) {
+ qtAnimation()->setCurrentTime(qtAnimation()->duration());
+ }
+}
+
+void QDeclarativeAbstractAnimation::setTarget(const QDeclarativeProperty &p)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ d->defaultProperty = p;
+
+ if (!d->avoidPropertyValueSourceStart)
+ setRunning(true);
+}
+
+/*
+ we rely on setTarget only being called when used as a value source
+ so this function allows us to do the same thing as setTarget without
+ that assumption
+*/
+void QDeclarativeAbstractAnimation::setDefaultTarget(const QDeclarativeProperty &p)
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ d->defaultProperty = p;
+}
+
+/*
+ don't allow start/stop/pause/resume to be manually invoked,
+ because something else (like a Behavior) already has control
+ over the animation.
+*/
+void QDeclarativeAbstractAnimation::setDisableUserControl()
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ d->disableUserControl = true;
+}
+
+void QDeclarativeAbstractAnimation::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_UNUSED(actions);
+ Q_UNUSED(modified);
+ Q_UNUSED(direction);
+}
+
+void QDeclarativeAbstractAnimation::timelineComplete()
+{
+ Q_D(QDeclarativeAbstractAnimation);
+ setRunning(false);
+ if (d->alwaysRunToEnd && d->repeat) {
+ qtAnimation()->setLoopCount(-1);
+ }
+}
+
+/*!
+ \qmlclass PauseAnimation QDeclarativePauseAnimation
+ \since 4.7
+ \inherits Animation
+ \brief The PauseAnimation element provides a pause for an animation.
+
+ When used in a SequentialAnimation, PauseAnimation is a step when
+ nothing happens, for a specified duration.
+
+ A 500ms animation sequence, with a 100ms pause between two animations:
+ \code
+ SequentialAnimation {
+ NumberAnimation { ... duration: 200 }
+ PauseAnimation { duration: 100 }
+ NumberAnimation { ... duration: 200 }
+ }
+ \endcode
+*/
+/*!
+ \internal
+ \class QDeclarativePauseAnimation
+*/
+
+
+QDeclarativePauseAnimation::QDeclarativePauseAnimation(QObject *parent)
+: QDeclarativeAbstractAnimation(*(new QDeclarativePauseAnimationPrivate), parent)
+{
+ Q_D(QDeclarativePauseAnimation);
+ d->init();
+}
+
+QDeclarativePauseAnimation::~QDeclarativePauseAnimation()
+{
+}
+
+void QDeclarativePauseAnimationPrivate::init()
+{
+ Q_Q(QDeclarativePauseAnimation);
+ pa = new QPauseAnimation;
+ QDeclarativeGraphics_setParent_noEvent(pa, q);
+}
+
+/*!
+ \qmlproperty int PauseAnimation::duration
+ This property holds the duration of the pause in milliseconds
+
+ The default value is 250.
+*/
+int QDeclarativePauseAnimation::duration() const
+{
+ Q_D(const QDeclarativePauseAnimation);
+ return d->pa->duration();
+}
+
+void QDeclarativePauseAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QDeclarativePauseAnimation);
+ if (d->pa->duration() == duration)
+ return;
+ d->pa->setDuration(duration);
+ emit durationChanged(duration);
+}
+
+QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation()
+{
+ Q_D(QDeclarativePauseAnimation);
+ return d->pa;
+}
+
+/*!
+ \qmlclass ColorAnimation QDeclarativeColorAnimation
+ \since 4.7
+ \inherits PropertyAnimation
+ \brief The ColorAnimation element allows you to animate color changes.
+
+ \code
+ ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 }
+ \endcode
+
+ When used in a transition, ColorAnimation will by default animate
+ all properties of type color that are changing. If a property or properties
+ are explicitly set for the animation, then those will be used instead.
+*/
+/*!
+ \internal
+ \class QDeclarativeColorAnimation
+*/
+
+QDeclarativeColorAnimation::QDeclarativeColorAnimation(QObject *parent)
+: QDeclarativePropertyAnimation(parent)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ d->interpolatorType = QMetaType::QColor;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultToInterpolatorType = true;
+}
+
+QDeclarativeColorAnimation::~QDeclarativeColorAnimation()
+{
+}
+
+/*!
+ \qmlproperty color ColorAnimation::from
+ This property holds the starting color.
+*/
+QColor QDeclarativeColorAnimation::from() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->from.value<QColor>();
+}
+
+void QDeclarativeColorAnimation::setFrom(const QColor &f)
+{
+ QDeclarativePropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty color ColorAnimation::to
+ This property holds the ending color.
+*/
+QColor QDeclarativeColorAnimation::to() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->to.value<QColor>();
+}
+
+void QDeclarativeColorAnimation::setTo(const QColor &t)
+{
+ QDeclarativePropertyAnimation::setTo(t);
+}
+
+
+
+/*!
+ \qmlclass ScriptAction QDeclarativeScriptAction
+ \since 4.7
+ \inherits Animation
+ \brief The ScriptAction element allows scripts to be run during an animation.
+
+*/
+/*!
+ \internal
+ \class QDeclarativeScriptAction
+*/
+QDeclarativeScriptAction::QDeclarativeScriptAction(QObject *parent)
+ :QDeclarativeAbstractAnimation(*(new QDeclarativeScriptActionPrivate), parent)
+{
+ Q_D(QDeclarativeScriptAction);
+ d->init();
+}
+
+QDeclarativeScriptAction::~QDeclarativeScriptAction()
+{
+}
+
+void QDeclarativeScriptActionPrivate::init()
+{
+ Q_Q(QDeclarativeScriptAction);
+ rsa = new QActionAnimation(&proxy);
+ QDeclarativeGraphics_setParent_noEvent(rsa, q);
+}
+
+/*!
+ \qmlproperty script ScriptAction::script
+ This property holds the script to run.
+*/
+QDeclarativeScriptString QDeclarativeScriptAction::script() const
+{
+ Q_D(const QDeclarativeScriptAction);
+ return d->script;
+}
+
+void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script)
+{
+ Q_D(QDeclarativeScriptAction);
+ d->script = script;
+}
+
+/*!
+ \qmlproperty QString ScriptAction::stateChangeScriptName
+ This property holds the the name of the StateChangeScript to run.
+
+ This property is only valid when ScriptAction is used as part of a transition.
+ If both script and stateChangeScriptName are set, stateChangeScriptName will be used.
+*/
+QString QDeclarativeScriptAction::stateChangeScriptName() const
+{
+ Q_D(const QDeclarativeScriptAction);
+ return d->name;
+}
+
+void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name)
+{
+ Q_D(QDeclarativeScriptAction);
+ d->name = name;
+}
+
+void QDeclarativeScriptActionPrivate::execute()
+{
+ QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
+
+ const QString &str = scriptStr.script();
+ if (!str.isEmpty()) {
+ QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject());
+ expr.value();
+ }
+}
+
+void QDeclarativeScriptAction::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativeScriptAction);
+ Q_UNUSED(modified);
+ Q_UNUSED(direction);
+
+ d->hasRunScriptScript = false;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+
+ if (action.event && action.event->typeName() == QLatin1String("StateChangeScript")
+ && static_cast<QDeclarativeStateChangeScript*>(action.event)->name() == d->name) {
+ //### how should we handle reverse direction?
+ d->runScriptScript = static_cast<QDeclarativeStateChangeScript*>(action.event)->script();
+ d->hasRunScriptScript = true;
+ action.actionDone = true;
+ break; //assumes names are unique
+ }
+ }
+}
+
+QAbstractAnimation *QDeclarativeScriptAction::qtAnimation()
+{
+ Q_D(QDeclarativeScriptAction);
+ return d->rsa;
+}
+
+
+
+/*!
+ \qmlclass PropertyAction QDeclarativePropertyAction
+ \since 4.7
+ \inherits Animation
+ \brief The PropertyAction element allows immediate property changes during animation.
+
+ Explicitly set \c theimage.smooth=true during a transition:
+ \code
+ PropertyAction { target: theimage; property: "smooth"; value: true }
+ \endcode
+
+ Set \c thewebview.url to the value set for the destination state:
+ \code
+ PropertyAction { target: thewebview; property: "url" }
+ \endcode
+
+ The PropertyAction is immediate -
+ the target property is not animated to the selected value in any way.
+*/
+/*!
+ \internal
+ \class QDeclarativePropertyAction
+*/
+QDeclarativePropertyAction::QDeclarativePropertyAction(QObject *parent)
+: QDeclarativeAbstractAnimation(*(new QDeclarativePropertyActionPrivate), parent)
+{
+ Q_D(QDeclarativePropertyAction);
+ d->init();
+}
+
+QDeclarativePropertyAction::~QDeclarativePropertyAction()
+{
+}
+
+void QDeclarativePropertyActionPrivate::init()
+{
+ Q_Q(QDeclarativePropertyAction);
+ spa = new QActionAnimation;
+ QDeclarativeGraphics_setParent_noEvent(spa, q);
+}
+
+/*!
+ \qmlproperty Object PropertyAction::target
+ This property holds an explicit target object to animate.
+
+ The exact effect of the \c target property depends on how the animation
+ is being used. Refer to the \l animation documentation for details.
+*/
+
+QObject *QDeclarativePropertyAction::target() const
+{
+ Q_D(const QDeclarativePropertyAction);
+ return d->target;
+}
+
+void QDeclarativePropertyAction::setTarget(QObject *o)
+{
+ Q_D(QDeclarativePropertyAction);
+ if (d->target == o)
+ return;
+ d->target = o;
+ emit targetChanged(d->target, d->propertyName);
+}
+
+QString QDeclarativePropertyAction::property() const
+{
+ Q_D(const QDeclarativePropertyAction);
+ return d->propertyName;
+}
+
+void QDeclarativePropertyAction::setProperty(const QString &n)
+{
+ Q_D(QDeclarativePropertyAction);
+ if (d->propertyName == n)
+ return;
+ d->propertyName = n;
+ emit targetChanged(d->target, d->propertyName);
+}
+
+/*!
+ \qmlproperty string PropertyAction::property
+ \qmlproperty string PropertyAction::properties
+ \qmlproperty Object PropertyAction::target
+ \qmlproperty list<Object> PropertyAction::targets
+
+ These properties are used as a set to determine which properties should be
+ affected by this action.
+
+ The details of how these properties are interpreted in different situations
+ is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
+ documentation.
+
+ \sa exclude
+*/
+QString QDeclarativePropertyAction::properties() const
+{
+ Q_D(const QDeclarativePropertyAction);
+ return d->properties;
+}
+
+void QDeclarativePropertyAction::setProperties(const QString &p)
+{
+ Q_D(QDeclarativePropertyAction);
+ if (d->properties == p)
+ return;
+ d->properties = p;
+ emit propertiesChanged(p);
+}
+
+QDeclarativeListProperty<QObject> QDeclarativePropertyAction::targets()
+{
+ Q_D(QDeclarativePropertyAction);
+ return QDeclarativeListProperty<QObject>(this, d->targets);
+}
+
+/*!
+ \qmlproperty list<Object> PropertyAction::exclude
+ This property holds the objects not to be affected by this animation.
+ \sa targets
+*/
+QDeclarativeListProperty<QObject> QDeclarativePropertyAction::exclude()
+{
+ Q_D(QDeclarativePropertyAction);
+ return QDeclarativeListProperty<QObject>(this, d->exclude);
+}
+
+/*!
+ \qmlproperty any PropertyAction::value
+ This property holds the value to be set on the property.
+ If not set, then the value defined for the end state of the transition.
+*/
+QVariant QDeclarativePropertyAction::value() const
+{
+ Q_D(const QDeclarativePropertyAction);
+ return d->value;
+}
+
+void QDeclarativePropertyAction::setValue(const QVariant &v)
+{
+ Q_D(QDeclarativePropertyAction);
+ if (d->value.isNull || d->value != v) {
+ d->value = v;
+ emit valueChanged(v);
+ }
+}
+
+QAbstractAnimation *QDeclarativePropertyAction::qtAnimation()
+{
+ Q_D(QDeclarativePropertyAction);
+ return d->spa;
+}
+
+void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativePropertyAction);
+ Q_UNUSED(direction);
+
+ struct QDeclarativeSetPropertyAnimationAction : public QAbstractAnimationAction
+ {
+ QDeclarativeStateActions actions;
+ virtual void doAction()
+ {
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QDeclarativeAction &action = actions.at(ii);
+ QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ }
+ }
+ };
+
+ QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
+ for (int ii = 0; ii < props.count(); ++ii)
+ props[ii] = props.at(ii).trimmed();
+ if (!d->propertyName.isEmpty())
+ props << d->propertyName;
+
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
+
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
+ }
+
+ QDeclarativeSetPropertyAnimationAction *data = new QDeclarativeSetPropertyAnimationAction;
+
+ bool hasExplicit = false;
+ //an explicit animation has been specified
+ if (d->value.isValid()) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QDeclarativeAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ myAction.toValue = d->value;
+ QDeclarativePropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!hasExplicit)
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+
+ QObject *obj = action.property.object();
+ QString propertyName = action.property.name();
+ QObject *sObj = action.specifiedObject;
+ QString sPropertyName = action.specifiedProperty;
+ bool same = (obj == sObj);
+
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
+ (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
+ QDeclarativeAction myAction = action;
+
+ if (d->value.isValid())
+ myAction.toValue = d->value;
+ QDeclarativePropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
+
+ modified << action.property;
+ data->actions << myAction;
+ action.fromValue = myAction.toValue;
+ }
+ }
+
+ if (data->actions.count()) {
+ d->spa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
+ } else {
+ delete data;
+ }
+}
+
+
+
+/*!
+ \qmlclass ParentAction QDeclarativeParentAction
+ \since 4.7
+ \inherits Animation
+ \brief The ParentAction element allows parent changes during animation.
+
+ ParentAction provides a way to specify at what point in a Transition a ParentChange should
+ occur.
+ \qml
+ State {
+ ParentChange {
+ target: myItem
+ parent: newParent
+ }
+ }
+ Transition {
+ SequentialAnimation {
+ PropertyAnimation { ... }
+ ParentAction {} //reparent myItem now
+ PropertyAnimation { ... }
+ }
+ }
+ \endqml
+
+ It also provides a way to explicitly reparent an item during an animation.
+ \qml
+ SequentialAnimation {
+ ParentAction { target: myItem; parent: newParent }
+ PropertyAnimation {}
+ }
+ \endqml
+
+ The ParentAction is immediate - it is not animated in any way.
+*/
+
+QDeclarativeParentAction::QDeclarativeParentAction(QObject *parent)
+: QDeclarativeAbstractAnimation(*(new QDeclarativeParentActionPrivate), parent)
+{
+ Q_D(QDeclarativeParentAction);
+ d->init();
+}
+
+QDeclarativeParentAction::~QDeclarativeParentAction()
+{
+}
+
+void QDeclarativeParentActionPrivate::init()
+{
+ Q_Q(QDeclarativeParentAction);
+ cpa = new QActionAnimation;
+ QDeclarativeGraphics_setParent_noEvent(cpa, q);
+}
+
+/*!
+ \qmlproperty Item ParentAction::target
+
+ This property holds a target item to reparent.
+
+ In the following example, \c myItem will be reparented by the ParentAction, while
+ \c myOtherItem will not.
+ \qml
+ State {
+ ParentChange {
+ target: myItem
+ parent: newParent
+ }
+ ParentChange {
+ target: myOtherItem
+ parent: otherNewParent
+ }
+ }
+ Transition {
+ SequentialAnimation {
+ PropertyAnimation { ... }
+ ParentAction { target: myItem }
+ PropertyAnimation { ... }
+ }
+ }
+ \endqml
+
+ */
+QDeclarativeItem *QDeclarativeParentAction::object() const
+{
+ Q_D(const QDeclarativeParentAction);
+ return d->pcTarget;
+}
+
+void QDeclarativeParentAction::setObject(QDeclarativeItem *target)
+{
+ Q_D(QDeclarativeParentAction);
+ d->pcTarget = target;
+}
+
+/*!
+ \qmlproperty Item ParentAction::parent
+
+ The item to reparent to (i.e. the new parent).
+ */
+QDeclarativeItem *QDeclarativeParentAction::parent() const
+{
+ Q_D(const QDeclarativeParentAction);
+ return d->pcParent;
+}
+
+void QDeclarativeParentAction::setParent(QDeclarativeItem *parent)
+{
+ Q_D(QDeclarativeParentAction);
+ d->pcParent = parent;
+}
+
+void QDeclarativeParentActionPrivate::doAction()
+{
+ QDeclarativeParentChange pc;
+ pc.setObject(pcTarget);
+ pc.setParent(pcParent);
+ pc.execute();
+}
+
+QAbstractAnimation *QDeclarativeParentAction::qtAnimation()
+{
+ Q_D(QDeclarativeParentAction);
+ return d->cpa;
+}
+
+void QDeclarativeParentAction::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativeParentAction);
+ Q_UNUSED(modified);
+ Q_UNUSED(direction);
+
+ struct QDeclarativeParentActionData : public QAbstractAnimationAction
+ {
+ QDeclarativeParentActionData(): pc(0) {}
+ ~QDeclarativeParentActionData() { delete pc; }
+
+ QDeclarativeStateActions actions;
+ bool reverse;
+ QDeclarativeParentChange *pc;
+ virtual void doAction()
+ {
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QDeclarativeAction &action = actions.at(ii);
+ if (reverse)
+ action.event->reverse();
+ else
+ action.event->execute();
+ }
+ }
+ };
+
+ QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
+
+ //### need to correctly handle modified/done
+
+ bool hasExplicit = false;
+ if (d->pcTarget && d->pcParent) {
+ data->reverse = false;
+ QDeclarativeAction myAction;
+ QDeclarativeParentChange *pc = new QDeclarativeParentChange;
+ pc->setObject(d->pcTarget);
+ pc->setParent(d->pcParent);
+ myAction.event = pc;
+ data->pc = pc;
+ data->actions << myAction;
+ hasExplicit = true;
+ }
+
+ if (!hasExplicit)
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+
+ if (action.event && action.event->typeName() == QLatin1String("ParentChange")
+ && (!d->pcTarget || static_cast<QDeclarativeParentChange*>(action.event)->object() == d->pcTarget)) {
+ QDeclarativeAction myAction = action;
+ data->reverse = action.reverseEvent;
+ //### this logic differs from PropertyAnimation
+ // (probably a result of modified vs. done)
+ if (d->pcParent) {
+ //### should we disallow this case?
+ QDeclarativeParentChange *pc = new QDeclarativeParentChange;
+ pc->setObject(d->pcTarget);
+ pc->setParent(static_cast<QDeclarativeParentChange*>(action.event)->parent());
+ myAction.event = pc;
+ data->pc = pc;
+ data->actions << myAction;
+ break; //only match one
+ } else {
+ action.actionDone = true;
+ data->actions << myAction;
+ }
+ }
+ }
+
+ if (data->actions.count()) {
+ d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
+ } else {
+ delete data;
+ }
+}
+
+
+
+/*!
+ \qmlclass NumberAnimation QDeclarativeNumberAnimation
+ \since 4.7
+ \inherits PropertyAnimation
+ \brief The NumberAnimation element allows you to animate changes in properties of type qreal.
+
+ Animate a set of properties over 200ms, from their values in the start state to
+ their values in the end state of the transition:
+ \code
+ NumberAnimation { properties: "x,y,scale"; duration: 200 }
+ \endcode
+*/
+
+/*!
+ \internal
+ \class QDeclarativeNumberAnimation
+*/
+
+QDeclarativeNumberAnimation::QDeclarativeNumberAnimation(QObject *parent)
+: QDeclarativePropertyAnimation(parent)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+}
+
+QDeclarativeNumberAnimation::~QDeclarativeNumberAnimation()
+{
+}
+
+/*!
+ \qmlproperty real NumberAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+qreal QDeclarativeNumberAnimation::from() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->from.toReal();
+}
+
+void QDeclarativeNumberAnimation::setFrom(qreal f)
+{
+ QDeclarativePropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real NumberAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition or Behavior.
+*/
+qreal QDeclarativeNumberAnimation::to() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->to.toReal();
+}
+
+void QDeclarativeNumberAnimation::setTo(qreal t)
+{
+ QDeclarativePropertyAnimation::setTo(t);
+}
+
+
+
+/*!
+ \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
+ \since 4.7
+ \inherits PropertyAnimation
+ \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeVector3dAnimation
+*/
+
+QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent)
+: QDeclarativePropertyAnimation(parent)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ d->interpolatorType = QMetaType::QVector3D;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultToInterpolatorType = true;
+}
+
+QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation()
+{
+}
+
+/*!
+ \qmlproperty real Vector3dAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+QVector3D QDeclarativeVector3dAnimation::from() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->from.value<QVector3D>();
+}
+
+void QDeclarativeVector3dAnimation::setFrom(QVector3D f)
+{
+ QDeclarativePropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real Vector3dAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition or Behavior.
+*/
+QVector3D QDeclarativeVector3dAnimation::to() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->to.value<QVector3D>();
+}
+
+void QDeclarativeVector3dAnimation::setTo(QVector3D t)
+{
+ QDeclarativePropertyAnimation::setTo(t);
+}
+
+
+
+/*!
+ \qmlclass RotationAnimation QDeclarativeRotationAnimation
+ \since 4.7
+ \inherits PropertyAnimation
+ \brief The RotationAnimation element allows you to animate rotations.
+
+ RotationAnimation is a specialized PropertyAnimation that gives control
+ over the direction of rotation.
+
+ The RotationAnimation in the following example ensures that we always take
+ the shortest rotation path when switching between our states.
+ \qml
+ states: {
+ State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
+ State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } }
+ State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } }
+ }
+ transition: Transition {
+ RotationAnimation { direction: RotationAnimation.Shortest }
+ }
+ \endqml
+
+ By default, when used in a transition RotationAnimation will rotate all
+ properties named "rotation" or "angle". You can override this by providing
+ your own properties via \c properties or \c property.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeRotationAnimation
+*/
+
+QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 180.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff < 0.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 0.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QDeclarativeRotationAnimation::QDeclarativeRotationAnimation(QObject *parent)
+: QDeclarativePropertyAnimation(*(new QDeclarativeRotationAnimationPrivate), parent)
+{
+ Q_D(QDeclarativeRotationAnimation);
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ d->defaultProperties = QLatin1String("rotation,angle");
+}
+
+QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation()
+{
+}
+
+/*!
+ \qmlproperty real RotationAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+qreal QDeclarativeRotationAnimation::from() const
+{
+ Q_D(const QDeclarativeRotationAnimation);
+ return d->from.toReal();
+}
+
+void QDeclarativeRotationAnimation::setFrom(qreal f)
+{
+ QDeclarativePropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real RotationAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition or Behavior.
+*/
+qreal QDeclarativeRotationAnimation::to() const
+{
+ Q_D(const QDeclarativeRotationAnimation);
+ return d->to.toReal();
+}
+
+void QDeclarativeRotationAnimation::setTo(qreal t)
+{
+ QDeclarativePropertyAnimation::setTo(t);
+}
+
+/*!
+ \qmlproperty enum RotationAnimation::direction
+ The direction in which to rotate.
+ Possible values are Numerical, Clockwise, Counterclockwise,
+ or Shortest.
+
+ \table
+ \row
+ \o Numerical
+ \o Rotate by linearly interpolating between the two numbers.
+ A rotation from 10 to 350 will rotate 340 degrees clockwise.
+ \row
+ \o Clockwise
+ \o Rotate clockwise between the two values
+ \row
+ \o Counterclockwise
+ \o Rotate counterclockwise between the two values
+ \row
+ \o Shortest
+ \o Rotate in the direction that produces the shortest animation path.
+ A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
+ \endtable
+
+ The default direction is Shortest.
+*/
+QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const
+{
+ Q_D(const QDeclarativeRotationAnimation);
+ return d->direction;
+}
+
+void QDeclarativeRotationAnimation::setDirection(QDeclarativeRotationAnimation::RotationDirection direction)
+{
+ Q_D(QDeclarativeRotationAnimation);
+ if (d->direction == direction)
+ return;
+
+ d->direction = direction;
+ switch(d->direction) {
+ case Clockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
+ break;
+ case Counterclockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
+ break;
+ case Shortest:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ break;
+ default:
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ break;
+ }
+
+ emit directionChanged();
+}
+
+
+
+QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QObject *parent)
+: QDeclarativeAbstractAnimation(*(new QDeclarativeAnimationGroupPrivate), parent)
+{
+}
+
+QDeclarativeAnimationGroup::QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent)
+ : QDeclarativeAbstractAnimation(dd, parent)
+{
+}
+
+void QDeclarativeAnimationGroupPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a)
+{
+ QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object);
+ if (q) {
+ q->d_func()->animations.append(a);
+ a->setGroup(q);
+ q->d_func()->ag->addAnimation(a->qtAnimation());
+ }
+}
+
+void QDeclarativeAnimationGroupPrivate::clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list)
+{
+ QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object);
+ if (q) {
+ for (int i = 0; i < q->d_func()->animations.count(); ++i)
+ q->d_func()->animations.at(i)->setGroup(0);
+ q->d_func()->animations.clear();
+ }
+}
+
+QDeclarativeAnimationGroup::~QDeclarativeAnimationGroup()
+{
+}
+
+QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGroup::animations()
+{
+ Q_D(QDeclarativeAnimationGroup);
+ QDeclarativeListProperty<QDeclarativeAbstractAnimation> list(this, d->animations);
+ list.append = &QDeclarativeAnimationGroupPrivate::append_animation;
+ list.clear = &QDeclarativeAnimationGroupPrivate::clear_animation;
+ return list;
+}
+
+/*!
+ \qmlclass SequentialAnimation QDeclarativeSequentialAnimation
+ \since 4.7
+ \inherits Animation
+ \brief The SequentialAnimation element allows you to run animations sequentially.
+
+ Animations controlled in SequentialAnimation will be run one after the other.
+
+ The following example chains two numeric animations together. The \c MyItem
+ object will animate from its current x position to 100, and then back to 0.
+
+ \code
+ SequentialAnimation {
+ NumberAnimation { target: MyItem; property: "x"; to: 100 }
+ NumberAnimation { target: MyItem; property: "x"; to: 0 }
+ }
+ \endcode
+
+ \sa ParallelAnimation
+*/
+
+QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) :
+ QDeclarativeAnimationGroup(parent)
+{
+ Q_D(QDeclarativeAnimationGroup);
+ d->ag = new QSequentialAnimationGroup(this);
+}
+
+QDeclarativeSequentialAnimation::~QDeclarativeSequentialAnimation()
+{
+}
+
+QAbstractAnimation *QDeclarativeSequentialAnimation::qtAnimation()
+{
+ Q_D(QDeclarativeAnimationGroup);
+ return d->ag;
+}
+
+void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativeAnimationGroup);
+
+ int inc = 1;
+ int from = 0;
+ if (direction == Backward) {
+ inc = -1;
+ from = d->animations.count() - 1;
+ }
+
+ bool valid = d->defaultProperty.isValid();
+ for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
+ d->animations.at(ii)->transition(actions, modified, direction);
+ }
+}
+
+
+
+/*!
+ \qmlclass ParallelAnimation QDeclarativeParallelAnimation
+ \since 4.7
+ \inherits Animation
+ \brief The ParallelAnimation element allows you to run animations in parallel.
+
+ Animations contained in ParallelAnimation will be run at the same time.
+
+ The following animation demonstrates animating the \c MyItem item
+ to (100,100) by animating the x and y properties in parallel.
+
+ \code
+ ParallelAnimation {
+ NumberAnimation { target: MyItem; property: "x"; to: 100 }
+ NumberAnimation { target: MyItem; property: "y"; to: 100 }
+ }
+ \endcode
+
+ \sa SequentialAnimation
+*/
+/*!
+ \internal
+ \class QDeclarativeParallelAnimation
+*/
+
+QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) :
+ QDeclarativeAnimationGroup(parent)
+{
+ Q_D(QDeclarativeAnimationGroup);
+ d->ag = new QParallelAnimationGroup(this);
+}
+
+QDeclarativeParallelAnimation::~QDeclarativeParallelAnimation()
+{
+}
+
+QAbstractAnimation *QDeclarativeParallelAnimation::qtAnimation()
+{
+ Q_D(QDeclarativeAnimationGroup);
+ return d->ag;
+}
+
+void QDeclarativeParallelAnimation::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativeAnimationGroup);
+ bool valid = d->defaultProperty.isValid();
+ for (int ii = 0; ii < d->animations.count(); ++ii) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
+ d->animations.at(ii)->transition(actions, modified, direction);
+ }
+}
+
+
+
+//convert a variant from string type to another animatable type
+void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
+{
+ if (variant.userType() != QVariant::String) {
+ variant.convert((QVariant::Type)type);
+ return;
+ }
+
+ switch (type) {
+ case QVariant::Rect: {
+ variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()).toRect());
+ break;
+ }
+ case QVariant::RectF: {
+ variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Point: {
+ variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()).toPoint());
+ break;
+ }
+ case QVariant::PointF: {
+ variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Size: {
+ variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()).toSize());
+ break;
+ }
+ case QVariant::SizeF: {
+ variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Color: {
+ variant.setValue(QDeclarativeStringConverters::colorFromString(variant.toString()));
+ break;
+ }
+ case QVariant::Vector3D: {
+ variant.setValue(QDeclarativeStringConverters::vector3DFromString(variant.toString()));
+ break;
+ }
+ default:
+ if ((uint)type >= QVariant::UserType) {
+ QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
+ if (converter)
+ variant = converter(variant.toString());
+ } else
+ variant.convert((QVariant::Type)type);
+ break;
+ }
+}
+
+/*!
+ \qmlclass PropertyAnimation QDeclarativePropertyAnimation
+ \since 4.7
+ \inherits Animation
+ \brief The PropertyAnimation element allows you to animate property changes.
+
+ PropertyAnimation provides a way to animate changes to a property's value. It can
+ be used in many different situations:
+ \list
+ \o In a Transition
+
+ Animate any objects that have changed their x or y properties in the target state using
+ an InOutQuad easing curve:
+ \qml
+ Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } }
+ \endqml
+ \o In a Behavior
+
+ Animate all changes to a rectangle's x property.
+ \qml
+ Rectangle {
+ x: Behavior { PropertyAnimation {} }
+ }
+ \endqml
+ \o As a property value source
+
+ Repeatedly animate the rectangle's x property.
+ \qml
+ Rectangle {
+ x: SequentialAnimation {
+ repeat: true
+ PropertyAnimation { to: 50 }
+ PropertyAnimation { to: 0 }
+ }
+ }
+ \endqml
+ \o In a signal handler
+
+ Fade out \c theObject when clicked:
+ \qml
+ MouseArea {
+ anchors.fill: theObject
+ onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
+ }
+ \endqml
+ \o Standalone
+
+ Animate \c theObject's size property over 200ms, from its current size to 20-by-20:
+ \qml
+ PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 }
+ \endqml
+ \endlist
+
+ Depending on how the animation is used, the set of properties normally used will be
+ different. For more information see the individual property documentation, as well
+ as the \l{QML Animation} introduction.
+*/
+
+QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QObject *parent)
+: QDeclarativeAbstractAnimation(*(new QDeclarativePropertyAnimationPrivate), parent)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ d->init();
+}
+
+QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent)
+: QDeclarativeAbstractAnimation(dd, parent)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ d->init();
+}
+
+QDeclarativePropertyAnimation::~QDeclarativePropertyAnimation()
+{
+}
+
+void QDeclarativePropertyAnimationPrivate::init()
+{
+ Q_Q(QDeclarativePropertyAnimation);
+ va = new QDeclarativeTimeLineValueAnimator;
+ QDeclarativeGraphics_setParent_noEvent(va, q);
+}
+
+/*!
+ \qmlproperty int PropertyAnimation::duration
+ This property holds the duration of the transition, in milliseconds.
+
+ The default value is 250.
+*/
+int QDeclarativePropertyAnimation::duration() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->va->duration();
+}
+
+void QDeclarativePropertyAnimation::setDuration(int duration)
+{
+ if (duration < 0) {
+ qmlInfo(this) << tr("Cannot set a duration of < 0");
+ return;
+ }
+
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->va->duration() == duration)
+ return;
+ d->va->setDuration(duration);
+ emit durationChanged(duration);
+}
+
+/*!
+ \qmlproperty real PropertyAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+QVariant QDeclarativePropertyAnimation::from() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->from;
+}
+
+void QDeclarativePropertyAnimation::setFrom(const QVariant &f)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->fromIsDefined && f == d->from)
+ return;
+ d->from = f;
+ d->fromIsDefined = f.isValid();
+ emit fromChanged(f);
+}
+
+/*!
+ \qmlproperty real PropertyAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition or Behavior.
+*/
+QVariant QDeclarativePropertyAnimation::to() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->to;
+}
+
+void QDeclarativePropertyAnimation::setTo(const QVariant &t)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->toIsDefined && t == d->to)
+ return;
+ d->to = t;
+ d->toIsDefined = t.isValid();
+ emit toChanged(t);
+}
+
+/*!
+ \qmlproperty QEasingCurve PropertyAnimation::easing
+ \brief the easing curve used for the transition.
+
+ Available values are:
+
+ \table
+ \row
+ \o \c Linear
+ \o Easing curve for a linear (t) function: velocity is constant.
+ \o \inlineimage qeasingcurve-linear.png
+ \row
+ \o \c InQuad
+ \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inquad.png
+ \row
+ \o \c OutQuad
+ \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity.
+ \o \inlineimage qeasingcurve-outquad.png
+ \row
+ \o \c InOutQuad
+ \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutquad.png
+ \row
+ \o \c OutInQuad
+ \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinquad.png
+ \row
+ \o \c InCubic
+ \o Easing curve for a cubic (t^3) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-incubic.png
+ \row
+ \o \c OutCubic
+ \o Easing curve for a cubic (t^3) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outcubic.png
+ \row
+ \o \c InOutCubic
+ \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutcubic.png
+ \row
+ \o \c OutInCubic
+ \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outincubic.png
+ \row
+ \o \c InQuart
+ \o Easing curve for a quartic (t^4) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inquart.png
+ \row
+ \o \c OutQuart
+ \o Easing curve for a cubic (t^4) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outquart.png
+ \row
+ \o \c InOutQuart
+ \o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutquart.png
+ \row
+ \o \c OutInQuart
+ \o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinquart.png
+ \row
+ \o \c InQuint
+ \o Easing curve for a quintic (t^5) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inquint.png
+ \row
+ \o \c OutQuint
+ \o Easing curve for a cubic (t^5) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outquint.png
+ \row
+ \o \c InOutQuint
+ \o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutquint.png
+ \row
+ \o \c OutInQuint
+ \o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinquint.png
+ \row
+ \o \c InSine
+ \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-insine.png
+ \row
+ \o \c OutSine
+ \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outsine.png
+ \row
+ \o \c InOutSine
+ \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutsine.png
+ \row
+ \o \c OutInSine
+ \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinsine.png
+ \row
+ \o \c InExpo
+ \o Easing curve for an exponential (2^t) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inexpo.png
+ \row
+ \o \c OutExpo
+ \o Easing curve for an exponential (2^t) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outexpo.png
+ \row
+ \o \c InOutExpo
+ \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutexpo.png
+ \row
+ \o \c OutInExpo
+ \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinexpo.png
+ \row
+ \o \c InCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-incirc.png
+ \row
+ \o \c OutCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outcirc.png
+ \row
+ \o \c InOutCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutcirc.png
+ \row
+ \o \c OutInCirc
+ \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outincirc.png
+ \row
+ \o \c InElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
+ \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \o \inlineimage qeasingcurve-inelastic.png
+ \row
+ \o \c OutElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
+ \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \o \inlineimage qeasingcurve-outelastic.png
+ \row
+ \o \c InOutElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutelastic.png
+ \row
+ \o \c OutInElastic
+ \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinelastic.png
+ \row
+ \o \c InBack
+ \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inback.png
+ \row
+ \o \c OutBack
+ \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
+ \o \inlineimage qeasingcurve-outback.png
+ \row
+ \o \c InOutBack
+ \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutback.png
+ \row
+ \o \c OutInBack
+ \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinback.png
+ \row
+ \o \c InBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
+ \o \inlineimage qeasingcurve-inbounce.png
+ \row
+ \o \c OutBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
+ \o \inlineimage qeasingcurve-outbounce.png
+ \row
+ \o \c InOutBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
+ \o \inlineimage qeasingcurve-inoutbounce.png
+ \row
+ \o \c OutInBounce
+ \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
+ \o \inlineimage qeasingcurve-outinbounce.png
+ \endtable
+
+*/
+QEasingCurve QDeclarativePropertyAnimation::easing() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->easing;
+}
+
+void QDeclarativePropertyAnimation::setEasing(const QEasingCurve &e)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->easing == e)
+ return;
+
+ d->easing = e;
+ d->va->setEasingCurve(d->easing);
+ emit easingChanged(e);
+}
+
+QObject *QDeclarativePropertyAnimation::target() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->target;
+}
+
+void QDeclarativePropertyAnimation::setTarget(QObject *o)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->target == o)
+ return;
+ d->target = o;
+ emit targetChanged(d->target, d->propertyName);
+}
+
+QString QDeclarativePropertyAnimation::property() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->propertyName;
+}
+
+void QDeclarativePropertyAnimation::setProperty(const QString &n)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->propertyName == n)
+ return;
+ d->propertyName = n;
+ emit targetChanged(d->target, d->propertyName);
+}
+
+QString QDeclarativePropertyAnimation::properties() const
+{
+ Q_D(const QDeclarativePropertyAnimation);
+ return d->properties;
+}
+
+void QDeclarativePropertyAnimation::setProperties(const QString &prop)
+{
+ Q_D(QDeclarativePropertyAnimation);
+ if (d->properties == prop)
+ return;
+
+ d->properties = prop;
+ emit propertiesChanged(prop);
+}
+
+/*!
+ \qmlproperty string PropertyAnimation::property
+ \qmlproperty string PropertyAnimation::properties
+ \qmlproperty Object PropertyAnimation::target
+ \qmlproperty list<Object> PropertyAnimation::targets
+
+ These properties are used as a set to determine which properties should be animated.
+ The singular and plural forms are functionally identical, e.g.
+ \qml
+ NumberAnimation { target: theItem; property: "x"; to: 500 }
+ \endqml
+ has the same meaning as
+ \qml
+ NumberAnimation { targets: theItem; properties: "x"; to: 500 }
+ \endqml
+ The singular forms are slightly optimized, so if you do have only a single target/property
+ to animate you should try to use them.
+
+ In many cases these properties do not need to be explicitly specified -- they can be
+ inferred from the animation framework.
+ \table 80%
+ \row
+ \o Value Source / Behavior
+ \o When an animation is used as a value source or in a Behavior, the default target and property
+ name to be animated can both be inferred.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
+ y: Behavior { NumberAnimation {} } //animate theRect's y property
+ }
+ \endqml
+ \row
+ \o Transition
+ \o When used in a transition, a property animation is assumed to match \e all targets
+ but \e no properties. In practice, that means you need to specify at least the properties
+ in order for the animation to do anything.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ Item { id: uselessItem }
+ states: State {
+ name: "state1"
+ PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
+ PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
+ }
+ transitions: Transition {
+ //animate both theRect's and uselessItem's x and y to their final values
+ NumberAnimation { properties: "x,y" }
+
+ //animate theRect's z to its final value
+ NumberAnimation { target: theRect; property: "z" }
+ }
+ }
+ \endqml
+ \row
+ \o Standalone
+ \o When an animation is used standalone, both the target and property need to be
+ explicitly specified.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ //need to explicitly specify target and property
+ NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: theAnim.start()
+ }
+ }
+ \endqml
+ \endtable
+
+ As seen in the above example, properties is specified as a comma-separated string of property names to animate.
+
+ \sa exclude
+*/
+QDeclarativeListProperty<QObject> QDeclarativePropertyAnimation::targets()
+{
+ Q_D(QDeclarativePropertyAnimation);
+ return QDeclarativeListProperty<QObject>(this, d->targets);
+}
+
+/*!
+ \qmlproperty list<Object> PropertyAnimation::exclude
+ This property holds the items not to be affected by this animation.
+ \sa targets
+*/
+QDeclarativeListProperty<QObject> QDeclarativePropertyAnimation::exclude()
+{
+ Q_D(QDeclarativePropertyAnimation);
+ return QDeclarativeListProperty<QObject>(this, d->exclude);
+}
+
+QAbstractAnimation *QDeclarativePropertyAnimation::qtAnimation()
+{
+ Q_D(QDeclarativePropertyAnimation);
+ return d->va;
+}
+
+struct PropertyUpdater : public QDeclarativeTimeLineValue
+{
+ QDeclarativeStateActions actions;
+ int interpolatorType; //for Number/ColorAnimation
+ int prevInterpolatorType; //for generic
+ QVariantAnimation::Interpolator interpolator;
+ bool reverse;
+ bool fromSourced;
+ bool fromDefined;
+ bool *wasDeleted;
+ PropertyUpdater() : wasDeleted(0) {}
+ ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
+ void setValue(qreal v)
+ {
+ bool deleted = false;
+ wasDeleted = &deleted;
+ if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
+ v = 1 - v;
+ QDeclarativeTimeLineValue::setValue(v);
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+
+ if (v == 1.)
+ QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ else {
+ if (!fromSourced && !fromDefined) {
+ action.fromValue = action.property.read();
+ if (interpolatorType)
+ QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
+ }
+ if (!interpolatorType) {
+ int propType = action.property.propertyType();
+ if (!prevInterpolatorType || prevInterpolatorType != propType) {
+ prevInterpolatorType = propType;
+ interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
+ }
+ }
+ if (interpolator)
+ QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ }
+ if (deleted)
+ return;
+ }
+ wasDeleted = 0;
+ fromSourced = true;
+ }
+};
+
+void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativePropertyAnimation);
+
+ QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
+ for (int ii = 0; ii < props.count(); ++ii)
+ props[ii] = props.at(ii).trimmed();
+ if (!d->propertyName.isEmpty())
+ props << d->propertyName;
+
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
+
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
+ }
+
+ if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
+ props << d->defaultProperties.split(QLatin1Char(','));
+ }
+
+ PropertyUpdater *data = new PropertyUpdater;
+ data->interpolatorType = d->interpolatorType;
+ data->interpolator = d->interpolator;
+ data->reverse = direction == Backward ? true : false;
+ data->fromSourced = false;
+ data->fromDefined = d->fromIsDefined;
+
+ bool hasExplicit = false;
+ //an explicit animation has been specified
+ if (d->toIsDefined) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QDeclarativeAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ if (d->fromIsDefined) {
+ myAction.fromValue = d->from;
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ }
+ myAction.toValue = d->to;
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!hasExplicit)
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QDeclarativeAction &action = actions[ii];
+
+ QObject *obj = action.property.object();
+ QString propertyName = action.property.name();
+ QObject *sObj = action.specifiedObject;
+ QString sPropertyName = action.specifiedProperty;
+ bool same = (obj == sObj);
+
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
+ (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
+ (props.contains(propertyName) || (!same && props.contains(sPropertyName))
+ || (useType && action.property.propertyType() == d->interpolatorType))) {
+ QDeclarativeAction myAction = action;
+
+ if (d->fromIsDefined)
+ myAction.fromValue = d->from;
+ else
+ myAction.fromValue = QVariant();
+ if (d->toIsDefined)
+ myAction.toValue = d->to;
+
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+
+ modified << action.property;
+
+ data->actions << myAction;
+ action.fromValue = myAction.toValue;
+ }
+ }
+
+ if (data->actions.count()) {
+ if (!d->rangeIsSet) {
+ d->va->setStartValue(qreal(0));
+ d->va->setEndValue(qreal(1));
+ d->rangeIsSet = true;
+ }
+ d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
+ d->va->setFromSourcedValue(&data->fromSourced);
+ } else {
+ delete data;
+ }
+}
+
+QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent)
+ : QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->topLevelGroup = new QSequentialAnimationGroup;
+ QDeclarativeGraphics_setParent_noEvent(d->topLevelGroup, this);
+
+ d->startAction = new QActionAnimation;
+ d->topLevelGroup->addAnimation(d->startAction);
+
+ d->ag = new QParallelAnimationGroup;
+ d->topLevelGroup->addAnimation(d->ag);
+
+ d->endAction = new QActionAnimation;
+ d->topLevelGroup->addAnimation(d->endAction);
+}
+
+QDeclarativeParentAnimation::~QDeclarativeParentAnimation()
+{
+}
+
+QDeclarativeItem *QDeclarativeParentAnimation::target() const
+{
+ Q_D(const QDeclarativeParentAnimation);
+ return d->target;
+}
+
+void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->target = target;
+}
+
+QDeclarativeItem *QDeclarativeParentAnimation::newParent() const
+{
+ Q_D(const QDeclarativeParentAnimation);
+ return d->newParent;
+}
+
+void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->newParent = newParent;
+}
+
+QDeclarativeItem *QDeclarativeParentAnimation::via() const
+{
+ Q_D(const QDeclarativeParentAnimation);
+ return d->via;
+}
+
+void QDeclarativeParentAnimation::setVia(QDeclarativeItem *via)
+{
+ Q_D(QDeclarativeParentAnimation);
+ d->via = via;
+}
+
+//### mirrors same-named function in QDeclarativeItem
+QPointF QDeclarativeParentAnimationPrivate::computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const
+{
+ switch(origin) {
+ default:
+ case QDeclarativeItem::TopLeft:
+ return QPointF(0, 0);
+ case QDeclarativeItem::Top:
+ return QPointF(width / 2., 0);
+ case QDeclarativeItem::TopRight:
+ return QPointF(width, 0);
+ case QDeclarativeItem::Left:
+ return QPointF(0, height / 2.);
+ case QDeclarativeItem::Center:
+ return QPointF(width / 2., height / 2.);
+ case QDeclarativeItem::Right:
+ return QPointF(width, height / 2.);
+ case QDeclarativeItem::BottomLeft:
+ return QPointF(0, height);
+ case QDeclarativeItem::Bottom:
+ return QPointF(width / 2., height);
+ case QDeclarativeItem::BottomRight:
+ return QPointF(width, height);
+ }
+}
+
+void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction)
+{
+ Q_D(QDeclarativeParentAnimation);
+
+ struct QDeclarativeParentActionData : public QAbstractAnimationAction
+ {
+ QDeclarativeParentActionData(): pc(0) {}
+ ~QDeclarativeParentActionData() { delete pc; }
+
+ QDeclarativeStateActions actions;
+ bool reverse;
+ QDeclarativeParentChange *pc;
+ virtual void doAction()
+ {
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ const QDeclarativeAction &action = actions.at(ii);
+ if (reverse)
+ action.event->reverse();
+ else
+ action.event->execute();
+ }
+ }
+ };
+
+ QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
+ QDeclarativeParentActionData *viaData = new QDeclarativeParentActionData;
+ for (int i = 0; i < actions.size(); ++i) {
+ QDeclarativeAction &action = actions[i];
+ if (action.event && action.event->typeName() == QLatin1String("ParentChange")
+ && (!d->target || static_cast<QDeclarativeParentChange*>(action.event)->object() == d->target)) {
+
+ QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(action.event);
+ QDeclarativeAction myAction = action;
+ data->reverse = action.reverseEvent;
+ action.actionDone = true;
+ data->actions << myAction;
+
+ if (d->via) {
+ viaData->reverse = false;
+ QDeclarativeAction myAction;
+ QDeclarativeParentChange *vpc = new QDeclarativeParentChange;
+ vpc->setObject(pc->object());
+ vpc->setParent(d->via);
+ myAction.event = vpc;
+ viaData->pc = vpc;
+ viaData->actions << myAction;
+ QDeclarativeAction dummyAction;
+ QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction;
+ QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction;
+ QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction;
+ QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction;
+ bool forward = (direction == QDeclarativeAbstractAnimation::Forward);
+ QDeclarativeItem *target = pc->object();
+ QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent();
+
+ //### this mirrors the logic in QDeclarativeParentChange.
+ bool ok;
+ const QTransform &transform = targetParent->itemTransform(d->via, &ok);
+ if (transform.type() >= QTransform::TxShear || !ok) {
+ qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under complex transform");
+ ok = false;
+ }
+
+ qreal scale = 1;
+ qreal rotation = 0;
+ if (ok && transform.type() != QTransform::TxRotate) {
+ if (transform.m11() == transform.m22())
+ scale = transform.m11();
+ else {
+ qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+ } else if (ok && transform.type() == QTransform::TxRotate) {
+ if (transform.m11() == transform.m22())
+ scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
+ else {
+ qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+
+ if (scale != 0)
+ rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
+ else {
+ qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under scale of 0");
+ ok = false;
+ }
+ }
+
+ const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal()));
+ qreal x = point.x();
+ qreal y = point.y();
+ if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) {
+ qreal w = target->width();
+ qreal h = target->height();
+ if (pc->widthIsSet())
+ w = actions[++i].toValue.toReal();
+ if (pc->heightIsSet())
+ h = actions[++i].toValue.toReal();
+ const QPointF &transformOrigin
+ = d->computeTransformOrigin(target->transformOrigin(), w,h);
+ qreal tempxt = transformOrigin.x();
+ qreal tempyt = transformOrigin.y();
+ QTransform t;
+ t.translate(-tempxt, -tempyt);
+ t.rotate(rotation);
+ t.scale(scale, scale);
+ t.translate(tempxt, tempyt);
+ const QPointF &offset = t.map(QPointF(0,0));
+ x += offset.x();
+ y += offset.y();
+ }
+
+ if (ok) {
+ //qDebug() << x << y << rotation << scale;
+ xAction.toValue = x;
+ yAction.toValue = y;
+ sAction.toValue = sAction.toValue.toReal() * scale;
+ rAction.toValue = rAction.toValue.toReal() + rotation;
+ }
+ }
+ }
+ }
+
+ if (data->actions.count()) {
+ if (direction == QDeclarativeAbstractAnimation::Forward) {
+ d->startAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped);
+ d->endAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped);
+ } else {
+ d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped);
+ d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped);
+ }
+ } else {
+ delete data;
+ delete viaData;
+ }
+
+ //take care of any child animations
+ bool valid = d->defaultProperty.isValid();
+ for (int ii = 0; ii < d->animations.count(); ++ii) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
+ d->animations.at(ii)->transition(actions, modified, direction);
+ }
+
+}
+
+QAbstractAnimation *QDeclarativeParentAnimation::qtAnimation()
+{
+ Q_D(QDeclarativeParentAnimation);
+ return d->topLevelGroup;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
new file mode 100644
index 0000000000..0f23f5ca49
--- /dev/null
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -0,0 +1,501 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEANIMATION_H
+#define QDECLARATIVEANIMATION_H
+
+#include "qdeclarativetransition_p.h"
+#include "qdeclarativestate_p.h"
+#include <QtGui/qvector3d.h>
+
+#include <qdeclarativepropertyvaluesource.h>
+#include <qdeclarative.h>
+#include <qdeclarativescriptstring.h>
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qeasingcurve.h>
+#include <QtCore/QAbstractAnimation>
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeAbstractAnimationPrivate;
+class QDeclarativeAnimationGroup;
+class Q_AUTOTEST_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeAbstractAnimation)
+
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_INTERFACES(QDeclarativePropertyValueSource)
+ Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged())
+ Q_PROPERTY(bool repeat READ repeat WRITE setRepeat NOTIFY repeatChanged)
+ Q_CLASSINFO("DefaultMethod", "start()")
+
+public:
+ QDeclarativeAbstractAnimation(QObject *parent=0);
+ virtual ~QDeclarativeAbstractAnimation();
+
+ bool isRunning() const;
+ void setRunning(bool);
+ bool isPaused() const;
+ void setPaused(bool);
+ bool alwaysRunToEnd() const;
+ void setAlwaysRunToEnd(bool);
+ bool repeat() const;
+ void setRepeat(bool);
+
+ int currentTime();
+ void setCurrentTime(int);
+
+ QDeclarativeAnimationGroup *group() const;
+ void setGroup(QDeclarativeAnimationGroup *);
+
+ void setDefaultTarget(const QDeclarativeProperty &);
+ void setDisableUserControl();
+
+ void classBegin();
+ void componentComplete();
+
+Q_SIGNALS:
+ void started();
+ void completed();
+ void runningChanged(bool);
+ void pausedChanged(bool);
+ void repeatChanged(bool);
+ void alwaysRunToEndChanged(bool);
+
+public Q_SLOTS:
+ void restart();
+ void start();
+ void pause();
+ void resume();
+ void stop();
+ void complete();
+
+protected:
+ QDeclarativeAbstractAnimation(QDeclarativeAbstractAnimationPrivate &dd, QObject *parent);
+
+public:
+ enum TransitionDirection { Forward, Backward };
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation() = 0;
+
+private Q_SLOTS:
+ void timelineComplete();
+
+private:
+ virtual void setTarget(const QDeclarativeProperty &);
+};
+
+class QDeclarativePauseAnimationPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativePauseAnimation : public QDeclarativeAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePauseAnimation)
+
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+
+public:
+ QDeclarativePauseAnimation(QObject *parent=0);
+ virtual ~QDeclarativePauseAnimation();
+
+ int duration() const;
+ void setDuration(int);
+
+Q_SIGNALS:
+ void durationChanged(int);
+
+protected:
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+class QDeclarativeScriptActionPrivate;
+class QDeclarativeScriptAction : public QDeclarativeAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeScriptAction)
+
+ Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
+ Q_PROPERTY(QString stateChangeScriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
+
+public:
+ QDeclarativeScriptAction(QObject *parent=0);
+ virtual ~QDeclarativeScriptAction();
+
+ QDeclarativeScriptString script() const;
+ void setScript(const QDeclarativeScriptString &);
+
+ QString stateChangeScriptName() const;
+ void setStateChangeScriptName(const QString &);
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+class QDeclarativePropertyActionPrivate;
+class QDeclarativePropertyAction : public QDeclarativeAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePropertyAction)
+
+ Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
+ Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
+
+public:
+ QDeclarativePropertyAction(QObject *parent=0);
+ virtual ~QDeclarativePropertyAction();
+
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
+ QString properties() const;
+ void setProperties(const QString &);
+
+ QDeclarativeListProperty<QObject> targets();
+ QDeclarativeListProperty<QObject> exclude();
+
+ QVariant value() const;
+ void setValue(const QVariant &);
+
+Q_SIGNALS:
+ void valueChanged(const QVariant &);
+ void propertiesChanged(const QString &);
+ void targetChanged(QObject *, const QString &);
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+class QDeclarativeItem;
+class QDeclarativeParentActionPrivate;
+class QDeclarativeParentAction : public QDeclarativeAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeParentAction)
+
+ Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
+ Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) //### newParent
+
+public:
+ QDeclarativeParentAction(QObject *parent=0);
+ virtual ~QDeclarativeParentAction();
+
+ QDeclarativeItem *object() const;
+ void setObject(QDeclarativeItem *);
+
+ QDeclarativeItem *parent() const;
+ void setParent(QDeclarativeItem *);
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+class QDeclarativePropertyAnimationPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
+
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
+ Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> targets READ targets)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> exclude READ exclude)
+
+public:
+ QDeclarativePropertyAnimation(QObject *parent=0);
+ virtual ~QDeclarativePropertyAnimation();
+
+ int duration() const;
+ void setDuration(int);
+
+ QVariant from() const;
+ void setFrom(const QVariant &);
+
+ QVariant to() const;
+ void setTo(const QVariant &);
+
+ QEasingCurve easing() const;
+ void setEasing(const QEasingCurve &);
+
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
+ QString properties() const;
+ void setProperties(const QString &);
+
+ QDeclarativeListProperty<QObject> targets();
+ QDeclarativeListProperty<QObject> exclude();
+
+protected:
+ QDeclarativePropertyAnimation(QDeclarativePropertyAnimationPrivate &dd, QObject *parent);
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+
+Q_SIGNALS:
+ void durationChanged(int);
+ void fromChanged(QVariant);
+ void toChanged(QVariant);
+ void easingChanged(const QEasingCurve &);
+ void propertiesChanged(const QString &);
+ void targetChanged(QObject *, const QString &);
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeColorAnimation : public QDeclarativePropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
+ Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged)
+
+public:
+ QDeclarativeColorAnimation(QObject *parent=0);
+ virtual ~QDeclarativeColorAnimation();
+
+ QColor from() const;
+ void setFrom(const QColor &);
+
+ QColor to() const;
+ void setTo(const QColor &);
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeNumberAnimation : public QDeclarativePropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+
+public:
+ QDeclarativeNumberAnimation(QObject *parent=0);
+ virtual ~QDeclarativeNumberAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
+};
+
+class Q_AUTOTEST_EXPORT QDeclarativeVector3dAnimation : public QDeclarativePropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePropertyAnimation)
+
+ Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
+
+public:
+ QDeclarativeVector3dAnimation(QObject *parent=0);
+ virtual ~QDeclarativeVector3dAnimation();
+
+ QVector3D from() const;
+ void setFrom(QVector3D);
+
+ QVector3D to() const;
+ void setTo(QVector3D);
+};
+
+class QDeclarativeRotationAnimationPrivate;
+class Q_AUTOTEST_EXPORT QDeclarativeRotationAnimation : public QDeclarativePropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeRotationAnimation)
+ Q_ENUMS(RotationDirection)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+
+public:
+ QDeclarativeRotationAnimation(QObject *parent=0);
+ virtual ~QDeclarativeRotationAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
+
+ enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
+ RotationDirection direction() const;
+ void setDirection(RotationDirection direction);
+
+Q_SIGNALS:
+ void directionChanged();
+};
+
+class QDeclarativeAnimationGroupPrivate;
+class QDeclarativeAnimationGroup : public QDeclarativeAbstractAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
+
+ Q_CLASSINFO("DefaultProperty", "animations")
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
+
+public:
+ QDeclarativeAnimationGroup(QObject *parent);
+ virtual ~QDeclarativeAnimationGroup();
+
+ QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
+ friend class QDeclarativeAbstractAnimation;
+
+protected:
+ QDeclarativeAnimationGroup(QDeclarativeAnimationGroupPrivate &dd, QObject *parent);
+};
+
+class QDeclarativeSequentialAnimation : public QDeclarativeAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
+
+public:
+ QDeclarativeSequentialAnimation(QObject *parent=0);
+ virtual ~QDeclarativeSequentialAnimation();
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+class QDeclarativeParallelAnimation : public QDeclarativeAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeAnimationGroup)
+
+public:
+ QDeclarativeParallelAnimation(QObject *parent=0);
+ virtual ~QDeclarativeParallelAnimation();
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+class QDeclarativeParentAnimationPrivate;
+class QDeclarativeParentAnimation : public QDeclarativeAnimationGroup
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeParentAnimation)
+
+ Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget)
+ //Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
+ Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia)
+
+public:
+ QDeclarativeParentAnimation(QObject *parent=0);
+ virtual ~QDeclarativeParentAnimation();
+
+ QDeclarativeItem *target() const;
+ void setTarget(QDeclarativeItem *);
+
+ QDeclarativeItem *newParent() const;
+ void setNewParent(QDeclarativeItem *);
+
+ QDeclarativeItem *via() const;
+ void setVia(QDeclarativeItem *);
+
+protected:
+ virtual void transition(QDeclarativeStateActions &actions,
+ QDeclarativeProperties &modified,
+ TransitionDirection direction);
+ virtual QAbstractAnimation *qtAnimation();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeAbstractAnimation)
+QML_DECLARE_TYPE(QDeclarativePauseAnimation)
+QML_DECLARE_TYPE(QDeclarativeScriptAction)
+QML_DECLARE_TYPE(QDeclarativePropertyAction)
+QML_DECLARE_TYPE(QDeclarativeParentAction)
+QML_DECLARE_TYPE(QDeclarativePropertyAnimation)
+QML_DECLARE_TYPE(QDeclarativeColorAnimation)
+QML_DECLARE_TYPE(QDeclarativeNumberAnimation)
+QML_DECLARE_TYPE(QDeclarativeSequentialAnimation)
+QML_DECLARE_TYPE(QDeclarativeParallelAnimation)
+QML_DECLARE_TYPE(QDeclarativeVector3dAnimation)
+QML_DECLARE_TYPE(QDeclarativeRotationAnimation)
+QML_DECLARE_TYPE(QDeclarativeParentAnimation)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEANIMATION_H
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
new file mode 100644
index 0000000000..e5820664f2
--- /dev/null
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -0,0 +1,391 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEANIMATION_P_H
+#define QDECLARATIVEANIMATION_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 "qdeclarativeanimation_p.h"
+
+#include "qdeclarativenullablevalue_p_p.h"
+#include "qdeclarativetimeline_p_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativecontext.h>
+
+#include <QtCore/QPauseAnimation>
+#include <QtCore/QVariantAnimation>
+#include <QtCore/QAnimationGroup>
+#include <QtGui/QColor>
+#include <QDebug>
+
+#include <private/qobject_p.h>
+#include <private/qvariantanimation_p.h>
+
+QT_BEGIN_NAMESPACE
+
+//interface for classes that provide animation actions for QActionAnimation
+class QAbstractAnimationAction
+{
+public:
+ virtual ~QAbstractAnimationAction() {}
+ virtual void doAction() = 0;
+};
+
+//templated animation action
+//allows us to specify an action that calls a function of a class.
+//(so that class doesn't have to inherit QDeclarativeAbstractAnimationAction)
+template<class T, void (T::*method)()>
+class QAnimationActionProxy : public QAbstractAnimationAction
+{
+public:
+ QAnimationActionProxy(T *p) : m_p(p) {}
+ virtual void doAction() { (m_p->*method)(); }
+
+private:
+ T *m_p;
+};
+
+//performs an action of type QAbstractAnimationAction
+class QActionAnimation : public QAbstractAnimation
+{
+ Q_OBJECT
+public:
+ QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped), running(false) {}
+ QActionAnimation(QAbstractAnimationAction *action, QObject *parent = 0)
+ : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped), running(false) {}
+ ~QActionAnimation() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } }
+ virtual int duration() const { return 0; }
+ void clearAnimAction()
+ {
+ if (policy == DeleteWhenStopped)
+ delete animAction;
+ animAction = 0;
+ }
+ void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p)
+ {
+ if (state() == Running)
+ stop();
+ if (policy == DeleteWhenStopped)
+ delete animAction;
+ animAction = action;
+ policy = p;
+ }
+protected:
+ virtual void updateCurrentTime(int) {}
+
+ virtual void updateState(State newState, State /*oldState*/)
+ {
+ if (newState == Running) {
+ if (animAction) {
+ running = true;
+ animAction->doAction();
+ running = false;
+ if (state() == Stopped && policy == DeleteWhenStopped) {
+ delete animAction;
+ animAction = 0;
+ }
+ }
+ } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
+ if (!running) {
+ delete animAction;
+ animAction = 0;
+ }
+ }*/
+ }
+
+private:
+ QAbstractAnimationAction *animAction;
+ DeletionPolicy policy;
+ bool running;
+};
+
+//animates QDeclarativeTimeLineValue (assumes start and end values will be reals or compatible)
+class QDeclarativeTimeLineValueAnimator : public QVariantAnimation
+{
+ Q_OBJECT
+public:
+ QDeclarativeTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
+ ~QDeclarativeTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
+ void setAnimValue(QDeclarativeTimeLineValue *value, DeletionPolicy p)
+ {
+ if (state() == Running)
+ stop();
+ if (policy == DeleteWhenStopped)
+ delete animValue;
+ animValue = value;
+ policy = p;
+ }
+ void setFromSourcedValue(bool *value)
+ {
+ fromSourced = value;
+ }
+protected:
+ virtual void updateCurrentValue(const QVariant &value)
+ {
+ if (state() == QAbstractAnimation::Stopped)
+ return;
+
+ if (animValue)
+ animValue->setValue(value.toReal());
+ }
+ virtual void updateState(State newState, State oldState)
+ {
+ QVariantAnimation::updateState(newState, oldState);
+ if (newState == Running) {
+ //check for new from every loop
+ if (fromSourced)
+ *fromSourced = false;
+ } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
+ delete animValue;
+ animValue = 0;
+ }*/ //### we get a stop each loop if we are in a group
+ //### top-level animation is the only reliable one for this
+ }
+
+private:
+ QDeclarativeTimeLineValue *animValue;
+ bool *fromSourced;
+ DeletionPolicy policy;
+};
+
+//an animation that just gives a tick
+template<class T, void (T::*method)(int)>
+class QTickAnimationProxy : public QAbstractAnimation
+{
+ //Q_OBJECT //doesn't work with templating
+public:
+ QTickAnimationProxy(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {}
+ virtual int duration() const { return -1; }
+protected:
+ virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); }
+
+private:
+ T *m_p;
+};
+
+class QDeclarativeAbstractAnimationPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeAbstractAnimation)
+public:
+ QDeclarativeAbstractAnimationPrivate()
+ : running(false), paused(false), alwaysRunToEnd(false), repeat(false),
+ connectedTimeLine(false), componentComplete(true),
+ avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {}
+
+ bool running:1;
+ bool paused:1;
+ bool alwaysRunToEnd:1;
+ bool repeat:1;
+ bool connectedTimeLine:1;
+ bool componentComplete:1;
+ bool avoidPropertyValueSourceStart:1;
+ bool disableUserControl:1;
+
+ void commence();
+
+ QDeclarativeProperty defaultProperty;
+
+ QDeclarativeAnimationGroup *group;
+
+ static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
+};
+
+class QDeclarativePauseAnimationPrivate : public QDeclarativeAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePauseAnimation)
+public:
+ QDeclarativePauseAnimationPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), pa(0) {}
+
+ void init();
+
+ QPauseAnimation *pa;
+};
+
+class QDeclarativeScriptActionPrivate : public QDeclarativeAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeScriptAction)
+public:
+ QDeclarativeScriptActionPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), proxy(this), rsa(0) {}
+
+ void init();
+
+ QDeclarativeScriptString script;
+ QString name;
+ QDeclarativeScriptString runScriptScript;
+ bool hasRunScriptScript;
+
+ void execute();
+
+ QAnimationActionProxy<QDeclarativeScriptActionPrivate,
+ &QDeclarativeScriptActionPrivate::execute> proxy;
+ QActionAnimation *rsa;
+};
+
+class QDeclarativePropertyActionPrivate : public QDeclarativeAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePropertyAction)
+public:
+ QDeclarativePropertyActionPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), target(0), spa(0) {}
+
+ void init();
+
+ QObject *target;
+ QString propertyName;
+ QString properties;
+ QList<QObject *> targets;
+ QList<QObject *> exclude;
+
+ QDeclarativeNullableValue<QVariant> value;
+
+ QActionAnimation *spa;
+};
+
+class QDeclarativeParentActionPrivate : public QDeclarativeAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeParentAction)
+public:
+ QDeclarativeParentActionPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {}
+
+ void init();
+
+ QDeclarativeItem *pcTarget;
+ QDeclarativeItem *pcParent;
+
+ void doAction();
+ QActionAnimation *cpa;
+};
+
+class QDeclarativeAnimationGroupPrivate : public QDeclarativeAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeAnimationGroup)
+public:
+ QDeclarativeAnimationGroupPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), ag(0) {}
+
+ static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *role);
+ static void clear_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list);
+ QList<QDeclarativeAbstractAnimation *> animations;
+ QAnimationGroup *ag;
+};
+
+class QDeclarativePropertyAnimationPrivate : public QDeclarativeAbstractAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePropertyAnimation)
+public:
+ QDeclarativePropertyAnimationPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
+ rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {}
+
+ void init();
+
+ QVariant from;
+ QVariant to;
+
+ QEasingCurve easing;
+
+ QObject *target;
+ QString propertyName;
+ QString properties;
+ QList<QObject *> targets;
+ QList<QObject *> exclude;
+ QString defaultProperties;
+
+ bool fromSourced;
+ bool fromIsDefined:1;
+ bool toIsDefined:1;
+ bool rangeIsSet:1;
+ bool defaultToInterpolatorType:1;
+ int interpolatorType;
+ QVariantAnimation::Interpolator interpolator;
+
+ QDeclarativeTimeLineValueAnimator *va;
+
+ static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
+ static void convertVariant(QVariant &variant, int type);
+};
+
+class QDeclarativeRotationAnimationPrivate : public QDeclarativePropertyAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeRotationAnimation)
+public:
+ QDeclarativeRotationAnimationPrivate() : direction(QDeclarativeRotationAnimation::Shortest) {}
+
+ QDeclarativeRotationAnimation::RotationDirection direction;
+};
+
+class QDeclarativeParentAnimationPrivate : public QDeclarativeAnimationGroupPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeParentAnimation)
+public:
+ QDeclarativeParentAnimationPrivate()
+ : QDeclarativeAnimationGroupPrivate(), target(0), newParent(0),
+ via(0), topLevelGroup(0), startAction(0), endAction(0) {}
+
+ QDeclarativeItem *target;
+ QDeclarativeItem *newParent;
+ QDeclarativeItem *via;
+
+ QSequentialAnimationGroup *topLevelGroup;
+ QActionAnimation *startAction;
+ QActionAnimation *endAction;
+
+ QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEANIMATION_P_H
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
new file mode 100644
index 0000000000..5352341ca8
--- /dev/null
+++ b/src/declarative/util/qdeclarativebehavior.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 "qdeclarativebehavior_p.h"
+
+#include "qdeclarativeanimation_p.h"
+#include "qdeclarativetransition_p.h"
+
+#include <qdeclarativecontext.h>
+#include <qdeclarativeinfo.h>
+#include <qdeclarativeproperty_p.h>
+
+#include <QtCore/qparallelanimationgroup.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+class QDeclarativeBehaviorPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeBehavior)
+public:
+ QDeclarativeBehaviorPrivate() : animation(0), enabled(true) {}
+
+ QDeclarativeProperty property;
+ QVariant currentValue;
+ QDeclarativeAbstractAnimation *animation;
+ bool enabled;
+};
+
+/*!
+ \qmlclass Behavior QDeclarativeBehavior
+ \since 4.7
+ \brief The Behavior element allows you to specify a default animation for a property change.
+
+ Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
+
+ In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
+ \code
+ Rectangle {
+ width: 20; height: 20
+ color: "#00ff00"
+ y: 200 //initial value
+ y: Behavior {
+ NumberAnimation {
+ easing: "easeOutBounce(amplitude:100)"
+ duration: 200
+ }
+ }
+ }
+ \endcode
+
+ Currently only a single Behavior may be specified for a property;
+ this Behavior can be enabled and disabled via the \l{enabled} property.
+*/
+
+
+QDeclarativeBehavior::QDeclarativeBehavior(QObject *parent)
+ : QObject(*(new QDeclarativeBehaviorPrivate), parent)
+{
+}
+
+QDeclarativeBehavior::~QDeclarativeBehavior()
+{
+}
+
+/*!
+ \qmlproperty Animation Behavior::animation
+ \default
+
+ The animation to use when the behavior is triggered.
+*/
+
+QDeclarativeAbstractAnimation *QDeclarativeBehavior::animation()
+{
+ Q_D(QDeclarativeBehavior);
+ return d->animation;
+}
+
+void QDeclarativeBehavior::setAnimation(QDeclarativeAbstractAnimation *animation)
+{
+ Q_D(QDeclarativeBehavior);
+ if (d->animation) {
+ qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
+ return;
+ }
+
+ d->animation = animation;
+ if (d->animation) {
+ d->animation->setDefaultTarget(d->property);
+ d->animation->setDisableUserControl();
+ }
+}
+
+/*!
+ \qmlproperty bool Behavior::enabled
+ Whether the Behavior will be triggered when the property it is tracking changes.
+
+ By default a Behavior is enabled.
+*/
+
+bool QDeclarativeBehavior::enabled() const
+{
+ Q_D(const QDeclarativeBehavior);
+ return d->enabled;
+}
+
+void QDeclarativeBehavior::setEnabled(bool enabled)
+{
+ Q_D(QDeclarativeBehavior);
+ if (d->enabled == enabled)
+ return;
+ d->enabled = enabled;
+ emit enabledChanged();
+}
+
+void QDeclarativeBehavior::write(const QVariant &value)
+{
+ Q_D(QDeclarativeBehavior);
+ if (!d->animation || !d->enabled) {
+ QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ return;
+ }
+
+ d->currentValue = d->property.read();
+
+ d->animation->qtAnimation()->stop();
+
+ QDeclarativeStateOperation::ActionList actions;
+ QDeclarativeAction action;
+ action.property = d->property;
+ action.fromValue = d->currentValue;
+ action.toValue = value;
+ actions << action;
+
+ QList<QDeclarativeProperty> after;
+ if (d->animation)
+ d->animation->transition(actions, after, QDeclarativeAbstractAnimation::Forward);
+ d->animation->qtAnimation()->start();
+ if (!after.contains(d->property))
+ QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+}
+
+void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property)
+{
+ Q_D(QDeclarativeBehavior);
+ d->property = property;
+ d->currentValue = property.read();
+ if (d->animation)
+ d->animation->setDefaultTarget(property);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativebehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h
new file mode 100644
index 0000000000..a633b55690
--- /dev/null
+++ b/src/declarative/util/qdeclarativebehavior_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 QDECLARATIVEBEHAVIOR_H
+#define QDECLARATIVEBEHAVIOR_H
+
+#include "qdeclarativestate_p.h"
+
+#include <qdeclarativepropertyvaluesource.h>
+#include <qdeclarativepropertyvalueinterceptor.h>
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeAbstractAnimation;
+class QDeclarativeBehaviorPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeBehavior : public QObject, public QDeclarativePropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeBehavior)
+
+ Q_INTERFACES(QDeclarativePropertyValueInterceptor)
+ Q_CLASSINFO("DefaultProperty", "animation")
+ Q_PROPERTY(QDeclarativeAbstractAnimation *animation READ animation WRITE setAnimation)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+
+public:
+ QDeclarativeBehavior(QObject *parent=0);
+ ~QDeclarativeBehavior();
+
+ virtual void setTarget(const QDeclarativeProperty &);
+ virtual void write(const QVariant &value);
+
+ QDeclarativeAbstractAnimation *animation();
+ void setAnimation(QDeclarativeAbstractAnimation *);
+
+ bool enabled() const;
+ void setEnabled(bool enabled);
+
+Q_SIGNALS:
+ void enabledChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeBehavior)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEBEHAVIOR_H
diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp
new file mode 100644
index 0000000000..e95a03ea1d
--- /dev/null
+++ b/src/declarative/util/qdeclarativebind.cpp
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativebind_p.h"
+
+#include "qdeclarativenullablevalue_p_p.h"
+
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeproperty.h>
+
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtScript/qscriptcontext.h>
+#include <QtScript/qscriptengine.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeBindPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeBindPrivate() : when(true), componentComplete(false), obj(0) {}
+
+ bool when : 1;
+ bool componentComplete : 1;
+ QObject *obj;
+ QString prop;
+ QDeclarativeNullableValue<QVariant> value;
+};
+
+
+/*!
+ \qmlclass Binding QDeclarativeBind
+ \since 4.7
+ \brief The Binding element allows arbitrary property bindings to be created.
+
+ Sometimes it is necessary to bind to a property of an object that wasn't
+ directly instantiated by QML - generally a property of a class exported
+ to QML by C++. In these cases, regular property binding doesn't work. Binding
+ allows you to bind any value to any property.
+
+ For example, imagine a C++ application that maps an "app.enteredText"
+ property into QML. You could use Binding to update the enteredText property
+ like this.
+ \code
+ TextEdit { id: myTextField; text: "Please type here..." }
+ Binding { target: app; property: "enteredText"; value: myTextField.text }
+ \endcode
+ Whenever the text in the TextEdit is updated, the C++ property will be
+ updated also.
+
+ If the binding target or binding property is changed, the bound value is
+ immediately pushed onto the new target.
+ */
+/*!
+ \internal
+ \class QDeclarativeBind
+ \ingroup group_utility
+ \brief The QDeclarativeBind class allows arbitrary property bindings to be created.
+
+ Simple bindings are usually earier to do in-place rather than creating a
+ QDeclarativeBind item. For that reason, QDeclarativeBind is usually used to transfer property information
+ from Qml to C++.
+
+ \sa cppqml
+ */
+QDeclarativeBind::QDeclarativeBind(QObject *parent)
+ : QObject(*(new QDeclarativeBindPrivate), parent)
+{
+}
+
+QDeclarativeBind::~QDeclarativeBind()
+{
+}
+
+bool QDeclarativeBind::when() const
+{
+ Q_D(const QDeclarativeBind);
+ return d->when;
+}
+
+void QDeclarativeBind::setWhen(bool v)
+{
+ Q_D(QDeclarativeBind);
+ d->when = v;
+ eval();
+}
+
+/*!
+ \qmlproperty Object Binding::target
+
+ The object to be updated.
+*/
+QObject *QDeclarativeBind::object()
+{
+ Q_D(const QDeclarativeBind);
+ return d->obj;
+}
+
+void QDeclarativeBind::setObject(QObject *obj)
+{
+ Q_D(QDeclarativeBind);
+ d->obj = obj;
+ eval();
+}
+
+/*!
+ \qmlproperty string Binding::property
+
+ The property to be updated.
+*/
+QString QDeclarativeBind::property() const
+{
+ Q_D(const QDeclarativeBind);
+ return d->prop;
+}
+
+void QDeclarativeBind::setProperty(const QString &p)
+{
+ Q_D(QDeclarativeBind);
+ d->prop = p;
+ eval();
+}
+
+/*!
+ \qmlproperty any Binding::value
+
+ The value to be set on the target object and property. This can be a
+ constant (which isn't very useful), or a bound expression.
+*/
+QVariant QDeclarativeBind::value() const
+{
+ Q_D(const QDeclarativeBind);
+ return d->value.value;
+}
+
+void QDeclarativeBind::setValue(const QVariant &v)
+{
+ Q_D(QDeclarativeBind);
+ d->value.value = v;
+ d->value.isNull = false;
+ eval();
+}
+
+void QDeclarativeBind::componentComplete()
+{
+ Q_D(QDeclarativeBind);
+ d->componentComplete = true;
+ eval();
+}
+
+void QDeclarativeBind::eval()
+{
+ Q_D(QDeclarativeBind);
+ if (!d->obj || d->value.isNull || !d->when || !d->componentComplete)
+ return;
+
+ QDeclarativeProperty prop(d->obj, d->prop);
+ prop.write(d->value.value);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativebind_p.h b/src/declarative/util/qdeclarativebind_p.h
new file mode 100644
index 0000000000..f756e802c1
--- /dev/null
+++ b/src/declarative/util/qdeclarativebind_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 QDECLARATIVEBIND_H
+#define QDECLARATIVEBIND_H
+
+#include <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeBindPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeBind : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeBind)
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_PROPERTY(QObject *target READ object WRITE setObject)
+ Q_PROPERTY(QString property READ property WRITE setProperty)
+ Q_PROPERTY(QVariant value READ value WRITE setValue)
+ Q_PROPERTY(bool when READ when WRITE setWhen)
+
+public:
+ QDeclarativeBind(QObject *parent=0);
+ ~QDeclarativeBind();
+
+ bool when() const;
+ void setWhen(bool);
+
+ QObject *object();
+ void setObject(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
+ QVariant value() const;
+ void setValue(const QVariant &);
+
+protected:
+ virtual void componentComplete();
+
+private:
+ void eval();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeBind)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp
new file mode 100644
index 0000000000..0b9e3aba7f
--- /dev/null
+++ b/src/declarative/util/qdeclarativeconnections.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeconnections_p.h"
+
+#include <qdeclarativeexpression.h>
+#include <qdeclarativeproperty_p.h>
+#include <qdeclarativeboundsignal_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeinfo.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstringlist.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeConnectionsPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeConnectionsPrivate() : target(0), componentcomplete(false) {}
+
+ QList<QDeclarativeBoundSignal*> boundsignals;
+ QObject *target;
+
+ bool componentcomplete;
+
+ QByteArray data;
+};
+
+/*!
+ \qmlclass Connections QDeclarativeConnections
+ \since 4.7
+ \brief A Connections object describes generalized connections to signals.
+
+ When connecting to signals in QML, the usual way is to create an
+ "on<Signal>" handler that reacts when a signal is received, like this:
+
+ \qml
+ MouseArea {
+ onClicked: { foo(...) }
+ }
+ \endqml
+
+ However, in some cases, it is not possible to connect to a signal in this
+ way, such as:
+
+ \list
+ \i multiple connections to the same signal
+ \i connections outside the scope of the signal sender
+ \i connections to targets not defined in QML
+ \endlist
+
+ When any of these are needed, the Connections object can be used instead.
+
+ For example, the above code can be changed to use a Connections object,
+ like this:
+
+ \qml
+ MouseArea {
+ Connections {
+ onClicked: foo(...)
+ }
+ }
+ \endqml
+
+ More generally, the Connections object can be a child of some other object than
+ the sender of the signal:
+
+ \qml
+ MouseArea {
+ id: area
+ }
+ ...
+ Connections {
+ target: area
+ onClicked: foo(...)
+ }
+ \endqml
+*/
+
+/*!
+ \internal
+ \class QDeclarativeConnections
+ \brief The QDeclarativeConnections class describes generalized connections to signals.
+
+*/
+QDeclarativeConnections::QDeclarativeConnections(QObject *parent) :
+ QObject(*(new QDeclarativeConnectionsPrivate), parent)
+{
+}
+
+QDeclarativeConnections::~QDeclarativeConnections()
+{
+}
+
+/*!
+ \qmlproperty Object Connections::target
+ This property holds the object that sends the signal.
+
+ By default, the target is assumed to be the parent of the Connections.
+*/
+QObject *QDeclarativeConnections::target() const
+{
+ Q_D(const QDeclarativeConnections);
+ return d->target ? d->target : parent();
+}
+
+void QDeclarativeConnections::setTarget(QObject *obj)
+{
+ Q_D(QDeclarativeConnections);
+ if (d->target == obj)
+ return;
+ foreach (QDeclarativeBoundSignal *s, d->boundsignals)
+ delete s;
+ d->boundsignals.clear();
+ d->target = obj;
+ connectSignals();
+ emit targetChanged();
+}
+
+
+QByteArray
+QDeclarativeConnectionsParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
+{
+ QByteArray rv;
+ QDataStream ds(&rv, QIODevice::WriteOnly);
+
+ for(int ii = 0; ii < props.count(); ++ii)
+ {
+ QString propName = QString::fromUtf8(props.at(ii).name());
+ if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
+ error(props.at(ii), QDeclarativeConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
+ return QByteArray();
+ }
+
+ QList<QVariant> values = props.at(ii).assignedValues();
+
+ for (int i = 0; i < values.count(); ++i) {
+ const QVariant &value = values.at(i);
+
+ if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
+ error(props.at(ii), QDeclarativeConnections::tr("Connections: nested objects not allowed"));
+ return QByteArray();
+ } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
+ error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error"));
+ return QByteArray();
+ } else {
+ QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(value);
+ if (v.isScript()) {
+ ds << propName;
+ ds << v.asScript();
+ } else {
+ error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected"));
+ return QByteArray();
+ }
+ }
+ }
+ }
+
+ return rv;
+}
+
+void QDeclarativeConnectionsParser::setCustomData(QObject *object,
+ const QByteArray &data)
+{
+ QDeclarativeConnectionsPrivate *p =
+ static_cast<QDeclarativeConnectionsPrivate *>(QObjectPrivate::get(object));
+ p->data = data;
+}
+
+
+void QDeclarativeConnections::connectSignals()
+{
+ Q_D(QDeclarativeConnections);
+ if (!d->componentcomplete)
+ return;
+
+ QDataStream ds(d->data);
+ while (!ds.atEnd()) {
+ QString propName;
+ ds >> propName;
+ QString script;
+ ds >> script;
+ QDeclarativeProperty prop(target(), propName);
+ if (!prop.isValid()) {
+ qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
+ } else if (prop.type() & QDeclarativeProperty::SignalProperty) {
+ QDeclarativeBoundSignal *signal =
+ new QDeclarativeBoundSignal(target(), prop.method(), this);
+ signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0));
+ d->boundsignals += signal;
+ } else {
+ qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName);
+ }
+ }
+}
+
+void QDeclarativeConnections::componentComplete()
+{
+ Q_D(QDeclarativeConnections);
+ d->componentcomplete=true;
+ connectSignals();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeconnections_p.h b/src/declarative/util/qdeclarativeconnections_p.h
new file mode 100644
index 0000000000..3eacf12cc4
--- /dev/null
+++ b/src/declarative/util/qdeclarativeconnections_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVECONNECTIONS_H
+#define QDECLARATIVECONNECTIONS_H
+
+#include <qdeclarative.h>
+#include <qdeclarativescriptstring.h>
+#include <private/qdeclarativecustomparser_p.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeBoundSignal;
+class QDeclarativeContext;
+class QDeclarativeConnectionsPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeConnections : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeConnections)
+
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
+
+public:
+ QDeclarativeConnections(QObject *parent=0);
+ ~QDeclarativeConnections();
+
+ QObject *target() const;
+ void setTarget(QObject *);
+
+Q_SIGNALS:
+ void targetChanged();
+
+private:
+ void connectSignals();
+ void componentComplete();
+};
+
+class QDeclarativeConnectionsParser : public QDeclarativeCustomParser
+{
+public:
+ virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
+ virtual void setCustomData(QObject *, const QByteArray &);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeConnections)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/util/qdeclarativedatetimeformatter.cpp b/src/declarative/util/qdeclarativedatetimeformatter.cpp
new file mode 100644
index 0000000000..4087091185
--- /dev/null
+++ b/src/declarative/util/qdeclarativedatetimeformatter.cpp
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativedatetimeformatter_p.h"
+
+#include <QtCore/qlocale.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+//TODO: may need optimisation as the QDateTime member may not be needed?
+// be able to set a locale?
+
+class QDeclarativeDateTimeFormatterPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeDateTimeFormatter)
+public:
+ QDeclarativeDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {}
+
+ void updateText();
+
+ QDateTime dateTime;
+ QDate date;
+ QTime time;
+ QLocale locale;
+ QString dateTimeText;
+ QString dateText;
+ QString timeText;
+ QString dateTimeFormat; //set for convienience?
+ QString dateFormat;
+ QString timeFormat;
+ bool longStyle;
+ bool componentComplete;
+};
+
+/*!
+ \qmlclass DateTimeFormatter QDeclarativeDateTimeFormatter
+ \since 4.7
+ \brief The DateTimeFormatter allows you to control the format of a date string.
+
+ \code
+ DateTimeFormatter { id: formatter; date: System.date }
+ Text { text: formatter.dateText }
+ \endcode
+
+ By default, the text properties (dateText, timeText, and dateTimeText) will return the
+ date and time using the current system locale's format.
+*/
+
+/*!
+ \internal
+ \class QDeclarativeDateTimeFormatter
+ \ingroup group_utility
+ \brief The QDeclarativeDateTimeFormatter class allows you to format a date string.
+*/
+
+QDeclarativeDateTimeFormatter::QDeclarativeDateTimeFormatter(QObject *parent)
+: QObject(*(new QDeclarativeDateTimeFormatterPrivate), parent)
+{
+}
+
+QDeclarativeDateTimeFormatter::~QDeclarativeDateTimeFormatter()
+{
+}
+
+/*!
+ \qmlproperty string DateTimeFormatter::dateText
+ \qmlproperty string DateTimeFormatter::timeText
+ \qmlproperty string DateTimeFormatter::dateTimeText
+
+ Formatted text representations of the \c date, \c time,
+ and \c {date and time}, respectively.
+
+ If there is no explictly specified format the DateTimeFormatter
+ will use the system locale's default 'short' setting.
+
+ \code
+ // specify source date (assuming today is February 19, 2009)
+ DateTimeFormatter { id: formatter; dateTime: Today.date }
+
+ // display the full date and time
+ Text { text: formatter.dateText }
+ \endcode
+
+ Would be equivalent to the following for a US English locale:
+
+ \code
+ // display the date
+ Text { text: "2/19/09" }
+ \endcode
+*/
+QString QDeclarativeDateTimeFormatter::dateTimeText() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->dateTimeText;
+}
+
+QString QDeclarativeDateTimeFormatter::dateText() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->dateText;
+}
+
+QString QDeclarativeDateTimeFormatter::timeText() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->timeText;
+}
+
+/*!
+ \qmlproperty date DateTimeFormatter::date
+ \qmlproperty time DateTimeFormatter::time
+ \qmlproperty datetime DateTimeFormatter::dateTime
+
+ The source date and time to be used by the formatter.
+
+ \code
+ // setting the date and time
+ DateTimeFormatter { date: System.date; time: System.time }
+ \endcode
+
+ For convienience it is possible to set the datetime property to set both the date and the time.
+ \code
+ // setting the datetime
+ DateTimeFormatter { dateTime: System.dateTime }
+ \endcode
+
+ There can only be one instance of date and time per formatter; if date, time, and dateTime are all
+ set the actual date and time used is not guaranteed.
+
+ \note If no date is set, dateTimeText will be just the date;
+ If no time is set, the dateTimeText will be just the time.
+
+*/
+QDate QDeclarativeDateTimeFormatter::date() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->date;
+}
+
+QTime QDeclarativeDateTimeFormatter::time() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->time;
+}
+
+QDateTime QDeclarativeDateTimeFormatter::dateTime() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->dateTime;
+}
+
+/*!
+ \qmlproperty string DateTimeFormatter::dateFormat
+ \qmlproperty string DateTimeFormatter::timeFormat
+ \qmlproperty string DateTimeFormatter::dateTimeFormat
+
+ Specifies a custom format which the DateTime Formatter can use.
+
+ If there is no explictly specified format the DateTimeFormatter
+ will use the system locale's default 'short' setting.
+
+ The text's format may be modified by setting:
+ \list
+ \i \c dateFormat
+ \i \c timeFormat
+ \i \c dateTimeFormat
+ \endlist
+
+ If only the format for date is defined, the time and dateTime formats will be defined
+ as the system locale default and likewise for the others.
+
+ Syntax for the format is based on the QDateTime::toString() formatting options.
+
+ \code
+ // Format the date such that the dateText is: '1997-12-12'
+ DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" }
+ \endcode
+
+ Assigning an empty string to a particular format will reset it.
+*/
+QString QDeclarativeDateTimeFormatter::dateTimeFormat() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->dateTimeFormat;
+}
+
+QString QDeclarativeDateTimeFormatter::dateFormat() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->dateFormat;
+}
+
+QString QDeclarativeDateTimeFormatter::timeFormat() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->timeFormat;
+}
+
+/*!
+ \qmlproperty bool DateTimeFormatter::longStyle
+
+ This property causes the formatter to use the system locale's long format rather than short format
+ by default.
+
+ This setting is off by default.
+*/
+bool QDeclarativeDateTimeFormatter::longStyle() const
+{
+ Q_D(const QDeclarativeDateTimeFormatter);
+ return d->longStyle;
+}
+
+void QDeclarativeDateTimeFormatter::setDateTime(const QDateTime &dateTime)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ if (d->dateTime == dateTime)
+ return;
+ d->dateTime = dateTime;
+ d->date = d->dateTime.date();
+ d->time = d->dateTime.time();
+ d->updateText();
+}
+
+void QDeclarativeDateTimeFormatter::setTime(const QTime &time)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ if (d->dateTime.time() == time)
+ return;
+ d->time = time;
+ d->dateTime.setTime(time);
+ d->updateText();
+}
+
+void QDeclarativeDateTimeFormatter::setDate(const QDate &date)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ if (d->dateTime.date() == date)
+ return;
+ d->date = date;
+ bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time
+ d->dateTime.setDate(date);
+ if (clearTime)
+ d->dateTime.setTime(QTime());
+ d->updateText();
+}
+
+//DateTime formatting may be a combination of date and time?
+void QDeclarativeDateTimeFormatter::setDateTimeFormat(const QString &format)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ //no format checking
+ d->dateTimeFormat = format;
+ d->updateText();
+}
+
+void QDeclarativeDateTimeFormatter::setDateFormat(const QString &format)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ //no format checking
+ d->dateFormat = format;
+ d->updateText();
+}
+
+void QDeclarativeDateTimeFormatter::setTimeFormat(const QString &format)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ //no format checking
+ d->timeFormat = format;
+ d->updateText();
+}
+
+void QDeclarativeDateTimeFormatter::setLongStyle(bool longStyle)
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ d->longStyle = longStyle;
+ d->updateText();
+}
+
+void QDeclarativeDateTimeFormatterPrivate::updateText()
+{
+ Q_Q(QDeclarativeDateTimeFormatter);
+ if (!componentComplete)
+ return;
+
+ QString str;
+ QString str1;
+ QString str2;
+
+ Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate;
+
+ if (dateFormat.isEmpty())
+ str1 = date.toString(defaultFormat);
+ else
+ str1 = date.toString(dateFormat);
+
+ if (timeFormat.isEmpty())
+ str2 = time.toString(defaultFormat);
+ else
+ str2 = time.toString(timeFormat);
+
+ if (dateTimeFormat.isEmpty())
+ str = dateTime.toString(defaultFormat);
+ //else if (!formatTime.isEmpty() && !formatDate.isEmpty())
+ // str = str1 + QLatin1Char(' ') + str2;
+ else
+ str = dateTime.toString(dateTimeFormat);
+
+ if (dateTimeText == str && dateText == str1 && timeText == str2)
+ return;
+
+ dateTimeText = str;
+ dateText = str1;
+ timeText = str2;
+
+ emit q->textChanged();
+}
+
+void QDeclarativeDateTimeFormatter::classBegin()
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ d->componentComplete = false;
+}
+
+void QDeclarativeDateTimeFormatter::componentComplete()
+{
+ Q_D(QDeclarativeDateTimeFormatter);
+ d->componentComplete = true;
+ d->updateText();
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativedatetimeformatter_p.h b/src/declarative/util/qdeclarativedatetimeformatter_p.h
new file mode 100644
index 0000000000..da900be4e8
--- /dev/null
+++ b/src/declarative/util/qdeclarativedatetimeformatter_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 QDECLARATIVEDATETIMEFORMATTER_H
+#define QDECLARATIVEDATETIMEFORMATTER_H
+
+#include <qdeclarative.h>
+
+#include <QtCore/qdatetime.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeDateTimeFormatterPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeDateTimeFormatter : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+
+ Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged)
+ Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged)
+ Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged)
+ Q_PROPERTY(QDate date READ date WRITE setDate)
+ Q_PROPERTY(QTime time READ time WRITE setTime)
+ Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime)
+ Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat)
+ Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat)
+ Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
+ Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle)
+public:
+ QDeclarativeDateTimeFormatter(QObject *parent=0);
+ ~QDeclarativeDateTimeFormatter();
+
+ QString dateTimeText() const;
+ QString dateText() const;
+ QString timeText() const;
+
+ QDate date() const;
+ void setDate(const QDate &);
+
+ QTime time() const;
+ void setTime(const QTime &);
+
+ QDateTime dateTime() const;
+ void setDateTime(const QDateTime &);
+
+ QString dateTimeFormat() const;
+ void setDateTimeFormat(const QString &);
+
+ QString dateFormat() const;
+ void setDateFormat(const QString &);
+
+ QString timeFormat() const;
+ void setTimeFormat(const QString &);
+
+ bool longStyle() const;
+ void setLongStyle(bool);
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void textChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeDateTimeFormatter)
+ Q_DECLARE_PRIVATE(QDeclarativeDateTimeFormatter)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeDateTimeFormatter)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp
new file mode 100644
index 0000000000..3fa9866e86
--- /dev/null
+++ b/src/declarative/util/qdeclarativeeasefollow.cpp
@@ -0,0 +1,537 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeeasefollow_p.h"
+
+#include "qdeclarativeanimation_p_p.h"
+
+#include <qdeclarativeproperty.h>
+
+#include <QtCore/qdebug.h>
+
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+class QDeclarativeEaseFollowPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeEaseFollow)
+public:
+ QDeclarativeEaseFollowPrivate()
+ : source(0), velocity(200), duration(-1), maximumEasingTime(-1),
+ reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
+ initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
+ lastTick(0), clock(this)
+ {}
+
+ qreal source;
+ qreal velocity;
+ qreal duration;
+ qreal maximumEasingTime;
+ QDeclarativeEaseFollow::ReversingMode reversingMode;
+
+ qreal initialVelocity;
+ qreal initialValue;
+ bool invert;
+ bool enabled;
+
+ qreal trackVelocity;
+
+ QDeclarativeProperty target;
+
+ int clockOffset;
+ int lastTick;
+ void tick(int);
+ void clockStart();
+ void clockStop();
+ QTickAnimationProxy<QDeclarativeEaseFollowPrivate, &QDeclarativeEaseFollowPrivate::tick> clock;
+
+ void restart();
+
+ // Parameters for use in tick()
+ qreal a; // Acceleration
+ qreal d; // Deceleration
+ qreal tf; // Total time
+ qreal tp; // Time at which peak velocity occurs
+ qreal td; // Time at which decelleration begins
+ qreal vp; // Velocity at tp
+ qreal sp; // Displacement at tp
+ qreal sd; // Displacement at td
+ qreal vi; // "Normalized" initialvelocity
+ bool recalc();
+};
+
+bool QDeclarativeEaseFollowPrivate::recalc()
+{
+ qreal s = source - initialValue;
+ vi = initialVelocity;
+
+ s = (invert?-1.0:1.0) * s;
+ vi = (invert?-1.0:1.0) * vi;
+
+ if (duration > 0 && velocity > 0) {
+ tf = s / velocity;
+ if (tf > (duration / 1000.)) tf = (duration / 1000.);
+ } else if (duration > 0) {
+ tf = duration / 1000.;
+ } else if (velocity > 0) {
+ tf = s / velocity;
+ } else {
+ return false;
+ }
+
+ if (maximumEasingTime == 0) {
+ a = 0;
+ d = 0;
+ tp = 0;
+ td = tf;
+ vp = velocity;
+ sp = 0;
+ sd = s;
+ } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) {
+
+ qreal met = maximumEasingTime / 1000.;
+ td = tf - met;
+
+ qreal c1 = td;
+ qreal c2 = (tf - td) * vi - tf * velocity;
+ qreal c3 = -0.5 * (tf - td) * vi * vi;
+
+ qreal vp1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+ // qreal vp2 = (-c2 - sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+
+ vp = vp1;
+ a = vp / met;
+ d = a;
+ tp = (vp - vi) / a;
+ sp = vi * tp + 0.5 * a * tp * tp;
+ sd = sp + (td - tp) * vp;
+ } else {
+
+ qreal c1 = 0.25 * tf * tf;
+ qreal c2 = 0.5 * vi * tf - s;
+ qreal c3 = -0.25 * vi * vi;
+
+ qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+ //qreal a2 = (-c2 - sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
+
+ qreal tp1 = 0.5 * tf - 0.5 * vi / a1;
+ //qreal tp2 = 0.5 * tf - 0.5 * vi / a2;
+ qreal vp1 = a1 * tp1 + vi;
+ //qreal vp2 = a2 * tp2 + vi;
+
+ qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1;
+ //qreal sp2 = 0.5 * a2 * tp2 * tp2 + vi * tp2;
+
+ a = a1;
+ d = a1;
+ tp = tp1;
+ td = tp1;
+ vp = vp1;
+ sp = sp1;
+ sd = sp1;
+ }
+
+ /*
+ qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
+ << vp << "sp:" << sp << "vi:" << vi << "invert:" << invert;
+ */
+ return true;
+}
+
+void QDeclarativeEaseFollowPrivate::clockStart()
+{
+ if (clock.state() == QAbstractAnimation::Running) {
+ clockOffset = lastTick;
+ return;
+ } else {
+ clockOffset = 0;
+ lastTick = 0;
+ clock.start();
+ }
+}
+
+void QDeclarativeEaseFollowPrivate::clockStop()
+{
+ clockOffset = 0;
+ lastTick = 0;
+ clock.stop();
+}
+
+void QDeclarativeEaseFollowPrivate::tick(int t)
+{
+ lastTick = t;
+ t -= clockOffset;
+
+ qreal time_seconds = qreal(t) / 1000.;
+
+ qreal out = 0;
+ if (time_seconds < tp) {
+
+ trackVelocity = vi + time_seconds * a;
+ trackVelocity = (invert?-1.0:1.0) * trackVelocity;
+
+ qreal value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
+ value = (invert?-1.0:1.0) * value;
+ target.write(initialValue + value);
+ out = initialValue + value;
+ } else if (time_seconds < td) {
+
+ time_seconds -= tp;
+ trackVelocity = (invert?-1.0:1.0) * vp;
+ qreal value = sp + time_seconds * vp;
+ value = (invert?-1.0:1.0) * value;
+
+ target.write(initialValue + value);
+
+ out = initialValue + value;
+ } else if (time_seconds < tf) {
+
+ time_seconds -= td;
+
+ trackVelocity = vp - time_seconds * a;
+ trackVelocity = (invert?-1.0:1.0) * trackVelocity;
+
+ qreal value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds;
+ value = (invert?-1.0:1.0) * value;
+
+ target.write(initialValue + value);
+
+ out = initialValue + value;
+ } else {
+
+ clock.stop();
+
+ trackVelocity = 0;
+ target.write(source);
+ }
+
+ //qWarning() << out << trackVelocity << t << a;
+}
+
+/*!
+ \qmlclass EaseFollow QDeclarativeEaseFollow
+ \since 4.7
+ \brief The EaseFollow element allows a property to smoothly track a value.
+
+ The EaseFollow smoothly animates a property's value to a set target value
+ using an ease in/out quad easing curve. If the target value changes while
+ the animation is in progress, the easing curves used to animate to the old
+ and the new target values are spliced together to avoid any obvious visual
+ glitches.
+
+ The property animation is configured by setting the velocity at which the
+ animation should occur, or the duration that the animation should take.
+ If both a velocity and a duration are specified, the one that results in
+ the quickest animation is chosen for each change in the target value.
+
+ For example, animating from 0 to 800 will take 4 seconds if a velocity
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ take 4 seconds with both a velocity of 200 and a duration of 8000 set.
+ Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
+ will take 8 seconds with a duration of 8000 set, and will take 8 seconds
+ with both a velocity of 200 and a duration of 8000 set.
+
+ The follow example shows one rectangle tracking the position of another.
+\code
+import Qt 4.6
+
+Rectangle {
+ width: 800; height: 600; color: "blue"
+
+ Rectangle {
+ color: "green"
+ width: 60; height: 60;
+ x: -5; y: -5;
+ x: EaseFollow { source: rect1.x - 5; velocity: 200 }
+ y: EaseFollow { source: rect1.y - 5; velocity: 200 }
+ }
+
+ Rectangle {
+ id: rect1
+ color: "red"
+ width: 50; height: 50;
+ }
+
+ focus: true
+ Keys.onRightPressed: rect1.x = rect1.x + 100
+ Keys.onLeftPressed: rect1.x = rect1.x - 100
+ Keys.onUpPressed: rect1.y = rect1.y - 100
+ Keys.onDownPressed: rect1.y = rect1.y + 100
+}
+\endcode
+
+ The default velocity of EaseFollow is 200 units/second. Note that if the range of the
+ value being animated is small, then the velocity will need to be adjusted
+ appropriately. For example, the opacity of an item ranges from 0 - 1.0.
+ To enable a smooth animation in this range the velocity will need to be
+ set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
+ of 0.5 will take 2000 ms to complete.
+
+ \sa SpringFollow
+*/
+
+QDeclarativeEaseFollow::QDeclarativeEaseFollow(QObject *parent)
+: QObject(*(new QDeclarativeEaseFollowPrivate), parent)
+{
+}
+
+QDeclarativeEaseFollow::~QDeclarativeEaseFollow()
+{
+}
+
+/*!
+ \qmlproperty qreal EaseFollow::source
+ This property holds the source value which will be tracked.
+
+ Bind to a property in order to track its changes.
+*/
+qreal QDeclarativeEaseFollow::sourceValue() const
+{
+ Q_D(const QDeclarativeEaseFollow);
+ return d->source;
+}
+
+/*!
+ \qmlproperty enumeration EaseFollow::reversingMode
+
+ Sets how the EaseFollow behaves if an animation direction is reversed.
+
+ If reversing mode is \c Eased, the animation will smoothly decelerate, and
+ then reverse direction. If the reversing mode is \c Immediate, the
+ animation will immediately begin accelerating in the reverse direction,
+ begining with a velocity of 0. If the reversing mode is \c Sync, the
+ property is immediately set to the target value.
+*/
+QDeclarativeEaseFollow::ReversingMode QDeclarativeEaseFollow::reversingMode() const
+{
+ Q_D(const QDeclarativeEaseFollow);
+ return d->reversingMode;
+}
+
+void QDeclarativeEaseFollow::setReversingMode(ReversingMode m)
+{
+ Q_D(QDeclarativeEaseFollow);
+ if (d->reversingMode == m)
+ return;
+
+ d->reversingMode = m;
+ emit reversingModeChanged();
+}
+
+void QDeclarativeEaseFollowPrivate::restart()
+{
+ if (!enabled || velocity == 0) {
+ clockStop();
+ return;
+ }
+
+ initialValue = target.read().toReal();
+
+ if (source == initialValue) {
+ clockStop();
+ return;
+ }
+
+ bool hasReversed = trackVelocity != 0. &&
+ ((trackVelocity > 0) == ((initialValue - source) > 0));
+
+ if (hasReversed) {
+ switch (reversingMode) {
+ default:
+ case QDeclarativeEaseFollow::Eased:
+ break;
+ case QDeclarativeEaseFollow::Sync:
+ target.write(source);
+ return;
+ case QDeclarativeEaseFollow::Immediate:
+ initialVelocity = 0;
+ clockStop();
+ break;
+ }
+ }
+
+ trackVelocity = initialVelocity;
+
+ invert = (source < initialValue);
+
+ if (!recalc()) {
+ target.write(source);
+ clockStop();
+ return;
+ }
+
+ clockStart();
+}
+
+void QDeclarativeEaseFollow::setSourceValue(qreal s)
+{
+ Q_D(QDeclarativeEaseFollow);
+
+ if (d->clock.state() == QAbstractAnimation::Running && d->source == s)
+ return;
+
+ d->source = s;
+ d->initialVelocity = d->trackVelocity;
+ d->restart();
+
+ emit sourceChanged();
+}
+
+/*!
+ \qmlproperty qreal EaseFollow::duration
+
+ This property holds the animation duration used when tracking the source.
+
+ Setting this to -1 (the default) disables the duration value.
+*/
+qreal QDeclarativeEaseFollow::duration() const
+{
+ Q_D(const QDeclarativeEaseFollow);
+ return d->duration;
+}
+
+void QDeclarativeEaseFollow::setDuration(qreal v)
+{
+ Q_D(QDeclarativeEaseFollow);
+ if (d->duration == v)
+ return;
+
+ d->duration = v;
+ d->trackVelocity = 0;
+
+ if (d->clock.state() == QAbstractAnimation::Running)
+ d->restart();
+
+ emit durationChanged();
+}
+
+qreal QDeclarativeEaseFollow::velocity() const
+{
+ Q_D(const QDeclarativeEaseFollow);
+ return d->velocity;
+}
+
+/*!
+ \qmlproperty qreal EaseFollow::velocity
+
+ This property holds the average velocity allowed when tracking the source.
+
+ The default velocity of EaseFollow is 200 units/second.
+
+ Setting this to -1 disables the velocity value.
+*/
+void QDeclarativeEaseFollow::setVelocity(qreal v)
+{
+ Q_D(QDeclarativeEaseFollow);
+ if (d->velocity == v)
+ return;
+
+ d->velocity = v;
+ d->trackVelocity = 0;
+
+ if (d->clock.state() == QAbstractAnimation::Running)
+ d->restart();
+
+ emit velocityChanged();
+}
+
+/*!
+ \qmlproperty bool EaseFollow::enabled
+ This property holds whether the target will track the source.
+*/
+bool QDeclarativeEaseFollow::enabled() const
+{
+ Q_D(const QDeclarativeEaseFollow);
+ return d->enabled;
+}
+
+void QDeclarativeEaseFollow::setEnabled(bool enabled)
+{
+ Q_D(QDeclarativeEaseFollow);
+ if (d->enabled == enabled)
+ return;
+
+ d->enabled = enabled;
+ if (enabled)
+ d->restart();
+ else
+ d->clockStop();
+
+ emit enabledChanged();
+}
+
+void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t)
+{
+ Q_D(QDeclarativeEaseFollow);
+ d->target = t;
+}
+
+/*!
+\qmlproperty qreal EaseFollow::maximumEasingTime
+
+This property specifies the maximum time an "eases" during the follow should take.
+Setting this property causes the velocity to "level out" after at a time. Setting
+a negative value reverts to the normal mode of easing over the entire animation
+duration.
+
+The default value is -1.
+*/
+qreal QDeclarativeEaseFollow::maximumEasingTime() const
+{
+ Q_D(const QDeclarativeEaseFollow);
+ return d->maximumEasingTime;
+}
+
+void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v)
+{
+ Q_D(QDeclarativeEaseFollow);
+ d->maximumEasingTime = v;
+
+ if (d->clock.state() == QAbstractAnimation::Running)
+ d->restart();
+
+ emit maximumEasingTimeChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeeasefollow_p.h b/src/declarative/util/qdeclarativeeasefollow_p.h
new file mode 100644
index 0000000000..83d1eff8b6
--- /dev/null
+++ b/src/declarative/util/qdeclarativeeasefollow_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 QDECLARATIVEEASEFOLLOW_H
+#define QDECLARATIVEEASEFOLLOW_H
+
+#include <qdeclarative.h>
+#include <qdeclarativepropertyvaluesource.h>
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeProperty;
+class QDeclarativeEaseFollowPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeEaseFollow : public QObject,
+ public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeEaseFollow)
+ Q_INTERFACES(QDeclarativePropertyValueSource)
+ Q_ENUMS(ReversingMode)
+
+ Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue NOTIFY sourceChanged)
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
+ Q_PROPERTY(qreal duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
+
+public:
+ enum ReversingMode { Eased, Immediate, Sync };
+
+ QDeclarativeEaseFollow(QObject *parent = 0);
+ ~QDeclarativeEaseFollow();
+
+ ReversingMode reversingMode() const;
+ void setReversingMode(ReversingMode);
+
+ qreal sourceValue() const;
+ void setSourceValue(qreal);
+
+ qreal velocity() const;
+ void setVelocity(qreal);
+
+ qreal duration() const;
+ void setDuration(qreal);
+
+ bool enabled() const;
+ void setEnabled(bool enabled);
+
+ qreal maximumEasingTime() const;
+ void setMaximumEasingTime(qreal);
+
+ virtual void setTarget(const QDeclarativeProperty &);
+
+Q_SIGNALS:
+ void sourceChanged();
+ void velocityChanged();
+ void durationChanged();
+ void reversingModeChanged();
+ void enabledChanged();
+ void maximumEasingTimeChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeEaseFollow);
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEEASEFOLLOW_H
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
new file mode 100644
index 0000000000..4d12ae18e9
--- /dev/null
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativefontloader_p.h"
+
+#include <qdeclarativecontext.h>
+#include <qdeclarativeengine.h>
+
+#include <QStringList>
+#include <QUrl>
+#include <QDebug>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QFile>
+#include <QFontDatabase>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeFontLoaderPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeFontLoader)
+
+public:
+ QDeclarativeFontLoaderPrivate() : reply(0), status(QDeclarativeFontLoader::Null) {}
+
+ void addFontToDatabase(const QByteArray &);
+
+ QUrl url;
+ QString name;
+ QNetworkReply *reply;
+ QDeclarativeFontLoader::Status status;
+};
+
+
+
+/*!
+ \qmlclass FontLoader QDeclarativeFontLoader
+ \since 4.7
+ \ingroup group_utility
+ \brief This item allows using fonts by name or url.
+
+ Example:
+ \qml
+ FontLoader { id: fixedFont; name: "Courier" }
+ FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
+
+ Text { text: "Fixed-size font"; font.family: fixedFont.name }
+ Text { text: "Fancy font"; font.family: webFont.name }
+ \endqml
+*/
+QDeclarativeFontLoader::QDeclarativeFontLoader(QObject *parent)
+ : QObject(*(new QDeclarativeFontLoaderPrivate), parent)
+{
+}
+
+QDeclarativeFontLoader::~QDeclarativeFontLoader()
+{
+}
+
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+
+/*!
+ \qmlproperty url FontLoader::source
+ The url of the font to load.
+*/
+QUrl QDeclarativeFontLoader::source() const
+{
+ Q_D(const QDeclarativeFontLoader);
+ return d->url;
+}
+
+void QDeclarativeFontLoader::setSource(const QUrl &url)
+{
+ Q_D(QDeclarativeFontLoader);
+ if (url == d->url)
+ return;
+ d->url = qmlContext(this)->resolvedUrl(url);
+
+ d->status = Loading;
+ emit statusChanged();
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+ QString lf = toLocalFileOrQrc(d->url);
+ if (!lf.isEmpty()) {
+ int id = QFontDatabase::addApplicationFont(lf);
+ if (id != -1) {
+ d->name = QFontDatabase::applicationFontFamilies(id).at(0);
+ emit nameChanged();
+ d->status = QDeclarativeFontLoader::Ready;
+ } else {
+ d->status = QDeclarativeFontLoader::Error;
+ qWarning() << "Cannot load font:" << url;
+ }
+ emit statusChanged();
+ } else
+#endif
+ {
+ QNetworkRequest req(d->url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ d->reply = qmlEngine(this)->networkAccessManager()->get(req);
+ QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ }
+}
+
+/*!
+ \qmlproperty string FontLoader::name
+
+ This property holds the name of the font family.
+ It is set automatically when a font is loaded using the \c url property.
+
+ Use this to set the \c font.family property of a \c Text item.
+
+ Example:
+ \qml
+ FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
+ Text { text: "Fancy font"; font.family: webFont.name }
+ \endqml
+*/
+QString QDeclarativeFontLoader::name() const
+{
+ Q_D(const QDeclarativeFontLoader);
+ return d->name;
+}
+
+void QDeclarativeFontLoader::setName(const QString &name)
+{
+ Q_D(QDeclarativeFontLoader);
+ if (d->name == name )
+ return;
+ d->name = name;
+ emit nameChanged();
+ d->status = Ready;
+ emit statusChanged();
+}
+
+/*!
+ \qmlproperty enum FontLoader::status
+
+ This property holds the status of font loading. It can be one of:
+ \list
+ \o Null - no font has been set
+ \o Ready - the font has been loaded
+ \o Loading - the font is currently being loaded
+ \o Error - an error occurred while loading the font
+ \endlist
+*/
+QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const
+{
+ Q_D(const QDeclarativeFontLoader);
+ return d->status;
+}
+
+void QDeclarativeFontLoader::replyFinished()
+{
+ Q_D(QDeclarativeFontLoader);
+ if (d->reply) {
+ if (!d->reply->error()) {
+ QByteArray ba = d->reply->readAll();
+ d->addFontToDatabase(ba);
+ } else {
+ d->status = Error;
+ emit statusChanged();
+ }
+ d->reply->deleteLater();
+ d->reply = 0;
+ }
+}
+
+void QDeclarativeFontLoaderPrivate::addFontToDatabase(const QByteArray &ba)
+{
+ Q_Q(QDeclarativeFontLoader);
+
+ int id = QFontDatabase::addApplicationFontFromData(ba);
+ if (id != -1) {
+ name = QFontDatabase::applicationFontFamilies(id).at(0);
+ emit q->nameChanged();
+ status = QDeclarativeFontLoader::Ready;
+ } else {
+ status = QDeclarativeFontLoader::Error;
+ qWarning() << "Cannot load font:" << url;
+ }
+ emit q->statusChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativefontloader_p.h b/src/declarative/util/qdeclarativefontloader_p.h
new file mode 100644
index 0000000000..14335ab098
--- /dev/null
+++ b/src/declarative/util/qdeclarativefontloader_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEFONTLOADER_H
+#define QDECLARATIVEFONTLOADER_H
+
+#include <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeFontLoaderPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeFontLoader : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeFontLoader)
+ Q_ENUMS(Status)
+
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+
+public:
+ enum Status { Null = 0, Ready, Loading, Error };
+
+ QDeclarativeFontLoader(QObject *parent = 0);
+ ~QDeclarativeFontLoader();
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ Status status() const;
+
+private Q_SLOTS:
+ void replyFinished();
+
+Q_SIGNALS:
+ void nameChanged();
+ void statusChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFontLoader)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEFONTLOADER_H
+
diff --git a/src/declarative/util/qdeclarativelistaccessor.cpp b/src/declarative/util/qdeclarativelistaccessor.cpp
new file mode 100644
index 0000000000..4e569093bd
--- /dev/null
+++ b/src/declarative/util/qdeclarativelistaccessor.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 "qdeclarativelistaccessor_p.h"
+
+#include <qdeclarativemetatype_p.h>
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qdebug.h>
+
+// ### Remove me
+#include <qdeclarativeengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QDeclarativeListAccessor::QDeclarativeListAccessor()
+: m_type(Invalid)
+{
+}
+
+QDeclarativeListAccessor::~QDeclarativeListAccessor()
+{
+}
+
+QVariant QDeclarativeListAccessor::list() const
+{
+ return d;
+}
+
+void QDeclarativeListAccessor::setList(const QVariant &v, QDeclarativeEngine *engine)
+{
+ d = v;
+
+ QDeclarativeEnginePrivate *enginePrivate = engine?QDeclarativeEnginePrivate::get(engine):0;
+
+ if (!d.isValid()) {
+ m_type = Invalid;
+ } else if (d.userType() == QVariant::StringList) {
+ m_type = StringList;
+ } else if (d.userType() == QMetaType::QVariantList) {
+ m_type = VariantList;
+ } else if (d.canConvert(QVariant::Int)) {
+ m_type = Integer;
+ } else if ((!enginePrivate && QDeclarativeMetaType::isQObject(d.userType())) ||
+ (enginePrivate && enginePrivate->isQObject(d.userType()))) {
+ QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v);
+ d = QVariant::fromValue(data);
+ m_type = Instance;
+ } else if (d.userType() == qMetaTypeId<QDeclarativeListReference>()) {
+ m_type = ListProperty;
+ } else {
+ m_type = Instance;
+ }
+}
+
+int QDeclarativeListAccessor::count() const
+{
+ switch(m_type) {
+ case StringList:
+ return qvariant_cast<QStringList>(d).count();
+ case VariantList:
+ return qvariant_cast<QVariantList>(d).count();
+ case ListProperty:
+ return ((QDeclarativeListReference *)d.constData())->count();
+ case Instance:
+ return 1;
+ case Integer:
+ return d.toInt();
+ default:
+ case Invalid:
+ return 0;
+ }
+}
+
+QVariant QDeclarativeListAccessor::at(int idx) const
+{
+ Q_ASSERT(idx >= 0 && idx < count());
+ switch(m_type) {
+ case StringList:
+ return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
+ case VariantList:
+ return qvariant_cast<QVariantList>(d).at(idx);
+ case ListProperty:
+ return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx));
+ case Instance:
+ return d;
+ case Integer:
+ return QVariant(idx);
+ default:
+ case Invalid:
+ return QVariant();
+ }
+}
+
+bool QDeclarativeListAccessor::isValid() const
+{
+ return m_type != Invalid;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativelistaccessor_p.h b/src/declarative/util/qdeclarativelistaccessor_p.h
new file mode 100644
index 0000000000..d8bb8af057
--- /dev/null
+++ b/src/declarative/util/qdeclarativelistaccessor_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 QDECLARATIVELISTACCESSOR_H
+#define QDECLARATIVELISTACCESSOR_H
+
+#include <QtCore/QVariant>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeEngine;
+class Q_DECLARATIVE_EXPORT QDeclarativeListAccessor
+{
+public:
+ QDeclarativeListAccessor();
+ ~QDeclarativeListAccessor();
+
+ QVariant list() const;
+ void setList(const QVariant &, QDeclarativeEngine * = 0);
+
+ bool isValid() const;
+
+ int count() const;
+ QVariant at(int) const;
+
+ enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
+ Type type() const { return m_type; }
+
+private:
+ Type m_type;
+ QVariant d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVELISTACCESSOR_H
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
new file mode 100644
index 0000000000..e3f26d79fa
--- /dev/null
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -0,0 +1,985 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativelistmodel_p.h"
+
+#include "qdeclarativeopenmetaobject_p.h"
+
+#include <qdeclarativecustomparser_p.h>
+#include <qdeclarativeparser_p.h>
+#include <qdeclarativeengine_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeinfo.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qstack.h>
+#include <QXmlStreamReader>
+#include <QtScript/qscriptvalueiterator.h>
+
+Q_DECLARE_METATYPE(QListModelInterface *)
+
+QT_BEGIN_NAMESPACE
+
+#define DATA_ROLE_ID 1
+#define DATA_ROLE_NAME "data"
+
+QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListModelData::instructions() const
+{
+ return (QDeclarativeListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData));
+}
+
+static void dump(ModelNode *node, int ind);
+
+/*!
+ \qmlclass ListModel QDeclarativeListModel
+ \since 4.7
+ \brief The ListModel element defines a free-form list data source.
+
+ The ListModel is a simple hierarchy of elements containing data roles. The contents can
+ be defined dynamically, or explicitly in QML:
+
+ For example:
+
+ \code
+ ListModel {
+ id: fruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+ }
+ \endcode
+
+ Roles (properties) must begin with a lower-case letter. The above example defines a
+ ListModel containing three elements, with the roles "name" and "cost".
+
+ The defined model can be used in views such as ListView:
+ \code
+ Component {
+ id: fruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+ }
+ }
+
+ ListView {
+ model: fruitModel
+ delegate: fruitDelegate
+ anchors.fill: parent
+ }
+ \endcode
+
+ It is possible for roles to contain list data. In the example below we create a list of fruit attributes:
+
+ \code
+ ListModel {
+ id: fruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ attributes: [
+ ListElement { description: "Core" },
+ ListElement { description: "Deciduous" }
+ ]
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ attributes: [
+ ListElement { description: "Citrus" }
+ ]
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Seedless" }
+ ]
+ }
+ }
+ \endcode
+
+ The delegate below will list all the fruit attributes:
+ \code
+ Component {
+ id: fruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { id: name; text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+ Row {
+ anchors.top: name.bottom
+ spacing: 5
+ Text { text: "Attributes:" }
+ Repeater {
+ dataSource: attributes
+ Component { Text { text: description } }
+ }
+ }
+ }
+ }
+ \endcode
+
+ The content of a ListModel may be created and modified using the clear(),
+ append(), and set() methods. For example:
+
+ \code
+ Component {
+ id: fruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+
+ // Double the price when clicked.
+ MouseArea {
+ anchors.fill: parent
+ onClicked: fruitModel.set(index, "cost", cost*2)
+ }
+ }
+ }
+ \endcode
+
+ When creating content dynamically, note that the set of available properties cannot be changed
+ except by first clearing the model - whatever properties are first added are then the
+ only permitted properties in the model.
+
+ \sa {qmlmodels}{Data Models}
+*/
+
+class ModelObject : public QObject
+{
+ Q_OBJECT
+public:
+ ModelObject();
+
+ void setValue(const QByteArray &name, const QVariant &val)
+ {
+ _mo->setValue(name, val);
+ }
+
+private:
+ QDeclarativeOpenMetaObject *_mo;
+};
+
+struct ModelNode
+{
+ ModelNode();
+ ~ModelNode();
+
+ QList<QVariant> values;
+ QHash<QString, ModelNode *> properties;
+
+ QDeclarativeListModel *model(const QDeclarativeListModel *parent) {
+ if (!modelCache) {
+ modelCache = new QDeclarativeListModel;
+ QDeclarativeEngine::setContextForObject(modelCache,QDeclarativeEngine::contextForObject(parent));
+
+ modelCache->_root = this;
+ }
+ return modelCache;
+ }
+
+ ModelObject *object(const QDeclarativeListModel *parent) {
+ if (!objectCache) {
+ objectCache = new ModelObject();
+ QHash<QString, ModelNode *>::iterator it;
+ for (it = properties.begin(); it != properties.end(); ++it) {
+ objectCache->setValue(it.key().toUtf8(), parent->valueForNode(*it));
+ }
+ }
+ return objectCache;
+ }
+
+ void setObjectValue(const QScriptValue& valuemap);
+ void setListValue(const QScriptValue& valuelist);
+
+ void setProperty(const QString& prop, const QVariant& val) {
+ QHash<QString, ModelNode *>::const_iterator it = properties.find(prop);
+ if (it != properties.end()) {
+ (*it)->values[0] = val;
+ } else {
+ ModelNode *n = new ModelNode;
+ n->values << val;
+ properties.insert(prop,n);
+ }
+ if (objectCache)
+ objectCache->setValue(prop.toUtf8(), val);
+ }
+
+ QDeclarativeListModel *modelCache;
+ ModelObject *objectCache;
+ bool isArray;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(ModelNode *)
+
+QT_BEGIN_NAMESPACE
+
+void ModelNode::setObjectValue(const QScriptValue& valuemap) {
+ QScriptValueIterator it(valuemap);
+ while (it.hasNext()) {
+ it.next();
+ ModelNode *value = new ModelNode;
+ QScriptValue v = it.value();
+ if (v.isArray()) {
+ value->isArray = true;
+ value->setListValue(v);
+ } else {
+ value->values << v.toVariant();
+ }
+ properties.insert(it.name(),value);
+ }
+}
+
+void ModelNode::setListValue(const QScriptValue& valuelist) {
+ QScriptValueIterator it(valuelist);
+ values.clear();
+ while (it.hasNext()) {
+ it.next();
+ ModelNode *value = new ModelNode;
+ QScriptValue v = it.value();
+ if (v.isArray()) {
+ value->isArray = true;
+ value->setListValue(v);
+ } else if (v.isObject()) {
+ value->setObjectValue(v);
+ } else {
+ value->values << v.toVariant();
+ }
+ values.append(qVariantFromValue(value));
+
+ }
+}
+
+
+ModelObject::ModelObject()
+: _mo(new QDeclarativeOpenMetaObject(this))
+{
+}
+
+QDeclarativeListModel::QDeclarativeListModel(QObject *parent)
+: QListModelInterface(parent), _rolesOk(false), _root(0)
+{
+}
+
+QDeclarativeListModel::~QDeclarativeListModel()
+{
+ delete _root;
+}
+
+void QDeclarativeListModel::checkRoles() const
+{
+ if (_rolesOk || !_root)
+ return;
+
+ for (int ii = 0; ii < _root->values.count(); ++ii) {
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(ii));
+ if (node) {
+ foreach (const QString &role, node->properties.keys())
+ addRole(role);
+ }
+ }
+
+ _rolesOk = true;
+}
+
+void QDeclarativeListModel::addRole(const QString &role) const
+{
+ if (!roleStrings.contains(role))
+ roleStrings << role;
+}
+
+QList<int> QDeclarativeListModel::roles() const
+{
+ checkRoles();
+ QList<int> rv;
+ for (int ii = 0; ii < roleStrings.count(); ++ii)
+ rv << ii;
+ return rv;
+}
+
+QString QDeclarativeListModel::toString(int role) const
+{
+ checkRoles();
+ if (role < roleStrings.count())
+ return roleStrings.at(role);
+ else
+ return QString();
+}
+
+QVariant QDeclarativeListModel::valueForNode(ModelNode *node) const
+{
+ QObject *rv = 0;
+
+ if (node->isArray) {
+ // List
+ rv = node->model(this);
+ } else {
+ if (!node->properties.isEmpty()) {
+ // Object
+ rv = node->object(this);
+ } else if (node->values.count() == 0) {
+ // Invalid
+ return QVariant();
+ } else if (node->values.count() == 1) {
+ // Value
+ QVariant &var = node->values[0];
+ ModelNode *valueNode = qvariant_cast<ModelNode *>(var);
+ if (valueNode) {
+ if (!valueNode->properties.isEmpty())
+ rv = valueNode->object(this);
+ else
+ rv = valueNode->model(this);
+ } else {
+ return var;
+ }
+ }
+ }
+
+ if (rv)
+ return QVariant::fromValue(rv);
+ else
+ return QVariant();
+}
+
+QHash<int,QVariant> QDeclarativeListModel::data(int index, const QList<int> &roles) const
+{
+ checkRoles();
+ QHash<int, QVariant> rv;
+ if (index >= count() || index < 0)
+ return rv;
+
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ if (!node)
+ return rv;
+
+ for (int ii = 0; ii < roles.count(); ++ii) {
+ const QString &roleString = roleStrings.at(roles.at(ii));
+
+ QHash<QString, ModelNode *>::ConstIterator iter =
+ node->properties.find(roleString);
+ if (iter != node->properties.end()) {
+ ModelNode *row = *iter;
+ rv.insert(roles.at(ii), valueForNode(row));
+ }
+ }
+
+ return rv;
+}
+
+QVariant QDeclarativeListModel::data(int index, int role) const
+{
+ checkRoles();
+ QVariant rv;
+ if (index >= count() || index < 0)
+ return rv;
+
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ if (!node)
+ return rv;
+
+ const QString &roleString = roleStrings.at(role);
+
+ QHash<QString, ModelNode *>::ConstIterator iter =
+ node->properties.find(roleString);
+ if (iter != node->properties.end()) {
+ ModelNode *row = *iter;
+ rv = valueForNode(row);
+ }
+
+ return rv;
+}
+
+/*!
+ \qmlproperty int ListModel::count
+ The number of data entries in the model.
+*/
+int QDeclarativeListModel::count() const
+{
+ if (!_root) return 0;
+ return _root->values.count();
+}
+
+/*!
+ \qmlmethod ListModel::clear()
+
+ Deletes all content from the model. The properties are cleared such that
+ different properties may be set on subsequent additions.
+
+ \sa append() remove()
+*/
+void QDeclarativeListModel::clear()
+{
+ int cleared = count();
+ _rolesOk = false;
+ delete _root;
+ _root = 0;
+ roleStrings.clear();
+ emit itemsRemoved(0,cleared);
+ emit countChanged(0);
+}
+
+/*!
+ \qmlmethod ListModel::remove(int index)
+
+ Deletes the content at \a index from the model.
+
+ \sa clear()
+*/
+void QDeclarativeListModel::remove(int index)
+{
+ if (!_root || index < 0 || index >= _root->values.count()) {
+ qmlInfo(this) << tr("remove: index %1 out of range").arg(index);
+ return;
+ }
+
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ _root->values.removeAt(index);
+ if (node)
+ delete node;
+ emit itemsRemoved(index,1);
+ emit countChanged(_root->values.count());
+}
+
+/*!
+ \qmlmethod ListModel::insert(int index, jsobject dict)
+
+ Adds a new item to the list model at position \a index, with the
+ values in \a dict.
+
+ \code
+ FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be to an existing item in the list, or one past
+ the end of the list (equivalent to append).
+
+ \sa set() append()
+*/
+void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap)
+{
+ if (!valuemap.isObject() || valuemap.isArray()) {
+ qmlInfo(this) << tr("insert: value is not an object");
+ return;
+ }
+ if (!_root)
+ _root = new ModelNode;
+ if (index >= _root->values.count() || index<0) {
+ if (index == _root->values.count())
+ append(valuemap);
+ else
+ qmlInfo(this) << tr("insert: index %1 out of range").arg(index);
+ return;
+ }
+ ModelNode *mn = new ModelNode;
+ mn->setObjectValue(valuemap);
+ _root->values.insert(index,qVariantFromValue(mn));
+ emit itemsInserted(index,1);
+ emit countChanged(_root->values.count());
+}
+
+/*!
+ \qmlmethod ListModel::move(int from, int to, int n)
+
+ Moves \a n items \a from one position \a to another.
+
+ The from and to ranges must exist; for example, to move the first 3 items
+ to the end of the list:
+
+ \code
+ FruitModel.move(0,FruitModel.count-3,3)
+ \endcode
+
+ \sa append()
+*/
+void QDeclarativeListModel::move(int from, int to, int n)
+{
+ if (n==0 || from==to)
+ return;
+ if (from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0) {
+ qmlInfo(this) << tr("move: out of range");
+ return;
+ }
+ int origfrom=from; // preserve actual move, so any animations are correct
+ int origto=to;
+ int orign=n;
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+ if (n==1) {
+ _root->values.move(from,to);
+ } else {
+ QList<QVariant> replaced;
+ int i=0;
+ QVariantList::const_iterator it=_root->values.begin(); it += from+n;
+ for (; i<to-from; ++i,++it)
+ replaced.append(*it);
+ i=0;
+ it=_root->values.begin(); it += from;
+ for (; i<n; ++i,++it)
+ replaced.append(*it);
+ QVariantList::const_iterator f=replaced.begin();
+ QVariantList::iterator t=_root->values.begin(); t += from;
+ for (; f != replaced.end(); ++f, ++t)
+ *t = *f;
+ }
+ emit itemsMoved(origfrom,origto,orign);
+}
+
+/*!
+ \qmlmethod ListModel::append(jsobject dict)
+
+ Adds a new item to the end of the list model, with the
+ values in \a dict.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ \sa set() remove()
+*/
+void QDeclarativeListModel::append(const QScriptValue& valuemap)
+{
+ if (!valuemap.isObject() || valuemap.isArray()) {
+ qmlInfo(this) << tr("append: value is not an object");
+ return;
+ }
+ if (!_root)
+ _root = new ModelNode;
+ ModelNode *mn = new ModelNode;
+ mn->setObjectValue(valuemap);
+ _root->values << qVariantFromValue(mn);
+ emit itemsInserted(count()-1,1);
+ emit countChanged(_root->values.count());
+}
+
+/*!
+ \qmlmethod object ListModel::get(int index)
+
+ Returns the item at \a index in the list model.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Jackfruit"})
+ FruitModel.get(0).cost
+ \endcode
+
+ The \a index must be an element in the list.
+
+ Note that properties of the returned object that are themselves objects
+ will also be models, and this get() method is used to access elements:
+
+ \code
+ FruitModel.append(..., "attributes":
+ [{"name":"spikes","value":"7mm"},
+ {"name":"color","value":"green"}]);
+ FruitModel.get(0).attributes.get(1).value; // == "green"
+ \endcode
+
+ \sa append()
+*/
+QScriptValue QDeclarativeListModel::get(int index) const
+{
+ if (index >= count() || index < 0) {
+ qmlInfo(this) << tr("get: index %1 out of range").arg(index);
+ return 0;
+ }
+
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ if (!node)
+ return 0;
+ QDeclarativeEngine *eng = qmlEngine(this);
+ if (!eng) {
+ qWarning("Cannot call QDeclarativeListModel::get() without a QDeclarativeEngine");
+ return 0;
+ }
+ return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng);
+}
+
+/*!
+ \qmlmethod ListModel::set(int index, jsobject dict)
+
+ Changes the item at \a index in the list model with the
+ values in \a dict. Properties not appearing in \a valuemap
+ are left unchanged.
+
+ \code
+ FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
+void QDeclarativeListModel::set(int index, const QScriptValue& valuemap)
+{
+ if (!valuemap.isObject() || valuemap.isArray()) {
+ qmlInfo(this) << tr("set: value is not an object");
+ return;
+ }
+ if ( !_root || index > _root->values.count() || index < 0) {
+ qmlInfo(this) << tr("set: index %1 out of range").arg(index);
+ return;
+ }
+ if (index == _root->values.count())
+ append(valuemap);
+ else {
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ QList<int> roles;
+ node->setObjectValue(valuemap);
+ QScriptValueIterator it(valuemap);
+ while (it.hasNext()) {
+ it.next();
+ int r = roleStrings.indexOf(it.name());
+ if (r<0) {
+ r = roleStrings.count();
+ roleStrings << it.name();
+ }
+ roles.append(r);
+ }
+ emit itemsChanged(index,1,roles);
+ }
+}
+
+/*!
+ \qmlmethod ListModel::setProperty(int index, string property, variant value)
+
+ Changes the \a property of the item at \a index in the list model to \a value.
+
+ \code
+ FruitModel.set(3, "cost", 5.95)
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
+void QDeclarativeListModel::setProperty(int index, const QString& property, const QVariant& value)
+{
+ if ( !_root || index >= _root->values.count() || index < 0) {
+ qmlInfo(this) << tr("set: index %1 out of range").arg(index);
+ return;
+ }
+ ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
+ int r = roleStrings.indexOf(property);
+ if (r<0) {
+ r = roleStrings.count();
+ roleStrings << property;
+ }
+ QList<int> roles;
+ roles.append(r);
+
+ if (node)
+ node->setProperty(property,value);
+ emit itemsChanged(index,1,roles);
+}
+
+bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
+{
+ QList<QVariant> values = prop.assignedValues();
+ for(int ii = 0; ii < values.count(); ++ii) {
+ const QVariant &value = values.at(ii);
+
+ if(value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
+ QDeclarativeCustomParserNode node =
+ qvariant_cast<QDeclarativeCustomParserNode>(value);
+
+ {
+ ListInstruction li;
+ li.type = ListInstruction::Push;
+ li.dataIdx = -1;
+ instr << li;
+ }
+
+ QList<QDeclarativeCustomParserProperty> props = node.properties();
+ for(int jj = 0; jj < props.count(); ++jj) {
+ const QDeclarativeCustomParserProperty &nodeProp = props.at(jj);
+ if (nodeProp.name() == "") {
+ error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot use default property"));
+ return false;
+ }
+ if (nodeProp.name() == "id") {
+ error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot use reserved \"id\" property"));
+ return false;
+ }
+
+ ListInstruction li;
+ int ref = data.count();
+ data.append(nodeProp.name());
+ data.append('\0');
+ li.type = ListInstruction::Set;
+ li.dataIdx = ref;
+ instr << li;
+
+ if(!compileProperty(nodeProp, instr, data))
+ return false;
+
+ li.type = ListInstruction::Pop;
+ li.dataIdx = -1;
+ instr << li;
+ }
+
+ {
+ ListInstruction li;
+ li.type = ListInstruction::Pop;
+ li.dataIdx = -1;
+ instr << li;
+ }
+
+ } else {
+
+ QDeclarativeParser::Variant variant =
+ qvariant_cast<QDeclarativeParser::Variant>(value);
+
+ int ref = data.count();
+
+ QByteArray d;
+ d += char(variant.type()); // type tag
+ if (variant.isString()) {
+ d += variant.asString().toUtf8();
+ } else if (variant.isNumber()) {
+ d += QByteArray::number(variant.asNumber(),'g',20);
+ } else if (variant.isBoolean()) {
+ d += char(variant.asBoolean());
+ } else if (variant.isScript()) {
+ if (definesEmptyList(variant.asScript())) {
+ d[0] = 0; // QDeclarativeParser::Variant::Invalid - marks empty list
+ } else {
+ error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value"));
+ return false;
+ }
+ }
+ d.append('\0');
+ data.append(d);
+
+ ListInstruction li;
+ li.type = ListInstruction::Value;
+ li.dataIdx = ref;
+ instr << li;
+ }
+ }
+
+ return true;
+}
+
+QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomParserProperty> &customProps)
+{
+ QList<ListInstruction> instr;
+ QByteArray data;
+
+ for(int ii = 0; ii < customProps.count(); ++ii) {
+ const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
+ if(prop.name() != "") { // isn't default property
+ error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
+ return QByteArray();
+ }
+
+ if(!compileProperty(prop, instr, data)) {
+ return QByteArray();
+ }
+ }
+
+ int size = sizeof(ListModelData) +
+ instr.count() * sizeof(ListInstruction) +
+ data.count();
+
+ QByteArray rv;
+ rv.resize(size);
+
+ ListModelData *lmd = (ListModelData *)rv.data();
+ lmd->dataOffset = sizeof(ListModelData) +
+ instr.count() * sizeof(ListInstruction);
+ lmd->instrCount = instr.count();
+ for (int ii = 0; ii < instr.count(); ++ii)
+ lmd->instructions()[ii] = instr.at(ii);
+ ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());
+
+ return rv;
+}
+
+void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &d)
+{
+ QDeclarativeListModel *rv = static_cast<QDeclarativeListModel *>(obj);
+
+ ModelNode *root = new ModelNode;
+ rv->_root = root;
+ QStack<ModelNode *> nodes;
+ nodes << root;
+
+ bool processingSet = false;
+
+ const ListModelData *lmd = (const ListModelData *)d.constData();
+ const char *data = ((const char *)lmd) + lmd->dataOffset;
+
+ for (int ii = 0; ii < lmd->instrCount; ++ii) {
+ const ListInstruction &instr = lmd->instructions()[ii];
+
+ switch(instr.type) {
+ case ListInstruction::Push:
+ {
+ ModelNode *n = nodes.top();
+ ModelNode *n2 = new ModelNode;
+ n->values << qVariantFromValue(n2);
+ nodes.push(n2);
+ if (processingSet)
+ n->isArray = true;
+ }
+ break;
+
+ case ListInstruction::Pop:
+ nodes.pop();
+ break;
+
+ case ListInstruction::Value:
+ {
+ ModelNode *n = nodes.top();
+ switch (QDeclarativeParser::Variant::Type(data[instr.dataIdx])) {
+ case QDeclarativeParser::Variant::Invalid:
+ n->isArray = true;
+ break;
+ case QDeclarativeParser::Variant::Boolean:
+ n->values.append(bool(data[1 + instr.dataIdx]));
+ break;
+ case QDeclarativeParser::Variant::Number:
+ n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
+ break;
+ case QDeclarativeParser::Variant::String:
+ n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));
+ break;
+ default:
+ Q_ASSERT("Format error in ListInstruction");
+ }
+
+ processingSet = false;
+ }
+ break;
+
+ case ListInstruction::Set:
+ {
+ ModelNode *n = nodes.top();
+ ModelNode *n2 = new ModelNode;
+ n->properties.insert(QString::fromUtf8(data + instr.dataIdx), n2);
+ nodes.push(n2);
+ processingSet = true;
+ }
+ break;
+ }
+ }
+}
+
+bool QDeclarativeListModelParser::definesEmptyList(const QString &s)
+{
+ if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
+ for (int i=1; i<s.length()-1; i++) {
+ if (!s[i].isSpace())
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \qmlclass ListElement
+ \since 4.7
+ \brief The ListElement element defines a data item in a ListModel.
+
+ \sa ListModel
+*/
+
+static void dump(ModelNode *node, int ind)
+{
+ QByteArray indentBa(ind * 4, ' ');
+ const char *indent = indentBa.constData();
+
+ for (int ii = 0; ii < node->values.count(); ++ii) {
+ ModelNode *subNode = qvariant_cast<ModelNode *>(node->values.at(ii));
+ if (subNode) {
+ qWarning().nospace() << indent << "Sub-node " << ii;
+ dump(subNode, ind + 1);
+ } else {
+ qWarning().nospace() << indent << "Sub-node " << ii << ": " << node->values.at(ii).toString();
+ }
+ }
+
+ for (QHash<QString, ModelNode *>::ConstIterator iter = node->properties.begin(); iter != node->properties.end(); ++iter) {
+ qWarning().nospace() << indent << "Property " << iter.key() << ':';
+ dump(iter.value(), ind + 1);
+ }
+}
+
+ModelNode::ModelNode()
+: modelCache(0), objectCache(0), isArray(false)
+{
+}
+
+ModelNode::~ModelNode()
+{
+ qDeleteAll(properties);
+ for (int ii = 0; ii < values.count(); ++ii) {
+ ModelNode *node = qvariant_cast<ModelNode *>(values.at(ii));
+ if (node) { delete node; node = 0; }
+ }
+ if (modelCache) { modelCache->_root = 0/* ==this */; delete modelCache; modelCache = 0; }
+ if (objectCache) { delete objectCache; }
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativelistmodel.moc>
diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h
new file mode 100644
index 0000000000..251a31fa66
--- /dev/null
+++ b/src/declarative/util/qdeclarativelistmodel_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 QDECLARATIVELISTMODEL_H
+#define QDECLARATIVELISTMODEL_H
+
+#include <qdeclarative.h>
+#include <private/qdeclarativecustomparser_p.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QStringList>
+#include <QtCore/QHash>
+#include <QtCore/QList>
+#include <QtCore/QVariant>
+#include "../3rdparty/qlistmodelinterface_p.h"
+#include <QtScript/qscriptvalue.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+struct ModelNode;
+class Q_DECLARATIVE_EXPORT QDeclarativeListModel : public QListModelInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+
+public:
+ QDeclarativeListModel(QObject *parent=0);
+ ~QDeclarativeListModel();
+
+ 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_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 setProperty(int index, const QString& property, const QVariant& value);
+ Q_INVOKABLE void move(int from, int to, int count);
+
+Q_SIGNALS:
+ void countChanged(int);
+
+private:
+ QVariant valueForNode(ModelNode *) const;
+ mutable QStringList roleStrings;
+ friend class QDeclarativeListModelParser;
+ friend struct ModelNode;
+
+ void checkRoles() const;
+ void addRole(const QString &) const;
+ mutable bool _rolesOk;
+ ModelNode *_root;
+};
+
+// ### FIXME
+class QDeclarativeListElement : public QObject
+{
+Q_OBJECT
+};
+
+class QDeclarativeListModelParser : public QDeclarativeCustomParser
+{
+public:
+ QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
+ void setCustomData(QObject *, const QByteArray &);
+
+private:
+ struct ListInstruction
+ {
+ enum { Push, Pop, Value, Set } type;
+ int dataIdx;
+ };
+ struct ListModelData
+ {
+ int dataOffset;
+ int instrCount;
+ ListInstruction *instructions() const;
+ };
+ bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
+
+ bool definesEmptyList(const QString &);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeListModel)
+QML_DECLARE_TYPE(QDeclarativeListElement)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVELISTMODEL_H
diff --git a/src/declarative/util/qdeclarativenullablevalue_p_p.h b/src/declarative/util/qdeclarativenullablevalue_p_p.h
new file mode 100644
index 0000000000..fc3f8af6dd
--- /dev/null
+++ b/src/declarative/util/qdeclarativenullablevalue_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 QDECLARATIVENULLABLEVALUE_P_H
+#define QDECLARATIVENULLABLEVALUE_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
+
+template<typename T>
+struct QDeclarativeNullableValue
+{
+ QDeclarativeNullableValue()
+ : isNull(true), value(T()) {}
+ QDeclarativeNullableValue(const QDeclarativeNullableValue<T> &o)
+ : isNull(o.isNull), value(o.value) {}
+ QDeclarativeNullableValue(const T &t)
+ : isNull(false), value(t) {}
+ QDeclarativeNullableValue<T> &operator=(const T &t)
+ { isNull = false; value = t; return *this; }
+ QDeclarativeNullableValue<T> &operator=(const QDeclarativeNullableValue<T> &o)
+ { isNull = o.isNull; value = o.value; return *this; }
+ operator T() const { return value; }
+
+ void invalidate() { isNull = true; }
+ bool isValid() const { return !isNull; }
+ bool isNull;
+ T value;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVENULLABLEVALUE_P_H
diff --git a/src/declarative/util/qdeclarativenumberformatter.cpp b/src/declarative/util/qdeclarativenumberformatter.cpp
new file mode 100644
index 0000000000..5d81958dfe
--- /dev/null
+++ b/src/declarative/util/qdeclarativenumberformatter.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativenumberformatter_p.h"
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+//TODO: set locale
+// docs
+// this is a wrapper around qnumberformat (test integration)
+// if number or format haven't been explictly set, text should be an empty string
+
+class QDeclarativeNumberFormatterPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeNumberFormatter)
+public:
+ QDeclarativeNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {}
+
+ void updateText();
+
+ QLocale locale;
+ QString format;
+ QNumberFormat numberFormat;
+ QString text;
+ qreal number;
+ bool componentComplete;
+};
+/*!
+ \qmlclass NumberFormatter
+ \since 4.7
+ \brief The NumberFormatter allows you to control the format of a number string.
+
+ The format property documentation has more details on how the format can be manipulated.
+
+ In the following example, the text element will display the text "1,234.57".
+ \code
+ NumberFormatter { id: formatter; number: 1234.5678; format: "##,##0.##" }
+ Text { text: formatter.text }
+ \endcode
+
+ */
+/*!
+ \internal
+ \class QDeclarativeNumberFormatter
+ \ingroup group_utility
+ \brief The QDeclarativeNumberFormatter class allows you to format a number to a particular string format/locale specific number format.
+*/
+
+QDeclarativeNumberFormatter::QDeclarativeNumberFormatter(QObject *parent)
+: QObject(*(new QDeclarativeNumberFormatterPrivate), parent)
+{
+}
+
+QDeclarativeNumberFormatter::~QDeclarativeNumberFormatter()
+{
+}
+
+/*!
+ \qmlproperty string NumberFormatter::text
+
+ The number in the specified format.
+
+ If no format is specified the text will be empty.
+*/
+
+QString QDeclarativeNumberFormatter::text() const
+{
+ Q_D(const QDeclarativeNumberFormatter);
+ return d->text;
+}
+
+/*!
+ \qmlproperty real NumberFormatter::number
+
+ A single point precision number. (Doubles are not yet supported)
+
+*/
+qreal QDeclarativeNumberFormatter::number() const
+{
+ Q_D(const QDeclarativeNumberFormatter);
+ return d->number;
+}
+
+/*!
+ \qmlproperty string NumberFormatter::format
+
+ The particular format the number will adhere to during the conversion to text.
+
+ The format syntax follows a style similar to the Unicode Standard (UTS35).
+
+ The table below shows the characters, patterns that can be used in the format.
+
+ \table
+ \header
+ \o Character
+ \o Meaning
+ \row
+ \o #
+ \o Any digit(s), zero shows as absent (for leading/trailing zeroes).
+ \row
+ \o 0
+ \o Implicit digit. Zero will show in the case that the input number is too small.
+ \row
+ \o .
+ \o Decimal separator. Output decimal seperator will be dependant on system locale.
+ \row
+ \o ,
+ \o Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize).
+ \row
+ \o other
+ \o Any other character will be taken as a string literal and placed directly into the output string.
+ \endtable
+
+ Invalid formats will not guarantee a meaningful text output.
+
+ \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point.
+
+ The following table illustrates the output text created by applying some examples of numeric formats to the formatter.
+
+ \table
+ \header
+ \o Format
+ \o Number
+ \o Output
+ \row
+ \o ###
+ \o 123456
+ \o 123456
+ \row
+ \o 000
+ \o 123456
+ \o 123456
+ \row
+ \o ######
+ \o 1234
+ \o 1234
+ \row
+ \o 000000
+ \o 1234
+ \o 001234
+ \row
+ \o ##,##0.##
+ \o 1234.456
+ \o 1,234.46 (for US locale)
+ \codeline 1 234,46 (for FR locale)
+ \row
+ \o 000000,000.#
+ \o 123456
+ \o 000,123,456 (for US locale)
+ \codeline 000 123 456 (for FR locale)
+ \row
+ \o 0.0###
+ \o 0.999997
+ \o 1.0
+ \row
+ \o (000) 000 - 000
+ \o 12345678
+ \o (012) 345 - 678
+ \row
+ \o #A
+ \o 12
+ \o 12A
+ \endtable
+
+*/
+QString QDeclarativeNumberFormatter::format() const
+{
+ Q_D(const QDeclarativeNumberFormatter);
+ return d->format;
+}
+
+void QDeclarativeNumberFormatter::setNumber(const qreal &number)
+{
+ Q_D(QDeclarativeNumberFormatter);
+ if (d->number == number)
+ return;
+ d->number = number;
+ d->updateText();
+}
+
+void QDeclarativeNumberFormatter::setFormat(const QString &format)
+{
+ Q_D(QDeclarativeNumberFormatter);
+ //no format checking
+ if (format.isEmpty())
+ d->format = QString::null;
+ else
+ d->format = format;
+ d->updateText();
+}
+
+void QDeclarativeNumberFormatterPrivate::updateText()
+{
+ Q_Q(QDeclarativeNumberFormatter);
+ if (!componentComplete)
+ return;
+
+ QNumberFormat tempFormat;
+ tempFormat.setFormat(format);
+ tempFormat.setNumber(number);
+
+ text = tempFormat.text();
+
+ emit q->textChanged();
+}
+
+void QDeclarativeNumberFormatter::classBegin()
+{
+ Q_D(QDeclarativeNumberFormatter);
+ d->componentComplete = false;
+}
+
+void QDeclarativeNumberFormatter::componentComplete()
+{
+ Q_D(QDeclarativeNumberFormatter);
+ d->componentComplete = true;
+ d->updateText();
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativenumberformatter_p.h b/src/declarative/util/qdeclarativenumberformatter_p.h
new file mode 100644
index 0000000000..3b8c7e1ac7
--- /dev/null
+++ b/src/declarative/util/qdeclarativenumberformatter_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 QDECLARATIVENUMBERFORMATTER_H
+#define QDECLARATIVENUMBERFORMATTER_H
+
+#include "qnumberformat_p.h"
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeNumberFormatterPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeNumberFormatter : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+
+ Q_PROPERTY(QString text READ text NOTIFY textChanged)
+ Q_PROPERTY(QString format READ format WRITE setFormat)
+ Q_PROPERTY(qreal number READ number WRITE setNumber)
+public:
+ QDeclarativeNumberFormatter(QObject *parent=0);
+ ~QDeclarativeNumberFormatter();
+
+ QString text() const;
+
+ qreal number() const;
+ void setNumber(const qreal &);
+
+ QString format() const;
+ void setFormat(const QString &);
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void textChanged();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeNumberFormatter)
+ Q_DECLARE_PRIVATE(QDeclarativeNumberFormatter)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeNumberFormatter)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp
new file mode 100644
index 0000000000..8c2335401f
--- /dev/null
+++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp
@@ -0,0 +1,355 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeopenmetaobject_p.h"
+#include "qdeclarativepropertycache_p.h"
+#include "qdeclarativedeclarativedata_p.h"
+#include <qmetaobjectbuilder_p.h>
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QDeclarativeOpenMetaObjectTypePrivate
+{
+public:
+ QDeclarativeOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {}
+
+ void init(const QMetaObject *metaObj);
+
+ int propertyOffset;
+ int signalOffset;
+ QHash<QByteArray, int> names;
+ QMetaObjectBuilder mob;
+ QMetaObject *mem;
+ QDeclarativePropertyCache *cache;
+ QDeclarativeEngine *engine;
+ QSet<QDeclarativeOpenMetaObject*> referers;
+};
+
+QDeclarativeOpenMetaObjectType::QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine)
+ : d(new QDeclarativeOpenMetaObjectTypePrivate)
+{
+ d->engine = engine;
+ d->init(base);
+}
+
+QDeclarativeOpenMetaObjectType::~QDeclarativeOpenMetaObjectType()
+{
+ if (d->mem)
+ qFree(d->mem);
+ if (d->cache)
+ d->cache->release();
+ delete d;
+}
+
+
+int QDeclarativeOpenMetaObjectType::propertyOffset() const
+{
+ return d->propertyOffset;
+}
+
+int QDeclarativeOpenMetaObjectType::signalOffset() const
+{
+ return d->signalOffset;
+}
+
+int QDeclarativeOpenMetaObjectType::createProperty(const QByteArray &name)
+{
+ int id = d->mob.propertyCount();
+ d->mob.addSignal("__" + QByteArray::number(id) + "()");
+ QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
+ build.setDynamic(true);
+ propertyCreated(id, build);
+ qFree(d->mem);
+ d->mem = d->mob.toMetaObject();
+ d->names.insert(name, id);
+ QSet<QDeclarativeOpenMetaObject*>::iterator it = d->referers.begin();
+ while (it != d->referers.end()) {
+ QDeclarativeOpenMetaObject *omo = *it;
+ *static_cast<QMetaObject *>(omo) = *d->mem;
+ if (d->cache)
+ d->cache->update(d->engine, omo);
+ ++it;
+ }
+
+ return d->propertyOffset + id;
+}
+
+void QDeclarativeOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder)
+{
+ if (d->referers.count())
+ (*d->referers.begin())->propertyCreated(id, builder);
+}
+
+void QDeclarativeOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
+{
+ if (!mem) {
+ mob.setSuperClass(metaObj);
+ mob.setClassName(metaObj->className());
+ mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
+
+ mem = mob.toMetaObject();
+
+ propertyOffset = mem->propertyOffset();
+ signalOffset = mem->methodOffset();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+class QDeclarativeOpenMetaObjectPrivate
+{
+public:
+ QDeclarativeOpenMetaObjectPrivate(QDeclarativeOpenMetaObject *_q)
+ : q(_q), parent(0), type(0), cacheProperties(false) {}
+
+ inline QVariant &getData(int idx) {
+ while (data.count() <= idx)
+ data << QPair<QVariant, bool>(QVariant(), false);
+ QPair<QVariant, bool> &prop = data[idx];
+ if (!prop.second) {
+ prop.first = q->initialValue(idx);
+ prop.second = true;
+ }
+ return prop.first;
+ }
+
+ inline void writeData(int idx, const QVariant &value) {
+ while (data.count() <= idx)
+ data << QPair<QVariant, bool>(QVariant(), false);
+ QPair<QVariant, bool> &prop = data[idx];
+ prop.first = value;
+ prop.second = true;
+ }
+
+ bool autoCreate;
+ QDeclarativeOpenMetaObject *q;
+ QAbstractDynamicMetaObject *parent;
+ QList<QPair<QVariant, bool> > data;
+ QObject *object;
+ QDeclarativeOpenMetaObjectType *type;
+ bool cacheProperties;
+};
+
+QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(QObject *obj, bool automatic)
+: d(new QDeclarativeOpenMetaObjectPrivate(this))
+{
+ d->autoCreate = automatic;
+ d->object = obj;
+
+ d->type = new QDeclarativeOpenMetaObjectType(obj->metaObject(), 0);
+ d->type->d->referers.insert(this);
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
+ op->metaObject = this;
+}
+
+QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(QObject *obj, QDeclarativeOpenMetaObjectType *type, bool automatic)
+: d(new QDeclarativeOpenMetaObjectPrivate(this))
+{
+ d->autoCreate = automatic;
+ d->object = obj;
+
+ d->type = type;
+ d->type->addref();
+ d->type->d->referers.insert(this);
+
+ QObjectPrivate *op = QObjectPrivate::get(obj);
+ *static_cast<QMetaObject *>(this) = *d->type->d->mem;
+ op->metaObject = this;
+}
+
+QDeclarativeOpenMetaObject::~QDeclarativeOpenMetaObject()
+{
+ if (d->parent)
+ delete d->parent;
+ d->type->d->referers.remove(this);
+ d->type->release();
+ delete d;
+}
+
+QDeclarativeOpenMetaObjectType *QDeclarativeOpenMetaObject::type() const
+{
+ return d->type;
+}
+
+int QDeclarativeOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
+{
+ if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty)
+ && id >= d->type->d->propertyOffset) {
+ int propId = id - d->type->d->propertyOffset;
+ if (c == QMetaObject::ReadProperty) {
+ propertyRead(propId);
+ *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
+ } else if (c == QMetaObject::WriteProperty) {
+ if (d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
+ propertyWrite(propId);
+ d->writeData(propId, *reinterpret_cast<QVariant *>(a[0]));
+ activate(d->object, d->type->d->signalOffset + propId, 0);
+ }
+ }
+ return -1;
+ } else {
+ if (d->parent)
+ return d->parent->metaCall(c, id, a);
+ else
+ return d->object->qt_metacall(c, id, a);
+ }
+}
+
+QAbstractDynamicMetaObject *QDeclarativeOpenMetaObject::parent() const
+{
+ return d->parent;
+}
+
+QVariant QDeclarativeOpenMetaObject::value(int id) const
+{
+ return d->getData(id);
+}
+
+void QDeclarativeOpenMetaObject::setValue(int id, const QVariant &value)
+{
+ d->writeData(id, value);
+ activate(d->object, id + d->type->d->signalOffset, 0);
+}
+
+QVariant QDeclarativeOpenMetaObject::value(const QByteArray &name) const
+{
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+ if (iter == d->type->d->names.end())
+ return QVariant();
+
+ return d->getData(*iter);
+}
+
+QVariant &QDeclarativeOpenMetaObject::operator[](const QByteArray &name)
+{
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+ Q_ASSERT(iter != d->type->d->names.end());
+
+ return d->getData(*iter);
+}
+
+void QDeclarativeOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
+{
+ QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
+
+ int id = -1;
+ if (iter == d->type->d->names.end()) {
+ id = d->type->createProperty(name.constData()) - d->type->d->propertyOffset;
+ } else {
+ id = *iter;
+ }
+
+ QVariant &dataVal = d->getData(id);
+ if (dataVal == val)
+ return;
+
+ dataVal = val;
+ activate(d->object, id + d->type->d->signalOffset, 0);
+}
+
+void QDeclarativeOpenMetaObject::setCached(bool c)
+{
+ if (c == d->cacheProperties || !d->type->d->engine)
+ return;
+
+ d->cacheProperties = c;
+
+ QDeclarativeDeclarativeData *qmldata = QDeclarativeDeclarativeData::get(d->object, true);
+ if (d->cacheProperties) {
+ if (!d->type->d->cache)
+ d->type->d->cache = QDeclarativePropertyCache::create(d->type->d->engine, this);
+ qmldata->propertyCache = d->type->d->cache;
+ d->type->d->cache->addref();
+ } else {
+ if (d->type->d->cache)
+ d->type->d->cache->release();
+ qmldata->propertyCache = 0;
+ }
+}
+
+
+int QDeclarativeOpenMetaObject::createProperty(const char *name, const char *)
+{
+ if (d->autoCreate)
+ return d->type->createProperty(name);
+ else
+ return -1;
+}
+
+void QDeclarativeOpenMetaObject::propertyRead(int)
+{
+}
+
+void QDeclarativeOpenMetaObject::propertyWrite(int)
+{
+}
+
+void QDeclarativeOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &)
+{
+}
+
+QVariant QDeclarativeOpenMetaObject::initialValue(int)
+{
+ return QVariant();
+}
+
+int QDeclarativeOpenMetaObject::count() const
+{
+ return d->type->d->names.count();
+}
+
+QByteArray QDeclarativeOpenMetaObject::name(int idx) const
+{
+ Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
+
+ return d->type->d->mob.property(idx).name();
+}
+
+QObject *QDeclarativeOpenMetaObject::object() const
+{
+ return d->object;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeopenmetaobject_p.h b/src/declarative/util/qdeclarativeopenmetaobject_p.h
new file mode 100644
index 0000000000..ec5ac17b20
--- /dev/null
+++ b/src/declarative/util/qdeclarativeopenmetaobject_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 QDECLARATIVEOPENMETAOBJECT_H
+#define QDECLARATIVEOPENMETAOBJECT_H
+
+#include <private/qdeclarativerefcount_p.h>
+#include <QtCore/QMetaObject>
+#include <QtCore/QObject>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeEngine;
+class QMetaPropertyBuilder;
+class QDeclarativeOpenMetaObjectTypePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeOpenMetaObjectType : public QDeclarativeRefCount
+{
+public:
+ QDeclarativeOpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine);
+ ~QDeclarativeOpenMetaObjectType();
+
+ int createProperty(const QByteArray &name);
+
+ int propertyOffset() const;
+ int signalOffset() const;
+
+protected:
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+
+private:
+ QDeclarativeOpenMetaObjectTypePrivate *d;
+ friend class QDeclarativeOpenMetaObject;
+ friend class QDeclarativeOpenMetaObjectPrivate;
+};
+
+class QDeclarativeOpenMetaObjectPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeOpenMetaObject : public QAbstractDynamicMetaObject
+{
+public:
+ QDeclarativeOpenMetaObject(QObject *, bool = true);
+ QDeclarativeOpenMetaObject(QObject *, QDeclarativeOpenMetaObjectType *, bool = true);
+ ~QDeclarativeOpenMetaObject();
+
+ QVariant value(const QByteArray &) const;
+ void setValue(const QByteArray &, const QVariant &);
+ QVariant value(int) const;
+ void setValue(int, const QVariant &);
+ QVariant &operator[](const QByteArray &);
+
+ int count() const;
+ QByteArray name(int) const;
+
+ QObject *object() const;
+ virtual QVariant initialValue(int);
+
+ // Be careful - once setCached(true) is called createProperty() is no
+ // longer automatically called for new properties.
+ void setCached(bool);
+
+ QDeclarativeOpenMetaObjectType *type() const;
+
+protected:
+ virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
+ virtual int createProperty(const char *, const char *);
+
+ virtual void propertyRead(int);
+ virtual void propertyWrite(int);
+ virtual void propertyCreated(int, QMetaPropertyBuilder &);
+
+ QAbstractDynamicMetaObject *parent() const;
+
+private:
+ QDeclarativeOpenMetaObjectPrivate *d;
+ friend class QDeclarativeOpenMetaObjectType;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEOPENMETAOBJECT_H
diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp
new file mode 100644
index 0000000000..34ae466cb1
--- /dev/null
+++ b/src/declarative/util/qdeclarativepackage.cpp
@@ -0,0 +1,194 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativepackage_p.h"
+
+#include <private/qobject_p.h>
+#include "private/qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Package QDeclarativePackage
+ \brief Package provides a collection of named items
+
+ The Package class is currently used in conjunction with
+ VisualDataModel to enable delegates with a shared context
+ to be provided to multiple views.
+
+ Any item within a Package may be assigned a name via the
+ \e {Package.name} attached property.
+
+ The example below creates a Package containing two named items;
+ \e list and \e grid. The third element in the package is parented to whichever
+ delegate it should appear in. This allows an item to move
+ between views.
+
+ \snippet examples/declarative/package/Delegate.qml 0
+
+ These named items are used as the delegates by the two views who
+ reference the special VisualDataModel.parts property to select
+ a model which provides the chosen delegate.
+
+ \snippet examples/declarative/package/view.qml 0
+
+*/
+
+
+class QDeclarativePackagePrivate : public QObjectPrivate
+{
+public:
+ QDeclarativePackagePrivate() {}
+
+ struct DataGuard : public QDeclarativeGuard<QObject>
+ {
+ DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; }
+ QList<DataGuard> *list;
+ void objectDestroyed(QObject *) {
+ // we assume priv will always be destroyed after objectDestroyed calls
+ list->removeOne(*this);
+ }
+ };
+
+ QList<DataGuard> dataList;
+ static void data_append(QDeclarativeListProperty<QObject> *prop, QObject *o) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->append(DataGuard(o, list));
+ }
+ static void data_clear(QDeclarativeListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->clear();
+ }
+ static QObject *data_at(QDeclarativeListProperty<QObject> *prop, int index) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->at(index);
+ }
+ static int data_count(QDeclarativeListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ return list->count();
+ }
+};
+
+QHash<QObject *, QDeclarativePackageAttached *> QDeclarativePackageAttached::attached;
+
+QDeclarativePackageAttached::QDeclarativePackageAttached(QObject *parent)
+: QObject(parent)
+{
+ attached.insert(parent, this);
+}
+
+QDeclarativePackageAttached::~QDeclarativePackageAttached()
+{
+ attached.remove(parent());
+}
+
+QString QDeclarativePackageAttached::name() const
+{
+ return _name;
+}
+
+void QDeclarativePackageAttached::setName(const QString &n)
+{
+ _name = n;
+}
+
+QDeclarativePackage::QDeclarativePackage(QObject *parent)
+ : QObject(*(new QDeclarativePackagePrivate), parent)
+{
+}
+
+QDeclarativePackage::~QDeclarativePackage()
+{
+ Q_D(QDeclarativePackage);
+ for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ QObject *obj = d->dataList.at(ii);
+ obj->setParent(this);
+ }
+}
+
+QDeclarativeListProperty<QObject> QDeclarativePackage::data()
+{
+ Q_D(QDeclarativePackage);
+ return QDeclarativeListProperty<QObject>(this, &d->dataList, QDeclarativePackagePrivate::data_append,
+ QDeclarativePackagePrivate::data_count,
+ QDeclarativePackagePrivate::data_at,
+ QDeclarativePackagePrivate::data_clear);
+}
+
+bool QDeclarativePackage::hasPart(const QString &name)
+{
+ Q_D(QDeclarativePackage);
+ for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ QObject *obj = d->dataList.at(ii);
+ QDeclarativePackageAttached *a = QDeclarativePackageAttached::attached.value(obj);
+ if (a && a->name() == name)
+ return true;
+ }
+ return false;
+}
+
+QObject *QDeclarativePackage::part(const QString &name)
+{
+ Q_D(QDeclarativePackage);
+ if (name.isEmpty() && !d->dataList.isEmpty())
+ return d->dataList.at(0);
+
+ for (int ii = 0; ii < d->dataList.count(); ++ii) {
+ QObject *obj = d->dataList.at(ii);
+ QDeclarativePackageAttached *a = QDeclarativePackageAttached::attached.value(obj);
+ if (a && a->name() == name)
+ return obj;
+ }
+
+ if (name == QLatin1String("default") && !d->dataList.isEmpty())
+ return d->dataList.at(0);
+
+ return 0;
+}
+
+QDeclarativePackageAttached *QDeclarativePackage::qmlAttachedProperties(QObject *o)
+{
+ return new QDeclarativePackageAttached(o);
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativepackage_p.h b/src/declarative/util/qdeclarativepackage_p.h
new file mode 100644
index 0000000000..87d9b80240
--- /dev/null
+++ b/src/declarative/util/qdeclarativepackage_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEPACKAGE_H
+#define QDECLARATIVEPACKAGE_H
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+/*****************************************************************************
+ *****************************************************************************
+ XXX Experimental
+ *****************************************************************************
+*****************************************************************************/
+
+class QDeclarativePackagePrivate;
+class QDeclarativePackageAttached;
+class QDeclarativePackage : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePackage)
+
+ Q_CLASSINFO("DefaultProperty", "data")
+ Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data SCRIPTABLE false)
+
+public:
+ QDeclarativePackage(QObject *parent=0);
+ virtual ~QDeclarativePackage();
+
+ QDeclarativeListProperty<QObject> data();
+
+ QObject *part(const QString & = QString());
+ bool hasPart(const QString &);
+
+ static QDeclarativePackageAttached *qmlAttachedProperties(QObject *);
+};
+
+class QDeclarativePackageAttached : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+public:
+ QDeclarativePackageAttached(QObject *parent);
+ virtual ~QDeclarativePackageAttached();
+
+ QString name() const;
+ void setName(const QString &n);
+
+ static QHash<QObject *, QDeclarativePackageAttached *> attached;
+private:
+ QString _name;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePackage)
+QML_DECLARE_TYPEINFO(QDeclarativePackage, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPACKAGE_H
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
new file mode 100644
index 0000000000..cfb25ddc8d
--- /dev/null
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -0,0 +1,642 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativepixmapcache_p.h"
+#include "qdeclarativenetworkaccessmanagerfactory.h"
+#include "qdeclarativeimageprovider.h"
+
+#include "qfxperf_p_p.h"
+
+#include <qdeclarativeengine.h>
+#include <private/qdeclarativeglobal_p.h>
+#include <private/qdeclarativeengine_p.h>
+
+#include <QCoreApplication>
+#include <QImageReader>
+#include <QHash>
+#include <QNetworkReply>
+#include <QPixmapCache>
+#include <QFile>
+#include <QThread>
+#include <QMutex>
+#include <QWaitCondition>
+#include <QtCore/qdebug.h>
+#include <private/qobject_p.h>
+#include <QSslError>
+
+#ifdef Q_OS_LINUX
+#include <pthread.h>
+#include <linux/sched.h>
+#endif
+
+// Maximum number of simultaneous image requests to send.
+static const int maxImageRequestCount = 8;
+
+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
+
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+class QDeclarativeImageReaderEvent : public QEvent
+{
+public:
+ enum ReadError { NoError, Loading, Decoding };
+
+ QDeclarativeImageReaderEvent(QDeclarativeImageReaderEvent::ReadError err, const QString &errStr, const QImage &img)
+ : QEvent(QEvent::User), error(err), errorString(errStr), image(img) {}
+
+ ReadError error;
+ QString errorString;
+ QImage image;
+};
+
+class QDeclarativeImageRequestHandler;
+class QDeclarativeImageReader : public QThread
+{
+ Q_OBJECT
+public:
+ QDeclarativeImageReader(QDeclarativeEngine *eng);
+ ~QDeclarativeImageReader();
+
+ QDeclarativePixmapReply *getImage(const QUrl &url);
+ void cancel(QDeclarativePixmapReply *rep);
+
+ static QDeclarativeImageReader *instance(QDeclarativeEngine *engine);
+
+protected:
+ void run();
+
+private:
+ QList<QDeclarativePixmapReply*> jobs;
+ QList<QDeclarativePixmapReply*> cancelled;
+ QDeclarativeEngine *engine;
+ QDeclarativeImageRequestHandler *handler;
+ QMutex mutex;
+
+ static QHash<QDeclarativeEngine *,QDeclarativeImageReader*> readers;
+ static QMutex readerMutex;
+ friend class QDeclarativeImageRequestHandler;
+};
+
+QHash<QDeclarativeEngine *,QDeclarativeImageReader*> QDeclarativeImageReader::readers;
+QMutex QDeclarativeImageReader::readerMutex;
+
+
+class QDeclarativeImageRequestHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeImageRequestHandler(QDeclarativeImageReader *read, QDeclarativeEngine *eng)
+ : QObject(), accessManager(0), engine(eng), reader(read)
+ {
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+ }
+
+ QDeclarativePixmapReply *getImage(const QUrl &url);
+ void cancel(QDeclarativePixmapReply *reply);
+
+protected:
+ bool event(QEvent *event);
+
+private slots:
+ void networkRequestDone();
+
+private:
+ QNetworkAccessManager *networkAccessManager() {
+ if (!accessManager)
+ accessManager = QDeclarativeEnginePrivate::get(engine)->createNetworkAccessManager(this);
+ return accessManager;
+ }
+
+ QHash<QNetworkReply*,QDeclarativePixmapReply*> replies;
+ QNetworkAccessManager *accessManager;
+ QDeclarativeEngine *engine;
+ QDeclarativeImageReader *reader;
+};
+
+//===========================================================================
+
+bool QDeclarativeImageRequestHandler::event(QEvent *event)
+{
+ if (event->type() == QEvent::User) {
+ static int replyDownloadProgress = -1;
+ static int replyFinished = -1;
+ static int downloadProgress = -1;
+ static int thisNetworkRequestDone = -1;
+
+ if (replyDownloadProgress == -1) {
+ replyDownloadProgress = QNetworkReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
+ replyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()");
+ downloadProgress = QDeclarativePixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
+ thisNetworkRequestDone = QDeclarativeImageRequestHandler::staticMetaObject.indexOfSlot("networkRequestDone()");
+ }
+
+ while (1) {
+ reader->mutex.lock();
+
+ if (reader->cancelled.count()) {
+ for (int i = 0; i < reader->cancelled.count(); ++i) {
+ QDeclarativePixmapReply *job = reader->cancelled.at(i);
+ // cancel any jobs already started
+ QNetworkReply *reply = replies.key(job, 0);
+ if (reply && reply->isRunning()) {
+ replies.remove(reply);
+ reply->close();
+ }
+ // remove from pending job list
+ for (int j = 0; j < reader->jobs.count(); ++j) {
+ if (reader->jobs.at(j) == job) {
+ reader->jobs.removeAt(j);
+ job->release(true);
+ break;
+ }
+ }
+ }
+ reader->cancelled.clear();
+ }
+
+ if (!reader->jobs.count() || replies.count() > maxImageRequestCount) {
+ reader->mutex.unlock();
+ break;
+ }
+
+ QDeclarativePixmapReply *runningJob = reader->jobs.takeLast();
+ QUrl url = runningJob->url();
+ reader->mutex.unlock();
+
+ // fetch
+ if (url.scheme() == QLatin1String("image")) {
+ // Use QmlImageProvider
+ QImage image = QDeclarativeEnginePrivate::get(engine)->getImageFromProvider(url);
+ QDeclarativeImageReaderEvent::ReadError errorCode = QDeclarativeImageReaderEvent::NoError;
+ QString errorStr;
+ if (image.isNull()) {
+ errorCode = QDeclarativeImageReaderEvent::Loading;
+ errorStr = QLatin1String("Failed to get image from provider: ") + url.toString();
+ }
+ QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image));
+ } else {
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+ // Image is local - load/decode immediately
+ QImage image;
+ QDeclarativeImageReaderEvent::ReadError errorCode = QDeclarativeImageReaderEvent::NoError;
+ QString errorStr;
+ QFile f(lf);
+ if (f.open(QIODevice::ReadOnly)) {
+ QImageReader imgio(&f);
+ if (!imgio.read(&image)) {
+ errorStr = QLatin1String("Error decoding: ") + url.toString()
+ + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\"");
+ errorCode = QDeclarativeImageReaderEvent::Loading;
+ }
+ } else {
+ errorStr = QLatin1String("Cannot open: ") + url.toString();
+ errorCode = QDeclarativeImageReaderEvent::Loading;
+ }
+ QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image));
+ } else {
+ // Network resource
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ QNetworkReply *reply = networkAccessManager()->get(req);
+
+ QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
+ QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
+
+ replies.insert(reply, runningJob);
+ }
+ }
+ }
+ return true;
+ }
+
+ return QObject::event(event);
+}
+
+void QDeclarativeImageRequestHandler::networkRequestDone()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+ QDeclarativePixmapReply *job = replies.take(reply);
+ if (job) {
+ QImage image;
+ QDeclarativeImageReaderEvent::ReadError error;
+ QString errorString;
+ if (reply->error()) {
+ error = QDeclarativeImageReaderEvent::Loading;
+ errorString = reply->errorString();
+ } else {
+ QImageReader imgio(reply);
+ if (imgio.read(&image)) {
+ error = QDeclarativeImageReaderEvent::NoError;
+ } else {
+ errorString = QLatin1String("Error decoding: ") + reply->url().toString()
+ + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\"");
+ error = QDeclarativeImageReaderEvent::Decoding;
+ }
+ }
+ // send completion event to the QDeclarativePixmapReply
+ QCoreApplication::postEvent(job, new QDeclarativeImageReaderEvent(error, errorString, image));
+ }
+ // kick off event loop again if we have dropped below max request count
+ if (replies.count() == maxImageRequestCount)
+ QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+ reply->deleteLater();
+}
+
+//===========================================================================
+
+QDeclarativeImageReader::QDeclarativeImageReader(QDeclarativeEngine *eng)
+ : QThread(eng), engine(eng), handler(0)
+{
+ start(QThread::LowPriority);
+}
+
+QDeclarativeImageReader::~QDeclarativeImageReader()
+{
+ readerMutex.lock();
+ readers.remove(engine);
+ readerMutex.unlock();
+
+ quit();
+ wait();
+}
+
+QDeclarativeImageReader *QDeclarativeImageReader::instance(QDeclarativeEngine *engine)
+{
+ readerMutex.lock();
+ QDeclarativeImageReader *reader = readers.value(engine);
+ if (!reader) {
+ reader = new QDeclarativeImageReader(engine);
+ readers.insert(engine, reader);
+ }
+ readerMutex.unlock();
+
+ return reader;
+}
+
+QDeclarativePixmapReply *QDeclarativeImageReader::getImage(const QUrl &url)
+{
+ mutex.lock();
+ QDeclarativePixmapReply *reply = new QDeclarativePixmapReply(this, url);
+ reply->addRef();
+ reply->setLoading();
+ jobs.append(reply);
+ if (jobs.count() == 1 && handler)
+ QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
+ mutex.unlock();
+ return reply;
+}
+
+void QDeclarativeImageReader::cancel(QDeclarativePixmapReply *reply)
+{
+ mutex.lock();
+ if (reply->isLoading()) {
+ // Add to cancel list to be cancelled in reader thread.
+ cancelled.append(reply);
+ if (cancelled.count() == 1 && handler)
+ QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
+ }
+ mutex.unlock();
+}
+
+void QDeclarativeImageReader::run()
+{
+#if defined(Q_OS_LINUX) && defined(SCHED_IDLE)
+ struct sched_param param;
+ int policy;
+
+ pthread_getschedparam(pthread_self(), &policy, &param);
+ pthread_setschedparam(pthread_self(), SCHED_IDLE, &param);
+#endif
+
+ handler = new QDeclarativeImageRequestHandler(this, engine);
+
+ exec();
+
+ delete handler;
+ handler = 0;
+}
+
+//===========================================================================
+
+static bool readImage(QIODevice *dev, QPixmap *pixmap, QString &errorString)
+{
+ QImageReader imgio(dev);
+
+//#define QT_TEST_SCALED_SIZE
+#ifdef QT_TEST_SCALED_SIZE
+ /*
+ Some mechanism is needed for loading images at a limited size, especially
+ for remote images. Loading only thumbnails of remote progressive JPEG
+ images can be efficient. (Qt jpeg handler does not do so currently)
+ */
+
+ QSize limit(60,60);
+ QSize sz = imgio.size();
+ if (sz.width() > limit.width() || sz.height() > limit.height()) {
+ sz.scale(limit,Qt::KeepAspectRatio);
+ imgio.setScaledSize(sz);
+ }
+#endif
+
+ QImage img;
+ if (imgio.read(&img)) {
+#ifdef QT_TEST_SCALED_SIZE
+ if (!sz.isValid())
+ img = img.scaled(limit,Qt::KeepAspectRatio);
+#endif
+ *pixmap = QPixmap::fromImage(img);
+ return true;
+ } else {
+ errorString = imgio.errorString();
+ return false;
+ }
+}
+
+/*!
+ \internal
+ \class QDeclarativePixmapCache
+ \brief Enacapsultes a pixmap for QDeclarativeGraphics items.
+
+ This class is NOT reentrant.
+ */
+
+typedef QHash<QUrl, QDeclarativePixmapReply *> QDeclarativePixmapReplyHash;
+Q_GLOBAL_STATIC(QDeclarativePixmapReplyHash, qmlActivePixmapReplies);
+
+class QDeclarativePixmapReplyPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePixmapReply)
+
+public:
+ QDeclarativePixmapReplyPrivate(QDeclarativeImageReader *r, const QUrl &u)
+ : QObjectPrivate(), refCount(1), url(u), status(QDeclarativePixmapReply::Loading), loading(false), reader(r) {
+ }
+
+ int refCount;
+ QUrl url;
+ QPixmap pixmap; // ensure reference to pixmap so QPixmapCache does not discard
+ QDeclarativePixmapReply::Status status;
+ bool loading;
+ QDeclarativeImageReader *reader;
+};
+
+
+QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url)
+ : QObject(*new QDeclarativePixmapReplyPrivate(reader, url), 0)
+{
+}
+
+QDeclarativePixmapReply::~QDeclarativePixmapReply()
+{
+}
+
+const QUrl &QDeclarativePixmapReply::url() const
+{
+ Q_D(const QDeclarativePixmapReply);
+ return d->url;
+}
+
+bool QDeclarativePixmapReply::event(QEvent *event)
+{
+ Q_D(QDeclarativePixmapReply);
+ if (event->type() == QEvent::User) {
+ d->loading = false;
+ if (!release(true)) {
+ QDeclarativeImageReaderEvent *de = static_cast<QDeclarativeImageReaderEvent*>(event);
+ d->status = (de->error == QDeclarativeImageReaderEvent::NoError) ? Ready : Error;
+ if (d->status == Ready)
+ d->pixmap = QPixmap::fromImage(de->image);
+ else
+ qWarning() << de->errorString;
+ QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100));
+ QString strKey = QString::fromLatin1(key.constData(), key.count());
+ QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false)
+ emit finished();
+ }
+ return true;
+ }
+
+ return QObject::event(event);
+}
+
+QDeclarativePixmapReply::Status QDeclarativePixmapReply::status() const
+{
+ Q_D(const QDeclarativePixmapReply);
+ return d->status;
+}
+
+bool QDeclarativePixmapReply::isLoading() const
+{
+ Q_D(const QDeclarativePixmapReply);
+ return d->loading;
+}
+
+void QDeclarativePixmapReply::setLoading()
+{
+ Q_D(QDeclarativePixmapReply);
+ d->loading = true;
+}
+
+void QDeclarativePixmapReply::addRef()
+{
+ Q_D(QDeclarativePixmapReply);
+ ++d->refCount;
+}
+
+bool QDeclarativePixmapReply::release(bool defer)
+{
+ Q_D(QDeclarativePixmapReply);
+ Q_ASSERT(d->refCount > 0);
+ --d->refCount;
+ if (d->refCount == 0) {
+ qmlActivePixmapReplies()->remove(d->url);
+ if (defer)
+ deleteLater();
+ else
+ delete this;
+ return true;
+ } else if (d->refCount == 1 && d->loading) {
+ // The only reference left is the reader thread.
+ qmlActivePixmapReplies()->remove(d->url);
+ d->reader->cancel(this);
+ }
+
+ return false;
+}
+
+/*!
+ Finds the cached pixmap corresponding to \a url.
+ If the image is a network resource and has not yet
+ been retrieved and cached, request() must be called.
+
+ Returns Ready, or Error if the image has been retrieved,
+ otherwise the current retrieval status.
+
+ If \a async is false the image will be loaded and decoded immediately;
+ otherwise the image will be loaded and decoded in a separate thread.
+
+ Note that images sourced from the network will always be loaded and
+ decoded asynchonously.
+*/
+QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, bool async)
+{
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested;
+ QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100));
+ QString strKey = QString::fromLatin1(key.constData(), key.count());
+
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+ if (!async) {
+ QString lf = toLocalFileOrQrc(url);
+ if (!lf.isEmpty()) {
+ status = QDeclarativePixmapReply::Ready;
+ if (!QPixmapCache::find(strKey,pixmap)) {
+ QFile f(lf);
+ if (f.open(QIODevice::ReadOnly)) {
+ QString errorString;
+ if (!readImage(&f, pixmap, errorString)) {
+ errorString = QLatin1String("Error decoding: ") + url.toString()
+ + QLatin1String(" \"") + errorString + QLatin1String("\"");
+ qWarning() << errorString;
+ *pixmap = QPixmap();
+ status = QDeclarativePixmapReply::Error;
+ }
+ } else {
+ qWarning() << "Cannot open" << url;
+ *pixmap = QPixmap();
+ status = QDeclarativePixmapReply::Error;
+ }
+ if (status == QDeclarativePixmapReply::Ready)
+ QPixmapCache::insert(strKey, *pixmap);
+ }
+ return status;
+ }
+ }
+#endif
+
+ QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url);
+ if (iter != qmlActivePixmapReplies()->end() && (*iter)->status() == QDeclarativePixmapReply::Ready) {
+ // Must check this, since QPixmapCache::insert may have failed.
+ *pixmap = (*iter)->d_func()->pixmap;
+ status = (*iter)->status();
+ (*iter)->release();
+ } else if (QPixmapCache::find(strKey, pixmap)) {
+ if (iter != qmlActivePixmapReplies()->end()) {
+ status = (*iter)->status();
+ (*iter)->release();
+ } else {
+ status = pixmap->isNull() ? QDeclarativePixmapReply::Error : QDeclarativePixmapReply::Ready;
+ }
+ } else if (iter != qmlActivePixmapReplies()->end()) {
+ status = QDeclarativePixmapReply::Loading;
+ }
+
+ return status;
+}
+
+/*!
+ Starts a network request to load \a url.
+
+ Returns a QDeclarativePixmapReply. Caller should connect to QDeclarativePixmapReply::finished()
+ and call get() when the image is available.
+
+ The returned QDeclarativePixmapReply will be deleted when all request() calls are
+ matched by a corresponding get() call.
+*/
+QDeclarativePixmapReply *QDeclarativePixmapCache::request(QDeclarativeEngine *engine, const QUrl &url)
+{
+ QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url);
+ if (iter == qmlActivePixmapReplies()->end()) {
+ QDeclarativeImageReader *reader = QDeclarativeImageReader::instance(engine);
+ QDeclarativePixmapReply *item = reader->getImage(url);
+ iter = qmlActivePixmapReplies()->insert(url, item);
+ } else {
+ (*iter)->addRef();
+ }
+
+ return (*iter);
+}
+
+/*!
+ Cancels a previous call to request().
+
+ May also cancel loading (eg. if no other pending request).
+
+ Any connections from the QDeclarativePixmapReply returned by request() to \a obj will be
+ disconnected.
+*/
+void QDeclarativePixmapCache::cancel(const QUrl& url, QObject *obj)
+{
+ QDeclarativePixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url);
+ if (iter == qmlActivePixmapReplies()->end())
+ return;
+
+ QDeclarativePixmapReply *reply = *iter;
+ if (obj)
+ QObject::disconnect(reply, 0, obj, 0);
+ reply->release();
+}
+
+/*!
+ This function is mainly for test verification. It returns the number of
+ requests that are still unfinished.
+*/
+int QDeclarativePixmapCache::pendingRequests()
+{
+ return qmlActivePixmapReplies()->count();
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativepixmapcache.moc>
diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h
new file mode 100644
index 0000000000..b8949db9c4
--- /dev/null
+++ b/src/declarative/util/qdeclarativepixmapcache_p.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 QDECLARATIVEPIXMAPCACHE_H
+#define QDECLARATIVEPIXMAPCACHE_H
+
+#include <QtCore/QString>
+#include <QtGui/QPixmap>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+class QDeclarativeEngine;
+class QNetworkReply;
+class QDeclarativeImageReader;
+
+class QDeclarativePixmapReplyPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativePixmapReply : public QObject
+{
+ Q_OBJECT
+public:
+ ~QDeclarativePixmapReply();
+
+ enum Status { Ready, Error, Unrequested, Loading };
+ Status status() const;
+
+ const QUrl &url() const;
+
+Q_SIGNALS:
+ void finished();
+ void downloadProgress(qint64, qint64);
+
+protected:
+ bool event(QEvent *event);
+
+private:
+ void addRef();
+ bool release(bool defer=false);
+ bool isLoading() const;
+ void setLoading();
+
+private:
+ QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url);
+ Q_DISABLE_COPY(QDeclarativePixmapReply)
+ Q_DECLARE_PRIVATE(QDeclarativePixmapReply)
+ friend class QDeclarativeImageRequestHandler;
+ friend class QDeclarativeImageReader;
+ friend class QDeclarativePixmapCache;
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache
+{
+public:
+ static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, bool async=false);
+ static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url);
+ static void cancel(const QUrl& url, QObject *obj);
+ static int pendingRequests();
+};
+
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPIXMAPCACHE_H
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
new file mode 100644
index 0000000000..9c2b1e691f
--- /dev/null
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -0,0 +1,486 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativepropertychanges_p.h"
+
+#include "qdeclarativeopenmetaobject_p.h"
+
+#include <qdeclarativeinfo.h>
+#include <qdeclarativecustomparser_p.h>
+#include <qdeclarativeparser_p.h>
+#include <qdeclarativeexpression.h>
+#include <qdeclarativebinding_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeguard_p.h>
+#include <qdeclarativeproperty_p.h>
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass PropertyChanges QDeclarativePropertyChanges
+ \since 4.7
+ \brief The PropertyChanges element describes new property values for a state.
+
+ PropertyChanges provides a state change that modifies the properties of an item.
+
+ Here is a property change that modifies the text and color of a Text element
+ when it is clicked:
+
+ \qml
+ Text {
+ id: myText
+ width: 100; height: 100
+ text: "Hello"
+ color: "blue"
+
+ states: State {
+ name: "myState"
+
+ PropertyChanges {
+ target: myText
+ text: "Goodbye"
+ color: "red"
+ }
+ }
+
+ MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
+ }
+ \endqml
+
+ State-specific script for signal handlers can also be specified:
+
+ \qml
+ PropertyChanges {
+ target: myMouseArea
+ onClicked: doSomethingDifferent()
+ }
+ \endqml
+
+ You can reset a property in a state change by assigning \c undefined. In the following
+ example we reset \c theText's width when we enter state1. This will give the text its
+ natural width (which is the whole string on one line).
+
+ \qml
+ import Qt 4.6
+
+ Rectangle {
+ width: 640
+ height: 480
+ Text {
+ id: theText
+ width: 50
+ wrap: true
+ text: "a text string that is longer than 50 pixels"
+ }
+
+ states: State {
+ name: "state1"
+ PropertyChanges {
+ target: theText
+ width: undefined
+ }
+ }
+ }
+ \endqml
+
+ Changes to an Item's parent or anchors should be done using the associated change elements
+ (ParentChange and AnchorChanges, respectively) rather than PropertyChanges.
+
+ \sa {qmlstate}{States}
+*/
+
+/*!
+ \internal
+ \class QDeclarativePropertyChanges
+ \brief The QDeclarativePropertyChanges class describes new property values for a state.
+*/
+
+/*!
+ \qmlproperty Object PropertyChanges::target
+ This property holds the object which contains the properties to be changed.
+*/
+
+class QDeclarativeReplaceSignalHandler : public QDeclarativeActionEvent
+{
+public:
+ QDeclarativeReplaceSignalHandler() : expression(0), reverseExpression(0),
+ rewindExpression(0), ownedExpression(0) {}
+ ~QDeclarativeReplaceSignalHandler() {
+ delete ownedExpression;
+ }
+
+ virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); }
+
+ QDeclarativeProperty property;
+ QDeclarativeExpression *expression;
+ QDeclarativeExpression *reverseExpression;
+ QDeclarativeExpression *rewindExpression;
+ QDeclarativeGuard<QDeclarativeExpression> ownedExpression;
+
+ virtual void execute() {
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression);
+ }
+
+ virtual bool isReversable() { return true; }
+ virtual void reverse() {
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
+ }
+
+ virtual void saveOriginals() {
+ saveCurrentValues();
+ reverseExpression = rewindExpression;
+ }
+
+ virtual void rewind() {
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
+ }
+ virtual void saveCurrentValues() {
+ rewindExpression = QDeclarativePropertyPrivate::signalExpression(property);
+ }
+
+ virtual bool override(QDeclarativeActionEvent*other) {
+ if (other == this)
+ return true;
+ if (other->typeName() != typeName())
+ return false;
+ if (static_cast<QDeclarativeReplaceSignalHandler*>(other)->property == property)
+ return true;
+ return false;
+ }
+};
+
+
+class QDeclarativePropertyChangesPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePropertyChanges)
+public:
+ QDeclarativePropertyChangesPrivate() : object(0), decoded(true), restore(true),
+ isExplicit(false) {}
+
+ QObject *object;
+ QByteArray data;
+
+ bool decoded : 1;
+ bool restore : 1;
+ bool isExplicit : 1;
+
+ void decode();
+
+ QList<QPair<QByteArray, QVariant> > properties;
+ QList<QPair<QByteArray, QDeclarativeExpression *> > expressions;
+ QList<QDeclarativeReplaceSignalHandler*> signalReplacements;
+
+ QDeclarativeProperty property(const QByteArray &);
+};
+
+void
+QDeclarativePropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
+ const QByteArray &pre,
+ const QDeclarativeCustomParserProperty &prop)
+{
+ QByteArray propName = pre + prop.name();
+
+ QList<QVariant> values = prop.assignedValues();
+ for (int ii = 0; ii < values.count(); ++ii) {
+ const QVariant &value = values.at(ii);
+
+ if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
+ continue;
+ } else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
+
+ QDeclarativeCustomParserProperty prop =
+ qvariant_cast<QDeclarativeCustomParserProperty>(value);
+ QByteArray pre = propName + '.';
+ compileList(list, pre, prop);
+
+ } else {
+ list << qMakePair(propName, value);
+ }
+ }
+}
+
+QByteArray
+QDeclarativePropertyChangesParser::compile(const QList<QDeclarativeCustomParserProperty> &props)
+{
+ QList<QPair<QByteArray, QVariant> > data;
+ for(int ii = 0; ii < props.count(); ++ii)
+ compileList(data, QByteArray(), props.at(ii));
+
+ QByteArray rv;
+ QDataStream ds(&rv, QIODevice::WriteOnly);
+
+ ds << data.count();
+ for(int ii = 0; ii < data.count(); ++ii) {
+ QDeclarativeParser::Variant v = qvariant_cast<QDeclarativeParser::Variant>(data.at(ii).second);
+ QVariant var;
+ bool isScript = v.isScript();
+ switch(v.type()) {
+ case QDeclarativeParser::Variant::Boolean:
+ var = QVariant(v.asBoolean());
+ break;
+ case QDeclarativeParser::Variant::Number:
+ var = QVariant(v.asNumber());
+ break;
+ case QDeclarativeParser::Variant::String:
+ var = QVariant(v.asString());
+ break;
+ case QDeclarativeParser::Variant::Invalid:
+ case QDeclarativeParser::Variant::Script:
+ var = QVariant(v.asScript());
+ break;
+ }
+
+ ds << data.at(ii).first << isScript << var;
+ }
+
+ return rv;
+}
+
+void QDeclarativePropertyChangesPrivate::decode()
+{
+ Q_Q(QDeclarativePropertyChanges);
+ if (decoded)
+ return;
+
+ QDataStream ds(&data, QIODevice::ReadOnly);
+
+ int count;
+ ds >> count;
+ for (int ii = 0; ii < count; ++ii) {
+ QByteArray name;
+ bool isScript;
+ QVariant data;
+ ds >> name;
+ ds >> isScript;
+ ds >> data;
+
+ QDeclarativeProperty prop = property(name); //### better way to check for signal property?
+ if (prop.type() & QDeclarativeProperty::SignalProperty) {
+ QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object);
+ QDeclarativeReplaceSignalHandler *handler = new QDeclarativeReplaceSignalHandler;
+ handler->property = prop;
+ handler->expression = expression;
+ signalReplacements << handler;
+ } else if (isScript) {
+ QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object);
+ expressions << qMakePair(name, expression);
+ } else {
+ properties << qMakePair(name, data);
+ }
+ }
+
+ decoded = true;
+ data.clear();
+}
+
+void QDeclarativePropertyChangesParser::setCustomData(QObject *object,
+ const QByteArray &data)
+{
+ QDeclarativePropertyChangesPrivate *p =
+ static_cast<QDeclarativePropertyChangesPrivate *>(QObjectPrivate::get(object));
+ p->data = data;
+ p->decoded = false;
+}
+
+QDeclarativePropertyChanges::QDeclarativePropertyChanges()
+: QDeclarativeStateOperation(*(new QDeclarativePropertyChangesPrivate))
+{
+}
+
+QDeclarativePropertyChanges::~QDeclarativePropertyChanges()
+{
+ Q_D(QDeclarativePropertyChanges);
+ for(int ii = 0; ii < d->expressions.count(); ++ii)
+ delete d->expressions.at(ii).second;
+ for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
+ delete d->signalReplacements.at(ii);
+}
+
+QObject *QDeclarativePropertyChanges::object() const
+{
+ Q_D(const QDeclarativePropertyChanges);
+ return d->object;
+}
+
+void QDeclarativePropertyChanges::setObject(QObject *o)
+{
+ Q_D(QDeclarativePropertyChanges);
+ d->object = o;
+}
+
+/*!
+ \qmlproperty bool PropertyChanges::restoreEntryValues
+
+ Whether or not the previous values should be restored when
+ leaving the state. By default, restoreEntryValues is true.
+
+ By setting restoreEntryValues to false, you can create a temporary state
+ that has permanent effects on property values.
+*/
+bool QDeclarativePropertyChanges::restoreEntryValues() const
+{
+ Q_D(const QDeclarativePropertyChanges);
+ return d->restore;
+}
+
+void QDeclarativePropertyChanges::setRestoreEntryValues(bool v)
+{
+ Q_D(QDeclarativePropertyChanges);
+ d->restore = v;
+}
+
+QDeclarativeProperty
+QDeclarativePropertyChangesPrivate::property(const QByteArray &property)
+{
+ Q_Q(QDeclarativePropertyChanges);
+ QDeclarativeProperty prop(object, QString::fromUtf8(property));
+ if (!prop.isValid()) {
+ qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property));
+ return QDeclarativeProperty();
+ } else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) {
+ qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property));
+ return QDeclarativeProperty();
+ }
+ return prop;
+}
+
+QDeclarativePropertyChanges::ActionList QDeclarativePropertyChanges::actions()
+{
+ Q_D(QDeclarativePropertyChanges);
+
+ d->decode();
+
+ ActionList list;
+
+ for (int ii = 0; ii < d->properties.count(); ++ii) {
+
+ QByteArray property = d->properties.at(ii).first;
+
+ QDeclarativeAction a(d->object, QString::fromLatin1(property),
+ d->properties.at(ii).second);
+
+ if (a.property.isValid()) {
+ a.restore = restoreEntryValues();
+
+ if (a.property.propertyType() == QVariant::Url &&
+ (a.toValue.userType() == QVariant::String || a.toValue.userType() == QVariant::ByteArray) && !a.toValue.isNull())
+ a.toValue.setValue(qmlContext(this)->resolvedUrl(QUrl(a.toValue.toString())));
+
+ list << a;
+ }
+ }
+
+ for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
+
+ QDeclarativeReplaceSignalHandler *handler = d->signalReplacements.at(ii);
+
+ if (handler->property.isValid()) {
+ QDeclarativeAction a;
+ a.event = handler;
+ list << a;
+ }
+ }
+
+ for (int ii = 0; ii < d->expressions.count(); ++ii) {
+
+ QByteArray property = d->expressions.at(ii).first;
+ QDeclarativeProperty prop = d->property(property);
+
+ if (prop.isValid()) {
+ QDeclarativeAction a;
+ a.restore = restoreEntryValues();
+ a.property = prop;
+ a.fromValue = a.property.read();
+ a.specifiedObject = d->object;
+ a.specifiedProperty = QString::fromLatin1(property);
+
+ if (d->isExplicit) {
+ a.toValue = d->expressions.at(ii).second->value();
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this));
+ newBinding->setTarget(prop);
+ a.toBinding = newBinding;
+ a.deletableToBinding = true;
+ }
+
+ list << a;
+ }
+ }
+
+ return list;
+}
+
+/*!
+ \qmlproperty bool PropertyChanges::explicit
+
+ If explicit is set to true, any potential bindings will be interpreted as
+ once-off assignments that occur when the state is entered.
+
+ In the following example, the addition of explicit prevents myItem.width from
+ being bound to parent.width. Instead, it is assigned the value of parent.width
+ at the time of the state change.
+ \qml
+ PropertyChanges {
+ target: myItem
+ explicit: true
+ width: parent.width
+ }
+ \endqml
+
+ By default, explicit is false.
+*/
+bool QDeclarativePropertyChanges::isExplicit() const
+{
+ Q_D(const QDeclarativePropertyChanges);
+ return d->isExplicit;
+}
+
+void QDeclarativePropertyChanges::setIsExplicit(bool e)
+{
+ Q_D(QDeclarativePropertyChanges);
+ d->isExplicit = e;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativepropertychanges_p.h b/src/declarative/util/qdeclarativepropertychanges_p.h
new file mode 100644
index 0000000000..1274b0ca68
--- /dev/null
+++ b/src/declarative/util/qdeclarativepropertychanges_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 QDECLARATIVEPROPERTYCHANGES_H
+#define QDECLARATIVEPROPERTYCHANGES_H
+
+#include "qdeclarativestateoperations_p.h"
+#include <private/qdeclarativecustomparser_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativePropertyChangesPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyChanges : public QDeclarativeStateOperation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativePropertyChanges)
+
+ Q_PROPERTY(QObject *target READ object WRITE setObject)
+ Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
+ Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
+public:
+ QDeclarativePropertyChanges();
+ ~QDeclarativePropertyChanges();
+
+ QObject *object() const;
+ void setObject(QObject *);
+
+ bool restoreEntryValues() const;
+ void setRestoreEntryValues(bool);
+
+ bool isExplicit() const;
+ void setIsExplicit(bool);
+
+ virtual ActionList actions();
+};
+
+class QDeclarativePropertyChangesParser : public QDeclarativeCustomParser
+{
+public:
+ void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop);
+
+ virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
+ virtual void setCustomData(QObject *, const QByteArray &);
+};
+
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativePropertyChanges)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEPROPERTYCHANGES_H
diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp
new file mode 100644
index 0000000000..fcea515769
--- /dev/null
+++ b/src/declarative/util/qdeclarativepropertymap.cpp
@@ -0,0 +1,279 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativepropertymap.h"
+
+#include "qdeclarativeopenmetaobject_p.h"
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+//QDeclarativePropertyMapMetaObject lets us listen for changes coming from QML
+//so we can emit the changed signal.
+class QDeclarativePropertyMapMetaObject : public QDeclarativeOpenMetaObject
+{
+public:
+ QDeclarativePropertyMapMetaObject(QDeclarativePropertyMap *obj, QDeclarativePropertyMapPrivate *objPriv);
+
+protected:
+ virtual void propertyWrite(int index);
+
+private:
+ QDeclarativePropertyMap *map;
+ QDeclarativePropertyMapPrivate *priv;
+};
+
+class QDeclarativePropertyMapPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativePropertyMap)
+public:
+ QDeclarativePropertyMapMetaObject *mo;
+ QStringList keys;
+ void emitChanged(const QString &key);
+};
+
+void QDeclarativePropertyMapPrivate::emitChanged(const QString &key)
+{
+ Q_Q(QDeclarativePropertyMap);
+ emit q->valueChanged(key);
+}
+
+QDeclarativePropertyMapMetaObject::QDeclarativePropertyMapMetaObject(QDeclarativePropertyMap *obj, QDeclarativePropertyMapPrivate *objPriv) : QDeclarativeOpenMetaObject(obj)
+{
+ map = obj;
+ priv = objPriv;
+}
+
+void QDeclarativePropertyMapMetaObject::propertyWrite(int index)
+{
+ priv->emitChanged(QString::fromUtf8(name(index)));
+}
+
+/*!
+ \class QDeclarativePropertyMap
+ \since 4.7
+ \brief The QDeclarativePropertyMap class allows you to set key-value pairs that can be used in bindings.
+
+ QDeclarativePropertyMap provides a convenient way to expose domain data to the UI layer.
+ The following example shows how you might declare data in C++ and then
+ access it in QML.
+
+ Setup in C++:
+ \code
+ //create our data
+ QDeclarativePropertyMap ownerData;
+ ownerData.insert("name", QVariant(QString("John Smith")));
+ ownerData.insert("phone", QVariant(QString("555-5555")));
+
+ //expose it to the UI layer
+ QDeclarativeContext *ctxt = view->bindContext();
+ ctxt->setProperty("owner", &data);
+ \endcode
+
+ Then, in QML:
+ \code
+ Text { text: owner.name }
+ Text { text: owner.phone }
+ \endcode
+
+ The binding is dynamic - whenever a key's value is updated, anything bound to that
+ key will be updated as well.
+
+ To detect value changes made in the UI layer you can connect to the valueChanged() signal.
+ However, note that valueChanged() is \bold NOT emitted when changes are made by calling insert()
+ or clear() - it is only emitted when a value is updated from QML.
+
+ \note It is not possible to remove keys from the map; once a key has been added, you can only
+ modify or clear its associated value.
+*/
+
+/*!
+ Constructs a bindable map with parent object \a parent.
+*/
+QDeclarativePropertyMap::QDeclarativePropertyMap(QObject *parent)
+: QObject(*(new QDeclarativePropertyMapPrivate), parent)
+{
+ Q_D(QDeclarativePropertyMap);
+ d->mo = new QDeclarativePropertyMapMetaObject(this, d);
+}
+
+/*!
+ Destroys the bindable map.
+*/
+QDeclarativePropertyMap::~QDeclarativePropertyMap()
+{
+}
+
+/*!
+ Clears the value (if any) associated with \a key.
+*/
+void QDeclarativePropertyMap::clear(const QString &key)
+{
+ Q_D(QDeclarativePropertyMap);
+ d->mo->setValue(key.toUtf8(), QVariant());
+}
+
+/*!
+ Returns the value associated with \a key.
+
+ If no value has been set for this key (or if the value has been cleared),
+ an invalid QVariant is returned.
+*/
+QVariant QDeclarativePropertyMap::value(const QString &key) const
+{
+ Q_D(const QDeclarativePropertyMap);
+ return d->mo->value(key.toUtf8());
+}
+
+/*!
+ Sets the value associated with \a key to \a value.
+
+ If the key doesn't exist, it is automatically created.
+*/
+void QDeclarativePropertyMap::insert(const QString &key, const QVariant &value)
+{
+ Q_D(QDeclarativePropertyMap);
+ if (!d->keys.contains(key))
+ d->keys.append(key);
+ d->mo->setValue(key.toUtf8(), value);
+}
+
+/*!
+ Returns the list of keys.
+
+ Keys that have been cleared will still appear in this list, even though their
+ associated values are invalid QVariants.
+*/
+QStringList QDeclarativePropertyMap::keys() const
+{
+ Q_D(const QDeclarativePropertyMap);
+ return d->keys;
+}
+
+/*!
+ \overload
+
+ Same as size().
+*/
+int QDeclarativePropertyMap::count() const
+{
+ Q_D(const QDeclarativePropertyMap);
+ return d->keys.count();
+}
+
+/*!
+ Returns the number of keys in the map.
+
+ \sa isEmpty(), count()
+*/
+int QDeclarativePropertyMap::size() const
+{
+ Q_D(const QDeclarativePropertyMap);
+ return d->keys.size();
+}
+
+/*!
+ Returns true if the map contains no keys; otherwise returns
+ false.
+
+ \sa size()
+*/
+bool QDeclarativePropertyMap::isEmpty() const
+{
+ Q_D(const QDeclarativePropertyMap);
+ return d->keys.isEmpty();
+}
+
+/*!
+ Returns true if the map contains \a key.
+
+ \sa size()
+*/
+bool QDeclarativePropertyMap::contains(const QString &key) const
+{
+ Q_D(const QDeclarativePropertyMap);
+ return d->keys.contains(key);
+}
+
+/*!
+ Returns the value associated with the key \a key as a modifiable
+ reference.
+
+ If the map contains no item with key \a key, the function inserts
+ an invalid QVariant into the map with key \a key, and
+ returns a reference to it.
+
+ \sa insert(), value()
+*/
+QVariant &QDeclarativePropertyMap::operator[](const QString &key)
+{
+ //### optimize
+ Q_D(QDeclarativePropertyMap);
+ QByteArray utf8key = key.toUtf8();
+ if (!d->keys.contains(key)) {
+ d->keys.append(key);
+ d->mo->setValue(utf8key, QVariant()); //force creation -- needed below
+ }
+
+ return (*(d->mo))[utf8key];
+}
+
+/*!
+ \overload
+
+ Same as value().
+*/
+const QVariant QDeclarativePropertyMap::operator[](const QString &key) const
+{
+ return value(key);
+}
+
+/*!
+ \fn void QDeclarativePropertyMap::valueChanged(const QString &key)
+ This signal is emitted whenever one of the values in the map is changed. \a key
+ is the key corresponding to the value that was changed.
+
+ \note valueChanged() is \bold NOT emitted when changes are made by calling insert()
+ or clear() - it is only emitted when a value is updated from QML.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativepropertymap.h b/src/declarative/util/qdeclarativepropertymap.h
new file mode 100644
index 0000000000..513089f120
--- /dev/null
+++ b/src/declarative/util/qdeclarativepropertymap.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 QDECLARATIVEPROPERTYMAP_H
+#define QDECLARATIVEPROPERTYMAP_H
+
+#include <QtCore/QObject>
+#include <QtCore/QHash>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativePropertyMapPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyMap : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativePropertyMap(QObject *parent = 0);
+ virtual ~QDeclarativePropertyMap();
+
+ QVariant value(const QString &key) const;
+ void insert(const QString &key, const QVariant &value);
+ void clear(const QString &key);
+
+ Q_INVOKABLE QStringList keys() const;
+
+ int count() const;
+ int size() const;
+ bool isEmpty() const;
+ bool contains(const QString &key) const;
+
+ QVariant &operator[](const QString &key);
+ const QVariant operator[](const QString &key) const;
+
+Q_SIGNALS:
+ void valueChanged(const QString &key);
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativePropertyMap)
+ Q_DISABLE_COPY(QDeclarativePropertyMap)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
new file mode 100644
index 0000000000..6205ab9ec2
--- /dev/null
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -0,0 +1,465 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativespringfollow_p.h"
+
+#include "qdeclarativeanimation_p_p.h"
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+#include <limits.h>
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+class QDeclarativeSpringFollowPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeSpringFollow)
+public:
+ QDeclarativeSpringFollowPrivate()
+ : currentValue(0), sourceValue(0), maxVelocity(0), lastTime(0)
+ , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01)
+ , modulus(0.0), useMass(false), haveModulus(false), enabled(true), mode(Track), clock(this) {}
+
+ QDeclarativeProperty property;
+ qreal currentValue;
+ qreal sourceValue;
+ qreal maxVelocity;
+ qreal velocityms;
+ int lastTime;
+ qreal mass;
+ qreal spring;
+ qreal damping;
+ qreal velocity;
+ qreal epsilon;
+ qreal modulus;
+
+ bool useMass : 1;
+ bool haveModulus : 1;
+ bool enabled : 1;
+
+ enum Mode {
+ Track,
+ Velocity,
+ Spring
+ };
+ Mode mode;
+
+ void tick(int);
+ void updateMode();
+ void start();
+ void stop();
+
+ QTickAnimationProxy<QDeclarativeSpringFollowPrivate, &QDeclarativeSpringFollowPrivate::tick> clock;
+};
+
+void QDeclarativeSpringFollowPrivate::tick(int time)
+{
+ Q_Q(QDeclarativeSpringFollow);
+
+ int elapsed = time - lastTime;
+ if (!elapsed)
+ return;
+ qreal srcVal = sourceValue;
+ if (haveModulus) {
+ currentValue = fmod(currentValue, modulus);
+ srcVal = fmod(srcVal, modulus);
+ }
+ if (mode == Spring) {
+ if (elapsed < 16) // capped at 62fps.
+ return;
+ // Real men solve the spring DEs using RK4.
+ // We'll do something much simpler which gives a result that looks fine.
+ int count = elapsed / 16;
+ for (int i = 0; i < count; ++i) {
+ qreal diff = srcVal - currentValue;
+ if (haveModulus && qAbs(diff) > modulus / 2) {
+ if (diff < 0)
+ diff += modulus;
+ else
+ diff -= modulus;
+ }
+ if (useMass)
+ velocity = velocity + (spring * diff - damping * velocity) / mass;
+ else
+ velocity = velocity + spring * diff - damping * velocity;
+ if (maxVelocity > 0.) {
+ // limit velocity
+ if (velocity > maxVelocity)
+ velocity = maxVelocity;
+ else if (velocity < -maxVelocity)
+ velocity = -maxVelocity;
+ }
+ currentValue += velocity * 16.0 / 1000.0;
+ if (haveModulus) {
+ currentValue = fmod(currentValue, modulus);
+ if (currentValue < 0.0)
+ currentValue += modulus;
+ }
+ }
+ if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) {
+ velocity = 0.0;
+ currentValue = srcVal;
+ clock.stop();
+ }
+ lastTime = time - (elapsed - count * 16);
+ } else {
+ qreal moveBy = elapsed * velocityms;
+ qreal diff = srcVal - currentValue;
+ if (haveModulus && qAbs(diff) > modulus / 2) {
+ if (diff < 0)
+ diff += modulus;
+ else
+ diff -= modulus;
+ }
+ if (diff > 0) {
+ currentValue += moveBy;
+ if (haveModulus)
+ currentValue = fmod(currentValue, modulus);
+ if (currentValue > sourceValue) {
+ currentValue = sourceValue;
+ clock.stop();
+ }
+ } else {
+ currentValue -= moveBy;
+ if (haveModulus && currentValue < 0.0)
+ currentValue = fmod(currentValue, modulus) + modulus;
+ if (currentValue < sourceValue) {
+ currentValue = sourceValue;
+ clock.stop();
+ }
+ }
+ lastTime = time;
+ }
+ property.write(currentValue);
+ emit q->valueChanged(currentValue);
+ if (clock.state() != QAbstractAnimation::Running)
+ emit q->syncChanged();
+}
+
+void QDeclarativeSpringFollowPrivate::updateMode()
+{
+ if (spring == 0. && maxVelocity == 0.)
+ mode = Track;
+ else if (spring > 0.)
+ mode = Spring;
+ else
+ mode = Velocity;
+}
+
+void QDeclarativeSpringFollowPrivate::start()
+{
+ if (!enabled)
+ return;
+
+ Q_Q(QDeclarativeSpringFollow);
+ if (mode == QDeclarativeSpringFollowPrivate::Track) {
+ currentValue = sourceValue;
+ property.write(currentValue);
+ } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
+ lastTime = 0;
+ currentValue = property.read().toReal();
+ clock.start(); // infinity??
+ emit q->syncChanged();
+ }
+}
+
+void QDeclarativeSpringFollowPrivate::stop()
+{
+ clock.stop();
+}
+
+/*!
+ \qmlclass SpringFollow QDeclarativeSpringFollow
+ \since 4.7
+ \brief The SpringFollow element allows a property to track a value.
+
+ In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200:
+ \code
+ Rectangle {
+ id: rect1
+ width: 20; height: 20
+ color: "#00ff00"
+ y: 200 //initial value
+ y: SequentialAnimation {
+ running: true
+ repeat: true
+ NumberAnimation {
+ to: 200
+ easing: "easeOutBounce(amplitude:100)"
+ duration: 2000
+ }
+ PauseAnimation { duration: 1000 }
+ }
+ }
+ Rectangle {
+ id: rect2
+ x: rect1.width
+ width: 20; height: 20
+ color: "#ff0000"
+ y: SpringFollow { source: rect1.y; velocity: 200 }
+ }
+ \endcode
+
+ \sa EaseFollow
+*/
+
+QDeclarativeSpringFollow::QDeclarativeSpringFollow(QObject *parent)
+: QObject(*(new QDeclarativeSpringFollowPrivate),parent)
+{
+}
+
+QDeclarativeSpringFollow::~QDeclarativeSpringFollow()
+{
+}
+
+void QDeclarativeSpringFollow::setTarget(const QDeclarativeProperty &property)
+{
+ Q_D(QDeclarativeSpringFollow);
+ d->property = property;
+ d->currentValue = property.read().toReal();
+}
+
+qreal QDeclarativeSpringFollow::sourceValue() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->sourceValue;
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::source
+ This property holds the source value which will be tracked.
+
+ Bind to a property in order to track its changes.
+*/
+
+void QDeclarativeSpringFollow::setSourceValue(qreal value)
+{
+ Q_D(QDeclarativeSpringFollow);
+ if (d->clock.state() == QAbstractAnimation::Running && d->sourceValue == value)
+ return;
+
+ d->sourceValue = value;
+ d->start();
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::velocity
+ This property holds the maximum velocity allowed when tracking the source.
+*/
+
+qreal QDeclarativeSpringFollow::velocity() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->maxVelocity;
+}
+
+void QDeclarativeSpringFollow::setVelocity(qreal velocity)
+{
+ Q_D(QDeclarativeSpringFollow);
+ d->maxVelocity = velocity;
+ d->velocityms = velocity / 1000.0;
+ d->updateMode();
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::spring
+ This property holds the spring constant
+
+ The spring constant describes how strongly the target is pulled towards the
+ source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0
+
+ When a spring constant is set and the velocity property is greater than 0,
+ velocity limits the maximum speed.
+*/
+qreal QDeclarativeSpringFollow::spring() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->spring;
+}
+
+void QDeclarativeSpringFollow::setSpring(qreal spring)
+{
+ Q_D(QDeclarativeSpringFollow);
+ d->spring = spring;
+ d->updateMode();
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::damping
+ This property holds the spring damping constant
+
+ The damping constant describes how quickly a sprung follower comes to rest.
+ Useful range is 0 - 1.0
+*/
+qreal QDeclarativeSpringFollow::damping() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->damping;
+}
+
+void QDeclarativeSpringFollow::setDamping(qreal damping)
+{
+ Q_D(QDeclarativeSpringFollow);
+ if (damping > 1.)
+ damping = 1.;
+
+ d->damping = damping;
+}
+
+
+/*!
+ \qmlproperty qreal SpringFollow::epsilon
+ This property holds the spring epsilon
+
+ The epsilon is the rate and amount of change in the value which is close enough
+ to 0 to be considered equal to zero. This will depend on the usage of the value.
+ For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
+
+ The default is 0.01. Tuning this value can provide small performance improvements.
+*/
+qreal QDeclarativeSpringFollow::epsilon() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->epsilon;
+}
+
+void QDeclarativeSpringFollow::setEpsilon(qreal epsilon)
+{
+ Q_D(QDeclarativeSpringFollow);
+ d->epsilon = epsilon;
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::modulus
+ This property holds the modulus value.
+
+ Setting a \a modulus forces the target value to "wrap around" at the modulus.
+ For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
+*/
+qreal QDeclarativeSpringFollow::modulus() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->modulus;
+}
+
+void QDeclarativeSpringFollow::setModulus(qreal modulus)
+{
+ Q_D(QDeclarativeSpringFollow);
+ if (d->modulus != modulus) {
+ d->haveModulus = modulus != 0.0;
+ d->modulus = modulus;
+ emit modulusChanged();
+ }
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::mass
+ This property holds the "mass" of the property being moved.
+
+ mass is 1.0 by default. Setting a different mass changes the dynamics of
+ a \l spring follow.
+*/
+qreal QDeclarativeSpringFollow::mass() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->mass;
+}
+
+void QDeclarativeSpringFollow::setMass(qreal mass)
+{
+ Q_D(QDeclarativeSpringFollow);
+ if (d->mass != mass && mass > 0.0) {
+ d->useMass = mass != 1.0;
+ d->mass = mass;
+ emit massChanged();
+ }
+}
+
+/*!
+ \qmlproperty qreal SpringFollow::value
+ The current value.
+*/
+
+/*!
+ \qmlproperty bool SpringFollow::enabled
+ This property holds whether the target will track the source.
+*/
+bool QDeclarativeSpringFollow::enabled() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->enabled;
+}
+
+void QDeclarativeSpringFollow::setEnabled(bool enabled)
+{
+ Q_D(QDeclarativeSpringFollow);
+ d->enabled = enabled;
+ if (enabled)
+ d->start();
+ else
+ d->stop();
+}
+
+/*!
+ \qmlproperty bool SpringFollow::inSync
+ This property is true when target is equal to the source; otherwise
+ false. If inSync is true the target is not being animated.
+
+ If \l enabled is false then inSync will also be false.
+*/
+bool QDeclarativeSpringFollow::inSync() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->enabled && d->clock.state() != QAbstractAnimation::Running;
+}
+
+qreal QDeclarativeSpringFollow::value() const
+{
+ Q_D(const QDeclarativeSpringFollow);
+ return d->currentValue;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativespringfollow_p.h b/src/declarative/util/qdeclarativespringfollow_p.h
new file mode 100644
index 0000000000..2ac0d82cd4
--- /dev/null
+++ b/src/declarative/util/qdeclarativespringfollow_p.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 QDECLARATIVESMOOTHFOLLOW_H
+#define QDECLARATIVESMOOTHFOLLOW_H
+
+#include <qdeclarativepropertyvaluesource.h>
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeSpringFollowPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeSpringFollow : public QObject,
+ public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeSpringFollow)
+ Q_INTERFACES(QDeclarativePropertyValueSource)
+
+ Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue)
+ Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
+ Q_PROPERTY(qreal spring READ spring WRITE setSpring)
+ Q_PROPERTY(qreal damping READ damping WRITE setDamping)
+ Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+ Q_PROPERTY(qreal value READ value NOTIFY valueChanged)
+ Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
+ Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
+ Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged)
+
+public:
+ QDeclarativeSpringFollow(QObject *parent=0);
+ ~QDeclarativeSpringFollow();
+
+ virtual void setTarget(const QDeclarativeProperty &);
+
+ qreal sourceValue() const;
+ void setSourceValue(qreal value);
+ qreal velocity() const;
+ void setVelocity(qreal velocity);
+ qreal spring() const;
+ void setSpring(qreal spring);
+ qreal damping() const;
+ void setDamping(qreal damping);
+ qreal epsilon() const;
+ void setEpsilon(qreal epsilon);
+ qreal mass() const;
+ void setMass(qreal modulus);
+ qreal modulus() const;
+ void setModulus(qreal modulus);
+ bool enabled() const;
+ void setEnabled(bool enabled);
+ bool inSync() const;
+
+ qreal value() const;
+
+Q_SIGNALS:
+ void valueChanged(qreal);
+ void modulusChanged();
+ void massChanged();
+ void syncChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeSpringFollow)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESMOOTHFOLLOW_H
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
new file mode 100644
index 0000000000..1d70d33636
--- /dev/null
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -0,0 +1,483 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativestate_p_p.h"
+#include "qdeclarativestate_p.h"
+
+#include "qdeclarativetransition_p.h"
+#include "qdeclarativestategroup_p.h"
+#include "qdeclarativestateoperations_p.h"
+#include "qdeclarativeanimation_p.h"
+#include "qdeclarativeanimation_p_p.h"
+
+#include <qdeclarativebinding_p.h>
+#include <qdeclarativeglobal_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+
+QDeclarativeAction::QDeclarativeAction()
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), toBinding(0), event(0),
+ specifiedObject(0)
+{
+}
+
+QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyName,
+ const QVariant &value)
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
+ property(target, propertyName), toValue(value),
+ fromBinding(0), toBinding(0), event(0),
+ specifiedObject(target), specifiedProperty(propertyName)
+{
+ if (property.isValid())
+ fromValue = property.read();
+}
+
+QDeclarativeActionEvent::~QDeclarativeActionEvent()
+{
+}
+
+QString QDeclarativeActionEvent::typeName() const
+{
+ return QString();
+}
+
+void QDeclarativeActionEvent::execute()
+{
+}
+
+bool QDeclarativeActionEvent::isReversable()
+{
+ return false;
+}
+
+void QDeclarativeActionEvent::reverse()
+{
+}
+
+QList<QDeclarativeAction> QDeclarativeActionEvent::extraActions()
+{
+ return QList<QDeclarativeAction>();
+}
+
+bool QDeclarativeActionEvent::changesBindings()
+{
+ return false;
+}
+
+void QDeclarativeActionEvent::clearForwardBindings()
+{
+}
+
+void QDeclarativeActionEvent::clearReverseBindings()
+{
+}
+
+bool QDeclarativeActionEvent::override(QDeclarativeActionEvent *other)
+{
+ Q_UNUSED(other);
+ return false;
+}
+
+/*!
+ \internal
+*/
+QDeclarativeStateOperation::QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+/*!
+ \qmlclass State QDeclarativeState
+ \since 4.7
+ \brief The State element defines configurations of objects and properties.
+
+ A state is specified as a set of batched changes from the default configuration.
+
+ Note that setting the state of an object from within another state of the same object is
+ inadvisible. Not only would this have the same effect as going directly to the second state
+ it may cause the program to crash.
+
+ \sa {qmlstates}{States}, {state-transitions}{Transitions}
+*/
+
+/*!
+ \internal
+ \class QDeclarativeState
+ \brief The QDeclarativeState class allows you to define configurations of objects and properties.
+
+ \ingroup group_states
+
+ QDeclarativeState allows you to specify a state as a set of batched changes from the default
+ configuration.
+
+ \sa {states-transitions}{States and Transitions}
+*/
+
+
+QDeclarativeState::QDeclarativeState(QObject *parent)
+: QObject(*(new QDeclarativeStatePrivate), parent)
+{
+ Q_D(QDeclarativeState);
+ d->transitionManager.setState(this);
+}
+
+QDeclarativeState::~QDeclarativeState()
+{
+ Q_D(QDeclarativeState);
+ if (d->group)
+ d->group->removeState(this);
+}
+
+/*!
+ \qmlproperty string State::name
+ This property holds the name of the state
+
+ Each state should have a unique name.
+*/
+QString QDeclarativeState::name() const
+{
+ Q_D(const QDeclarativeState);
+ return d->name;
+}
+
+void QDeclarativeState::setName(const QString &n)
+{
+ Q_D(QDeclarativeState);
+ d->name = n;
+}
+
+bool QDeclarativeState::isWhenKnown() const
+{
+ Q_D(const QDeclarativeState);
+ return d->when != 0;
+}
+
+/*!
+ \qmlproperty bool State::when
+ This property holds when the state should be applied
+
+ This should be set to an expression that evaluates to true when you want the state to
+ be applied.
+*/
+QDeclarativeBinding *QDeclarativeState::when() const
+{
+ Q_D(const QDeclarativeState);
+ return d->when;
+}
+
+void QDeclarativeState::setWhen(QDeclarativeBinding *when)
+{
+ Q_D(QDeclarativeState);
+ d->when = when;
+ if (d->group)
+ d->group->updateAutoState();
+}
+
+/*!
+ \qmlproperty string State::extend
+ This property holds the state that this state extends
+
+ The state being extended is treated as the base state in regards to
+ the changes specified by the extending state.
+*/
+QString QDeclarativeState::extends() const
+{
+ Q_D(const QDeclarativeState);
+ return d->extends;
+}
+
+void QDeclarativeState::setExtends(const QString &extends)
+{
+ Q_D(QDeclarativeState);
+ d->extends = extends;
+}
+
+/*!
+ \qmlproperty list<Change> State::changes
+ This property holds the changes to apply for this state
+ \default
+
+ By default these changes are applied against the default state. If the state
+ extends another state, then the changes are applied against the state being
+ extended.
+*/
+QDeclarativeListProperty<QDeclarativeStateOperation> QDeclarativeState::changes()
+{
+ Q_D(QDeclarativeState);
+ return QDeclarativeListProperty<QDeclarativeStateOperation>(this, &d->operations, QDeclarativeStatePrivate::operations_append,
+ QDeclarativeStatePrivate::operations_count, QDeclarativeStatePrivate::operations_at,
+ QDeclarativeStatePrivate::operations_clear);
+}
+
+int QDeclarativeState::operationCount() const
+{
+ Q_D(const QDeclarativeState);
+ return d->operations.count();
+}
+
+QDeclarativeStateOperation *QDeclarativeState::operationAt(int index) const
+{
+ Q_D(const QDeclarativeState);
+ return d->operations.at(index);
+}
+
+QDeclarativeState &QDeclarativeState::operator<<(QDeclarativeStateOperation *op)
+{
+ Q_D(QDeclarativeState);
+ d->operations.append(QDeclarativeStatePrivate::OperationGuard(op, &d->operations));
+ return *this;
+}
+
+void QDeclarativeStatePrivate::complete()
+{
+ Q_Q(QDeclarativeState);
+
+ for (int ii = 0; ii < reverting.count(); ++ii) {
+ for (int jj = 0; jj < revertList.count(); ++jj) {
+ if (revertList.at(jj).property == reverting.at(ii)) {
+ revertList.removeAt(jj);
+ break;
+ }
+ }
+ }
+ reverting.clear();
+
+ emit q->completed();
+}
+
+// Generate a list of actions for this state. This includes coelescing state
+// actions that this state "extends"
+QDeclarativeStateOperation::ActionList
+QDeclarativeStatePrivate::generateActionList(QDeclarativeStateGroup *group) const
+{
+ QDeclarativeStateOperation::ActionList applyList;
+ if (inState)
+ return applyList;
+
+ // Prevent "extends" recursion
+ inState = true;
+
+ if (!extends.isEmpty()) {
+ QList<QDeclarativeState *> states = group->states();
+ for (int ii = 0; ii < states.count(); ++ii)
+ if (states.at(ii)->name() == extends)
+ applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList(group);
+ }
+
+ foreach(QDeclarativeStateOperation *op, operations)
+ applyList << op->actions();
+
+ inState = false;
+ return applyList;
+}
+
+QDeclarativeStateGroup *QDeclarativeState::stateGroup() const
+{
+ Q_D(const QDeclarativeState);
+ return d->group;
+}
+
+void QDeclarativeState::setStateGroup(QDeclarativeStateGroup *group)
+{
+ Q_D(QDeclarativeState);
+ d->group = group;
+}
+
+void QDeclarativeState::cancel()
+{
+ Q_D(QDeclarativeState);
+ d->transitionManager.cancel();
+}
+
+void QDeclarativeAction::deleteFromBinding()
+{
+ if (fromBinding) {
+ QDeclarativePropertyPrivate::setBinding(property, 0);
+ fromBinding->destroy();
+ fromBinding = 0;
+ }
+}
+
+void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransition *trans, QDeclarativeState *revert)
+{
+ Q_D(QDeclarativeState);
+
+ qmlExecuteDeferred(this);
+
+ cancel();
+ if (revert)
+ revert->cancel();
+ d->revertList.clear();
+ d->reverting.clear();
+
+ if (revert) {
+ QDeclarativeStatePrivate *revertPrivate =
+ static_cast<QDeclarativeStatePrivate*>(revert->d_func());
+ d->revertList = revertPrivate->revertList;
+ revertPrivate->revertList.clear();
+ }
+
+ // List of actions caused by this state
+ QDeclarativeStateOperation::ActionList applyList = d->generateActionList(group);
+
+ // List of actions that need to be reverted to roll back (just) this state
+ QDeclarativeStatePrivate::SimpleActionList additionalReverts;
+ // First add the reverse of all the applyList actions
+ for (int ii = 0; ii < applyList.count(); ++ii) {
+ QDeclarativeAction &action = applyList[ii];
+
+ bool found = false;
+
+ int jj;
+ if (action.event) {
+ if (!action.event->isReversable())
+ continue;
+ for (jj = 0; jj < d->revertList.count(); ++jj) {
+ QDeclarativeActionEvent *event = d->revertList.at(jj).event;
+ if (event && event->typeName() == action.event->typeName()) {
+ if (action.event->override(event)) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found || action.event != d->revertList.at(jj).event)
+ action.event->saveOriginals();
+ else if (action.event->isRewindable())
+ action.event->saveCurrentValues();
+ } else {
+ action.fromBinding = QDeclarativePropertyPrivate::binding(action.property);
+
+ for (jj = 0; jj < d->revertList.count(); ++jj) {
+ if (d->revertList.at(jj).property == action.property) {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ if (!found) {
+ if (!action.restore) {
+ action.deleteFromBinding();
+ } else {
+ // Only need to revert the applyList action if the previous
+ // state doesn't have a higher priority revert already
+ QDeclarativeSimpleAction r(action);
+ additionalReverts << r;
+ }
+ } else if (d->revertList.at(jj).binding != action.fromBinding) {
+ action.deleteFromBinding();
+ }
+ }
+
+ // Any reverts from a previous state that aren't carried forth
+ // into this state need to be translated into apply actions
+ for (int ii = 0; ii < d->revertList.count(); ++ii) {
+ bool found = false;
+ if (d->revertList.at(ii).event) {
+ QDeclarativeActionEvent *event = d->revertList.at(ii).event;
+ if (!event->isReversable())
+ continue;
+ for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ const QDeclarativeAction &action = applyList.at(jj);
+ if (action.event && action.event->typeName() == event->typeName()) {
+ if (action.event->override(event))
+ found = true;
+ }
+ }
+ } else {
+ for (int jj = 0; !found && jj < applyList.count(); ++jj) {
+ const QDeclarativeAction &action = applyList.at(jj);
+ if (action.property == d->revertList.at(ii).property)
+ found = true;
+ }
+ }
+ if (!found) {
+ QVariant cur = d->revertList.at(ii).property.read();
+ QDeclarativeAbstractBinding *delBinding =
+ QDeclarativePropertyPrivate::setBinding(d->revertList.at(ii).property, 0);
+ if (delBinding)
+ delBinding->destroy();
+
+ QDeclarativeAction a;
+ a.property = d->revertList.at(ii).property;
+ a.fromValue = cur;
+ a.toValue = d->revertList.at(ii).value;
+ a.toBinding = d->revertList.at(ii).binding;
+ a.specifiedObject = d->revertList.at(ii).specifiedObject;
+ a.specifiedProperty = d->revertList.at(ii).specifiedProperty;
+ a.event = d->revertList.at(ii).event;
+ a.reverseEvent = d->revertList.at(ii).reverseEvent;
+ if (a.event && a.event->isRewindable())
+ a.event->saveCurrentValues();
+ applyList << a;
+ // Store these special reverts in the reverting list
+ d->reverting << d->revertList.at(ii).property;
+ }
+ }
+ // All the local reverts now become part of the ongoing revertList
+ d->revertList << additionalReverts;
+
+ // Output for debugging
+ if (stateChangeDebug()) {
+ foreach(const QDeclarativeAction &action, applyList) {
+ if (action.event)
+ qWarning() << " QDeclarativeAction event:" << action.event->typeName();
+ else
+ qWarning() << " QDeclarativeAction:" << action.property.object()
+ << action.property.name() << "From:" << action.fromValue
+ << "To:" << action.toValue;
+ }
+ }
+
+ d->transitionManager.transition(applyList, trans);
+}
+
+QDeclarativeStateOperation::ActionList QDeclarativeStateOperation::actions()
+{
+ return ActionList();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h
new file mode 100644
index 0000000000..0c6e7a3fdd
--- /dev/null
+++ b/src/declarative/util/qdeclarativestate_p.h
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVESTATE_H
+#define QDECLARATIVESTATE_H
+
+#include <qdeclarative.h>
+#include <qdeclarativeproperty.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeActionEvent;
+class QDeclarativeAbstractBinding;
+class QDeclarativeBinding;
+class QDeclarativeExpression;
+class Q_DECLARATIVE_EXPORT QDeclarativeAction
+{
+public:
+ QDeclarativeAction();
+ QDeclarativeAction(QObject *, const QString &, const QVariant &);
+
+ bool restore:1;
+ bool actionDone:1;
+ bool reverseEvent:1;
+ bool deletableToBinding:1;
+
+ QDeclarativeProperty property;
+ QVariant fromValue;
+ QVariant toValue;
+
+ QDeclarativeAbstractBinding *fromBinding;
+ QDeclarativeAbstractBinding *toBinding;
+ QDeclarativeActionEvent *event;
+
+ //strictly for matching
+ QObject *specifiedObject;
+ QString specifiedProperty;
+
+ void deleteFromBinding();
+};
+
+class QDeclarativeActionEvent
+{
+public:
+ virtual ~QDeclarativeActionEvent();
+ virtual QString typeName() const;
+
+ virtual void execute();
+ virtual bool isReversable();
+ virtual void reverse();
+ virtual void saveOriginals() {}
+
+ virtual bool isRewindable() { return isReversable(); }
+ virtual void rewind() {}
+ virtual void saveCurrentValues() {}
+
+ //virtual bool hasExtraActions();
+ virtual QList<QDeclarativeAction> extraActions();
+
+ virtual bool changesBindings();
+ virtual void clearForwardBindings();
+ virtual void clearReverseBindings();
+ virtual bool override(QDeclarativeActionEvent*other);
+};
+
+//### rename to QDeclarativeStateChange?
+class QDeclarativeStateGroup;
+class Q_DECLARATIVE_EXPORT QDeclarativeStateOperation : public QObject
+{
+ Q_OBJECT
+public:
+ QDeclarativeStateOperation(QObject *parent = 0)
+ : QObject(parent) {}
+ typedef QList<QDeclarativeAction> ActionList;
+
+ virtual ActionList actions();
+
+protected:
+ QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent = 0);
+};
+
+typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions;
+
+class QDeclarativeTransition;
+class QDeclarativeStatePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeState : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen)
+ Q_PROPERTY(QString extend READ extends WRITE setExtends)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeStateOperation> changes READ changes)
+ Q_CLASSINFO("DefaultProperty", "changes")
+ Q_CLASSINFO("DeferredPropertyNames", "changes")
+
+public:
+ QDeclarativeState(QObject *parent=0);
+ virtual ~QDeclarativeState();
+
+ QString name() const;
+ void setName(const QString &);
+
+ /*'when' is a QDeclarativeBinding to limit state changes oscillation
+ due to the unpredictable order of evaluation of bound expressions*/
+ bool isWhenKnown() const;
+ QDeclarativeBinding *when() const;
+ void setWhen(QDeclarativeBinding *);
+
+ QString extends() const;
+ void setExtends(const QString &);
+
+ QDeclarativeListProperty<QDeclarativeStateOperation> changes();
+ int operationCount() const;
+ QDeclarativeStateOperation *operationAt(int) const;
+
+ QDeclarativeState &operator<<(QDeclarativeStateOperation *);
+
+ void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert);
+ void cancel();
+
+ QDeclarativeStateGroup *stateGroup() const;
+ void setStateGroup(QDeclarativeStateGroup *);
+
+Q_SIGNALS:
+ void completed();
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativeState)
+ Q_DISABLE_COPY(QDeclarativeState)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeStateOperation)
+QML_DECLARE_TYPE(QDeclarativeState)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESTATE_H
diff --git a/src/declarative/util/qdeclarativestate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h
new file mode 100644
index 0000000000..6f52219757
--- /dev/null
+++ b/src/declarative/util/qdeclarativestate_p_p.h
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVESTATE_P_H
+#define QDECLARATIVESTATE_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 "qdeclarativestate_p.h"
+
+#include "qdeclarativeanimation_p_p.h"
+#include "qdeclarativetransitionmanager_p_p.h"
+
+#include <qdeclarativeproperty_p.h>
+#include <qdeclarativeguard_p.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeSimpleAction
+{
+public:
+ enum State { StartState, EndState };
+ QDeclarativeSimpleAction(const QDeclarativeAction &a, State state = StartState)
+ {
+ property = a.property;
+ specifiedObject = a.specifiedObject;
+ specifiedProperty = a.specifiedProperty;
+ event = a.event;
+ if (state == StartState) {
+ value = a.fromValue;
+ binding = QDeclarativePropertyPrivate::binding(property);
+ reverseEvent = true;
+ } else {
+ value = a.toValue;
+ binding = a.toBinding;
+ reverseEvent = false;
+ }
+ }
+
+ QDeclarativeProperty property;
+ QVariant value;
+ QDeclarativeAbstractBinding *binding;
+ QObject *specifiedObject;
+ QString specifiedProperty;
+ QDeclarativeActionEvent *event;
+ bool reverseEvent;
+};
+
+class QDeclarativeStatePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeState)
+
+public:
+ QDeclarativeStatePrivate()
+ : when(0), inState(false), group(0) {}
+
+ typedef QList<QDeclarativeSimpleAction> SimpleActionList;
+
+ QString name;
+ QDeclarativeBinding *when;
+
+ struct OperationGuard : public QDeclarativeGuard<QDeclarativeStateOperation>
+ {
+ OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QDeclarativeGuard<QObject>&)*this = obj; }
+ QList<OperationGuard> *list;
+ void objectDestroyed(QDeclarativeStateOperation *) {
+ // we assume priv will always be destroyed after objectDestroyed calls
+ list->removeOne(*this);
+ }
+ };
+ QList<OperationGuard> operations;
+
+ static void operations_append(QDeclarativeListProperty<QDeclarativeStateOperation> *prop, QDeclarativeStateOperation *op) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->append(OperationGuard(op, list));
+ }
+ static void operations_clear(QDeclarativeListProperty<QDeclarativeStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->clear();
+ }
+ static int operations_count(QDeclarativeListProperty<QDeclarativeStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->count();
+ }
+ static QDeclarativeStateOperation *operations_at(QDeclarativeListProperty<QDeclarativeStateOperation> *prop, int index) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ return list->at(index);
+ }
+
+ QDeclarativeTransitionManager transitionManager;
+
+ SimpleActionList revertList;
+ QList<QDeclarativeProperty> reverting;
+ QString extends;
+ mutable bool inState;
+ QDeclarativeStateGroup *group;
+
+ QDeclarativeStateOperation::ActionList generateActionList(QDeclarativeStateGroup *) const;
+ void complete();
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVESTATE_P_H
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
new file mode 100644
index 0000000000..00119ceae0
--- /dev/null
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -0,0 +1,441 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativestategroup_p.h"
+
+#include "qdeclarativetransition_p.h"
+#include "qdeclarativestate_p_p.h"
+
+#include <qdeclarativebinding_p.h>
+#include <qdeclarativeglobal_p.h>
+
+#include <QtCore/qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+
+class QDeclarativeStateGroupPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeStateGroup)
+public:
+ QDeclarativeStateGroupPrivate()
+ : nullState(0), componentComplete(true),
+ ignoreTrans(false), applyingState(false) {}
+
+ QString currentState;
+ QDeclarativeState *nullState;
+
+ static void append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state);
+ static int count_state(QDeclarativeListProperty<QDeclarativeState> *list);
+ static QDeclarativeState *at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index);
+
+ QList<QDeclarativeState *> states;
+ QList<QDeclarativeTransition *> transitions;
+
+ bool componentComplete;
+ bool ignoreTrans;
+ bool applyingState;
+
+ QDeclarativeTransition *findTransition(const QString &from, const QString &to);
+ void setCurrentStateInternal(const QString &state, bool = false);
+ bool updateAutoState();
+};
+
+/*!
+ \qmlclass StateGroup QDeclarativeStateGroup
+ \since 4.7
+ \brief The StateGroup element provides state support for non-Item elements.
+
+ Item (and all dervied elements) provides built in support for states and transitions
+ via its state, states and transitions properties. StateGroup provides an easy way to
+ use this support in other (non-Item-derived) elements.
+
+ \qml
+ MyCustomObject {
+ StateGroup {
+ id: myStateGroup
+ states: State {
+ name: "state1"
+ ...
+ }
+ transitions: Transition {
+ ...
+ }
+ }
+
+ onSomethingHappened: myStateGroup.state = "state1";
+ }
+ \endqml
+
+ \sa {qmlstate}{States} {state-transitions}{Transitions}
+*/
+
+QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent)
+ : QObject(*(new QDeclarativeStateGroupPrivate), parent)
+{
+}
+
+QDeclarativeStateGroup::~QDeclarativeStateGroup()
+{
+ Q_D(const QDeclarativeStateGroup);
+ for (int i = 0; i < d->states.count(); ++i)
+ d->states.at(i)->setStateGroup(0);
+}
+
+QList<QDeclarativeState *> QDeclarativeStateGroup::states() const
+{
+ Q_D(const QDeclarativeStateGroup);
+ return d->states;
+}
+
+/*!
+ \qmlproperty list<State> StateGroup::states
+ This property holds a list of states defined by the state group.
+
+ \qml
+ StateGroup {
+ states: [
+ State { ... },
+ State { ... }
+ ...
+ ]
+ }
+ \endqml
+
+ \sa {qmlstate}{States}
+*/
+QDeclarativeListProperty<QDeclarativeState> QDeclarativeStateGroup::statesProperty()
+{
+ Q_D(QDeclarativeStateGroup);
+ return QDeclarativeListProperty<QDeclarativeState>(this, &d->states, &QDeclarativeStateGroupPrivate::append_state,
+ &QDeclarativeStateGroupPrivate::count_state,
+ &QDeclarativeStateGroupPrivate::at_state);
+}
+
+void QDeclarativeStateGroupPrivate::append_state(QDeclarativeListProperty<QDeclarativeState> *list, QDeclarativeState *state)
+{
+ QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
+ if (state) {
+ _this->d_func()->states.append(state);
+ state->setStateGroup(_this);
+ }
+
+}
+
+int QDeclarativeStateGroupPrivate::count_state(QDeclarativeListProperty<QDeclarativeState> *list)
+{
+ QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
+ return _this->d_func()->states.count();
+}
+
+QDeclarativeState *QDeclarativeStateGroupPrivate::at_state(QDeclarativeListProperty<QDeclarativeState> *list, int index)
+{
+ QDeclarativeStateGroup *_this = static_cast<QDeclarativeStateGroup *>(list->object);
+ return _this->d_func()->states.at(index);
+}
+
+/*!
+ \qmlproperty list<Transition> StateGroup::transitions
+ This property holds a list of transitions defined by the state group.
+
+ \qml
+ StateGroup {
+ transitions: [
+ Transition { ... },
+ Transition { ... }
+ ...
+ ]
+ }
+ \endqml
+
+ \sa {state-transitions}{Transitions}
+*/
+QDeclarativeListProperty<QDeclarativeTransition> QDeclarativeStateGroup::transitionsProperty()
+{
+ Q_D(QDeclarativeStateGroup);
+ return QDeclarativeListProperty<QDeclarativeTransition>(this, d->transitions);
+}
+
+/*!
+ \qmlproperty string StateGroup::state
+
+ This property holds the name of the current state of the state group.
+
+ 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 state group is in its base state (i.e. no explicit state has been
+ set), \c state will be a blank string. Likewise, you can return a
+ state group to its base state by setting its current state to \c ''.
+
+ \sa {qmlstates}{States}
+*/
+QString QDeclarativeStateGroup::state() const
+{
+ Q_D(const QDeclarativeStateGroup);
+ return d->currentState;
+}
+
+void QDeclarativeStateGroup::setState(const QString &state)
+{
+ Q_D(QDeclarativeStateGroup);
+ if (d->currentState == state)
+ return;
+
+ d->setCurrentStateInternal(state);
+}
+
+void QDeclarativeStateGroup::classBegin()
+{
+ Q_D(QDeclarativeStateGroup);
+ d->componentComplete = false;
+}
+
+void QDeclarativeStateGroup::componentComplete()
+{
+ Q_D(QDeclarativeStateGroup);
+ d->componentComplete = true;
+
+ if (d->updateAutoState()) {
+ return;
+ } else if (!d->currentState.isEmpty()) {
+ QString cs = d->currentState;
+ d->currentState = QString();
+ d->setCurrentStateInternal(cs, true);
+ }
+}
+
+/*!
+ Returns true if the state was changed, otherwise false.
+*/
+bool QDeclarativeStateGroup::updateAutoState()
+{
+ Q_D(QDeclarativeStateGroup);
+ return d->updateAutoState();
+}
+
+bool QDeclarativeStateGroupPrivate::updateAutoState()
+{
+ Q_Q(QDeclarativeStateGroup);
+ if (!componentComplete)
+ return false;
+
+ bool revert = false;
+ for (int ii = 0; ii < states.count(); ++ii) {
+ QDeclarativeState *state = states.at(ii);
+ if (state->isWhenKnown()) {
+ if (!state->name().isEmpty()) {
+ if (state->when() && state->when()->value().toBool()) {
+ if (stateChangeDebug())
+ qWarning() << "Setting auto state due to:"
+ << state->when()->expression();
+ if (currentState != state->name()) {
+ q->setState(state->name());
+ return true;
+ } else {
+ return false;
+ }
+ } else if (state->name() == currentState) {
+ revert = true;
+ }
+ }
+ }
+ }
+ if (revert) {
+ bool rv = currentState != QString();
+ q->setState(QString());
+ return rv;
+ } else {
+ return false;
+ }
+}
+
+QDeclarativeTransition *QDeclarativeStateGroupPrivate::findTransition(const QString &from, const QString &to)
+{
+ QDeclarativeTransition *highest = 0;
+ int score = 0;
+ bool reversed = false;
+ bool done = false;
+
+ for (int ii = 0; !done && ii < transitions.count(); ++ii) {
+ QDeclarativeTransition *t = transitions.at(ii);
+ for (int ii = 0; ii < 2; ++ii)
+ {
+ if (ii && (!t->reversible() ||
+ (t->fromState() == QLatin1String("*") &&
+ t->toState() == QLatin1String("*"))))
+ break;
+ QStringList fromState;
+ QStringList toState;
+
+ fromState = t->fromState().split(QLatin1Char(','));
+ toState = t->toState().split(QLatin1Char(','));
+ if (ii == 1)
+ qSwap(fromState, toState);
+ int tScore = 0;
+ if (fromState.contains(from))
+ tScore += 2;
+ else if (fromState.contains(QLatin1String("*")))
+ tScore += 1;
+ else
+ continue;
+
+ if (toState.contains(to))
+ tScore += 2;
+ else if (toState.contains(QLatin1String("*")))
+ tScore += 1;
+ else
+ continue;
+
+ if (ii == 1)
+ reversed = true;
+ else
+ reversed = false;
+
+ if (tScore == 4) {
+ highest = t;
+ done = true;
+ break;
+ } else if (tScore > score) {
+ score = tScore;
+ highest = t;
+ }
+ }
+ }
+
+ if (highest)
+ highest->setReversed(reversed);
+
+ return highest;
+}
+
+void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state,
+ bool ignoreTrans)
+{
+ Q_Q(QDeclarativeStateGroup);
+ if (!componentComplete) {
+ currentState = state;
+ return;
+ }
+
+ if (applyingState) {
+ qWarning() << "Can't apply a state change as part of a state definition.";
+ return;
+ }
+
+ applyingState = true;
+
+ QDeclarativeTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state);
+ if (stateChangeDebug()) {
+ qWarning() << this << "Changing state. From" << currentState << ". To" << state;
+ if (transition)
+ qWarning() << " using transition" << transition->fromState()
+ << transition->toState();
+ }
+
+ QDeclarativeState *oldState = 0;
+ if (!currentState.isEmpty()) {
+ for (int ii = 0; ii < states.count(); ++ii) {
+ if (states.at(ii)->name() == currentState) {
+ oldState = states.at(ii);
+ break;
+ }
+ }
+ }
+
+ currentState = state;
+ emit q->stateChanged(currentState);
+
+ QDeclarativeState *newState = 0;
+ for (int ii = 0; ii < states.count(); ++ii) {
+ if (states.at(ii)->name() == currentState) {
+ newState = states.at(ii);
+ break;
+ }
+ }
+
+ if (oldState == 0 || newState == 0) {
+ if (!nullState) { nullState = new QDeclarativeState; QDeclarativeGraphics_setParent_noEvent(nullState, q); }
+ if (!oldState) oldState = nullState;
+ if (!newState) newState = nullState;
+ }
+
+ newState->apply(q, transition, oldState);
+ applyingState = false;
+ if (!transition)
+ static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(newState))->complete();
+}
+
+QDeclarativeState *QDeclarativeStateGroup::findState(const QString &name) const
+{
+ Q_D(const QDeclarativeStateGroup);
+ for (int i = 0; i < d->states.count(); ++i) {
+ QDeclarativeState *state = d->states.at(i);
+ if (state->name() == name)
+ return state;
+ }
+
+ return 0;
+}
+
+void QDeclarativeStateGroup::removeState(QDeclarativeState *state)
+{
+ Q_D(QDeclarativeStateGroup);
+ d->states.removeOne(state);
+}
+
+QT_END_NAMESPACE
+
+
diff --git a/src/declarative/util/qdeclarativestategroup_p.h b/src/declarative/util/qdeclarativestategroup_p.h
new file mode 100644
index 0000000000..9650199f8c
--- /dev/null
+++ b/src/declarative/util/qdeclarativestategroup_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 QDECLARATIVESTATEGROUP_H
+#define QDECLARATIVESTATEGROUP_H
+
+#include "qdeclarativestate_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeStateGroupPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_DECLARE_PRIVATE(QDeclarativeStateGroup)
+
+ Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeState> states READ statesProperty DESIGNABLE false)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeTransition> transitions READ transitionsProperty DESIGNABLE false)
+
+public:
+ QDeclarativeStateGroup(QObject * = 0);
+ virtual ~QDeclarativeStateGroup();
+
+ QString state() const;
+ void setState(const QString &);
+
+ QDeclarativeListProperty<QDeclarativeState> statesProperty();
+ QList<QDeclarativeState *> states() const;
+
+ QDeclarativeListProperty<QDeclarativeTransition> transitionsProperty();
+
+ QDeclarativeState *findState(const QString &name) const;
+
+ virtual void classBegin();
+ virtual void componentComplete();
+Q_SIGNALS:
+ void stateChanged(const QString &);
+
+private:
+ friend class QDeclarativeState;
+ bool updateAutoState();
+ void removeState(QDeclarativeState *state);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeStateGroup)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESTATEGROUP_H
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
new file mode 100644
index 0000000000..cea9ad7beb
--- /dev/null
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -0,0 +1,989 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativestateoperations_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+#include <qdeclarativeinfo.h>
+#include <qdeclarativeanchors_p_p.h>
+#include <qdeclarativeitem_p.h>
+#include <qdeclarativeguard_p.h>
+#include <qdeclarativenullablevalue_p_p.h>
+
+#include <QtCore/qdebug.h>
+#include <QtGui/qgraphicsitem.h>
+#include <QtCore/qmath.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeParentChangePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeParentChange)
+public:
+ QDeclarativeParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0),
+ rewindParent(0), rewindStackBefore(0) {}
+
+ QDeclarativeItem *target;
+ QDeclarativeItem *parent;
+ QDeclarativeGuard<QDeclarativeItem> origParent;
+ QDeclarativeGuard<QDeclarativeItem> origStackBefore;
+ QDeclarativeItem *rewindParent;
+ QDeclarativeItem *rewindStackBefore;
+
+ QDeclarativeNullableValue<qreal> x;
+ QDeclarativeNullableValue<qreal> y;
+ QDeclarativeNullableValue<qreal> width;
+ QDeclarativeNullableValue<qreal> height;
+ QDeclarativeNullableValue<qreal> scale;
+ QDeclarativeNullableValue<qreal> rotation;
+
+ void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0);
+};
+
+void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore)
+{
+ if (targetParent && target && target->parentItem()) {
+ //### for backwards direction, can we just restore original x, y, scale, rotation
+ Q_Q(QDeclarativeParentChange);
+ bool ok;
+ const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok);
+ if (transform.type() >= QTransform::TxShear || !ok) {
+ qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under complex transform");
+ ok = false;
+ }
+
+ qreal scale = 1;
+ qreal rotation = 0;
+ if (ok && transform.type() != QTransform::TxRotate) {
+ if (transform.m11() == transform.m22())
+ scale = transform.m11();
+ else {
+ qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+ } else if (ok && transform.type() == QTransform::TxRotate) {
+ if (transform.m11() == transform.m22())
+ scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
+ else {
+ qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under non-uniform scale");
+ ok = false;
+ }
+
+ if (scale != 0)
+ rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
+ else {
+ qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under scale of 0");
+ ok = false;
+ }
+ }
+
+ const QPointF &point = transform.map(QPointF(target->x(),target->y()));
+ qreal x = point.x();
+ qreal y = point.y();
+ if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) {
+ qreal tempxt = target->transformOriginPoint().x();
+ qreal tempyt = target->transformOriginPoint().y();
+ QTransform t;
+ t.translate(-tempxt, -tempyt);
+ t.rotate(rotation);
+ t.scale(scale, scale);
+ t.translate(tempxt, tempyt);
+ const QPointF &offset = t.map(QPointF(0,0));
+ x += offset.x();
+ y += offset.y();
+ }
+
+ target->setParentItem(targetParent);
+ if (ok) {
+ //qDebug() << x << y << rotation << scale;
+ target->setX(x);
+ target->setY(y);
+ target->setRotation(target->rotation() + rotation);
+ target->setScale(target->scale() * scale);
+ }
+ } else if (target) {
+ target->setParentItem(targetParent);
+ }
+
+ //restore the original stack position.
+ //### if stackBefore has also been reparented this won't work
+ if (stackBefore)
+ target->stackBefore(stackBefore);
+}
+
+/*!
+ \preliminary
+ \qmlclass ParentChange QDeclarativeParentChange
+ \brief The ParentChange element allows you to reparent an Item in a state change.
+
+ ParentChange reparents an Item while preserving its visual appearance (position, rotation,
+ and scale) on screen. You can then specify a transition to move/rotate/scale the Item to
+ its final intended appearance.
+
+ ParentChange can only preserve visual appearance if no complex transforms are involved.
+ More specifically, it will not work if the transform property has been set for any
+ Items involved in the reparenting (defined as any Items in the common ancestor tree
+ for the original and new parent).
+
+ You can specify at which point in a transition you want a ParentChange to occur by
+ using a ParentAction.
+*/
+
+
+QDeclarativeParentChange::QDeclarativeParentChange(QObject *parent)
+ : QDeclarativeStateOperation(*(new QDeclarativeParentChangePrivate), parent)
+{
+}
+
+QDeclarativeParentChange::~QDeclarativeParentChange()
+{
+}
+
+qreal QDeclarativeParentChange::x() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->x.isNull ? qreal(0.) : d->x.value;
+}
+
+void QDeclarativeParentChange::setX(qreal x)
+{
+ Q_D(QDeclarativeParentChange);
+ d->x = x;
+}
+
+bool QDeclarativeParentChange::xIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->x.isValid();
+}
+
+qreal QDeclarativeParentChange::y() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->y.isNull ? qreal(0.) : d->y.value;
+}
+
+void QDeclarativeParentChange::setY(qreal y)
+{
+ Q_D(QDeclarativeParentChange);
+ d->y = y;
+}
+
+bool QDeclarativeParentChange::yIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->y.isValid();
+}
+
+qreal QDeclarativeParentChange::width() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->width.isNull ? qreal(0.) : d->width.value;
+}
+
+void QDeclarativeParentChange::setWidth(qreal width)
+{
+ Q_D(QDeclarativeParentChange);
+ d->width = width;
+}
+
+bool QDeclarativeParentChange::widthIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->width.isValid();
+}
+
+qreal QDeclarativeParentChange::height() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->height.isNull ? qreal(0.) : d->height.value;
+}
+
+void QDeclarativeParentChange::setHeight(qreal height)
+{
+ Q_D(QDeclarativeParentChange);
+ d->height = height;
+}
+
+bool QDeclarativeParentChange::heightIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->height.isValid();
+}
+
+qreal QDeclarativeParentChange::scale() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->scale.isNull ? qreal(1.) : d->scale.value;
+}
+
+void QDeclarativeParentChange::setScale(qreal scale)
+{
+ Q_D(QDeclarativeParentChange);
+ d->scale = scale;
+}
+
+bool QDeclarativeParentChange::scaleIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->scale.isValid();
+}
+
+qreal QDeclarativeParentChange::rotation() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->rotation.isNull ? qreal(0.) : d->rotation.value;
+}
+
+void QDeclarativeParentChange::setRotation(qreal rotation)
+{
+ Q_D(QDeclarativeParentChange);
+ d->rotation = rotation;
+}
+
+bool QDeclarativeParentChange::rotationIsSet() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->rotation.isValid();
+}
+
+QDeclarativeItem *QDeclarativeParentChange::originalParent() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->origParent;
+}
+
+/*!
+ \qmlproperty Item ParentChange::target
+ This property holds the item to be reparented
+*/
+
+QDeclarativeItem *QDeclarativeParentChange::object() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->target;
+}
+
+void QDeclarativeParentChange::setObject(QDeclarativeItem *target)
+{
+ Q_D(QDeclarativeParentChange);
+ d->target = target;
+}
+
+/*!
+ \qmlproperty Item ParentChange::parent
+ This property holds the parent for the item in this state
+*/
+
+QDeclarativeItem *QDeclarativeParentChange::parent() const
+{
+ Q_D(const QDeclarativeParentChange);
+ return d->parent;
+}
+
+void QDeclarativeParentChange::setParent(QDeclarativeItem *parent)
+{
+ Q_D(QDeclarativeParentChange);
+ d->parent = parent;
+}
+
+QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
+{
+ Q_D(QDeclarativeParentChange);
+ if (!d->target || !d->parent)
+ return ActionList();
+
+ ActionList actions;
+
+ QDeclarativeAction a;
+ a.event = this;
+ actions << a;
+
+ if (d->x.isValid()) {
+ QDeclarativeAction xa(d->target, QLatin1String("x"), x());
+ actions << xa;
+ }
+
+ if (d->y.isValid()) {
+ QDeclarativeAction ya(d->target, QLatin1String("y"), y());
+ actions << ya;
+ }
+
+ if (d->scale.isValid()) {
+ QDeclarativeAction sa(d->target, QLatin1String("scale"), scale());
+ actions << sa;
+ }
+
+ if (d->rotation.isValid()) {
+ QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation());
+ actions << ra;
+ }
+
+ if (d->width.isValid()) {
+ QDeclarativeAction wa(d->target, QLatin1String("width"), width());
+ actions << wa;
+ }
+
+ if (d->height.isValid()) {
+ QDeclarativeAction ha(d->target, QLatin1String("height"), height());
+ actions << ha;
+ }
+
+ return actions;
+}
+
+class AccessibleFxItem : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem)
+public:
+ int siblingIndex() {
+ Q_D(QDeclarativeItem);
+ return d->siblingIndex;
+ }
+};
+
+void QDeclarativeParentChange::saveOriginals()
+{
+ Q_D(QDeclarativeParentChange);
+ saveCurrentValues();
+ d->origParent = d->rewindParent;
+ d->origStackBefore = d->rewindStackBefore;
+}
+
+void QDeclarativeParentChange::execute()
+{
+ Q_D(QDeclarativeParentChange);
+ d->doChange(d->parent);
+}
+
+bool QDeclarativeParentChange::isReversable()
+{
+ return true;
+}
+
+void QDeclarativeParentChange::reverse()
+{
+ Q_D(QDeclarativeParentChange);
+ d->doChange(d->origParent, d->origStackBefore);
+}
+
+QString QDeclarativeParentChange::typeName() const
+{
+ return QLatin1String("ParentChange");
+}
+
+bool QDeclarativeParentChange::override(QDeclarativeActionEvent*other)
+{
+ Q_D(QDeclarativeParentChange);
+ if (other->typeName() != QLatin1String("ParentChange"))
+ return false;
+ if (QDeclarativeParentChange *otherPC = static_cast<QDeclarativeParentChange*>(other))
+ return (d->target == otherPC->object());
+ return false;
+}
+
+void QDeclarativeParentChange::saveCurrentValues()
+{
+ Q_D(QDeclarativeParentChange);
+ if (!d->target) {
+ d->rewindParent = 0;
+ d->rewindStackBefore = 0;
+ return;
+ }
+
+ d->rewindParent = d->target->parentItem();
+
+ if (!d->rewindParent) {
+ d->rewindStackBefore = 0;
+ return;
+ }
+
+ //try to determine the item's original stack position so we can restore it
+ int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1;
+ QList<QGraphicsItem*> children = d->rewindParent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem*>(children.at(i));
+ if (!child)
+ continue;
+ if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) {
+ d->rewindStackBefore = child;
+ break;
+ }
+ }
+}
+
+void QDeclarativeParentChange::rewind()
+{
+ Q_D(QDeclarativeParentChange);
+ d->doChange(d->rewindParent, d->rewindStackBefore);
+}
+
+class QDeclarativeStateChangeScriptPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeStateChangeScriptPrivate() {}
+
+ QDeclarativeScriptString script;
+ QString name;
+};
+
+/*!
+ \qmlclass StateChangeScript QDeclarativeStateChangeScript
+ \brief The StateChangeScript element allows you to run a script in a state.
+
+ The script specified will be run immediately when the state is made current.
+ Alternatively you can use a ScriptAction to specify at which point in the transition
+ you want the StateChangeScript to be run.
+*/
+
+QDeclarativeStateChangeScript::QDeclarativeStateChangeScript(QObject *parent)
+: QDeclarativeStateOperation(*(new QDeclarativeStateChangeScriptPrivate), parent)
+{
+}
+
+QDeclarativeStateChangeScript::~QDeclarativeStateChangeScript()
+{
+}
+
+/*!
+ \qmlproperty script StateChangeScript::script
+ This property holds the script to run when the state is current.
+*/
+QDeclarativeScriptString QDeclarativeStateChangeScript::script() const
+{
+ Q_D(const QDeclarativeStateChangeScript);
+ return d->script;
+}
+
+void QDeclarativeStateChangeScript::setScript(const QDeclarativeScriptString &s)
+{
+ Q_D(QDeclarativeStateChangeScript);
+ d->script = s;
+}
+
+/*!
+ \qmlproperty script StateChangeScript::script
+ This property holds the name of the script. This name can be used by a
+ ScriptAction to target a specific script.
+
+ \sa ScriptAction::stateChangeScriptName
+*/
+QString QDeclarativeStateChangeScript::name() const
+{
+ Q_D(const QDeclarativeStateChangeScript);
+ return d->name;
+}
+
+void QDeclarativeStateChangeScript::setName(const QString &n)
+{
+ Q_D(QDeclarativeStateChangeScript);
+ d->name = n;
+}
+
+void QDeclarativeStateChangeScript::execute()
+{
+ Q_D(QDeclarativeStateChangeScript);
+ const QString &script = d->script.script();
+ if (!script.isEmpty()) {
+ QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject());
+ expr.value();
+ }
+}
+
+QDeclarativeStateChangeScript::ActionList QDeclarativeStateChangeScript::actions()
+{
+ ActionList rv;
+ QDeclarativeAction a;
+ a.event = this;
+ rv << a;
+ return rv;
+}
+
+QString QDeclarativeStateChangeScript::typeName() const
+{
+ return QLatin1String("StateChangeScript");
+}
+
+/*!
+ \qmlclass AnchorChanges QDeclarativeAnchorChanges
+ \brief The AnchorChanges element allows you to change the anchors of an item in a state.
+
+ In the following example we change the top and bottom anchors of an item:
+ \snippet examples/declarative/anchors/anchor-changes.qml 0
+
+ AnchorChanges will 'inject' \c x, \c y, \c width, and \c height changes into the transition,
+ so you can animate them as you would normally changes to these properties:
+ \qml
+ //animate our anchor changes
+ NumberAnimation { targets: content; properties: "x,y,width,height" }
+ \endqml
+
+ For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+
+
+class QDeclarativeAnchorChangesPrivate : public QObjectPrivate
+{
+public:
+ QDeclarativeAnchorChangesPrivate() : target(0) {}
+
+ QString name;
+ QDeclarativeItem *target;
+ QString resetString;
+ QStringList resetList;
+ QDeclarativeAnchorLine left;
+ QDeclarativeAnchorLine right;
+ QDeclarativeAnchorLine horizontalCenter;
+ QDeclarativeAnchorLine top;
+ QDeclarativeAnchorLine bottom;
+ QDeclarativeAnchorLine verticalCenter;
+ QDeclarativeAnchorLine baseline;
+
+ QDeclarativeAnchorLine origLeft;
+ QDeclarativeAnchorLine origRight;
+ QDeclarativeAnchorLine origHCenter;
+ QDeclarativeAnchorLine origTop;
+ QDeclarativeAnchorLine origBottom;
+ QDeclarativeAnchorLine origVCenter;
+ QDeclarativeAnchorLine origBaseline;
+
+ QDeclarativeAnchorLine rewindLeft;
+ QDeclarativeAnchorLine rewindRight;
+ QDeclarativeAnchorLine rewindHCenter;
+ QDeclarativeAnchorLine rewindTop;
+ QDeclarativeAnchorLine rewindBottom;
+ QDeclarativeAnchorLine rewindVCenter;
+ QDeclarativeAnchorLine rewindBaseline;
+
+ qreal fromX;
+ qreal fromY;
+ qreal fromWidth;
+ qreal fromHeight;
+};
+
+/*!
+ \qmlproperty Item AnchorChanges::target
+ This property holds the Item whose anchors will change
+*/
+
+QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent)
+ : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent)
+{
+}
+
+QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges()
+{
+}
+
+QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions()
+{
+ QDeclarativeAction a;
+ a.event = this;
+ return ActionList() << a;
+}
+
+QDeclarativeItem *QDeclarativeAnchorChanges::object() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->target;
+}
+
+void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->target = target;
+}
+
+QString QDeclarativeAnchorChanges::reset() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->resetString;
+}
+
+void QDeclarativeAnchorChanges::setReset(const QString &reset)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->resetString = reset;
+ d->resetList = d->resetString.split(QLatin1Char(','));
+ for (int i = 0; i < d->resetList.count(); ++i)
+ d->resetList[i] = d->resetList.at(i).trimmed();
+}
+
+/*!
+ \qmlproperty AnchorLine AnchorChanges::left
+ \qmlproperty AnchorLine AnchorChanges::right
+ \qmlproperty AnchorLine AnchorChanges::horizontalCenter
+ \qmlproperty AnchorLine AnchorChanges::top
+ \qmlproperty AnchorLine AnchorChanges::bottom
+ \qmlproperty AnchorLine AnchorChanges::verticalCenter
+ \qmlproperty AnchorLine AnchorChanges::baseline
+
+ These properties change the respective anchors of the item.
+*/
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::left() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->left;
+}
+
+void QDeclarativeAnchorChanges::setLeft(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->left = edge;
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::right() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->right;
+}
+
+void QDeclarativeAnchorChanges::setRight(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->right = edge;
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::horizontalCenter() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->horizontalCenter;
+}
+
+void QDeclarativeAnchorChanges::setHorizontalCenter(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->horizontalCenter = edge;
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::top() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->top;
+}
+
+void QDeclarativeAnchorChanges::setTop(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->top = edge;
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::bottom() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->bottom;
+}
+
+void QDeclarativeAnchorChanges::setBottom(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->bottom = edge;
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::verticalCenter() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->verticalCenter;
+}
+
+void QDeclarativeAnchorChanges::setVerticalCenter(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->verticalCenter = edge;
+}
+
+QDeclarativeAnchorLine QDeclarativeAnchorChanges::baseline() const
+{
+ Q_D(const QDeclarativeAnchorChanges);
+ return d->baseline;
+}
+
+void QDeclarativeAnchorChanges::setBaseline(const QDeclarativeAnchorLine &edge)
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->baseline = edge;
+}
+
+void QDeclarativeAnchorChanges::execute()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ if (!d->target)
+ return;
+
+ //set any anchors that have been specified
+ if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setLeft(d->left);
+ if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setRight(d->right);
+ if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setHorizontalCenter(d->horizontalCenter);
+ if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setTop(d->top);
+ if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBottom(d->bottom);
+ if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setVerticalCenter(d->verticalCenter);
+ if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBaseline(d->baseline);
+}
+
+bool QDeclarativeAnchorChanges::isReversable()
+{
+ return true;
+}
+
+void QDeclarativeAnchorChanges::reverse()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ if (!d->target)
+ return;
+
+ //restore previous anchors
+ if (d->origLeft.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setLeft(d->origLeft);
+ if (d->origRight.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setRight(d->origRight);
+ if (d->origHCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setHorizontalCenter(d->origHCenter);
+ if (d->origTop.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setTop(d->origTop);
+ if (d->origBottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBottom(d->origBottom);
+ if (d->origVCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setVerticalCenter(d->origVCenter);
+ if (d->origBaseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBaseline(d->origBaseline);
+}
+
+QString QDeclarativeAnchorChanges::typeName() const
+{
+ return QLatin1String("AnchorChanges");
+}
+
+QList<QDeclarativeAction> QDeclarativeAnchorChanges::extraActions()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ QList<QDeclarativeAction> extra;
+
+ //### try to be smarter about which ones we add.
+ // or short-circuit later on if they haven't actually changed.
+ // we shouldn't set explicit width if there wasn't one before.
+ if (d->target) {
+ QDeclarativeAction a;
+ a.fromValue = d->fromX;
+ a.property = QDeclarativeProperty(d->target, QLatin1String("x"));
+ extra << a;
+
+ a.fromValue = d->fromY;
+ a.property = QDeclarativeProperty(d->target, QLatin1String("y"));
+ extra << a;
+
+ a.fromValue = d->fromWidth;
+ a.property = QDeclarativeProperty(d->target, QLatin1String("width"));
+ extra << a;
+
+ a.fromValue = d->fromHeight;
+ a.property = QDeclarativeProperty(d->target, QLatin1String("height"));
+ extra << a;
+ }
+
+ return extra;
+}
+
+bool QDeclarativeAnchorChanges::changesBindings()
+{
+ return true;
+}
+
+void QDeclarativeAnchorChanges::saveOriginals()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->origLeft = d->target->anchors()->left();
+ d->origRight = d->target->anchors()->right();
+ d->origHCenter = d->target->anchors()->horizontalCenter();
+ d->origTop = d->target->anchors()->top();
+ d->origBottom = d->target->anchors()->bottom();
+ d->origVCenter = d->target->anchors()->verticalCenter();
+ d->origBaseline = d->target->anchors()->baseline();
+
+ saveCurrentValues();
+}
+
+void QDeclarativeAnchorChanges::clearForwardBindings()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->fromX = d->target->x();
+ d->fromY = d->target->y();
+ d->fromWidth = d->target->width();
+ d->fromHeight = d->target->height();
+
+ //reset any anchors that have been specified
+ if (d->resetList.contains(QLatin1String("left")))
+ d->target->anchors()->resetLeft();
+ if (d->resetList.contains(QLatin1String("right")))
+ d->target->anchors()->resetRight();
+ if (d->resetList.contains(QLatin1String("horizontalCenter")))
+ d->target->anchors()->resetHorizontalCenter();
+ if (d->resetList.contains(QLatin1String("top")))
+ d->target->anchors()->resetTop();
+ if (d->resetList.contains(QLatin1String("bottom")))
+ d->target->anchors()->resetBottom();
+ if (d->resetList.contains(QLatin1String("verticalCenter")))
+ d->target->anchors()->resetVerticalCenter();
+ if (d->resetList.contains(QLatin1String("baseline")))
+ d->target->anchors()->resetBaseline();
+
+ //reset any anchors that we'll be setting in the state
+ if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetLeft();
+ if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetRight();
+ if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetHorizontalCenter();
+ if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetTop();
+ if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetBottom();
+ if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetVerticalCenter();
+ if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetBaseline();
+}
+
+void QDeclarativeAnchorChanges::clearReverseBindings()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->fromX = d->target->x();
+ d->fromY = d->target->y();
+ d->fromWidth = d->target->width();
+ d->fromHeight = d->target->height();
+
+ //reset any anchors that were set in the state
+ if (d->left.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetLeft();
+ if (d->right.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetRight();
+ if (d->horizontalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetHorizontalCenter();
+ if (d->top.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetTop();
+ if (d->bottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetBottom();
+ if (d->verticalCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetVerticalCenter();
+ if (d->baseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetBaseline();
+
+ //reset any anchors that were set in the original state
+ if (d->origLeft.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetLeft();
+ if (d->origRight.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetRight();
+ if (d->origHCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetHorizontalCenter();
+ if (d->origTop.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetTop();
+ if (d->origBottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetBottom();
+ if (d->origVCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetVerticalCenter();
+ if (d->origBaseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->resetBaseline();
+}
+
+bool QDeclarativeAnchorChanges::override(QDeclarativeActionEvent*other)
+{
+ if (other->typeName() != QLatin1String("AnchorChanges"))
+ return false;
+ if (static_cast<QDeclarativeActionEvent*>(this) == other)
+ return true;
+ if (static_cast<QDeclarativeAnchorChanges*>(other)->object() == object())
+ return true;
+ return false;
+}
+
+void QDeclarativeAnchorChanges::rewind()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ if (!d->target)
+ return;
+
+ //restore previous anchors
+ if (d->rewindLeft.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setLeft(d->rewindLeft);
+ if (d->rewindRight.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setRight(d->rewindRight);
+ if (d->rewindHCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setHorizontalCenter(d->rewindHCenter);
+ if (d->rewindTop.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setTop(d->rewindTop);
+ if (d->rewindBottom.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBottom(d->rewindBottom);
+ if (d->rewindVCenter.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setVerticalCenter(d->rewindVCenter);
+ if (d->rewindBaseline.anchorLine != QDeclarativeAnchorLine::Invalid)
+ d->target->anchors()->setBaseline(d->rewindBaseline);
+}
+
+void QDeclarativeAnchorChanges::saveCurrentValues()
+{
+ Q_D(QDeclarativeAnchorChanges);
+ d->rewindLeft = d->target->anchors()->left();
+ d->rewindRight = d->target->anchors()->right();
+ d->rewindHCenter = d->target->anchors()->horizontalCenter();
+ d->rewindTop = d->target->anchors()->top();
+ d->rewindBottom = d->target->anchors()->bottom();
+ d->rewindVCenter = d->target->anchors()->verticalCenter();
+ d->rewindBaseline = d->target->anchors()->baseline();
+}
+
+#include <qdeclarativestateoperations.moc>
+#include <moc_qdeclarativestateoperations_p.cpp>
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h
new file mode 100644
index 0000000000..026a64da62
--- /dev/null
+++ b/src/declarative/util/qdeclarativestateoperations_p.h
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVESTATEOPERATIONS_H
+#define QDECLARATIVESTATEOPERATIONS_H
+
+#include "qdeclarativestate_p.h"
+
+#include <qdeclarativeitem.h>
+#include "private/qdeclarativeanchors_p.h"
+#include <qdeclarativescriptstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeParentChangePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeParentChange : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeParentChange)
+
+ Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
+ Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent)
+ 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_PROPERTY(qreal scale READ scale WRITE setScale)
+ Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
+public:
+ QDeclarativeParentChange(QObject *parent=0);
+ ~QDeclarativeParentChange();
+
+ QDeclarativeItem *object() const;
+ void setObject(QDeclarativeItem *);
+
+ QDeclarativeItem *parent() const;
+ void setParent(QDeclarativeItem *);
+
+ QDeclarativeItem *originalParent() const;
+
+ qreal x() const;
+ void setX(qreal x);
+ bool xIsSet() const;
+
+ qreal y() const;
+ void setY(qreal y);
+ bool yIsSet() const;
+
+ qreal width() const;
+ void setWidth(qreal width);
+ bool widthIsSet() const;
+
+ qreal height() const;
+ void setHeight(qreal height);
+ bool heightIsSet() const;
+
+ qreal scale() const;
+ void setScale(qreal scale);
+ bool scaleIsSet() const;
+
+ qreal rotation() const;
+ void setRotation(qreal rotation);
+ bool rotationIsSet() const;
+
+ virtual ActionList actions();
+
+ virtual void saveOriginals();
+ virtual void execute();
+ virtual bool isReversable();
+ virtual void reverse();
+ virtual QString typeName() const;
+ virtual bool override(QDeclarativeActionEvent*other);
+ virtual void rewind();
+ virtual void saveCurrentValues();
+};
+
+class QDeclarativeStateChangeScriptPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeStateChangeScript : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeStateChangeScript)
+
+ Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+public:
+ QDeclarativeStateChangeScript(QObject *parent=0);
+ ~QDeclarativeStateChangeScript();
+
+ virtual ActionList actions();
+
+ virtual QString typeName() const;
+
+ QDeclarativeScriptString script() const;
+ void setScript(const QDeclarativeScriptString &);
+
+ QString name() const;
+ void setName(const QString &);
+
+ virtual void execute();
+};
+
+class QDeclarativeAnchorChangesPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges)
+
+ Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
+ Q_PROPERTY(QString reset READ reset WRITE setReset)
+ Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft)
+ Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight)
+ Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter)
+ Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop)
+ Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom)
+ Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter)
+ Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline)
+
+public:
+ QDeclarativeAnchorChanges(QObject *parent=0);
+ ~QDeclarativeAnchorChanges();
+
+ virtual ActionList actions();
+
+ QDeclarativeItem *object() const;
+ void setObject(QDeclarativeItem *);
+
+ QString reset() const;
+ void setReset(const QString &);
+
+ QDeclarativeAnchorLine left() const;
+ void setLeft(const QDeclarativeAnchorLine &edge);
+
+ QDeclarativeAnchorLine right() const;
+ void setRight(const QDeclarativeAnchorLine &edge);
+
+ QDeclarativeAnchorLine horizontalCenter() const;
+ void setHorizontalCenter(const QDeclarativeAnchorLine &edge);
+
+ QDeclarativeAnchorLine top() const;
+ void setTop(const QDeclarativeAnchorLine &edge);
+
+ QDeclarativeAnchorLine bottom() const;
+ void setBottom(const QDeclarativeAnchorLine &edge);
+
+ QDeclarativeAnchorLine verticalCenter() const;
+ void setVerticalCenter(const QDeclarativeAnchorLine &edge);
+
+ QDeclarativeAnchorLine baseline() const;
+ void setBaseline(const QDeclarativeAnchorLine &edge);
+
+ virtual void execute();
+ virtual bool isReversable();
+ virtual void reverse();
+ virtual QString typeName() const;
+ virtual bool override(QDeclarativeActionEvent*other);
+ virtual QList<QDeclarativeAction> extraActions();
+ virtual bool changesBindings();
+ virtual void saveOriginals();
+ virtual void clearForwardBindings();
+ virtual void clearReverseBindings();
+ virtual void rewind();
+ virtual void saveCurrentValues();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeParentChange)
+QML_DECLARE_TYPE(QDeclarativeStateChangeScript)
+QML_DECLARE_TYPE(QDeclarativeAnchorChanges)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESTATEOPERATIONS_H
diff --git a/src/declarative/util/qdeclarativestyledtext.cpp b/src/declarative/util/qdeclarativestyledtext.cpp
new file mode 100644
index 0000000000..461de1248e
--- /dev/null
+++ b/src/declarative/util/qdeclarativestyledtext.cpp
@@ -0,0 +1,347 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QStack>
+#include <QVector>
+#include <QPainter>
+#include <QTextLayout>
+#include <QDebug>
+#include <qmath.h>
+#include "qdeclarativestyledtext_p.h"
+
+/*
+ QDeclarativeStyledText supports few tags:
+
+ <b></b> - bold
+ <i></i> - italic
+ <br> - new line
+ <font color="color_name" size="1-7"></font>
+
+ The opening and closing tags must be correctly nested.
+*/
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeStyledTextPrivate
+{
+public:
+ QDeclarativeStyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {}
+
+ void parse();
+ bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format);
+ bool parseCloseTag(const QChar *&ch, const QString &textIn);
+ void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut);
+ bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
+ QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
+ QStringRef parseValue(const QChar *&ch, const QString &textIn);
+
+ inline void skipSpace(const QChar *&ch) {
+ while (ch->isSpace() && !ch->isNull())
+ ++ch;
+ }
+
+ QString text;
+ QTextLayout &layout;
+ QFont baseFont;
+
+ static const QChar lessThan;
+ static const QChar greaterThan;
+ static const QChar equals;
+ static const QChar singleQuote;
+ static const QChar doubleQuote;
+ static const QChar slash;
+ static const QChar ampersand;
+};
+
+const QChar QDeclarativeStyledTextPrivate::lessThan(QLatin1Char('<'));
+const QChar QDeclarativeStyledTextPrivate::greaterThan(QLatin1Char('>'));
+const QChar QDeclarativeStyledTextPrivate::equals(QLatin1Char('='));
+const QChar QDeclarativeStyledTextPrivate::singleQuote(QLatin1Char('\''));
+const QChar QDeclarativeStyledTextPrivate::doubleQuote(QLatin1Char('\"'));
+const QChar QDeclarativeStyledTextPrivate::slash(QLatin1Char('/'));
+const QChar QDeclarativeStyledTextPrivate::ampersand(QLatin1Char('&'));
+
+QDeclarativeStyledText::QDeclarativeStyledText(const QString &string, QTextLayout &layout)
+: d(new QDeclarativeStyledTextPrivate(string, layout))
+{
+}
+
+QDeclarativeStyledText::~QDeclarativeStyledText()
+{
+ delete d;
+}
+
+void QDeclarativeStyledText::parse(const QString &string, QTextLayout &layout)
+{
+ if (string.isEmpty())
+ return;
+ QDeclarativeStyledText styledText(string, layout);
+ styledText.d->parse();
+}
+
+void QDeclarativeStyledTextPrivate::parse()
+{
+ QList<QTextLayout::FormatRange> ranges;
+ QStack<QTextCharFormat> formatStack;
+
+ QString drawText;
+ drawText.reserve(text.count());
+
+ int textStart = 0;
+ int textLength = 0;
+ int rangeStart = 0;
+ const QChar *ch = text.constData();
+ while (!ch->isNull()) {
+ if (*ch == lessThan) {
+ if (textLength)
+ drawText.append(QStringRef(&text, textStart, textLength));
+ if (rangeStart != drawText.length() && formatStack.count()) {
+ QTextLayout::FormatRange formatRange;
+ formatRange.format = formatStack.top();
+ formatRange.start = rangeStart;
+ formatRange.length = drawText.length() - rangeStart;
+ ranges.append(formatRange);
+ }
+ rangeStart = drawText.length();
+ ++ch;
+ if (*ch == slash) {
+ ++ch;
+ if (parseCloseTag(ch, text)) {
+ if (formatStack.count())
+ formatStack.pop();
+ }
+ } else {
+ QTextCharFormat format;
+ if (formatStack.count())
+ format = formatStack.top();
+ else
+ format.setFont(baseFont);
+ if (parseTag(ch, text, drawText, format))
+ formatStack.push(format);
+ }
+ textStart = ch - text.constData() + 1;
+ textLength = 0;
+ } else if (*ch == ampersand) {
+ ++ch;
+ drawText.append(QStringRef(&text, textStart, textLength));
+ parseEntity(ch, text, drawText);
+ textStart = ch - text.constData() + 1;
+ textLength = 0;
+ } else {
+ ++textLength;
+ }
+ if (!ch->isNull())
+ ++ch;
+ }
+ if (textLength)
+ drawText.append(QStringRef(&text, textStart, textLength));
+ if (rangeStart != drawText.length() && formatStack.count()) {
+ QTextLayout::FormatRange formatRange;
+ formatRange.format = formatStack.top();
+ formatRange.start = rangeStart;
+ formatRange.length = drawText.length() - rangeStart;
+ ranges.append(formatRange);
+ }
+
+ layout.setText(drawText);
+ layout.setAdditionalFormats(ranges);
+}
+
+bool QDeclarativeStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
+{
+ skipSpace(ch);
+
+ int tagStart = ch - textIn.constData();
+ int tagLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == greaterThan) {
+ QStringRef tag(&textIn, tagStart, tagLength);
+ const QChar char0 = tag.at(0);
+ if (char0 == QLatin1Char('b')) {
+ if (tagLength == 1)
+ format.setFontWeight(QFont::Bold);
+ else if (tagLength == 2 && tag.at(1) == QLatin1Char('r'))
+ textOut.append(QChar(QChar::LineSeparator));
+ } else if (char0 == QLatin1Char('i')) {
+ if (tagLength == 1)
+ format.setFontItalic(true);
+ }
+ return true;
+ } else if (ch->isSpace()) {
+ // may have params.
+ QStringRef tag(&textIn, tagStart, tagLength);
+ if (tag == QLatin1String("font"))
+ return parseFontAttributes(ch, textIn, format);
+ if (*ch == greaterThan || ch->isNull())
+ continue;
+ } else if (*ch != slash){
+ tagLength++;
+ }
+ ++ch;
+ }
+
+ return false;
+}
+
+bool QDeclarativeStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn)
+{
+ skipSpace(ch);
+
+ int tagStart = ch - textIn.constData();
+ int tagLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == greaterThan) {
+ QStringRef tag(&textIn, tagStart, tagLength);
+ const QChar char0 = tag.at(0);
+ if (char0 == QLatin1Char('b')) {
+ if (tagLength == 1)
+ return true;
+ else if (tag.at(1) == QLatin1Char('r') && tagLength == 2)
+ return true;
+ } else if (char0 == QLatin1Char('i')) {
+ if (tagLength == 1)
+ return true;
+ } else if (tag == QLatin1String("font")) {
+ return true;
+ }
+ return false;
+ } else if (!ch->isSpace()){
+ tagLength++;
+ }
+ ++ch;
+ }
+
+ return false;
+}
+
+void QDeclarativeStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut)
+{
+ int entityStart = ch - textIn.constData();
+ int entityLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == QLatin1Char(';')) {
+ QStringRef entity(&textIn, entityStart, entityLength);
+ if (entity == QLatin1String("gt"))
+ textOut += QChar(62);
+ else if (entity == QLatin1String("lt"))
+ textOut += QChar(60);
+ else if (entity == QLatin1String("amp"))
+ textOut += QChar(38);
+ return;
+ }
+ ++entityLength;
+ ++ch;
+ }
+}
+
+bool QDeclarativeStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
+{
+ bool valid = false;
+ QPair<QStringRef,QStringRef> attr;
+ do {
+ attr = parseAttribute(ch, textIn);
+ if (attr.first == QLatin1String("color")) {
+ valid = true;
+ format.setForeground(QColor(attr.second.toString()));
+ } else if (attr.first == QLatin1String("size")) {
+ valid = true;
+ int size = attr.second.toString().toInt();
+ if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+'))
+ size += 3;
+ if (size >= 1 && size <= 7) {
+ static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
+ format.setFontPointSize(baseFont.pointSize() * scaling[size-1]);
+ }
+ }
+ } while (!ch->isNull() && !attr.first.isEmpty());
+
+ return valid;
+}
+
+QPair<QStringRef,QStringRef> QDeclarativeStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
+{
+ skipSpace(ch);
+
+ int attrStart = ch - textIn.constData();
+ int attrLength = 0;
+ while (!ch->isNull()) {
+ if (*ch == greaterThan) {
+ break;
+ } else if (*ch == equals) {
+ ++ch;
+ if (*ch != singleQuote && *ch != doubleQuote) {
+ while (*ch != greaterThan && !ch->isNull())
+ ++ch;
+ break;
+ }
+ ++ch;
+ if (!attrLength)
+ break;
+ QStringRef attr(&textIn, attrStart, attrLength);
+ QStringRef val = parseValue(ch, textIn);
+ if (!val.isEmpty())
+ return QPair<QStringRef,QStringRef>(attr,val);
+ break;
+ } else {
+ ++attrLength;
+ }
+ ++ch;
+ }
+
+ return QPair<QStringRef,QStringRef>();
+}
+
+QStringRef QDeclarativeStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
+{
+ int valStart = ch - textIn.constData();
+ int valLength = 0;
+ while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) {
+ ++valLength;
+ ++ch;
+ }
+ if (ch->isNull())
+ return QStringRef();
+ ++ch; // skip quote
+
+ return QStringRef(&textIn, valStart, valLength);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativestyledtext_p.h b/src/declarative/util/qdeclarativestyledtext_p.h
new file mode 100644
index 0000000000..8d2c42d2ff
--- /dev/null
+++ b/src/declarative/util/qdeclarativestyledtext_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVESTYLEDTEXT_H
+#define QDECLARATIVESTYLEDTEXT_H
+
+#include <QSizeF>
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+class QPointF;
+class QString;
+class QDeclarativeStyledTextPrivate;
+class QTextLayout;
+
+class Q_DECLARATIVE_EXPORT QDeclarativeStyledText
+{
+public:
+ static void parse(const QString &string, QTextLayout &layout);
+
+private:
+ QDeclarativeStyledText(const QString &string, QTextLayout &layout);
+ ~QDeclarativeStyledText();
+
+ QDeclarativeStyledTextPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp
new file mode 100644
index 0000000000..d819c27d6b
--- /dev/null
+++ b/src/declarative/util/qdeclarativesystempalette.cpp
@@ -0,0 +1,304 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativesystempalette_p.h"
+
+#include <QApplication>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeSystemPalettePrivate : public QObjectPrivate
+{
+public:
+ QPalette palette;
+ QPalette::ColorGroup group;
+};
+
+
+
+/*!
+ \qmlclass SystemPalette QDeclarativeSystemPalette
+ \since 4.7
+ \ingroup group_utility
+ \brief The SystemPalette item gives access to the Qt palettes.
+ \sa QPalette
+
+ Example:
+ \qml
+ SystemPalette { id: myPalette; colorGroup: Qt.Active }
+
+ Rectangle {
+ width: 640; height: 480
+ color: myPalette.window
+ Text {
+ anchors.fill: parent
+ text: "Hello!"; color: myPalette.windowText
+ }
+ }
+ \endqml
+*/
+QDeclarativeSystemPalette::QDeclarativeSystemPalette(QObject *parent)
+ : QObject(*(new QDeclarativeSystemPalettePrivate), parent)
+{
+ Q_D(QDeclarativeSystemPalette);
+ d->palette = QApplication::palette();
+ d->group = QPalette::Active;
+ qApp->installEventFilter(this);
+}
+
+QDeclarativeSystemPalette::~QDeclarativeSystemPalette()
+{
+}
+
+/*!
+ \qmlproperty color SystemPalette::window
+ The window (general background) color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::window() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Window);
+}
+
+/*!
+ \qmlproperty color SystemPalette::windowText
+ The window text (general foreground) color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::windowText() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::WindowText);
+}
+
+/*!
+ \qmlproperty color SystemPalette::base
+ The base color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::base() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Base);
+}
+
+/*!
+ \qmlproperty color SystemPalette::text
+ The text color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::text() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Text);
+}
+
+/*!
+ \qmlproperty color SystemPalette::alternateBase
+ The alternate base color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::alternateBase() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::AlternateBase);
+}
+
+/*!
+ \qmlproperty color SystemPalette::button
+ The button color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::button() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Button);
+}
+
+/*!
+ \qmlproperty color SystemPalette::buttonText
+ The button text foreground color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::buttonText() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::ButtonText);
+}
+
+/*!
+ \qmlproperty color SystemPalette::light
+ The light color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::light() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Light);
+}
+
+/*!
+ \qmlproperty color SystemPalette::midlight
+ The midlight color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::midlight() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Midlight);
+}
+
+/*!
+ \qmlproperty color SystemPalette::dark
+ The dark color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::dark() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Dark);
+}
+
+/*!
+ \qmlproperty color SystemPalette::mid
+ The mid color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::mid() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Mid);
+}
+
+/*!
+ \qmlproperty color SystemPalette::shadow
+ The shadow color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::shadow() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Shadow);
+}
+
+/*!
+ \qmlproperty color SystemPalette::highlight
+ The highlight color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::highlight() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::Highlight);
+}
+
+/*!
+ \qmlproperty color SystemPalette::highlightedText
+ The highlighted text color of the current color group.
+
+ \sa QPalette::ColorRole
+*/
+QColor QDeclarativeSystemPalette::highlightedText() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return d->palette.color(d->group, QPalette::HighlightedText);
+}
+
+/*!
+ \qmlproperty QDeclarativeSystemPalette::ColorGroup SystemPalette::colorGroup
+
+ The color group of the palette. It can be Active, Inactive or Disabled.
+ Active is the default.
+
+ \sa QPalette::ColorGroup
+*/
+QDeclarativeSystemPalette::ColorGroup QDeclarativeSystemPalette::colorGroup() const
+{
+ Q_D(const QDeclarativeSystemPalette);
+ return (QDeclarativeSystemPalette::ColorGroup)d->group;
+}
+
+void QDeclarativeSystemPalette::setColorGroup(QDeclarativeSystemPalette::ColorGroup colorGroup)
+{
+ Q_D(QDeclarativeSystemPalette);
+ d->group = (QPalette::ColorGroup)colorGroup;
+ emit paletteChanged();
+}
+
+bool QDeclarativeSystemPalette::eventFilter(QObject *watched, QEvent *event)
+{
+ if (watched == qApp) {
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
+ return false;
+ }
+ }
+ return QObject::eventFilter(watched, event);
+}
+
+bool QDeclarativeSystemPalette::event(QEvent *event)
+{
+ Q_D(QDeclarativeSystemPalette);
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ d->palette = QApplication::palette();
+ emit paletteChanged();
+ return true;
+ }
+ return QObject::event(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativesystempalette_p.h b/src/declarative/util/qdeclarativesystempalette_p.h
new file mode 100644
index 0000000000..9fa6b08594
--- /dev/null
+++ b/src/declarative/util/qdeclarativesystempalette_p.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVESYSTEMPALETTE_H
+#define QDECLARATIVESYSTEMPALETTE_H
+
+#include <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+#include <QPalette>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeSystemPalettePrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeSystemPalette : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(ColorGroup)
+ Q_DECLARE_PRIVATE(QDeclarativeSystemPalette)
+
+ Q_PROPERTY(QDeclarativeSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
+ Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
+ Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
+ Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
+ Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
+ Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
+ Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
+ Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
+ Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
+ Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
+
+public:
+ QDeclarativeSystemPalette(QObject *parent=0);
+ ~QDeclarativeSystemPalette();
+
+ enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
+
+ QColor window() const;
+ QColor windowText() const;
+
+ QColor base() const;
+ QColor text() const;
+ QColor alternateBase() const;
+
+ QColor button() const;
+ QColor buttonText() const;
+
+ QColor light() const;
+ QColor midlight() const;
+ QColor dark() const;
+ QColor mid() const;
+ QColor shadow() const;
+
+ QColor highlight() const;
+ QColor highlightedText() const;
+
+ QDeclarativeSystemPalette::ColorGroup colorGroup() const;
+ void setColorGroup(QDeclarativeSystemPalette::ColorGroup);
+
+Q_SIGNALS:
+ void paletteChanged();
+
+private:
+ bool eventFilter(QObject *watched, QEvent *event);
+ bool event(QEvent *event);
+
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeSystemPalette)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVESYSTEMPALETTE_H
diff --git a/src/declarative/util/qdeclarativetimeline.cpp b/src/declarative/util/qdeclarativetimeline.cpp
new file mode 100644
index 0000000000..8e133b6f86
--- /dev/null
+++ b/src/declarative/util/qdeclarativetimeline.cpp
@@ -0,0 +1,942 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativetimeline_p_p.h"
+
+#include <QDebug>
+#include <QMutex>
+#include <QThread>
+#include <QWaitCondition>
+#include <QEvent>
+#include <QCoreApplication>
+#include <QEasingCurve>
+#include <QTime>
+
+QT_BEGIN_NAMESPACE
+
+struct Update {
+ Update(QDeclarativeTimeLineValue *_g, qreal _v)
+ : g(_g), v(_v) {}
+ Update(const QDeclarativeTimeLineCallback &_e)
+ : g(0), v(0), e(_e) {}
+
+ QDeclarativeTimeLineValue *g;
+ qreal v;
+ QDeclarativeTimeLineCallback e;
+};
+
+struct QDeclarativeTimeLinePrivate
+{
+ QDeclarativeTimeLinePrivate(QDeclarativeTimeLine *);
+
+ struct Op {
+ enum Type {
+ Pause,
+ Set,
+ Move,
+ MoveBy,
+ Accel,
+ AccelDistance,
+ Execute
+ };
+ Op() {}
+ Op(Type t, int l, qreal v, qreal v2, int o,
+ const QDeclarativeTimeLineCallback &ev = QDeclarativeTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
+ : type(t), length(l), value(v), value2(v2), order(o), event(ev),
+ easing(es) {}
+ Op(const Op &o)
+ : type(o.type), length(o.length), value(o.value), value2(o.value2),
+ order(o.order), event(o.event), easing(o.easing) {}
+ Op &operator=(const Op &o) {
+ type = o.type; length = o.length; value = o.value;
+ value2 = o.value2; order = o.order; event = o.event;
+ easing = o.easing;
+ return *this;
+ }
+
+ Type type;
+ int length;
+ qreal value;
+ qreal value2;
+
+ int order;
+ QDeclarativeTimeLineCallback event;
+ QEasingCurve easing;
+ };
+ struct TimeLine
+ {
+ TimeLine() : length(0), consumedOpLength(0), base(0.) {}
+ QList<Op> ops;
+ int length;
+ int consumedOpLength;
+ qreal base;
+ };
+
+ int length;
+ int syncPoint;
+ typedef QHash<QDeclarativeTimeLineObject *, TimeLine> Ops;
+ Ops ops;
+ QDeclarativeTimeLine *q;
+
+ void add(QDeclarativeTimeLineObject &, const Op &);
+ qreal value(const Op &op, int time, qreal base, bool *) const;
+
+ int advance(int);
+
+ bool clockRunning;
+ int prevTime;
+
+ int order;
+
+ QDeclarativeTimeLine::SyncMode syncMode;
+ int syncAdj;
+ QList<QPair<int, Update> > *updateQueue;
+};
+
+QDeclarativeTimeLinePrivate::QDeclarativeTimeLinePrivate(QDeclarativeTimeLine *parent)
+: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QDeclarativeTimeLine::LocalSync), syncAdj(0), updateQueue(0)
+{
+}
+
+void QDeclarativeTimeLinePrivate::add(QDeclarativeTimeLineObject &g, const Op &o)
+{
+ if (g._t && g._t != q) {
+ qWarning() << "QDeclarativeTimeLine: Cannot modify a QDeclarativeTimeLineValue owned by"
+ << "another timeline.";
+ return;
+ }
+ g._t = q;
+
+ Ops::Iterator iter = ops.find(&g);
+ if (iter == ops.end()) {
+ iter = ops.insert(&g, TimeLine());
+ if (syncPoint > 0)
+ q->pause(g, syncPoint);
+ }
+ if (!iter->ops.isEmpty() &&
+ o.type == Op::Pause &&
+ iter->ops.last().type == Op::Pause) {
+ iter->ops.last().length += o.length;
+ iter->length += o.length;
+ } else {
+ iter->ops.append(o);
+ iter->length += o.length;
+ }
+
+ if (iter->length > length)
+ length = iter->length;
+
+ if (!clockRunning) {
+ q->stop();
+ prevTime = 0;
+ clockRunning = true;
+
+ if (syncMode == QDeclarativeTimeLine::LocalSync) {
+ syncAdj = -1;
+ } else {
+ syncAdj = 0;
+ }
+ q->start();
+/* q->tick(0);
+ if (syncMode == QDeclarativeTimeLine::LocalSync) {
+ syncAdj = -1;
+ } else {
+ syncAdj = 0;
+ }
+ */
+ }
+}
+
+qreal QDeclarativeTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const
+{
+ Q_ASSERT(time >= 0);
+ Q_ASSERT(time <= op.length);
+ *changed = true;
+
+ switch(op.type) {
+ case Op::Pause:
+ *changed = false;
+ return base;
+ case Op::Set:
+ return op.value;
+ case Op::Move:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return op.value;
+ } else {
+ qreal delta = op.value - base;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if (op.easing.type() == QEasingCurve::Linear)
+ return base + delta * pTime;
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
+ }
+ case Op::MoveBy:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return base + op.value;
+ } else {
+ qreal delta = op.value;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if (op.easing.type() == QEasingCurve::Linear)
+ return base + delta * pTime;
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
+ }
+ case Op::Accel:
+ if (time == 0) {
+ return base;
+ } else {
+ qreal t = (qreal)(time) / 1000.0f;
+ qreal delta = op.value * t + 0.5f * op.value2 * t * t;
+ return base + delta;
+ }
+ case Op::AccelDistance:
+ if (time == 0) {
+ return base;
+ } else if (time == (op.length)) {
+ return base + op.value2;
+ } else {
+ qreal t = (qreal)(time) / 1000.0f;
+ qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length;
+ qreal delta = op.value * t + 0.5f * accel * t * t;
+ return base + delta;
+
+ }
+ case Op::Execute:
+ op.event.d0(op.event.d1);
+ *changed = false;
+ return -1;
+ }
+
+ return base;
+}
+
+/*!
+ \internal
+ \class QDeclarativeTimeLine
+ \ingroup group_animation
+ \brief The QDeclarativeTimeLine class provides a timeline for controlling animations.
+
+ QDeclarativeTimeLine is similar to QTimeLine except:
+ \list
+ \i It updates QDeclarativeTimeLineValue instances directly, rather than maintaining a single
+ current value.
+
+ For example, the following animates a simple value over 200 milliseconds:
+ \code
+ QDeclarativeTimeLineValue v(<starting value>);
+ QDeclarativeTimeLine tl;
+ tl.move(v, 100., 200);
+ tl.start()
+ \endcode
+
+ If your program needs to know when values are changed, it can either
+ connect to the QDeclarativeTimeLine's updated() signal, or inherit from QDeclarativeTimeLineValue
+ and reimplement the QDeclarativeTimeLineValue::setValue() method.
+
+ \i Supports multiple QDeclarativeTimeLineValue, arbitrary start and end values and allows
+ animations to be strung together for more complex effects.
+
+ For example, the following animation moves the x and y coordinates of
+ an object from wherever they are to the position (100, 100) in 50
+ milliseconds and then further animates them to (100, 200) in 50
+ milliseconds:
+
+ \code
+ QDeclarativeTimeLineValue x(<starting value>);
+ QDeclarativeTimeLineValue y(<starting value>);
+
+ QDeclarativeTimeLine tl;
+ tl.start();
+
+ tl.move(x, 100., 50);
+ tl.move(y, 100., 50);
+ tl.move(y, 200., 50);
+ \endcode
+
+ \i All QDeclarativeTimeLine instances share a single, synchronized clock.
+
+ Actions scheduled within the same event loop tick are scheduled
+ synchronously against each other, regardless of the wall time between the
+ scheduling. Synchronized scheduling applies both to within the same
+ QDeclarativeTimeLine and across separate QDeclarativeTimeLine's within the same process.
+
+ \endlist
+
+ Currently easing functions are not supported.
+*/
+
+
+/*!
+ Construct a new QDeclarativeTimeLine with the specified \a parent.
+*/
+QDeclarativeTimeLine::QDeclarativeTimeLine(QObject *parent)
+: QAbstractAnimation(parent)
+{
+ d = new QDeclarativeTimeLinePrivate(this);
+}
+
+/*!
+ Destroys the time line. Any inprogress animations are canceled, but not
+ completed.
+*/
+QDeclarativeTimeLine::~QDeclarativeTimeLine()
+{
+ for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter)
+ iter.key()->_t = 0;
+
+ delete d; d = 0;
+}
+
+/*!
+ \enum QDeclarativeTimeLine::SyncMode
+ */
+
+/*!
+ Return the timeline's synchronization mode.
+ */
+QDeclarativeTimeLine::SyncMode QDeclarativeTimeLine::syncMode() const
+{
+ return d->syncMode;
+}
+
+/*!
+ Set the timeline's synchronization mode to \a syncMode.
+ */
+void QDeclarativeTimeLine::setSyncMode(SyncMode syncMode)
+{
+ d->syncMode = syncMode;
+}
+
+/*!
+ Pause \a obj for \a time milliseconds.
+*/
+void QDeclarativeTimeLine::pause(QDeclarativeTimeLineObject &obj, int time)
+{
+ if (time <= 0) return;
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Pause, time, 0., 0., d->order++);
+ d->add(obj, op);
+}
+
+/*!
+ Execute the \a event.
+ */
+void QDeclarativeTimeLine::callback(const QDeclarativeTimeLineCallback &callback)
+{
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
+ d->add(*callback.callbackObject(), op);
+}
+
+/*!
+ Set the \a value of \a timeLineValue.
+*/
+void QDeclarativeTimeLine::set(QDeclarativeTimeLineValue &timeLineValue, qreal value)
+{
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
+ given \a acceleration rate. Although the \a acceleration is technically
+ a deceleration, it should always be positive. The QDeclarativeTimeLine will ensure
+ that the deceleration is in the opposite direction to the initial velocity.
+*/
+int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
+{
+ if ((velocity > 0.0f) == (acceleration > 0.0f))
+ acceleration = acceleration * -1.0f;
+
+ int time = static_cast<int>(-1000 * velocity / acceleration);
+
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ \overload
+
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
+ given \a acceleration rate over a maximum distance of maxDistance.
+
+ If necessary, QDeclarativeTimeLine will reduce the acceleration to ensure that the
+ entire operation does not require a move of more than \a maxDistance.
+ \a maxDistance should always be positive.
+*/
+int QDeclarativeTimeLine::accel(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
+{
+ Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f);
+
+ qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance);
+ if (maxAccel > acceleration)
+ acceleration = maxAccel;
+
+ if ((velocity > 0.0f) == (acceleration > 0.0f))
+ acceleration = acceleration * -1.0f;
+
+ int time = static_cast<int>(-1000 * velocity / acceleration);
+
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ Decelerate \a timeLineValue from the starting \a velocity to zero over the given
+ \a distance. This is like accel(), but the QDeclarativeTimeLine calculates the exact
+ deceleration to use.
+
+ \a distance should be positive.
+*/
+int QDeclarativeTimeLine::accelDistance(QDeclarativeTimeLineValue &timeLineValue, qreal velocity, qreal distance)
+{
+ if (distance == 0.0f || velocity == 0.0f)
+ return -1;
+ Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f));
+
+ int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
+
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
+ d->add(timeLineValue, op);
+
+ return time;
+}
+
+/*!
+ Linearly change the \a timeLineValue from its current value to the given
+ \a destination value over \a time milliseconds.
+*/
+void QDeclarativeTimeLine::move(QDeclarativeTimeLineValue &timeLineValue, qreal destination, int time)
+{
+ if (time <= 0) return;
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Change the \a timeLineValue from its current value to the given \a destination
+ value over \a time milliseconds using the \a easing curve.
+ */
+void QDeclarativeTimeLine::move(QDeclarativeTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
+{
+ if (time <= 0) return;
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QDeclarativeTimeLineCallback(), easing);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Linearly change the \a timeLineValue from its current value by the \a change amount
+ over \a time milliseconds.
+*/
+void QDeclarativeTimeLine::moveBy(QDeclarativeTimeLineValue &timeLineValue, qreal change, int time)
+{
+ if (time <= 0) return;
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Change the \a timeLineValue from its current value by the \a change amount over
+ \a time milliseconds using the \a easing curve.
+ */
+void QDeclarativeTimeLine::moveBy(QDeclarativeTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
+{
+ if (time <= 0) return;
+ QDeclarativeTimeLinePrivate::Op op(QDeclarativeTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QDeclarativeTimeLineCallback(), easing);
+ d->add(timeLineValue, op);
+}
+
+/*!
+ Cancel (but don't complete) all scheduled actions for \a timeLineValue.
+*/
+void QDeclarativeTimeLine::reset(QDeclarativeTimeLineValue &timeLineValue)
+{
+ if (!timeLineValue._t)
+ return;
+ if (timeLineValue._t != this) {
+ qWarning() << "QDeclarativeTimeLine: Cannot reset a QDeclarativeTimeLineValue owned by another timeline.";
+ return;
+ }
+ remove(&timeLineValue);
+ timeLineValue._t = 0;
+}
+
+int QDeclarativeTimeLine::duration() const
+{
+ return -1;
+}
+
+/*!
+ Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
+ within this timeline.
+
+ Following operations on \a timeLineValue in this timeline will be scheduled after
+ all the currently scheduled actions on \a syncTo are complete. In
+ psuedo-code this is equivalent to:
+ \code
+ QDeclarativeTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
+ \endcode
+*/
+void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue, QDeclarativeTimeLineValue &syncTo)
+{
+ QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
+ if (iter == d->ops.end())
+ return;
+ int length = iter->length;
+
+ iter = d->ops.find(&timeLineValue);
+ if (iter == d->ops.end()) {
+ pause(timeLineValue, length);
+ } else {
+ int glength = iter->length;
+ pause(timeLineValue, length - glength);
+ }
+}
+
+/*!
+ Synchronize the end point of \a timeLineValue to the endpoint of the longest
+ action cursrently scheduled in the timeline.
+
+ In psuedo-code, this is equivalent to:
+ \code
+ QDeclarativeTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
+ \endcode
+*/
+void QDeclarativeTimeLine::sync(QDeclarativeTimeLineValue &timeLineValue)
+{
+ QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
+ if (iter == d->ops.end()) {
+ pause(timeLineValue, d->length);
+ } else {
+ pause(timeLineValue, d->length - iter->length);
+ }
+}
+
+/*
+ Synchronize all currently and future scheduled values in this timeline to
+ the longest action currently scheduled.
+
+ For example:
+ \code
+ value1->setValue(0.);
+ value2->setValue(0.);
+ value3->setValue(0.);
+ QDeclarativeTimeLine tl;
+ ...
+ tl.move(value1, 10, 200);
+ tl.move(value2, 10, 100);
+ tl.sync();
+ tl.move(value2, 20, 100);
+ tl.move(value3, 20, 100);
+ \endcode
+
+ will result in:
+
+ \table
+ \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms
+ \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10
+ \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0
+ \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0
+ \endtable
+*/
+
+/*void QDeclarativeTimeLine::sync()
+{
+ for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter)
+ pause(*iter.key(), d->length - iter->length);
+ d->syncPoint = d->length;
+}*/
+
+/*!
+ \internal
+
+ Temporary hack.
+ */
+void QDeclarativeTimeLine::setSyncPoint(int sp)
+{
+ d->syncPoint = sp;
+}
+
+/*!
+ \internal
+
+ Temporary hack.
+ */
+int QDeclarativeTimeLine::syncPoint() const
+{
+ return d->syncPoint;
+}
+
+/*!
+ Returns true if the timeline is active. An active timeline is one where
+ QDeclarativeTimeLineValue actions are still pending.
+*/
+bool QDeclarativeTimeLine::isActive() const
+{
+ return !d->ops.isEmpty();
+}
+
+/*!
+ Completes the timeline. All queued actions are played to completion, and then discarded. For example,
+ \code
+ QDeclarativeTimeLineValue v(0.);
+ QDeclarativeTimeLine tl;
+ tl.move(v, 100., 1000.);
+ // 500 ms passes
+ // v.value() == 50.
+ tl.complete();
+ // v.value() == 100.
+ \endcode
+*/
+void QDeclarativeTimeLine::complete()
+{
+ d->advance(d->length);
+}
+
+/*!
+ Resets the timeline. All queued actions are discarded and QDeclarativeTimeLineValue's retain their current value. For example,
+ \code
+ QDeclarativeTimeLineValue v(0.);
+ QDeclarativeTimeLine tl;
+ tl.move(v, 100., 1000.);
+ // 500 ms passes
+ // v.value() == 50.
+ tl.clear();
+ // v.value() == 50.
+ \endcode
+*/
+void QDeclarativeTimeLine::clear()
+{
+ for (QDeclarativeTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter)
+ iter.key()->_t = 0;
+ d->ops.clear();
+ d->length = 0;
+ d->syncPoint = 0;
+ //XXX need stop here?
+}
+
+int QDeclarativeTimeLine::time() const
+{
+ return d->prevTime;
+}
+
+/*!
+ \fn void QDeclarativeTimeLine::updated()
+
+ Emitted each time the timeline modifies QDeclarativeTimeLineValues. Even if multiple
+ QDeclarativeTimeLineValues are changed, this signal is only emitted once for each clock tick.
+*/
+
+void QDeclarativeTimeLine::updateCurrentTime(int v)
+{
+ if (d->syncAdj == -1)
+ d->syncAdj = v;
+ v -= d->syncAdj;
+
+ int timeChanged = v - d->prevTime;
+#if 0
+ if (!timeChanged)
+ return;
+#endif
+ d->prevTime = v;
+ d->advance(timeChanged);
+ emit updated();
+
+ // Do we need to stop the clock?
+ if (d->ops.isEmpty()) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = false;
+ emit completed();
+ } /*else if (pauseTime > 0) {
+ GfxClock::cancelClock();
+ d->prevTime = 0;
+ GfxClock::pauseFor(pauseTime);
+ d->syncAdj = 0;
+ d->clockRunning = false;
+ }*/ else if (/*!GfxClock::isActive()*/ state() != Running) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = true;
+ d->syncAdj = 0;
+ start();
+ }
+}
+
+bool operator<(const QPair<int, Update> &lhs,
+ const QPair<int, Update> &rhs)
+{
+ return lhs.first < rhs.first;
+}
+
+int QDeclarativeTimeLinePrivate::advance(int t)
+{
+ int pauseTime = -1;
+
+ // XXX - surely there is a more efficient way?
+ do {
+ pauseTime = -1;
+ // Minimal advance time
+ int advanceTime = t;
+ for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) {
+ TimeLine &tl = *iter;
+ Op &op = tl.ops.first();
+ int length = op.length - tl.consumedOpLength;
+
+ if (length < advanceTime) {
+ advanceTime = length;
+ if (advanceTime == 0)
+ break;
+ }
+ }
+ t -= advanceTime;
+
+ // Process until then. A zero length advance time will only process
+ // sets.
+ QList<QPair<int, Update> > updates;
+
+ for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
+ QDeclarativeTimeLineValue *v = static_cast<QDeclarativeTimeLineValue *>(iter.key());
+ TimeLine &tl = *iter;
+ Q_ASSERT(!tl.ops.isEmpty());
+
+ do {
+ Op &op = tl.ops.first();
+ if (advanceTime == 0 && op.length != 0)
+ continue;
+
+ if (tl.consumedOpLength == 0 &&
+ op.type != Op::Pause &&
+ op.type != Op::Execute)
+ tl.base = v->value();
+
+ if ((tl.consumedOpLength + advanceTime) == op.length) {
+ if (op.type == Op::Execute) {
+ updates << qMakePair(op.order, Update(op.event));
+ } else {
+ bool changed = false;
+ qreal val = value(op, op.length, tl.base, &changed);
+ if (changed)
+ updates << qMakePair(op.order, Update(v, val));
+ }
+ tl.length -= qMin(advanceTime, tl.length);
+ tl.consumedOpLength = 0;
+ tl.ops.removeFirst();
+ } else {
+ tl.consumedOpLength += advanceTime;
+ bool changed = false;
+ qreal val = value(op, tl.consumedOpLength, tl.base, &changed);
+ if (changed)
+ updates << qMakePair(op.order, Update(v, val));
+ tl.length -= qMin(advanceTime, tl.length);
+ break;
+ }
+
+ } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0);
+
+
+ if (tl.ops.isEmpty()) {
+ iter = ops.erase(iter);
+ v->_t = 0;
+ } else {
+ if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
+ int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
+ if (pauseTime == -1 || opPauseTime < pauseTime)
+ pauseTime = opPauseTime;
+ } else {
+ pauseTime = 0;
+ }
+ ++iter;
+ }
+ }
+
+ length -= qMin(length, advanceTime);
+ syncPoint -= advanceTime;
+
+ qSort(updates.begin(), updates.end());
+ updateQueue = &updates;
+ for (int ii = 0; ii < updates.count(); ++ii) {
+ const Update &v = updates.at(ii).second;
+ if (v.g) {
+ v.g->setValue(v.v);
+ } else {
+ v.e.d0(v.e.d1);
+ }
+ }
+ updateQueue = 0;
+ } while(t);
+
+ return pauseTime;
+}
+
+void QDeclarativeTimeLine::remove(QDeclarativeTimeLineObject *v)
+{
+ QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.find(v);
+ Q_ASSERT(iter != d->ops.end());
+
+ int len = iter->length;
+ d->ops.erase(iter);
+ if (len == d->length) {
+ // We need to recalculate the length
+ d->length = 0;
+ for (QDeclarativeTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
+ iter != d->ops.end();
+ ++iter) {
+
+ if (iter->length > d->length)
+ d->length = iter->length;
+
+ }
+ }
+ if (d->ops.isEmpty()) {
+ stop();
+ d->clockRunning = false;
+ } else if (/*!GfxClock::isActive()*/ state() != Running) {
+ stop();
+ d->prevTime = 0;
+ d->clockRunning = true;
+
+ if (d->syncMode == QDeclarativeTimeLine::LocalSync) {
+ d->syncAdj = -1;
+ } else {
+ d->syncAdj = 0;
+ }
+ start();
+ }
+
+ if (d->updateQueue) {
+ for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
+ if (d->updateQueue->at(ii).second.g == v ||
+ d->updateQueue->at(ii).second.e.callbackObject() == v) {
+ d->updateQueue->removeAt(ii);
+ --ii;
+ }
+ }
+ }
+
+
+}
+
+/*!
+ \internal
+ \class QDeclarativeTimeLineValue
+ \ingroup group_animation
+ \brief The QDeclarativeTimeLineValue class provides a value that can be modified by QDeclarativeTimeLine.
+*/
+
+/*!
+ \fn QDeclarativeTimeLineValue::QDeclarativeTimeLineValue(qreal value = 0)
+
+ Construct a new QDeclarativeTimeLineValue with an initial \a value.
+*/
+
+/*!
+ \fn qreal QDeclarativeTimeLineValue::value() const
+
+ Return the current value.
+*/
+
+/*!
+ \fn void QDeclarativeTimeLineValue::setValue(qreal value)
+
+ Set the current \a value.
+*/
+
+/*!
+ \fn QDeclarativeTimeLine *QDeclarativeTimeLineValue::timeLine() const
+
+ If a QDeclarativeTimeLine is operating on this value, return a pointer to it,
+ otherwise return null.
+*/
+
+
+QDeclarativeTimeLineObject::QDeclarativeTimeLineObject()
+: _t(0)
+{
+}
+
+QDeclarativeTimeLineObject::~QDeclarativeTimeLineObject()
+{
+ if (_t) {
+ _t->remove(this);
+ _t = 0;
+ }
+}
+
+QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback()
+: d0(0), d1(0), d2(0)
+{
+}
+
+QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback(QDeclarativeTimeLineObject *b, Callback f, void *d)
+: d0(f), d1(d), d2(b)
+{
+}
+
+QDeclarativeTimeLineCallback::QDeclarativeTimeLineCallback(const QDeclarativeTimeLineCallback &o)
+: d0(o.d0), d1(o.d1), d2(o.d2)
+{
+}
+
+QDeclarativeTimeLineCallback &QDeclarativeTimeLineCallback::operator=(const QDeclarativeTimeLineCallback &o)
+{
+ d0 = o.d0;
+ d1 = o.d1;
+ d2 = o.d2;
+ return *this;
+}
+
+QDeclarativeTimeLineObject *QDeclarativeTimeLineCallback::callbackObject() const
+{
+ return d2;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativetimeline_p_p.h b/src/declarative/util/qdeclarativetimeline_p_p.h
new file mode 100644
index 0000000000..c08c07cb5e
--- /dev/null
+++ b/src/declarative/util/qdeclarativetimeline_p_p.h
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVETIMELINE_H
+#define QDECLARATIVETIMELINE_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>
+#include <QtCore/QAbstractAnimation>
+
+QT_BEGIN_NAMESPACE
+
+class QEasingCurve;
+class QDeclarativeTimeLineValue;
+class QDeclarativeTimeLineCallback;
+struct QDeclarativeTimeLinePrivate;
+class QDeclarativeTimeLineObject;
+class QDeclarativeTimeLine : public QAbstractAnimation
+{
+Q_OBJECT
+public:
+ QDeclarativeTimeLine(QObject *parent = 0);
+ ~QDeclarativeTimeLine();
+
+ enum SyncMode { LocalSync, GlobalSync };
+ SyncMode syncMode() const;
+ void setSyncMode(SyncMode);
+
+ void pause(QDeclarativeTimeLineObject &, int);
+ void callback(const QDeclarativeTimeLineCallback &);
+ void set(QDeclarativeTimeLineValue &, qreal);
+
+ int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel);
+ int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
+ int accelDistance(QDeclarativeTimeLineValue &, qreal velocity, qreal distance);
+
+ void move(QDeclarativeTimeLineValue &, qreal destination, int time = 500);
+ void move(QDeclarativeTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
+ void moveBy(QDeclarativeTimeLineValue &, qreal change, int time = 500);
+ void moveBy(QDeclarativeTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
+
+ void sync();
+ void setSyncPoint(int);
+ int syncPoint() const;
+
+ void sync(QDeclarativeTimeLineValue &);
+ void sync(QDeclarativeTimeLineValue &, QDeclarativeTimeLineValue &);
+
+ void reset(QDeclarativeTimeLineValue &);
+
+ void complete();
+ void clear();
+ bool isActive() const;
+
+ int time() const;
+
+ virtual int duration() const;
+Q_SIGNALS:
+ void updated();
+ void completed();
+
+protected:
+ virtual void updateCurrentTime(int);
+
+private:
+ void remove(QDeclarativeTimeLineObject *);
+ friend class QDeclarativeTimeLineObject;
+ friend struct QDeclarativeTimeLinePrivate;
+ QDeclarativeTimeLinePrivate *d;
+};
+
+class QDeclarativeTimeLineObject
+{
+public:
+ QDeclarativeTimeLineObject();
+ virtual ~QDeclarativeTimeLineObject();
+
+protected:
+ friend class QDeclarativeTimeLine;
+ friend struct QDeclarativeTimeLinePrivate;
+ QDeclarativeTimeLine *_t;
+};
+
+class QDeclarativeTimeLineValue : public QDeclarativeTimeLineObject
+{
+public:
+ QDeclarativeTimeLineValue(qreal v = 0.) : _v(v) {}
+
+ virtual qreal value() const { return _v; }
+ virtual void setValue(qreal v) { _v = v; }
+
+ QDeclarativeTimeLine *timeLine() const { return _t; }
+
+ operator qreal() const { return _v; }
+ QDeclarativeTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
+private:
+ friend class QDeclarativeTimeLine;
+ friend struct QDeclarativeTimeLinePrivate;
+ qreal _v;
+};
+
+class QDeclarativeTimeLineCallback
+{
+public:
+ typedef void (*Callback)(void *);
+
+ QDeclarativeTimeLineCallback();
+ QDeclarativeTimeLineCallback(QDeclarativeTimeLineObject *b, Callback, void * = 0);
+ QDeclarativeTimeLineCallback(const QDeclarativeTimeLineCallback &o);
+
+ QDeclarativeTimeLineCallback &operator=(const QDeclarativeTimeLineCallback &o);
+ QDeclarativeTimeLineObject *callbackObject() const;
+
+private:
+ friend class QDeclarativeTimeLinePrivate;
+ Callback d0;
+ void *d1;
+ QDeclarativeTimeLineObject *d2;
+};
+
+template<class T>
+class QDeclarativeTimeLineValueProxy : public QDeclarativeTimeLineValue
+{
+public:
+ QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
+ : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
+ {
+ Q_ASSERT(_class);
+ }
+
+ QDeclarativeTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
+ : QDeclarativeTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
+ {
+ Q_ASSERT(_class);
+ }
+
+ virtual void setValue(qreal v)
+ {
+ QDeclarativeTimeLineValue::setValue(v);
+ if (_setFunctionReal) (_class->*_setFunctionReal)(v);
+ else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
+ }
+
+private:
+ T *_class;
+ void (T::*_setFunctionReal)(qreal);
+ void (T::*_setFunctionInt)(int);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/util/qdeclarativetimer.cpp b/src/declarative/util/qdeclarativetimer.cpp
new file mode 100644
index 0000000000..d7e02b163e
--- /dev/null
+++ b/src/declarative/util/qdeclarativetimer.cpp
@@ -0,0 +1,314 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativetimer_p.h"
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qpauseanimation.h>
+#include <qdebug.h>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+class QDeclarativeTimerPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeTimer)
+public:
+ QDeclarativeTimerPrivate()
+ : interval(1000), running(false), repeating(false), triggeredOnStart(false)
+ , classBegun(false), componentComplete(false), firstTick(true) {}
+ int interval;
+ QPauseAnimation pause;
+ bool running : 1;
+ bool repeating : 1;
+ bool triggeredOnStart : 1;
+ bool classBegun : 1;
+ bool componentComplete : 1;
+ bool firstTick : 1;
+};
+
+/*!
+ \qmlclass Timer QDeclarativeTimer
+ \since 4.7
+ \brief The Timer item triggers a handler at a specified interval.
+
+ A timer can be used to trigger an action either once, or repeatedly
+ at a given interval.
+
+ Here is a timer that shows the current date and time, and updates
+ the text every 500 milliseconds:
+
+ \qml
+ Timer {
+ interval: 500; running: true; repeat: true
+ onTriggered: time.text = Date().toString()
+ }
+ Text {
+ id: time
+ }
+ \endqml
+
+ QDeclarativeTimer is synchronized with the animation timer. Since the animation
+ timer is usually set to 60fps, the resolution of QDeclarativeTimer will be
+ at best 16ms.
+
+ If the Timer is running and one of its properties is changed, the
+ elapsed time will be reset. For example, if a Timer with interval of
+ 1000ms has its \e repeat property changed 500ms after starting, the
+ elapsed time will be reset to 0, and the Timer will be triggered
+ 1000ms later.
+*/
+
+QDeclarativeTimer::QDeclarativeTimer(QObject *parent)
+ : QObject(*(new QDeclarativeTimerPrivate), parent)
+{
+ Q_D(QDeclarativeTimer);
+ connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked()));
+ connect(&d->pause, SIGNAL(finished()), this, SLOT(finished()));
+ d->pause.setLoopCount(1);
+ d->pause.setDuration(d->interval);
+}
+
+/*!
+ \qmlproperty int Timer::interval
+
+ Sets the \a interval between triggers, in milliseconds.
+
+ The default interval is 1000 milliseconds.
+*/
+void QDeclarativeTimer::setInterval(int interval)
+{
+ Q_D(QDeclarativeTimer);
+ if (interval != d->interval) {
+ d->interval = interval;
+ update();
+ }
+}
+
+int QDeclarativeTimer::interval() const
+{
+ Q_D(const QDeclarativeTimer);
+ return d->interval;
+}
+
+/*!
+ \qmlproperty bool Timer::running
+
+ If set to true, starts the timer; otherwise stops the timer.
+ For a non-repeating timer, \a running is set to false after the
+ timer has been triggered.
+
+ \a running defaults to false.
+
+ \sa repeat
+*/
+bool QDeclarativeTimer::isRunning() const
+{
+ Q_D(const QDeclarativeTimer);
+ return d->running;
+}
+
+void QDeclarativeTimer::setRunning(bool running)
+{
+ Q_D(QDeclarativeTimer);
+ if (d->running != running) {
+ d->running = running;
+ d->firstTick = true;
+ emit runningChanged();
+ update();
+ }
+}
+
+/*!
+ \qmlproperty bool Timer::repeat
+
+ If \a repeat is true the timer is triggered repeatedly at the
+ specified interval; otherwise, the timer will trigger once at the
+ specified interval and then stop (i.e. running will be set to false).
+
+ \a repeat defaults to false.
+
+ \sa running
+*/
+bool QDeclarativeTimer::isRepeating() const
+{
+ Q_D(const QDeclarativeTimer);
+ return d->repeating;
+}
+
+void QDeclarativeTimer::setRepeating(bool repeating)
+{
+ Q_D(QDeclarativeTimer);
+ if (repeating != d->repeating) {
+ d->repeating = repeating;
+ update();
+ }
+}
+
+/*!
+ \qmlproperty bool Timer::triggeredOnStart
+
+ When a timer is started, the first trigger is usually after the specified
+ interval has elapsed. It is sometimes desirable to trigger immediately
+ when the timer is started; for example, to establish an initial
+ state.
+
+ If \a triggeredOnStart is true, the timer is triggered immediately
+ when started, and subsequently at the specified interval. Note that if
+ \e repeat is set to false, the timer is triggered twice; once on start,
+ and again at the interval.
+
+ \a triggeredOnStart defaults to false.
+
+ \sa running
+*/
+bool QDeclarativeTimer::triggeredOnStart() const
+{
+ Q_D(const QDeclarativeTimer);
+ return d->triggeredOnStart;
+}
+
+void QDeclarativeTimer::setTriggeredOnStart(bool triggeredOnStart)
+{
+ Q_D(QDeclarativeTimer);
+ if (d->triggeredOnStart != triggeredOnStart) {
+ d->triggeredOnStart = triggeredOnStart;
+ update();
+ }
+}
+
+/*!
+ \qmlmethod Timer::start()
+ \brief Starts the timer.
+
+ If the timer is already running, calling this method has no effect. The
+ \c running property will be true following a call to \c start().
+*/
+void QDeclarativeTimer::start()
+{
+ setRunning(true);
+}
+
+/*!
+ \qmlmethod Timer::stop()
+ \brief Stops the timer.
+
+ If the timer is not running, calling this method has no effect. The
+ \c running property will be false following a call to \c stop().
+*/
+void QDeclarativeTimer::stop()
+{
+ setRunning(false);
+}
+
+/*!
+ \qmlmethod Timer::restart()
+ \brief Restarts the timer.
+
+ If the Timer is not running it will be started, otherwise it will be
+ stopped, reset to initial state and started. The \c running property
+ will be true following a call to \c restart().
+*/
+void QDeclarativeTimer::restart()
+{
+ setRunning(false);
+ setRunning(true);
+}
+
+void QDeclarativeTimer::update()
+{
+ Q_D(QDeclarativeTimer);
+ if (d->classBegun && !d->componentComplete)
+ return;
+ d->pause.stop();
+ if (d->running) {
+ d->pause.setCurrentTime(0);
+ d->pause.setLoopCount(d->repeating ? -1 : 1);
+ d->pause.setDuration(d->interval);
+ d->pause.start();
+ if (d->triggeredOnStart && d->firstTick) {
+ QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
+ QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection);
+ }
+ }
+}
+
+void QDeclarativeTimer::classBegin()
+{
+ Q_D(QDeclarativeTimer);
+ d->classBegun = true;
+}
+
+void QDeclarativeTimer::componentComplete()
+{
+ Q_D(QDeclarativeTimer);
+ d->componentComplete = true;
+ update();
+}
+
+/*!
+ \qmlsignal Timer::onTriggered()
+
+ This handler is called when the Timer is triggered.
+*/
+void QDeclarativeTimer::ticked()
+{
+ Q_D(QDeclarativeTimer);
+ if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick)))
+ emit triggered();
+ d->firstTick = false;
+}
+
+void QDeclarativeTimer::finished()
+{
+ Q_D(QDeclarativeTimer);
+ if (d->repeating || !d->running)
+ return;
+ emit triggered();
+ d->running = false;
+ d->firstTick = false;
+ emit runningChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativetimer_p.h b/src/declarative/util/qdeclarativetimer_p.h
new file mode 100644
index 0000000000..e063657011
--- /dev/null
+++ b/src/declarative/util/qdeclarativetimer_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 QDECLARATIVETIMER_H
+#define QDECLARATIVETIMER_H
+
+#include <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+#include <QtCore/qabstractanimation.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeTimerPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeTimer : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeTimer)
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_PROPERTY(int interval READ interval WRITE setInterval)
+ Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating)
+ Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart)
+
+public:
+ QDeclarativeTimer(QObject *parent=0);
+
+ void setInterval(int interval);
+ int interval() const;
+
+ bool isRunning() const;
+ void setRunning(bool running);
+
+ bool isRepeating() const;
+ void setRepeating(bool repeating);
+
+ bool triggeredOnStart() const;
+ void setTriggeredOnStart(bool triggeredOnStart);
+
+protected:
+ void classBegin();
+ void componentComplete();
+
+public Q_SLOTS:
+ void start();
+ void stop();
+ void restart();
+
+Q_SIGNALS:
+ void triggered();
+ void runningChanged();
+
+private:
+ void update();
+
+private Q_SLOTS:
+ void ticked();
+ void finished();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeTimer)
+
+QT_END_HEADER
+
+#endif
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
new file mode 100644
index 0000000000..ac07b10c1e
--- /dev/null
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include "qdeclarativestate_p.h"
+#include "qdeclarativestategroup_p.h"
+#include "qdeclarativestate_p_p.h"
+#include "qdeclarativestateoperations_p.h"
+#include "qdeclarativeanimation_p.h"
+#include "qdeclarativeanimation_p_p.h"
+#include "qdeclarativetransitionmanager_p_p.h"
+
+#include <QParallelAnimationGroup>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass Transition QDeclarativeTransition
+ \since 4.7
+ \brief The Transition element defines animated transitions that occur on state changes.
+
+ \sa {qmlstates}{States}, {state-transitions}{Transitions}
+*/
+
+/*!
+ \internal
+ \class QDeclarativeTransition
+ \brief The QDeclarativeTransition class allows you to define animated transitions that occur on state changes.
+
+ \ingroup group_states
+*/
+
+//ParallelAnimationWrapperallows us to do a "callback" when the animation finishes, rather than connecting
+//and disconnecting signals and slots frequently
+class ParallelAnimationWrapper : public QParallelAnimationGroup
+{
+ Q_OBJECT
+public:
+ ParallelAnimationWrapper(QObject *parent = 0) : QParallelAnimationGroup(parent) {}
+ QDeclarativeTransitionPrivate *trans;
+protected:
+ virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
+};
+
+class QDeclarativeTransitionPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeTransition)
+public:
+ QDeclarativeTransitionPrivate()
+ : fromState(QLatin1String("*")), toState(QLatin1String("*")),
+ reversed(false), reversible(false), endState(0)
+ {
+ group.trans = this;
+ }
+
+ QString fromState;
+ QString toState;
+ bool reversed;
+ bool reversible;
+ ParallelAnimationWrapper group;
+ QDeclarativeTransitionManager *endState;
+
+ void complete()
+ {
+ endState->complete();
+ }
+ static void append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a);
+ QList<QDeclarativeAbstractAnimation *> animations;
+};
+
+void QDeclarativeTransitionPrivate::append_animation(QDeclarativeListProperty<QDeclarativeAbstractAnimation> *list, QDeclarativeAbstractAnimation *a)
+{
+ QDeclarativeTransition *q = static_cast<QDeclarativeTransition *>(list->object);
+ q->d_func()->animations.append(a);
+ q->d_func()->group.addAnimation(a->qtAnimation());
+ a->setDisableUserControl();
+}
+
+void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
+{
+ QParallelAnimationGroup::updateState(newState, oldState);
+ if (newState == Stopped &&
+ ((direction() == QAbstractAnimation::Forward && currentLoopTime() == duration()) ||
+ (direction() == QAbstractAnimation::Backward && currentLoopTime() == 0)))
+ {
+ trans->complete();
+ }
+}
+
+
+
+QDeclarativeTransition::QDeclarativeTransition(QObject *parent)
+ : QObject(*(new QDeclarativeTransitionPrivate), parent)
+{
+}
+
+QDeclarativeTransition::~QDeclarativeTransition()
+{
+}
+
+void QDeclarativeTransition::stop()
+{
+ Q_D(QDeclarativeTransition);
+ d->group.stop();
+}
+
+void QDeclarativeTransition::setReversed(bool r)
+{
+ Q_D(QDeclarativeTransition);
+ d->reversed = r;
+}
+
+void QDeclarativeTransition::prepare(QDeclarativeStateOperation::ActionList &actions,
+ QList<QDeclarativeProperty> &after,
+ QDeclarativeTransitionManager *endState)
+{
+ Q_D(QDeclarativeTransition);
+
+ qmlExecuteDeferred(this);
+
+ if (d->reversed) {
+ for (int ii = d->animations.count() - 1; ii >= 0; --ii) {
+ d->animations.at(ii)->transition(actions, after, QDeclarativeAbstractAnimation::Backward);
+ }
+ } else {
+ for (int ii = 0; ii < d->animations.count(); ++ii) {
+ d->animations.at(ii)->transition(actions, after, QDeclarativeAbstractAnimation::Forward);
+ }
+ }
+
+ d->endState = endState;
+ d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
+ d->group.start();
+}
+
+/*!
+ \qmlproperty string Transition::from
+ \qmlproperty string Transition::to
+ These properties are selectors indicating which state changes should trigger the transition.
+
+ from is used in conjunction with to to determine when a transition should
+ be applied. By default from and to are both "*" (any state). In the following example,
+ the transition is applied when changing from state1 to state2.
+ \code
+ Transition {
+ from: "state1"
+ to: "state2"
+ ...
+ }
+ \endcode
+*/
+QString QDeclarativeTransition::fromState() const
+{
+ Q_D(const QDeclarativeTransition);
+ return d->fromState;
+}
+
+void QDeclarativeTransition::setFromState(const QString &f)
+{
+ Q_D(QDeclarativeTransition);
+ d->fromState = f;
+}
+
+/*!
+ \qmlproperty bool Transition::reversible
+ This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.
+
+ The default value is false.
+*/
+bool QDeclarativeTransition::reversible() const
+{
+ Q_D(const QDeclarativeTransition);
+ return d->reversible;
+}
+
+void QDeclarativeTransition::setReversible(bool r)
+{
+ Q_D(QDeclarativeTransition);
+ d->reversible = r;
+}
+
+QString QDeclarativeTransition::toState() const
+{
+ Q_D(const QDeclarativeTransition);
+ return d->toState;
+}
+
+void QDeclarativeTransition::setToState(const QString &t)
+{
+ Q_D(QDeclarativeTransition);
+ d->toState = t;
+}
+
+/*!
+ \qmlproperty list<Animation> Transition::animations
+ \default
+ This property holds a list of the animations to be run for this transition.
+
+ The top-level animations are run in parallel. To run them sequentially,
+ you can create a single SequentialAnimation which contains all the animations,
+ and assign that to animations the animations property.
+ \default
+*/
+QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeTransition::animations()
+{
+ Q_D(QDeclarativeTransition);
+ return QDeclarativeListProperty<QDeclarativeAbstractAnimation>(this, &d->animations, QDeclarativeTransitionPrivate::append_animation);
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativetransition.moc>
diff --git a/src/declarative/util/qdeclarativetransition_p.h b/src/declarative/util/qdeclarativetransition_p.h
new file mode 100644
index 0000000000..861111a225
--- /dev/null
+++ b/src/declarative/util/qdeclarativetransition_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 QDECLARATIVETRANSITION_H
+#define QDECLARATIVETRANSITION_H
+
+#include "qdeclarativestate_p.h"
+
+#include <qdeclarative.h>
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeAbstractAnimation;
+class QDeclarativeTransitionPrivate;
+class QDeclarativeTransitionManager;
+class Q_DECLARATIVE_EXPORT QDeclarativeTransition : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QDeclarativeTransition)
+
+ Q_PROPERTY(QString from READ fromState WRITE setFromState)
+ Q_PROPERTY(QString to READ toState WRITE setToState)
+ Q_PROPERTY(bool reversible READ reversible WRITE setReversible)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
+ Q_CLASSINFO("DefaultProperty", "animations")
+ Q_CLASSINFO("DeferredPropertyNames", "animations")
+
+public:
+ QDeclarativeTransition(QObject *parent=0);
+ ~QDeclarativeTransition();
+
+ QString fromState() const;
+ void setFromState(const QString &);
+
+ QString toState() const;
+ void setToState(const QString &);
+
+ bool reversible() const;
+ void setReversible(bool);
+
+ QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations();
+
+ void prepare(QDeclarativeStateOperation::ActionList &actions,
+ QList<QDeclarativeProperty> &after,
+ QDeclarativeTransitionManager *end);
+
+ void setReversed(bool r);
+ void stop();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeTransition)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVETRANSITION_H
diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp
new file mode 100644
index 0000000000..e1143fa65c
--- /dev/null
+++ b/src/declarative/util/qdeclarativetransitionmanager.cpp
@@ -0,0 +1,283 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativetransitionmanager_p_p.h"
+
+#include "qdeclarativestate_p_p.h"
+
+#include <qdeclarativebinding_p.h>
+#include <qdeclarativeglobal_p.h>
+#include <qdeclarativeproperty_p.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
+
+class QDeclarativeTransitionManagerPrivate
+{
+public:
+ QDeclarativeTransitionManagerPrivate()
+ : state(0), transition(0) {}
+
+ void applyBindings();
+ typedef QList<QDeclarativeSimpleAction> SimpleActionList;
+ QDeclarativeState *state;
+ QDeclarativeTransition *transition;
+ QDeclarativeStateOperation::ActionList bindingsList;
+ SimpleActionList completeList;
+};
+
+QDeclarativeTransitionManager::QDeclarativeTransitionManager()
+: d(new QDeclarativeTransitionManagerPrivate)
+{
+}
+
+void QDeclarativeTransitionManager::setState(QDeclarativeState *s)
+{
+ d->state = s;
+}
+
+QDeclarativeTransitionManager::~QDeclarativeTransitionManager()
+{
+ delete d; d = 0;
+}
+
+void QDeclarativeTransitionManager::complete()
+{
+ d->applyBindings();
+
+ for (int ii = 0; ii < d->completeList.count(); ++ii) {
+ const QDeclarativeProperty &prop = d->completeList.at(ii).property;
+ prop.write(d->completeList.at(ii).value);
+ }
+
+ d->completeList.clear();
+
+ if (d->state)
+ static_cast<QDeclarativeStatePrivate*>(QObjectPrivate::get(d->state))->complete();
+}
+
+void QDeclarativeTransitionManagerPrivate::applyBindings()
+{
+ foreach(const QDeclarativeAction &action, bindingsList) {
+ if (action.toBinding) {
+ QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding);
+ } else if (action.event) {
+ if (action.reverseEvent)
+ action.event->reverse();
+ else
+ action.event->execute();
+ }
+
+ }
+
+ bindingsList.clear();
+}
+
+void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &list,
+ QDeclarativeTransition *transition)
+{
+ cancel();
+
+ QDeclarativeStateOperation::ActionList applyList = list;
+ // Determine which actions are binding changes.
+ foreach(const QDeclarativeAction &action, applyList) {
+ if (action.toBinding)
+ d->bindingsList << action;
+ if (action.fromBinding)
+ QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding
+ if (action.event && action.event->changesBindings()) { //### assume isReversable()?
+ d->bindingsList << action;
+ if (action.reverseEvent)
+ action.event->clearReverseBindings();
+ else
+ action.event->clearForwardBindings();
+ }
+ }
+
+ // Animated transitions need both the start and the end value for
+ // each property change. In the presence of bindings, the end values
+ // are non-trivial to calculate. As a "best effort" attempt, we first
+ // apply all the property and binding changes, then read all the actual
+ // final values, then roll back the changes and proceed as normal.
+ //
+ // This doesn't catch everything, and it might be a little fragile in
+ // some cases - but whatcha going to do?
+
+ if (!d->bindingsList.isEmpty()) {
+
+ //### do extra actions here?
+
+ // Apply all the property and binding changes
+ for (int ii = 0; ii < applyList.size(); ++ii) {
+ const QDeclarativeAction &action = applyList.at(ii);
+ if (action.toBinding) {
+ QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ } else if (!action.event) {
+ QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ } else if (action.event->isReversable()) {
+ if (action.reverseEvent)
+ action.event->reverse();
+ else
+ action.event->execute();
+ applyList << action.event->extraActions();
+ }
+ }
+
+ // Read all the end values for binding changes
+ for (int ii = 0; ii < applyList.size(); ++ii) {
+ QDeclarativeAction *action = &applyList[ii];
+ if (action->event)
+ continue;
+ const QDeclarativeProperty &prop = action->property;
+ if (action->toBinding || !action->toValue.isValid()) { //### is this always right (used for exta actions)
+ action->toValue = prop.read();
+ }
+ }
+
+ // Revert back to the original values
+ foreach(const QDeclarativeAction &action, applyList) {
+ if (action.event) {
+ if (action.event->isReversable()) {
+ if (action.reverseEvent) { //reverse the reverse
+ action.event->clearForwardBindings();
+ action.event->rewind();
+ action.event->clearReverseBindings();
+ } else {
+ action.event->clearReverseBindings();
+ action.event->rewind();
+ action.event->clearForwardBindings();
+ }
+ }
+ continue;
+ }
+
+ if (action.toBinding)
+ QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition
+
+ QDeclarativePropertyPrivate::write(action.property, action.fromValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ }
+ }
+
+ if (transition) {
+ QList<QDeclarativeProperty> touched;
+ d->transition = transition;
+ d->transition->prepare(applyList, touched, this);
+
+ // Modify the action list to remove actions handled in the transition
+ for (int ii = 0; ii < applyList.count(); ++ii) {
+ const QDeclarativeAction &action = applyList.at(ii);
+
+ if (action.event) {
+
+ if (action.actionDone) {
+ applyList.removeAt(ii);
+ --ii;
+ }
+
+ } else {
+
+ if (touched.contains(action.property)) {
+ if (action.toValue != action.fromValue)
+ d->completeList <<
+ QDeclarativeSimpleAction(action, QDeclarativeSimpleAction::EndState);
+
+ applyList.removeAt(ii);
+ --ii;
+ }
+
+ }
+ }
+ }
+
+ // Any actions remaining have not been handled by the transition and should
+ // be applied immediately. We skip applying bindings, as they are all
+ // applied at the end in applyBindings() to avoid any nastiness mid
+ // transition
+ foreach(const QDeclarativeAction &action, applyList) {
+ if (action.event && !action.event->changesBindings()) {
+ if (action.event->isReversable() && action.reverseEvent)
+ action.event->reverse();
+ else
+ action.event->execute();
+ } else if (!action.event && !action.toBinding) {
+ action.property.write(action.toValue);
+ }
+ }
+ if (stateChangeDebug()) {
+ foreach(const QDeclarativeAction &action, applyList) {
+ if (action.event)
+ qWarning() << " No transition for event:" << action.event->typeName();
+ else
+ qWarning() << " No transition for:" << action.property.object()
+ << action.property.name() << "From:" << action.fromValue
+ << "To:" << action.toValue;
+ }
+ }
+ if (!transition)
+ d->applyBindings();
+}
+
+void QDeclarativeTransitionManager::cancel()
+{
+ if (d->transition) {
+ // ### this could potentially trigger a complete in rare circumstances
+ d->transition->stop();
+ d->transition = 0;
+ }
+
+ for(int i = 0; i < d->bindingsList.count(); ++i) {
+ QDeclarativeAction action = d->bindingsList[i];
+ if (action.toBinding && action.deletableToBinding) {
+ QDeclarativePropertyPrivate::setBinding(action.property, 0);
+ action.toBinding->destroy();
+ action.toBinding = 0;
+ action.deletableToBinding = false;
+ } else if (action.event) {
+ //### what do we do here?
+ }
+
+ }
+ d->bindingsList.clear();
+ d->completeList.clear();
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativetransitionmanager_p_p.h b/src/declarative/util/qdeclarativetransitionmanager_p_p.h
new file mode 100644
index 0000000000..d6e626e6f6
--- /dev/null
+++ b/src/declarative/util/qdeclarativetransitionmanager_p_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVETRANSITIONMANAGER_P_H
+#define QDECLARATIVETRANSITIONMANAGER_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 "qdeclarativestateoperations_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeStatePrivate;
+class QDeclarativeTransitionManagerPrivate;
+class QDeclarativeTransitionManager
+{
+public:
+ QDeclarativeTransitionManager();
+ ~QDeclarativeTransitionManager();
+
+ void transition(const QList<QDeclarativeAction> &, QDeclarativeTransition *transition);
+
+ void cancel();
+
+private:
+ Q_DISABLE_COPY(QDeclarativeTransitionManager);
+ QDeclarativeTransitionManagerPrivate *d;
+
+ void complete();
+ void setState(QDeclarativeState *);
+
+ friend class QDeclarativeState;
+ friend class QDeclarativeTransitionPrivate;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVETRANSITIONMANAGER_P_H
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
new file mode 100644
index 0000000000..2b8c7def14
--- /dev/null
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** 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 "qdeclarativeutilmodule_p.h"
+#include "qfxperf_p_p.h"
+#include "qdeclarativeanimation_p.h"
+#include "qdeclarativeanimation_p_p.h"
+#include "qdeclarativebehavior_p.h"
+#include "qdeclarativebind_p.h"
+#include "qdeclarativeconnections_p.h"
+#include "qdeclarativedatetimeformatter_p.h"
+#include "qdeclarativeeasefollow_p.h"
+#include "qdeclarativefontloader_p.h"
+#include "qdeclarativelistaccessor_p.h"
+#include "qdeclarativelistmodel_p.h"
+#include "qdeclarativenullablevalue_p_p.h"
+#include "qdeclarativenumberformatter_p.h"
+#include "qdeclarativeopenmetaobject_p.h"
+#include "qdeclarativepackage_p.h"
+#include "qdeclarativepixmapcache_p.h"
+#include "qdeclarativepropertychanges_p.h"
+#include "qdeclarativepropertymap.h"
+#include "qdeclarativespringfollow_p.h"
+#include "qdeclarativestategroup_p.h"
+#include "qdeclarativestateoperations_p.h"
+#include "qdeclarativestate_p.h"
+#include "qdeclarativestate_p_p.h"
+#include "qdeclarativestyledtext_p.h"
+#include "qdeclarativesystempalette_p.h"
+#include "qdeclarativetimeline_p_p.h"
+#include "qdeclarativetimer_p.h"
+#include "qdeclarativetransitionmanager_p_p.h"
+#include "qdeclarativetransition_p.h"
+#include "qdeclarativeview.h"
+#include "qdeclarativexmllistmodel_p.h"
+#include "qnumberformat_p.h"
+#include "qperformancelog_p_p.h"
+
+void QDeclarativeUtilModule::defineModule()
+{
+ QML_REGISTER_TYPE(Qt,4,6,AnchorChanges,QDeclarativeAnchorChanges);
+ QML_REGISTER_TYPE(Qt,4,6,Behavior,QDeclarativeBehavior);
+ QML_REGISTER_TYPE(Qt,4,6,Binding,QDeclarativeBind);
+ QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QDeclarativeColorAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,Connections,QDeclarativeConnections);
+ QML_REGISTER_TYPE(Qt,4,6,DateTimeFormatter,QDeclarativeDateTimeFormatter);
+ QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QDeclarativeEaseFollow);;
+ QML_REGISTER_TYPE(Qt,4,6,FontLoader,QDeclarativeFontLoader);
+ QML_REGISTER_TYPE(Qt,4,6,ListElement,QDeclarativeListElement);
+ QML_REGISTER_TYPE(Qt,4,6,NumberAnimation,QDeclarativeNumberAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,NumberFormatter,QDeclarativeNumberFormatter);;
+ QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage);
+ QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction);
+ QML_REGISTER_TYPE(Qt,4,6,ParentAnimation,QDeclarativeParentAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,ParentChange,QDeclarativeParentChange);
+ QML_REGISTER_TYPE(Qt,4,6,PauseAnimation,QDeclarativePauseAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,PropertyAction,QDeclarativePropertyAction);
+ QML_REGISTER_TYPE(Qt,4,6,PropertyAnimation,QDeclarativePropertyAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,RotationAnimation,QDeclarativeRotationAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,ScriptAction,QDeclarativeScriptAction);
+ QML_REGISTER_TYPE(Qt,4,6,SequentialAnimation,QDeclarativeSequentialAnimation);
+ QML_REGISTER_TYPE(Qt,4,6,SpringFollow,QDeclarativeSpringFollow);
+ QML_REGISTER_TYPE(Qt,4,6,StateChangeScript,QDeclarativeStateChangeScript);
+ QML_REGISTER_TYPE(Qt,4,6,StateGroup,QDeclarativeStateGroup);
+ QML_REGISTER_TYPE(Qt,4,6,State,QDeclarativeState);
+ QML_REGISTER_TYPE(Qt,4,6,SystemPalette,QDeclarativeSystemPalette);
+ QML_REGISTER_TYPE(Qt,4,6,Timer,QDeclarativeTimer);
+ QML_REGISTER_TYPE(Qt,4,6,Transition,QDeclarativeTransition);
+ QML_REGISTER_TYPE(Qt,4,6,Vector3dAnimation,QDeclarativeVector3dAnimation);
+#ifndef QT_NO_XMLPATTERNS
+ QML_REGISTER_TYPE(Qt,4,6,XmlListModel,QDeclarativeXmlListModel);
+ QML_REGISTER_TYPE(Qt,4,6,XmlRole,QDeclarativeXmlListModelRole);
+#endif
+
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeAbstractAnimation);
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeStateOperation);
+ QML_REGISTER_NOCREATE_TYPE(QNumberFormat);
+
+ QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser);
+ QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser);
+ QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, Connections, QDeclarativeConnections, QDeclarativeConnectionsParser);
+}
diff --git a/src/declarative/util/qdeclarativeutilmodule_p.h b/src/declarative/util/qdeclarativeutilmodule_p.h
new file mode 100644
index 0000000000..602c8c5a53
--- /dev/null
+++ b/src/declarative/util/qdeclarativeutilmodule_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 QDECLARATIVEUTILMODULE_H
+#define QDECLARATIVEUTILMODULE_H
+
+#include <qdeclarative.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeUtilModule
+{
+public:
+ static void defineModule();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEUTILMODULE_H
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
new file mode 100644
index 0000000000..6fe5bf3545
--- /dev/null
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -0,0 +1,570 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeview.h"
+
+#include "qperformancelog_p_p.h"
+#include "qfxperf_p_p.h"
+
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativedebug_p.h>
+#include <qdeclarativedebugservice_p.h>
+#include <qdeclarativeglobal_p.h>
+
+#include <qscriptvalueiterator.h>
+#include <qdebug.h>
+#include <qtimer.h>
+#include <qevent.h>
+#include <qdir.h>
+#include <qcoreapplication.h>
+#include <qfontdatabase.h>
+#include <qicon.h>
+#include <qurl.h>
+#include <qboxlayout.h>
+#include <qbasictimer.h>
+#include <QtCore/qabstractanimation.h>
+#include <private/qgraphicsview_p.h>
+
+QT_BEGIN_NAMESPACE
+
+DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
+
+class QDeclarativeViewDebugServer;
+class FrameBreakAnimation : public QAbstractAnimation
+{
+public:
+ FrameBreakAnimation(QDeclarativeViewDebugServer *s)
+ : QAbstractAnimation((QObject*)s), server(s)
+ {
+ start();
+ }
+
+ virtual int duration() const { return -1; }
+ virtual void updateCurrentTime(int msecs);
+
+private:
+ QDeclarativeViewDebugServer *server;
+};
+
+class QDeclarativeViewDebugServer : public QDeclarativeDebugService
+{
+public:
+ QDeclarativeViewDebugServer(QObject *parent = 0) : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0)
+ {
+ timer.start();
+ new FrameBreakAnimation(this);
+ }
+
+ void addTiming(int pe, int tbf)
+ {
+ if (!isEnabled())
+ return;
+
+ bool isFrameBreak = breaks > 1;
+ breaks = 0;
+ int e = timer.elapsed();
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)pe << (int)tbf << (int)e
+ << (bool)isFrameBreak;
+ sendMessage(data);
+ }
+
+ void frameBreak() { ++breaks; }
+
+private:
+ QTime timer;
+ int breaks;
+};
+
+Q_GLOBAL_STATIC(QDeclarativeViewDebugServer, qfxViewDebugServer);
+
+void FrameBreakAnimation::updateCurrentTime(int msecs)
+{
+ Q_UNUSED(msecs);
+ server->frameBreak();
+}
+
+class QDeclarativeViewPrivate
+{
+public:
+ QDeclarativeViewPrivate(QDeclarativeView *view)
+ : q(view), root(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {}
+
+ void execute();
+
+ QDeclarativeView *q;
+
+ QGuard<QGraphicsObject> root;
+ QGuard<QDeclarativeItem> qmlRoot;
+
+ QUrl source;
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent *component;
+ QBasicTimer resizetimer;
+
+ mutable QSize initialSize;
+ QDeclarativeView::ResizeMode resizeMode;
+ QTime frameTimer;
+
+ void init();
+
+ QGraphicsScene scene;
+};
+
+void QDeclarativeViewPrivate::execute()
+{
+ delete root;
+ delete component;
+ component = new QDeclarativeComponent(&engine, source, q);
+
+ if (!component->isLoading()) {
+ q->continueExecute();
+ } else {
+ QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), q, SLOT(continueExecute()));
+ }
+}
+
+
+/*!
+ \class QDeclarativeView
+ \since 4.7
+ \brief The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface.
+
+ Any QGraphicsObject or QDeclarativeItem
+ created via QML can be placed on a standard QGraphicsScene and viewed with a standard
+ QGraphicsView.
+
+ QDeclarativeView is a QGraphicsView subclass provided as a convenience for displaying QML
+ files, and connecting between QML and C++ Qt objects.
+
+ QDeclarativeView performs the following functions:
+
+ \list
+ \o Manages QDeclarativeComponent loading and object creation.
+ \o Initializes QGraphicsView for optimal performance with QML:
+ \list
+ \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState);
+ \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+ \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex);
+ \endlist
+ \o Initializes QGraphicsView for QML key handling:
+ \list
+ \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
+ \o QGraphicsScene::setStickyFocus(true);
+ \endlist
+ \endlist
+
+ Typical usage:
+ \code
+ ...
+ QDeclarativeView *view = new QDeclarativeView(this);
+ vbox->addWidget(view);
+
+ QUrl url(fileName);
+ view->setSource(url);
+ view->show();
+ \endcode
+
+ To receive errors related to loading and executing QML with QDeclarativeView,
+ you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error.
+ The errors are available via QDeclarativeView::errors().
+*/
+
+
+/*! \fn void QDeclarativeView::sceneResized(QSize size)
+ This signal is emitted when the view is resized to \a size.
+*/
+
+/*! \fn void QDeclarativeView::statusChanged(QDeclarativeView::Status status)
+ This signal is emitted when the component's current \l{QDeclarativeView::Status} {status} changes.
+*/
+
+/*!
+ \fn QDeclarativeView::QDeclarativeView(QWidget *parent)
+
+ Constructs a QDeclarativeView with the given \a parent.
+*/
+QDeclarativeView::QDeclarativeView(QWidget *parent)
+: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this))
+{
+ setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
+ d->init();
+}
+
+/*!
+ \fn QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
+
+ Constructs a QDeclarativeView with the given QML \a source and \a parent.
+*/
+QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
+: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this))
+{
+ setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
+ d->init();
+ setSource(source);
+}
+
+void QDeclarativeViewPrivate::init()
+{
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ {
+ QDeclarativePerfTimer<QDeclarativePerf::FontDatabase> perf;
+ QFontDatabase database;
+ }
+#endif
+
+ q->setScene(&scene);
+
+ q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
+ q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ q->setFrameStyle(0);
+
+ // These seem to give the best performance
+ q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+ scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ q->viewport()->setFocusPolicy(Qt::NoFocus);
+
+ scene.setStickyFocus(true); //### needed for correct focus handling
+}
+
+/*!
+ The destructor clears the view's \l {QGraphicsObject} {items} and
+ deletes the internal representation.
+ */
+QDeclarativeView::~QDeclarativeView()
+{
+ delete d->root;
+}
+
+/*!
+ Sets the source to the \a url, loads the QML component and instantiates it.
+ */
+void QDeclarativeView::setSource(const QUrl& url)
+{
+ if (url != d->source) {
+ d->source = url;
+ d->execute();
+ }
+}
+
+/*!
+ Returns the source URL, if set.
+
+ \sa setSource()
+ */
+QUrl QDeclarativeView::source() const
+{
+ return d->source;
+}
+
+/*!
+ Returns a pointer to the QDeclarativeEngine used for instantiating
+ QML Components.
+ */
+QDeclarativeEngine* QDeclarativeView::engine()
+{
+ return &d->engine;
+}
+
+/*!
+ This function returns the root of the context hierarchy. 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.
+ */
+QDeclarativeContext* QDeclarativeView::rootContext()
+{
+ return d->engine.rootContext();
+}
+
+
+/*!
+ \enum QDeclarativeView::Status
+
+ Specifies the loading status of the QDeclarativeView.
+
+ \value Null This QDeclarativeView has no source set.
+ \value Ready This QDeclarativeView has loaded and created the QML component.
+ \value Loading This QDeclarativeView is loading network data.
+ \value Error An error has occured. Calling errorDescription() to retrieve a description.
+*/
+
+/*!
+ \property QDeclarativeView::status
+ The component's current \l{QDeclarativeView::Status} {status}.
+*/
+
+QDeclarativeView::Status QDeclarativeView::status() const
+{
+ if (!d->component)
+ return QDeclarativeView::Null;
+
+ return QDeclarativeView::Status(d->component->status());
+}
+
+/*!
+ 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> QDeclarativeView::errors() const
+{
+ if (d->component)
+ return d->component->errors();
+ return QList<QDeclarativeError>();
+}
+
+
+/*!
+ \property QDeclarativeView::resizeMode
+ \brief whether the view should resize the canvas contents
+
+ If this property is set to SizeViewToRootObject (the default), the view
+ resizes with the root item in the QML.
+
+ If this property is set to SizeRootObjectToView, the view will
+ automatically resize the root item.
+
+ Regardless of this property, the sizeHint of the view
+ is the initial size of the root item. Note though that
+ since QML may load dynamically, that size may change.
+
+ \sa initialSize()
+*/
+
+void QDeclarativeView::setResizeMode(ResizeMode mode)
+{
+ if (d->resizeMode == mode)
+ return;
+
+ d->resizeMode = mode;
+ if (d->qmlRoot) {
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
+ } else {
+ d->qmlRoot->setWidth(d->initialSize.width());
+ d->qmlRoot->setHeight(d->initialSize.height());
+ }
+ }
+}
+
+QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const
+{
+ return d->resizeMode;
+}
+
+/*!
+ \internal
+ */
+void QDeclarativeView::continueExecute()
+{
+
+ disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
+
+ if (d->component->isError()) {
+ QList<QDeclarativeError> errorList = d->component->errors();
+ foreach (const QDeclarativeError &error, errorList) {
+ qWarning() << error;
+ }
+ emit statusChanged(status());
+ return;
+ }
+
+ QObject *obj = d->component->create();
+
+ if(d->component->isError()) {
+ QList<QDeclarativeError> errorList = d->component->errors();
+ foreach (const QDeclarativeError &error, errorList) {
+ qWarning() << error;
+ }
+ emit statusChanged(status());
+ return;
+ }
+
+ setRootObject(obj);
+ emit statusChanged(status());
+}
+
+
+/*!
+ \internal
+*/
+void QDeclarativeView::setRootObject(QObject *obj)
+{
+ if (QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(obj)) {
+ d->scene.addItem(item);
+
+ QPerformanceLog::displayData();
+ QPerformanceLog::clear();
+ d->root = item;
+ d->qmlRoot = item;
+ connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
+ connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
+ if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
+ d->initialSize.setWidth(d->qmlRoot->width());
+ if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
+ d->initialSize.setHeight(d->qmlRoot->height());
+ resize(d->initialSize);
+
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
+ } else {
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
+ emit sceneResized(sz);
+ resize(sz);
+ }
+ updateGeometry();
+ } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
+ d->scene.addItem(item);
+ qWarning() << "QDeclarativeView::resizeMode is not honored for components of type QGraphicsObject";
+ } else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
+ window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ window()->setAttribute(Qt::WA_NoSystemBackground, false);
+ if (!layout()) {
+ setLayout(new QVBoxLayout);
+ layout()->setContentsMargins(0, 0, 0, 0);
+ } else if (layout()->count()) {
+ // Hide the QGraphicsView in GV mode.
+ QLayoutItem *item = layout()->itemAt(0);
+ if (item->widget())
+ item->widget()->hide();
+ }
+ layout()->addWidget(wid);
+ emit sceneResized(wid->size());
+ }
+}
+
+/*!
+ \internal
+ */
+void QDeclarativeView::sizeChanged()
+{
+ // delay, so we catch both width and height changing.
+ d->resizetimer.start(0,this);
+}
+
+/*!
+ \internal
+ If the \l {QTimerEvent} {timer event} \a e is this
+ view's resize timer, sceneResized() is emitted.
+ */
+void QDeclarativeView::timerEvent(QTimerEvent* e)
+{
+ if (!e || e->timerId() == d->resizetimer.timerId()) {
+ if (d->qmlRoot) {
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
+ emit sceneResized(sz);
+ //if (!d->resizable)
+ //resize(sz);
+ }
+ d->resizetimer.stop();
+ updateGeometry();
+ }
+}
+
+/*!
+ \internal
+ The size hint is the size of the root item.
+*/
+QSize QDeclarativeView::sizeHint() const
+{
+ if (d->qmlRoot) {
+ if (d->initialSize.width() <= 0)
+ d->initialSize.setWidth(d->qmlRoot->width());
+ if (d->initialSize.height() <= 0)
+ d->initialSize.setHeight(d->qmlRoot->height());
+ }
+ return d->initialSize;
+}
+
+/*!
+ Returns the view's root \l {QGraphicsObject} {item}.
+ */
+QGraphicsObject *QDeclarativeView::rootObject() const
+{
+ return d->root;
+}
+
+/*!
+ \internal
+ This function handles the \l {QResizeEvent} {resize event}
+ \a e.
+ */
+void QDeclarativeView::resizeEvent(QResizeEvent *e)
+{
+ if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
+ }
+ if (d->qmlRoot) {
+ setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height()));
+ } else if (d->root) {
+ setSceneRect(d->root->boundingRect());
+ } else {
+ setSceneRect(rect());
+ }
+ QGraphicsView::resizeEvent(e);
+}
+
+/*!
+ \internal
+*/
+void QDeclarativeView::paintEvent(QPaintEvent *event)
+{
+ int time = 0;
+ if (frameRateDebug() || QDeclarativeViewDebugServer::isDebuggingEnabled())
+ time = d->frameTimer.restart();
+ QGraphicsView::paintEvent(event);
+ if (QDeclarativeViewDebugServer::isDebuggingEnabled())
+ qfxViewDebugServer()->addTiming(d->frameTimer.elapsed(), time);
+ if (frameRateDebug())
+ qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h
new file mode 100644
index 0000000000..03d8db3e57
--- /dev/null
+++ b/src/declarative/util/qdeclarativeview.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 QDECLARATIVEVIEW_H
+#define QDECLARATIVEVIEW_H
+
+#include <QtCore/qdatetime.h>
+#include <QtGui/qgraphicssceneevent.h>
+#include <QtGui/qgraphicsview.h>
+#include <QtGui/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QGraphicsObject;
+class QDeclarativeEngine;
+class QDeclarativeContext;
+class QDeclarativeError;
+
+class QDeclarativeViewPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeView : public QGraphicsView
+{
+ Q_OBJECT
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+
+public:
+ explicit QDeclarativeView(QWidget *parent = 0);
+ QDeclarativeView(const QUrl &source, QWidget *parent = 0);
+ virtual ~QDeclarativeView();
+
+ QUrl source() const;
+ void setSource(const QUrl&);
+
+ QDeclarativeEngine* engine();
+ QDeclarativeContext* rootContext();
+
+ QGraphicsObject *rootObject() const;
+
+ enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
+ ResizeMode resizeMode() const;
+ void setResizeMode(ResizeMode);
+
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+
+ QList<QDeclarativeError> errors() const;
+
+ QSize sizeHint() const;
+
+Q_SIGNALS:
+ void sceneResized(QSize size); // ???
+ void statusChanged(QDeclarativeView::Status);
+
+private Q_SLOTS:
+ void continueExecute();
+ void sizeChanged();
+
+protected:
+ virtual void resizeEvent(QResizeEvent *);
+ virtual void paintEvent(QPaintEvent *event);
+ virtual void timerEvent(QTimerEvent*);
+ virtual void setRootObject(QObject *obj);
+
+ friend class QDeclarativeViewPrivate;
+ QDeclarativeViewPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEVIEW_H
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
new file mode 100644
index 0000000000..386df46ca8
--- /dev/null
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -0,0 +1,797 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativexmllistmodel_p.h"
+
+#include <qdeclarativecontext.h>
+#include <qdeclarativeengine.h>
+
+#include <QDebug>
+#include <QStringList>
+#include <QApplication>
+#include <QThread>
+#include <QMutex>
+#include <QWaitCondition>
+#include <QXmlQuery>
+#include <QXmlResultItems>
+#include <QXmlNodeModelIndex>
+#include <QBuffer>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+
+typedef QPair<int, int> QDeclarativeXmlListRange;
+
+/*!
+ \qmlclass XmlRole QDeclarativeXmlListModelRole
+ \since 4.7
+ \brief The XmlRole element allows you to specify a role for an XmlListModel.
+*/
+
+/*!
+ \qmlproperty string XmlRole::name
+ The name for the role. This name is used to access the model data for this role from Qml.
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()" }
+
+ ...
+
+ Component {
+ id: myDelegate
+ Text { text: title }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlproperty string XmlRole::query
+ The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
+ relative).
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()" }
+ \endqml
+*/
+
+/*!
+ \qmlproperty bool XmlRole::isKey
+ Defines whether this is a key role.
+
+ Key roles are used to to determine whether a set of values should
+ be updated or added to the XML list model when XmlListModel::reload()
+ is called.
+
+ \sa XmlListModel
+*/
+
+
+class QDeclarativeXmlQuery : public QThread
+{
+ Q_OBJECT
+public:
+ QDeclarativeXmlQuery(QObject *parent=0)
+ : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
+ }
+ ~QDeclarativeXmlQuery() {
+ m_mutex.lock();
+ m_quit = true;
+ m_condition.wakeOne();
+ m_mutex.unlock();
+
+ wait();
+ }
+
+ void abort() {
+ QMutexLocker locker(&m_mutex);
+ m_abort = true;
+ }
+
+ int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *> *roleObjects) {
+ QMutexLocker locker(&m_mutex);
+ m_size = 0;
+ m_data = data;
+ m_query = QLatin1String("doc($src)") + query;
+ m_namespaces = namespaces;
+ m_roleObjects = roleObjects;
+ if (!isRunning()) {
+ m_abort = false;
+ start();
+ } else {
+ m_restart = true;
+ m_condition.wakeOne();
+ }
+ m_queryId++;
+ return m_queryId;
+ }
+
+ QList<QList<QVariant> > modelData() {
+ QMutexLocker locker(&m_mutex);
+ return m_modelData;
+ }
+
+ QList<QDeclarativeXmlListRange> insertedItemRanges() {
+ QMutexLocker locker(&m_mutex);
+ return m_insertedItemRanges;
+ }
+
+ QList<QDeclarativeXmlListRange> removedItemRanges() {
+ QMutexLocker locker(&m_mutex);
+ return m_removedItemRanges;
+ }
+
+Q_SIGNALS:
+ void queryCompleted(int queryId, int size);
+
+protected:
+ void run() {
+ while (!m_quit) {
+ m_mutex.lock();
+ int queryId = m_queryId;
+ doQueryJob();
+ doSubQueryJob();
+ m_data.clear(); // no longer needed
+ m_mutex.unlock();
+
+ m_mutex.lock();
+ if (!m_abort)
+ emit queryCompleted(queryId, m_size);
+ if (!m_restart)
+ m_condition.wait(&m_mutex);
+ m_abort = false;
+ m_restart = false;
+ m_mutex.unlock();
+ }
+ }
+
+private:
+ void doQueryJob();
+ void doSubQueryJob();
+ void getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const;
+ void addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const;
+
+private:
+ QMutex m_mutex;
+ QWaitCondition m_condition;
+ bool m_quit;
+ bool m_restart;
+ bool m_abort;
+ QByteArray m_data;
+ QString m_query;
+ QString m_namespaces;
+ QString m_prefix;
+ int m_size;
+ int m_queryId;
+ const QList<QDeclarativeXmlListModelRole *> *m_roleObjects;
+ QList<QList<QVariant> > m_modelData;
+ QStringList m_keysValues;
+ QList<QDeclarativeXmlListRange> m_insertedItemRanges;
+ QList<QDeclarativeXmlListRange> m_removedItemRanges;
+};
+
+void QDeclarativeXmlQuery::doQueryJob()
+{
+ QString r;
+ QXmlQuery query;
+ QBuffer buffer(&m_data);
+ buffer.open(QIODevice::ReadOnly);
+ query.bindVariable(QLatin1String("src"), &buffer);
+ query.setQuery(m_namespaces + m_query);
+ query.evaluateTo(&r);
+
+ //qDebug() << r;
+
+ //always need a single root element
+ QByteArray xml = "<dummy:items xmlns:dummy=\"http://qtsotware.com/dummy\">\n" + r.toUtf8() + "</dummy:items>";
+ QBuffer b(&xml);
+ b.open(QIODevice::ReadOnly);
+ //qDebug() << xml;
+
+ QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + m_namespaces;
+ QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
+ m_query.mid(m_query.lastIndexOf(QLatin1Char('/')));
+
+ //figure out how many items we are dealing with
+ int count = -1;
+ {
+ QXmlResultItems result;
+ QXmlQuery countquery;
+ countquery.bindVariable(QLatin1String("inputDocument"), &b);
+ countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')'));
+ countquery.evaluateTo(&result);
+ QXmlItem item(result.next());
+ if (item.isAtomicValue())
+ count = item.toAtomicValue().toInt();
+ }
+ //qDebug() << count;
+
+ m_prefix = namespaces + prefix + QLatin1Char('/');
+ m_data = xml;
+ if (count > 0)
+ m_size = count;
+}
+
+void QDeclarativeXmlQuery::getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const
+{
+ QStringList keysQueries;
+ for (int i=0; i<m_roleObjects->count(); i++) {
+ if (m_roleObjects->at(i)->isKey())
+ keysQueries << m_roleObjects->at(i)->query();
+ }
+ QString keysQuery;
+ if (keysQueries.count() == 1)
+ keysQuery = m_prefix + keysQueries[0];
+ else if (keysQueries.count() > 1)
+ keysQuery = m_prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")");
+
+ if (!keysQuery.isEmpty()) {
+ query->setQuery(keysQuery);
+ QXmlResultItems resultItems;
+ query->evaluateTo(&resultItems);
+ QXmlItem item(resultItems.next());
+ while (!item.isNull()) {
+ values->append(item.toAtomicValue().toString());
+ item = resultItems.next();
+ }
+ }
+}
+
+void QDeclarativeXmlQuery::addIndexToRangeList(QList<QDeclarativeXmlListRange> *ranges, int index) const {
+ if (ranges->isEmpty())
+ ranges->append(qMakePair(index, 1));
+ else if (ranges->last().first + ranges->last().second == index)
+ ranges->last().second += 1;
+ else
+ ranges->append(qMakePair(index, 1));
+}
+
+void QDeclarativeXmlQuery::doSubQueryJob()
+{
+ m_modelData.clear();
+
+ QBuffer b(&m_data);
+ b.open(QIODevice::ReadOnly);
+
+ QXmlQuery subquery;
+ subquery.bindVariable(QLatin1String("inputDocument"), &b);
+
+ QStringList keysValues;
+ getValuesOfKeyRoles(&keysValues, &subquery);
+
+ // See if any values of key roles have been inserted or removed.
+ m_insertedItemRanges.clear();
+ m_removedItemRanges.clear();
+ if (m_keysValues.isEmpty()) {
+ m_insertedItemRanges << qMakePair(0, m_size);
+ } else {
+ if (keysValues != m_keysValues) {
+ QStringList temp;
+ for (int i=0; i<m_keysValues.count(); i++) {
+ if (!keysValues.contains(m_keysValues[i]))
+ addIndexToRangeList(&m_removedItemRanges, i);
+ else
+ temp << m_keysValues[i];
+ }
+
+ for (int i=0; i<keysValues.count(); i++) {
+ if (temp.count() == i || keysValues[i] != temp[i]) {
+ temp.insert(i, keysValues[i]);
+ addIndexToRangeList(&m_insertedItemRanges, i);
+ }
+ }
+ }
+ }
+ m_keysValues = keysValues;
+
+ // Get the new values for each role.
+ //### we might be able to condense even further (query for everything in one go)
+ for (int i = 0; i < m_roleObjects->size(); ++i) {
+ QDeclarativeXmlListModelRole *role = m_roleObjects->at(i);
+ if (!role->isValid()) {
+ QList<QVariant> resultList;
+ for (int j = 0; j < m_size; ++j)
+ resultList << QVariant();
+ m_modelData << resultList;
+ continue;
+ }
+ subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + role->query() + QLatin1String(" return if ($v) then ") + role->query() + QLatin1String(" else \"\")"));
+ QXmlResultItems resultItems;
+ subquery.evaluateTo(&resultItems);
+ QXmlItem item(resultItems.next());
+ QList<QVariant> resultList;
+ while (!item.isNull()) {
+ resultList << item.toAtomicValue(); //### we used to trim strings
+ item = resultItems.next();
+ }
+ //### should warn here if things have gone wrong.
+ while (resultList.count() < m_size)
+ resultList << QVariant();
+ m_modelData << resultList;
+ b.seek(0);
+ }
+
+ //this method is much slower, but works better for incremental loading
+ /*for (int j = 0; j < m_size; ++j) {
+ QList<QVariant> resultList;
+ for (int i = 0; i < m_roleObjects->size(); ++i) {
+ QDeclarativeXmlListModelRole *role = m_roleObjects->at(i);
+ subquery.setQuery(m_prefix.arg(j+1) + role->query());
+ if (role->isStringList()) {
+ QStringList data;
+ subquery.evaluateTo(&data);
+ resultList << QVariant(data);
+ //qDebug() << data;
+ } else {
+ QString s;
+ subquery.evaluateTo(&s);
+ if (role->isCData()) {
+ //un-escape
+ s.replace(QLatin1String("&lt;"), QLatin1String("<"));
+ s.replace(QLatin1String("&gt;"), QLatin1String(">"));
+ s.replace(QLatin1String("&amp;"), QLatin1String("&"));
+ }
+ resultList << s.trimmed();
+ //qDebug() << s;
+ }
+ b.seek(0);
+ }
+ m_modelData << resultList;
+ }*/
+}
+
+class QDeclarativeXmlListModelPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QDeclarativeXmlListModel)
+public:
+ QDeclarativeXmlListModelPrivate()
+ : isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
+ , reply(0), status(QDeclarativeXmlListModel::Null), progress(0.0)
+ , queryId(-1), roleObjects() {}
+
+ bool isComponentComplete;
+ QUrl src;
+ QString xml;
+ QString query;
+ QString namespaces;
+ int size;
+ QList<int> roles;
+ QStringList roleNames;
+ int highestRole;
+ QNetworkReply *reply;
+ QDeclarativeXmlListModel::Status status;
+ qreal progress;
+ QDeclarativeXmlQuery qmlXmlQuery;
+ int queryId;
+ QList<QDeclarativeXmlListModelRole *> roleObjects;
+ static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role);
+ static void clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list);
+ static void removeAt_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, int i);
+ static void insert_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, int i, QDeclarativeXmlListModelRole *role);
+ QList<QList<QVariant> > data;
+};
+
+
+void QDeclarativeXmlListModelPrivate::append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role)
+{
+ QDeclarativeXmlListModel *_this = qobject_cast<QDeclarativeXmlListModel *>(list->object);
+ if (_this) {
+ int i = _this->d_func()->roleObjects.count();
+ _this->d_func()->roleObjects.append(role);
+ if (_this->d_func()->roleNames.contains(role->name())) {
+ qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
+ return;
+ }
+ _this->d_func()->roles.insert(i, _this->d_func()->highestRole);
+ _this->d_func()->roleNames.insert(i, role->name());
+ ++_this->d_func()->highestRole;
+ }
+}
+
+//### clear needs to invalidate any cached data (in data table) as well
+// (and the model should emit the appropriate signals)
+void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list)
+{
+ QDeclarativeXmlListModel *_this = static_cast<QDeclarativeXmlListModel *>(list->object);
+ _this->d_func()->roles.clear();
+ _this->d_func()->roleNames.clear();
+ _this->d_func()->roleObjects.clear();
+}
+
+/*!
+ \class QDeclarativeXmlListModel
+ \internal
+*/
+
+/*!
+ \qmlclass XmlListModel QDeclarativeXmlListModel
+ \since 4.7
+ \brief The XmlListModel element is used to specify a model using XPath expressions.
+
+ XmlListModel is used to create a model from XML data that can be used as a data source
+ for the view classes (such as ListView, PathView, GridView) and other classes that interact with model
+ data (such as Repeater).
+
+ Here is an example of a model containing news from a Yahoo RSS feed:
+ \qml
+ XmlListModel {
+ id: feedModel
+ source: "http://rss.news.yahoo.com/rss/oceania"
+ query: "/rss/channel/item"
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "pubDate"; query: "pubDate/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ }
+ \endqml
+
+ You can also define certain roles as "keys" so that the model only adds data
+ that contains new values for these keys when reload() is called.
+
+ For example, if the roles above were defined like this:
+
+ \qml
+ XmlRole { name: "title"; query: "title/string()"; isKey: true }
+ XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true }
+ \endqml
+
+ Then when reload() is called, the model will only add new items with a
+ "title" and "pubDate" value combination that is not already present in
+ the model.
+
+ This is useful to provide incremental updates and avoid repainting an
+ entire model in a view.
+*/
+
+QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
+ : QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent)
+{
+ Q_D(QDeclarativeXmlListModel);
+ connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)),
+ this, SLOT(queryCompleted(int,int)));
+}
+
+QDeclarativeXmlListModel::~QDeclarativeXmlListModel()
+{
+}
+
+/*!
+ \qmlproperty list<XmlRole> XmlListModel::roles
+
+ The roles to make available for this model.
+*/
+QDeclarativeListProperty<QDeclarativeXmlListModelRole> QDeclarativeXmlListModel::roleObjects()
+{
+ Q_D(QDeclarativeXmlListModel);
+ QDeclarativeListProperty<QDeclarativeXmlListModelRole> list(this, d->roleObjects);
+ list.append = &QDeclarativeXmlListModelPrivate::append_role;
+ list.clear = &QDeclarativeXmlListModelPrivate::clear_role;
+ return list;
+}
+
+QHash<int,QVariant> QDeclarativeXmlListModel::data(int index, const QList<int> &roles) const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ QHash<int, QVariant> rv;
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ int roleIndex = d->roles.indexOf(role);
+ rv.insert(role, roleIndex == -1 ? QVariant() : d->data.at(roleIndex).at(index));
+ }
+ return rv;
+}
+
+QVariant QDeclarativeXmlListModel::data(int index, int role) const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ int roleIndex = d->roles.indexOf(role);
+ return (roleIndex == -1) ? QVariant() : d->data.at(roleIndex).at(index);
+}
+
+/*!
+ \qmlproperty int XmlListModel::count
+ The number of data entries in the model.
+*/
+int QDeclarativeXmlListModel::count() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->size;
+}
+
+QList<int> QDeclarativeXmlListModel::roles() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->roles;
+}
+
+QString QDeclarativeXmlListModel::toString(int role) const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ int index = d->roles.indexOf(role);
+ if (index == -1)
+ return QString();
+ return d->roleNames.at(index);
+}
+
+/*!
+ \qmlproperty url XmlListModel::source
+ The location of the XML data source.
+
+ If both source and xml are set, xml will be used.
+*/
+QUrl QDeclarativeXmlListModel::source() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->src;
+}
+
+void QDeclarativeXmlListModel::setSource(const QUrl &src)
+{
+ Q_D(QDeclarativeXmlListModel);
+ if (d->src != src) {
+ d->src = src;
+ reload();
+ }
+}
+
+/*!
+ \qmlproperty string XmlListModel::xml
+ This property holds XML text set directly.
+
+ The text is assumed to be UTF-8 encoded.
+
+ If both source and xml are set, xml will be used.
+*/
+QString QDeclarativeXmlListModel::xml() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->xml;
+}
+
+void QDeclarativeXmlListModel::setXml(const QString &xml)
+{
+ Q_D(QDeclarativeXmlListModel);
+ d->xml = xml;
+ reload();
+}
+
+/*!
+ \qmlproperty string XmlListModel::query
+ An absolute XPath query representing the base query for the model items. The query should start with
+ '/' or '//'.
+*/
+QString QDeclarativeXmlListModel::query() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->query;
+}
+
+void QDeclarativeXmlListModel::setQuery(const QString &query)
+{
+ Q_D(QDeclarativeXmlListModel);
+ if (!query.startsWith(QLatin1Char('/'))) {
+ qmlInfo(this) << QCoreApplication::translate("QDeclarativeXmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
+ return;
+ }
+
+ if (d->query != query) {
+ d->query = query;
+ reload();
+ }
+}
+
+/*!
+ \qmlproperty string XmlListModel::namespaceDeclarations
+ A set of declarations for the namespaces used in the query.
+*/
+QString QDeclarativeXmlListModel::namespaceDeclarations() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->namespaces;
+}
+
+void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarations)
+{
+ Q_D(QDeclarativeXmlListModel);
+ if (d->namespaces != declarations) {
+ d->namespaces = declarations;
+ reload();
+ }
+}
+
+/*!
+ \qmlproperty enum XmlListModel::status
+
+ This property holds the status of data source loading. It can be one of:
+ \list
+ \o Null - no data source has been set
+ \o Ready - nthe data source has been loaded
+ \o Loading - the data source is currently being loaded
+ \o Error - an error occurred while loading the data source
+ \endlist
+
+ \sa progress
+
+*/
+QDeclarativeXmlListModel::Status QDeclarativeXmlListModel::status() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->status;
+}
+
+/*!
+ \qmlproperty real XmlListModel::progress
+
+ This property holds the progress of data source loading, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+
+ \sa status
+*/
+qreal QDeclarativeXmlListModel::progress() const
+{
+ Q_D(const QDeclarativeXmlListModel);
+ return d->progress;
+}
+
+void QDeclarativeXmlListModel::classBegin()
+{
+ Q_D(QDeclarativeXmlListModel);
+ d->isComponentComplete = false;
+}
+
+void QDeclarativeXmlListModel::componentComplete()
+{
+ Q_D(QDeclarativeXmlListModel);
+ d->isComponentComplete = true;
+ reload();
+}
+
+/*!
+ \qmlmethod XmlListModel::reload()
+
+ Reloads the model.
+
+ If no key roles have been specified, all existing model
+ data is removed, and the model is rebuilt from scratch.
+
+ Otherwise, items are only added if the model does not already
+ contain items with matching key role values.
+*/
+void QDeclarativeXmlListModel::reload()
+{
+ Q_D(QDeclarativeXmlListModel);
+
+ if (!d->isComponentComplete)
+ return;
+
+ d->qmlXmlQuery.abort();
+ d->queryId = -1;
+
+ if (d->size < 0)
+ d->size = 0;
+
+ if (d->src.isEmpty() && d->xml.isEmpty())
+ return;
+
+ if (d->reply) {
+ d->reply->abort();
+ d->reply->deleteLater();
+ d->reply = 0;
+ }
+
+ if (!d->xml.isEmpty()) {
+ d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
+ d->progress = 1.0;
+ d->status = Ready;
+ emit progressChanged(d->progress);
+ emit statusChanged(d->status);
+ return;
+ }
+
+ d->progress = 0.0;
+ d->status = Loading;
+ emit progressChanged(d->progress);
+ emit statusChanged(d->status);
+
+ QNetworkRequest req(d->src);
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
+ QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+}
+
+void QDeclarativeXmlListModel::requestFinished()
+{
+ Q_D(QDeclarativeXmlListModel);
+ if (d->reply->error() != QNetworkReply::NoError) {
+ disconnect(d->reply, 0, this, 0);
+ d->reply->deleteLater();
+ d->reply = 0;
+ d->status = Error;
+ } else {
+ d->status = Ready;
+ QByteArray data = d->reply->readAll();
+ d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects);
+ disconnect(d->reply, 0, this, 0);
+ d->reply->deleteLater();
+ d->reply = 0;
+ }
+ d->progress = 1.0;
+ emit progressChanged(d->progress);
+ emit statusChanged(d->status);
+}
+
+void QDeclarativeXmlListModel::requestProgress(qint64 received, qint64 total)
+{
+ Q_D(QDeclarativeXmlListModel);
+ if (d->status == Loading && total > 0) {
+ d->progress = qreal(received)/total;
+ emit progressChanged(d->progress);
+ }
+}
+
+void QDeclarativeXmlListModel::queryCompleted(int id, int size)
+{
+ Q_D(QDeclarativeXmlListModel);
+ if (id != d->queryId)
+ return;
+ bool sizeChanged = size != d->size;
+ d->size = size;
+ d->data = d->qmlXmlQuery.modelData();
+
+ QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges();
+ for (int i=0; i<removed.count(); i++)
+ emit itemsRemoved(removed[i].first, removed[i].second);
+ QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges();
+ for (int i=0; i<inserted.count(); i++)
+ emit itemsInserted(inserted[i].first, inserted[i].second);
+
+ if (sizeChanged)
+ emit countChanged();
+}
+
+QT_END_NAMESPACE
+
+#include <qdeclarativexmllistmodel.moc>
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h
new file mode 100644
index 0000000000..132a53cdf5
--- /dev/null
+++ b/src/declarative/util/qdeclarativexmllistmodel_p.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEXMLLISTMODEL_H
+#define QDECLARATIVEXMLLISTMODEL_H
+
+#include <qdeclarative.h>
+#include <qdeclarativeinfo.h>
+
+#include <QtCore/qurl.h>
+
+#include "../3rdparty/qlistmodelinterface_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QDeclarativeContext;
+
+class QDeclarativeXmlListModelRole;
+
+class QDeclarativeXmlListModelPrivate;
+class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModel : public QListModelInterface, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+ Q_ENUMS(Status)
+
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource)
+ Q_PROPERTY(QString xml READ xml WRITE setXml)
+ Q_PROPERTY(QString query READ query WRITE setQuery)
+ Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
+ Q_PROPERTY(QDeclarativeListProperty<QDeclarativeXmlListModelRole> roles READ roleObjects)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
+ Q_CLASSINFO("DefaultProperty", "roles")
+
+public:
+ QDeclarativeXmlListModel(QObject *parent = 0);
+ ~QDeclarativeXmlListModel();
+
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+ virtual QVariant data(int index, int role) const;
+ virtual int count() const;
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+
+ QDeclarativeListProperty<QDeclarativeXmlListModelRole> roleObjects();
+
+ QUrl source() const;
+ void setSource(const QUrl&);
+
+ QString xml() const;
+ void setXml(const QString&);
+
+ QString query() const;
+ void setQuery(const QString&);
+
+ QString namespaceDeclarations() const;
+ void setNamespaceDeclarations(const QString&);
+
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void statusChanged(Status);
+ void progressChanged(qreal progress);
+ void countChanged();
+
+public Q_SLOTS:
+ // ### need to use/expose Expiry to guess when to call this?
+ // ### property to auto-call this on reasonable Expiry?
+ // ### LastModified/Age also useful to guess.
+ // ### Probably also applies to other network-requesting types.
+ void reload();
+
+private Q_SLOTS:
+ void requestFinished();
+ void requestProgress(qint64,qint64);
+ void queryCompleted(int,int);
+
+private:
+ Q_DECLARE_PRIVATE(QDeclarativeXmlListModel)
+ Q_DISABLE_COPY(QDeclarativeXmlListModel)
+};
+
+class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModelRole : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString query READ query WRITE setQuery)
+ Q_PROPERTY(bool isKey READ isKey WRITE setIsKey)
+
+public:
+ QDeclarativeXmlListModelRole() : m_isKey(false) {}
+ ~QDeclarativeXmlListModelRole() {}
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) { m_name = name; }
+
+ QString query() const { return m_query; }
+ void setQuery(const QString &query)
+ {
+ if (query.startsWith(QLatin1Char('/'))) {
+ qmlInfo(this) << tr("An XmlRole query must not start with '/'");
+ return;
+ }
+ m_query = query;
+ }
+
+ bool isKey() const { return m_isKey; }
+ void setIsKey(bool b) { m_isKey = b; }
+
+ bool isValid() {
+ return !m_name.isEmpty() && !m_query.isEmpty();
+ }
+
+private:
+ QString m_name;
+ QString m_query;
+ bool m_isKey;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeXmlListModel)
+QML_DECLARE_TYPE(QDeclarativeXmlListModelRole)
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEXMLLISTMODEL_H
diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp
index 8f5617c32b..5611c49a83 100644
--- a/src/declarative/util/qfxperf.cpp
+++ b/src/declarative/util/qfxperf.cpp
@@ -43,25 +43,25 @@
QT_BEGIN_NAMESPACE
-Q_DEFINE_PERFORMANCE_LOG(QmlPerf, "QmlGraphics") {
- Q_DEFINE_PERFORMANCE_METRIC(QmlParsing, "Compilation: QML Parsing")
+Q_DEFINE_PERFORMANCE_LOG(QDeclarativePerf, "QDeclarativeGraphics") {
+ Q_DEFINE_PERFORMANCE_METRIC(QDeclarativeParsing, "Compilation: QML Parsing")
Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation")
Q_DEFINE_PERFORMANCE_METRIC(VMEExecution, "Execution: QML VME Execution")
Q_DEFINE_PERFORMANCE_METRIC(BindInit, "BindValue Initialization")
Q_DEFINE_PERFORMANCE_METRIC(BindValue, "BindValue execution")
Q_DEFINE_PERFORMANCE_METRIC(BindValueSSE, "BindValue execution SSE")
Q_DEFINE_PERFORMANCE_METRIC(BindValueQt, "BindValue execution QtScript")
- Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QmlBinding::update")
+ Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QDeclarativeBinding::update")
Q_DEFINE_PERFORMANCE_METRIC(PixmapLoad, "Pixmap loading")
Q_DEFINE_PERFORMANCE_METRIC(FontDatabase, "Font database creation")
- Q_DEFINE_PERFORMANCE_METRIC(QmlGraphicsPathViewPathCache, "FX Items: QmlGraphicsPathView: Path cache")
- Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QmlGraphicsParticles: Particle creation")
- Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QmlGraphicsItem::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QmlGraphicsImage::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QmlGraphicsBasePositioner::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QmlGraphicsText::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(QmlGraphicsText_setText, " QmlGraphicsText::setText")
- Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine")
+ Q_DEFINE_PERFORMANCE_METRIC(QDeclarativePathViewPathCache, "FX Items: QDeclarativePathView: Path cache")
+ Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QDeclarativeParticles: Particle creation")
+ Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QDeclarativeItem::componentComplete")
+ Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QDeclarativeImage::componentComplete")
+ Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QDeclarativeBasePositioner::componentComplete")
+ Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QDeclarativeText::componentComplete")
+ Q_DEFINE_PERFORMANCE_METRIC(QDeclarativeText_setText, " QDeclarativeText::setText")
+ Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QDeclarativeScript::addScriptToEngine")
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qfxperf_p_p.h b/src/declarative/util/qfxperf_p_p.h
index 106f7617ea..8b65821300 100644
--- a/src/declarative/util/qfxperf_p_p.h
+++ b/src/declarative/util/qfxperf_p_p.h
@@ -60,8 +60,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-Q_DECLARE_PERFORMANCE_LOG(QmlPerf) {
- Q_DECLARE_PERFORMANCE_METRIC(QmlParsing)
+Q_DECLARE_PERFORMANCE_LOG(QDeclarativePerf) {
+ Q_DECLARE_PERFORMANCE_METRIC(QDeclarativeParsing)
Q_DECLARE_PERFORMANCE_METRIC(Compilation)
Q_DECLARE_PERFORMANCE_METRIC(VMEExecution)
@@ -73,13 +73,13 @@ Q_DECLARE_PERFORMANCE_LOG(QmlPerf) {
Q_DECLARE_PERFORMANCE_METRIC(BindableValueUpdate)
Q_DECLARE_PERFORMANCE_METRIC(PixmapLoad)
Q_DECLARE_PERFORMANCE_METRIC(FontDatabase)
- Q_DECLARE_PERFORMANCE_METRIC(QmlGraphicsPathViewPathCache)
+ Q_DECLARE_PERFORMANCE_METRIC(QDeclarativePathViewPathCache)
Q_DECLARE_PERFORMANCE_METRIC(CreateParticle)
Q_DECLARE_PERFORMANCE_METRIC(ItemComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(ImageComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(BaseLayoutComponentComplete)
Q_DECLARE_PERFORMANCE_METRIC(TextComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(QmlGraphicsText_setText)
+ Q_DECLARE_PERFORMANCE_METRIC(QDeclarativeText_setText)
Q_DECLARE_PERFORMANCE_METRIC(AddScript)
}
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
deleted file mode 100644
index e8a920acc0..0000000000
--- a/src/declarative/util/qmlanimation.cpp
+++ /dev/null
@@ -1,2446 +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 "qmlanimation_p.h"
-#include "qmlanimation_p_p.h"
-
-#include "qmlbehavior_p.h"
-#include "qmlstateoperations_p.h"
-
-#include <qmlpropertyvaluesource.h>
-#include <qml.h>
-#include <qmlinfo.h>
-#include <qmlexpression.h>
-#include <qmlstringconverters_p.h>
-#include <qmlglobal_p.h>
-
-#include <qvariant.h>
-#include <qcolor.h>
-#include <qfile.h>
-#include <QParallelAnimationGroup>
-#include <QSequentialAnimationGroup>
-#include <QtCore/qset.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-
-#include <private/qvariantanimation_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
-{
- QEasingCurve easingCurve;
-
- QString normalizedCurve = curve;
- bool hasParams = curve.contains(QLatin1Char('('));
- QStringList props;
-
- if (hasParams) {
- QString easeName = curve.trimmed();
- if (!easeName.endsWith(QLatin1Char(')'))) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Unmatched parenthesis in easing function \"%1\"").arg(curve);
- return easingCurve;
- }
-
- int idx = easeName.indexOf(QLatin1Char('('));
- QString prop_str =
- easeName.mid(idx + 1, easeName.length() - 1 - idx - 1);
- normalizedCurve = easeName.left(idx);
- if (!normalizedCurve.startsWith(QLatin1String("ease"))) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Easing function \"%1\" must start with \"ease\"").arg(curve);
- return easingCurve;
- }
-
- props = prop_str.split(QLatin1Char(','));
- }
-
- if (normalizedCurve.startsWith(QLatin1String("ease")))
- normalizedCurve = normalizedCurve.mid(4);
-
- static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type");
- static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index);
-
- int value = me.keyToValue(normalizedCurve.toUtf8().constData());
- if (value < 0) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing curve \"%1\"").arg(curve);
- return easingCurve;
- }
- easingCurve.setType((QEasingCurve::Type)value);
-
- if (hasParams) {
- foreach(const QString &str, props) {
- int sep = str.indexOf(QLatin1Char(':'));
-
- if (sep == -1) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
- continue;
- }
-
- QString propName = str.left(sep).trimmed();
- bool isOk;
- qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk);
-
- if (propName.isEmpty() || !isOk) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
- continue;
- }
-
- if (propName == QLatin1String("amplitude")) {
- easingCurve.setAmplitude(propValue);
- } else if (propName == QLatin1String("period")) {
- easingCurve.setPeriod(propValue);
- } else if (propName == QLatin1String("overshoot")) {
- easingCurve.setOvershoot(propValue);
- } else {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing parameter \"%1\"").arg(propName);
- continue;
- }
- }
- }
- return easingCurve;
-}
-
-QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation)
-
-/*!
- \qmlclass Animation QmlAbstractAnimation
- \since 4.7
- \brief The Animation element is the base of all QML animations.
-
- The Animation element cannot be used directly in a QML file. It exists
- to provide a set of common properties and methods, available across all the
- other animation types that inherit from it. Attempting to use the Animation
- element directly will result in an error.
-*/
-
-/*!
- \class QmlAbstractAnimation
- \internal
-*/
-
-QmlAbstractAnimation::QmlAbstractAnimation(QObject *parent)
-: QObject(*(new QmlAbstractAnimationPrivate), parent)
-{
-}
-
-QmlAbstractAnimation::~QmlAbstractAnimation()
-{
-}
-
-QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObject *parent)
-: QObject(dd, parent)
-{
-}
-
-/*!
- \qmlproperty bool Animation::running
- This property holds whether the animation is currently running.
-
- The \c running property can be set to declaratively control whether or not
- an animation is running. The following example will animate a rectangle
- whenever the \l MouseArea is pressed.
-
- \code
- Rectangle {
- width: 100; height: 100
- x: NumberAnimation {
- running: myMouse.pressed
- from: 0; to: 100
- }
- MouseArea { id: myMouse }
- }
- \endcode
-
- Likewise, the \c running property can be read to determine if the animation
- is running. In the following example the text element will indicate whether
- or not the animation is running.
-
- \code
- NumberAnimation { id: myAnimation }
- Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" }
- \endcode
-
- Animations can also be started and stopped imperatively from JavaScript
- using the \c start() and \c stop() methods.
-
- By default, animations are not running. Though, when the animations are assigned to properties,
- as property value sources, they are set to running by default.
-*/
-bool QmlAbstractAnimation::isRunning() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->running;
-}
-
-//commence is called to start an animation when it is used as a
-//simple animation, and not as part of a transition
-void QmlAbstractAnimationPrivate::commence()
-{
- Q_Q(QmlAbstractAnimation);
-
- QmlStateActions actions;
- QmlMetaProperties properties;
- q->transition(actions, properties, QmlAbstractAnimation::Forward);
-
- q->qtAnimation()->start();
- if (q->qtAnimation()->state() != QAbstractAnimation::Running) {
- running = false;
- emit q->completed();
- }
-}
-
-QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
-{
- QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj));
- if (!prop.isValid()) {
- qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
- return QmlMetaProperty();
- } else if (!prop.isWritable()) {
- qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str);
- return QmlMetaProperty();
- }
- return prop;
-}
-
-void QmlAbstractAnimation::setRunning(bool r)
-{
- Q_D(QmlAbstractAnimation);
- if (!d->componentComplete) {
- d->running = r;
- if (r == false)
- d->avoidPropertyValueSourceStart = true;
- return;
- }
-
- if (d->running == r)
- return;
-
- if (d->group || d->disableUserControl) {
- qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- return;
- }
-
- d->running = r;
- if (d->running) {
- if (d->alwaysRunToEnd && d->repeat
- && qtAnimation()->state() == QAbstractAnimation::Running) {
- qtAnimation()->setLoopCount(-1);
- }
-
- if (!d->connectedTimeLine) {
- QObject::connect(qtAnimation(), SIGNAL(finished()),
- this, SLOT(timelineComplete()));
- d->connectedTimeLine = true;
- }
- d->commence();
- emit started();
- } else {
- if (d->alwaysRunToEnd) {
- if (d->repeat)
- qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1);
- } else
- qtAnimation()->stop();
-
- emit completed();
- }
-
- emit runningChanged(d->running);
-}
-
-/*!
- \qmlproperty bool Animation::paused
- This property holds whether the animation is currently paused.
-
- The \c paused property can be set to declaratively control whether or not
- an animation is paused.
-
- Animations can also be paused and resumed imperatively from JavaScript
- using the \c pause() and \c resume() methods.
-
- By default, animations are not paused.
-*/
-bool QmlAbstractAnimation::isPaused() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->paused;
-}
-
-void QmlAbstractAnimation::setPaused(bool p)
-{
- Q_D(QmlAbstractAnimation);
- if (d->paused == p)
- return;
-
- if (d->group || d->disableUserControl) {
- qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes");
- return;
- }
-
- d->paused = p;
- if (d->paused)
- qtAnimation()->pause();
- else
- qtAnimation()->resume();
-
- emit pausedChanged(d->paused);
-}
-
-void QmlAbstractAnimation::classBegin()
-{
- Q_D(QmlAbstractAnimation);
- d->componentComplete = false;
-}
-
-void QmlAbstractAnimation::componentComplete()
-{
- Q_D(QmlAbstractAnimation);
- d->componentComplete = true;
- if (d->running) {
- d->running = false;
- setRunning(true);
- }
-}
-
-/*!
- \qmlproperty bool Animation::alwaysRunToEnd
- This property holds whether the animation should run to completion when it is stopped.
-
- If this true the animation will complete its current iteration when it
- is stopped - either by setting the \c running property to false, or by
- calling the \c stop() method. The \c complete() method is not effected
- by this value.
-
- This behavior is most useful when the \c repeat property is set, as the
- animation will finish playing normally but not restart.
-
- By default, the alwaysRunToEnd property is not set.
-*/
-bool QmlAbstractAnimation::alwaysRunToEnd() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->alwaysRunToEnd;
-}
-
-void QmlAbstractAnimation::setAlwaysRunToEnd(bool f)
-{
- Q_D(QmlAbstractAnimation);
- if (d->alwaysRunToEnd == f)
- return;
-
- d->alwaysRunToEnd = f;
- emit alwaysRunToEndChanged(f);
-}
-
-/*!
- \qmlproperty bool Animation::repeat
- This property holds whether the animation should repeat.
-
- If set, the animation will continuously repeat until it is explicitly
- stopped - either by setting the \c running property to false, or by calling
- the \c stop() method.
-
- In the following example, the rectangle will spin indefinately.
-
- \code
- Rectangle {
- rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
- }
- \endcode
-*/
-bool QmlAbstractAnimation::repeat() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->repeat;
-}
-
-void QmlAbstractAnimation::setRepeat(bool r)
-{
- Q_D(QmlAbstractAnimation);
- if (r == d->repeat)
- return;
-
- d->repeat = r;
- int lc = r ? -1 : 1;
- qtAnimation()->setLoopCount(lc);
- emit repeatChanged(r);
-}
-
-int QmlAbstractAnimation::currentTime()
-{
- return qtAnimation()->currentLoopTime();
-}
-
-void QmlAbstractAnimation::setCurrentTime(int time)
-{
- qtAnimation()->setCurrentTime(time);
-}
-
-QmlAnimationGroup *QmlAbstractAnimation::group() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->group;
-}
-
-void QmlAbstractAnimation::setGroup(QmlAnimationGroup *g)
-{
- Q_D(QmlAbstractAnimation);
- if (d->group == g)
- return;
- if (d->group)
- static_cast<QmlAnimationGroupPrivate *>(d->group->d_func())->animations.removeAll(this);
-
- d->group = g;
-
- if (d->group && !static_cast<QmlAnimationGroupPrivate *>(d->group->d_func())->animations.contains(this))
- static_cast<QmlAnimationGroupPrivate *>(d->group->d_func())->animations.append(this);
-
- if (d->group)
- ((QAnimationGroup*)d->group->qtAnimation())->addAnimation(qtAnimation());
-
- //if (g) //if removed from a group, then the group should no longer be the parent
- setParent(g);
-}
-
-/*!
- \qmlmethod Animation::start()
- \brief Starts the animation.
-
- If the animation is already running, calling this method has no effect. The
- \c running property will be true following a call to \c start().
-*/
-void QmlAbstractAnimation::start()
-{
- setRunning(true);
-}
-
-/*!
- \qmlmethod Animation::pause()
- \brief Pauses the animation.
-
- If the animation is already paused, calling this method has no effect. The
- \c paused property will be true following a call to \c pause().
-*/
-void QmlAbstractAnimation::pause()
-{
- setPaused(true);
-}
-
-/*!
- \qmlmethod Animation::resume()
- \brief Resumes a paused animation.
-
- If the animation is not paused, calling this method has no effect. The
- \c paused property will be false following a call to \c resume().
-*/
-void QmlAbstractAnimation::resume()
-{
- setPaused(false);
-}
-
-/*!
- \qmlmethod Animation::stop()
- \brief Stops the animation.
-
- If the animation is not running, calling this method has no effect. The
- \c running property will be false following a call to \c stop().
-
- Normally \c stop() stops the animation immediately, and the animation has
- no further influence on property values. In this example animation
- \code
- Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
- }
- \endcode
- was stopped at time 250ms, the \c x property will have a value of 50.
-
- However, if the \c alwaysRunToEnd property is set, the animation will
- continue running until it completes and then stop. The \c running property
- will still become false immediately.
-*/
-void QmlAbstractAnimation::stop()
-{
- setRunning(false);
-}
-
-/*!
- \qmlmethod Animation::restart()
- \brief Restarts the animation.
-
- This is a convenience method, and is equivalent to calling \c stop() and
- then \c start().
-*/
-void QmlAbstractAnimation::restart()
-{
- stop();
- start();
-}
-
-/*!
- \qmlmethod Animation::complete()
- \brief Stops the animation, jumping to the final property values.
-
- If the animation is not running, calling this method has no effect. The
- \c running property will be false following a call to \c complete().
-
- Unlike \c stop(), \c complete() immediately fast-forwards the animation to
- its end. In the following example,
- \code
- Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
- }
- \endcode
- calling \c stop() at time 250ms will result in the \c x property having
- a value of 50, while calling \c complete() will set the \c x property to
- 100, exactly as though the animation had played the whole way through.
-*/
-void QmlAbstractAnimation::complete()
-{
- if (isRunning()) {
- qtAnimation()->setCurrentTime(qtAnimation()->duration());
- }
-}
-
-void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p)
-{
- Q_D(QmlAbstractAnimation);
- d->defaultProperty = p;
-
- if (!d->avoidPropertyValueSourceStart)
- setRunning(true);
-}
-
-/*
- we rely on setTarget only being called when used as a value source
- so this function allows us to do the same thing as setTarget without
- that assumption
-*/
-void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p)
-{
- Q_D(QmlAbstractAnimation);
- d->defaultProperty = p;
-}
-
-/*
- don't allow start/stop/pause/resume to be manually invoked,
- because something else (like a Behavior) already has control
- over the animation.
-*/
-void QmlAbstractAnimation::setDisableUserControl()
-{
- Q_D(QmlAbstractAnimation);
- d->disableUserControl = true;
-}
-
-void QmlAbstractAnimation::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_UNUSED(actions);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
-}
-
-void QmlAbstractAnimation::timelineComplete()
-{
- Q_D(QmlAbstractAnimation);
- setRunning(false);
- if (d->alwaysRunToEnd && d->repeat) {
- qtAnimation()->setLoopCount(-1);
- }
-}
-
-/*!
- \qmlclass PauseAnimation QmlPauseAnimation
- \since 4.7
- \inherits Animation
- \brief The PauseAnimation element provides a pause for an animation.
-
- When used in a SequentialAnimation, PauseAnimation is a step when
- nothing happens, for a specified duration.
-
- A 500ms animation sequence, with a 100ms pause between two animations:
- \code
- SequentialAnimation {
- NumberAnimation { ... duration: 200 }
- PauseAnimation { duration: 100 }
- NumberAnimation { ... duration: 200 }
- }
- \endcode
-*/
-/*!
- \internal
- \class QmlPauseAnimation
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,PauseAnimation,QmlPauseAnimation)
-QmlPauseAnimation::QmlPauseAnimation(QObject *parent)
-: QmlAbstractAnimation(*(new QmlPauseAnimationPrivate), parent)
-{
- Q_D(QmlPauseAnimation);
- d->init();
-}
-
-QmlPauseAnimation::~QmlPauseAnimation()
-{
-}
-
-void QmlPauseAnimationPrivate::init()
-{
- Q_Q(QmlPauseAnimation);
- pa = new QPauseAnimation;
- QmlGraphics_setParent_noEvent(pa, q);
-}
-
-/*!
- \qmlproperty int PauseAnimation::duration
- This property holds the duration of the pause in milliseconds
-
- The default value is 250.
-*/
-int QmlPauseAnimation::duration() const
-{
- Q_D(const QmlPauseAnimation);
- return d->pa->duration();
-}
-
-void QmlPauseAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QmlPauseAnimation);
- if (d->pa->duration() == duration)
- return;
- d->pa->setDuration(duration);
- emit durationChanged(duration);
-}
-
-QAbstractAnimation *QmlPauseAnimation::qtAnimation()
-{
- Q_D(QmlPauseAnimation);
- return d->pa;
-}
-
-/*!
- \qmlclass ColorAnimation QmlColorAnimation
- \since 4.7
- \inherits PropertyAnimation
- \brief The ColorAnimation element allows you to animate color changes.
-
- \code
- ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 }
- \endcode
-
- When used in a transition, ColorAnimation will by default animate
- all properties of type color that are changing. If a property or properties
- are explicitly set for the animation, then those will be used instead.
-*/
-/*!
- \internal
- \class QmlColorAnimation
-*/
-
-QmlColorAnimation::QmlColorAnimation(QObject *parent)
-: QmlPropertyAnimation(parent)
-{
- Q_D(QmlPropertyAnimation);
- d->interpolatorType = QMetaType::QColor;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
-}
-
-QmlColorAnimation::~QmlColorAnimation()
-{
-}
-
-/*!
- \qmlproperty color ColorAnimation::from
- This property holds the starting color.
-*/
-QColor QmlColorAnimation::from() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->from.value<QColor>();
-}
-
-void QmlColorAnimation::setFrom(const QColor &f)
-{
- QmlPropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty color ColorAnimation::to
- This property holds the ending color.
-*/
-QColor QmlColorAnimation::to() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->to.value<QColor>();
-}
-
-void QmlColorAnimation::setTo(const QColor &t)
-{
- QmlPropertyAnimation::setTo(t);
-}
-
-QML_DEFINE_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation)
-
-/*!
- \qmlclass ScriptAction QmlScriptAction
- \since 4.7
- \inherits Animation
- \brief The ScriptAction element allows scripts to be run during an animation.
-
-*/
-/*!
- \internal
- \class QmlScriptAction
-*/
-QmlScriptAction::QmlScriptAction(QObject *parent)
- :QmlAbstractAnimation(*(new QmlScriptActionPrivate), parent)
-{
- Q_D(QmlScriptAction);
- d->init();
-}
-
-QmlScriptAction::~QmlScriptAction()
-{
-}
-
-void QmlScriptActionPrivate::init()
-{
- Q_Q(QmlScriptAction);
- rsa = new QActionAnimation(&proxy);
- QmlGraphics_setParent_noEvent(rsa, q);
-}
-
-/*!
- \qmlproperty script ScriptAction::script
- This property holds the script to run.
-*/
-QmlScriptString QmlScriptAction::script() const
-{
- Q_D(const QmlScriptAction);
- return d->script;
-}
-
-void QmlScriptAction::setScript(const QmlScriptString &script)
-{
- Q_D(QmlScriptAction);
- d->script = script;
-}
-
-/*!
- \qmlproperty QString ScriptAction::stateChangeScriptName
- This property holds the the name of the StateChangeScript to run.
-
- This property is only valid when ScriptAction is used as part of a transition.
- If both script and stateChangeScriptName are set, stateChangeScriptName will be used.
-*/
-QString QmlScriptAction::stateChangeScriptName() const
-{
- Q_D(const QmlScriptAction);
- return d->name;
-}
-
-void QmlScriptAction::setStateChangeScriptName(const QString &name)
-{
- Q_D(QmlScriptAction);
- d->name = name;
-}
-
-void QmlScriptActionPrivate::execute()
-{
- QmlScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
-
- const QString &str = scriptStr.script();
- if (!str.isEmpty()) {
- QmlExpression expr(scriptStr.context(), str, scriptStr.scopeObject());
- expr.setTrackChange(false);
- expr.value();
- }
-}
-
-void QmlScriptAction::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlScriptAction);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
-
- d->hasRunScriptScript = false;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- if (action.event && action.event->typeName() == QLatin1String("StateChangeScript")
- && static_cast<QmlStateChangeScript*>(action.event)->name() == d->name) {
- //### how should we handle reverse direction?
- d->runScriptScript = static_cast<QmlStateChangeScript*>(action.event)->script();
- d->hasRunScriptScript = true;
- action.actionDone = true;
- break; //assumes names are unique
- }
- }
-}
-
-QAbstractAnimation *QmlScriptAction::qtAnimation()
-{
- Q_D(QmlScriptAction);
- return d->rsa;
-}
-
-QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction)
-
-/*!
- \qmlclass PropertyAction QmlPropertyAction
- \since 4.7
- \inherits Animation
- \brief The PropertyAction element allows immediate property changes during animation.
-
- Explicitly set \c theimage.smooth=true during a transition:
- \code
- PropertyAction { target: theimage; property: "smooth"; value: true }
- \endcode
-
- Set \c thewebview.url to the value set for the destination state:
- \code
- PropertyAction { target: thewebview; property: "url" }
- \endcode
-
- The PropertyAction is immediate -
- the target property is not animated to the selected value in any way.
-*/
-/*!
- \internal
- \class QmlPropertyAction
-*/
-QmlPropertyAction::QmlPropertyAction(QObject *parent)
-: QmlAbstractAnimation(*(new QmlPropertyActionPrivate), parent)
-{
- Q_D(QmlPropertyAction);
- d->init();
-}
-
-QmlPropertyAction::~QmlPropertyAction()
-{
-}
-
-void QmlPropertyActionPrivate::init()
-{
- Q_Q(QmlPropertyAction);
- spa = new QActionAnimation;
- QmlGraphics_setParent_noEvent(spa, q);
-}
-
-/*!
- \qmlproperty Object PropertyAction::target
- This property holds an explicit target object to animate.
-
- The exact effect of the \c target property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
-
-QObject *QmlPropertyAction::target() const
-{
- Q_D(const QmlPropertyAction);
- return d->target;
-}
-
-void QmlPropertyAction::setTarget(QObject *o)
-{
- Q_D(QmlPropertyAction);
- if (d->target == o)
- return;
- d->target = o;
- emit targetChanged(d->target, d->propertyName);
-}
-
-QString QmlPropertyAction::property() const
-{
- Q_D(const QmlPropertyAction);
- return d->propertyName;
-}
-
-void QmlPropertyAction::setProperty(const QString &n)
-{
- Q_D(QmlPropertyAction);
- if (d->propertyName == n)
- return;
- d->propertyName = n;
- emit targetChanged(d->target, d->propertyName);
-}
-
-/*!
- \qmlproperty string PropertyAction::property
- \qmlproperty string PropertyAction::properties
- \qmlproperty Object PropertyAction::target
- \qmlproperty list<Object> PropertyAction::targets
-
- These properties are used as a set to determine which properties should be
- affected by this action.
-
- The details of how these properties are interpreted in different situations
- is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
- documentation.
-
- \sa exclude
-*/
-QString QmlPropertyAction::properties() const
-{
- Q_D(const QmlPropertyAction);
- return d->properties;
-}
-
-void QmlPropertyAction::setProperties(const QString &p)
-{
- Q_D(QmlPropertyAction);
- if (d->properties == p)
- return;
- d->properties = p;
- emit propertiesChanged(p);
-}
-
-QmlListProperty<QObject> QmlPropertyAction::targets()
-{
- Q_D(QmlPropertyAction);
- return QmlListProperty<QObject>(this, d->targets);
-}
-
-/*!
- \qmlproperty list<Object> PropertyAction::exclude
- This property holds the objects not to be affected by this animation.
- \sa targets
-*/
-QmlListProperty<QObject> QmlPropertyAction::exclude()
-{
- Q_D(QmlPropertyAction);
- return QmlListProperty<QObject>(this, d->exclude);
-}
-
-/*!
- \qmlproperty any PropertyAction::value
- This property holds the value to be set on the property.
- If not set, then the value defined for the end state of the transition.
-*/
-QVariant QmlPropertyAction::value() const
-{
- Q_D(const QmlPropertyAction);
- return d->value;
-}
-
-void QmlPropertyAction::setValue(const QVariant &v)
-{
- Q_D(QmlPropertyAction);
- if (d->value.isNull || d->value != v) {
- d->value = v;
- emit valueChanged(v);
- }
-}
-
-QAbstractAnimation *QmlPropertyAction::qtAnimation()
-{
- Q_D(QmlPropertyAction);
- return d->spa;
-}
-
-void QmlPropertyAction::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlPropertyAction);
- Q_UNUSED(direction);
-
- struct QmlSetPropertyAnimationAction : public QAbstractAnimationAction
- {
- QmlStateActions actions;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QmlAction &action = actions.at(ii);
- action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
- }
- };
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty())
- props << d->propertyName;
-
- QList<QObject*> targets = d->targets;
- if (d->target)
- targets.append(d->target);
-
- bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
-
- if (d->defaultProperty.isValid() && !hasSelectors) {
- props << d->defaultProperty.name();
- targets << d->defaultProperty.object();
- }
-
- QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction;
-
- bool hasExplicit = false;
- //an explicit animation has been specified
- if (d->value.isValid()) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
- QmlAction myAction;
- myAction.property = d->createProperty(targets.at(j), props.at(i), this);
- if (myAction.property.isValid()) {
- myAction.toValue = d->value;
- QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
- }
- }
- }
- }
- }
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
- QObject *sObj = action.specifiedObject;
- QString sPropertyName = action.specifiedProperty;
- bool same = (obj == sObj);
-
- if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
- (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
- QmlAction myAction = action;
-
- if (d->value.isValid())
- myAction.toValue = d->value;
- QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
-
- modified << action.property;
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- if (data->actions.count()) {
- d->spa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
- } else {
- delete data;
- }
-}
-
-QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction)
-
-/*!
- \qmlclass ParentAction QmlParentAction
- \since 4.7
- \inherits Animation
- \brief The ParentAction element allows parent changes during animation.
-
- ParentAction provides a way to specify at what point in a Transition a ParentChange should
- occur.
- \qml
- State {
- ParentChange {
- target: myItem
- parent: newParent
- }
- }
- Transition {
- SequentialAnimation {
- PropertyAnimation { ... }
- ParentAction {} //reparent myItem now
- PropertyAnimation { ... }
- }
- }
- \endqml
-
- It also provides a way to explicitly reparent an item during an animation.
- \qml
- SequentialAnimation {
- ParentAction { target: myItem; parent: newParent }
- PropertyAnimation {}
- }
- \endqml
-
- The ParentAction is immediate - it is not animated in any way.
-*/
-
-QmlParentAction::QmlParentAction(QObject *parent)
-: QmlAbstractAnimation(*(new QmlParentActionPrivate), parent)
-{
- Q_D(QmlParentAction);
- d->init();
-}
-
-QmlParentAction::~QmlParentAction()
-{
-}
-
-void QmlParentActionPrivate::init()
-{
- Q_Q(QmlParentAction);
- cpa = new QActionAnimation;
- QmlGraphics_setParent_noEvent(cpa, q);
-}
-
-/*!
- \qmlproperty Item ParentAction::target
-
- This property holds a target item to reparent.
-
- In the following example, \c myItem will be reparented by the ParentAction, while
- \c myOtherItem will not.
- \qml
- State {
- ParentChange {
- target: myItem
- parent: newParent
- }
- ParentChange {
- target: myOtherItem
- parent: otherNewParent
- }
- }
- Transition {
- SequentialAnimation {
- PropertyAnimation { ... }
- ParentAction { target: myItem }
- PropertyAnimation { ... }
- }
- }
- \endqml
-
- */
-QmlGraphicsItem *QmlParentAction::object() const
-{
- Q_D(const QmlParentAction);
- return d->pcTarget;
-}
-
-void QmlParentAction::setObject(QmlGraphicsItem *target)
-{
- Q_D(QmlParentAction);
- d->pcTarget = target;
-}
-
-/*!
- \qmlproperty Item ParentAction::parent
-
- The item to reparent to (i.e. the new parent).
- */
-QmlGraphicsItem *QmlParentAction::parent() const
-{
- Q_D(const QmlParentAction);
- return d->pcParent;
-}
-
-void QmlParentAction::setParent(QmlGraphicsItem *parent)
-{
- Q_D(QmlParentAction);
- d->pcParent = parent;
-}
-
-void QmlParentActionPrivate::doAction()
-{
- QmlParentChange pc;
- pc.setObject(pcTarget);
- pc.setParent(pcParent);
- pc.execute();
-}
-
-QAbstractAnimation *QmlParentAction::qtAnimation()
-{
- Q_D(QmlParentAction);
- return d->cpa;
-}
-
-void QmlParentAction::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlParentAction);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
-
- struct QmlParentActionData : public QAbstractAnimationAction
- {
- QmlParentActionData(): pc(0) {}
- ~QmlParentActionData() { delete pc; }
-
- QmlStateActions actions;
- bool reverse;
- QmlParentChange *pc;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QmlAction &action = actions.at(ii);
- if (reverse)
- action.event->reverse();
- else
- action.event->execute();
- }
- }
- };
-
- QmlParentActionData *data = new QmlParentActionData;
-
- //### need to correctly handle modified/done
-
- bool hasExplicit = false;
- if (d->pcTarget && d->pcParent) {
- data->reverse = false;
- QmlAction myAction;
- QmlParentChange *pc = new QmlParentChange;
- pc->setObject(d->pcTarget);
- pc->setParent(d->pcParent);
- myAction.event = pc;
- data->pc = pc;
- data->actions << myAction;
- hasExplicit = true;
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- if (action.event && action.event->typeName() == QLatin1String("ParentChange")
- && (!d->pcTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcTarget)) {
- QmlAction myAction = action;
- data->reverse = action.reverseEvent;
- //### this logic differs from PropertyAnimation
- // (probably a result of modified vs. done)
- if (d->pcParent) {
- //### should we disallow this case?
- QmlParentChange *pc = new QmlParentChange;
- pc->setObject(d->pcTarget);
- pc->setParent(static_cast<QmlParentChange*>(action.event)->parent());
- myAction.event = pc;
- data->pc = pc;
- data->actions << myAction;
- break; //only match one
- } else {
- action.actionDone = true;
- data->actions << myAction;
- }
- }
- }
-
- if (data->actions.count()) {
- d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
- } else {
- delete data;
- }
-}
-
-QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction)
-
-/*!
- \qmlclass NumberAnimation QmlNumberAnimation
- \since 4.7
- \inherits PropertyAnimation
- \brief The NumberAnimation element allows you to animate changes in properties of type qreal.
-
- Animate a set of properties over 200ms, from their values in the start state to
- their values in the end state of the transition:
- \code
- NumberAnimation { properties: "x,y,scale"; duration: 200 }
- \endcode
-*/
-
-/*!
- \internal
- \class QmlNumberAnimation
-*/
-
-QmlNumberAnimation::QmlNumberAnimation(QObject *parent)
-: QmlPropertyAnimation(parent)
-{
- Q_D(QmlPropertyAnimation);
- d->interpolatorType = QMetaType::QReal;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
-}
-
-QmlNumberAnimation::~QmlNumberAnimation()
-{
-}
-
-/*!
- \qmlproperty real NumberAnimation::from
- This property holds the starting value.
- If not set, then the value defined in the start state of the transition.
-*/
-qreal QmlNumberAnimation::from() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->from.toReal();
-}
-
-void QmlNumberAnimation::setFrom(qreal f)
-{
- QmlPropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real NumberAnimation::to
- This property holds the ending value.
- If not set, then the value defined in the end state of the transition or Behavior.
-*/
-qreal QmlNumberAnimation::to() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->to.toReal();
-}
-
-void QmlNumberAnimation::setTo(qreal t)
-{
- QmlPropertyAnimation::setTo(t);
-}
-
-QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation)
-
-/*!
- \qmlclass Vector3dAnimation QmlVector3dAnimation
- \since 4.7
- \inherits PropertyAnimation
- \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
-*/
-
-/*!
- \internal
- \class QmlVector3dAnimation
-*/
-
-QmlVector3dAnimation::QmlVector3dAnimation(QObject *parent)
-: QmlPropertyAnimation(parent)
-{
- Q_D(QmlPropertyAnimation);
- d->interpolatorType = QMetaType::QVector3D;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
-}
-
-QmlVector3dAnimation::~QmlVector3dAnimation()
-{
-}
-
-/*!
- \qmlproperty real Vector3dAnimation::from
- This property holds the starting value.
- If not set, then the value defined in the start state of the transition.
-*/
-QVector3D QmlVector3dAnimation::from() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->from.value<QVector3D>();
-}
-
-void QmlVector3dAnimation::setFrom(QVector3D f)
-{
- QmlPropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real Vector3dAnimation::to
- This property holds the ending value.
- If not set, then the value defined in the end state of the transition or Behavior.
-*/
-QVector3D QmlVector3dAnimation::to() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->to.value<QVector3D>();
-}
-
-void QmlVector3dAnimation::setTo(QVector3D t)
-{
- QmlPropertyAnimation::setTo(t);
-}
-
-QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation)
-
-/*!
- \qmlclass RotationAnimation QmlRotationAnimation
- \since 4.7
- \inherits PropertyAnimation
- \brief The RotationAnimation element allows you to animate rotations.
-
- RotationAnimation is a specialized PropertyAnimation that gives control
- over the direction of rotation.
-
- The RotationAnimation in the following example ensures that we always take
- the shortest rotation path when switching between our states.
- \qml
- states: {
- State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
- State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } }
- State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } }
- }
- transition: Transition {
- RotationAnimation { direction: RotationAnimation.Shortest }
- }
- \endqml
-
- By default, when used in a transition RotationAnimation will rotate all
- properties named "rotation" or "angle". You can override this by providing
- your own properties via \c properties or \c property.
-*/
-
-/*!
- \internal
- \class QmlRotationAnimation
-*/
-
-QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff > 180.0){
- newt -= 360.0;
- diff -= 360.0;
- }
- while(diff < -180.0){
- newt += 360.0;
- diff += 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff < 0.0){
- newt += 360.0;
- diff += 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
-{
- qreal newt = t;
- qreal diff = t-f;
- while(diff > 0.0){
- newt -= 360.0;
- diff -= 360.0;
- }
- return QVariant(f + (newt - f) * progress);
-}
-
-QmlRotationAnimation::QmlRotationAnimation(QObject *parent)
-: QmlPropertyAnimation(*(new QmlRotationAnimationPrivate), parent)
-{
- Q_D(QmlRotationAnimation);
- d->interpolatorType = QMetaType::QReal;
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
- d->defaultProperties = QLatin1String("rotation,angle");
-}
-
-QmlRotationAnimation::~QmlRotationAnimation()
-{
-}
-
-/*!
- \qmlproperty real RotationAnimation::from
- This property holds the starting value.
- If not set, then the value defined in the start state of the transition.
-*/
-qreal QmlRotationAnimation::from() const
-{
- Q_D(const QmlRotationAnimation);
- return d->from.toReal();
-}
-
-void QmlRotationAnimation::setFrom(qreal f)
-{
- QmlPropertyAnimation::setFrom(f);
-}
-
-/*!
- \qmlproperty real RotationAnimation::to
- This property holds the ending value.
- If not set, then the value defined in the end state of the transition or Behavior.
-*/
-qreal QmlRotationAnimation::to() const
-{
- Q_D(const QmlRotationAnimation);
- return d->to.toReal();
-}
-
-void QmlRotationAnimation::setTo(qreal t)
-{
- QmlPropertyAnimation::setTo(t);
-}
-
-/*!
- \qmlproperty enum RotationAnimation::direction
- The direction in which to rotate.
- Possible values are Numerical, Clockwise, Counterclockwise,
- or Shortest.
-
- \table
- \row
- \o Numerical
- \o Rotate by linearly interpolating between the two numbers.
- A rotation from 10 to 350 will rotate 340 degrees clockwise.
- \row
- \o Clockwise
- \o Rotate clockwise between the two values
- \row
- \o Counterclockwise
- \o Rotate counterclockwise between the two values
- \row
- \o Shortest
- \o Rotate in the direction that produces the shortest animation path.
- A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
- \endtable
-
- The default direction is Shortest.
-*/
-QmlRotationAnimation::RotationDirection QmlRotationAnimation::direction() const
-{
- Q_D(const QmlRotationAnimation);
- return d->direction;
-}
-
-void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection direction)
-{
- Q_D(QmlRotationAnimation);
- if (d->direction == direction)
- return;
-
- d->direction = direction;
- switch(d->direction) {
- case Clockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
- break;
- case Counterclockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
- break;
- case Shortest:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
- break;
- default:
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- break;
- }
-
- emit directionChanged();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation)
-
-QmlAnimationGroup::QmlAnimationGroup(QObject *parent)
-: QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent)
-{
-}
-
-void QmlAnimationGroupPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a)
-{
- QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object);
- if (q) {
- q->d_func()->animations.append(a);
- a->setGroup(q);
- }
-}
-
-void QmlAnimationGroupPrivate::clear_animation(QmlListProperty<QmlAbstractAnimation> *list)
-{
- QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object);
- if (q) {
- for (int i = 0; i < q->d_func()->animations.count(); ++i)
- q->d_func()->animations.at(i)->setGroup(0);
- q->d_func()->animations.clear();
- }
-}
-
-QmlAnimationGroup::~QmlAnimationGroup()
-{
-}
-
-QmlListProperty<QmlAbstractAnimation> QmlAnimationGroup::animations()
-{
- Q_D(QmlAnimationGroup);
- QmlListProperty<QmlAbstractAnimation> list(this, d->animations);
- list.append = &QmlAnimationGroupPrivate::append_animation;
- list.clear = &QmlAnimationGroupPrivate::clear_animation;
- return list;
-}
-
-/*!
- \qmlclass SequentialAnimation QmlSequentialAnimation
- \since 4.7
- \inherits Animation
- \brief The SequentialAnimation element allows you to run animations sequentially.
-
- Animations controlled in SequentialAnimation will be run one after the other.
-
- The following example chains two numeric animations together. The \c MyItem
- object will animate from its current x position to 100, and then back to 0.
-
- \code
- SequentialAnimation {
- NumberAnimation { target: MyItem; property: "x"; to: 100 }
- NumberAnimation { target: MyItem; property: "x"; to: 0 }
- }
- \endcode
-
- \sa ParallelAnimation
-*/
-
-QmlSequentialAnimation::QmlSequentialAnimation(QObject *parent) :
- QmlAnimationGroup(parent)
-{
- Q_D(QmlAnimationGroup);
- d->ag = new QSequentialAnimationGroup(this);
-}
-
-QmlSequentialAnimation::~QmlSequentialAnimation()
-{
-}
-
-QAbstractAnimation *QmlSequentialAnimation::qtAnimation()
-{
- Q_D(QmlAnimationGroup);
- return d->ag;
-}
-
-void QmlSequentialAnimation::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlAnimationGroup);
-
- int inc = 1;
- int from = 0;
- if (direction == Backward) {
- inc = -1;
- from = d->animations.count() - 1;
- }
-
- bool valid = d->defaultProperty.isValid();
- for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- d->animations.at(ii)->transition(actions, modified, direction);
- }
-}
-
-QML_DEFINE_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation)
-
-/*!
- \qmlclass ParallelAnimation QmlParallelAnimation
- \since 4.7
- \inherits Animation
- \brief The ParallelAnimation element allows you to run animations in parallel.
-
- Animations contained in ParallelAnimation will be run at the same time.
-
- The following animation demonstrates animating the \c MyItem item
- to (100,100) by animating the x and y properties in parallel.
-
- \code
- ParallelAnimation {
- NumberAnimation { target: MyItem; property: "x"; to: 100 }
- NumberAnimation { target: MyItem; property: "y"; to: 100 }
- }
- \endcode
-
- \sa SequentialAnimation
-*/
-/*!
- \internal
- \class QmlParallelAnimation
-*/
-
-QmlParallelAnimation::QmlParallelAnimation(QObject *parent) :
- QmlAnimationGroup(parent)
-{
- Q_D(QmlAnimationGroup);
- d->ag = new QParallelAnimationGroup(this);
-}
-
-QmlParallelAnimation::~QmlParallelAnimation()
-{
-}
-
-QAbstractAnimation *QmlParallelAnimation::qtAnimation()
-{
- Q_D(QmlAnimationGroup);
- return d->ag;
-}
-
-void QmlParallelAnimation::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlAnimationGroup);
- bool valid = d->defaultProperty.isValid();
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- if (valid)
- d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
- d->animations.at(ii)->transition(actions, modified, direction);
- }
-}
-
-QML_DEFINE_TYPE(Qt,4,6,ParallelAnimation,QmlParallelAnimation)
-
-//convert a variant from string type to another animatable type
-void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
-{
- if (variant.userType() != QVariant::String) {
- variant.convert((QVariant::Type)type);
- return;
- }
-
- switch (type) {
- case QVariant::Rect: {
- variant.setValue(QmlStringConverters::rectFFromString(variant.toString()).toRect());
- break;
- }
- case QVariant::RectF: {
- variant.setValue(QmlStringConverters::rectFFromString(variant.toString()));
- break;
- }
- case QVariant::Point: {
- variant.setValue(QmlStringConverters::pointFFromString(variant.toString()).toPoint());
- break;
- }
- case QVariant::PointF: {
- variant.setValue(QmlStringConverters::pointFFromString(variant.toString()));
- break;
- }
- case QVariant::Size: {
- variant.setValue(QmlStringConverters::sizeFFromString(variant.toString()).toSize());
- break;
- }
- case QVariant::SizeF: {
- variant.setValue(QmlStringConverters::sizeFFromString(variant.toString()));
- break;
- }
- case QVariant::Color: {
- variant.setValue(QmlStringConverters::colorFromString(variant.toString()));
- break;
- }
- case QVariant::Vector3D: {
- variant.setValue(QmlStringConverters::vector3DFromString(variant.toString()));
- break;
- }
- default:
- if ((uint)type >= QVariant::UserType) {
- QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(type);
- if (converter)
- variant = converter(variant.toString());
- } else
- variant.convert((QVariant::Type)type);
- break;
- }
-}
-
-/*!
- \qmlclass PropertyAnimation QmlPropertyAnimation
- \since 4.7
- \inherits Animation
- \brief The PropertyAnimation element allows you to animate property changes.
-
- PropertyAnimation provides a way to animate changes to a property's value. It can
- be used in many different situations:
- \list
- \o In a Transition
-
- Animate any objects that have changed their x or y properties in the target state using
- an InOutQuad easing curve:
- \qml
- Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } }
- \endqml
- \o In a Behavior
-
- Animate all changes to a rectangle's x property.
- \qml
- Rectangle {
- x: Behavior { PropertyAnimation {} }
- }
- \endqml
- \o As a property value source
-
- Repeatedly animate the rectangle's x property.
- \qml
- Rectangle {
- x: SequentialAnimation {
- repeat: true
- PropertyAnimation { to: 50 }
- PropertyAnimation { to: 0 }
- }
- }
- \endqml
- \o In a signal handler
-
- Fade out \c theObject when clicked:
- \qml
- MouseArea {
- anchors.fill: theObject
- onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
- }
- \endqml
- \o Standalone
-
- Animate \c theObject's size property over 200ms, from its current size to 20-by-20:
- \qml
- PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 }
- \endqml
- \endlist
-
- Depending on how the animation is used, the set of properties normally used will be
- different. For more information see the individual property documentation, as well
- as the \l{QML Animation} introduction.
-*/
-
-QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
-: QmlAbstractAnimation(*(new QmlPropertyAnimationPrivate), parent)
-{
- Q_D(QmlPropertyAnimation);
- d->init();
-}
-
-QmlPropertyAnimation::QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent)
-: QmlAbstractAnimation(dd, parent)
-{
- Q_D(QmlPropertyAnimation);
- d->init();
-}
-
-QmlPropertyAnimation::~QmlPropertyAnimation()
-{
-}
-
-void QmlPropertyAnimationPrivate::init()
-{
- Q_Q(QmlPropertyAnimation);
- va = new QmlTimeLineValueAnimator;
- QmlGraphics_setParent_noEvent(va, q);
-}
-
-/*!
- \qmlproperty int PropertyAnimation::duration
- This property holds the duration of the transition, in milliseconds.
-
- The default value is 250.
-*/
-int QmlPropertyAnimation::duration() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->va->duration();
-}
-
-void QmlPropertyAnimation::setDuration(int duration)
-{
- if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
- return;
- }
-
- Q_D(QmlPropertyAnimation);
- if (d->va->duration() == duration)
- return;
- d->va->setDuration(duration);
- emit durationChanged(duration);
-}
-
-/*!
- \qmlproperty real PropertyAnimation::from
- This property holds the starting value.
- If not set, then the value defined in the start state of the transition.
-*/
-QVariant QmlPropertyAnimation::from() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->from;
-}
-
-void QmlPropertyAnimation::setFrom(const QVariant &f)
-{
- Q_D(QmlPropertyAnimation);
- if (d->fromIsDefined && f == d->from)
- return;
- d->from = f;
- d->fromIsDefined = f.isValid();
- emit fromChanged(f);
-}
-
-/*!
- \qmlproperty real PropertyAnimation::to
- This property holds the ending value.
- If not set, then the value defined in the end state of the transition or Behavior.
-*/
-QVariant QmlPropertyAnimation::to() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->to;
-}
-
-void QmlPropertyAnimation::setTo(const QVariant &t)
-{
- Q_D(QmlPropertyAnimation);
- if (d->toIsDefined && t == d->to)
- return;
- d->to = t;
- d->toIsDefined = t.isValid();
- emit toChanged(t);
-}
-
-/*!
- \qmlproperty string PropertyAnimation::easing
- \brief the easing curve used for the transition.
-
- Available values are:
-
- \table
- \row
- \o \c easeLinear
- \o Easing curve for a linear (t) function: velocity is constant.
- \o \inlineimage qeasingcurve-linear.png
- \row
- \o \c easeInQuad
- \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquad.png
- \row
- \o \c easeOutQuad
- \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity.
- \o \inlineimage qeasingcurve-outquad.png
- \row
- \o \c easeInOutQuad
- \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquad.png
- \row
- \o \c easeOutInQuad
- \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquad.png
- \row
- \o \c easeInCubic
- \o Easing curve for a cubic (t^3) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-incubic.png
- \row
- \o \c easeOutCubic
- \o Easing curve for a cubic (t^3) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outcubic.png
- \row
- \o \c easeInOutCubic
- \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutcubic.png
- \row
- \o \c easeOutInCubic
- \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outincubic.png
- \row
- \o \c easeInQuart
- \o Easing curve for a quartic (t^4) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquart.png
- \row
- \o \c easeOutQuart
- \o Easing curve for a cubic (t^4) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outquart.png
- \row
- \o \c easeInOutQuart
- \o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquart.png
- \row
- \o \c easeOutInQuart
- \o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquart.png
- \row
- \o \c easeInQuint
- \o Easing curve for a quintic (t^5) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inquint.png
- \row
- \o \c easeOutQuint
- \o Easing curve for a cubic (t^5) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outquint.png
- \row
- \o \c easeInOutQuint
- \o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutquint.png
- \row
- \o \c easeOutInQuint
- \o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinquint.png
- \row
- \o \c easeInSine
- \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-insine.png
- \row
- \o \c easeOutSine
- \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outsine.png
- \row
- \o \c easeInOutSine
- \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutsine.png
- \row
- \o \c easeOutInSine
- \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinsine.png
- \row
- \o \c easeInExpo
- \o Easing curve for an exponential (2^t) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inexpo.png
- \row
- \o \c easeOutExpo
- \o Easing curve for an exponential (2^t) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outexpo.png
- \row
- \o \c easeInOutExpo
- \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutexpo.png
- \row
- \o \c easeOutInExpo
- \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinexpo.png
- \row
- \o \c easeInCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-incirc.png
- \row
- \o \c easeOutCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outcirc.png
- \row
- \o \c easeInOutCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutcirc.png
- \row
- \o \c easeOutInCirc
- \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outincirc.png
- \row
- \o \c easeInElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
- \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \o \inlineimage qeasingcurve-inelastic.png
- \row
- \o \c easeOutElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
- \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
- \o \inlineimage qeasingcurve-outelastic.png
- \row
- \o \c easeInOutElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutelastic.png
- \row
- \o \c easeOutInElastic
- \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinelastic.png
- \row
- \o \c easeInBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inback.png
- \row
- \o \c easeOutBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
- \o \inlineimage qeasingcurve-outback.png
- \row
- \o \c easeInOutBack
- \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutback.png
- \row
- \o \c easeOutInBack
- \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinback.png
- \row
- \o \c easeInBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
- \o \inlineimage qeasingcurve-inbounce.png
- \row
- \o \c easeOutBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
- \o \inlineimage qeasingcurve-outbounce.png
- \row
- \o \c easeInOutBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
- \o \inlineimage qeasingcurve-inoutbounce.png
- \row
- \o \c easeOutInBounce
- \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
- \o \inlineimage qeasingcurve-outinbounce.png
- \endtable
-
-*/
-QString QmlPropertyAnimation::easing() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->easing;
-}
-
-void QmlPropertyAnimation::setEasing(const QString &e)
-{
- Q_D(QmlPropertyAnimation);
- if (d->easing == e)
- return;
-
- d->easing = e;
- d->va->setEasingCurve(stringToCurve(d->easing, this));
- emit easingChanged(e);
-}
-
-QObject *QmlPropertyAnimation::target() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->target;
-}
-
-void QmlPropertyAnimation::setTarget(QObject *o)
-{
- Q_D(QmlPropertyAnimation);
- if (d->target == o)
- return;
- d->target = o;
- emit targetChanged(d->target, d->propertyName);
-}
-
-QString QmlPropertyAnimation::property() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->propertyName;
-}
-
-void QmlPropertyAnimation::setProperty(const QString &n)
-{
- Q_D(QmlPropertyAnimation);
- if (d->propertyName == n)
- return;
- d->propertyName = n;
- emit targetChanged(d->target, d->propertyName);
-}
-
-QString QmlPropertyAnimation::properties() const
-{
- Q_D(const QmlPropertyAnimation);
- return d->properties;
-}
-
-void QmlPropertyAnimation::setProperties(const QString &prop)
-{
- Q_D(QmlPropertyAnimation);
- if (d->properties == prop)
- return;
-
- d->properties = prop;
- emit propertiesChanged(prop);
-}
-
-/*!
- \qmlproperty string PropertyAnimation::property
- \qmlproperty string PropertyAnimation::properties
- \qmlproperty Object PropertyAnimation::target
- \qmlproperty list<Object> PropertyAnimation::targets
-
- These properties are used as a set to determine which properties should be animated.
- The singular and plural forms are functionally identical, e.g.
- \qml
- NumberAnimation { target: theItem; property: "x"; to: 500 }
- \endqml
- has the same meaning as
- \qml
- NumberAnimation { targets: theItem; properties: "x"; to: 500 }
- \endqml
- The singular forms are slightly optimized, so if you do have only a single target/property
- to animate you should try to use them.
-
- In many cases these properties do not need to be explicitly specified -- they can be
- inferred from the animation framework.
- \table 80%
- \row
- \o Value Source / Behavior
- \o When an animation is used as a value source or in a Behavior, the default target and property
- name to be animated can both be inferred.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
- y: Behavior { NumberAnimation {} } //animate theRect's y property
- }
- \endqml
- \row
- \o Transition
- \o When used in a transition, a property animation is assumed to match \e all targets
- but \e no properties. In practice, that means you need to specify at least the properties
- in order for the animation to do anything.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- Item { id: uselessItem }
- states: State {
- name: "state1"
- PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
- PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
- }
- transitions: Transition {
- //animate both theRect's and uselessItem's x and y to their final values
- NumberAnimation { properties: "x,y" }
-
- //animate theRect's z to its final value
- NumberAnimation { target: theRect; property: "z" }
- }
- }
- \endqml
- \row
- \o Standalone
- \o When an animation is used standalone, both the target and property need to be
- explicitly specified.
- \qml
- Rectangle {
- id: theRect
- width: 100; height: 100
- color: Qt.rgba(0,0,1)
- //need to explicitly specify target and property
- NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 }
- MouseArea {
- anchors.fill: parent
- onClicked: theAnim.start()
- }
- }
- \endqml
- \endtable
-
- As seen in the above example, properties is specified as a comma-separated string of property names to animate.
-
- \sa exclude
-*/
-QmlListProperty<QObject> QmlPropertyAnimation::targets()
-{
- Q_D(QmlPropertyAnimation);
- return QmlListProperty<QObject>(this, d->targets);
-}
-
-/*!
- \qmlproperty list<Object> PropertyAnimation::exclude
- This property holds the items not to be affected by this animation.
- \sa targets
-*/
-QmlListProperty<QObject> QmlPropertyAnimation::exclude()
-{
- Q_D(QmlPropertyAnimation);
- return QmlListProperty<QObject>(this, d->exclude);
-}
-
-QAbstractAnimation *QmlPropertyAnimation::qtAnimation()
-{
- Q_D(QmlPropertyAnimation);
- return d->va;
-}
-
-struct PropertyUpdater : public QmlTimeLineValue
-{
- QmlStateActions actions;
- int interpolatorType; //for Number/ColorAnimation
- int prevInterpolatorType; //for generic
- QVariantAnimation::Interpolator interpolator;
- bool reverse;
- bool fromSourced;
- bool fromDefined;
- bool *wasDeleted;
- PropertyUpdater() : wasDeleted(0) {}
- ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
- void setValue(qreal v)
- {
- bool deleted = false;
- wasDeleted = &deleted;
- if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
- v = 1 - v;
- QmlTimeLineValue::setValue(v);
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- if (v == 1.)
- action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- else {
- if (!fromSourced && !fromDefined) {
- action.fromValue = action.property.read();
- if (interpolatorType)
- QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
- }
- if (!interpolatorType) {
- int propType = action.property.propertyType();
- if (!prevInterpolatorType || prevInterpolatorType != propType) {
- prevInterpolatorType = propType;
- interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
- }
- }
- if (interpolator)
- action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
- if (deleted)
- return;
- }
- wasDeleted = 0;
- fromSourced = true;
- }
-};
-
-void QmlPropertyAnimation::transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QmlPropertyAnimation);
-
- QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
- for (int ii = 0; ii < props.count(); ++ii)
- props[ii] = props.at(ii).trimmed();
- if (!d->propertyName.isEmpty())
- props << d->propertyName;
-
- QList<QObject*> targets = d->targets;
- if (d->target)
- targets.append(d->target);
-
- bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
- bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
-
- if (d->defaultProperty.isValid() && !hasSelectors) {
- props << d->defaultProperty.name();
- targets << d->defaultProperty.object();
- }
-
- if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
- props << d->defaultProperties.split(QLatin1Char(','));
- }
-
- PropertyUpdater *data = new PropertyUpdater;
- data->interpolatorType = d->interpolatorType;
- data->interpolator = d->interpolator;
- data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = d->fromIsDefined;
-
- bool hasExplicit = false;
- //an explicit animation has been specified
- if (d->toIsDefined) {
- for (int i = 0; i < props.count(); ++i) {
- for (int j = 0; j < targets.count(); ++j) {
- QmlAction myAction;
- myAction.property = d->createProperty(targets.at(j), props.at(i), this);
- if (myAction.property.isValid()) {
- if (d->fromIsDefined) {
- myAction.fromValue = d->from;
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- }
- myAction.toValue = d->to;
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
- }
- }
- }
- }
- }
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
- QObject *sObj = action.specifiedObject;
- QString sPropertyName = action.specifiedProperty;
- bool same = (obj == sObj);
-
- if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
- (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
- (props.contains(propertyName) || (!same && props.contains(sPropertyName))
- || (useType && action.property.propertyType() == d->interpolatorType))) {
- QmlAction myAction = action;
-
- if (d->fromIsDefined)
- myAction.fromValue = d->from;
- else
- myAction.fromValue = QVariant();
- if (d->toIsDefined)
- myAction.toValue = d->to;
-
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
-
- modified << action.property;
-
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
-
- if (data->actions.count()) {
- if (!d->rangeIsSet) {
- d->va->setStartValue(qreal(0));
- d->va->setEndValue(qreal(1));
- d->rangeIsSet = true;
- }
- d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
- d->va->setFromSourcedValue(&data->fromSourced);
- } else {
- delete data;
- }
-}
-
-QML_DEFINE_TYPE(Qt,4,6,PropertyAnimation,QmlPropertyAnimation)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
deleted file mode 100644
index 623ad8de4d..0000000000
--- a/src/declarative/util/qmlanimation_p.h
+++ /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$
-**
-****************************************************************************/
-
-#ifndef QMLANIMATION_H
-#define QMLANIMATION_H
-
-#include "qmltransition_p.h"
-#include "qmlstate_p.h"
-#include <QtGui/qvector3d.h>
-
-#include <qmlpropertyvaluesource.h>
-#include <qml.h>
-#include <qmlscriptstring.h>
-
-#include <QtCore/qvariant.h>
-#include <QtCore/QAbstractAnimation>
-#include <QtGui/qcolor.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlAbstractAnimationPrivate;
-class QmlAnimationGroup;
-class Q_AUTOTEST_EXPORT QmlAbstractAnimation : public QObject, public QmlPropertyValueSource, public QmlParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlAbstractAnimation)
-
- Q_INTERFACES(QmlParserStatus)
- Q_INTERFACES(QmlPropertyValueSource)
- Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged())
- Q_PROPERTY(bool repeat READ repeat WRITE setRepeat NOTIFY repeatChanged)
- Q_CLASSINFO("DefaultMethod", "start()")
-
-public:
- QmlAbstractAnimation(QObject *parent=0);
- virtual ~QmlAbstractAnimation();
-
- bool isRunning() const;
- void setRunning(bool);
- bool isPaused() const;
- void setPaused(bool);
- bool alwaysRunToEnd() const;
- void setAlwaysRunToEnd(bool);
- bool repeat() const;
- void setRepeat(bool);
-
- int currentTime();
- void setCurrentTime(int);
-
- QmlAnimationGroup *group() const;
- void setGroup(QmlAnimationGroup *);
-
- void setDefaultTarget(const QmlMetaProperty &);
- void setDisableUserControl();
-
- void classBegin();
- void componentComplete();
-
-Q_SIGNALS:
- void started();
- void completed();
- void runningChanged(bool);
- void pausedChanged(bool);
- void repeatChanged(bool);
- void alwaysRunToEndChanged(bool);
-
-public Q_SLOTS:
- void restart();
- void start();
- void pause();
- void resume();
- void stop();
- void complete();
-
-protected:
- QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObject *parent);
-
-public:
- enum TransitionDirection { Forward, Backward };
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation() = 0;
-
-private Q_SLOTS:
- void timelineComplete();
-
-private:
- virtual void setTarget(const QmlMetaProperty &);
-};
-
-class QmlPauseAnimationPrivate;
-class Q_AUTOTEST_EXPORT QmlPauseAnimation : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPauseAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
-
-public:
- QmlPauseAnimation(QObject *parent=0);
- virtual ~QmlPauseAnimation();
-
- int duration() const;
- void setDuration(int);
-
-Q_SIGNALS:
- void durationChanged(int);
-
-protected:
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QmlScriptActionPrivate;
-class QmlScriptAction : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlScriptAction)
-
- Q_PROPERTY(QmlScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString stateChangeScriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
-
-public:
- QmlScriptAction(QObject *parent=0);
- virtual ~QmlScriptAction();
-
- QmlScriptString script() const;
- void setScript(const QmlScriptString &);
-
- QString stateChangeScriptName() const;
- void setStateChangeScriptName(const QString &);
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QmlPropertyActionPrivate;
-class QmlPropertyAction : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPropertyAction)
-
- Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QmlListProperty<QObject> targets READ targets)
- Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
- Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
-
-public:
- QmlPropertyAction(QObject *parent=0);
- virtual ~QmlPropertyAction();
-
- QObject *target() const;
- void setTarget(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QmlListProperty<QObject> targets();
- QmlListProperty<QObject> exclude();
-
- QVariant value() const;
- void setValue(const QVariant &);
-
-Q_SIGNALS:
- void valueChanged(const QVariant &);
- void propertiesChanged(const QString &);
- void targetChanged(QObject *, const QString &);
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QmlGraphicsItem;
-class QmlParentActionPrivate;
-class QmlParentAction : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlParentAction)
-
- Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject)
- Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) //### newParent
-
-public:
- QmlParentAction(QObject *parent=0);
- virtual ~QmlParentAction();
-
- QmlGraphicsItem *object() const;
- void setObject(QmlGraphicsItem *);
-
- QmlGraphicsItem *parent() const;
- void setParent(QmlGraphicsItem *);
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QmlPropertyAnimationPrivate;
-class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPropertyAnimation)
-
- Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
- Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QmlListProperty<QObject> targets READ targets)
- Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
-
-public:
- QmlPropertyAnimation(QObject *parent=0);
- virtual ~QmlPropertyAnimation();
-
- int duration() const;
- void setDuration(int);
-
- QVariant from() const;
- void setFrom(const QVariant &);
-
- QVariant to() const;
- void setTo(const QVariant &);
-
- QString easing() const;
- void setEasing(const QString &);
-
- QObject *target() const;
- void setTarget(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QString properties() const;
- void setProperties(const QString &);
-
- QmlListProperty<QObject> targets();
- QmlListProperty<QObject> exclude();
-
-protected:
- QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent);
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-
-Q_SIGNALS:
- void durationChanged(int);
- void fromChanged(QVariant);
- void toChanged(QVariant);
- void easingChanged(const QString &);
- void propertiesChanged(const QString &);
- void targetChanged(QObject *, const QString &);
-};
-
-class Q_AUTOTEST_EXPORT QmlColorAnimation : public QmlPropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPropertyAnimation)
- Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged)
-
-public:
- QmlColorAnimation(QObject *parent=0);
- virtual ~QmlColorAnimation();
-
- QColor from() const;
- void setFrom(const QColor &);
-
- QColor to() const;
- void setTo(const QColor &);
-};
-
-class Q_AUTOTEST_EXPORT QmlNumberAnimation : public QmlPropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPropertyAnimation)
-
- Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
-
-public:
- QmlNumberAnimation(QObject *parent=0);
- virtual ~QmlNumberAnimation();
-
- qreal from() const;
- void setFrom(qreal);
-
- qreal to() const;
- void setTo(qreal);
-};
-
-class Q_AUTOTEST_EXPORT QmlVector3dAnimation : public QmlPropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPropertyAnimation)
-
- Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
-
-public:
- QmlVector3dAnimation(QObject *parent=0);
- virtual ~QmlVector3dAnimation();
-
- QVector3D from() const;
- void setFrom(QVector3D);
-
- QVector3D to() const;
- void setTo(QVector3D);
-};
-
-class QmlRotationAnimationPrivate;
-class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlRotationAnimation)
- Q_ENUMS(RotationDirection)
-
- Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
- Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
-
-public:
- QmlRotationAnimation(QObject *parent=0);
- virtual ~QmlRotationAnimation();
-
- qreal from() const;
- void setFrom(qreal);
-
- qreal to() const;
- void setTo(qreal);
-
- enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
- RotationDirection direction() const;
- void setDirection(RotationDirection direction);
-
-Q_SIGNALS:
- void directionChanged();
-};
-
-class QmlAnimationGroupPrivate;
-class QmlAnimationGroup : public QmlAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlAnimationGroup)
-
- Q_CLASSINFO("DefaultProperty", "animations")
- Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations)
-
-public:
- QmlAnimationGroup(QObject *parent);
- virtual ~QmlAnimationGroup();
-
- QmlListProperty<QmlAbstractAnimation> animations();
- friend class QmlAbstractAnimation;
-};
-
-class QmlSequentialAnimation : public QmlAnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlAnimationGroup)
-
-public:
- QmlSequentialAnimation(QObject *parent=0);
- virtual ~QmlSequentialAnimation();
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-class QmlParallelAnimation : public QmlAnimationGroup
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlAnimationGroup)
-
-public:
- QmlParallelAnimation(QObject *parent=0);
- virtual ~QmlParallelAnimation();
-
-protected:
- virtual void transition(QmlStateActions &actions,
- QmlMetaProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlAbstractAnimation)
-QML_DECLARE_TYPE(QmlPauseAnimation)
-QML_DECLARE_TYPE(QmlScriptAction)
-QML_DECLARE_TYPE(QmlPropertyAction)
-QML_DECLARE_TYPE(QmlParentAction)
-QML_DECLARE_TYPE(QmlPropertyAnimation)
-QML_DECLARE_TYPE(QmlColorAnimation)
-QML_DECLARE_TYPE(QmlNumberAnimation)
-QML_DECLARE_TYPE(QmlSequentialAnimation)
-QML_DECLARE_TYPE(QmlParallelAnimation)
-QML_DECLARE_TYPE(QmlVector3dAnimation)
-QML_DECLARE_TYPE(QmlRotationAnimation)
-
-QT_END_HEADER
-
-#endif // QMLANIMATION_H
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
deleted file mode 100644
index 056ce824d7..0000000000
--- a/src/declarative/util/qmlanimation_p_p.h
+++ /dev/null
@@ -1,364 +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 QMLANIMATION_P_H
-#define QMLANIMATION_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 "qmlanimation_p.h"
-
-#include "qmlnullablevalue_p_p.h"
-#include "qmltimeline_p_p.h"
-
-#include <qml.h>
-#include <qmlcontext.h>
-
-#include <QtCore/QPauseAnimation>
-#include <QtCore/QVariantAnimation>
-#include <QtCore/QAnimationGroup>
-#include <QtGui/QColor>
-#include <QDebug>
-
-#include <private/qobject_p.h>
-#include <private/qvariantanimation_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//interface for classes that provide animation actions for QActionAnimation
-class QAbstractAnimationAction
-{
-public:
- virtual ~QAbstractAnimationAction() {}
- virtual void doAction() = 0;
-};
-
-//templated animation action
-//allows us to specify an action that calls a function of a class.
-//(so that class doesn't have to inherit QmlAbstractAnimationAction)
-template<class T, void (T::*method)()>
-class QAnimationActionProxy : public QAbstractAnimationAction
-{
-public:
- QAnimationActionProxy(T *p) : m_p(p) {}
- virtual void doAction() { (m_p->*method)(); }
-
-private:
- T *m_p;
-};
-
-//performs an action of type QAbstractAnimationAction
-class QActionAnimation : public QAbstractAnimation
-{
- Q_OBJECT
-public:
- QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped), running(false) {}
- QActionAnimation(QAbstractAnimationAction *action, QObject *parent = 0)
- : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped), running(false) {}
- ~QActionAnimation() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } }
- virtual int duration() const { return 0; }
- void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p)
- {
- if (state() == Running)
- stop();
- if (policy == DeleteWhenStopped)
- delete animAction;
- animAction = action;
- policy = p;
- }
-protected:
- virtual void updateCurrentTime(int) {}
-
- virtual void updateState(State newState, State /*oldState*/)
- {
- if (newState == Running) {
- if (animAction) {
- running = true;
- animAction->doAction();
- running = false;
- if (state() == Stopped && policy == DeleteWhenStopped) {
- delete animAction;
- animAction = 0;
- }
- }
- } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
- if (!running) {
- delete animAction;
- animAction = 0;
- }
- }*/
- }
-
-private:
- QAbstractAnimationAction *animAction;
- DeletionPolicy policy;
- bool running;
-};
-
-//animates QmlTimeLineValue (assumes start and end values will be reals or compatible)
-class QmlTimeLineValueAnimator : public QVariantAnimation
-{
- Q_OBJECT
-public:
- QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
- ~QmlTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
- void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p)
- {
- if (state() == Running)
- stop();
- if (policy == DeleteWhenStopped)
- delete animValue;
- animValue = value;
- policy = p;
- }
- void setFromSourcedValue(bool *value)
- {
- fromSourced = value;
- }
-protected:
- virtual void updateCurrentValue(const QVariant &value)
- {
- if (animValue)
- animValue->setValue(value.toReal());
- }
- virtual void updateState(State newState, State oldState)
- {
- QVariantAnimation::updateState(newState, oldState);
- if (newState == Running) {
- //check for new from every loop
- if (fromSourced)
- *fromSourced = false;
- } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
- delete animValue;
- animValue = 0;
- }*/ //### we get a stop each loop if we are in a group
- //### top-level animation is the only reliable one for this
- }
-
-private:
- QmlTimeLineValue *animValue;
- bool *fromSourced;
- DeletionPolicy policy;
-};
-
-//an animation that just gives a tick
-template<class T, void (T::*method)(int)>
-class QTickAnimationProxy : public QAbstractAnimation
-{
- //Q_OBJECT //doesn't work with templating
-public:
- QTickAnimationProxy(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {}
- virtual int duration() const { return -1; }
-protected:
- virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); }
-
-private:
- T *m_p;
-};
-
-class QmlAbstractAnimationPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlAbstractAnimation)
-public:
- QmlAbstractAnimationPrivate()
- : running(false), paused(false), alwaysRunToEnd(false), repeat(false),
- connectedTimeLine(false), componentComplete(true),
- avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {}
-
- bool running:1;
- bool paused:1;
- bool alwaysRunToEnd:1;
- bool repeat:1;
- bool connectedTimeLine:1;
- bool componentComplete:1;
- bool avoidPropertyValueSourceStart:1;
- bool disableUserControl:1;
-
- void commence();
-
- QmlMetaProperty defaultProperty;
-
- QmlAnimationGroup *group;
-
- static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
-};
-
-class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlPauseAnimation)
-public:
- QmlPauseAnimationPrivate()
- : QmlAbstractAnimationPrivate(), pa(0) {}
-
- void init();
-
- QPauseAnimation *pa;
-};
-
-class QmlScriptActionPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlScriptAction)
-public:
- QmlScriptActionPrivate()
- : QmlAbstractAnimationPrivate(), hasRunScriptScript(false), proxy(this), rsa(0) {}
-
- void init();
-
- QmlScriptString script;
- QString name;
- QmlScriptString runScriptScript;
- bool hasRunScriptScript;
-
- void execute();
-
- QAnimationActionProxy<QmlScriptActionPrivate,
- &QmlScriptActionPrivate::execute> proxy;
- QActionAnimation *rsa;
-};
-
-class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlPropertyAction)
-public:
- QmlPropertyActionPrivate()
- : QmlAbstractAnimationPrivate(), target(0), spa(0) {}
-
- void init();
-
- QObject *target;
- QString propertyName;
- QString properties;
- QList<QObject *> targets;
- QList<QObject *> exclude;
-
- QmlNullableValue<QVariant> value;
-
- QActionAnimation *spa;
-};
-
-class QmlParentActionPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlParentAction)
-public:
- QmlParentActionPrivate()
- : QmlAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {}
-
- void init();
-
- QmlGraphicsItem *pcTarget;
- QmlGraphicsItem *pcParent;
-
- void doAction();
- QActionAnimation *cpa;
-};
-
-class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlAnimationGroup)
-public:
- QmlAnimationGroupPrivate()
- : QmlAbstractAnimationPrivate(), ag(0) {}
-
- static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *role);
- static void clear_animation(QmlListProperty<QmlAbstractAnimation> *list);
- static void removeAt_animation(QmlListProperty<QmlAbstractAnimation> *list, int i);
- static void insert_animation(QmlListProperty<QmlAbstractAnimation> *list, int i, QmlAbstractAnimation *role);
- QList<QmlAbstractAnimation *> animations;
- QAnimationGroup *ag;
-};
-
-class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlPropertyAnimation)
-public:
- QmlPropertyAnimationPrivate()
- : QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {}
-
- void init();
-
- QVariant from;
- QVariant to;
-
- QString easing;
-
- QObject *target;
- QString propertyName;
- QString properties;
- QList<QObject *> targets;
- QList<QObject *> exclude;
- QString defaultProperties;
-
- bool fromSourced;
- bool fromIsDefined:1;
- bool toIsDefined:1;
- bool rangeIsSet:1;
- bool defaultToInterpolatorType:1;
- int interpolatorType;
- QVariantAnimation::Interpolator interpolator;
-
- QmlTimeLineValueAnimator *va;
-
- static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
- static void convertVariant(QVariant &variant, int type);
-};
-
-class QmlRotationAnimationPrivate : public QmlPropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QmlRotationAnimation)
-public:
- QmlRotationAnimationPrivate() : direction(QmlRotationAnimation::Shortest) {}
-
- QmlRotationAnimation::RotationDirection direction;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLANIMATION_P_H
diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp
deleted file mode 100644
index 6d397c0a73..0000000000
--- a/src/declarative/util/qmlbehavior.cpp
+++ /dev/null
@@ -1,192 +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 "qmlbehavior_p.h"
-
-#include "qmlanimation_p.h"
-#include "qmltransition_p.h"
-
-#include <qmlcontext.h>
-#include <qmlinfo.h>
-
-#include <QtCore/qparallelanimationgroup.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,Behavior,QmlBehavior)
-
-class QmlBehaviorPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlBehavior)
-public:
- QmlBehaviorPrivate() : animation(0), enabled(true) {}
-
- QmlMetaProperty property;
- QVariant currentValue;
- QmlAbstractAnimation *animation;
- bool enabled;
-};
-
-/*!
- \qmlclass Behavior QmlBehavior
- \since 4.7
- \brief The Behavior element allows you to specify a default animation for a property change.
-
- Behaviors provide one way to specify \l{qmlanimation.html}{animations} in QML.
-
- In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
- \code
- Rectangle {
- width: 20; height: 20
- color: "#00ff00"
- y: 200 //initial value
- y: Behavior {
- NumberAnimation {
- easing: "easeOutBounce(amplitude:100)"
- duration: 200
- }
- }
- }
- \endcode
-
- Currently only a single Behavior may be specified for a property;
- this Behavior can be enabled and disabled via the \l{enabled} property.
-*/
-
-
-QmlBehavior::QmlBehavior(QObject *parent)
- : QObject(*(new QmlBehaviorPrivate), parent)
-{
-}
-
-QmlBehavior::~QmlBehavior()
-{
-}
-
-/*!
- \qmlproperty Animation Behavior::animation
- \default
-
- The animation to use when the behavior is triggered.
-*/
-
-QmlAbstractAnimation *QmlBehavior::animation()
-{
- Q_D(QmlBehavior);
- return d->animation;
-}
-
-void QmlBehavior::setAnimation(QmlAbstractAnimation *animation)
-{
- Q_D(QmlBehavior);
- if (d->animation) {
- qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
- return;
- }
-
- d->animation = animation;
- if (d->animation) {
- d->animation->setDefaultTarget(d->property);
- d->animation->setDisableUserControl();
- }
-}
-
-/*!
- \qmlproperty bool Behavior::enabled
- Whether the Behavior will be triggered when the property it is tracking changes.
-
- By default a Behavior is enabled.
-*/
-
-bool QmlBehavior::enabled() const
-{
- Q_D(const QmlBehavior);
- return d->enabled;
-}
-
-void QmlBehavior::setEnabled(bool enabled)
-{
- Q_D(QmlBehavior);
- if (d->enabled == enabled)
- return;
- d->enabled = enabled;
- emit enabledChanged();
-}
-
-void QmlBehavior::write(const QVariant &value)
-{
- Q_D(QmlBehavior);
- if (!d->animation || !d->enabled) {
- d->property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- return;
- }
-
- d->currentValue = d->property.read();
-
- d->animation->qtAnimation()->stop();
-
- QmlStateOperation::ActionList actions;
- QmlAction action;
- action.property = d->property;
- action.fromValue = d->currentValue;
- action.toValue = value;
- actions << action;
-
- QList<QmlMetaProperty> after;
- if (d->animation)
- d->animation->transition(actions, after, QmlAbstractAnimation::Forward);
- d->animation->qtAnimation()->start();
- if (!after.contains(d->property))
- d->property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
-}
-
-void QmlBehavior::setTarget(const QmlMetaProperty &property)
-{
- Q_D(QmlBehavior);
- d->property = property;
- d->currentValue = property.read();
- if (d->animation)
- d->animation->setDefaultTarget(property);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlbehavior_p.h b/src/declarative/util/qmlbehavior_p.h
deleted file mode 100644
index ee9e862c4d..0000000000
--- a/src/declarative/util/qmlbehavior_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 QMLBEHAVIOR_H
-#define QMLBEHAVIOR_H
-
-#include "qmlstate_p.h"
-
-#include <qmlpropertyvaluesource.h>
-#include <qmlpropertyvalueinterceptor.h>
-#include <qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlAbstractAnimation;
-class QmlBehaviorPrivate;
-class Q_DECLARATIVE_EXPORT QmlBehavior : public QObject, public QmlPropertyValueInterceptor
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlBehavior)
-
- Q_INTERFACES(QmlPropertyValueInterceptor)
- Q_CLASSINFO("DefaultProperty", "animation")
- Q_PROPERTY(QmlAbstractAnimation *animation READ animation WRITE setAnimation)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
-
-public:
- QmlBehavior(QObject *parent=0);
- ~QmlBehavior();
-
- virtual void setTarget(const QmlMetaProperty &);
- virtual void write(const QVariant &value);
-
- QmlAbstractAnimation *animation();
- void setAnimation(QmlAbstractAnimation *);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
-Q_SIGNALS:
- void enabledChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlBehavior)
-
-QT_END_HEADER
-
-#endif // QMLBEHAVIOR_H
diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp
deleted file mode 100644
index 6743edda39..0000000000
--- a/src/declarative/util/qmlbind.cpp
+++ /dev/null
@@ -1,202 +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 "qmlbind_p.h"
-
-#include "qmlnullablevalue_p_p.h"
-
-#include <qmlengine.h>
-#include <qmlcontext.h>
-
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-#include <QtScript/qscriptvalue.h>
-#include <QtScript/qscriptcontext.h>
-#include <QtScript/qscriptengine.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlBindPrivate : public QObjectPrivate
-{
-public:
- QmlBindPrivate() : when(true), componentComplete(false), obj(0) {}
-
- bool when : 1;
- bool componentComplete : 1;
- QObject *obj;
- QString prop;
- QmlNullableValue<QVariant> value;
-};
-
-QML_DEFINE_TYPE(Qt,4,6,Binding,QmlBind)
-/*!
- \qmlclass Binding QmlBind
- \since 4.7
- \brief The Binding element allows arbitrary property bindings to be created.
-
- Sometimes it is necessary to bind to a property of an object that wasn't
- directly instantiated by QML - generally a property of a class exported
- to QML by C++. In these cases, regular property binding doesn't work. Binding
- allows you to bind any value to any property.
-
- For example, imagine a C++ application that maps an "app.enteredText"
- property into QML. You could use Binding to update the enteredText property
- like this.
- \code
- TextEdit { id: myTextField; text: "Please type here..." }
- Binding { target: app; property: "enteredText"; value: myTextField.text }
- \endcode
- Whenever the text in the TextEdit is updated, the C++ property will be
- updated also.
-
- If the binding target or binding property is changed, the bound value is
- immediately pushed onto the new target.
- */
-/*!
- \internal
- \class QmlBind
- \ingroup group_utility
- \brief The QmlBind class allows arbitrary property bindings to be created.
-
- Simple bindings are usually earier to do in-place rather than creating a
- QmlBind item. For that reason, QmlBind is usually used to transfer property information
- from Qml to C++.
-
- \sa cppqml
- */
-QmlBind::QmlBind(QObject *parent)
- : QObject(*(new QmlBindPrivate), parent)
-{
-}
-
-QmlBind::~QmlBind()
-{
-}
-
-bool QmlBind::when() const
-{
- Q_D(const QmlBind);
- return d->when;
-}
-
-void QmlBind::setWhen(bool v)
-{
- Q_D(QmlBind);
- d->when = v;
- eval();
-}
-
-/*!
- \qmlproperty Object Binding::target
-
- The object to be updated.
-*/
-QObject *QmlBind::object()
-{
- Q_D(const QmlBind);
- return d->obj;
-}
-
-void QmlBind::setObject(QObject *obj)
-{
- Q_D(QmlBind);
- d->obj = obj;
- eval();
-}
-
-/*!
- \qmlproperty string Binding::property
-
- The property to be updated.
-*/
-QString QmlBind::property() const
-{
- Q_D(const QmlBind);
- return d->prop;
-}
-
-void QmlBind::setProperty(const QString &p)
-{
- Q_D(QmlBind);
- d->prop = p;
- eval();
-}
-
-/*!
- \qmlproperty any Binding::value
-
- The value to be set on the target object and property. This can be a
- constant (which isn't very useful), or a bound expression.
-*/
-QVariant QmlBind::value() const
-{
- Q_D(const QmlBind);
- return d->value.value;
-}
-
-void QmlBind::setValue(const QVariant &v)
-{
- Q_D(QmlBind);
- d->value.value = v;
- d->value.isNull = false;
- eval();
-}
-
-void QmlBind::componentComplete()
-{
- Q_D(QmlBind);
- d->componentComplete = true;
- eval();
-}
-
-void QmlBind::eval()
-{
- Q_D(QmlBind);
- if (!d->obj || d->value.isNull || !d->when || !d->componentComplete)
- return;
-
- QmlMetaProperty prop(d->obj, d->prop);
- prop.write(d->value.value);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlbind_p.h b/src/declarative/util/qmlbind_p.h
deleted file mode 100644
index 6fdd2dc90a..0000000000
--- a/src/declarative/util/qmlbind_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 QMLBIND_H
-#define QMLBIND_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlBindPrivate;
-class Q_DECLARATIVE_EXPORT QmlBind : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlBind)
- Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(QString property READ property WRITE setProperty)
- Q_PROPERTY(QVariant value READ value WRITE setValue)
- Q_PROPERTY(bool when READ when WRITE setWhen)
-
-public:
- QmlBind(QObject *parent=0);
- ~QmlBind();
-
- bool when() const;
- void setWhen(bool);
-
- QObject *object();
- void setObject(QObject *);
-
- QString property() const;
- void setProperty(const QString &);
-
- QVariant value() const;
- void setValue(const QVariant &);
-
-protected:
- virtual void componentComplete();
-
-private:
- void eval();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlBind)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
deleted file mode 100644
index 204377c3ac..0000000000
--- a/src/declarative/util/qmlconnection.cpp
+++ /dev/null
@@ -1,288 +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 "qmlconnection_p.h"
-
-#include <qmlexpression.h>
-#include <qmlboundsignal_p.h>
-#include <qmlcontext.h>
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlConnectionPrivate : public QObjectPrivate
-{
-public:
- QmlConnectionPrivate() : boundsignal(0), signalSender(0), scriptset(false), componentcomplete(false) {}
-
- QmlBoundSignal *boundsignal;
- QObject *signalSender;
- QmlScriptString script;
- bool scriptset;
- QString signal;
- bool componentcomplete;
-};
-
-/*!
- \qmlclass Connection QmlConnection
- \since 4.7
- \brief A Connection object describes generalized connections to signals.
-
- When connecting to signals in QML, the usual way is to create an
- "on<Signal>" handler that reacts when a signal is received, like this:
-
- \qml
- MouseArea {
- onClicked: { foo(x+123,y+456) }
- }
- \endqml
-
- However, in some cases, it is not possible to connect to a signal in this
- way. For example, JavaScript-in-HTML style signal properties do not allow:
-
- \list
- \i connecting to signals with the same name but different parameters
- \i conformance checking that parameters are correctly named
- \i multiple connections to the same signal
- \i connections outside the scope of the signal sender
- \i signals in classes with coincidentally-named on<Signal> properties
- \endlist
-
- When any of these are needed, the Connection object can be used instead.
-
- For example, the above code can be changed to use a Connection object,
- like this:
-
- \qml
- MouseArea {
- Connection {
- signal: "clicked(x,y)"
- script: { foo(x+123,y+456) }
- }
- }
- \endqml
-
- More generally, the Connection object can be a child of some other object than
- the sender of the signal, and the script is the default attribute:
-
- \qml
- MouseArea {
- id: mr
- }
- ...
- Connection {
- sender: mr
- signal: "clicked(x,y)"
- script: { foo(x+123,y+456) }
- }
- \endqml
-*/
-
-/*!
- \internal
- \class QmlConnection
- \brief The QmlConnection class describes generalized connections to signals.
-
-*/
-QmlConnection::QmlConnection(QObject *parent) :
- QObject(*(new QmlConnectionPrivate), parent)
-{
-}
-
-QmlConnection::~QmlConnection()
-{
- Q_D(QmlConnection);
- delete d->boundsignal;
-}
-
-/*!
- \qmlproperty Object Connection::sender
- This property holds the object that sends the signal.
-
- By default, the sender is assumed to be the parent of the Connection.
-*/
-QObject *QmlConnection::signalSender() const
-{
- Q_D(const QmlConnection);
- return d->signalSender ? d->signalSender : parent();
-}
-
-void QmlConnection::setSignalSender(QObject *obj)
-{
- Q_D(QmlConnection);
- if (d->signalSender == obj)
- return;
- disconnectIfValid();
- d->signalSender = obj;
- connectIfValid();
-}
-
-void QmlConnection::connectIfValid()
-{
- Q_D(QmlConnection);
- if (!d->componentcomplete)
- return;
- // boundsignal must not exist
- if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) {
- // create
- // XXX scope?
- int sigIdx = -1;
- int lparen = d->signal.indexOf(QLatin1Char('('));
- QList<QByteArray> sigparams;
- if (lparen >= 0 && d->signal.length() > lparen+2) {
- QStringList l = d->signal.mid(lparen+1,d->signal.length()-lparen-2).split(QLatin1Char(','));
- foreach (const QString &s, l) {
- sigparams.append(s.trimmed().toUtf8());
- }
- }
- QString signalname = d->signal.left(lparen);
- QObject *sender = d->signalSender ? d->signalSender : parent();
- const QMetaObject *mo = sender->metaObject();
- int methods = mo->methodCount();
- for (int ii = 0; ii < methods; ++ii) {
- QMetaMethod method = mo->method(ii);
- QString methodName = QString::fromUtf8(method.signature());
- int idx = methodName.indexOf(QLatin1Char('('));
- methodName = methodName.left(idx);
- if (methodName == signalname && (lparen<0 || method.parameterNames() == sigparams)) {
- sigIdx = ii;
- break;
- }
- }
- if (sigIdx < 0) {
- // Cannot usefully warn, since could be in middle of
- // changing sender and signal.
- // XXX need state change transactions to do better
- return;
- }
-
- d->boundsignal = new QmlBoundSignal(qmlContext(this), d->script.script(), sender, mo->method(sigIdx), this);
- }
-}
-
-void QmlConnection::disconnectIfValid()
-{
- Q_D(QmlConnection);
- if (!d->componentcomplete)
- return;
- if ((d->signalSender || parent()) && !d->signal.isEmpty() && d->scriptset) {
- // boundsignal must exist
- // destroy
- delete d->boundsignal;
- d->boundsignal = 0;
- }
-}
-
-void QmlConnection::componentComplete()
-{
- Q_D(QmlConnection);
- d->componentcomplete=true;
- connectIfValid();
-}
-
-
-/*!
- \qmlproperty script Connection::script
- This property holds the JavaScript executed whenever the signal is sent.
-
- This is the default attribute of Connection.
-*/
-QmlScriptString QmlConnection::script() const
-{
- Q_D(const QmlConnection);
- return d->script;
-}
-
-void QmlConnection::setScript(const QmlScriptString& script)
-{
- Q_D(QmlConnection);
- if ((d->signalSender || parent()) && !d->signal.isEmpty()) {
- if (!d->scriptset) {
- // mustn't exist - create
- d->scriptset = true;
- d->script = script;
- connectIfValid();
- } else {
- // must exist - update
- d->script = script;
- d->boundsignal->expression()->setExpression(script.script());
- }
- } else {
- d->scriptset = true;
- d->script = script;
- }
-}
-
-/*!
- \qmlproperty string Connection::signal
- This property holds the signal from the sender to which the script is attached.
-
- The signal's formal parameter names must be given in parentheses:
-
- \qml
-Connection {
- signal: "clicked(x,y)"
- script: { ... }
-}
- \endqml
-*/
-QString QmlConnection::signal() const
-{
- Q_D(const QmlConnection);
- return d->signal;
-}
-
-void QmlConnection::setSignal(const QString& sig)
-{
- Q_D(QmlConnection);
- if (d->signal == sig)
- return;
- disconnectIfValid();
- d->signal = sig;
- connectIfValid();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,Connection,QmlConnection)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlconnection_p.h b/src/declarative/util/qmlconnection_p.h
deleted file mode 100644
index 2106cb06d0..0000000000
--- a/src/declarative/util/qmlconnection_p.h
+++ /dev/null
@@ -1,93 +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 QMLCONNECTION_H
-#define QMLCONNECTION_H
-
-#include <qml.h>
-#include <qmlscriptstring.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlBoundSignal;
-class QmlContext;
-class QmlConnectionPrivate;
-class Q_DECLARATIVE_EXPORT QmlConnection : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlConnection)
-
- Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QObject *sender READ signalSender WRITE setSignalSender)
- Q_PROPERTY(QmlScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString signal READ signal WRITE setSignal)
-
-public:
- QmlConnection(QObject *parent=0);
- ~QmlConnection();
-
- QObject *signalSender() const;
- void setSignalSender(QObject *);
- QmlScriptString script() const;
- void setScript(const QmlScriptString&);
- QString signal() const;
- void setSignal(const QString&);
-
-private:
- void disconnectIfValid();
- void connectIfValid();
- void componentComplete();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlConnection)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp
deleted file mode 100644
index 4b8fb0069a..0000000000
--- a/src/declarative/util/qmldatetimeformatter.cpp
+++ /dev/null
@@ -1,373 +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 "qmldatetimeformatter_p.h"
-
-#include <QtCore/qlocale.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: may need optimisation as the QDateTime member may not be needed?
-// be able to set a locale?
-
-class QmlDateTimeFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlDateTimeFormatter)
-public:
- QmlDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {}
-
- void updateText();
-
- QDateTime dateTime;
- QDate date;
- QTime time;
- QLocale locale;
- QString dateTimeText;
- QString dateText;
- QString timeText;
- QString dateTimeFormat; //set for convienience?
- QString dateFormat;
- QString timeFormat;
- bool longStyle;
- bool componentComplete;
-};
-
-/*!
- \qmlclass DateTimeFormatter QmlDateTimeFormatter
- \since 4.7
- \brief The DateTimeFormatter allows you to control the format of a date string.
-
- \code
- DateTimeFormatter { id: formatter; date: System.date }
- Text { text: formatter.dateText }
- \endcode
-
- By default, the text properties (dateText, timeText, and dateTimeText) will return the
- date and time using the current system locale's format.
-*/
-
-/*!
- \internal
- \class QmlDateTimeFormatter
- \ingroup group_utility
- \brief The QmlDateTimeFormatter class allows you to format a date string.
-*/
-
-QmlDateTimeFormatter::QmlDateTimeFormatter(QObject *parent)
-: QObject(*(new QmlDateTimeFormatterPrivate), parent)
-{
-}
-
-QmlDateTimeFormatter::~QmlDateTimeFormatter()
-{
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateText
- \qmlproperty string DateTimeFormatter::timeText
- \qmlproperty string DateTimeFormatter::dateTimeText
-
- Formatted text representations of the \c date, \c time,
- and \c {date and time}, respectively.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- \code
- // specify source date (assuming today is February 19, 2009)
- DateTimeFormatter { id: formatter; dateTime: Today.date }
-
- // display the full date and time
- Text { text: formatter.dateText }
- \endcode
-
- Would be equivalent to the following for a US English locale:
-
- \code
- // display the date
- Text { text: "2/19/09" }
- \endcode
-*/
-QString QmlDateTimeFormatter::dateTimeText() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateTimeText;
-}
-
-QString QmlDateTimeFormatter::dateText() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateText;
-}
-
-QString QmlDateTimeFormatter::timeText() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->timeText;
-}
-
-/*!
- \qmlproperty date DateTimeFormatter::date
- \qmlproperty time DateTimeFormatter::time
- \qmlproperty datetime DateTimeFormatter::dateTime
-
- The source date and time to be used by the formatter.
-
- \code
- // setting the date and time
- DateTimeFormatter { date: System.date; time: System.time }
- \endcode
-
- For convienience it is possible to set the datetime property to set both the date and the time.
- \code
- // setting the datetime
- DateTimeFormatter { dateTime: System.dateTime }
- \endcode
-
- There can only be one instance of date and time per formatter; if date, time, and dateTime are all
- set the actual date and time used is not guaranteed.
-
- \note If no date is set, dateTimeText will be just the date;
- If no time is set, the dateTimeText will be just the time.
-
-*/
-QDate QmlDateTimeFormatter::date() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->date;
-}
-
-QTime QmlDateTimeFormatter::time() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->time;
-}
-
-QDateTime QmlDateTimeFormatter::dateTime() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateTime;
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateFormat
- \qmlproperty string DateTimeFormatter::timeFormat
- \qmlproperty string DateTimeFormatter::dateTimeFormat
-
- Specifies a custom format which the DateTime Formatter can use.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- The text's format may be modified by setting:
- \list
- \i \c dateFormat
- \i \c timeFormat
- \i \c dateTimeFormat
- \endlist
-
- If only the format for date is defined, the time and dateTime formats will be defined
- as the system locale default and likewise for the others.
-
- Syntax for the format is based on the QDateTime::toString() formatting options.
-
- \code
- // Format the date such that the dateText is: '1997-12-12'
- DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" }
- \endcode
-
- Assigning an empty string to a particular format will reset it.
-*/
-QString QmlDateTimeFormatter::dateTimeFormat() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateTimeFormat;
-}
-
-QString QmlDateTimeFormatter::dateFormat() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->dateFormat;
-}
-
-QString QmlDateTimeFormatter::timeFormat() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->timeFormat;
-}
-
-/*!
- \qmlproperty bool DateTimeFormatter::longStyle
-
- This property causes the formatter to use the system locale's long format rather than short format
- by default.
-
- This setting is off by default.
-*/
-bool QmlDateTimeFormatter::longStyle() const
-{
- Q_D(const QmlDateTimeFormatter);
- return d->longStyle;
-}
-
-void QmlDateTimeFormatter::setDateTime(const QDateTime &dateTime)
-{
- Q_D(QmlDateTimeFormatter);
- if (d->dateTime == dateTime)
- return;
- d->dateTime = dateTime;
- d->date = d->dateTime.date();
- d->time = d->dateTime.time();
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setTime(const QTime &time)
-{
- Q_D(QmlDateTimeFormatter);
- if (d->dateTime.time() == time)
- return;
- d->time = time;
- d->dateTime.setTime(time);
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setDate(const QDate &date)
-{
- Q_D(QmlDateTimeFormatter);
- if (d->dateTime.date() == date)
- return;
- d->date = date;
- bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time
- d->dateTime.setDate(date);
- if (clearTime)
- d->dateTime.setTime(QTime());
- d->updateText();
-}
-
-//DateTime formatting may be a combination of date and time?
-void QmlDateTimeFormatter::setDateTimeFormat(const QString &format)
-{
- Q_D(QmlDateTimeFormatter);
- //no format checking
- d->dateTimeFormat = format;
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setDateFormat(const QString &format)
-{
- Q_D(QmlDateTimeFormatter);
- //no format checking
- d->dateFormat = format;
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setTimeFormat(const QString &format)
-{
- Q_D(QmlDateTimeFormatter);
- //no format checking
- d->timeFormat = format;
- d->updateText();
-}
-
-void QmlDateTimeFormatter::setLongStyle(bool longStyle)
-{
- Q_D(QmlDateTimeFormatter);
- d->longStyle = longStyle;
- d->updateText();
-}
-
-void QmlDateTimeFormatterPrivate::updateText()
-{
- Q_Q(QmlDateTimeFormatter);
- if (!componentComplete)
- return;
-
- QString str;
- QString str1;
- QString str2;
-
- Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate;
-
- if (dateFormat.isEmpty())
- str1 = date.toString(defaultFormat);
- else
- str1 = date.toString(dateFormat);
-
- if (timeFormat.isEmpty())
- str2 = time.toString(defaultFormat);
- else
- str2 = time.toString(timeFormat);
-
- if (dateTimeFormat.isEmpty())
- str = dateTime.toString(defaultFormat);
- //else if (!formatTime.isEmpty() && !formatDate.isEmpty())
- // str = str1 + QLatin1Char(' ') + str2;
- else
- str = dateTime.toString(dateTimeFormat);
-
- if (dateTimeText == str && dateText == str1 && timeText == str2)
- return;
-
- dateTimeText = str;
- dateText = str1;
- timeText = str2;
-
- emit q->textChanged();
-}
-
-void QmlDateTimeFormatter::classBegin()
-{
- Q_D(QmlDateTimeFormatter);
- d->componentComplete = false;
-}
-
-void QmlDateTimeFormatter::componentComplete()
-{
- Q_D(QmlDateTimeFormatter);
- d->componentComplete = true;
- d->updateText();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,DateTimeFormatter,QmlDateTimeFormatter)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmldatetimeformatter_p.h b/src/declarative/util/qmldatetimeformatter_p.h
deleted file mode 100644
index 2cd80b99eb..0000000000
--- a/src/declarative/util/qmldatetimeformatter_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 QMLDATETIMEFORMATTER_H
-#define QMLDATETIMEFORMATTER_H
-
-#include <qml.h>
-
-#include <QtCore/qdatetime.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlDateTimeFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
-
- Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged)
- Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged)
- Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged)
- Q_PROPERTY(QDate date READ date WRITE setDate)
- Q_PROPERTY(QTime time READ time WRITE setTime)
- Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime)
- Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat)
- Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat)
- Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
- Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle)
-public:
- QmlDateTimeFormatter(QObject *parent=0);
- ~QmlDateTimeFormatter();
-
- QString dateTimeText() const;
- QString dateText() const;
- QString timeText() const;
-
- QDate date() const;
- void setDate(const QDate &);
-
- QTime time() const;
- void setTime(const QTime &);
-
- QDateTime dateTime() const;
- void setDateTime(const QDateTime &);
-
- QString dateTimeFormat() const;
- void setDateTimeFormat(const QString &);
-
- QString dateFormat() const;
- void setDateFormat(const QString &);
-
- QString timeFormat() const;
- void setTimeFormat(const QString &);
-
- bool longStyle() const;
- void setLongStyle(bool);
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QmlDateTimeFormatter)
- Q_DECLARE_PRIVATE(QmlDateTimeFormatter)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlDateTimeFormatter)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
deleted file mode 100644
index 214f6f6679..0000000000
--- a/src/declarative/util/qmleasefollow.cpp
+++ /dev/null
@@ -1,537 +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 "qmleasefollow_p.h"
-
-#include "qmlanimation_p_p.h"
-
-#include <qmlmetaproperty.h>
-
-#include <QtCore/qdebug.h>
-
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,EaseFollow,QmlEaseFollow);
-
-class QmlEaseFollowPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlEaseFollow)
-public:
- QmlEaseFollowPrivate()
- : source(0), velocity(200), duration(-1), maximumEasingTime(-1),
- reversingMode(QmlEaseFollow::Eased), initialVelocity(0),
- initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
- lastTick(0), clock(this)
- {}
-
- qreal source;
- qreal velocity;
- qreal duration;
- qreal maximumEasingTime;
- QmlEaseFollow::ReversingMode reversingMode;
-
- qreal initialVelocity;
- qreal initialValue;
- bool invert;
- bool enabled;
-
- qreal trackVelocity;
-
- QmlMetaProperty target;
-
- int clockOffset;
- int lastTick;
- void tick(int);
- void clockStart();
- void clockStop();
- QTickAnimationProxy<QmlEaseFollowPrivate, &QmlEaseFollowPrivate::tick> clock;
-
- void restart();
-
- // Parameters for use in tick()
- qreal a; // Acceleration
- qreal d; // Deceleration
- qreal tf; // Total time
- qreal tp; // Time at which peak velocity occurs
- qreal td; // Time at which decelleration begins
- qreal vp; // Velocity at tp
- qreal sp; // Displacement at tp
- qreal sd; // Displacement at td
- qreal vi; // "Normalized" initialvelocity
- bool recalc();
-};
-
-bool QmlEaseFollowPrivate::recalc()
-{
- qreal s = source - initialValue;
- vi = initialVelocity;
-
- s = (invert?-1.0:1.0) * s;
- vi = (invert?-1.0:1.0) * vi;
-
- if (duration > 0 && velocity > 0) {
- tf = s / velocity;
- if (tf > (duration / 1000.)) tf = (duration / 1000.);
- } else if (duration > 0) {
- tf = duration / 1000.;
- } else if (velocity > 0) {
- tf = s / velocity;
- } else {
- return false;
- }
-
- if (maximumEasingTime == 0) {
- a = 0;
- d = 0;
- tp = 0;
- td = tf;
- vp = velocity;
- sp = 0;
- sd = s;
- } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) {
-
- qreal met = maximumEasingTime / 1000.;
- td = tf - met;
-
- qreal c1 = td;
- qreal c2 = (tf - td) * vi - tf * velocity;
- qreal c3 = -0.5 * (tf - td) * vi * vi;
-
- qreal vp1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
- // qreal vp2 = (-c2 - sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
-
- vp = vp1;
- a = vp / met;
- d = a;
- tp = (vp - vi) / a;
- sp = vi * tp + 0.5 * a * tp * tp;
- sd = sp + (td - tp) * vp;
- } else {
-
- qreal c1 = 0.25 * tf * tf;
- qreal c2 = 0.5 * vi * tf - s;
- qreal c3 = -0.25 * vi * vi;
-
- qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
- //qreal a2 = (-c2 - sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1);
-
- qreal tp1 = 0.5 * tf - 0.5 * vi / a1;
- //qreal tp2 = 0.5 * tf - 0.5 * vi / a2;
- qreal vp1 = a1 * tp1 + vi;
- //qreal vp2 = a2 * tp2 + vi;
-
- qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1;
- //qreal sp2 = 0.5 * a2 * tp2 * tp2 + vi * tp2;
-
- a = a1;
- d = a1;
- tp = tp1;
- td = tp1;
- vp = vp1;
- sp = sp1;
- sd = sp1;
- }
-
- /*
- qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
- << vp << "sp:" << sp << "vi:" << vi << "invert:" << invert;
- */
- return true;
-}
-
-void QmlEaseFollowPrivate::clockStart()
-{
- if (clock.state() == QAbstractAnimation::Running) {
- clockOffset = lastTick;
- return;
- } else {
- clockOffset = 0;
- lastTick = 0;
- clock.start();
- }
-}
-
-void QmlEaseFollowPrivate::clockStop()
-{
- clockOffset = 0;
- lastTick = 0;
- clock.stop();
-}
-
-void QmlEaseFollowPrivate::tick(int t)
-{
- lastTick = t;
- t -= clockOffset;
-
- qreal time_seconds = qreal(t) / 1000.;
-
- qreal out = 0;
- if (time_seconds < tp) {
-
- trackVelocity = vi + time_seconds * a;
- trackVelocity = (invert?-1.0:1.0) * trackVelocity;
-
- qreal value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds;
- value = (invert?-1.0:1.0) * value;
- target.write(initialValue + value);
- out = initialValue + value;
- } else if (time_seconds < td) {
-
- time_seconds -= tp;
- trackVelocity = (invert?-1.0:1.0) * vp;
- qreal value = sp + time_seconds * vp;
- value = (invert?-1.0:1.0) * value;
-
- target.write(initialValue + value);
-
- out = initialValue + value;
- } else if (time_seconds < tf) {
-
- time_seconds -= td;
-
- trackVelocity = vp - time_seconds * a;
- trackVelocity = (invert?-1.0:1.0) * trackVelocity;
-
- qreal value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds;
- value = (invert?-1.0:1.0) * value;
-
- target.write(initialValue + value);
-
- out = initialValue + value;
- } else {
-
- clock.stop();
-
- trackVelocity = 0;
- target.write(source);
- }
-
- //qWarning() << out << trackVelocity << t << a;
-}
-
-/*!
- \qmlclass EaseFollow QmlEaseFollow
- \since 4.7
- \brief The EaseFollow element allows a property to smoothly track a value.
-
- The EaseFollow smoothly animates a property's value to a set target value
- using an ease in/out quad easing curve. If the target value changes while
- the animation is in progress, the easing curves used to animate to the old
- and the new target values are spliced together to avoid any obvious visual
- glitches.
-
- The property animation is configured by setting the velocity at which the
- animation should occur, or the duration that the animation should take.
- If both a velocity and a duration are specified, the one that results in
- the quickest animation is chosen for each change in the target value.
-
- For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
- take 4 seconds with both a velocity of 200 and a duration of 8000 set.
- Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
- will take 8 seconds with a duration of 8000 set, and will take 8 seconds
- with both a velocity of 200 and a duration of 8000 set.
-
- The follow example shows one rectangle tracking the position of another.
-\code
-import Qt 4.6
-
-Rectangle {
- width: 800; height: 600; color: "blue"
-
- Rectangle {
- color: "green"
- width: 60; height: 60;
- x: -5; y: -5;
- x: EaseFollow { source: rect1.x - 5; velocity: 200 }
- y: EaseFollow { source: rect1.y - 5; velocity: 200 }
- }
-
- Rectangle {
- id: rect1
- color: "red"
- width: 50; height: 50;
- }
-
- focus: true
- Keys.onRightPressed: rect1.x = rect1.x + 100
- Keys.onLeftPressed: rect1.x = rect1.x - 100
- Keys.onUpPressed: rect1.y = rect1.y - 100
- Keys.onDownPressed: rect1.y = rect1.y + 100
-}
-\endcode
-
- The default velocity of EaseFollow is 200 units/second. Note that if the range of the
- value being animated is small, then the velocity will need to be adjusted
- appropriately. For example, the opacity of an item ranges from 0 - 1.0.
- To enable a smooth animation in this range the velocity will need to be
- set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity
- of 0.5 will take 2000 ms to complete.
-
- \sa SpringFollow
-*/
-
-QmlEaseFollow::QmlEaseFollow(QObject *parent)
-: QObject(*(new QmlEaseFollowPrivate), parent)
-{
-}
-
-QmlEaseFollow::~QmlEaseFollow()
-{
-}
-
-/*!
- \qmlproperty qreal EaseFollow::source
- This property holds the source value which will be tracked.
-
- Bind to a property in order to track its changes.
-*/
-qreal QmlEaseFollow::sourceValue() const
-{
- Q_D(const QmlEaseFollow);
- return d->source;
-}
-
-/*!
- \qmlproperty enumeration EaseFollow::reversingMode
-
- Sets how the EaseFollow behaves if an animation direction is reversed.
-
- If reversing mode is \c Eased, the animation will smoothly decelerate, and
- then reverse direction. If the reversing mode is \c Immediate, the
- animation will immediately begin accelerating in the reverse direction,
- begining with a velocity of 0. If the reversing mode is \c Sync, the
- property is immediately set to the target value.
-*/
-QmlEaseFollow::ReversingMode QmlEaseFollow::reversingMode() const
-{
- Q_D(const QmlEaseFollow);
- return d->reversingMode;
-}
-
-void QmlEaseFollow::setReversingMode(ReversingMode m)
-{
- Q_D(QmlEaseFollow);
- if (d->reversingMode == m)
- return;
-
- d->reversingMode = m;
- emit reversingModeChanged();
-}
-
-void QmlEaseFollowPrivate::restart()
-{
- if (!enabled || velocity == 0) {
- clockStop();
- return;
- }
-
- initialValue = target.read().toReal();
-
- if (source == initialValue) {
- clockStop();
- return;
- }
-
- bool hasReversed = trackVelocity != 0. &&
- ((trackVelocity > 0) == ((initialValue - source) > 0));
-
- if (hasReversed) {
- switch (reversingMode) {
- default:
- case QmlEaseFollow::Eased:
- break;
- case QmlEaseFollow::Sync:
- target.write(source);
- return;
- case QmlEaseFollow::Immediate:
- initialVelocity = 0;
- clockStop();
- break;
- }
- }
-
- trackVelocity = initialVelocity;
-
- invert = (source < initialValue);
-
- if (!recalc()) {
- target.write(source);
- clockStop();
- return;
- }
-
- clockStart();
-}
-
-void QmlEaseFollow::setSourceValue(qreal s)
-{
- Q_D(QmlEaseFollow);
-
- if (d->clock.state() == QAbstractAnimation::Running && d->source == s)
- return;
-
- d->source = s;
- d->initialVelocity = d->trackVelocity;
- d->restart();
-
- emit sourceChanged();
-}
-
-/*!
- \qmlproperty qreal EaseFollow::duration
-
- This property holds the animation duration used when tracking the source.
-
- Setting this to -1 (the default) disables the duration value.
-*/
-qreal QmlEaseFollow::duration() const
-{
- Q_D(const QmlEaseFollow);
- return d->duration;
-}
-
-void QmlEaseFollow::setDuration(qreal v)
-{
- Q_D(QmlEaseFollow);
- if (d->duration == v)
- return;
-
- d->duration = v;
- d->trackVelocity = 0;
-
- if (d->clock.state() == QAbstractAnimation::Running)
- d->restart();
-
- emit durationChanged();
-}
-
-qreal QmlEaseFollow::velocity() const
-{
- Q_D(const QmlEaseFollow);
- return d->velocity;
-}
-
-/*!
- \qmlproperty qreal EaseFollow::velocity
-
- This property holds the average velocity allowed when tracking the source.
-
- The default velocity of EaseFollow is 200 units/second.
-
- Setting this to -1 disables the velocity value.
-*/
-void QmlEaseFollow::setVelocity(qreal v)
-{
- Q_D(QmlEaseFollow);
- if (d->velocity == v)
- return;
-
- d->velocity = v;
- d->trackVelocity = 0;
-
- if (d->clock.state() == QAbstractAnimation::Running)
- d->restart();
-
- emit velocityChanged();
-}
-
-/*!
- \qmlproperty bool EaseFollow::enabled
- This property holds whether the target will track the source.
-*/
-bool QmlEaseFollow::enabled() const
-{
- Q_D(const QmlEaseFollow);
- return d->enabled;
-}
-
-void QmlEaseFollow::setEnabled(bool enabled)
-{
- Q_D(QmlEaseFollow);
- if (d->enabled == enabled)
- return;
-
- d->enabled = enabled;
- if (enabled)
- d->restart();
- else
- d->clockStop();
-
- emit enabledChanged();
-}
-
-void QmlEaseFollow::setTarget(const QmlMetaProperty &t)
-{
- Q_D(QmlEaseFollow);
- d->target = t;
-}
-
-/*!
-\qmlproperty qreal EaseFollow::maximumEasingTime
-
-This property specifies the maximum time an "eases" during the follow should take.
-Setting this property causes the velocity to "level out" after at a time. Setting
-a negative value reverts to the normal mode of easing over the entire animation
-duration.
-
-The default value is -1.
-*/
-qreal QmlEaseFollow::maximumEasingTime() const
-{
- Q_D(const QmlEaseFollow);
- return d->maximumEasingTime;
-}
-
-void QmlEaseFollow::setMaximumEasingTime(qreal v)
-{
- Q_D(QmlEaseFollow);
- d->maximumEasingTime = v;
-
- if (d->clock.state() == QAbstractAnimation::Running)
- d->restart();
-
- emit maximumEasingTimeChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmleasefollow_p.h b/src/declarative/util/qmleasefollow_p.h
deleted file mode 100644
index dddf54f6d5..0000000000
--- a/src/declarative/util/qmleasefollow_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 QMLEASEFOLLOW_H
-#define QMLEASEFOLLOW_H
-
-#include <qml.h>
-#include <qmlpropertyvaluesource.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlMetaProperty;
-class QmlEaseFollowPrivate;
-class Q_DECLARATIVE_EXPORT QmlEaseFollow : public QObject,
- public QmlPropertyValueSource
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlEaseFollow)
- Q_INTERFACES(QmlPropertyValueSource)
- Q_ENUMS(ReversingMode)
-
- Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue NOTIFY sourceChanged)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
- Q_PROPERTY(qreal duration READ duration WRITE setDuration NOTIFY durationChanged)
- Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
-
-public:
- enum ReversingMode { Eased, Immediate, Sync };
-
- QmlEaseFollow(QObject *parent = 0);
- ~QmlEaseFollow();
-
- ReversingMode reversingMode() const;
- void setReversingMode(ReversingMode);
-
- qreal sourceValue() const;
- void setSourceValue(qreal);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- qreal duration() const;
- void setDuration(qreal);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
- qreal maximumEasingTime() const;
- void setMaximumEasingTime(qreal);
-
- virtual void setTarget(const QmlMetaProperty &);
-
-Q_SIGNALS:
- void sourceChanged();
- void velocityChanged();
- void durationChanged();
- void reversingModeChanged();
- void enabledChanged();
- void maximumEasingTimeChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlEaseFollow);
-
-QT_END_HEADER
-
-#endif // QMLEASEFOLLOW_H
diff --git a/src/declarative/util/qmlfontloader.cpp b/src/declarative/util/qmlfontloader.cpp
deleted file mode 100644
index 52110d397a..0000000000
--- a/src/declarative/util/qmlfontloader.cpp
+++ /dev/null
@@ -1,230 +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 "qmlfontloader_p.h"
-
-#include <qmlcontext.h>
-#include <qmlengine.h>
-
-#include <QUrl>
-#include <QDebug>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QFile>
-#include <QFontDatabase>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlFontLoaderPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlFontLoader)
-
-public:
- QmlFontLoaderPrivate() : reply(0), status(QmlFontLoader::Null) {}
-
- void addFontToDatabase(const QByteArray &);
-
- QUrl url;
- QString name;
- QNetworkReply *reply;
- QmlFontLoader::Status status;
-};
-
-QML_DEFINE_TYPE(Qt,4,6,FontLoader,QmlFontLoader)
-
-/*!
- \qmlclass FontLoader QmlFontLoader
- \since 4.7
- \ingroup group_utility
- \brief This item allows using fonts by name or url.
-
- Example:
- \qml
- FontLoader { id: fixedFont; name: "Courier" }
- FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
-
- Text { text: "Fixed-size font"; font.family: fixedFont.name }
- Text { text: "Fancy font"; font.family: webFont.name }
- \endqml
-*/
-QmlFontLoader::QmlFontLoader(QObject *parent)
- : QObject(*(new QmlFontLoaderPrivate), parent)
-{
-}
-
-QmlFontLoader::~QmlFontLoader()
-{
-}
-
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-
-/*!
- \qmlproperty url FontLoader::source
- The url of the font to load.
-*/
-QUrl QmlFontLoader::source() const
-{
- Q_D(const QmlFontLoader);
- return d->url;
-}
-
-void QmlFontLoader::setSource(const QUrl &url)
-{
- Q_D(QmlFontLoader);
- if (url == d->url)
- return;
- d->url = qmlContext(this)->resolvedUrl(url);
-
- d->status = Loading;
- emit statusChanged();
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(d->url);
- if (!lf.isEmpty()) {
- int id = QFontDatabase::addApplicationFont(lf);
- if (id != -1) {
- d->name = QFontDatabase::applicationFontFamilies(id).at(0);
- emit nameChanged();
- d->status = QmlFontLoader::Ready;
- } else {
- d->status = QmlFontLoader::Error;
- qWarning() << "Cannot load font:" << url;
- }
- emit statusChanged();
- } else
-#endif
- {
- QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- d->reply = qmlEngine(this)->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished()));
- }
-}
-
-/*!
- \qmlproperty string FontLoader::name
-
- This property holds the name of the font family.
- It is set automatically when a font is loaded using the \c url property.
-
- Use this to set the \c font.family property of a \c Text item.
-
- Example:
- \qml
- FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
- Text { text: "Fancy font"; font.family: webFont.name }
- \endqml
-*/
-QString QmlFontLoader::name() const
-{
- Q_D(const QmlFontLoader);
- return d->name;
-}
-
-void QmlFontLoader::setName(const QString &name)
-{
- Q_D(QmlFontLoader);
- if (d->name == name )
- return;
- d->name = name;
- emit nameChanged();
- d->status = Ready;
- emit statusChanged();
-}
-
-/*!
- \qmlproperty enum FontLoader::status
-
- This property holds the status of font loading. It can be one of:
- \list
- \o Null - no font has been set
- \o Ready - the font has been loaded
- \o Loading - the font is currently being loaded
- \o Error - an error occurred while loading the font
- \endlist
-*/
-QmlFontLoader::Status QmlFontLoader::status() const
-{
- Q_D(const QmlFontLoader);
- return d->status;
-}
-
-void QmlFontLoader::replyFinished()
-{
- Q_D(QmlFontLoader);
- if (d->reply) {
- if (!d->reply->error()) {
- QByteArray ba = d->reply->readAll();
- d->addFontToDatabase(ba);
- } else {
- d->status = Error;
- emit statusChanged();
- }
- d->reply->deleteLater();
- d->reply = 0;
- }
-}
-
-void QmlFontLoaderPrivate::addFontToDatabase(const QByteArray &ba)
-{
- Q_Q(QmlFontLoader);
-
- int id = QFontDatabase::addApplicationFontFromData(ba);
- if (id != -1) {
- name = QFontDatabase::applicationFontFamilies(id).at(0);
- emit q->nameChanged();
- status = QmlFontLoader::Ready;
- } else {
- status = QmlFontLoader::Error;
- qWarning() << "Cannot load font:" << url;
- }
- emit q->statusChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlfontloader_p.h b/src/declarative/util/qmlfontloader_p.h
deleted file mode 100644
index 3d274525d0..0000000000
--- a/src/declarative/util/qmlfontloader_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 QMLFONTLOADER_H
-#define QMLFONTLOADER_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlFontLoaderPrivate;
-class Q_DECLARATIVE_EXPORT QmlFontLoader : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlFontLoader)
- Q_ENUMS(Status)
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
-public:
- enum Status { Null = 0, Ready, Loading, Error };
-
- QmlFontLoader(QObject *parent = 0);
- ~QmlFontLoader();
-
- QUrl source() const;
- void setSource(const QUrl &url);
-
- QString name() const;
- void setName(const QString &name);
-
- Status status() const;
-
-private Q_SLOTS:
- void replyFinished();
-
-Q_SIGNALS:
- void nameChanged();
- void statusChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlFontLoader)
-
-QT_END_HEADER
-
-#endif // QMLFONTLOADER_H
-
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp
deleted file mode 100644
index abdb626eff..0000000000
--- a/src/declarative/util/qmllistaccessor.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmllistaccessor_p.h"
-
-#include <qmlmetatype.h>
-
-#include <QStringList>
-#include <QtCore/qdebug.h>
-
-// ### Remove me
-#include <qmlengine_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QmlListAccessor::QmlListAccessor()
-: m_type(Invalid)
-{
-}
-
-QmlListAccessor::~QmlListAccessor()
-{
-}
-
-QVariant QmlListAccessor::list() const
-{
- return d;
-}
-
-void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine)
-{
- d = v;
-
- QmlEnginePrivate *enginePrivate = engine?QmlEnginePrivate::get(engine):0;
-
- if (!d.isValid()) {
- m_type = Invalid;
- } else if (d.userType() == QVariant::StringList) {
- m_type = StringList;
- } else if (d.userType() == QMetaType::QVariantList) {
- m_type = VariantList;
- } else if (d.canConvert(QVariant::Int)) {
- m_type = Integer;
- } else if ((!enginePrivate && QmlMetaType::isQObject(d.userType())) ||
- (enginePrivate && enginePrivate->isQObject(d.userType()))) {
- QObject *data = enginePrivate?enginePrivate->toQObject(v):QmlMetaType::toQObject(v);
- d = QVariant::fromValue(data);
- m_type = Instance;
- } else if (d.userType() == qMetaTypeId<QmlListReference>()) {
- m_type = ListProperty;
- } else {
- m_type = Instance;
- }
-}
-
-int QmlListAccessor::count() const
-{
- switch(m_type) {
- case StringList:
- return qvariant_cast<QStringList>(d).count();
- case VariantList:
- return qvariant_cast<QVariantList>(d).count();
- case ListProperty:
- return ((QmlListReference *)d.constData())->count();
- case Instance:
- return 1;
- case Integer:
- return d.toInt();
- default:
- case Invalid:
- return 0;
- }
-}
-
-QVariant QmlListAccessor::at(int idx) const
-{
- Q_ASSERT(idx >= 0 && idx < count());
- switch(m_type) {
- case StringList:
- return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
- case VariantList:
- return qvariant_cast<QVariantList>(d).at(idx);
- case ListProperty:
- return QVariant::fromValue(((QmlListReference *)d.constData())->at(idx));
- case Instance:
- return d;
- case Integer:
- return QVariant(idx);
- default:
- case Invalid:
- return QVariant();
- }
-}
-
-bool QmlListAccessor::isValid() const
-{
- return m_type != Invalid;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h
deleted file mode 100644
index 611eebb91f..0000000000
--- a/src/declarative/util/qmllistaccessor_p.h
+++ /dev/null
@@ -1,80 +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 QMLLISTACCESSOR_H
-#define QMLLISTACCESSOR_H
-
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlEngine;
-class Q_DECLARATIVE_EXPORT QmlListAccessor
-{
-public:
- QmlListAccessor();
- ~QmlListAccessor();
-
- QVariant list() const;
- void setList(const QVariant &, QmlEngine * = 0);
-
- bool isValid() const;
-
- int count() const;
- QVariant at(int) const;
-
- enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
- Type type() const { return m_type; }
-
-private:
- Type m_type;
- QVariant d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLLISTACCESSOR_H
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
deleted file mode 100644
index 6958b186de..0000000000
--- a/src/declarative/util/qmllistmodel.cpp
+++ /dev/null
@@ -1,1014 +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 "qmllistmodel_p.h"
-
-#include "qmlopenmetaobject_p.h"
-
-#include <qmlcustomparser_p.h>
-#include <qmlparser_p.h>
-#include <qmlengine_p.h>
-#include <qmlcontext.h>
-#include <qmlinfo.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qstack.h>
-#include <QXmlStreamReader>
-#include <QtScript/qscriptvalueiterator.h>
-
-Q_DECLARE_METATYPE(QListModelInterface *)
-
-QT_BEGIN_NAMESPACE
-
-#define DATA_ROLE_ID 1
-#define DATA_ROLE_NAME "data"
-
-struct ListInstruction
-{
- enum { Push, Pop, Value, Set } type;
- int dataIdx;
-};
-
-struct ListModelData
-{
- int dataOffset;
- int instrCount;
- ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); }
-};
-
-static void dump(ModelNode *node, int ind);
-
-/*!
- \qmlclass ListModel QmlListModel
- \since 4.7
- \brief The ListModel element defines a free-form list data source.
-
- The ListModel is a simple hierarchy of elements containing data roles. The contents can
- be defined dynamically, or explicitly in QML:
-
- For example:
-
- \code
- ListModel {
- id: fruitModel
- ListElement {
- name: "Apple"
- cost: 2.45
- }
- ListElement {
- name: "Orange"
- cost: 3.25
- }
- ListElement {
- name: "Banana"
- cost: 1.95
- }
- }
- \endcode
-
- Roles (properties) must begin with a lower-case letter. The above example defines a
- ListModel containing three elements, with the roles "name" and "cost".
-
- The defined model can be used in views such as ListView:
- \code
- Component {
- id: fruitDelegate
- Item {
- width: 200; height: 50
- Text { text: name }
- Text { text: '$'+cost; anchors.right: parent.right }
- }
- }
-
- ListView {
- model: fruitModel
- delegate: fruitDelegate
- anchors.fill: parent
- }
- \endcode
-
- It is possible for roles to contain list data. In the example below we create a list of fruit attributes:
-
- \code
- ListModel {
- id: fruitModel
- ListElement {
- name: "Apple"
- cost: 2.45
- attributes: [
- ListElement { description: "Core" },
- ListElement { description: "Deciduous" }
- ]
- }
- ListElement {
- name: "Orange"
- cost: 3.25
- attributes: [
- ListElement { description: "Citrus" }
- ]
- }
- ListElement {
- name: "Banana"
- cost: 1.95
- attributes: [
- ListElement { description: "Tropical" },
- ListElement { description: "Seedless" }
- ]
- }
- }
- \endcode
-
- The delegate below will list all the fruit attributes:
- \code
- Component {
- id: fruitDelegate
- Item {
- width: 200; height: 50
- Text { id: name; text: name }
- Text { text: '$'+cost; anchors.right: parent.right }
- Row {
- anchors.top: name.bottom
- spacing: 5
- Text { text: "Attributes:" }
- Repeater {
- dataSource: attributes
- Component { Text { text: description } }
- }
- }
- }
- }
- \endcode
-
- The content of a ListModel may be created and modified using the clear(),
- append(), and set() methods. For example:
-
- \code
- Component {
- id: fruitDelegate
- Item {
- width: 200; height: 50
- Text { text: name }
- Text { text: '$'+cost; anchors.right: parent.right }
-
- // Double the price when clicked.
- MouseArea {
- anchors.fill: parent
- onClicked: fruitModel.set(index, "cost", cost*2)
- }
- }
- }
- \endcode
-
- When creating content dynamically, note that the set of available properties cannot be changed
- except by first clearing the model - whatever properties are first added are then the
- only permitted properties in the model.
-
- \sa {qmlmodels}{Data Models}
-*/
-
-class ModelObject : public QObject
-{
- Q_OBJECT
-public:
- ModelObject();
-
- void setValue(const QByteArray &name, const QVariant &val)
- {
- _mo->setValue(name, val);
- }
-
-private:
- QmlOpenMetaObject *_mo;
-};
-
-struct ModelNode
-{
- ModelNode();
- ~ModelNode();
-
- QList<QVariant> values;
- QHash<QString, ModelNode *> properties;
-
- QmlListModel *model(const QmlListModel *parent) {
- if (!modelCache) {
- modelCache = new QmlListModel;
- QmlEngine::setContextForObject(modelCache,QmlEngine::contextForObject(parent));
-
- modelCache->_root = this;
- }
- return modelCache;
- }
-
- ModelObject *object(const QmlListModel *parent) {
- if (!objectCache) {
- objectCache = new ModelObject();
- QHash<QString, ModelNode *>::iterator it;
- for (it = properties.begin(); it != properties.end(); ++it) {
- objectCache->setValue(it.key().toUtf8(), parent->valueForNode(*it));
- }
- }
- return objectCache;
- }
-
- void setObjectValue(const QScriptValue& valuemap);
- void setListValue(const QScriptValue& valuelist);
-
- void setProperty(const QString& prop, const QVariant& val) {
- QHash<QString, ModelNode *>::const_iterator it = properties.find(prop);
- if (it != properties.end()) {
- (*it)->values[0] = val;
- } else {
- ModelNode *n = new ModelNode;
- n->values << val;
- properties.insert(prop,n);
- }
- if (objectCache)
- objectCache->setValue(prop.toUtf8(), val);
- }
-
- QmlListModel *modelCache;
- ModelObject *objectCache;
- bool isArray;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(ModelNode *)
-
-QT_BEGIN_NAMESPACE
-
-void ModelNode::setObjectValue(const QScriptValue& valuemap) {
- QScriptValueIterator it(valuemap);
- while (it.hasNext()) {
- it.next();
- ModelNode *value = new ModelNode;
- QScriptValue v = it.value();
- if (v.isArray()) {
- value->isArray = true;
- value->setListValue(v);
- } else {
- value->values << v.toVariant();
- }
- properties.insert(it.name(),value);
- }
-}
-
-void ModelNode::setListValue(const QScriptValue& valuelist) {
- QScriptValueIterator it(valuelist);
- values.clear();
- while (it.hasNext()) {
- it.next();
- ModelNode *value = new ModelNode;
- QScriptValue v = it.value();
- if (v.isArray()) {
- value->isArray = true;
- value->setListValue(v);
- } else if (v.isObject()) {
- value->setObjectValue(v);
- } else {
- value->values << v.toVariant();
- }
- values.append(qVariantFromValue(value));
-
- }
-}
-
-
-ModelObject::ModelObject()
-: _mo(new QmlOpenMetaObject(this))
-{
-}
-
-QmlListModel::QmlListModel(QObject *parent)
-: QListModelInterface(parent), _rolesOk(false), _root(0)
-{
-}
-
-QmlListModel::~QmlListModel()
-{
- delete _root;
-}
-
-void QmlListModel::checkRoles() const
-{
- if (_rolesOk || !_root)
- return;
-
- for (int ii = 0; ii < _root->values.count(); ++ii) {
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(ii));
- if (node) {
- foreach (const QString &role, node->properties.keys())
- addRole(role);
- }
- }
-
- _rolesOk = true;
-}
-
-void QmlListModel::addRole(const QString &role) const
-{
- if (!roleStrings.contains(role))
- roleStrings << role;
-}
-
-QList<int> QmlListModel::roles() const
-{
- checkRoles();
- QList<int> rv;
- for (int ii = 0; ii < roleStrings.count(); ++ii)
- rv << ii;
- return rv;
-}
-
-QString QmlListModel::toString(int role) const
-{
- checkRoles();
- if (role < roleStrings.count())
- return roleStrings.at(role);
- else
- return QString();
-}
-
-QVariant QmlListModel::valueForNode(ModelNode *node) const
-{
- QObject *rv = 0;
-
- if (node->isArray) {
- // List
- rv = node->model(this);
- } else {
- if (!node->properties.isEmpty()) {
- // Object
- rv = node->object(this);
- } else if (node->values.count() == 0) {
- // Invalid
- return QVariant();
- } else if (node->values.count() == 1) {
- // Value
- QVariant &var = node->values[0];
- ModelNode *valueNode = qvariant_cast<ModelNode *>(var);
- if (valueNode) {
- if (!valueNode->properties.isEmpty())
- rv = valueNode->object(this);
- else
- rv = valueNode->model(this);
- } else {
- return var;
- }
- }
- }
-
- if (rv)
- return QVariant::fromValue(rv);
- else
- return QVariant();
-}
-
-QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const
-{
- checkRoles();
- QHash<int, QVariant> rv;
- if (index >= count() || index < 0)
- return rv;
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- if (!node)
- return rv;
-
- for (int ii = 0; ii < roles.count(); ++ii) {
- const QString &roleString = roleStrings.at(roles.at(ii));
-
- QHash<QString, ModelNode *>::ConstIterator iter =
- node->properties.find(roleString);
- if (iter != node->properties.end()) {
- ModelNode *row = *iter;
- rv.insert(roles.at(ii), valueForNode(row));
- }
- }
-
- return rv;
-}
-
-QVariant QmlListModel::data(int index, int role) const
-{
- checkRoles();
- QVariant rv;
- if (index >= count() || index < 0)
- return rv;
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- if (!node)
- return rv;
-
- const QString &roleString = roleStrings.at(role);
-
- QHash<QString, ModelNode *>::ConstIterator iter =
- node->properties.find(roleString);
- if (iter != node->properties.end()) {
- ModelNode *row = *iter;
- rv = valueForNode(row);
- }
-
- return rv;
-}
-
-/*!
- \qmlproperty int ListModel::count
- The number of data entries in the model.
-*/
-int QmlListModel::count() const
-{
- if (!_root) return 0;
- return _root->values.count();
-}
-
-/*!
- \qmlmethod ListModel::clear()
-
- Deletes all content from the model. The properties are cleared such that
- different properties may be set on subsequent additions.
-
- \sa append() remove()
-*/
-void QmlListModel::clear()
-{
- int cleared = count();
- _rolesOk = false;
- delete _root;
- _root = 0;
- roleStrings.clear();
- emit itemsRemoved(0,cleared);
- emit countChanged(0);
-}
-
-/*!
- \qmlmethod ListModel::remove(int index)
-
- Deletes the content at \a index from the model.
-
- \sa clear()
-*/
-void QmlListModel::remove(int index)
-{
- if (!_root || index < 0 || index >= _root->values.count()) {
- qmlInfo(this) << tr("remove: index %1 out of range").arg(index);
- return;
- }
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- _root->values.removeAt(index);
- if (node)
- delete node;
- emit itemsRemoved(index,1);
- emit countChanged(_root->values.count());
-}
-
-/*!
- \qmlmethod ListModel::insert(int index, jsobject dict)
-
- Adds a new item to the list model at position \a index, with the
- values in \a dict.
-
- \code
- FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
- \endcode
-
- The \a index must be to an existing item in the list, or one past
- the end of the list (equivalent to append).
-
- \sa set() append()
-*/
-void QmlListModel::insert(int index, const QScriptValue& valuemap)
-{
- if (!valuemap.isObject() || valuemap.isArray()) {
- qmlInfo(this) << tr("insert: value is not an object");
- return;
- }
- if (!_root)
- _root = new ModelNode;
- if (index >= _root->values.count() || index<0) {
- if (index == _root->values.count())
- append(valuemap);
- else
- qmlInfo(this) << tr("insert: index %1 out of range").arg(index);
- return;
- }
- ModelNode *mn = new ModelNode;
- mn->setObjectValue(valuemap);
- _root->values.insert(index,qVariantFromValue(mn));
- emit itemsInserted(index,1);
- emit countChanged(_root->values.count());
-}
-
-/*!
- \qmlmethod ListModel::move(int from, int to, int n)
-
- Moves \a n items \a from one position \a to another.
-
- The from and to ranges must exist; for example, to move the first 3 items
- to the end of the list:
-
- \code
- FruitModel.move(0,FruitModel.count-3,3)
- \endcode
-
- \sa append()
-*/
-void QmlListModel::move(int from, int to, int n)
-{
- if (n==0 || from==to)
- return;
- if (from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0) {
- qmlInfo(this) << tr("move: out of range");
- return;
- }
- int origfrom=from; // preserve actual move, so any animations are correct
- int origto=to;
- int orign=n;
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
- if (n==1) {
- _root->values.move(from,to);
- } else {
- QList<QVariant> replaced;
- int i=0;
- QVariantList::const_iterator it=_root->values.begin(); it += from+n;
- for (; i<to-from; ++i,++it)
- replaced.append(*it);
- i=0;
- it=_root->values.begin(); it += from;
- for (; i<n; ++i,++it)
- replaced.append(*it);
- QVariantList::const_iterator f=replaced.begin();
- QVariantList::iterator t=_root->values.begin(); t += from;
- for (; f != replaced.end(); ++f, ++t)
- *t = *f;
- }
- emit itemsMoved(origfrom,origto,orign);
-}
-
-/*!
- \qmlmethod ListModel::append(jsobject dict)
-
- Adds a new item to the end of the list model, with the
- values in \a dict.
-
- \code
- FruitModel.append({"cost": 5.95, "name":"Pizza"})
- \endcode
-
- \sa set() remove()
-*/
-void QmlListModel::append(const QScriptValue& valuemap)
-{
- if (!valuemap.isObject() || valuemap.isArray()) {
- qmlInfo(this) << tr("append: value is not an object");
- return;
- }
- if (!_root)
- _root = new ModelNode;
- ModelNode *mn = new ModelNode;
- mn->setObjectValue(valuemap);
- _root->values << qVariantFromValue(mn);
- emit itemsInserted(count()-1,1);
- emit countChanged(_root->values.count());
-}
-
-/*!
- \qmlmethod object ListModel::get(int index)
-
- Returns the item at \a index in the list model.
-
- \code
- FruitModel.append({"cost": 5.95, "name":"Jackfruit"})
- FruitModel.get(0).cost
- \endcode
-
- The \a index must be an element in the list.
-
- Note that properties of the returned object that are themselves objects
- will also be models, and this get() method is used to access elements:
-
- \code
- FruitModel.append(..., "attributes":
- [{"name":"spikes","value":"7mm"},
- {"name":"color","value":"green"}]);
- FruitModel.get(0).attributes.get(1).value; // == "green"
- \endcode
-
- \sa append()
-*/
-QScriptValue QmlListModel::get(int index) const
-{
- if (index >= count() || index < 0) {
- qmlInfo(this) << tr("get: index %1 out of range").arg(index);
- return 0;
- }
-
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- if (!node)
- return 0;
- QmlEngine *eng = qmlEngine(this);
- if (!eng) {
- qWarning("Cannot call QmlListModel::get() without a QmlEngine");
- return 0;
- }
- return QmlEnginePrivate::qmlScriptObject(node->object(this), eng);
-}
-
-/*!
- \qmlmethod ListModel::set(int index, jsobject dict)
-
- Changes the item at \a index in the list model with the
- values in \a dict. Properties not appearing in \a valuemap
- are left unchanged.
-
- \code
- FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
- \endcode
-
- The \a index must be an element in the list.
-
- \sa append()
-*/
-void QmlListModel::set(int index, const QScriptValue& valuemap)
-{
- if (!valuemap.isObject() || valuemap.isArray()) {
- qmlInfo(this) << tr("set: value is not an object");
- return;
- }
- if ( !_root || index > _root->values.count() || index < 0) {
- qmlInfo(this) << tr("set: index %1 out of range").arg(index);
- return;
- }
- if (index == _root->values.count())
- append(valuemap);
- else {
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- QList<int> roles;
- node->setObjectValue(valuemap);
- QScriptValueIterator it(valuemap);
- while (it.hasNext()) {
- it.next();
- int r = roleStrings.indexOf(it.name());
- if (r<0) {
- r = roleStrings.count();
- roleStrings << it.name();
- }
- roles.append(r);
- }
- emit itemsChanged(index,1,roles);
- }
-}
-
-/*!
- \qmlmethod ListModel::setProperty(int index, string property, variant value)
-
- Changes the \a property of the item at \a index in the list model to \a value.
-
- \code
- FruitModel.set(3, "cost", 5.95)
- \endcode
-
- The \a index must be an element in the list.
-
- \sa append()
-*/
-void QmlListModel::setProperty(int index, const QString& property, const QVariant& value)
-{
- if ( !_root || index >= _root->values.count() || index < 0) {
- qmlInfo(this) << tr("set: index %1 out of range").arg(index);
- return;
- }
- ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
- int r = roleStrings.indexOf(property);
- if (r<0) {
- r = roleStrings.count();
- roleStrings << property;
- }
- QList<int> roles;
- roles.append(r);
-
- if (node)
- node->setProperty(property,value);
- emit itemsChanged(index,1,roles);
-}
-
-class QmlListModelParser : public QmlCustomParser
-{
-public:
- QByteArray compile(const QList<QmlCustomParserProperty> &);
- bool compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
- void setCustomData(QObject *, const QByteArray &);
-
-private:
- bool definesEmptyList(const QString &);
-};
-
-bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data)
-{
- QList<QVariant> values = prop.assignedValues();
- for(int ii = 0; ii < values.count(); ++ii) {
- const QVariant &value = values.at(ii);
-
- if(value.userType() == qMetaTypeId<QmlCustomParserNode>()) {
- QmlCustomParserNode node =
- qvariant_cast<QmlCustomParserNode>(value);
-
- {
- ListInstruction li;
- li.type = ListInstruction::Push;
- li.dataIdx = -1;
- instr << li;
- }
-
- QList<QmlCustomParserProperty> props = node.properties();
- for(int jj = 0; jj < props.count(); ++jj) {
- const QmlCustomParserProperty &nodeProp = props.at(jj);
- if (nodeProp.name() == "") {
- error(nodeProp, QmlListModel::tr("ListElement: cannot use default property"));
- return false;
- }
- if (nodeProp.name() == "id") {
- error(nodeProp, QmlListModel::tr("ListElement: cannot use reserved \"id\" property"));
- return false;
- }
-
- ListInstruction li;
- int ref = data.count();
- data.append(nodeProp.name());
- data.append('\0');
- li.type = ListInstruction::Set;
- li.dataIdx = ref;
- instr << li;
-
- if(!compileProperty(nodeProp, instr, data))
- return false;
-
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
-
- {
- ListInstruction li;
- li.type = ListInstruction::Pop;
- li.dataIdx = -1;
- instr << li;
- }
-
- } else {
-
- QmlParser::Variant variant =
- qvariant_cast<QmlParser::Variant>(value);
-
- int ref = data.count();
-
- QByteArray d;
- d += char(variant.type()); // type tag
- if (variant.isString()) {
- d += variant.asString().toUtf8();
- } else if (variant.isNumber()) {
- d += QByteArray::number(variant.asNumber(),'g',20);
- } else if (variant.isBoolean()) {
- d += char(variant.asBoolean());
- } else if (variant.isScript()) {
- if (definesEmptyList(variant.asScript())) {
- d[0] = 0; // QmlParser::Variant::Invalid - marks empty list
- } else {
- error(prop, QmlListModel::tr("ListElement: cannot use script for property value"));
- return false;
- }
- }
- d.append('\0');
- data.append(d);
-
- ListInstruction li;
- li.type = ListInstruction::Value;
- li.dataIdx = ref;
- instr << li;
- }
- }
-
- return true;
-}
-
-QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps)
-{
- QList<ListInstruction> instr;
- QByteArray data;
-
- for(int ii = 0; ii < customProps.count(); ++ii) {
- const QmlCustomParserProperty &prop = customProps.at(ii);
- if(prop.name() != "") { // isn't default property
- error(prop, QmlListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
- return QByteArray();
- }
-
- if(!compileProperty(prop, instr, data)) {
- return QByteArray();
- }
- }
-
- int size = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction) +
- data.count();
-
- QByteArray rv;
- rv.resize(size);
-
- ListModelData *lmd = (ListModelData *)rv.data();
- lmd->dataOffset = sizeof(ListModelData) +
- instr.count() * sizeof(ListInstruction);
- lmd->instrCount = instr.count();
- for (int ii = 0; ii < instr.count(); ++ii)
- lmd->instructions()[ii] = instr.at(ii);
- ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());
-
- return rv;
-}
-
-void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d)
-{
- QmlListModel *rv = static_cast<QmlListModel *>(obj);
-
- ModelNode *root = new ModelNode;
- rv->_root = root;
- QStack<ModelNode *> nodes;
- nodes << root;
-
- bool processingSet = false;
-
- const ListModelData *lmd = (const ListModelData *)d.constData();
- const char *data = ((const char *)lmd) + lmd->dataOffset;
-
- for (int ii = 0; ii < lmd->instrCount; ++ii) {
- const ListInstruction &instr = lmd->instructions()[ii];
-
- switch(instr.type) {
- case ListInstruction::Push:
- {
- ModelNode *n = nodes.top();
- ModelNode *n2 = new ModelNode;
- n->values << qVariantFromValue(n2);
- nodes.push(n2);
- if (processingSet)
- n->isArray = true;
- }
- break;
-
- case ListInstruction::Pop:
- nodes.pop();
- break;
-
- case ListInstruction::Value:
- {
- ModelNode *n = nodes.top();
- switch (QmlParser::Variant::Type(data[instr.dataIdx])) {
- case QmlParser::Variant::Invalid:
- n->isArray = true;
- break;
- case QmlParser::Variant::Boolean:
- n->values.append(bool(data[1 + instr.dataIdx]));
- break;
- case QmlParser::Variant::Number:
- n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
- break;
- case QmlParser::Variant::String:
- n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));
- break;
- default:
- Q_ASSERT("Format error in ListInstruction");
- }
-
- processingSet = false;
- }
- break;
-
- case ListInstruction::Set:
- {
- ModelNode *n = nodes.top();
- ModelNode *n2 = new ModelNode;
- n->properties.insert(QString::fromUtf8(data + instr.dataIdx), n2);
- nodes.push(n2);
- processingSet = true;
- }
- break;
- }
- }
-}
-
-bool QmlListModelParser::definesEmptyList(const QString &s)
-{
- if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) {
- for (int i=1; i<s.length()-1; i++) {
- if (!s[i].isSpace())
- return false;
- }
- return true;
- }
- return false;
-}
-
-QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, ListModel, QmlListModel, QmlListModelParser)
-
-/*!
- \qmlclass ListElement
- \since 4.7
- \brief The ListElement element defines a data item in a ListModel.
-
- \sa ListModel
-*/
-// ### FIXME
-class QmlListElement : public QObject
-{
-Q_OBJECT
-};
-QML_DEFINE_TYPE(Qt,4,6,ListElement,QmlListElement)
-
-static void dump(ModelNode *node, int ind)
-{
- QByteArray indentBa(ind * 4, ' ');
- const char *indent = indentBa.constData();
-
- for (int ii = 0; ii < node->values.count(); ++ii) {
- ModelNode *subNode = qvariant_cast<ModelNode *>(node->values.at(ii));
- if (subNode) {
- qWarning().nospace() << indent << "Sub-node " << ii;
- dump(subNode, ind + 1);
- } else {
- qWarning().nospace() << indent << "Sub-node " << ii << ": " << node->values.at(ii).toString();
- }
- }
-
- for (QHash<QString, ModelNode *>::ConstIterator iter = node->properties.begin(); iter != node->properties.end(); ++iter) {
- qWarning().nospace() << indent << "Property " << iter.key() << ':';
- dump(iter.value(), ind + 1);
- }
-}
-
-ModelNode::ModelNode()
-: modelCache(0), objectCache(0), isArray(false)
-{
-}
-
-ModelNode::~ModelNode()
-{
- qDeleteAll(properties);
- for (int ii = 0; ii < values.count(); ++ii) {
- ModelNode *node = qvariant_cast<ModelNode *>(values.at(ii));
- if (node) { delete node; node = 0; }
- }
- if (modelCache) { modelCache->_root = 0/* ==this */; delete modelCache; modelCache = 0; }
- if (objectCache) { delete objectCache; }
-}
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlListElement)
-
-#include <qmllistmodel.moc>
diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qmllistmodel_p.h
deleted file mode 100644
index 4cf6746288..0000000000
--- a/src/declarative/util/qmllistmodel_p.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 QMLLISTMODEL_H
-#define QMLLISTMODEL_H
-
-#include <qml.h>
-
-#include <QtCore/QObject>
-#include <QtCore/QStringList>
-#include <QtCore/QHash>
-#include <QtCore/QList>
-#include <QtCore/QVariant>
-#include "../3rdparty/qlistmodelinterface_p.h"
-#include <QtScript/qscriptvalue.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-struct ModelNode;
-class Q_DECLARATIVE_EXPORT QmlListModel : public QListModelInterface
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
-public:
- QmlListModel(QObject *parent=0);
- ~QmlListModel();
-
- 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_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 setProperty(int index, const QString& property, const QVariant& value);
- Q_INVOKABLE void move(int from, int to, int count);
-
-Q_SIGNALS:
- void countChanged(int);
-
-private:
- QVariant valueForNode(ModelNode *) const;
- mutable QStringList roleStrings;
- friend class QmlListModelParser;
- friend struct ModelNode;
-
- void checkRoles() const;
- void addRole(const QString &) const;
- mutable bool _rolesOk;
- ModelNode *_root;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlListModel)
-
-QT_END_HEADER
-
-#endif // QMLLISTMODEL_H
diff --git a/src/declarative/util/qmlnullablevalue_p_p.h b/src/declarative/util/qmlnullablevalue_p_p.h
deleted file mode 100644
index c426258a16..0000000000
--- a/src/declarative/util/qmlnullablevalue_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 QMLNULLABLEVALUE_P_H
-#define QMLNULLABLEVALUE_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
-
-template<typename T>
-struct QmlNullableValue
-{
- QmlNullableValue()
- : isNull(true), value(T()) {}
- QmlNullableValue(const QmlNullableValue<T> &o)
- : isNull(o.isNull), value(o.value) {}
- QmlNullableValue(const T &t)
- : isNull(false), value(t) {}
- QmlNullableValue<T> &operator=(const T &t)
- { isNull = false; value = t; return *this; }
- QmlNullableValue<T> &operator=(const QmlNullableValue<T> &o)
- { isNull = o.isNull; value = o.value; return *this; }
- operator T() const { return value; }
-
- void invalidate() { isNull = true; }
- bool isValid() const { return !isNull; }
- bool isNull;
- T value;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLNULLABLEVALUE_P_H
diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qmlnumberformatter.cpp
deleted file mode 100644
index 0845d0c52e..0000000000
--- a/src/declarative/util/qmlnumberformatter.cpp
+++ /dev/null
@@ -1,261 +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 "qmlnumberformatter_p.h"
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: set locale
-// docs
-// this is a wrapper around qnumberformat (test integration)
-// if number or format haven't been explictly set, text should be an empty string
-
-class QmlNumberFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlNumberFormatter)
-public:
- QmlNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {}
-
- void updateText();
-
- QLocale locale;
- QString format;
- QNumberFormat numberFormat;
- QString text;
- qreal number;
- bool componentComplete;
-};
-/*!
- \qmlclass NumberFormatter
- \since 4.7
- \brief The NumberFormatter allows you to control the format of a number string.
-
- The format property documentation has more details on how the format can be manipulated.
-
- In the following example, the text element will display the text "1,234.57".
- \code
- NumberFormatter { id: formatter; number: 1234.5678; format: "##,##0.##" }
- Text { text: formatter.text }
- \endcode
-
- */
-/*!
- \internal
- \class QmlNumberFormatter
- \ingroup group_utility
- \brief The QmlNumberFormatter class allows you to format a number to a particular string format/locale specific number format.
-*/
-
-QmlNumberFormatter::QmlNumberFormatter(QObject *parent)
-: QObject(*(new QmlNumberFormatterPrivate), parent)
-{
-}
-
-QmlNumberFormatter::~QmlNumberFormatter()
-{
-}
-
-/*!
- \qmlproperty string NumberFormatter::text
-
- The number in the specified format.
-
- If no format is specified the text will be empty.
-*/
-
-QString QmlNumberFormatter::text() const
-{
- Q_D(const QmlNumberFormatter);
- return d->text;
-}
-
-/*!
- \qmlproperty real NumberFormatter::number
-
- A single point precision number. (Doubles are not yet supported)
-
-*/
-qreal QmlNumberFormatter::number() const
-{
- Q_D(const QmlNumberFormatter);
- return d->number;
-}
-
-/*!
- \qmlproperty string NumberFormatter::format
-
- The particular format the number will adhere to during the conversion to text.
-
- The format syntax follows a style similar to the Unicode Standard (UTS35).
-
- The table below shows the characters, patterns that can be used in the format.
-
- \table
- \header
- \o Character
- \o Meaning
- \row
- \o #
- \o Any digit(s), zero shows as absent (for leading/trailing zeroes).
- \row
- \o 0
- \o Implicit digit. Zero will show in the case that the input number is too small.
- \row
- \o .
- \o Decimal separator. Output decimal seperator will be dependant on system locale.
- \row
- \o ,
- \o Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize).
- \row
- \o other
- \o Any other character will be taken as a string literal and placed directly into the output string.
- \endtable
-
- Invalid formats will not guarantee a meaningful text output.
-
- \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point.
-
- The following table illustrates the output text created by applying some examples of numeric formats to the formatter.
-
- \table
- \header
- \o Format
- \o Number
- \o Output
- \row
- \o ###
- \o 123456
- \o 123456
- \row
- \o 000
- \o 123456
- \o 123456
- \row
- \o ######
- \o 1234
- \o 1234
- \row
- \o 000000
- \o 1234
- \o 001234
- \row
- \o ##,##0.##
- \o 1234.456
- \o 1,234.46 (for US locale)
- \codeline 1 234,46 (for FR locale)
- \row
- \o 000000,000.#
- \o 123456
- \o 000,123,456 (for US locale)
- \codeline 000 123 456 (for FR locale)
- \row
- \o 0.0###
- \o 0.999997
- \o 1.0
- \row
- \o (000) 000 - 000
- \o 12345678
- \o (012) 345 - 678
- \row
- \o #A
- \o 12
- \o 12A
- \endtable
-
-*/
-QString QmlNumberFormatter::format() const
-{
- Q_D(const QmlNumberFormatter);
- return d->format;
-}
-
-void QmlNumberFormatter::setNumber(const qreal &number)
-{
- Q_D(QmlNumberFormatter);
- if (d->number == number)
- return;
- d->number = number;
- d->updateText();
-}
-
-void QmlNumberFormatter::setFormat(const QString &format)
-{
- Q_D(QmlNumberFormatter);
- //no format checking
- if (format.isEmpty())
- d->format = QString::null;
- else
- d->format = format;
- d->updateText();
-}
-
-void QmlNumberFormatterPrivate::updateText()
-{
- Q_Q(QmlNumberFormatter);
- if (!componentComplete)
- return;
-
- QNumberFormat tempFormat;
- tempFormat.setFormat(format);
- tempFormat.setNumber(number);
-
- text = tempFormat.text();
-
- emit q->textChanged();
-}
-
-void QmlNumberFormatter::classBegin()
-{
- Q_D(QmlNumberFormatter);
- d->componentComplete = false;
-}
-
-void QmlNumberFormatter::componentComplete()
-{
- Q_D(QmlNumberFormatter);
- d->componentComplete = true;
- d->updateText();
-}
-QML_DEFINE_TYPE(Qt,4,6,NumberFormatter,QmlNumberFormatter);
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlnumberformatter_p.h b/src/declarative/util/qmlnumberformatter_p.h
deleted file mode 100644
index d08885b6ed..0000000000
--- a/src/declarative/util/qmlnumberformatter_p.h
+++ /dev/null
@@ -1,93 +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 QMLNUMBERFORMATTER_H
-#define QMLNUMBERFORMATTER_H
-
-#include "qnumberformat_p.h"
-
-#include <qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlNumberFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QmlNumberFormatter : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
-
- Q_PROPERTY(QString text READ text NOTIFY textChanged)
- Q_PROPERTY(QString format READ format WRITE setFormat)
- Q_PROPERTY(qreal number READ number WRITE setNumber)
-public:
- QmlNumberFormatter(QObject *parent=0);
- ~QmlNumberFormatter();
-
- QString text() const;
-
- qreal number() const;
- void setNumber(const qreal &);
-
- QString format() const;
- void setFormat(const QString &);
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QmlNumberFormatter)
- Q_DECLARE_PRIVATE(QmlNumberFormatter)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlNumberFormatter)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp
deleted file mode 100644
index 0847c47c81..0000000000
--- a/src/declarative/util/qmlopenmetaobject.cpp
+++ /dev/null
@@ -1,355 +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 "qmlopenmetaobject_p.h"
-#include "qmlpropertycache_p.h"
-#include "qmldeclarativedata_p.h"
-#include <qmetaobjectbuilder_p.h>
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QmlOpenMetaObjectTypePrivate
-{
-public:
- QmlOpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {}
-
- void init(const QMetaObject *metaObj);
-
- int propertyOffset;
- int signalOffset;
- QHash<QByteArray, int> names;
- QMetaObjectBuilder mob;
- QMetaObject *mem;
- QmlPropertyCache *cache;
- QmlEngine *engine;
- QSet<QmlOpenMetaObject*> referers;
-};
-
-QmlOpenMetaObjectType::QmlOpenMetaObjectType(const QMetaObject *base, QmlEngine *engine)
- : d(new QmlOpenMetaObjectTypePrivate)
-{
- d->engine = engine;
- d->init(base);
-}
-
-QmlOpenMetaObjectType::~QmlOpenMetaObjectType()
-{
- if (d->mem)
- qFree(d->mem);
- if (d->cache)
- d->cache->release();
- delete d;
-}
-
-
-int QmlOpenMetaObjectType::propertyOffset() const
-{
- return d->propertyOffset;
-}
-
-int QmlOpenMetaObjectType::signalOffset() const
-{
- return d->signalOffset;
-}
-
-int QmlOpenMetaObjectType::createProperty(const QByteArray &name)
-{
- int id = d->mob.propertyCount();
- d->mob.addSignal("__" + QByteArray::number(id) + "()");
- QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
- build.setDynamic(true);
- propertyCreated(id, build);
- qFree(d->mem);
- d->mem = d->mob.toMetaObject();
- d->names.insert(name, id);
- QSet<QmlOpenMetaObject*>::iterator it = d->referers.begin();
- while (it != d->referers.end()) {
- QmlOpenMetaObject *omo = *it;
- *static_cast<QMetaObject *>(omo) = *d->mem;
- if (d->cache)
- d->cache->update(d->engine, omo);
- ++it;
- }
-
- return d->propertyOffset + id;
-}
-
-void QmlOpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder)
-{
- if (d->referers.count())
- (*d->referers.begin())->propertyCreated(id, builder);
-}
-
-void QmlOpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
-{
- if (!mem) {
- mob.setSuperClass(metaObj);
- mob.setClassName(metaObj->className());
- mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
-
- mem = mob.toMetaObject();
-
- propertyOffset = mem->propertyOffset();
- signalOffset = mem->methodOffset();
- }
-}
-
-//----------------------------------------------------------------------------
-
-class QmlOpenMetaObjectPrivate
-{
-public:
- QmlOpenMetaObjectPrivate(QmlOpenMetaObject *_q)
- : q(_q), parent(0), type(0), cacheProperties(false) {}
-
- inline QVariant &getData(int idx) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- QPair<QVariant, bool> &prop = data[idx];
- if (!prop.second) {
- prop.first = q->initialValue(idx);
- prop.second = true;
- }
- return prop.first;
- }
-
- inline void writeData(int idx, const QVariant &value) {
- while (data.count() <= idx)
- data << QPair<QVariant, bool>(QVariant(), false);
- QPair<QVariant, bool> &prop = data[idx];
- prop.first = value;
- prop.second = true;
- }
-
- bool autoCreate;
- QmlOpenMetaObject *q;
- QAbstractDynamicMetaObject *parent;
- QList<QPair<QVariant, bool> > data;
- QObject *object;
- QmlOpenMetaObjectType *type;
- bool cacheProperties;
-};
-
-QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, bool automatic)
-: d(new QmlOpenMetaObjectPrivate(this))
-{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = new QmlOpenMetaObjectType(obj->metaObject(), 0);
- d->type->d->referers.insert(this);
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- *static_cast<QMetaObject *>(this) = *d->type->d->mem;
- op->metaObject = this;
-}
-
-QmlOpenMetaObject::QmlOpenMetaObject(QObject *obj, QmlOpenMetaObjectType *type, bool automatic)
-: d(new QmlOpenMetaObjectPrivate(this))
-{
- d->autoCreate = automatic;
- d->object = obj;
-
- d->type = type;
- d->type->addref();
- d->type->d->referers.insert(this);
-
- QObjectPrivate *op = QObjectPrivate::get(obj);
- *static_cast<QMetaObject *>(this) = *d->type->d->mem;
- op->metaObject = this;
-}
-
-QmlOpenMetaObject::~QmlOpenMetaObject()
-{
- if (d->parent)
- delete d->parent;
- d->type->d->referers.remove(this);
- d->type->release();
- delete d;
-}
-
-QmlOpenMetaObjectType *QmlOpenMetaObject::type() const
-{
- return d->type;
-}
-
-int QmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a)
-{
- if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty)
- && id >= d->type->d->propertyOffset) {
- int propId = id - d->type->d->propertyOffset;
- if (c == QMetaObject::ReadProperty) {
- propertyRead(propId);
- *reinterpret_cast<QVariant *>(a[0]) = d->getData(propId);
- } else if (c == QMetaObject::WriteProperty) {
- if (d->data[propId].first != *reinterpret_cast<QVariant *>(a[0])) {
- propertyWrite(propId);
- d->writeData(propId, *reinterpret_cast<QVariant *>(a[0]));
- activate(d->object, d->type->d->signalOffset + propId, 0);
- }
- }
- return -1;
- } else {
- if (d->parent)
- return d->parent->metaCall(c, id, a);
- else
- return d->object->qt_metacall(c, id, a);
- }
-}
-
-QAbstractDynamicMetaObject *QmlOpenMetaObject::parent() const
-{
- return d->parent;
-}
-
-QVariant QmlOpenMetaObject::value(int id) const
-{
- return d->getData(id);
-}
-
-void QmlOpenMetaObject::setValue(int id, const QVariant &value)
-{
- d->writeData(id, value);
- activate(d->object, id + d->type->d->signalOffset, 0);
-}
-
-QVariant QmlOpenMetaObject::value(const QByteArray &name) const
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
- if (iter == d->type->d->names.end())
- return QVariant();
-
- return d->getData(*iter);
-}
-
-QVariant &QmlOpenMetaObject::operator[](const QByteArray &name)
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
- Q_ASSERT(iter != d->type->d->names.end());
-
- return d->getData(*iter);
-}
-
-void QmlOpenMetaObject::setValue(const QByteArray &name, const QVariant &val)
-{
- QHash<QByteArray, int>::ConstIterator iter = d->type->d->names.find(name);
-
- int id = -1;
- if (iter == d->type->d->names.end()) {
- id = d->type->createProperty(name.constData()) - d->type->d->propertyOffset;
- } else {
- id = *iter;
- }
-
- QVariant &dataVal = d->getData(id);
- if (dataVal == val)
- return;
-
- dataVal = val;
- activate(d->object, id + d->type->d->signalOffset, 0);
-}
-
-void QmlOpenMetaObject::setCached(bool c)
-{
- if (c == d->cacheProperties || !d->type->d->engine)
- return;
-
- d->cacheProperties = c;
-
- QmlDeclarativeData *qmldata = QmlDeclarativeData::get(d->object, true);
- if (d->cacheProperties) {
- if (!d->type->d->cache)
- d->type->d->cache = QmlPropertyCache::create(d->type->d->engine, this);
- qmldata->propertyCache = d->type->d->cache;
- d->type->d->cache->addref();
- } else {
- if (d->type->d->cache)
- d->type->d->cache->release();
- qmldata->propertyCache = 0;
- }
-}
-
-
-int QmlOpenMetaObject::createProperty(const char *name, const char *)
-{
- if (d->autoCreate)
- return d->type->createProperty(name);
- else
- return -1;
-}
-
-void QmlOpenMetaObject::propertyRead(int)
-{
-}
-
-void QmlOpenMetaObject::propertyWrite(int)
-{
-}
-
-void QmlOpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &)
-{
-}
-
-QVariant QmlOpenMetaObject::initialValue(int)
-{
- return QVariant();
-}
-
-int QmlOpenMetaObject::count() const
-{
- return d->type->d->names.count();
-}
-
-QByteArray QmlOpenMetaObject::name(int idx) const
-{
- Q_ASSERT(idx >= 0 && idx < d->type->d->names.count());
-
- return d->type->d->mob.property(idx).name();
-}
-
-QObject *QmlOpenMetaObject::object() const
-{
- return d->object;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlopenmetaobject_p.h b/src/declarative/util/qmlopenmetaobject_p.h
deleted file mode 100644
index 3f9450dbc3..0000000000
--- a/src/declarative/util/qmlopenmetaobject_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 QMLOPENMETAOBJECT_H
-#define QMLOPENMETAOBJECT_H
-
-#include <private/qmlrefcount_p.h>
-#include <QtCore/QMetaObject>
-#include <QtCore/QObject>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlEngine;
-class QMetaPropertyBuilder;
-class QmlOpenMetaObjectTypePrivate;
-class Q_DECLARATIVE_EXPORT QmlOpenMetaObjectType : public QmlRefCount
-{
-public:
- QmlOpenMetaObjectType(const QMetaObject *base, QmlEngine *engine);
- ~QmlOpenMetaObjectType();
-
- int createProperty(const QByteArray &name);
-
- int propertyOffset() const;
- int signalOffset() const;
-
-protected:
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
-
-private:
- QmlOpenMetaObjectTypePrivate *d;
- friend class QmlOpenMetaObject;
- friend class QmlOpenMetaObjectPrivate;
-};
-
-class QmlOpenMetaObjectPrivate;
-class Q_DECLARATIVE_EXPORT QmlOpenMetaObject : public QAbstractDynamicMetaObject
-{
-public:
- QmlOpenMetaObject(QObject *, bool = true);
- QmlOpenMetaObject(QObject *, QmlOpenMetaObjectType *, bool = true);
- ~QmlOpenMetaObject();
-
- QVariant value(const QByteArray &) const;
- void setValue(const QByteArray &, const QVariant &);
- QVariant value(int) const;
- void setValue(int, const QVariant &);
- QVariant &operator[](const QByteArray &);
-
- int count() const;
- QByteArray name(int) const;
-
- QObject *object() const;
- virtual QVariant initialValue(int);
-
- // Be careful - once setCached(true) is called createProperty() is no
- // longer automatically called for new properties.
- void setCached(bool);
-
- QmlOpenMetaObjectType *type() const;
-
-protected:
- virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
- virtual int createProperty(const char *, const char *);
-
- virtual void propertyRead(int);
- virtual void propertyWrite(int);
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
-
- QAbstractDynamicMetaObject *parent() const;
-
-private:
- QmlOpenMetaObjectPrivate *d;
- friend class QmlOpenMetaObjectType;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLOPENMETAOBJECT_H
diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp
deleted file mode 100644
index 82f776f5c4..0000000000
--- a/src/declarative/util/qmlpackage.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmlpackage_p.h"
-
-#include <private/qobject_p.h>
-#include "private/qmlguard_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlPackagePrivate : public QObjectPrivate
-{
-public:
- QmlPackagePrivate() {}
-
- struct DataGuard : public QmlGuard<QObject>
- {
- DataGuard(QObject *obj, QList<DataGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
- QList<DataGuard> *list;
- void objectDestroyed(QObject *) {
- // we assume priv will always be destroyed after objectDestroyed calls
- list->removeOne(*this);
- }
- };
-
- QList<DataGuard> dataList;
- static void data_append(QmlListProperty<QObject> *prop, QObject *o) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- list->append(DataGuard(o, list));
- }
- static void data_clear(QmlListProperty<QObject> *prop) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- list->clear();
- }
- static QObject *data_at(QmlListProperty<QObject> *prop, int index) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->at(index);
- }
- static int data_count(QmlListProperty<QObject> *prop) {
- QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
- return list->count();
- }
-};
-
-class QmlPackageAttached : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(QString name READ name WRITE setName)
-public:
- QmlPackageAttached(QObject *parent);
- virtual ~QmlPackageAttached();
-
- QString name() const;
- void setName(const QString &n);
-
- static QHash<QObject *, QmlPackageAttached *> attached;
-private:
- QString _name;
-};
-
-QHash<QObject *, QmlPackageAttached *> QmlPackageAttached::attached;
-
-QmlPackageAttached::QmlPackageAttached(QObject *parent)
-: QObject(parent)
-{
- attached.insert(parent, this);
-}
-
-QmlPackageAttached::~QmlPackageAttached()
-{
- attached.remove(parent());
-}
-
-QString QmlPackageAttached::name() const
-{
- return _name;
-}
-
-void QmlPackageAttached::setName(const QString &n)
-{
- _name = n;
-}
-
-QmlPackage::QmlPackage(QObject *parent)
- : QObject(*(new QmlPackagePrivate), parent)
-{
-}
-
-QmlPackage::~QmlPackage()
-{
- Q_D(QmlPackage);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- obj->setParent(this);
- }
-}
-
-QmlListProperty<QObject> QmlPackage::data()
-{
- Q_D(QmlPackage);
- return QmlListProperty<QObject>(this, &d->dataList, QmlPackagePrivate::data_append,
- QmlPackagePrivate::data_count,
- QmlPackagePrivate::data_at,
- QmlPackagePrivate::data_clear);
-}
-
-bool QmlPackage::hasPart(const QString &name)
-{
- Q_D(QmlPackage);
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- QmlPackageAttached *a = QmlPackageAttached::attached.value(obj);
- if (a && a->name() == name)
- return true;
- }
- return false;
-}
-
-QObject *QmlPackage::part(const QString &name)
-{
- Q_D(QmlPackage);
- if (name.isEmpty() && !d->dataList.isEmpty())
- return d->dataList.at(0);
-
- for (int ii = 0; ii < d->dataList.count(); ++ii) {
- QObject *obj = d->dataList.at(ii);
- QmlPackageAttached *a = QmlPackageAttached::attached.value(obj);
- if (a && a->name() == name)
- return obj;
- }
-
- if (name == QLatin1String("default") && !d->dataList.isEmpty())
- return d->dataList.at(0);
-
- return 0;
-}
-
-QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o)
-{
- return new QmlPackageAttached(o);
-}
-
-QML_DEFINE_TYPE(Qt,4,6,Package,QmlPackage)
-
-QT_END_NAMESPACE
-
-#include <qmlpackage.moc>
diff --git a/src/declarative/util/qmlpackage_p.h b/src/declarative/util/qmlpackage_p.h
deleted file mode 100644
index 29b6bbeba9..0000000000
--- a/src/declarative/util/qmlpackage_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 QMLPACKAGE_H
-#define QMLPACKAGE_H
-
-#include <qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-/*****************************************************************************
- *****************************************************************************
- XXX Experimental
- *****************************************************************************
-*****************************************************************************/
-
-class QmlPackagePrivate;
-class QmlPackageAttached;
-class QmlPackage : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPackage)
-
- Q_CLASSINFO("DefaultProperty", "data")
- Q_PROPERTY(QmlListProperty<QObject> data READ data SCRIPTABLE false)
-
-public:
- QmlPackage(QObject *parent=0);
- virtual ~QmlPackage();
-
- QmlListProperty<QObject> data();
-
- QObject *part(const QString & = QString());
- bool hasPart(const QString &);
-
- static QmlPackageAttached *qmlAttachedProperties(QObject *);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlPackage)
-QML_DECLARE_TYPEINFO(QmlPackage, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QMLPACKAGE_H
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
deleted file mode 100644
index 2459651e14..0000000000
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ /dev/null
@@ -1,611 +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 "qmlpixmapcache_p.h"
-#include "qmlnetworkaccessmanagerfactory.h"
-#include "qmlimageprovider.h"
-
-#include "qfxperf_p_p.h"
-
-#include <qmlengine.h>
-#include <private/qmlglobal_p.h>
-#include <private/qmlengine_p.h>
-
-#include <QCoreApplication>
-#include <QImageReader>
-#include <QHash>
-#include <QNetworkReply>
-#include <QPixmapCache>
-#include <QFile>
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
-#include <QtCore/qdebug.h>
-#include <private/qobject_p.h>
-#include <QSslError>
-
-#ifdef Q_OS_LINUX
-#include <pthread.h>
-#include <linux/sched.h>
-#endif
-
-// Maximum number of simultaneous image requests to send.
-static const int maxImageRequestCount = 8;
-
-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
-
-class QmlImageReaderEvent : public QEvent
-{
-public:
- enum ReadError { NoError, Loading, Decoding };
-
- QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, const QImage &img)
- : QEvent(QEvent::User), error(err), errorString(errStr), image(img) {}
-
- ReadError error;
- QString errorString;
- QImage image;
-};
-
-class QmlImageRequestHandler;
-class QmlImageReader : public QThread
-{
- Q_OBJECT
-public:
- QmlImageReader(QmlEngine *eng);
- ~QmlImageReader();
-
- QmlPixmapReply *getImage(const QUrl &url);
- void cancel(QmlPixmapReply *rep);
-
- static QmlImageReader *instance(QmlEngine *engine);
-
-protected:
- void run();
-
-private:
- QList<QmlPixmapReply*> jobs;
- QList<QmlPixmapReply*> cancelled;
- QmlEngine *engine;
- QmlImageRequestHandler *handler;
- QMutex mutex;
-
- static QHash<QmlEngine *,QmlImageReader*> readers;
- static QMutex readerMutex;
- friend class QmlImageRequestHandler;
-};
-
-QHash<QmlEngine *,QmlImageReader*> QmlImageReader::readers;
-QMutex QmlImageReader::readerMutex;
-
-
-class QmlImageRequestHandler : public QObject
-{
- Q_OBJECT
-public:
- QmlImageRequestHandler(QmlImageReader *read, QmlEngine *eng)
- : QObject(), accessManager(0), engine(eng), reader(read)
- {
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
- }
-
- QmlPixmapReply *getImage(const QUrl &url);
- void cancel(QmlPixmapReply *reply);
-
-protected:
- bool event(QEvent *event);
-
-private slots:
- void networkRequestDone();
-
-private:
- QNetworkAccessManager *networkAccessManager() {
- if (!accessManager)
- accessManager = QmlEnginePrivate::get(engine)->createNetworkAccessManager(this);
- return accessManager;
- }
-
- QHash<QNetworkReply*,QmlPixmapReply*> replies;
- QNetworkAccessManager *accessManager;
- QmlEngine *engine;
- QmlImageReader *reader;
-};
-
-//===========================================================================
-
-bool QmlImageRequestHandler::event(QEvent *event)
-{
- if (event->type() == QEvent::User) {
- static int replyDownloadProgress = -1;
- static int replyFinished = -1;
- static int downloadProgress = -1;
- static int thisNetworkRequestDone = -1;
-
- if (replyDownloadProgress == -1) {
- replyDownloadProgress = QNetworkReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- replyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()");
- downloadProgress = QmlPixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- thisNetworkRequestDone = QmlImageRequestHandler::staticMetaObject.indexOfSlot("networkRequestDone()");
- }
-
- while (1) {
- reader->mutex.lock();
-
- if (reader->cancelled.count()) {
- for (int i = 0; i < reader->cancelled.count(); ++i) {
- QmlPixmapReply *job = reader->cancelled.at(i);
- // cancel any jobs already started
- QNetworkReply *reply = replies.key(job, 0);
- if (reply && reply->isRunning()) {
- replies.remove(reply);
- reply->close();
- }
- // remove from pending job list
- for (int j = 0; j < reader->jobs.count(); ++j) {
- if (reader->jobs.at(j) == job) {
- reader->jobs.removeAt(j);
- job->release(true);
- break;
- }
- }
- }
- reader->cancelled.clear();
- }
-
- if (!reader->jobs.count() || replies.count() > maxImageRequestCount) {
- reader->mutex.unlock();
- break;
- }
-
- QmlPixmapReply *runningJob = reader->jobs.takeLast();
- QUrl url = runningJob->url();
- reader->mutex.unlock();
-
- // fetch
- if (url.scheme() == QLatin1String("image")) {
- QImage image = QmlEnginePrivate::get(engine)->getImageFromProvider(url);
- QmlImageReaderEvent::ReadError errorCode = QmlImageReaderEvent::NoError;
- QString errorStr;
- if (image.isNull()) {
- errorCode = QmlImageReaderEvent::Loading;
- errorStr = QLatin1String("Failed to get image from provider: ") + url.toString();
- }
- QCoreApplication::postEvent(runningJob, new QmlImageReaderEvent(errorCode, errorStr, image));
- } else {
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- QNetworkReply *reply = networkAccessManager()->get(req);
-
- QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
- QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
-
- replies.insert(reply, runningJob);
- }
- }
- return true;
- }
-
- return QObject::event(event);
-}
-
-void QmlImageRequestHandler::networkRequestDone()
-{
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
- QmlPixmapReply *job = replies.take(reply);
- if (job) {
- QImage image;
- QmlImageReaderEvent::ReadError error;
- QString errorString;
- if (reply->error()) {
- error = QmlImageReaderEvent::Loading;
- errorString = reply->errorString();
- } else {
- QImageReader imgio(reply);
- if (imgio.read(&image)) {
- error = QmlImageReaderEvent::NoError;
- } else {
- errorString = QLatin1String("Error decoding: ") + reply->url().toString()
- + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\"");
- error = QmlImageReaderEvent::Decoding;
- }
- }
- // send completion event to the QmlPixmapReply
- QCoreApplication::postEvent(job, new QmlImageReaderEvent(error, errorString, image));
- }
- // kick off event loop again if we have dropped below max request count
- if (replies.count() == maxImageRequestCount)
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
- reply->deleteLater();
-}
-
-//===========================================================================
-
-QmlImageReader::QmlImageReader(QmlEngine *eng)
- : QThread(eng), engine(eng), handler(0)
-{
- start(QThread::LowPriority);
-}
-
-QmlImageReader::~QmlImageReader()
-{
- readerMutex.lock();
- readers.remove(engine);
- readerMutex.unlock();
-
- quit();
- wait();
-}
-
-QmlImageReader *QmlImageReader::instance(QmlEngine *engine)
-{
- readerMutex.lock();
- QmlImageReader *reader = readers.value(engine);
- if (!reader) {
- reader = new QmlImageReader(engine);
- readers.insert(engine, reader);
- }
- readerMutex.unlock();
-
- return reader;
-}
-
-QmlPixmapReply *QmlImageReader::getImage(const QUrl &url)
-{
- mutex.lock();
- QmlPixmapReply *reply = new QmlPixmapReply(this, url);
- reply->addRef();
- reply->setLoading();
- jobs.append(reply);
- if (jobs.count() == 1 && handler)
- QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
- mutex.unlock();
- return reply;
-}
-
-void QmlImageReader::cancel(QmlPixmapReply *reply)
-{
- mutex.lock();
- if (reply->isLoading()) {
- // Add to cancel list to be cancelled in reader thread.
- cancelled.append(reply);
- if (cancelled.count() == 1 && handler)
- QCoreApplication::postEvent(handler, new QEvent(QEvent::User));
- }
- mutex.unlock();
-}
-
-void QmlImageReader::run()
-{
-#if defined(Q_OS_LINUX) && defined(SCHED_IDLE)
- struct sched_param param;
- int policy;
-
- pthread_getschedparam(pthread_self(), &policy, &param);
- pthread_setschedparam(pthread_self(), SCHED_IDLE, &param);
-#endif
-
- handler = new QmlImageRequestHandler(this, engine);
-
- exec();
-
- delete handler;
- handler = 0;
-}
-
-//===========================================================================
-
-static bool readImage(QIODevice *dev, QPixmap *pixmap, QString &errorString)
-{
- QImageReader imgio(dev);
-
-//#define QT_TEST_SCALED_SIZE
-#ifdef QT_TEST_SCALED_SIZE
- /*
- Some mechanism is needed for loading images at a limited size, especially
- for remote images. Loading only thumbnails of remote progressive JPEG
- images can be efficient. (Qt jpeg handler does not do so currently)
- */
-
- QSize limit(60,60);
- QSize sz = imgio.size();
- if (sz.width() > limit.width() || sz.height() > limit.height()) {
- sz.scale(limit,Qt::KeepAspectRatio);
- imgio.setScaledSize(sz);
- }
-#endif
-
- QImage img;
- if (imgio.read(&img)) {
-#ifdef QT_TEST_SCALED_SIZE
- if (!sz.isValid())
- img = img.scaled(limit,Qt::KeepAspectRatio);
-#endif
- *pixmap = QPixmap::fromImage(img);
- return true;
- } else {
- errorString = imgio.errorString();
- return false;
- }
-}
-
-/*!
- \internal
- \class QmlPixmapCache
- \brief Enacapsultes a pixmap for QmlGraphics items.
-
- This class is NOT reentrant.
- */
-
-static QString toLocalFileOrQrc(const QUrl& url)
-{
- QString r = url.toLocalFile();
- if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
- r = QLatin1Char(':') + url.path();
- return r;
-}
-
-typedef QHash<QUrl, QmlPixmapReply *> QmlPixmapReplyHash;
-Q_GLOBAL_STATIC(QmlPixmapReplyHash, qmlActivePixmapReplies);
-
-class QmlPixmapReplyPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlPixmapReply)
-
-public:
- QmlPixmapReplyPrivate(QmlImageReader *r, const QUrl &u)
- : QObjectPrivate(), refCount(1), url(u), status(QmlPixmapReply::Loading), loading(false), reader(r) {
- }
-
- int refCount;
- QUrl url;
- QPixmap pixmap; // ensure reference to pixmap so QPixmapCache does not discard
- QmlPixmapReply::Status status;
- bool loading;
- QmlImageReader *reader;
-};
-
-
-QmlPixmapReply::QmlPixmapReply(QmlImageReader *reader, const QUrl &url)
- : QObject(*new QmlPixmapReplyPrivate(reader, url), 0)
-{
-}
-
-QmlPixmapReply::~QmlPixmapReply()
-{
-}
-
-const QUrl &QmlPixmapReply::url() const
-{
- Q_D(const QmlPixmapReply);
- return d->url;
-}
-
-bool QmlPixmapReply::event(QEvent *event)
-{
- Q_D(QmlPixmapReply);
- if (event->type() == QEvent::User) {
- d->loading = false;
- if (!release(true)) {
- QmlImageReaderEvent *de = static_cast<QmlImageReaderEvent*>(event);
- d->status = (de->error == QmlImageReaderEvent::NoError) ? Ready : Error;
- if (d->status == Ready)
- d->pixmap = QPixmap::fromImage(de->image);
- else
- qWarning() << de->errorString;
- QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100));
- QString strKey = QString::fromLatin1(key.constData(), key.count());
- QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false)
- emit finished();
- }
- return true;
- }
-
- return QObject::event(event);
-}
-
-QmlPixmapReply::Status QmlPixmapReply::status() const
-{
- Q_D(const QmlPixmapReply);
- return d->status;
-}
-
-bool QmlPixmapReply::isLoading() const
-{
- Q_D(const QmlPixmapReply);
- return d->loading;
-}
-
-void QmlPixmapReply::setLoading()
-{
- Q_D(QmlPixmapReply);
- d->loading = true;
-}
-
-void QmlPixmapReply::addRef()
-{
- Q_D(QmlPixmapReply);
- ++d->refCount;
-}
-
-bool QmlPixmapReply::release(bool defer)
-{
- Q_D(QmlPixmapReply);
- Q_ASSERT(d->refCount > 0);
- --d->refCount;
- if (d->refCount == 0) {
- qmlActivePixmapReplies()->remove(d->url);
- if (defer)
- deleteLater();
- else
- delete this;
- return true;
- } else if (d->refCount == 1 && d->loading) {
- // The only reference left is the reader thread.
- qmlActivePixmapReplies()->remove(d->url);
- d->reader->cancel(this);
- }
-
- return false;
-}
-
-/*!
- Finds the cached pixmap corresponding to \a url.
- If the image is a network resource and has not yet
- been retrieved and cached, request() must be called.
-
- Returns Ready, or Error if the image has been retrieved,
- otherwise the current retrieval status.
-*/
-QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap)
-{
- QmlPixmapReply::Status status = QmlPixmapReply::Unrequested;
-
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- QString lf = toLocalFileOrQrc(url);
- if (!lf.isEmpty()) {
- status = QmlPixmapReply::Ready;
- if (!QPixmapCache::find(lf,pixmap)) {
- QFile f(lf);
- if (f.open(QIODevice::ReadOnly)) {
- QString errorString;
- if (!readImage(&f, pixmap, errorString)) {
- errorString = QLatin1String("Error decoding: ") + url.toString()
- + QLatin1String(" \"") + errorString + QLatin1String("\"");
- qWarning() << errorString;
- *pixmap = QPixmap();
- status = QmlPixmapReply::Error;
- }
- } else {
- qWarning() << "Cannot open" << url;
- *pixmap = QPixmap();
- status = QmlPixmapReply::Error;
- }
- if (status == QmlPixmapReply::Ready)
- QPixmapCache::insert(lf, *pixmap);
- }
- return status;
- }
-#endif
-
- QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100));
- QString strKey = QString::fromLatin1(key.constData(), key.count());
- QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url);
- if (iter != qmlActivePixmapReplies()->end() && (*iter)->status() == QmlPixmapReply::Ready) {
- // Must check this, since QPixmapCache::insert may have failed.
- *pixmap = (*iter)->d_func()->pixmap;
- status = (*iter)->status();
- (*iter)->release();
- } else if (QPixmapCache::find(strKey, pixmap)) {
- if (iter != qmlActivePixmapReplies()->end()) {
- status = (*iter)->status();
- (*iter)->release();
- } else {
- status = pixmap->isNull() ? QmlPixmapReply::Error : QmlPixmapReply::Ready;
- }
- } else if (iter != qmlActivePixmapReplies()->end()) {
- status = QmlPixmapReply::Loading;
- }
-
- return status;
-}
-
-/*!
- Starts a network request to load \a url.
-
- Returns a QmlPixmapReply. Caller should connect to QmlPixmapReply::finished()
- and call get() when the image is available.
-
- The returned QmlPixmapReply will be deleted when all request() calls are
- matched by a corresponding get() call.
-*/
-QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url)
-{
- QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url);
- if (iter == qmlActivePixmapReplies()->end()) {
- QmlImageReader *reader = QmlImageReader::instance(engine);
- QmlPixmapReply *item = reader->getImage(url);
- iter = qmlActivePixmapReplies()->insert(url, item);
- } else {
- (*iter)->addRef();
- }
-
- return (*iter);
-}
-
-/*!
- Cancels a previous call to request().
-
- May also cancel loading (eg. if no other pending request).
-
- Any connections from the QmlPixmapReply returned by request() to \a obj will be
- disconnected.
-*/
-void QmlPixmapCache::cancel(const QUrl& url, QObject *obj)
-{
- QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url);
- if (iter == qmlActivePixmapReplies()->end())
- return;
-
- QmlPixmapReply *reply = *iter;
- if (obj)
- QObject::disconnect(reply, 0, obj, 0);
- reply->release();
-}
-
-/*!
- This function is mainly for test verification. It returns the number of
- requests that are still unfinished.
-*/
-int QmlPixmapCache::pendingRequests()
-{
- return qmlActivePixmapReplies()->count();
-}
-
-QT_END_NAMESPACE
-
-#include <qmlpixmapcache.moc>
diff --git a/src/declarative/util/qmlpixmapcache_p.h b/src/declarative/util/qmlpixmapcache_p.h
deleted file mode 100644
index 86908cc6db..0000000000
--- a/src/declarative/util/qmlpixmapcache_p.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 QMLPIXMAPCACHE_H
-#define QMLPIXMAPCACHE_H
-
-#include <QtCore/QString>
-#include <QtGui/QPixmap>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QmlEngine;
-class QNetworkReply;
-class QmlImageReader;
-
-class QmlPixmapReplyPrivate;
-class Q_DECLARATIVE_EXPORT QmlPixmapReply : public QObject
-{
- Q_OBJECT
-public:
- ~QmlPixmapReply();
-
- enum Status { Ready, Error, Unrequested, Loading };
- Status status() const;
-
- const QUrl &url() const;
-
-Q_SIGNALS:
- void finished();
- void downloadProgress(qint64, qint64);
-
-protected:
- bool event(QEvent *event);
-
-private:
- void addRef();
- bool release(bool defer=false);
- bool isLoading() const;
- void setLoading();
-
-private:
- QmlPixmapReply(QmlImageReader *reader, const QUrl &url);
- Q_DISABLE_COPY(QmlPixmapReply)
- Q_DECLARE_PRIVATE(QmlPixmapReply)
- friend class QmlImageRequestHandler;
- friend class QmlImageReader;
- friend class QmlPixmapCache;
-};
-
-class Q_DECLARATIVE_EXPORT QmlPixmapCache
-{
-public:
- static QmlPixmapReply::Status get(const QUrl& url, QPixmap *pixmap);
- static QmlPixmapReply *request(QmlEngine *, const QUrl& url);
- static void cancel(const QUrl& url, QObject *obj);
- static int pendingRequests();
-};
-
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLPIXMAPCACHE_H
diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp
deleted file mode 100644
index fba22f93be..0000000000
--- a/src/declarative/util/qmlpropertychanges.cpp
+++ /dev/null
@@ -1,469 +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 "qmlpropertychanges_p.h"
-
-#include "qmlopenmetaobject_p.h"
-
-#include <qmlinfo.h>
-#include <qmlcustomparser_p.h>
-#include <qmlparser_p.h>
-#include <qmlexpression.h>
-#include <qmlbinding.h>
-#include <qmlcontext.h>
-#include <qmlguard_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass PropertyChanges QmlPropertyChanges
- \since 4.7
- \brief The PropertyChanges element describes new property values for a state.
-
- PropertyChanges provides a state change that modifies the properties of an item.
-
- Here is a property change that modifies the text and color of a Text element
- when it is clicked:
-
- \qml
- Text {
- id: myText
- width: 100; height: 100
- text: "Hello"
- color: "blue"
-
- states: State {
- name: "myState"
-
- PropertyChanges {
- target: myText
- text: "Goodbye"
- color: "red"
- }
- }
-
- MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
- }
- \endqml
-
- State-specific script for signal handlers can also be specified:
-
- \qml
- PropertyChanges {
- target: myMouseArea
- onClicked: doSomethingDifferent()
- }
- \endqml
-
- Changes to an Item's parent or anchors should be done using the associated change elements
- (ParentChange and AnchorChanges, respectively) rather than PropertyChanges.
-
- \sa {qmlstate}{States}
-*/
-
-/*!
- \internal
- \class QmlPropertyChanges
- \brief The QmlPropertyChanges class describes new property values for a state.
-*/
-
-/*!
- \qmlproperty Object PropertyChanges::target
- This property holds the object which contains the properties to be changed.
-*/
-
-class QmlReplaceSignalHandler : public QmlActionEvent
-{
-public:
- QmlReplaceSignalHandler() : expression(0), reverseExpression(0),
- rewindExpression(0), ownedExpression(0) {}
- ~QmlReplaceSignalHandler() {
- delete ownedExpression;
- }
-
- virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); }
-
- QmlMetaProperty property;
- QmlExpression *expression;
- QmlExpression *reverseExpression;
- QmlExpression *rewindExpression;
- QmlGuard<QmlExpression> ownedExpression;
-
- virtual void execute() {
- ownedExpression = property.setSignalExpression(expression);
- }
-
- virtual bool isReversable() { return true; }
- virtual void reverse() {
- ownedExpression = property.setSignalExpression(reverseExpression);
- }
-
- virtual void saveOriginals() {
- saveCurrentValues();
- reverseExpression = rewindExpression;
- }
-
- virtual void rewind() {
- ownedExpression = property.setSignalExpression(rewindExpression);
- }
- virtual void saveCurrentValues() { rewindExpression = property.signalExpression(); }
-
- virtual bool override(QmlActionEvent*other) {
- if (other == this)
- return true;
- if (other->typeName() != typeName())
- return false;
- if (static_cast<QmlReplaceSignalHandler*>(other)->property == property)
- return true;
- return false;
- }
-};
-
-
-class QmlPropertyChangesPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlPropertyChanges)
-public:
- QmlPropertyChangesPrivate() : object(0), decoded(true), restore(true),
- isExplicit(false) {}
-
- QObject *object;
- QByteArray data;
-
- bool decoded : 1;
- bool restore : 1;
- bool isExplicit : 1;
-
- void decode();
-
- QList<QPair<QByteArray, QVariant> > properties;
- QList<QPair<QByteArray, QmlExpression *> > expressions;
- QList<QmlReplaceSignalHandler*> signalReplacements;
-
- QmlMetaProperty property(const QByteArray &);
-};
-
-class QmlPropertyChangesParser : public QmlCustomParser
-{
-public:
- void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QmlCustomParserProperty &prop);
-
- virtual QByteArray compile(const QList<QmlCustomParserProperty> &);
- virtual void setCustomData(QObject *, const QByteArray &);
-};
-
-void
-QmlPropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &list,
- const QByteArray &pre,
- const QmlCustomParserProperty &prop)
-{
- QByteArray propName = pre + prop.name();
-
- QList<QVariant> values = prop.assignedValues();
- for (int ii = 0; ii < values.count(); ++ii) {
- const QVariant &value = values.at(ii);
-
- if (value.userType() == qMetaTypeId<QmlCustomParserNode>()) {
- continue;
- } else if(value.userType() == qMetaTypeId<QmlCustomParserProperty>()) {
-
- QmlCustomParserProperty prop =
- qvariant_cast<QmlCustomParserProperty>(value);
- QByteArray pre = propName + '.';
- compileList(list, pre, prop);
-
- } else {
- list << qMakePair(propName, value);
- }
- }
-}
-
-QByteArray
-QmlPropertyChangesParser::compile(const QList<QmlCustomParserProperty> &props)
-{
- QList<QPair<QByteArray, QVariant> > data;
- for(int ii = 0; ii < props.count(); ++ii)
- compileList(data, QByteArray(), props.at(ii));
-
- QByteArray rv;
- QDataStream ds(&rv, QIODevice::WriteOnly);
-
- ds << data.count();
- for(int ii = 0; ii < data.count(); ++ii) {
- QmlParser::Variant v = qvariant_cast<QmlParser::Variant>(data.at(ii).second);
- QVariant var;
- bool isScript = v.isScript();
- switch(v.type()) {
- case QmlParser::Variant::Boolean:
- var = QVariant(v.asBoolean());
- break;
- case QmlParser::Variant::Number:
- var = QVariant(v.asNumber());
- break;
- case QmlParser::Variant::String:
- var = QVariant(v.asString());
- break;
- case QmlParser::Variant::Invalid:
- case QmlParser::Variant::Script:
- var = QVariant(v.asScript());
- break;
- }
-
- ds << data.at(ii).first << isScript << var;
- }
-
- return rv;
-}
-
-void QmlPropertyChangesPrivate::decode()
-{
- Q_Q(QmlPropertyChanges);
- if (decoded)
- return;
-
- QDataStream ds(&data, QIODevice::ReadOnly);
-
- int count;
- ds >> count;
- for (int ii = 0; ii < count; ++ii) {
- QByteArray name;
- bool isScript;
- QVariant data;
- ds >> name;
- ds >> isScript;
- ds >> data;
-
- QmlMetaProperty prop = property(name); //### better way to check for signal property?
- if (prop.type() & QmlMetaProperty::SignalProperty) {
- QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object);
- expression->setTrackChange(false);
- QmlReplaceSignalHandler *handler = new QmlReplaceSignalHandler;
- handler->property = prop;
- handler->expression = expression;
- signalReplacements << handler;
- } else if (isScript) {
- QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object);
- expression->setTrackChange(false);
- expressions << qMakePair(name, expression);
- } else {
- properties << qMakePair(name, data);
- }
- }
-
- decoded = true;
- data.clear();
-}
-
-void QmlPropertyChangesParser::setCustomData(QObject *object,
- const QByteArray &data)
-{
- QmlPropertyChangesPrivate *p =
- static_cast<QmlPropertyChangesPrivate *>(QObjectPrivate::get(object));
- p->data = data;
- p->decoded = false;
-}
-
-QmlPropertyChanges::QmlPropertyChanges()
-: QmlStateOperation(*(new QmlPropertyChangesPrivate))
-{
-}
-
-QmlPropertyChanges::~QmlPropertyChanges()
-{
- Q_D(QmlPropertyChanges);
- for(int ii = 0; ii < d->expressions.count(); ++ii)
- delete d->expressions.at(ii).second;
- for(int ii = 0; ii < d->signalReplacements.count(); ++ii)
- delete d->signalReplacements.at(ii);
-}
-
-QObject *QmlPropertyChanges::object() const
-{
- Q_D(const QmlPropertyChanges);
- return d->object;
-}
-
-void QmlPropertyChanges::setObject(QObject *o)
-{
- Q_D(QmlPropertyChanges);
- d->object = o;
-}
-
-/*!
- \qmlproperty bool PropertyChanges::restoreEntryValues
-
- Whether or not the previous values should be restored when
- leaving the state. By default, restoreEntryValues is true.
-
- By setting restoreEntryValues to false, you can create a temporary state
- that has permanent effects on property values.
-*/
-bool QmlPropertyChanges::restoreEntryValues() const
-{
- Q_D(const QmlPropertyChanges);
- return d->restore;
-}
-
-void QmlPropertyChanges::setRestoreEntryValues(bool v)
-{
- Q_D(QmlPropertyChanges);
- d->restore = v;
-}
-
-QmlMetaProperty
-QmlPropertyChangesPrivate::property(const QByteArray &property)
-{
- Q_Q(QmlPropertyChanges);
- QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromUtf8(property));
- if (!prop.isValid()) {
- qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property));
- return QmlMetaProperty();
- } else if (!(prop.type() & QmlMetaProperty::SignalProperty) && !prop.isWritable()) {
- qmlInfo(q) << QmlPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property));
- return QmlMetaProperty();
- }
- return prop;
-}
-
-QmlPropertyChanges::ActionList QmlPropertyChanges::actions()
-{
- Q_D(QmlPropertyChanges);
-
- d->decode();
-
- ActionList list;
-
- for (int ii = 0; ii < d->properties.count(); ++ii) {
-
- QByteArray property = d->properties.at(ii).first;
-
- QmlAction a(d->object, QString::fromLatin1(property),
- d->properties.at(ii).second);
-
- if (a.property.isValid()) {
- a.restore = restoreEntryValues();
-
- if (a.property.propertyType() == QVariant::Url &&
- (a.toValue.userType() == QVariant::String || a.toValue.userType() == QVariant::ByteArray) && !a.toValue.isNull())
- a.toValue.setValue(qmlContext(this)->resolvedUrl(QUrl(a.toValue.toString())));
-
- list << a;
- }
- }
-
- for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
-
- QmlReplaceSignalHandler *handler = d->signalReplacements.at(ii);
-
- if (handler->property.isValid()) {
- QmlAction a;
- a.event = handler;
- list << a;
- }
- }
-
- for (int ii = 0; ii < d->expressions.count(); ++ii) {
-
- QByteArray property = d->expressions.at(ii).first;
- QmlMetaProperty prop = d->property(property);
-
- if (prop.isValid()) {
- QmlAction a;
- a.restore = restoreEntryValues();
- a.property = prop;
- a.fromValue = a.property.read();
- a.specifiedObject = d->object;
- a.specifiedProperty = QString::fromLatin1(property);
-
- if (d->isExplicit) {
- a.toValue = d->expressions.at(ii).second->value();
- } else {
- QmlBinding *newBinding = new QmlBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this));
- newBinding->setTarget(prop);
- a.toBinding = newBinding;
- a.deletableToBinding = true;
- }
-
- list << a;
- }
- }
-
- return list;
-}
-
-/*!
- \qmlproperty bool PropertyChanges::explicit
-
- If explicit is set to true, any potential bindings will be interpreted as
- once-off assignments that occur when the state is entered.
-
- In the following example, the addition of explicit prevents myItem.width from
- being bound to parent.width. Instead, it is assigned the value of parent.width
- at the time of the state change.
- \qml
- PropertyChanges {
- target: myItem
- explicit: true
- width: parent.width
- }
- \endqml
-
- By default, explicit is false.
-*/
-bool QmlPropertyChanges::isExplicit() const
-{
- Q_D(const QmlPropertyChanges);
- return d->isExplicit;
-}
-
-void QmlPropertyChanges::setIsExplicit(bool e)
-{
- Q_D(QmlPropertyChanges);
- d->isExplicit = e;
-}
-
-QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QmlPropertyChanges, QmlPropertyChangesParser)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlpropertychanges_p.h b/src/declarative/util/qmlpropertychanges_p.h
deleted file mode 100644
index 19dcf9d30b..0000000000
--- a/src/declarative/util/qmlpropertychanges_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 QMLPROPERTYCHANGES_H
-#define QMLPROPERTYCHANGES_H
-
-#include "qmlstateoperations_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlPropertyChangesPrivate;
-class Q_DECLARATIVE_EXPORT QmlPropertyChanges : public QmlStateOperation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlPropertyChanges)
-
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
- Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
-public:
- QmlPropertyChanges();
- ~QmlPropertyChanges();
-
- QObject *object() const;
- void setObject(QObject *);
-
- bool restoreEntryValues() const;
- void setRestoreEntryValues(bool);
-
- bool isExplicit() const;
- void setIsExplicit(bool);
-
- virtual ActionList actions();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlPropertyChanges)
-
-QT_END_HEADER
-
-#endif // QMLPROPERTYCHANGES_H
diff --git a/src/declarative/util/qmlpropertymap.cpp b/src/declarative/util/qmlpropertymap.cpp
deleted file mode 100644
index 317896e871..0000000000
--- a/src/declarative/util/qmlpropertymap.cpp
+++ /dev/null
@@ -1,279 +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 "qmlpropertymap.h"
-
-#include "qmlopenmetaobject_p.h"
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-//QmlPropertyMapMetaObject lets us listen for changes coming from QML
-//so we can emit the changed signal.
-class QmlPropertyMapMetaObject : public QmlOpenMetaObject
-{
-public:
- QmlPropertyMapMetaObject(QmlPropertyMap *obj, QmlPropertyMapPrivate *objPriv);
-
-protected:
- virtual void propertyWrite(int index);
-
-private:
- QmlPropertyMap *map;
- QmlPropertyMapPrivate *priv;
-};
-
-class QmlPropertyMapPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlPropertyMap)
-public:
- QmlPropertyMapMetaObject *mo;
- QStringList keys;
- void emitChanged(const QString &key);
-};
-
-void QmlPropertyMapPrivate::emitChanged(const QString &key)
-{
- Q_Q(QmlPropertyMap);
- emit q->valueChanged(key);
-}
-
-QmlPropertyMapMetaObject::QmlPropertyMapMetaObject(QmlPropertyMap *obj, QmlPropertyMapPrivate *objPriv) : QmlOpenMetaObject(obj)
-{
- map = obj;
- priv = objPriv;
-}
-
-void QmlPropertyMapMetaObject::propertyWrite(int index)
-{
- priv->emitChanged(QString::fromUtf8(name(index)));
-}
-
-/*!
- \class QmlPropertyMap
- \since 4.7
- \brief The QmlPropertyMap class allows you to set key-value pairs that can be used in bindings.
-
- QmlPropertyMap provides a convenient way to expose domain data to the UI layer.
- The following example shows how you might declare data in C++ and then
- access it in QML.
-
- Setup in C++:
- \code
- //create our data
- QmlPropertyMap ownerData;
- ownerData.insert("name", QVariant(QString("John Smith")));
- ownerData.insert("phone", QVariant(QString("555-5555")));
-
- //expose it to the UI layer
- QmlContext *ctxt = view->bindContext();
- ctxt->setProperty("owner", &data);
- \endcode
-
- Then, in QML:
- \code
- Text { text: owner.name }
- Text { text: owner.phone }
- \endcode
-
- The binding is dynamic - whenever a key's value is updated, anything bound to that
- key will be updated as well.
-
- To detect value changes made in the UI layer you can connect to the valueChanged() signal.
- However, note that valueChanged() is \bold NOT emitted when changes are made by calling insert()
- or clear() - it is only emitted when a value is updated from QML.
-
- \note It is not possible to remove keys from the map; once a key has been added, you can only
- modify or clear its associated value.
-*/
-
-/*!
- Constructs a bindable map with parent object \a parent.
-*/
-QmlPropertyMap::QmlPropertyMap(QObject *parent)
-: QObject(*(new QmlPropertyMapPrivate), parent)
-{
- Q_D(QmlPropertyMap);
- d->mo = new QmlPropertyMapMetaObject(this, d);
-}
-
-/*!
- Destroys the bindable map.
-*/
-QmlPropertyMap::~QmlPropertyMap()
-{
-}
-
-/*!
- Clears the value (if any) associated with \a key.
-*/
-void QmlPropertyMap::clear(const QString &key)
-{
- Q_D(QmlPropertyMap);
- d->mo->setValue(key.toUtf8(), QVariant());
-}
-
-/*!
- Returns the value associated with \a key.
-
- If no value has been set for this key (or if the value has been cleared),
- an invalid QVariant is returned.
-*/
-QVariant QmlPropertyMap::value(const QString &key) const
-{
- Q_D(const QmlPropertyMap);
- return d->mo->value(key.toUtf8());
-}
-
-/*!
- Sets the value associated with \a key to \a value.
-
- If the key doesn't exist, it is automatically created.
-*/
-void QmlPropertyMap::insert(const QString &key, const QVariant &value)
-{
- Q_D(QmlPropertyMap);
- if (!d->keys.contains(key))
- d->keys.append(key);
- d->mo->setValue(key.toUtf8(), value);
-}
-
-/*!
- Returns the list of keys.
-
- Keys that have been cleared will still appear in this list, even though their
- associated values are invalid QVariants.
-*/
-QStringList QmlPropertyMap::keys() const
-{
- Q_D(const QmlPropertyMap);
- return d->keys;
-}
-
-/*!
- \overload
-
- Same as size().
-*/
-int QmlPropertyMap::count() const
-{
- Q_D(const QmlPropertyMap);
- return d->keys.count();
-}
-
-/*!
- Returns the number of keys in the map.
-
- \sa isEmpty(), count()
-*/
-int QmlPropertyMap::size() const
-{
- Q_D(const QmlPropertyMap);
- return d->keys.size();
-}
-
-/*!
- Returns true if the map contains no keys; otherwise returns
- false.
-
- \sa size()
-*/
-bool QmlPropertyMap::isEmpty() const
-{
- Q_D(const QmlPropertyMap);
- return d->keys.isEmpty();
-}
-
-/*!
- Returns true if the map contains \a key.
-
- \sa size()
-*/
-bool QmlPropertyMap::contains(const QString &key) const
-{
- Q_D(const QmlPropertyMap);
- return d->keys.contains(key);
-}
-
-/*!
- Returns the value associated with the key \a key as a modifiable
- reference.
-
- If the map contains no item with key \a key, the function inserts
- an invalid QVariant into the map with key \a key, and
- returns a reference to it.
-
- \sa insert(), value()
-*/
-QVariant &QmlPropertyMap::operator[](const QString &key)
-{
- //### optimize
- Q_D(QmlPropertyMap);
- QByteArray utf8key = key.toUtf8();
- if (!d->keys.contains(key)) {
- d->keys.append(key);
- d->mo->setValue(utf8key, QVariant()); //force creation -- needed below
- }
-
- return (*(d->mo))[utf8key];
-}
-
-/*!
- \overload
-
- Same as value().
-*/
-const QVariant QmlPropertyMap::operator[](const QString &key) const
-{
- return value(key);
-}
-
-/*!
- \fn void QmlPropertyMap::valueChanged(const QString &key)
- This signal is emitted whenever one of the values in the map is changed. \a key
- is the key corresponding to the value that was changed.
-
- \note valueChanged() is \bold NOT emitted when changes are made by calling insert()
- or clear() - it is only emitted when a value is updated from QML.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlpropertymap.h b/src/declarative/util/qmlpropertymap.h
deleted file mode 100644
index a56ed0f26f..0000000000
--- a/src/declarative/util/qmlpropertymap.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 QMLPROPERTYMAP_H
-#define QMLPROPERTYMAP_H
-
-#include <QtCore/QObject>
-#include <QtCore/QHash>
-#include <QtCore/QStringList>
-#include <QtCore/QVariant>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlPropertyMapPrivate;
-class Q_DECLARATIVE_EXPORT QmlPropertyMap : public QObject
-{
- Q_OBJECT
-public:
- QmlPropertyMap(QObject *parent = 0);
- virtual ~QmlPropertyMap();
-
- QVariant value(const QString &key) const;
- void insert(const QString &key, const QVariant &value);
- void clear(const QString &key);
-
- Q_INVOKABLE QStringList keys() const;
-
- int count() const;
- int size() const;
- bool isEmpty() const;
- bool contains(const QString &key) const;
-
- QVariant &operator[](const QString &key);
- const QVariant operator[](const QString &key) const;
-
-Q_SIGNALS:
- void valueChanged(const QString &key);
-
-private:
- Q_DECLARE_PRIVATE(QmlPropertyMap)
- Q_DISABLE_COPY(QmlPropertyMap)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qmlspringfollow.cpp
deleted file mode 100644
index b180d1e823..0000000000
--- a/src/declarative/util/qmlspringfollow.cpp
+++ /dev/null
@@ -1,465 +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 "qmlspringfollow_p.h"
-
-#include "qmlanimation_p_p.h"
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-#include <limits.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,SpringFollow,QmlSpringFollow)
-
-class QmlSpringFollowPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlSpringFollow)
-public:
- QmlSpringFollowPrivate()
- : currentValue(0), sourceValue(0), maxVelocity(0), lastTime(0)
- , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01)
- , modulus(0.0), useMass(false), haveModulus(false), enabled(true), mode(Track), clock(this) {}
-
- QmlMetaProperty property;
- qreal currentValue;
- qreal sourceValue;
- qreal maxVelocity;
- qreal velocityms;
- int lastTime;
- qreal mass;
- qreal spring;
- qreal damping;
- qreal velocity;
- qreal epsilon;
- qreal modulus;
-
- bool useMass : 1;
- bool haveModulus : 1;
- bool enabled : 1;
-
- enum Mode {
- Track,
- Velocity,
- Spring
- };
- Mode mode;
-
- void tick(int);
- void updateMode();
- void start();
- void stop();
-
- QTickAnimationProxy<QmlSpringFollowPrivate, &QmlSpringFollowPrivate::tick> clock;
-};
-
-void QmlSpringFollowPrivate::tick(int time)
-{
- Q_Q(QmlSpringFollow);
-
- int elapsed = time - lastTime;
- if (!elapsed)
- return;
- qreal srcVal = sourceValue;
- if (haveModulus) {
- currentValue = fmod(currentValue, modulus);
- srcVal = fmod(srcVal, modulus);
- }
- if (mode == Spring) {
- if (elapsed < 16) // capped at 62fps.
- return;
- // Real men solve the spring DEs using RK4.
- // We'll do something much simpler which gives a result that looks fine.
- int count = elapsed / 16;
- for (int i = 0; i < count; ++i) {
- qreal diff = srcVal - currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (useMass)
- velocity = velocity + (spring * diff - damping * velocity) / mass;
- else
- velocity = velocity + spring * diff - damping * velocity;
- if (maxVelocity > 0.) {
- // limit velocity
- if (velocity > maxVelocity)
- velocity = maxVelocity;
- else if (velocity < -maxVelocity)
- velocity = -maxVelocity;
- }
- currentValue += velocity * 16.0 / 1000.0;
- if (haveModulus) {
- currentValue = fmod(currentValue, modulus);
- if (currentValue < 0.0)
- currentValue += modulus;
- }
- }
- if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) {
- velocity = 0.0;
- currentValue = srcVal;
- clock.stop();
- }
- lastTime = time - (elapsed - count * 16);
- } else {
- qreal moveBy = elapsed * velocityms;
- qreal diff = srcVal - currentValue;
- if (haveModulus && qAbs(diff) > modulus / 2) {
- if (diff < 0)
- diff += modulus;
- else
- diff -= modulus;
- }
- if (diff > 0) {
- currentValue += moveBy;
- if (haveModulus)
- currentValue = fmod(currentValue, modulus);
- if (currentValue > sourceValue) {
- currentValue = sourceValue;
- clock.stop();
- }
- } else {
- currentValue -= moveBy;
- if (haveModulus && currentValue < 0.0)
- currentValue = fmod(currentValue, modulus) + modulus;
- if (currentValue < sourceValue) {
- currentValue = sourceValue;
- clock.stop();
- }
- }
- lastTime = time;
- }
- property.write(currentValue);
- emit q->valueChanged(currentValue);
- if (clock.state() != QAbstractAnimation::Running)
- emit q->syncChanged();
-}
-
-void QmlSpringFollowPrivate::updateMode()
-{
- if (spring == 0. && maxVelocity == 0.)
- mode = Track;
- else if (spring > 0.)
- mode = Spring;
- else
- mode = Velocity;
-}
-
-void QmlSpringFollowPrivate::start()
-{
- if (!enabled)
- return;
-
- Q_Q(QmlSpringFollow);
- if (mode == QmlSpringFollowPrivate::Track) {
- currentValue = sourceValue;
- property.write(currentValue);
- } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
- lastTime = 0;
- currentValue = property.read().toReal();
- clock.start(); // infinity??
- emit q->syncChanged();
- }
-}
-
-void QmlSpringFollowPrivate::stop()
-{
- clock.stop();
-}
-
-/*!
- \qmlclass SpringFollow QmlSpringFollow
- \since 4.7
- \brief The SpringFollow element allows a property to track a value.
-
- In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200:
- \code
- Rectangle {
- id: rect1
- width: 20; height: 20
- color: "#00ff00"
- y: 200 //initial value
- y: SequentialAnimation {
- running: true
- repeat: true
- NumberAnimation {
- to: 200
- easing: "easeOutBounce(amplitude:100)"
- duration: 2000
- }
- PauseAnimation { duration: 1000 }
- }
- }
- Rectangle {
- id: rect2
- x: rect1.width
- width: 20; height: 20
- color: "#ff0000"
- y: SpringFollow { source: rect1.y; velocity: 200 }
- }
- \endcode
-
- \sa EaseFollow
-*/
-
-QmlSpringFollow::QmlSpringFollow(QObject *parent)
-: QObject(*(new QmlSpringFollowPrivate),parent)
-{
-}
-
-QmlSpringFollow::~QmlSpringFollow()
-{
-}
-
-void QmlSpringFollow::setTarget(const QmlMetaProperty &property)
-{
- Q_D(QmlSpringFollow);
- d->property = property;
- d->currentValue = property.read().toReal();
-}
-
-qreal QmlSpringFollow::sourceValue() const
-{
- Q_D(const QmlSpringFollow);
- return d->sourceValue;
-}
-
-/*!
- \qmlproperty qreal SpringFollow::source
- This property holds the source value which will be tracked.
-
- Bind to a property in order to track its changes.
-*/
-
-void QmlSpringFollow::setSourceValue(qreal value)
-{
- Q_D(QmlSpringFollow);
- if (d->clock.state() == QAbstractAnimation::Running && d->sourceValue == value)
- return;
-
- d->sourceValue = value;
- d->start();
-}
-
-/*!
- \qmlproperty qreal SpringFollow::velocity
- This property holds the maximum velocity allowed when tracking the source.
-*/
-
-qreal QmlSpringFollow::velocity() const
-{
- Q_D(const QmlSpringFollow);
- return d->maxVelocity;
-}
-
-void QmlSpringFollow::setVelocity(qreal velocity)
-{
- Q_D(QmlSpringFollow);
- d->maxVelocity = velocity;
- d->velocityms = velocity / 1000.0;
- d->updateMode();
-}
-
-/*!
- \qmlproperty qreal SpringFollow::spring
- This property holds the spring constant
-
- The spring constant describes how strongly the target is pulled towards the
- source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0
-
- When a spring constant is set and the velocity property is greater than 0,
- velocity limits the maximum speed.
-*/
-qreal QmlSpringFollow::spring() const
-{
- Q_D(const QmlSpringFollow);
- return d->spring;
-}
-
-void QmlSpringFollow::setSpring(qreal spring)
-{
- Q_D(QmlSpringFollow);
- d->spring = spring;
- d->updateMode();
-}
-
-/*!
- \qmlproperty qreal SpringFollow::damping
- This property holds the spring damping constant
-
- The damping constant describes how quickly a sprung follower comes to rest.
- Useful range is 0 - 1.0
-*/
-qreal QmlSpringFollow::damping() const
-{
- Q_D(const QmlSpringFollow);
- return d->damping;
-}
-
-void QmlSpringFollow::setDamping(qreal damping)
-{
- Q_D(QmlSpringFollow);
- if (damping > 1.)
- damping = 1.;
-
- d->damping = damping;
-}
-
-
-/*!
- \qmlproperty qreal SpringFollow::epsilon
- This property holds the spring epsilon
-
- The epsilon is the rate and amount of change in the value which is close enough
- to 0 to be considered equal to zero. This will depend on the usage of the value.
- For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
-
- The default is 0.01. Tuning this value can provide small performance improvements.
-*/
-qreal QmlSpringFollow::epsilon() const
-{
- Q_D(const QmlSpringFollow);
- return d->epsilon;
-}
-
-void QmlSpringFollow::setEpsilon(qreal epsilon)
-{
- Q_D(QmlSpringFollow);
- d->epsilon = epsilon;
-}
-
-/*!
- \qmlproperty qreal SpringFollow::modulus
- This property holds the modulus value.
-
- Setting a \a modulus forces the target value to "wrap around" at the modulus.
- For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
-*/
-qreal QmlSpringFollow::modulus() const
-{
- Q_D(const QmlSpringFollow);
- return d->modulus;
-}
-
-void QmlSpringFollow::setModulus(qreal modulus)
-{
- Q_D(QmlSpringFollow);
- if (d->modulus != modulus) {
- d->haveModulus = modulus != 0.0;
- d->modulus = modulus;
- emit modulusChanged();
- }
-}
-
-/*!
- \qmlproperty qreal SpringFollow::mass
- This property holds the "mass" of the property being moved.
-
- mass is 1.0 by default. Setting a different mass changes the dynamics of
- a \l spring follow.
-*/
-qreal QmlSpringFollow::mass() const
-{
- Q_D(const QmlSpringFollow);
- return d->mass;
-}
-
-void QmlSpringFollow::setMass(qreal mass)
-{
- Q_D(QmlSpringFollow);
- if (d->mass != mass && mass > 0.0) {
- d->useMass = mass != 1.0;
- d->mass = mass;
- emit massChanged();
- }
-}
-
-/*!
- \qmlproperty qreal SpringFollow::value
- The current value.
-*/
-
-/*!
- \qmlproperty bool SpringFollow::enabled
- This property holds whether the target will track the source.
-*/
-bool QmlSpringFollow::enabled() const
-{
- Q_D(const QmlSpringFollow);
- return d->enabled;
-}
-
-void QmlSpringFollow::setEnabled(bool enabled)
-{
- Q_D(QmlSpringFollow);
- d->enabled = enabled;
- if (enabled)
- d->start();
- else
- d->stop();
-}
-
-/*!
- \qmlproperty bool SpringFollow::inSync
- This property is true when target is equal to the source; otherwise
- false. If inSync is true the target is not being animated.
-
- If \l enabled is false then inSync will also be false.
-*/
-bool QmlSpringFollow::inSync() const
-{
- Q_D(const QmlSpringFollow);
- return d->enabled && d->clock.state() != QAbstractAnimation::Running;
-}
-
-qreal QmlSpringFollow::value() const
-{
- Q_D(const QmlSpringFollow);
- return d->currentValue;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlspringfollow_p.h b/src/declarative/util/qmlspringfollow_p.h
deleted file mode 100644
index 4a0ed1ce2b..0000000000
--- a/src/declarative/util/qmlspringfollow_p.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 QMLSMOOTHFOLLOW_H
-#define QMLSMOOTHFOLLOW_H
-
-#include <qmlpropertyvaluesource.h>
-#include <qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlSpringFollowPrivate;
-class Q_DECLARATIVE_EXPORT QmlSpringFollow : public QObject,
- public QmlPropertyValueSource
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlSpringFollow)
- Q_INTERFACES(QmlPropertyValueSource)
-
- Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal spring READ spring WRITE setSpring)
- Q_PROPERTY(qreal damping READ damping WRITE setDamping)
- Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(qreal value READ value NOTIFY valueChanged)
- Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
- Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
- Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged)
-
-public:
- QmlSpringFollow(QObject *parent=0);
- ~QmlSpringFollow();
-
- virtual void setTarget(const QmlMetaProperty &);
-
- qreal sourceValue() const;
- void setSourceValue(qreal value);
- qreal velocity() const;
- void setVelocity(qreal velocity);
- qreal spring() const;
- void setSpring(qreal spring);
- qreal damping() const;
- void setDamping(qreal damping);
- qreal epsilon() const;
- void setEpsilon(qreal epsilon);
- qreal mass() const;
- void setMass(qreal modulus);
- qreal modulus() const;
- void setModulus(qreal modulus);
- bool enabled() const;
- void setEnabled(bool enabled);
- bool inSync() const;
-
- qreal value() const;
-
-Q_SIGNALS:
- void valueChanged(qreal);
- void modulusChanged();
- void massChanged();
- void syncChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlSpringFollow)
-
-QT_END_HEADER
-
-#endif // QMLSMOOTHFOLLOW_H
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
deleted file mode 100644
index c743e0b744..0000000000
--- a/src/declarative/util/qmlstate.cpp
+++ /dev/null
@@ -1,483 +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 "qmlstate_p_p.h"
-#include "qmlstate_p.h"
-
-#include "qmltransition_p.h"
-#include "qmlstategroup_p.h"
-#include "qmlstateoperations_p.h"
-#include "qmlanimation_p.h"
-#include "qmlanimation_p_p.h"
-
-#include <qmlbinding.h>
-#include <qmlglobal_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-QmlAction::QmlAction()
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), toBinding(0), event(0),
- specifiedObject(0)
-{
-}
-
-QmlAction::QmlAction(QObject *target, const QString &propertyName,
- const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), toValue(value), fromBinding(0),
- toBinding(0), event(0), specifiedObject(target),
- specifiedProperty(propertyName)
-{
- property = QmlMetaProperty::createProperty(target, propertyName);
- if (property.isValid())
- fromValue = property.read();
-}
-
-QmlActionEvent::~QmlActionEvent()
-{
-}
-
-QString QmlActionEvent::typeName() const
-{
- return QString();
-}
-
-void QmlActionEvent::execute()
-{
-}
-
-bool QmlActionEvent::isReversable()
-{
- return false;
-}
-
-void QmlActionEvent::reverse()
-{
-}
-
-QList<QmlAction> QmlActionEvent::extraActions()
-{
- return QList<QmlAction>();
-}
-
-bool QmlActionEvent::changesBindings()
-{
- return false;
-}
-
-void QmlActionEvent::clearForwardBindings()
-{
-}
-
-void QmlActionEvent::clearReverseBindings()
-{
-}
-
-bool QmlActionEvent::override(QmlActionEvent *other)
-{
- Q_UNUSED(other);
- return false;
-}
-
-/*!
- \internal
-*/
-QmlStateOperation::QmlStateOperation(QObjectPrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
- \qmlclass State QmlState
- \since 4.7
- \brief The State element defines configurations of objects and properties.
-
- A state is specified as a set of batched changes from the default configuration.
-
- Note that setting the state of an object from within another state of the same object is
- inadvisible. Not only would this have the same effect as going directly to the second state
- it may cause the program to crash.
-
- \sa {qmlstates}{States}, {state-transitions}{Transitions}
-*/
-
-/*!
- \internal
- \class QmlState
- \brief The QmlState class allows you to define configurations of objects and properties.
-
- \ingroup group_states
-
- QmlState allows you to specify a state as a set of batched changes from the default
- configuration.
-
- \sa {states-transitions}{States and Transitions}
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,State,QmlState)
-QmlState::QmlState(QObject *parent)
-: QObject(*(new QmlStatePrivate), parent)
-{
- Q_D(QmlState);
- d->transitionManager.setState(this);
-}
-
-QmlState::~QmlState()
-{
- Q_D(QmlState);
- if (d->group)
- d->group->removeState(this);
-}
-
-/*!
- \qmlproperty string State::name
- This property holds the name of the state
-
- Each state should have a unique name.
-*/
-QString QmlState::name() const
-{
- Q_D(const QmlState);
- return d->name;
-}
-
-void QmlState::setName(const QString &n)
-{
- Q_D(QmlState);
- d->name = n;
-}
-
-bool QmlState::isWhenKnown() const
-{
- Q_D(const QmlState);
- return d->when != 0;
-}
-
-/*!
- \qmlproperty bool State::when
- This property holds when the state should be applied
-
- This should be set to an expression that evaluates to true when you want the state to
- be applied.
-*/
-QmlBinding *QmlState::when() const
-{
- Q_D(const QmlState);
- return d->when;
-}
-
-void QmlState::setWhen(QmlBinding *when)
-{
- Q_D(QmlState);
- d->when = when;
- if (d->group)
- d->group->updateAutoState();
-}
-
-/*!
- \qmlproperty string State::extend
- This property holds the state that this state extends
-
- The state being extended is treated as the base state in regards to
- the changes specified by the extending state.
-*/
-QString QmlState::extends() const
-{
- Q_D(const QmlState);
- return d->extends;
-}
-
-void QmlState::setExtends(const QString &extends)
-{
- Q_D(QmlState);
- d->extends = extends;
-}
-
-/*!
- \qmlproperty list<Change> State::changes
- This property holds the changes to apply for this state
- \default
-
- By default these changes are applied against the default state. If the state
- extends another state, then the changes are applied against the state being
- extended.
-*/
-QmlListProperty<QmlStateOperation> QmlState::changes()
-{
- Q_D(QmlState);
- return QmlListProperty<QmlStateOperation>(this, &d->operations, QmlStatePrivate::operations_append,
- QmlStatePrivate::operations_count, QmlStatePrivate::operations_at,
- QmlStatePrivate::operations_clear);
-}
-
-int QmlState::operationCount() const
-{
- Q_D(const QmlState);
- return d->operations.count();
-}
-
-QmlStateOperation *QmlState::operationAt(int index) const
-{
- Q_D(const QmlState);
- return d->operations.at(index);
-}
-
-QmlState &QmlState::operator<<(QmlStateOperation *op)
-{
- Q_D(QmlState);
- d->operations.append(QmlStatePrivate::OperationGuard(op, &d->operations));
- return *this;
-}
-
-void QmlStatePrivate::complete()
-{
- Q_Q(QmlState);
-
- for (int ii = 0; ii < reverting.count(); ++ii) {
- for (int jj = 0; jj < revertList.count(); ++jj) {
- if (revertList.at(jj).property == reverting.at(ii)) {
- revertList.removeAt(jj);
- break;
- }
- }
- }
- reverting.clear();
-
- emit q->completed();
-}
-
-// Generate a list of actions for this state. This includes coelescing state
-// actions that this state "extends"
-QmlStateOperation::ActionList
-QmlStatePrivate::generateActionList(QmlStateGroup *group) const
-{
- QmlStateOperation::ActionList applyList;
- if (inState)
- return applyList;
-
- // Prevent "extends" recursion
- inState = true;
-
- if (!extends.isEmpty()) {
- QList<QmlState *> states = group->states();
- for (int ii = 0; ii < states.count(); ++ii)
- if (states.at(ii)->name() == extends)
- applyList = static_cast<QmlStatePrivate*>(states.at(ii)->d_func())->generateActionList(group);
- }
-
- foreach(QmlStateOperation *op, operations)
- applyList << op->actions();
-
- inState = false;
- return applyList;
-}
-
-QmlStateGroup *QmlState::stateGroup() const
-{
- Q_D(const QmlState);
- return d->group;
-}
-
-void QmlState::setStateGroup(QmlStateGroup *group)
-{
- Q_D(QmlState);
- d->group = group;
-}
-
-void QmlState::cancel()
-{
- Q_D(QmlState);
- d->transitionManager.cancel();
-}
-
-void QmlAction::deleteFromBinding()
-{
- if (fromBinding) {
- property.setBinding(0);
- fromBinding->destroy();
- fromBinding = 0;
- }
-}
-
-void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *revert)
-{
- Q_D(QmlState);
-
- qmlExecuteDeferred(this);
-
- cancel();
- if (revert)
- revert->cancel();
- d->revertList.clear();
- d->reverting.clear();
-
- if (revert) {
- QmlStatePrivate *revertPrivate =
- static_cast<QmlStatePrivate*>(revert->d_func());
- d->revertList = revertPrivate->revertList;
- revertPrivate->revertList.clear();
- }
-
- // List of actions caused by this state
- QmlStateOperation::ActionList applyList = d->generateActionList(group);
-
- // List of actions that need to be reverted to roll back (just) this state
- QmlStatePrivate::SimpleActionList additionalReverts;
- // First add the reverse of all the applyList actions
- for (int ii = 0; ii < applyList.count(); ++ii) {
- QmlAction &action = applyList[ii];
-
- bool found = false;
-
- int jj;
- if (action.event) {
- if (!action.event->isReversable())
- continue;
- for (jj = 0; jj < d->revertList.count(); ++jj) {
- QmlActionEvent *event = d->revertList.at(jj).event;
- if (event && event->typeName() == action.event->typeName()) {
- if (action.event->override(event)) {
- found = true;
- break;
- }
- }
- }
- if (!found || action.event != d->revertList.at(jj).event)
- action.event->saveOriginals();
- else if (action.event->isRewindable())
- action.event->saveCurrentValues();
- } else {
- action.fromBinding = action.property.binding();
-
- for (jj = 0; jj < d->revertList.count(); ++jj) {
- if (d->revertList.at(jj).property == action.property) {
- found = true;
- break;
- }
- }
- }
-
- if (!found) {
- if (!action.restore) {
- action.deleteFromBinding();
- } else {
- // Only need to revert the applyList action if the previous
- // state doesn't have a higher priority revert already
- QmlSimpleAction r(action);
- additionalReverts << r;
- }
- } else if (d->revertList.at(jj).binding != action.fromBinding) {
- action.deleteFromBinding();
- }
- }
-
- // Any reverts from a previous state that aren't carried forth
- // into this state need to be translated into apply actions
- for (int ii = 0; ii < d->revertList.count(); ++ii) {
- bool found = false;
- if (d->revertList.at(ii).event) {
- QmlActionEvent *event = d->revertList.at(ii).event;
- if (!event->isReversable())
- continue;
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
- const QmlAction &action = applyList.at(jj);
- if (action.event && action.event->typeName() == event->typeName()) {
- if (action.event->override(event))
- found = true;
- }
- }
- } else {
- for (int jj = 0; !found && jj < applyList.count(); ++jj) {
- const QmlAction &action = applyList.at(jj);
- if (action.property == d->revertList.at(ii).property)
- found = true;
- }
- }
- if (!found) {
- QVariant cur = d->revertList.at(ii).property.read();
- QmlAbstractBinding *delBinding = d->revertList.at(ii).property.setBinding(0);
- if (delBinding)
- delBinding->destroy();
-
- QmlAction a;
- a.property = d->revertList.at(ii).property;
- a.fromValue = cur;
- a.toValue = d->revertList.at(ii).value;
- a.toBinding = d->revertList.at(ii).binding;
- a.specifiedObject = d->revertList.at(ii).specifiedObject;
- a.specifiedProperty = d->revertList.at(ii).specifiedProperty;
- a.event = d->revertList.at(ii).event;
- a.reverseEvent = d->revertList.at(ii).reverseEvent;
- if (a.event && a.event->isRewindable())
- a.event->saveCurrentValues();
- applyList << a;
- // Store these special reverts in the reverting list
- d->reverting << d->revertList.at(ii).property;
- }
- }
- // All the local reverts now become part of the ongoing revertList
- d->revertList << additionalReverts;
-
- // Output for debugging
- if (stateChangeDebug()) {
- foreach(const QmlAction &action, applyList) {
- if (action.event)
- qWarning() << " QmlAction event:" << action.event->typeName();
- else
- qWarning() << " QmlAction:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
- }
- }
-
- d->transitionManager.transition(applyList, trans);
-}
-
-QML_DEFINE_NOCREATE_TYPE(QmlStateOperation)
-QmlStateOperation::ActionList QmlStateOperation::actions()
-{
- return ActionList();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h
deleted file mode 100644
index 2c9238717e..0000000000
--- a/src/declarative/util/qmlstate_p.h
+++ /dev/null
@@ -1,181 +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 QMLSTATE_H
-#define QMLSTATE_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlActionEvent;
-class QmlBinding;
-class Q_DECLARATIVE_EXPORT QmlAction
-{
-public:
- QmlAction();
- QmlAction(QObject *, const QString &, const QVariant &);
-
- bool restore:1;
- bool actionDone:1;
- bool reverseEvent:1;
- bool deletableToBinding:1;
-
- QmlMetaProperty property;
- QVariant fromValue;
- QVariant toValue;
-
- QmlAbstractBinding *fromBinding;
- QmlAbstractBinding *toBinding;
- QmlActionEvent *event;
-
- //strictly for matching
- QObject *specifiedObject;
- QString specifiedProperty;
-
- void deleteFromBinding();
-};
-
-class QmlActionEvent
-{
-public:
- virtual ~QmlActionEvent();
- virtual QString typeName() const;
-
- virtual void execute();
- virtual bool isReversable();
- virtual void reverse();
- virtual void saveOriginals() {}
-
- virtual bool isRewindable() { return isReversable(); }
- virtual void rewind() {}
- virtual void saveCurrentValues() {}
-
- //virtual bool hasExtraActions();
- virtual QList<QmlAction> extraActions();
-
- virtual bool changesBindings();
- virtual void clearForwardBindings();
- virtual void clearReverseBindings();
- virtual bool override(QmlActionEvent*other);
-};
-
-//### rename to QmlStateChange?
-class QmlStateGroup;
-class Q_DECLARATIVE_EXPORT QmlStateOperation : public QObject
-{
- Q_OBJECT
-public:
- QmlStateOperation(QObject *parent = 0)
- : QObject(parent) {}
- typedef QList<QmlAction> ActionList;
-
- virtual ActionList actions();
-
-protected:
- QmlStateOperation(QObjectPrivate &dd, QObject *parent = 0);
-};
-
-typedef QmlStateOperation::ActionList QmlStateActions;
-
-class QmlTransition;
-class QmlStatePrivate;
-class Q_DECLARATIVE_EXPORT QmlState : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QmlBinding *when READ when WRITE setWhen)
- Q_PROPERTY(QString extend READ extends WRITE setExtends)
- Q_PROPERTY(QmlListProperty<QmlStateOperation> changes READ changes)
- Q_CLASSINFO("DefaultProperty", "changes")
- Q_CLASSINFO("DeferredPropertyNames", "changes")
-
-public:
- QmlState(QObject *parent=0);
- virtual ~QmlState();
-
- QString name() const;
- void setName(const QString &);
-
- /*'when' is a QmlBinding to limit state changes oscillation
- due to the unpredictable order of evaluation of bound expressions*/
- bool isWhenKnown() const;
- QmlBinding *when() const;
- void setWhen(QmlBinding *);
-
- QString extends() const;
- void setExtends(const QString &);
-
- QmlListProperty<QmlStateOperation> changes();
- int operationCount() const;
- QmlStateOperation *operationAt(int) const;
-
- QmlState &operator<<(QmlStateOperation *);
-
- void apply(QmlStateGroup *, QmlTransition *, QmlState *revert);
- void cancel();
-
- QmlStateGroup *stateGroup() const;
- void setStateGroup(QmlStateGroup *);
-
-Q_SIGNALS:
- void completed();
-
-private:
- Q_DECLARE_PRIVATE(QmlState)
- Q_DISABLE_COPY(QmlState)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlStateOperation)
-QML_DECLARE_TYPE(QmlState)
-
-QT_END_HEADER
-
-#endif // QMLSTATE_H
diff --git a/src/declarative/util/qmlstate_p_p.h b/src/declarative/util/qmlstate_p_p.h
deleted file mode 100644
index d138e4e106..0000000000
--- a/src/declarative/util/qmlstate_p_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 QMLSTATE_P_H
-#define QMLSTATE_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 "qmlstate_p.h"
-
-#include "qmlanimation_p_p.h"
-#include "qmltransitionmanager_p_p.h"
-
-#include <qmlguard_p.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlSimpleAction
-{
-public:
- enum State { StartState, EndState };
- QmlSimpleAction(const QmlAction &a, State state = StartState)
- {
- property = a.property;
- specifiedObject = a.specifiedObject;
- specifiedProperty = a.specifiedProperty;
- event = a.event;
- if (state == StartState) {
- value = a.fromValue;
- binding = property.binding();
- reverseEvent = true;
- } else {
- value = a.toValue;
- binding = a.toBinding;
- reverseEvent = false;
- }
- }
-
- QmlMetaProperty property;
- QVariant value;
- QmlAbstractBinding *binding;
- QObject *specifiedObject;
- QString specifiedProperty;
- QmlActionEvent *event;
- bool reverseEvent;
-};
-
-class QmlStatePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlState)
-
-public:
- QmlStatePrivate()
- : when(0), inState(false), group(0) {}
-
- typedef QList<QmlSimpleAction> SimpleActionList;
-
- QString name;
- QmlBinding *when;
-
- struct OperationGuard : public QmlGuard<QmlStateOperation>
- {
- OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { (QmlGuard<QObject>&)*this = obj; }
- QList<OperationGuard> *list;
- void objectDestroyed(QmlStateOperation *) {
- // we assume priv will always be destroyed after objectDestroyed calls
- list->removeOne(*this);
- }
- };
- QList<OperationGuard> operations;
-
- static void operations_append(QmlListProperty<QmlStateOperation> *prop, QmlStateOperation *op) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- list->append(OperationGuard(op, list));
- }
- static void operations_clear(QmlListProperty<QmlStateOperation> *prop) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- list->clear();
- }
- static int operations_count(QmlListProperty<QmlStateOperation> *prop) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->count();
- }
- static QmlStateOperation *operations_at(QmlListProperty<QmlStateOperation> *prop, int index) {
- QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
- return list->at(index);
- }
-
- QmlTransitionManager transitionManager;
-
- SimpleActionList revertList;
- QList<QmlMetaProperty> reverting;
- QString extends;
- mutable bool inState;
- QmlStateGroup *group;
-
- QmlStateOperation::ActionList generateActionList(QmlStateGroup *) const;
- void complete();
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLSTATE_P_H
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
deleted file mode 100644
index 7e6dc58c17..0000000000
--- a/src/declarative/util/qmlstategroup.cpp
+++ /dev/null
@@ -1,441 +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 "qmlstategroup_p.h"
-
-#include "qmltransition_p.h"
-#include "qmlstate_p_p.h"
-
-#include <qmlbinding.h>
-#include <qmlglobal_p.h>
-
-#include <QtCore/qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-class QmlStateGroupPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlStateGroup)
-public:
- QmlStateGroupPrivate(QmlStateGroup *p)
- : nullState(0), componentComplete(true),
- ignoreTrans(false), applyingState(false) {}
-
- QString currentState;
- QmlState *nullState;
-
- static void append_state(QmlListProperty<QmlState> *list, QmlState *state);
- static int count_state(QmlListProperty<QmlState> *list);
- static QmlState *at_state(QmlListProperty<QmlState> *list, int index);
-
- QList<QmlState *> states;
- QList<QmlTransition *> transitions;
-
- bool componentComplete;
- bool ignoreTrans;
- bool applyingState;
-
- QmlTransition *findTransition(const QString &from, const QString &to);
- void setCurrentStateInternal(const QString &state, bool = false);
- bool updateAutoState();
-};
-
-/*!
- \qmlclass StateGroup QmlStateGroup
- \since 4.7
- \brief The StateGroup element provides state support for non-Item elements.
-
- Item (and all dervied elements) provides built in support for states and transitions
- via its state, states and transitions properties. StateGroup provides an easy way to
- use this support in other (non-Item-derived) elements.
-
- \qml
- MyCustomObject {
- StateGroup {
- id: myStateGroup
- states: State {
- name: "state1"
- ...
- }
- transitions: Transition {
- ...
- }
- }
-
- onSomethingHappened: myStateGroup.state = "state1";
- }
- \endqml
-
- \sa {qmlstate}{States} {state-transitions}{Transitions}
-*/
-
-QmlStateGroup::QmlStateGroup(QObject *parent)
- : QObject(*(new QmlStateGroupPrivate(this)), parent)
-{
-}
-
-QmlStateGroup::~QmlStateGroup()
-{
- Q_D(const QmlStateGroup);
- for (int i = 0; i < d->states.count(); ++i)
- d->states.at(i)->setStateGroup(0);
-}
-
-QList<QmlState *> QmlStateGroup::states() const
-{
- Q_D(const QmlStateGroup);
- return d->states;
-}
-
-/*!
- \qmlproperty list<State> StateGroup::states
- This property holds a list of states defined by the state group.
-
- \qml
- StateGroup {
- states: [
- State { ... },
- State { ... }
- ...
- ]
- }
- \endqml
-
- \sa {qmlstate}{States}
-*/
-QmlListProperty<QmlState> QmlStateGroup::statesProperty()
-{
- Q_D(QmlStateGroup);
- return QmlListProperty<QmlState>(this, &d->states, &QmlStateGroupPrivate::append_state,
- &QmlStateGroupPrivate::count_state,
- &QmlStateGroupPrivate::at_state);
-}
-
-void QmlStateGroupPrivate::append_state(QmlListProperty<QmlState> *list, QmlState *state)
-{
- QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
- if (state) {
- _this->d_func()->states.append(state);
- state->setStateGroup(_this);
- }
-
-}
-
-int QmlStateGroupPrivate::count_state(QmlListProperty<QmlState> *list)
-{
- QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
- return _this->d_func()->states.count();
-}
-
-QmlState *QmlStateGroupPrivate::at_state(QmlListProperty<QmlState> *list, int index)
-{
- QmlStateGroup *_this = static_cast<QmlStateGroup *>(list->object);
- return _this->d_func()->states.at(index);
-}
-
-/*!
- \qmlproperty list<Transition> StateGroup::transitions
- This property holds a list of transitions defined by the state group.
-
- \qml
- StateGroup {
- transitions: [
- Transition { ... },
- Transition { ... }
- ...
- ]
- }
- \endqml
-
- \sa {state-transitions}{Transitions}
-*/
-QmlListProperty<QmlTransition> QmlStateGroup::transitionsProperty()
-{
- Q_D(QmlStateGroup);
- return QmlListProperty<QmlTransition>(this, d->transitions);
-}
-
-/*!
- \qmlproperty string StateGroup::state
-
- This property holds the name of the current state of the state group.
-
- 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 state group is in its base state (i.e. no explicit state has been
- set), \c state will be a blank string. Likewise, you can return a
- state group to its base state by setting its current state to \c ''.
-
- \sa {qmlstates}{States}
-*/
-QString QmlStateGroup::state() const
-{
- Q_D(const QmlStateGroup);
- return d->currentState;
-}
-
-void QmlStateGroup::setState(const QString &state)
-{
- Q_D(QmlStateGroup);
- if (d->currentState == state)
- return;
-
- d->setCurrentStateInternal(state);
-}
-
-void QmlStateGroup::classBegin()
-{
- Q_D(QmlStateGroup);
- d->componentComplete = false;
-}
-
-void QmlStateGroup::componentComplete()
-{
- Q_D(QmlStateGroup);
- d->componentComplete = true;
-
- if (d->updateAutoState()) {
- return;
- } else if (!d->currentState.isEmpty()) {
- QString cs = d->currentState;
- d->currentState = QString();
- d->setCurrentStateInternal(cs, true);
- }
-}
-
-/*!
- Returns true if the state was changed, otherwise false.
-*/
-bool QmlStateGroup::updateAutoState()
-{
- Q_D(QmlStateGroup);
- return d->updateAutoState();
-}
-
-bool QmlStateGroupPrivate::updateAutoState()
-{
- Q_Q(QmlStateGroup);
- if (!componentComplete)
- return false;
-
- bool revert = false;
- for (int ii = 0; ii < states.count(); ++ii) {
- QmlState *state = states.at(ii);
- if (state->isWhenKnown()) {
- if (!state->name().isEmpty()) {
- if (state->when() && state->when()->value().toBool()) {
- if (stateChangeDebug())
- qWarning() << "Setting auto state due to:"
- << state->when()->expression();
- if (currentState != state->name()) {
- q->setState(state->name());
- return true;
- } else {
- return false;
- }
- } else if (state->name() == currentState) {
- revert = true;
- }
- }
- }
- }
- if (revert) {
- bool rv = currentState != QString();
- q->setState(QString());
- return rv;
- } else {
- return false;
- }
-}
-
-QmlTransition *QmlStateGroupPrivate::findTransition(const QString &from, const QString &to)
-{
- QmlTransition *highest = 0;
- int score = 0;
- bool reversed = false;
- bool done = false;
-
- for (int ii = 0; !done && ii < transitions.count(); ++ii) {
- QmlTransition *t = transitions.at(ii);
- for (int ii = 0; ii < 2; ++ii)
- {
- if (ii && (!t->reversible() ||
- (t->fromState() == QLatin1String("*") &&
- t->toState() == QLatin1String("*"))))
- break;
- QStringList fromState;
- QStringList toState;
-
- fromState = t->fromState().split(QLatin1Char(','));
- toState = t->toState().split(QLatin1Char(','));
- if (ii == 1)
- qSwap(fromState, toState);
- int tScore = 0;
- if (fromState.contains(from))
- tScore += 2;
- else if (fromState.contains(QLatin1String("*")))
- tScore += 1;
- else
- continue;
-
- if (toState.contains(to))
- tScore += 2;
- else if (toState.contains(QLatin1String("*")))
- tScore += 1;
- else
- continue;
-
- if (ii == 1)
- reversed = true;
- else
- reversed = false;
-
- if (tScore == 4) {
- highest = t;
- done = true;
- break;
- } else if (tScore > score) {
- score = tScore;
- highest = t;
- }
- }
- }
-
- if (highest)
- highest->setReversed(reversed);
-
- return highest;
-}
-
-void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state,
- bool ignoreTrans)
-{
- Q_Q(QmlStateGroup);
- if (!componentComplete) {
- currentState = state;
- return;
- }
-
- if (applyingState) {
- qWarning() << "Can't apply a state change as part of a state definition.";
- return;
- }
-
- applyingState = true;
-
- QmlTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state);
- if (stateChangeDebug()) {
- qWarning() << this << "Changing state. From" << currentState << ". To" << state;
- if (transition)
- qWarning() << " using transition" << transition->fromState()
- << transition->toState();
- }
-
- QmlState *oldState = 0;
- if (!currentState.isEmpty()) {
- for (int ii = 0; ii < states.count(); ++ii) {
- if (states.at(ii)->name() == currentState) {
- oldState = states.at(ii);
- break;
- }
- }
- }
-
- currentState = state;
- emit q->stateChanged(currentState);
-
- QmlState *newState = 0;
- for (int ii = 0; ii < states.count(); ++ii) {
- if (states.at(ii)->name() == currentState) {
- newState = states.at(ii);
- break;
- }
- }
-
- if (oldState == 0 || newState == 0) {
- if (!nullState) { nullState = new QmlState; QmlGraphics_setParent_noEvent(nullState, q); }
- if (!oldState) oldState = nullState;
- if (!newState) newState = nullState;
- }
-
- newState->apply(q, transition, oldState);
- applyingState = false;
- if (!transition)
- static_cast<QmlStatePrivate*>(QObjectPrivate::get(newState))->complete();
-}
-
-QmlState *QmlStateGroup::findState(const QString &name) const
-{
- Q_D(const QmlStateGroup);
- for (int i = 0; i < d->states.count(); ++i) {
- QmlState *state = d->states.at(i);
- if (state->name() == name)
- return state;
- }
-
- return 0;
-}
-
-void QmlStateGroup::removeState(QmlState *state)
-{
- Q_D(QmlStateGroup);
- d->states.removeOne(state);
-}
-
-QT_END_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup)
diff --git a/src/declarative/util/qmlstategroup_p.h b/src/declarative/util/qmlstategroup_p.h
deleted file mode 100644
index d39ca03672..0000000000
--- a/src/declarative/util/qmlstategroup_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 QMLSTATEGROUP_H
-#define QMLSTATEGROUP_H
-
-#include "qmlstate_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlStateGroupPrivate;
-class Q_DECLARATIVE_EXPORT QmlStateGroup : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
- Q_DECLARE_PRIVATE(QmlStateGroup)
-
- Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QmlListProperty<QmlState> states READ statesProperty DESIGNABLE false)
- Q_PROPERTY(QmlListProperty<QmlTransition> transitions READ transitionsProperty DESIGNABLE false)
-
-public:
- QmlStateGroup(QObject * = 0);
- virtual ~QmlStateGroup();
-
- QString state() const;
- void setState(const QString &);
-
- QmlListProperty<QmlState> statesProperty();
- QList<QmlState *> states() const;
-
- QmlListProperty<QmlTransition> transitionsProperty();
-
- QmlState *findState(const QString &name) const;
-
- virtual void classBegin();
- virtual void componentComplete();
-Q_SIGNALS:
- void stateChanged(const QString &);
-
-private:
- friend class QmlState;
- bool updateAutoState();
- void removeState(QmlState *state);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlStateGroup)
-
-QT_END_HEADER
-
-#endif // QMLSTATEGROUP_H
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
deleted file mode 100644
index 5f06045068..0000000000
--- a/src/declarative/util/qmlstateoperations.cpp
+++ /dev/null
@@ -1,837 +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 "qmlstateoperations_p.h"
-
-#include <qml.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-#include <qmlinfo.h>
-#include <qmlgraphicsanchors_p_p.h>
-#include <qmlgraphicsitem_p.h>
-#include <qmlguard_p.h>
-
-#include <QtCore/qdebug.h>
-#include <QtGui/qgraphicsitem.h>
-#include <QtCore/qmath.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlParentChangePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlParentChange)
-public:
- QmlParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0),
- rewindParent(0), rewindStackBefore(0) {}
-
- QmlGraphicsItem *target;
- QmlGraphicsItem *parent;
- QmlGuard<QmlGraphicsItem> origParent;
- QmlGuard<QmlGraphicsItem> origStackBefore;
- QmlGraphicsItem *rewindParent;
- QmlGraphicsItem *rewindStackBefore;
-
- void doChange(QmlGraphicsItem *targetParent, QmlGraphicsItem *stackBefore = 0);
-};
-
-void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphicsItem *stackBefore)
-{
- if (targetParent && target && target->parentItem()) {
- //### for backwards direction, can we just restore original x, y, scale, rotation
- Q_Q(QmlParentChange);
- bool ok;
- const QTransform &transform = target->itemTransform(targetParent, &ok);
- if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under complex transform");
- ok = false;
- }
-
- qreal scale = 1;
- qreal rotation = 0;
- if (ok && transform.type() != QTransform::TxRotate) {
- if (transform.m11() == transform.m22())
- scale = transform.m11();
- else {
- qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
- } else if (ok && transform.type() == QTransform::TxRotate) {
- if (transform.m11() == transform.m22())
- scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
- else {
- qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under non-uniform scale");
- ok = false;
- }
-
- if (scale != 0)
- rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
- else {
- qmlInfo(q) << QmlParentChange::tr("Unable to preserve appearance under scale of 0");
- ok = false;
- }
- }
-
- qreal xt = transform.dx();
- qreal yt = transform.dy();
- if (ok && target->transformOrigin() != QmlGraphicsItem::TopLeft) {
- qreal tempxt = target->transformOriginPoint().x();
- qreal tempyt = target->transformOriginPoint().y();
- QTransform t;
- t.translate(-tempxt, -tempyt);
- t.rotate(rotation);
- t.scale(scale, scale);
- t.translate(tempxt, tempyt);
- QPointF offset = t.map(QPointF(0,0));
- xt += offset.x();
- yt += offset.y();
- }
-
- target->setParentItem(targetParent);
- if (ok) {
- //qDebug() << xt << yt << rotation << scale;
- target->setX(xt);
- target->setY(yt);
- target->setRotation(rotation);
- target->setScale(scale);
- }
- } else if (target) {
- target->setParentItem(targetParent);
- }
-
- //restore the original stack position.
- //### if stackBefore has also been reparented this won't work
- if (stackBefore)
- target->stackBefore(stackBefore);
-}
-
-/*!
- \preliminary
- \qmlclass ParentChange QmlParentChange
- \since 4.7
- \brief The ParentChange element allows you to reparent an Item in a state change.
-
- ParentChange reparents an Item while preserving its visual appearance (position, rotation,
- and scale) on screen. You can then specify a transition to move/rotate/scale the Item to
- its final intended appearance.
-
- ParentChange can only preserve visual appearance if no complex transforms are involved.
- More specifically, it will not work if the transform property has been set for any
- Items involved in the reparenting (defined as any Items in the common ancestor tree
- for the original and new parent).
-
- You can specify at which point in a transition you want a ParentChange to occur by
- using a ParentAction.
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,ParentChange,QmlParentChange)
-QmlParentChange::QmlParentChange(QObject *parent)
- : QmlStateOperation(*(new QmlParentChangePrivate), parent)
-{
-}
-
-QmlParentChange::~QmlParentChange()
-{
-}
-
-/*!
- \qmlproperty Item ParentChange::target
- This property holds the item to be reparented
-*/
-
-QmlGraphicsItem *QmlParentChange::object() const
-{
- Q_D(const QmlParentChange);
- return d->target;
-}
-
-void QmlParentChange::setObject(QmlGraphicsItem *target)
-{
- Q_D(QmlParentChange);
- d->target = target;
-}
-
-/*!
- \qmlproperty Item ParentChange::parent
- This property holds the parent for the item in this state
-*/
-
-QmlGraphicsItem *QmlParentChange::parent() const
-{
- Q_D(const QmlParentChange);
- return d->parent;
-}
-
-void QmlParentChange::setParent(QmlGraphicsItem *parent)
-{
- Q_D(QmlParentChange);
- d->parent = parent;
-}
-
-QmlStateOperation::ActionList QmlParentChange::actions()
-{
- Q_D(QmlParentChange);
- if (!d->target || !d->parent)
- return ActionList();
-
- QmlAction a;
- a.event = this;
-
- return ActionList() << a;
-}
-
-class AccessibleFxItem : public QmlGraphicsItem
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QmlGraphicsItem)
-public:
- int siblingIndex() {
- Q_D(QmlGraphicsItem);
- return d->siblingIndex;
- }
-};
-
-void QmlParentChange::saveOriginals()
-{
- Q_D(QmlParentChange);
- saveCurrentValues();
- d->origParent = d->rewindParent;
- d->origStackBefore = d->rewindStackBefore;
-}
-
-void QmlParentChange::execute()
-{
- Q_D(QmlParentChange);
- d->doChange(d->parent);
-}
-
-bool QmlParentChange::isReversable()
-{
- return true;
-}
-
-void QmlParentChange::reverse()
-{
- Q_D(QmlParentChange);
- d->doChange(d->origParent, d->origStackBefore);
-}
-
-QString QmlParentChange::typeName() const
-{
- return QLatin1String("ParentChange");
-}
-
-bool QmlParentChange::override(QmlActionEvent*other)
-{
- Q_D(QmlParentChange);
- if (other->typeName() != QLatin1String("ParentChange"))
- return false;
- if (QmlParentChange *otherPC = static_cast<QmlParentChange*>(other))
- return (d->target == otherPC->object());
- return false;
-}
-
-void QmlParentChange::saveCurrentValues()
-{
- Q_D(QmlParentChange);
- if (!d->target) {
- d->rewindParent = 0;
- d->rewindStackBefore = 0;
- return;
- }
-
- d->rewindParent = d->target->parentItem();
-
- if (!d->rewindParent) {
- d->rewindStackBefore = 0;
- return;
- }
-
- //try to determine the item's original stack position so we can restore it
- int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1;
- QList<QGraphicsItem*> children = d->rewindParent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem*>(children.at(i));
- if (!child)
- continue;
- if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) {
- d->rewindStackBefore = child;
- break;
- }
- }
-}
-
-void QmlParentChange::rewind()
-{
- Q_D(QmlParentChange);
- d->doChange(d->rewindParent, d->rewindStackBefore);
-}
-
-class QmlStateChangeScriptPrivate : public QObjectPrivate
-{
-public:
- QmlStateChangeScriptPrivate() {}
-
- QmlScriptString script;
- QString name;
-};
-
-/*!
- \qmlclass StateChangeScript QmlStateChangeScript
- \since 4.7
- \brief The StateChangeScript element allows you to run a script in a state.
-
- The script specified will be run immediately when the state is made current.
- Alternatively you can use a ScriptAction to specify at which point in the transition
- you want the StateChangeScript to be run.
-*/
-QML_DEFINE_TYPE(Qt,4,6,StateChangeScript,QmlStateChangeScript)
-QmlStateChangeScript::QmlStateChangeScript(QObject *parent)
-: QmlStateOperation(*(new QmlStateChangeScriptPrivate), parent)
-{
-}
-
-QmlStateChangeScript::~QmlStateChangeScript()
-{
-}
-
-/*!
- \qmlproperty script StateChangeScript::script
- This property holds the script to run when the state is current.
-*/
-QmlScriptString QmlStateChangeScript::script() const
-{
- Q_D(const QmlStateChangeScript);
- return d->script;
-}
-
-void QmlStateChangeScript::setScript(const QmlScriptString &s)
-{
- Q_D(QmlStateChangeScript);
- d->script = s;
-}
-
-/*!
- \qmlproperty script StateChangeScript::script
- This property holds the name of the script. This name can be used by a
- ScriptAction to target a specific script.
-
- \sa ScriptAction::stateChangeScriptName
-*/
-QString QmlStateChangeScript::name() const
-{
- Q_D(const QmlStateChangeScript);
- return d->name;
-}
-
-void QmlStateChangeScript::setName(const QString &n)
-{
- Q_D(QmlStateChangeScript);
- d->name = n;
-}
-
-void QmlStateChangeScript::execute()
-{
- Q_D(QmlStateChangeScript);
- const QString &script = d->script.script();
- if (!script.isEmpty()) {
- QmlExpression expr(d->script.context(), script, d->script.scopeObject());
- expr.setTrackChange(false);
- expr.value();
- }
-}
-
-QmlStateChangeScript::ActionList QmlStateChangeScript::actions()
-{
- ActionList rv;
- QmlAction a;
- a.event = this;
- rv << a;
- return rv;
-}
-
-QString QmlStateChangeScript::typeName() const
-{
- return QLatin1String("StateChangeScript");
-}
-
-/*!
- \qmlclass AnchorChanges QmlAnchorChanges
- \since 4.7
- \brief The AnchorChanges element allows you to change the anchors of an item in a state.
-
- In the following example we change the top and bottom anchors of an item:
- \snippet examples/declarative/anchors/anchor-changes.qml 0
-
- AnchorChanges will 'inject' \c x, \c y, \c width, and \c height changes into the transition,
- so you can animate them as you would normally changes to these properties:
- \qml
- //animate our anchor changes
- NumberAnimation { targets: content; properties: "x,y,width,height" }
- \endqml
-
- For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,AnchorChanges,QmlAnchorChanges)
-
-class QmlAnchorChangesPrivate : public QObjectPrivate
-{
-public:
- QmlAnchorChangesPrivate() : target(0) {}
-
- QString name;
- QmlGraphicsItem *target;
- QString resetString;
- QStringList resetList;
- QmlGraphicsAnchorLine left;
- QmlGraphicsAnchorLine right;
- QmlGraphicsAnchorLine horizontalCenter;
- QmlGraphicsAnchorLine top;
- QmlGraphicsAnchorLine bottom;
- QmlGraphicsAnchorLine verticalCenter;
- QmlGraphicsAnchorLine baseline;
-
- QmlGraphicsAnchorLine origLeft;
- QmlGraphicsAnchorLine origRight;
- QmlGraphicsAnchorLine origHCenter;
- QmlGraphicsAnchorLine origTop;
- QmlGraphicsAnchorLine origBottom;
- QmlGraphicsAnchorLine origVCenter;
- QmlGraphicsAnchorLine origBaseline;
-
- QmlGraphicsAnchorLine rewindLeft;
- QmlGraphicsAnchorLine rewindRight;
- QmlGraphicsAnchorLine rewindHCenter;
- QmlGraphicsAnchorLine rewindTop;
- QmlGraphicsAnchorLine rewindBottom;
- QmlGraphicsAnchorLine rewindVCenter;
- QmlGraphicsAnchorLine rewindBaseline;
-
- qreal fromX;
- qreal fromY;
- qreal fromWidth;
- qreal fromHeight;
-};
-
-/*!
- \qmlproperty Item AnchorChanges::target
- This property holds the Item whose anchors will change
-*/
-
-QmlAnchorChanges::QmlAnchorChanges(QObject *parent)
- : QmlStateOperation(*(new QmlAnchorChangesPrivate), parent)
-{
-}
-
-QmlAnchorChanges::~QmlAnchorChanges()
-{
-}
-
-QmlAnchorChanges::ActionList QmlAnchorChanges::actions()
-{
- QmlAction a;
- a.event = this;
- return ActionList() << a;
-}
-
-QmlGraphicsItem *QmlAnchorChanges::object() const
-{
- Q_D(const QmlAnchorChanges);
- return d->target;
-}
-
-void QmlAnchorChanges::setObject(QmlGraphicsItem *target)
-{
- Q_D(QmlAnchorChanges);
- d->target = target;
-}
-
-QString QmlAnchorChanges::reset() const
-{
- Q_D(const QmlAnchorChanges);
- return d->resetString;
-}
-
-void QmlAnchorChanges::setReset(const QString &reset)
-{
- Q_D(QmlAnchorChanges);
- d->resetString = reset;
- d->resetList = d->resetString.split(QLatin1Char(','));
- for (int i = 0; i < d->resetList.count(); ++i)
- d->resetList[i] = d->resetList.at(i).trimmed();
-}
-
-/*!
- \qmlproperty AnchorLine AnchorChanges::left
- \qmlproperty AnchorLine AnchorChanges::right
- \qmlproperty AnchorLine AnchorChanges::horizontalCenter
- \qmlproperty AnchorLine AnchorChanges::top
- \qmlproperty AnchorLine AnchorChanges::bottom
- \qmlproperty AnchorLine AnchorChanges::verticalCenter
- \qmlproperty AnchorLine AnchorChanges::baseline
-
- These properties change the respective anchors of the item.
-*/
-
-QmlGraphicsAnchorLine QmlAnchorChanges::left() const
-{
- Q_D(const QmlAnchorChanges);
- return d->left;
-}
-
-void QmlAnchorChanges::setLeft(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->left = edge;
-}
-
-QmlGraphicsAnchorLine QmlAnchorChanges::right() const
-{
- Q_D(const QmlAnchorChanges);
- return d->right;
-}
-
-void QmlAnchorChanges::setRight(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->right = edge;
-}
-
-QmlGraphicsAnchorLine QmlAnchorChanges::horizontalCenter() const
-{
- Q_D(const QmlAnchorChanges);
- return d->horizontalCenter;
-}
-
-void QmlAnchorChanges::setHorizontalCenter(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->horizontalCenter = edge;
-}
-
-QmlGraphicsAnchorLine QmlAnchorChanges::top() const
-{
- Q_D(const QmlAnchorChanges);
- return d->top;
-}
-
-void QmlAnchorChanges::setTop(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->top = edge;
-}
-
-QmlGraphicsAnchorLine QmlAnchorChanges::bottom() const
-{
- Q_D(const QmlAnchorChanges);
- return d->bottom;
-}
-
-void QmlAnchorChanges::setBottom(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->bottom = edge;
-}
-
-QmlGraphicsAnchorLine QmlAnchorChanges::verticalCenter() const
-{
- Q_D(const QmlAnchorChanges);
- return d->verticalCenter;
-}
-
-void QmlAnchorChanges::setVerticalCenter(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->verticalCenter = edge;
-}
-
-QmlGraphicsAnchorLine QmlAnchorChanges::baseline() const
-{
- Q_D(const QmlAnchorChanges);
- return d->baseline;
-}
-
-void QmlAnchorChanges::setBaseline(const QmlGraphicsAnchorLine &edge)
-{
- Q_D(QmlAnchorChanges);
- d->baseline = edge;
-}
-
-void QmlAnchorChanges::execute()
-{
- Q_D(QmlAnchorChanges);
- if (!d->target)
- return;
-
- //set any anchors that have been specified
- if (d->left.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setLeft(d->left);
- if (d->right.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setRight(d->right);
- if (d->horizontalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setHorizontalCenter(d->horizontalCenter);
- if (d->top.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setTop(d->top);
- if (d->bottom.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setBottom(d->bottom);
- if (d->verticalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setVerticalCenter(d->verticalCenter);
- if (d->baseline.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setBaseline(d->baseline);
-}
-
-bool QmlAnchorChanges::isReversable()
-{
- return true;
-}
-
-void QmlAnchorChanges::reverse()
-{
- Q_D(QmlAnchorChanges);
- if (!d->target)
- return;
-
- //restore previous anchors
- if (d->origLeft.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setLeft(d->origLeft);
- if (d->origRight.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setRight(d->origRight);
- if (d->origHCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setHorizontalCenter(d->origHCenter);
- if (d->origTop.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setTop(d->origTop);
- if (d->origBottom.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setBottom(d->origBottom);
- if (d->origVCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setVerticalCenter(d->origVCenter);
- if (d->origBaseline.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setBaseline(d->origBaseline);
-}
-
-QString QmlAnchorChanges::typeName() const
-{
- return QLatin1String("AnchorChanges");
-}
-
-QList<QmlAction> QmlAnchorChanges::extraActions()
-{
- Q_D(QmlAnchorChanges);
- QList<QmlAction> extra;
-
- //### try to be smarter about which ones we add.
- // or short-circuit later on if they haven't actually changed.
- // we shouldn't set explicit width if there wasn't one before.
- if (d->target) {
- QmlAction a;
- a.fromValue = d->fromX;
- a.property = QmlMetaProperty(d->target, QLatin1String("x"));
- extra << a;
-
- a.fromValue = d->fromY;
- a.property = QmlMetaProperty(d->target, QLatin1String("y"));
- extra << a;
-
- a.fromValue = d->fromWidth;
- a.property = QmlMetaProperty(d->target, QLatin1String("width"));
- extra << a;
-
- a.fromValue = d->fromHeight;
- a.property = QmlMetaProperty(d->target, QLatin1String("height"));
- extra << a;
- }
-
- return extra;
-}
-
-bool QmlAnchorChanges::changesBindings()
-{
- return true;
-}
-
-void QmlAnchorChanges::saveOriginals()
-{
- Q_D(QmlAnchorChanges);
- d->origLeft = d->target->anchors()->left();
- d->origRight = d->target->anchors()->right();
- d->origHCenter = d->target->anchors()->horizontalCenter();
- d->origTop = d->target->anchors()->top();
- d->origBottom = d->target->anchors()->bottom();
- d->origVCenter = d->target->anchors()->verticalCenter();
- d->origBaseline = d->target->anchors()->baseline();
-
- saveCurrentValues();
-}
-
-void QmlAnchorChanges::clearForwardBindings()
-{
- Q_D(QmlAnchorChanges);
- d->fromX = d->target->x();
- d->fromY = d->target->y();
- d->fromWidth = d->target->width();
- d->fromHeight = d->target->height();
-
- //reset any anchors that have been specified
- if (d->resetList.contains(QLatin1String("left")))
- d->target->anchors()->resetLeft();
- if (d->resetList.contains(QLatin1String("right")))
- d->target->anchors()->resetRight();
- if (d->resetList.contains(QLatin1String("horizontalCenter")))
- d->target->anchors()->resetHorizontalCenter();
- if (d->resetList.contains(QLatin1String("top")))
- d->target->anchors()->resetTop();
- if (d->resetList.contains(QLatin1String("bottom")))
- d->target->anchors()->resetBottom();
- if (d->resetList.contains(QLatin1String("verticalCenter")))
- d->target->anchors()->resetVerticalCenter();
- if (d->resetList.contains(QLatin1String("baseline")))
- d->target->anchors()->resetBaseline();
-
- //reset any anchors that we'll be setting in the state
- if (d->left.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetLeft();
- if (d->right.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetRight();
- if (d->horizontalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetHorizontalCenter();
- if (d->top.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetTop();
- if (d->bottom.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetBottom();
- if (d->verticalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetVerticalCenter();
- if (d->baseline.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetBaseline();
-}
-
-void QmlAnchorChanges::clearReverseBindings()
-{
- Q_D(QmlAnchorChanges);
- d->fromX = d->target->x();
- d->fromY = d->target->y();
- d->fromWidth = d->target->width();
- d->fromHeight = d->target->height();
-
- //reset any anchors that were set in the state
- if (d->left.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetLeft();
- if (d->right.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetRight();
- if (d->horizontalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetHorizontalCenter();
- if (d->top.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetTop();
- if (d->bottom.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetBottom();
- if (d->verticalCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetVerticalCenter();
- if (d->baseline.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetBaseline();
-
- //reset any anchors that were set in the original state
- if (d->origLeft.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetLeft();
- if (d->origRight.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetRight();
- if (d->origHCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetHorizontalCenter();
- if (d->origTop.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetTop();
- if (d->origBottom.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetBottom();
- if (d->origVCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetVerticalCenter();
- if (d->origBaseline.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->resetBaseline();
-}
-
-bool QmlAnchorChanges::override(QmlActionEvent*other)
-{
- if (other->typeName() != QLatin1String("AnchorChanges"))
- return false;
- if (static_cast<QmlActionEvent*>(this) == other)
- return true;
- if (static_cast<QmlAnchorChanges*>(other)->object() == object())
- return true;
- return false;
-}
-
-void QmlAnchorChanges::rewind()
-{
- Q_D(QmlAnchorChanges);
- if (!d->target)
- return;
-
- //restore previous anchors
- if (d->rewindLeft.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setLeft(d->rewindLeft);
- if (d->rewindRight.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setRight(d->rewindRight);
- if (d->rewindHCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setHorizontalCenter(d->rewindHCenter);
- if (d->rewindTop.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setTop(d->rewindTop);
- if (d->rewindBottom.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setBottom(d->rewindBottom);
- if (d->rewindVCenter.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setVerticalCenter(d->rewindVCenter);
- if (d->rewindBaseline.anchorLine != QmlGraphicsAnchorLine::Invalid)
- d->target->anchors()->setBaseline(d->rewindBaseline);
-}
-
-void QmlAnchorChanges::saveCurrentValues()
-{
- Q_D(QmlAnchorChanges);
- d->rewindLeft = d->target->anchors()->left();
- d->rewindRight = d->target->anchors()->right();
- d->rewindHCenter = d->target->anchors()->horizontalCenter();
- d->rewindTop = d->target->anchors()->top();
- d->rewindBottom = d->target->anchors()->bottom();
- d->rewindVCenter = d->target->anchors()->verticalCenter();
- d->rewindBaseline = d->target->anchors()->baseline();
-}
-
-#include <qmlstateoperations.moc>
-#include <moc_qmlstateoperations_p.cpp>
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/util/qmlstateoperations_p.h b/src/declarative/util/qmlstateoperations_p.h
deleted file mode 100644
index dc1974b97e..0000000000
--- a/src/declarative/util/qmlstateoperations_p.h
+++ /dev/null
@@ -1,184 +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 QMLSTATEOPERATIONS_H
-#define QMLSTATEOPERATIONS_H
-
-#include "qmlstate_p.h"
-
-#include <qmlgraphicsitem.h>
-#include "private/qmlgraphicsanchors_p.h"
-#include <qmlscriptstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlParentChangePrivate;
-class Q_DECLARATIVE_EXPORT QmlParentChange : public QmlStateOperation, public QmlActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlParentChange)
-
- Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject)
- Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent)
-public:
- QmlParentChange(QObject *parent=0);
- ~QmlParentChange();
-
- QmlGraphicsItem *object() const;
- void setObject(QmlGraphicsItem *);
-
- QmlGraphicsItem *parent() const;
- void setParent(QmlGraphicsItem *);
-
- virtual ActionList actions();
-
- virtual void saveOriginals();
- virtual void execute();
- virtual bool isReversable();
- virtual void reverse();
- virtual QString typeName() const;
- virtual bool override(QmlActionEvent*other);
- virtual void rewind();
- virtual void saveCurrentValues();
-};
-
-class QmlStateChangeScriptPrivate;
-class Q_DECLARATIVE_EXPORT QmlStateChangeScript : public QmlStateOperation, public QmlActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlStateChangeScript)
-
- Q_PROPERTY(QmlScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString name READ name WRITE setName)
-
-public:
- QmlStateChangeScript(QObject *parent=0);
- ~QmlStateChangeScript();
-
- virtual ActionList actions();
-
- virtual QString typeName() const;
-
- QmlScriptString script() const;
- void setScript(const QmlScriptString &);
-
- QString name() const;
- void setName(const QString &);
-
- virtual void execute();
-};
-
-class QmlAnchorChangesPrivate;
-class Q_DECLARATIVE_EXPORT QmlAnchorChanges : public QmlStateOperation, public QmlActionEvent
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlAnchorChanges)
-
- Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject)
- Q_PROPERTY(QString reset READ reset WRITE setReset)
- Q_PROPERTY(QmlGraphicsAnchorLine left READ left WRITE setLeft)
- Q_PROPERTY(QmlGraphicsAnchorLine right READ right WRITE setRight)
- Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter)
- Q_PROPERTY(QmlGraphicsAnchorLine top READ top WRITE setTop)
- Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom)
- Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter)
- Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline)
-
-public:
- QmlAnchorChanges(QObject *parent=0);
- ~QmlAnchorChanges();
-
- virtual ActionList actions();
-
- QmlGraphicsItem *object() const;
- void setObject(QmlGraphicsItem *);
-
- QString reset() const;
- void setReset(const QString &);
-
- QmlGraphicsAnchorLine left() const;
- void setLeft(const QmlGraphicsAnchorLine &edge);
-
- QmlGraphicsAnchorLine right() const;
- void setRight(const QmlGraphicsAnchorLine &edge);
-
- QmlGraphicsAnchorLine horizontalCenter() const;
- void setHorizontalCenter(const QmlGraphicsAnchorLine &edge);
-
- QmlGraphicsAnchorLine top() const;
- void setTop(const QmlGraphicsAnchorLine &edge);
-
- QmlGraphicsAnchorLine bottom() const;
- void setBottom(const QmlGraphicsAnchorLine &edge);
-
- QmlGraphicsAnchorLine verticalCenter() const;
- void setVerticalCenter(const QmlGraphicsAnchorLine &edge);
-
- QmlGraphicsAnchorLine baseline() const;
- void setBaseline(const QmlGraphicsAnchorLine &edge);
-
- virtual void execute();
- virtual bool isReversable();
- virtual void reverse();
- virtual QString typeName() const;
- virtual bool override(QmlActionEvent*other);
- virtual QList<QmlAction> extraActions();
- virtual bool changesBindings();
- virtual void saveOriginals();
- virtual void clearForwardBindings();
- virtual void clearReverseBindings();
- virtual void rewind();
- virtual void saveCurrentValues();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlParentChange)
-QML_DECLARE_TYPE(QmlStateChangeScript)
-QML_DECLARE_TYPE(QmlAnchorChanges)
-
-QT_END_HEADER
-
-#endif // QMLSTATEOPERATIONS_H
diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp
deleted file mode 100644
index 1f31214ec6..0000000000
--- a/src/declarative/util/qmlstyledtext.cpp
+++ /dev/null
@@ -1,347 +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 <QStack>
-#include <QVector>
-#include <QPainter>
-#include <QTextLayout>
-#include <QDebug>
-#include <qmath.h>
-#include "qmlstyledtext_p.h"
-
-/*
- QmlStyledText supports few tags:
-
- <b></b> - bold
- <i></i> - italic
- <br> - new line
- <font color="color_name" size="1-7"></font>
-
- The opening and closing tags must be correctly nested.
-*/
-
-QT_BEGIN_NAMESPACE
-
-class QmlStyledTextPrivate
-{
-public:
- QmlStyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {}
-
- void parse();
- bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format);
- bool parseCloseTag(const QChar *&ch, const QString &textIn);
- void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut);
- bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
- QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
- QStringRef parseValue(const QChar *&ch, const QString &textIn);
-
- inline void skipSpace(const QChar *&ch) {
- while (ch->isSpace() && !ch->isNull())
- ++ch;
- }
-
- QString text;
- QTextLayout &layout;
- QFont baseFont;
-
- static const QChar lessThan;
- static const QChar greaterThan;
- static const QChar equals;
- static const QChar singleQuote;
- static const QChar doubleQuote;
- static const QChar slash;
- static const QChar ampersand;
-};
-
-const QChar QmlStyledTextPrivate::lessThan(QLatin1Char('<'));
-const QChar QmlStyledTextPrivate::greaterThan(QLatin1Char('>'));
-const QChar QmlStyledTextPrivate::equals(QLatin1Char('='));
-const QChar QmlStyledTextPrivate::singleQuote(QLatin1Char('\''));
-const QChar QmlStyledTextPrivate::doubleQuote(QLatin1Char('\"'));
-const QChar QmlStyledTextPrivate::slash(QLatin1Char('/'));
-const QChar QmlStyledTextPrivate::ampersand(QLatin1Char('&'));
-
-QmlStyledText::QmlStyledText(const QString &string, QTextLayout &layout)
-: d(new QmlStyledTextPrivate(string, layout))
-{
-}
-
-QmlStyledText::~QmlStyledText()
-{
- delete d;
-}
-
-void QmlStyledText::parse(const QString &string, QTextLayout &layout)
-{
- QmlStyledText styledText(string, layout);
- styledText.d->parse();
-}
-
-void QmlStyledTextPrivate::parse()
-{
- QList<QTextLayout::FormatRange> ranges;
- QStack<QTextCharFormat> formatStack;
-
- QString drawText;
- drawText.reserve(text.count());
-
- int textStart = 0;
- int textLength = 0;
- int rangeStart = 0;
- const QChar *ch = text.constData();
- while (!ch->isNull()) {
- if (*ch == lessThan) {
- if (textLength)
- drawText.append(QStringRef(&text, textStart, textLength));
- if (rangeStart != drawText.length() && formatStack.count()) {
- QTextLayout::FormatRange formatRange;
- formatRange.format = formatStack.top();
- formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
- ranges.append(formatRange);
- }
- rangeStart = drawText.length();
- ++ch;
- if (*ch == slash) {
- ++ch;
- if (parseCloseTag(ch, text))
- formatStack.pop();
- } else {
- QTextCharFormat format;
- if (formatStack.count())
- format = formatStack.top();
- else
- format.setFont(baseFont);
- if (parseTag(ch, text, drawText, format))
- formatStack.push(format);
- }
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else if (*ch == ampersand) {
- ++ch;
- drawText.append(QStringRef(&text, textStart, textLength));
- parseEntity(ch, text, drawText);
- textStart = ch - text.constData() + 1;
- textLength = 0;
- } else {
- ++textLength;
- }
- ++ch;
- }
- if (textLength)
- drawText.append(QStringRef(&text, textStart, textLength));
- if (rangeStart != drawText.length() && formatStack.count()) {
- QTextLayout::FormatRange formatRange;
- formatRange.format = formatStack.top();
- formatRange.start = rangeStart;
- formatRange.length = drawText.length() - rangeStart;
- ranges.append(formatRange);
- }
-
- layout.setText(drawText);
- layout.setAdditionalFormats(ranges);
-}
-
-bool QmlStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
-{
- skipSpace(ch);
-
- int tagStart = ch - textIn.constData();
- int tagLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- QStringRef tag(&textIn, tagStart, tagLength);
- const QChar char0 = tag.at(0);
- if (char0 == QLatin1Char('b')) {
- if (tagLength == 1) {
- format.setFontWeight(QFont::Bold);
- return true;
- } else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
- textOut.append(QChar(QChar::LineSeparator));
- return true;
- }
- } else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1) {
- format.setFontItalic(true);
- return true;
- }
- }
- return false;
- } else if (ch->isSpace()) {
- // may have params.
- QStringRef tag(&textIn, tagStart, tagLength);
- if (tag == QLatin1String("font"))
- return parseFontAttributes(ch, textIn, format);
- if (*ch == greaterThan || ch->isNull())
- continue;
- } else if (*ch != slash){
- tagLength++;
- }
- ++ch;
- }
-
- return false;
-}
-
-bool QmlStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn)
-{
- skipSpace(ch);
-
- int tagStart = ch - textIn.constData();
- int tagLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- QStringRef tag(&textIn, tagStart, tagLength);
- const QChar char0 = tag.at(0);
- if (char0 == QLatin1Char('b')) {
- if (tagLength == 1)
- return true;
- else if (tag.at(1) == QLatin1Char('r') && tagLength == 2)
- return true;
- } else if (char0 == QLatin1Char('i')) {
- if (tagLength == 1)
- return true;
- } else if (tag == QLatin1String("font")) {
- return true;
- }
- return false;
- } else if (!ch->isSpace()){
- tagLength++;
- }
- ++ch;
- }
-
- return false;
-}
-
-void QmlStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut)
-{
- int entityStart = ch - textIn.constData();
- int entityLength = 0;
- while (!ch->isNull()) {
- if (*ch == QLatin1Char(';')) {
- QStringRef entity(&textIn, entityStart, entityLength);
- if (entity == QLatin1String("gt"))
- textOut += QChar(62);
- else if (entity == QLatin1String("lt"))
- textOut += QChar(60);
- else if (entity == QLatin1String("amp"))
- textOut += QChar(38);
- return;
- }
- ++entityLength;
- ++ch;
- }
-}
-
-bool QmlStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
-{
- bool valid = false;
- QPair<QStringRef,QStringRef> attr;
- do {
- attr = parseAttribute(ch, textIn);
- if (attr.first == QLatin1String("color")) {
- valid = true;
- format.setForeground(QColor(attr.second.toString()));
- } else if (attr.first == QLatin1String("size")) {
- valid = true;
- int size = attr.second.toString().toInt();
- if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+'))
- size += 3;
- if (size >= 1 && size <= 7) {
- static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
- format.setFontPointSize(baseFont.pointSize() * scaling[size-1]);
- }
- }
- } while (!ch->isNull() && !attr.first.isEmpty());
-
- return valid;
-}
-
-QPair<QStringRef,QStringRef> QmlStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
-{
- skipSpace(ch);
-
- int attrStart = ch - textIn.constData();
- int attrLength = 0;
- while (!ch->isNull()) {
- if (*ch == greaterThan) {
- break;
- } else if (*ch == equals) {
- ++ch;
- if (*ch != singleQuote && *ch != doubleQuote) {
- while (*ch != greaterThan && !ch->isNull())
- ++ch;
- break;
- }
- ++ch;
- if (!attrLength)
- break;
- QStringRef attr(&textIn, attrStart, attrLength);
- QStringRef val = parseValue(ch, textIn);
- if (!val.isEmpty())
- return QPair<QStringRef,QStringRef>(attr,val);
- break;
- } else {
- ++attrLength;
- }
- ++ch;
- }
-
- return QPair<QStringRef,QStringRef>();
-}
-
-QStringRef QmlStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
-{
- int valStart = ch - textIn.constData();
- int valLength = 0;
- while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) {
- ++valLength;
- ++ch;
- }
- if (ch->isNull())
- return QStringRef();
- ++ch; // skip quote
-
- return QStringRef(&textIn, valStart, valLength);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h
deleted file mode 100644
index 4698279605..0000000000
--- a/src/declarative/util/qmlstyledtext_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 QMLSTYLEDTEXT_H
-#define QMLSTYLEDTEXT_H
-
-#include <QSizeF>
-
-QT_BEGIN_NAMESPACE
-
-class QPainter;
-class QPointF;
-class QString;
-class QmlStyledTextPrivate;
-
-class Q_DECLARATIVE_EXPORT QmlStyledText
-{
-public:
- static void parse(const QString &string, QTextLayout &layout);
-
-private:
- QmlStyledText(const QString &string, QTextLayout &layout);
- ~QmlStyledText();
-
- QmlStyledTextPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp
deleted file mode 100644
index 4e78518243..0000000000
--- a/src/declarative/util/qmlsystempalette.cpp
+++ /dev/null
@@ -1,304 +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 "qmlsystempalette_p.h"
-
-#include <QApplication>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlSystemPalettePrivate : public QObjectPrivate
-{
-public:
- QPalette palette;
- QPalette::ColorGroup group;
-};
-
-QML_DEFINE_TYPE(Qt,4,6,SystemPalette,QmlSystemPalette)
-
-/*!
- \qmlclass SystemPalette QmlSystemPalette
- \since 4.7
- \ingroup group_utility
- \brief The SystemPalette item gives access to the Qt palettes.
- \sa QPalette
-
- Example:
- \qml
- SystemPalette { id: myPalette; colorGroup: Qt.Active }
-
- Rectangle {
- width: 640; height: 480
- color: myPalette.window
- Text {
- anchors.fill: parent
- text: "Hello!"; color: myPalette.windowText
- }
- }
- \endqml
-*/
-QmlSystemPalette::QmlSystemPalette(QObject *parent)
- : QObject(*(new QmlSystemPalettePrivate), parent)
-{
- Q_D(QmlSystemPalette);
- d->palette = QApplication::palette();
- d->group = QPalette::Active;
- qApp->installEventFilter(this);
-}
-
-QmlSystemPalette::~QmlSystemPalette()
-{
-}
-
-/*!
- \qmlproperty color SystemPalette::window
- The window (general background) color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::window() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Window);
-}
-
-/*!
- \qmlproperty color SystemPalette::windowText
- The window text (general foreground) color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::windowText() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::WindowText);
-}
-
-/*!
- \qmlproperty color SystemPalette::base
- The base color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::base() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Base);
-}
-
-/*!
- \qmlproperty color SystemPalette::text
- The text color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::text() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Text);
-}
-
-/*!
- \qmlproperty color SystemPalette::alternateBase
- The alternate base color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::alternateBase() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::AlternateBase);
-}
-
-/*!
- \qmlproperty color SystemPalette::button
- The button color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::button() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Button);
-}
-
-/*!
- \qmlproperty color SystemPalette::buttonText
- The button text foreground color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::buttonText() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::ButtonText);
-}
-
-/*!
- \qmlproperty color SystemPalette::light
- The light color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::light() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Light);
-}
-
-/*!
- \qmlproperty color SystemPalette::midlight
- The midlight color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::midlight() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Midlight);
-}
-
-/*!
- \qmlproperty color SystemPalette::dark
- The dark color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::dark() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Dark);
-}
-
-/*!
- \qmlproperty color SystemPalette::mid
- The mid color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::mid() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Mid);
-}
-
-/*!
- \qmlproperty color SystemPalette::shadow
- The shadow color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::shadow() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Shadow);
-}
-
-/*!
- \qmlproperty color SystemPalette::highlight
- The highlight color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::highlight() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::Highlight);
-}
-
-/*!
- \qmlproperty color SystemPalette::highlightedText
- The highlighted text color of the current color group.
-
- \sa QPalette::ColorRole
-*/
-QColor QmlSystemPalette::highlightedText() const
-{
- Q_D(const QmlSystemPalette);
- return d->palette.color(d->group, QPalette::HighlightedText);
-}
-
-/*!
- \qmlproperty QmlSystemPalette::ColorGroup SystemPalette::colorGroup
-
- The color group of the palette. It can be Active, Inactive or Disabled.
- Active is the default.
-
- \sa QPalette::ColorGroup
-*/
-QmlSystemPalette::ColorGroup QmlSystemPalette::colorGroup() const
-{
- Q_D(const QmlSystemPalette);
- return (QmlSystemPalette::ColorGroup)d->group;
-}
-
-void QmlSystemPalette::setColorGroup(QmlSystemPalette::ColorGroup colorGroup)
-{
- Q_D(QmlSystemPalette);
- d->group = (QPalette::ColorGroup)colorGroup;
- emit paletteChanged();
-}
-
-bool QmlSystemPalette::eventFilter(QObject *watched, QEvent *event)
-{
- if (watched == qApp) {
- if (event->type() == QEvent::ApplicationPaletteChange) {
- QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
- return false;
- }
- }
- return QObject::eventFilter(watched, event);
-}
-
-bool QmlSystemPalette::event(QEvent *event)
-{
- Q_D(QmlSystemPalette);
- if (event->type() == QEvent::ApplicationPaletteChange) {
- d->palette = QApplication::palette();
- emit paletteChanged();
- return true;
- }
- return QObject::event(event);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlsystempalette_p.h b/src/declarative/util/qmlsystempalette_p.h
deleted file mode 100644
index e25bf7fd3d..0000000000
--- a/src/declarative/util/qmlsystempalette_p.h
+++ /dev/null
@@ -1,122 +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 QMLSYSTEMPALETTE_H
-#define QMLSYSTEMPALETTE_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-#include <QPalette>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlSystemPalettePrivate;
-class Q_DECLARATIVE_EXPORT QmlSystemPalette : public QObject
-{
- Q_OBJECT
- Q_ENUMS(ColorGroup)
- Q_DECLARE_PRIVATE(QmlSystemPalette)
-
- Q_PROPERTY(QmlSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged)
- Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
- Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
- Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
- Q_PROPERTY(QColor text READ text NOTIFY paletteChanged)
- Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
- Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
- Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
- Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
- Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
- Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
- Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
- Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
- Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
- Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
-
-public:
- QmlSystemPalette(QObject *parent=0);
- ~QmlSystemPalette();
-
- enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
-
- QColor window() const;
- QColor windowText() const;
-
- QColor base() const;
- QColor text() const;
- QColor alternateBase() const;
-
- QColor button() const;
- QColor buttonText() const;
-
- QColor light() const;
- QColor midlight() const;
- QColor dark() const;
- QColor mid() const;
- QColor shadow() const;
-
- QColor highlight() const;
- QColor highlightedText() const;
-
- QmlSystemPalette::ColorGroup colorGroup() const;
- void setColorGroup(QmlSystemPalette::ColorGroup);
-
-Q_SIGNALS:
- void paletteChanged();
-
-private:
- bool eventFilter(QObject *watched, QEvent *event);
- bool event(QEvent *event);
-
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlSystemPalette)
-
-QT_END_HEADER
-
-#endif // QMLSYSTEMPALETTE_H
diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp
deleted file mode 100644
index 5c5df40f1e..0000000000
--- a/src/declarative/util/qmltimeline.cpp
+++ /dev/null
@@ -1,942 +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 "qmltimeline_p_p.h"
-
-#include <QDebug>
-#include <QMutex>
-#include <QThread>
-#include <QWaitCondition>
-#include <QEvent>
-#include <QCoreApplication>
-#include <QEasingCurve>
-#include <QTime>
-
-QT_BEGIN_NAMESPACE
-
-struct Update {
- Update(QmlTimeLineValue *_g, qreal _v)
- : g(_g), v(_v) {}
- Update(const QmlTimeLineCallback &_e)
- : g(0), v(0), e(_e) {}
-
- QmlTimeLineValue *g;
- qreal v;
- QmlTimeLineCallback e;
-};
-
-struct QmlTimeLinePrivate
-{
- QmlTimeLinePrivate(QmlTimeLine *);
-
- struct Op {
- enum Type {
- Pause,
- Set,
- Move,
- MoveBy,
- Accel,
- AccelDistance,
- Execute
- };
- Op() {}
- Op(Type t, int l, qreal v, qreal v2, int o,
- const QmlTimeLineCallback &ev = QmlTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
- : type(t), length(l), value(v), value2(v2), order(o), event(ev),
- easing(es) {}
- Op(const Op &o)
- : type(o.type), length(o.length), value(o.value), value2(o.value2),
- order(o.order), event(o.event), easing(o.easing) {}
- Op &operator=(const Op &o) {
- type = o.type; length = o.length; value = o.value;
- value2 = o.value2; order = o.order; event = o.event;
- easing = o.easing;
- return *this;
- }
-
- Type type;
- int length;
- qreal value;
- qreal value2;
-
- int order;
- QmlTimeLineCallback event;
- QEasingCurve easing;
- };
- struct TimeLine
- {
- TimeLine() : length(0), consumedOpLength(0), base(0.) {}
- QList<Op> ops;
- int length;
- int consumedOpLength;
- qreal base;
- };
-
- int length;
- int syncPoint;
- typedef QHash<QmlTimeLineObject *, TimeLine> Ops;
- Ops ops;
- QmlTimeLine *q;
-
- void add(QmlTimeLineObject &, const Op &);
- qreal value(const Op &op, int time, qreal base, bool *) const;
-
- int advance(int);
-
- bool clockRunning;
- int prevTime;
-
- int order;
-
- QmlTimeLine::SyncMode syncMode;
- int syncAdj;
- QList<QPair<int, Update> > *updateQueue;
-};
-
-QmlTimeLinePrivate::QmlTimeLinePrivate(QmlTimeLine *parent)
-: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QmlTimeLine::LocalSync), syncAdj(0), updateQueue(0)
-{
-}
-
-void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o)
-{
- if (g._t && g._t != q) {
- qWarning() << "QmlTimeLine: Cannot modify a QmlTimeLineValue owned by"
- << "another timeline.";
- return;
- }
- g._t = q;
-
- Ops::Iterator iter = ops.find(&g);
- if (iter == ops.end()) {
- iter = ops.insert(&g, TimeLine());
- if (syncPoint > 0)
- q->pause(g, syncPoint);
- }
- if (!iter->ops.isEmpty() &&
- o.type == Op::Pause &&
- iter->ops.last().type == Op::Pause) {
- iter->ops.last().length += o.length;
- iter->length += o.length;
- } else {
- iter->ops.append(o);
- iter->length += o.length;
- }
-
- if (iter->length > length)
- length = iter->length;
-
- if (!clockRunning) {
- q->stop();
- prevTime = 0;
- clockRunning = true;
-
- if (syncMode == QmlTimeLine::LocalSync) {
- syncAdj = -1;
- } else {
- syncAdj = 0;
- }
- q->start();
-/* q->tick(0);
- if (syncMode == QmlTimeLine::LocalSync) {
- syncAdj = -1;
- } else {
- syncAdj = 0;
- }
- */
- }
-}
-
-qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const
-{
- Q_ASSERT(time >= 0);
- Q_ASSERT(time <= op.length);
- *changed = true;
-
- switch(op.type) {
- case Op::Pause:
- *changed = false;
- return base;
- case Op::Set:
- return op.value;
- case Op::Move:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return op.value;
- } else {
- qreal delta = op.value - base;
- qreal pTime = (qreal)(time) / (qreal)op.length;
- if (op.easing.type() == QEasingCurve::Linear)
- return base + delta * pTime;
- else
- return base + delta * op.easing.valueForProgress(pTime);
- }
- case Op::MoveBy:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return base + op.value;
- } else {
- qreal delta = op.value;
- qreal pTime = (qreal)(time) / (qreal)op.length;
- if (op.easing.type() == QEasingCurve::Linear)
- return base + delta * pTime;
- else
- return base + delta * op.easing.valueForProgress(pTime);
- }
- case Op::Accel:
- if (time == 0) {
- return base;
- } else {
- qreal t = (qreal)(time) / 1000.0f;
- qreal delta = op.value * t + 0.5f * op.value2 * t * t;
- return base + delta;
- }
- case Op::AccelDistance:
- if (time == 0) {
- return base;
- } else if (time == (op.length)) {
- return base + op.value2;
- } else {
- qreal t = (qreal)(time) / 1000.0f;
- qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length;
- qreal delta = op.value * t + 0.5f * accel * t * t;
- return base + delta;
-
- }
- case Op::Execute:
- op.event.d0(op.event.d1);
- *changed = false;
- return -1;
- }
-
- return base;
-}
-
-/*!
- \internal
- \class QmlTimeLine
- \ingroup group_animation
- \brief The QmlTimeLine class provides a timeline for controlling animations.
-
- QmlTimeLine is similar to QTimeLine except:
- \list
- \i It updates QmlTimeLineValue instances directly, rather than maintaining a single
- current value.
-
- For example, the following animates a simple value over 200 milliseconds:
- \code
- QmlTimeLineValue v(<starting value>);
- QmlTimeLine tl;
- tl.move(v, 100., 200);
- tl.start()
- \endcode
-
- If your program needs to know when values are changed, it can either
- connect to the QmlTimeLine's updated() signal, or inherit from QmlTimeLineValue
- and reimplement the QmlTimeLineValue::setValue() method.
-
- \i Supports multiple QmlTimeLineValue, arbitrary start and end values and allows
- animations to be strung together for more complex effects.
-
- For example, the following animation moves the x and y coordinates of
- an object from wherever they are to the position (100, 100) in 50
- milliseconds and then further animates them to (100, 200) in 50
- milliseconds:
-
- \code
- QmlTimeLineValue x(<starting value>);
- QmlTimeLineValue y(<starting value>);
-
- QmlTimeLine tl;
- tl.start();
-
- tl.move(x, 100., 50);
- tl.move(y, 100., 50);
- tl.move(y, 200., 50);
- \endcode
-
- \i All QmlTimeLine instances share a single, synchronized clock.
-
- Actions scheduled within the same event loop tick are scheduled
- synchronously against each other, regardless of the wall time between the
- scheduling. Synchronized scheduling applies both to within the same
- QmlTimeLine and across separate QmlTimeLine's within the same process.
-
- \endlist
-
- Currently easing functions are not supported.
-*/
-
-
-/*!
- Construct a new QmlTimeLine with the specified \a parent.
-*/
-QmlTimeLine::QmlTimeLine(QObject *parent)
-: QAbstractAnimation(parent)
-{
- d = new QmlTimeLinePrivate(this);
-}
-
-/*!
- Destroys the time line. Any inprogress animations are canceled, but not
- completed.
-*/
-QmlTimeLine::~QmlTimeLine()
-{
- for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter)
- iter.key()->_t = 0;
-
- delete d; d = 0;
-}
-
-/*!
- \enum QmlTimeLine::SyncMode
- */
-
-/*!
- Return the timeline's synchronization mode.
- */
-QmlTimeLine::SyncMode QmlTimeLine::syncMode() const
-{
- return d->syncMode;
-}
-
-/*!
- Set the timeline's synchronization mode to \a syncMode.
- */
-void QmlTimeLine::setSyncMode(SyncMode syncMode)
-{
- d->syncMode = syncMode;
-}
-
-/*!
- Pause \a obj for \a time milliseconds.
-*/
-void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
-{
- if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Pause, time, 0., 0., d->order++);
- d->add(obj, op);
-}
-
-/*!
- Execute the \a event.
- */
-void QmlTimeLine::callback(const QmlTimeLineCallback &callback)
-{
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback);
- d->add(*callback.callbackObject(), op);
-}
-
-/*!
- Set the \a value of \a timeLineValue.
-*/
-void QmlTimeLine::set(QmlTimeLineValue &timeLineValue, qreal value)
-{
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Decelerate \a timeLineValue from the starting \a velocity to zero at the
- given \a acceleration rate. Although the \a acceleration is technically
- a deceleration, it should always be positive. The QmlTimeLine will ensure
- that the deceleration is in the opposite direction to the initial velocity.
-*/
-int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
-{
- if ((velocity > 0.0f) == (acceleration > 0.0f))
- acceleration = acceleration * -1.0f;
-
- int time = static_cast<int>(-1000 * velocity / acceleration);
-
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- \overload
-
- Decelerate \a timeLineValue from the starting \a velocity to zero at the
- given \a acceleration rate over a maximum distance of maxDistance.
-
- If necessary, QmlTimeLine will reduce the acceleration to ensure that the
- entire operation does not require a move of more than \a maxDistance.
- \a maxDistance should always be positive.
-*/
-int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
-{
- Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f);
-
- qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance);
- if (maxAccel > acceleration)
- acceleration = maxAccel;
-
- if ((velocity > 0.0f) == (acceleration > 0.0f))
- acceleration = acceleration * -1.0f;
-
- int time = static_cast<int>(-1000 * velocity / acceleration);
-
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- Decelerate \a timeLineValue from the starting \a velocity to zero over the given
- \a distance. This is like accel(), but the QmlTimeLine calculates the exact
- deceleration to use.
-
- \a distance should be positive.
-*/
-int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, qreal distance)
-{
- if (distance == 0.0f || velocity == 0.0f)
- return -1;
- Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f));
-
- int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
-
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
- d->add(timeLineValue, op);
-
- return time;
-}
-
-/*!
- Linearly change the \a timeLineValue from its current value to the given
- \a destination value over \a time milliseconds.
-*/
-void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int time)
-{
- if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Change the \a timeLineValue from its current value to the given \a destination
- value over \a time milliseconds using the \a easing curve.
- */
-void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
-{
- if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineCallback(), easing);
- d->add(timeLineValue, op);
-}
-
-/*!
- Linearly change the \a timeLineValue from its current value by the \a change amount
- over \a time milliseconds.
-*/
-void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time)
-{
- if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
- d->add(timeLineValue, op);
-}
-
-/*!
- Change the \a timeLineValue from its current value by the \a change amount over
- \a time milliseconds using the \a easing curve.
- */
-void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
-{
- if (time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineCallback(), easing);
- d->add(timeLineValue, op);
-}
-
-/*!
- Cancel (but don't complete) all scheduled actions for \a timeLineValue.
-*/
-void QmlTimeLine::reset(QmlTimeLineValue &timeLineValue)
-{
- if (!timeLineValue._t)
- return;
- if (timeLineValue._t != this) {
- qWarning() << "QmlTimeLine: Cannot reset a QmlTimeLineValue owned by another timeline.";
- return;
- }
- remove(&timeLineValue);
- timeLineValue._t = 0;
-}
-
-int QmlTimeLine::duration() const
-{
- return -1;
-}
-
-/*!
- Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
- within this timeline.
-
- Following operations on \a timeLineValue in this timeline will be scheduled after
- all the currently scheduled actions on \a syncTo are complete. In
- psuedo-code this is equivalent to:
- \code
- QmlTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
- \endcode
-*/
-void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue, QmlTimeLineValue &syncTo)
-{
- QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
- if (iter == d->ops.end())
- return;
- int length = iter->length;
-
- iter = d->ops.find(&timeLineValue);
- if (iter == d->ops.end()) {
- pause(timeLineValue, length);
- } else {
- int glength = iter->length;
- pause(timeLineValue, length - glength);
- }
-}
-
-/*!
- Synchronize the end point of \a timeLineValue to the endpoint of the longest
- action cursrently scheduled in the timeline.
-
- In psuedo-code, this is equivalent to:
- \code
- QmlTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
- \endcode
-*/
-void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue)
-{
- QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
- if (iter == d->ops.end()) {
- pause(timeLineValue, d->length);
- } else {
- pause(timeLineValue, d->length - iter->length);
- }
-}
-
-/*
- Synchronize all currently and future scheduled values in this timeline to
- the longest action currently scheduled.
-
- For example:
- \code
- value1->setValue(0.);
- value2->setValue(0.);
- value3->setValue(0.);
- QmlTimeLine tl;
- ...
- tl.move(value1, 10, 200);
- tl.move(value2, 10, 100);
- tl.sync();
- tl.move(value2, 20, 100);
- tl.move(value3, 20, 100);
- \endcode
-
- will result in:
-
- \table
- \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms
- \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10
- \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0
- \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0
- \endtable
-*/
-
-/*void QmlTimeLine::sync()
-{
- for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter)
- pause(*iter.key(), d->length - iter->length);
- d->syncPoint = d->length;
-}*/
-
-/*!
- \internal
-
- Temporary hack.
- */
-void QmlTimeLine::setSyncPoint(int sp)
-{
- d->syncPoint = sp;
-}
-
-/*!
- \internal
-
- Temporary hack.
- */
-int QmlTimeLine::syncPoint() const
-{
- return d->syncPoint;
-}
-
-/*!
- Returns true if the timeline is active. An active timeline is one where
- QmlTimeLineValue actions are still pending.
-*/
-bool QmlTimeLine::isActive() const
-{
- return !d->ops.isEmpty();
-}
-
-/*!
- Completes the timeline. All queued actions are played to completion, and then discarded. For example,
- \code
- QmlTimeLineValue v(0.);
- QmlTimeLine tl;
- tl.move(v, 100., 1000.);
- // 500 ms passes
- // v.value() == 50.
- tl.complete();
- // v.value() == 100.
- \endcode
-*/
-void QmlTimeLine::complete()
-{
- d->advance(d->length);
-}
-
-/*!
- Resets the timeline. All queued actions are discarded and QmlTimeLineValue's retain their current value. For example,
- \code
- QmlTimeLineValue v(0.);
- QmlTimeLine tl;
- tl.move(v, 100., 1000.);
- // 500 ms passes
- // v.value() == 50.
- tl.clear();
- // v.value() == 50.
- \endcode
-*/
-void QmlTimeLine::clear()
-{
- for (QmlTimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter)
- iter.key()->_t = 0;
- d->ops.clear();
- d->length = 0;
- d->syncPoint = 0;
- //XXX need stop here?
-}
-
-int QmlTimeLine::time() const
-{
- return d->prevTime;
-}
-
-/*!
- \fn void QmlTimeLine::updated()
-
- Emitted each time the timeline modifies QmlTimeLineValues. Even if multiple
- QmlTimeLineValues are changed, this signal is only emitted once for each clock tick.
-*/
-
-void QmlTimeLine::updateCurrentTime(int v)
-{
- if (d->syncAdj == -1)
- d->syncAdj = v;
- v -= d->syncAdj;
-
- int timeChanged = v - d->prevTime;
-#if 0
- if (!timeChanged)
- return;
-#endif
- d->prevTime = v;
- d->advance(timeChanged);
- emit updated();
-
- // Do we need to stop the clock?
- if (d->ops.isEmpty()) {
- stop();
- d->prevTime = 0;
- d->clockRunning = false;
- emit completed();
- } /*else if (pauseTime > 0) {
- GfxClock::cancelClock();
- d->prevTime = 0;
- GfxClock::pauseFor(pauseTime);
- d->syncAdj = 0;
- d->clockRunning = false;
- }*/ else if (/*!GfxClock::isActive()*/ state() != Running) {
- stop();
- d->prevTime = 0;
- d->clockRunning = true;
- d->syncAdj = 0;
- start();
- }
-}
-
-bool operator<(const QPair<int, Update> &lhs,
- const QPair<int, Update> &rhs)
-{
- return lhs.first < rhs.first;
-}
-
-int QmlTimeLinePrivate::advance(int t)
-{
- int pauseTime = -1;
-
- // XXX - surely there is a more efficient way?
- do {
- pauseTime = -1;
- // Minimal advance time
- int advanceTime = t;
- for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) {
- TimeLine &tl = *iter;
- Op &op = tl.ops.first();
- int length = op.length - tl.consumedOpLength;
-
- if (length < advanceTime) {
- advanceTime = length;
- if (advanceTime == 0)
- break;
- }
- }
- t -= advanceTime;
-
- // Process until then. A zero length advance time will only process
- // sets.
- QList<QPair<int, Update> > updates;
-
- for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
- QmlTimeLineValue *v = static_cast<QmlTimeLineValue *>(iter.key());
- TimeLine &tl = *iter;
- Q_ASSERT(!tl.ops.isEmpty());
-
- do {
- Op &op = tl.ops.first();
- if (advanceTime == 0 && op.length != 0)
- continue;
-
- if (tl.consumedOpLength == 0 &&
- op.type != Op::Pause &&
- op.type != Op::Execute)
- tl.base = v->value();
-
- if ((tl.consumedOpLength + advanceTime) == op.length) {
- if (op.type == Op::Execute) {
- updates << qMakePair(op.order, Update(op.event));
- } else {
- bool changed = false;
- qreal val = value(op, op.length, tl.base, &changed);
- if (changed)
- updates << qMakePair(op.order, Update(v, val));
- }
- tl.length -= qMin(advanceTime, tl.length);
- tl.consumedOpLength = 0;
- tl.ops.removeFirst();
- } else {
- tl.consumedOpLength += advanceTime;
- bool changed = false;
- qreal val = value(op, tl.consumedOpLength, tl.base, &changed);
- if (changed)
- updates << qMakePair(op.order, Update(v, val));
- tl.length -= qMin(advanceTime, tl.length);
- break;
- }
-
- } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0);
-
-
- if (tl.ops.isEmpty()) {
- iter = ops.erase(iter);
- v->_t = 0;
- } else {
- if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
- int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
- if (pauseTime == -1 || opPauseTime < pauseTime)
- pauseTime = opPauseTime;
- } else {
- pauseTime = 0;
- }
- ++iter;
- }
- }
-
- length -= qMin(length, advanceTime);
- syncPoint -= advanceTime;
-
- qSort(updates.begin(), updates.end());
- updateQueue = &updates;
- for (int ii = 0; ii < updates.count(); ++ii) {
- const Update &v = updates.at(ii).second;
- if (v.g) {
- v.g->setValue(v.v);
- } else {
- v.e.d0(v.e.d1);
- }
- }
- updateQueue = 0;
- } while(t);
-
- return pauseTime;
-}
-
-void QmlTimeLine::remove(QmlTimeLineObject *v)
-{
- QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(v);
- Q_ASSERT(iter != d->ops.end());
-
- int len = iter->length;
- d->ops.erase(iter);
- if (len == d->length) {
- // We need to recalculate the length
- d->length = 0;
- for (QmlTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
- iter != d->ops.end();
- ++iter) {
-
- if (iter->length > d->length)
- d->length = iter->length;
-
- }
- }
- if (d->ops.isEmpty()) {
- stop();
- d->clockRunning = false;
- } else if (/*!GfxClock::isActive()*/ state() != Running) {
- stop();
- d->prevTime = 0;
- d->clockRunning = true;
-
- if (d->syncMode == QmlTimeLine::LocalSync) {
- d->syncAdj = -1;
- } else {
- d->syncAdj = 0;
- }
- start();
- }
-
- if (d->updateQueue) {
- for (int ii = 0; ii < d->updateQueue->count(); ++ii) {
- if (d->updateQueue->at(ii).second.g == v ||
- d->updateQueue->at(ii).second.e.callbackObject() == v) {
- d->updateQueue->removeAt(ii);
- --ii;
- }
- }
- }
-
-
-}
-
-/*!
- \internal
- \class QmlTimeLineValue
- \ingroup group_animation
- \brief The QmlTimeLineValue class provides a value that can be modified by QmlTimeLine.
-*/
-
-/*!
- \fn QmlTimeLineValue::QmlTimeLineValue(qreal value = 0)
-
- Construct a new QmlTimeLineValue with an initial \a value.
-*/
-
-/*!
- \fn qreal QmlTimeLineValue::value() const
-
- Return the current value.
-*/
-
-/*!
- \fn void QmlTimeLineValue::setValue(qreal value)
-
- Set the current \a value.
-*/
-
-/*!
- \fn QmlTimeLine *QmlTimeLineValue::timeLine() const
-
- If a QmlTimeLine is operating on this value, return a pointer to it,
- otherwise return null.
-*/
-
-
-QmlTimeLineObject::QmlTimeLineObject()
-: _t(0)
-{
-}
-
-QmlTimeLineObject::~QmlTimeLineObject()
-{
- if (_t) {
- _t->remove(this);
- _t = 0;
- }
-}
-
-QmlTimeLineCallback::QmlTimeLineCallback()
-: d0(0), d1(0), d2(0)
-{
-}
-
-QmlTimeLineCallback::QmlTimeLineCallback(QmlTimeLineObject *b, Callback f, void *d)
-: d0(f), d1(d), d2(b)
-{
-}
-
-QmlTimeLineCallback::QmlTimeLineCallback(const QmlTimeLineCallback &o)
-: d0(o.d0), d1(o.d1), d2(o.d2)
-{
-}
-
-QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o)
-{
- d0 = o.d0;
- d1 = o.d1;
- d2 = o.d2;
- return *this;
-}
-
-QmlTimeLineObject *QmlTimeLineCallback::callbackObject() const
-{
- return d2;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h
deleted file mode 100644
index 076355d74b..0000000000
--- a/src/declarative/util/qmltimeline_p_p.h
+++ /dev/null
@@ -1,200 +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 QMLTIMELINE_H
-#define QMLTIMELINE_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>
-#include <QtCore/QAbstractAnimation>
-
-QT_BEGIN_NAMESPACE
-
-class QEasingCurve;
-class QmlTimeLineValue;
-class QmlTimeLineCallback;
-struct QmlTimeLinePrivate;
-class QmlTimeLineObject;
-class QmlTimeLine : public QAbstractAnimation
-{
-Q_OBJECT
-public:
- QmlTimeLine(QObject *parent = 0);
- ~QmlTimeLine();
-
- enum SyncMode { LocalSync, GlobalSync };
- SyncMode syncMode() const;
- void setSyncMode(SyncMode);
-
- void pause(QmlTimeLineObject &, int);
- void callback(const QmlTimeLineCallback &);
- void set(QmlTimeLineValue &, qreal);
-
- int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
- int accel(QmlTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
- int accelDistance(QmlTimeLineValue &, qreal velocity, qreal distance);
-
- void move(QmlTimeLineValue &, qreal destination, int time = 500);
- void move(QmlTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
- void moveBy(QmlTimeLineValue &, qreal change, int time = 500);
- void moveBy(QmlTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
-
- void sync();
- void setSyncPoint(int);
- int syncPoint() const;
-
- void sync(QmlTimeLineValue &);
- void sync(QmlTimeLineValue &, QmlTimeLineValue &);
-
- void reset(QmlTimeLineValue &);
-
- void complete();
- void clear();
- bool isActive() const;
-
- int time() const;
-
- virtual int duration() const;
-Q_SIGNALS:
- void updated();
- void completed();
-
-protected:
- virtual void updateCurrentTime(int);
-
-private:
- void remove(QmlTimeLineObject *);
- friend class QmlTimeLineObject;
- friend struct QmlTimeLinePrivate;
- QmlTimeLinePrivate *d;
-};
-
-class QmlTimeLineObject
-{
-public:
- QmlTimeLineObject();
- virtual ~QmlTimeLineObject();
-
-protected:
- friend class QmlTimeLine;
- friend struct QmlTimeLinePrivate;
- QmlTimeLine *_t;
-};
-
-class QmlTimeLineValue : public QmlTimeLineObject
-{
-public:
- QmlTimeLineValue(qreal v = 0.) : _v(v) {}
-
- virtual qreal value() const { return _v; }
- virtual void setValue(qreal v) { _v = v; }
-
- QmlTimeLine *timeLine() const { return _t; }
-
- operator qreal() const { return _v; }
- QmlTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
-private:
- friend class QmlTimeLine;
- friend struct QmlTimeLinePrivate;
- qreal _v;
-};
-
-class QmlTimeLineCallback
-{
-public:
- typedef void (*Callback)(void *);
-
- QmlTimeLineCallback();
- QmlTimeLineCallback(QmlTimeLineObject *b, Callback, void * = 0);
- QmlTimeLineCallback(const QmlTimeLineCallback &o);
-
- QmlTimeLineCallback &operator=(const QmlTimeLineCallback &o);
- QmlTimeLineObject *callbackObject() const;
-
-private:
- friend class QmlTimeLinePrivate;
- Callback d0;
- void *d1;
- QmlTimeLineObject *d2;
-};
-
-template<class T>
-class QmlTimeLineValueProxy : public QmlTimeLineValue
-{
-public:
- QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
- : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
- {
- Q_ASSERT(_class);
- }
-
- QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
- : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
- {
- Q_ASSERT(_class);
- }
-
- virtual void setValue(qreal v)
- {
- QmlTimeLineValue::setValue(v);
- if (_setFunctionReal) (_class->*_setFunctionReal)(v);
- else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v);
- }
-
-private:
- T *_class;
- void (T::*_setFunctionReal)(qreal);
- void (T::*_setFunctionInt)(int);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp
deleted file mode 100644
index 1779b222de..0000000000
--- a/src/declarative/util/qmltimer.cpp
+++ /dev/null
@@ -1,314 +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 "qmltimer_p.h"
-
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qpauseanimation.h>
-#include <qdebug.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,Timer,QmlTimer)
-
-class QmlTimerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlTimer)
-public:
- QmlTimerPrivate()
- : interval(1000), running(false), repeating(false), triggeredOnStart(false)
- , classBegun(false), componentComplete(false), firstTick(true) {}
- int interval;
- QPauseAnimation pause;
- bool running : 1;
- bool repeating : 1;
- bool triggeredOnStart : 1;
- bool classBegun : 1;
- bool componentComplete : 1;
- bool firstTick : 1;
-};
-
-/*!
- \qmlclass Timer QmlTimer
- \since 4.7
- \brief The Timer item triggers a handler at a specified interval.
-
- A timer can be used to trigger an action either once, or repeatedly
- at a given interval.
-
- Here is a timer that shows the current date and time, and updates
- the text every 500 milliseconds:
-
- \qml
- Timer {
- interval: 500; running: true; repeat: true
- onTriggered: time.text = Date().toString()
- }
- Text {
- id: time
- }
- \endqml
-
- QmlTimer is synchronized with the animation timer. Since the animation
- timer is usually set to 60fps, the resolution of QmlTimer will be
- at best 16ms.
-
- If the Timer is running and one of its properties is changed, the
- elapsed time will be reset. For example, if a Timer with interval of
- 1000ms has its \e repeat property changed 500ms after starting, the
- elapsed time will be reset to 0, and the Timer will be triggered
- 1000ms later.
-*/
-
-QmlTimer::QmlTimer(QObject *parent)
- : QObject(*(new QmlTimerPrivate), parent)
-{
- Q_D(QmlTimer);
- connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked()));
- connect(&d->pause, SIGNAL(finished()), this, SLOT(finished()));
- d->pause.setLoopCount(1);
- d->pause.setDuration(d->interval);
-}
-
-/*!
- \qmlproperty int Timer::interval
-
- Sets the \a interval between triggers, in milliseconds.
-
- The default interval is 1000 milliseconds.
-*/
-void QmlTimer::setInterval(int interval)
-{
- Q_D(QmlTimer);
- if (interval != d->interval) {
- d->interval = interval;
- update();
- }
-}
-
-int QmlTimer::interval() const
-{
- Q_D(const QmlTimer);
- return d->interval;
-}
-
-/*!
- \qmlproperty bool Timer::running
-
- If set to true, starts the timer; otherwise stops the timer.
- For a non-repeating timer, \a running is set to false after the
- timer has been triggered.
-
- \a running defaults to false.
-
- \sa repeat
-*/
-bool QmlTimer::isRunning() const
-{
- Q_D(const QmlTimer);
- return d->running;
-}
-
-void QmlTimer::setRunning(bool running)
-{
- Q_D(QmlTimer);
- if (d->running != running) {
- d->running = running;
- d->firstTick = true;
- emit runningChanged();
- update();
- }
-}
-
-/*!
- \qmlproperty bool Timer::repeat
-
- If \a repeat is true the timer is triggered repeatedly at the
- specified interval; otherwise, the timer will trigger once at the
- specified interval and then stop (i.e. running will be set to false).
-
- \a repeat defaults to false.
-
- \sa running
-*/
-bool QmlTimer::isRepeating() const
-{
- Q_D(const QmlTimer);
- return d->repeating;
-}
-
-void QmlTimer::setRepeating(bool repeating)
-{
- Q_D(QmlTimer);
- if (repeating != d->repeating) {
- d->repeating = repeating;
- update();
- }
-}
-
-/*!
- \qmlproperty bool Timer::triggeredOnStart
-
- When a timer is started, the first trigger is usually after the specified
- interval has elapsed. It is sometimes desirable to trigger immediately
- when the timer is started; for example, to establish an initial
- state.
-
- If \a triggeredOnStart is true, the timer is triggered immediately
- when started, and subsequently at the specified interval. Note that if
- \e repeat is set to false, the timer is triggered twice; once on start,
- and again at the interval.
-
- \a triggeredOnStart defaults to false.
-
- \sa running
-*/
-bool QmlTimer::triggeredOnStart() const
-{
- Q_D(const QmlTimer);
- return d->triggeredOnStart;
-}
-
-void QmlTimer::setTriggeredOnStart(bool triggeredOnStart)
-{
- Q_D(QmlTimer);
- if (d->triggeredOnStart != triggeredOnStart) {
- d->triggeredOnStart = triggeredOnStart;
- update();
- }
-}
-
-/*!
- \qmlmethod Timer::start()
- \brief Starts the timer.
-
- If the timer is already running, calling this method has no effect. The
- \c running property will be true following a call to \c start().
-*/
-void QmlTimer::start()
-{
- setRunning(true);
-}
-
-/*!
- \qmlmethod Timer::stop()
- \brief Stops the timer.
-
- If the timer is not running, calling this method has no effect. The
- \c running property will be false following a call to \c stop().
-*/
-void QmlTimer::stop()
-{
- setRunning(false);
-}
-
-/*!
- \qmlmethod Timer::restart()
- \brief Restarts the timer.
-
- If the Timer is not running it will be started, otherwise it will be
- stopped, reset to initial state and started. The \c running property
- will be true following a call to \c restart().
-*/
-void QmlTimer::restart()
-{
- setRunning(false);
- setRunning(true);
-}
-
-void QmlTimer::update()
-{
- Q_D(QmlTimer);
- if (d->classBegun && !d->componentComplete)
- return;
- d->pause.stop();
- if (d->running) {
- d->pause.setCurrentTime(0);
- d->pause.setLoopCount(d->repeating ? -1 : 1);
- d->pause.setDuration(d->interval);
- d->pause.start();
- if (d->triggeredOnStart && d->firstTick) {
- QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
- QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection);
- }
- }
-}
-
-void QmlTimer::classBegin()
-{
- Q_D(QmlTimer);
- d->classBegun = true;
-}
-
-void QmlTimer::componentComplete()
-{
- Q_D(QmlTimer);
- d->componentComplete = true;
- update();
-}
-
-/*!
- \qmlsignal Timer::onTriggered()
-
- This handler is called when the Timer is triggered.
-*/
-void QmlTimer::ticked()
-{
- Q_D(QmlTimer);
- if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick)))
- emit triggered();
- d->firstTick = false;
-}
-
-void QmlTimer::finished()
-{
- Q_D(QmlTimer);
- if (d->repeating || !d->running)
- return;
- emit triggered();
- d->running = false;
- d->firstTick = false;
- emit runningChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltimer_p.h b/src/declarative/util/qmltimer_p.h
deleted file mode 100644
index d1c5ee566f..0000000000
--- a/src/declarative/util/qmltimer_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 QMLTIMER_H
-#define QMLTIMER_H
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-#include <QtCore/qabstractanimation.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlTimerPrivate;
-class Q_DECLARATIVE_EXPORT QmlTimer : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlTimer)
- Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(int interval READ interval WRITE setInterval)
- Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating)
- Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart)
-
-public:
- QmlTimer(QObject *parent=0);
-
- void setInterval(int interval);
- int interval() const;
-
- bool isRunning() const;
- void setRunning(bool running);
-
- bool isRepeating() const;
- void setRepeating(bool repeating);
-
- bool triggeredOnStart() const;
- void setTriggeredOnStart(bool triggeredOnStart);
-
-protected:
- void classBegin();
- void componentComplete();
-
-public Q_SLOTS:
- void start();
- void stop();
- void restart();
-
-Q_SIGNALS:
- void triggered();
- void runningChanged();
-
-private:
- void update();
-
-private Q_SLOTS:
- void ticked();
- void finished();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlTimer)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
deleted file mode 100644
index e2ce417aee..0000000000
--- a/src/declarative/util/qmltransition.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "qmlstate_p.h"
-#include "qmlstategroup_p.h"
-#include "qmlstate_p_p.h"
-#include "qmlstateoperations_p.h"
-#include "qmlanimation_p.h"
-#include "qmlanimation_p_p.h"
-#include "qmltransitionmanager_p_p.h"
-
-#include <QParallelAnimationGroup>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Transition QmlTransition
- \since 4.7
- \brief The Transition element defines animated transitions that occur on state changes.
-
- \sa {qmlstates}{States}, {state-transitions}{Transitions}
-*/
-
-/*!
- \internal
- \class QmlTransition
- \brief The QmlTransition class allows you to define animated transitions that occur on state changes.
-
- \ingroup group_states
-*/
-
-//ParallelAnimationWrapperallows us to do a "callback" when the animation finishes, rather than connecting
-//and disconnecting signals and slots frequently
-class ParallelAnimationWrapper : public QParallelAnimationGroup
-{
- Q_OBJECT
-public:
- ParallelAnimationWrapper(QObject *parent = 0) : QParallelAnimationGroup(parent) {}
- QmlTransitionPrivate *trans;
-protected:
- virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
-};
-
-class QmlTransitionPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlTransition)
-public:
- QmlTransitionPrivate()
- : fromState(QLatin1String("*")), toState(QLatin1String("*")),
- reversed(false), reversible(false), endState(0)
- {
- group.trans = this;
- }
-
- QString fromState;
- QString toState;
- bool reversed;
- bool reversible;
- ParallelAnimationWrapper group;
- QmlTransitionManager *endState;
-
- void complete()
- {
- endState->complete();
- }
- static void append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a);
- QList<QmlAbstractAnimation *> animations;
-};
-
-void QmlTransitionPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a)
-{
- QmlTransition *q = static_cast<QmlTransition *>(list->object);
- q->d_func()->animations.append(a);
- q->d_func()->group.addAnimation(a->qtAnimation());
- a->setDisableUserControl();
-}
-
-void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
-{
- QParallelAnimationGroup::updateState(newState, oldState);
- if (newState == Stopped &&
- ((direction() == QAbstractAnimation::Forward && currentLoopTime() == duration()) ||
- (direction() == QAbstractAnimation::Backward && currentLoopTime() == 0)))
- {
- trans->complete();
- }
-}
-
-
-QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition)
-QmlTransition::QmlTransition(QObject *parent)
- : QObject(*(new QmlTransitionPrivate), parent)
-{
-}
-
-QmlTransition::~QmlTransition()
-{
-}
-
-void QmlTransition::stop()
-{
- Q_D(QmlTransition);
- d->group.stop();
-}
-
-void QmlTransition::setReversed(bool r)
-{
- Q_D(QmlTransition);
- d->reversed = r;
-}
-
-void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
- QList<QmlMetaProperty> &after,
- QmlTransitionManager *endState)
-{
- Q_D(QmlTransition);
-
- qmlExecuteDeferred(this);
-
- if (d->reversed) {
- for (int ii = d->animations.count() - 1; ii >= 0; --ii) {
- d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Backward);
- }
- } else {
- for (int ii = 0; ii < d->animations.count(); ++ii) {
- d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward);
- }
- }
-
- d->endState = endState;
- d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
- d->group.start();
-}
-
-/*!
- \qmlproperty string Transition::from
- \qmlproperty string Transition::to
- These properties are selectors indicating which state changes should trigger the transition.
-
- from is used in conjunction with to to determine when a transition should
- be applied. By default from and to are both "*" (any state). In the following example,
- the transition is applied when changing from state1 to state2.
- \code
- Transition {
- from: "state1"
- to: "state2"
- ...
- }
- \endcode
-*/
-QString QmlTransition::fromState() const
-{
- Q_D(const QmlTransition);
- return d->fromState;
-}
-
-void QmlTransition::setFromState(const QString &f)
-{
- Q_D(QmlTransition);
- d->fromState = f;
-}
-
-/*!
- \qmlproperty bool Transition::reversible
- This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed.
-
- The default value is false.
-*/
-bool QmlTransition::reversible() const
-{
- Q_D(const QmlTransition);
- return d->reversible;
-}
-
-void QmlTransition::setReversible(bool r)
-{
- Q_D(QmlTransition);
- d->reversible = r;
-}
-
-QString QmlTransition::toState() const
-{
- Q_D(const QmlTransition);
- return d->toState;
-}
-
-void QmlTransition::setToState(const QString &t)
-{
- Q_D(QmlTransition);
- d->toState = t;
-}
-
-/*!
- \qmlproperty list<Animation> Transition::animations
- \default
- This property holds a list of the animations to be run for this transition.
-
- The top-level animations are run in parallel. To run them sequentially,
- you can create a single SequentialAnimation which contains all the animations,
- and assign that to animations the animations property.
- \default
-*/
-QmlListProperty<QmlAbstractAnimation> QmlTransition::animations()
-{
- Q_D(QmlTransition);
- return QmlListProperty<QmlAbstractAnimation>(this, &d->animations, QmlTransitionPrivate::append_animation);
-}
-
-QT_END_NAMESPACE
-
-#include <qmltransition.moc>
diff --git a/src/declarative/util/qmltransition_p.h b/src/declarative/util/qmltransition_p.h
deleted file mode 100644
index ea02a33b20..0000000000
--- a/src/declarative/util/qmltransition_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 QMLTRANSITION_H
-#define QMLTRANSITION_H
-
-#include "qmlstate_p.h"
-
-#include <qml.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlAbstractAnimation;
-class QmlTransitionPrivate;
-class QmlTransitionManager;
-class Q_DECLARATIVE_EXPORT QmlTransition : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlTransition)
-
- Q_PROPERTY(QString from READ fromState WRITE setFromState)
- Q_PROPERTY(QString to READ toState WRITE setToState)
- Q_PROPERTY(bool reversible READ reversible WRITE setReversible)
- Q_PROPERTY(QmlListProperty<QmlAbstractAnimation> animations READ animations)
- Q_CLASSINFO("DefaultProperty", "animations")
- Q_CLASSINFO("DeferredPropertyNames", "animations")
-
-public:
- QmlTransition(QObject *parent=0);
- ~QmlTransition();
-
- QString fromState() const;
- void setFromState(const QString &);
-
- QString toState() const;
- void setToState(const QString &);
-
- bool reversible() const;
- void setReversible(bool);
-
- QmlListProperty<QmlAbstractAnimation> animations();
-
- void prepare(QmlStateOperation::ActionList &actions,
- QList<QmlMetaProperty> &after,
- QmlTransitionManager *end);
-
- void setReversed(bool r);
- void stop();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlTransition)
-
-QT_END_HEADER
-
-#endif // QMLTRANSITION_H
diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp
deleted file mode 100644
index f2a4d644cb..0000000000
--- a/src/declarative/util/qmltransitionmanager.cpp
+++ /dev/null
@@ -1,282 +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 "qmltransitionmanager_p_p.h"
-
-#include "qmlstate_p_p.h"
-
-#include <qmlbinding.h>
-#include <qmlglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-
-class QmlTransitionManagerPrivate
-{
-public:
- QmlTransitionManagerPrivate()
- : state(0), transition(0) {}
-
- void applyBindings();
- typedef QList<QmlSimpleAction> SimpleActionList;
- QmlState *state;
- QmlTransition *transition;
- QmlStateOperation::ActionList bindingsList;
- SimpleActionList completeList;
-};
-
-QmlTransitionManager::QmlTransitionManager()
-: d(new QmlTransitionManagerPrivate)
-{
-}
-
-void QmlTransitionManager::setState(QmlState *s)
-{
- d->state = s;
-}
-
-QmlTransitionManager::~QmlTransitionManager()
-{
- delete d; d = 0;
-}
-
-void QmlTransitionManager::complete()
-{
- d->applyBindings();
-
- for (int ii = 0; ii < d->completeList.count(); ++ii) {
- const QmlMetaProperty &prop = d->completeList.at(ii).property;
- prop.write(d->completeList.at(ii).value);
- }
-
- d->completeList.clear();
-
- if (d->state)
- static_cast<QmlStatePrivate*>(QObjectPrivate::get(d->state))->complete();
-}
-
-void QmlTransitionManagerPrivate::applyBindings()
-{
- foreach(const QmlAction &action, bindingsList) {
- if (action.toBinding) {
- action.property.setBinding(action.toBinding);
- } else if (action.event) {
- if (action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- }
-
- }
-
- bindingsList.clear();
-}
-
-void QmlTransitionManager::transition(const QList<QmlAction> &list,
- QmlTransition *transition)
-{
- cancel();
-
- QmlStateOperation::ActionList applyList = list;
- // Determine which actions are binding changes.
- foreach(const QmlAction &action, applyList) {
- if (action.toBinding)
- d->bindingsList << action;
- if (action.fromBinding)
- action.property.setBinding(0); // Disable current binding
- if (action.event && action.event->changesBindings()) { //### assume isReversable()?
- d->bindingsList << action;
- if (action.reverseEvent)
- action.event->clearReverseBindings();
- else
- action.event->clearForwardBindings();
- }
- }
-
- // Animated transitions need both the start and the end value for
- // each property change. In the presence of bindings, the end values
- // are non-trivial to calculate. As a "best effort" attempt, we first
- // apply all the property and binding changes, then read all the actual
- // final values, then roll back the changes and proceed as normal.
- //
- // This doesn't catch everything, and it might be a little fragile in
- // some cases - but whatcha going to do?
-
- if (!d->bindingsList.isEmpty()) {
-
- //### do extra actions here?
-
- // Apply all the property and binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- const QmlAction &action = applyList.at(ii);
- if (action.toBinding) {
- action.property.setBinding(action.toBinding, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- } else if (!action.event) {
- action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- } else if (action.event->isReversable()) {
- if (action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- applyList << action.event->extraActions();
- }
- }
-
- // Read all the end values for binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- QmlAction *action = &applyList[ii];
- if (action->event)
- continue;
- const QmlMetaProperty &prop = action->property;
- if (action->toBinding || !action->toValue.isValid()) { //### is this always right (used for exta actions)
- action->toValue = prop.read();
- }
- }
-
- // Revert back to the original values
- foreach(const QmlAction &action, applyList) {
- if (action.event) {
- if (action.event->isReversable()) {
- if (action.reverseEvent) { //reverse the reverse
- action.event->clearForwardBindings();
- action.event->rewind();
- action.event->clearReverseBindings();
- } else {
- action.event->clearReverseBindings();
- action.event->rewind();
- action.event->clearForwardBindings();
- }
- }
- continue;
- }
-
- if (action.toBinding)
- action.property.setBinding(0); // Make sure this is disabled during the transition
-
- action.property.write(action.fromValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
- }
-
- if (transition) {
- QList<QmlMetaProperty> touched;
- d->transition = transition;
- d->transition->prepare(applyList, touched, this);
-
- // Modify the action list to remove actions handled in the transition
- for (int ii = 0; ii < applyList.count(); ++ii) {
- const QmlAction &action = applyList.at(ii);
-
- if (action.event) {
-
- if (action.actionDone) {
- applyList.removeAt(ii);
- --ii;
- }
-
- } else {
-
- if (touched.contains(action.property)) {
- if (action.toValue != action.fromValue)
- d->completeList <<
- QmlSimpleAction(action, QmlSimpleAction::EndState);
-
- applyList.removeAt(ii);
- --ii;
- }
-
- }
- }
- }
-
- // Any actions remaining have not been handled by the transition and should
- // be applied immediately. We skip applying bindings, as they are all
- // applied at the end in applyBindings() to avoid any nastiness mid
- // transition
- foreach(const QmlAction &action, applyList) {
- if (action.event && !action.event->changesBindings()) {
- if (action.event->isReversable() && action.reverseEvent)
- action.event->reverse();
- else
- action.event->execute();
- } else if (!action.event && !action.toBinding) {
- action.property.write(action.toValue);
- }
- }
- if (stateChangeDebug()) {
- foreach(const QmlAction &action, applyList) {
- if (action.event)
- qWarning() << " No transition for event:" << action.event->typeName();
- else
- qWarning() << " No transition for:" << action.property.object()
- << action.property.name() << "From:" << action.fromValue
- << "To:" << action.toValue;
- }
- }
- if (!transition)
- d->applyBindings();
-}
-
-void QmlTransitionManager::cancel()
-{
- if (d->transition) {
- // ### this could potentially trigger a complete in rare circumstances
- d->transition->stop();
- d->transition = 0;
- }
-
- for(int i = 0; i < d->bindingsList.count(); ++i) {
- QmlAction action = d->bindingsList[i];
- if (action.toBinding && action.deletableToBinding) {
- action.property.setBinding(0);
- action.toBinding->destroy();
- action.toBinding = 0;
- action.deletableToBinding = false;
- } else if (action.event) {
- //### what do we do here?
- }
-
- }
- d->bindingsList.clear();
- d->completeList.clear();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltransitionmanager_p_p.h b/src/declarative/util/qmltransitionmanager_p_p.h
deleted file mode 100644
index 19ee7068de..0000000000
--- a/src/declarative/util/qmltransitionmanager_p_p.h
+++ /dev/null
@@ -1,85 +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 QMLTRANSITIONMANAGER_P_H
-#define QMLTRANSITIONMANAGER_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 "qmlstateoperations_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlStatePrivate;
-class QmlTransitionManagerPrivate;
-class QmlTransitionManager
-{
-public:
- QmlTransitionManager();
- ~QmlTransitionManager();
-
- void transition(const QList<QmlAction> &, QmlTransition *transition);
-
- void cancel();
-
-private:
- Q_DISABLE_COPY(QmlTransitionManager);
- QmlTransitionManagerPrivate *d;
-
- void complete();
- void setState(QmlState *);
-
- friend class QmlState;
- friend class QmlTransitionPrivate;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMLTRANSITIONMANAGER_P_H
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
deleted file mode 100644
index 632e8e2a76..0000000000
--- a/src/declarative/util/qmlview.cpp
+++ /dev/null
@@ -1,556 +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 "qmlview.h"
-
-#include "qperformancelog_p_p.h"
-#include "qfxperf_p_p.h"
-
-#include <qml.h>
-#include <qmlgraphicsitem.h>
-#include <qmlengine.h>
-#include <qmlcontext.h>
-#include <qmldebug_p.h>
-#include <qmldebugservice_p.h>
-#include <qmlglobal_p.h>
-
-#include <qscriptvalueiterator.h>
-#include <qdebug.h>
-#include <qtimer.h>
-#include <qevent.h>
-#include <qdir.h>
-#include <qcoreapplication.h>
-#include <qfontdatabase.h>
-#include <qicon.h>
-#include <qurl.h>
-#include <qboxlayout.h>
-#include <qbasictimer.h>
-#include <QtCore/qabstractanimation.h>
-#include <private/qgraphicsview_p.h>
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
-
-class QmlViewDebugServer;
-class FrameBreakAnimation : public QAbstractAnimation
-{
-public:
- FrameBreakAnimation(QmlViewDebugServer *s)
- : QAbstractAnimation((QObject*)s), server(s)
- {
- start();
- }
-
- virtual int duration() const { return -1; }
- virtual void updateCurrentTime(int msecs);
-
-private:
- QmlViewDebugServer *server;
-};
-
-class QmlViewDebugServer : public QmlDebugService
-{
-public:
- QmlViewDebugServer(QObject *parent = 0) : QmlDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0)
- {
- timer.start();
- new FrameBreakAnimation(this);
- }
-
- void addTiming(int pe, int tbf)
- {
- if (!isEnabled())
- return;
-
- bool isFrameBreak = breaks > 1;
- breaks = 0;
- int e = timer.elapsed();
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)pe << (int)tbf << (int)e
- << (bool)isFrameBreak;
- sendMessage(data);
- }
-
- void frameBreak() { ++breaks; }
-
-private:
- QTime timer;
- int breaks;
-};
-
-Q_GLOBAL_STATIC(QmlViewDebugServer, qfxViewDebugServer);
-
-void FrameBreakAnimation::updateCurrentTime(int msecs)
-{
- Q_UNUSED(msecs);
- server->frameBreak();
-}
-
-class QmlViewPrivate
-{
-public:
- QmlViewPrivate(QmlView *view)
- : q(view), root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {}
-
- QmlView *q;
-
- QGuard<QGraphicsObject> root;
- QGuard<QmlGraphicsItem> qmlRoot;
-
- QUrl source;
-
- QmlEngine engine;
- QmlComponent *component;
- QBasicTimer resizetimer;
-
- mutable QSize initialSize;
- QmlView::ResizeMode resizeMode;
- QTime frameTimer;
-
- void init();
-
- QGraphicsScene scene;
-};
-
-/*!
- \class QmlView
- \since 4.7
- \brief The QmlView class provides a widget for displaying a Qt Declarative user interface.
-
- Any QGraphicsObject or QmlGraphicsItem
- created via QML can be placed on a standard QGraphicsScene and viewed with a standard
- QGraphicsView.
-
- QmlView is a QGraphicsView subclass provided as a convenience for displaying QML
- files, and connecting between QML and C++ Qt objects.
-
- QmlView performs the following functions:
-
- \list
- \o Manages QmlComponent loading and object creation.
- \o Initializes QGraphicsView for optimal performance with QML:
- \list
- \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState);
- \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex);
- \endlist
- \o Initializes QGraphicsView for QML key handling:
- \list
- \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
- \o QGraphicsScene::setStickyFocus(true);
- \endlist
- \endlist
-
- Typical usage:
- \code
- ...
- QmlView *view = new QmlView(this);
- vbox->addWidget(view);
-
- QUrl url(fileName);
- view->setSource(url);
- ...
- view->execute();
- ...
- view->show();
- \endcode
-
- To receive errors related to loading and executing QML with QmlView,
- you can connect to the statusChanged() signal and monitor for QmlView::Error.
- The errors are available via QmlView::errors().
-*/
-
-
-/*! \fn void QmlView::sceneResized(QSize size)
- This signal is emitted when the view is resized to \a size.
-*/
-
-/*! \fn void QmlView::statusChanged(QmlView::Status status)
- This signal is emitted when the component's current \l{QmlView::Status} {status} changes.
-*/
-
-/*!
- \fn QmlView::QmlView(QWidget *parent)
-
- Constructs a QmlView with the given \a parent.
-*/
-QmlView::QmlView(QWidget *parent)
-: QGraphicsView(parent), d(new QmlViewPrivate(this))
-{
- setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
- d->init();
-}
-
-void QmlViewPrivate::init()
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- {
- QmlPerfTimer<QmlPerf::FontDatabase> perf;
- QFontDatabase database;
- }
-#endif
-
- q->setScene(&scene);
-
- q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
- q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- q->setFrameStyle(0);
-
- // These seem to give the best performance
- q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- q->viewport()->setFocusPolicy(Qt::NoFocus);
-
- scene.setStickyFocus(true); //### needed for correct focus handling
-}
-
-/*!
- The destructor clears the view's \l {QGraphicsObject} {items} and
- deletes the internal representation.
- */
-QmlView::~QmlView()
-{
- delete d->root;
-}
-
-/*!
- Sets the source to the \a url.
-
- Call \l execute() to load the QML and instantiate the component.
-
- \sa execute()
- */
-void QmlView::setSource(const QUrl& url)
-{
- d->source = url;
-}
-
-/*!
- Returns the source URL, if set.
-
- \sa setSource()
- */
-QUrl QmlView::source() const
-{
- return d->source;
-}
-
-/*!
- Returns a pointer to the QmlEngine used for instantiating
- QML Components.
- */
-QmlEngine* QmlView::engine()
-{
- return &d->engine;
-}
-
-/*!
- This function returns the root of the context hierarchy. 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.
- */
-QmlContext* QmlView::rootContext()
-{
- return d->engine.rootContext();
-}
-
-/*!
- Loads and instantiates the QML component set by the \l setSource() method.
-
- \sa setSource()
-*/
-void QmlView::execute()
-{
- delete d->root;
- delete d->component;
- d->component = new QmlComponent(&d->engine, d->source, this);
-
- if (!d->component->isLoading()) {
- continueExecute();
- } else {
- connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
- }
-}
-
-/*!
- \enum QmlView::Status
-
- Specifies the loading status of the QmlView.
-
- \value Null This QmlView has no source set.
- \value Ready This QmlView has loaded and created the QML component.
- \value Loading This QmlView is loading network data.
- \value Error An error has occured. Calling errorDescription() to retrieve a description.
-*/
-
-/*!
- \property QmlView::status
- The component's current \l{QmlView::Status} {status}.
-*/
-
-QmlView::Status QmlView::status() const
-{
- if (!d->component)
- return QmlView::Null;
-
- return QmlView::Status(d->component->status());
-}
-
-/*!
- 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> QmlView::errors() const
-{
- if (d->component)
- return d->component->errors();
- return QList<QmlError>();
-}
-
-
-/*!
- \property QmlView::resizeMode
- \brief whether the view should resize the canvas contents
-
- If this property is set to SizeViewToRootObject (the default), the view
- resizes with the root item in the QML.
-
- If this property is set to SizeRootObjectToView, the view will
- automatically resize the root item.
-
- Regardless of this property, the sizeHint of the view
- is the initial size of the root item. Note though that
- since QML may load dynamically, that size may change.
-
- \sa initialSize()
-*/
-
-void QmlView::setResizeMode(ResizeMode mode)
-{
- if (d->resizeMode == mode)
- return;
-
- d->resizeMode = mode;
- if (d->qmlRoot) {
- if (d->resizeMode == SizeRootObjectToView) {
- d->qmlRoot->setWidth(width());
- d->qmlRoot->setHeight(height());
- } else {
- d->qmlRoot->setWidth(d->initialSize.width());
- d->qmlRoot->setHeight(d->initialSize.height());
- }
- }
-}
-
-QmlView::ResizeMode QmlView::resizeMode() const
-{
- return d->resizeMode;
-}
-
-/*!
- \internal
- */
-void QmlView::continueExecute()
-{
-
- disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
-
- if (d->component->isError()) {
- QList<QmlError> errorList = d->component->errors();
- foreach (const QmlError &error, errorList) {
- qWarning() << error;
- }
- emit statusChanged(status());
- return;
- }
-
- QObject *obj = d->component->create();
-
- if(d->component->isError()) {
- QList<QmlError> errorList = d->component->errors();
- foreach (const QmlError &error, errorList) {
- qWarning() << error;
- }
- emit statusChanged(status());
- return;
- }
-
- if (obj) {
- if (QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(obj)) {
-
- d->scene.addItem(item);
-
- QPerformanceLog::displayData();
- QPerformanceLog::clear();
- d->root = item;
- d->qmlRoot = item;
- connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
- connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
- if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
- d->initialSize.setWidth(d->qmlRoot->width());
- if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
- d->initialSize.setHeight(d->qmlRoot->height());
- resize(d->initialSize);
-
- if (d->resizeMode == SizeRootObjectToView) {
- d->qmlRoot->setWidth(width());
- d->qmlRoot->setHeight(height());
- } else {
- QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
- emit sceneResized(sz);
- resize(sz);
- }
- updateGeometry();
- } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
- d->scene.addItem(item);
- qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject";
- } else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
- window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
- window()->setAttribute(Qt::WA_NoSystemBackground, false);
- if (!layout()) {
- setLayout(new QVBoxLayout);
- layout()->setContentsMargins(0, 0, 0, 0);
- } else if (layout()->count()) {
- // Hide the QGraphicsView in GV mode.
- QLayoutItem *item = layout()->itemAt(0);
- if (item->widget())
- item->widget()->hide();
- }
- layout()->addWidget(wid);
- emit sceneResized(wid->size());
- }
- }
- emit statusChanged(status());
-}
-
-/*!
- \internal
- */
-void QmlView::sizeChanged()
-{
- // delay, so we catch both width and height changing.
- d->resizetimer.start(0,this);
-}
-
-/*!
- \internal
- If the \l {QTimerEvent} {timer event} \a e is this
- view's resize timer, sceneResized() is emitted.
- */
-void QmlView::timerEvent(QTimerEvent* e)
-{
- if (!e || e->timerId() == d->resizetimer.timerId()) {
- if (d->qmlRoot) {
- QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
- emit sceneResized(sz);
- //if (!d->resizable)
- //resize(sz);
- }
- d->resizetimer.stop();
- updateGeometry();
- }
-}
-
-/*!
- \internal
- The size hint is the size of the root item.
-*/
-QSize QmlView::sizeHint() const
-{
- if (d->qmlRoot) {
- if (d->initialSize.width() <= 0)
- d->initialSize.setWidth(d->qmlRoot->width());
- if (d->initialSize.height() <= 0)
- d->initialSize.setHeight(d->qmlRoot->height());
- }
- return d->initialSize;
-}
-
-/*!
- Returns the view's root \l {QGraphicsObject} {item}.
- */
-QGraphicsObject *QmlView::rootObject() const
-{
- return d->root;
-}
-
-/*!
- \internal
- This function handles the \l {QResizeEvent} {resize event}
- \a e.
- */
-void QmlView::resizeEvent(QResizeEvent *e)
-{
- if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) {
- d->qmlRoot->setWidth(width());
- d->qmlRoot->setHeight(height());
- }
- if (d->qmlRoot) {
- setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height()));
- } else if (d->root) {
- setSceneRect(d->root->boundingRect());
- } else {
- setSceneRect(rect());
- }
- QGraphicsView::resizeEvent(e);
-}
-
-/*!
- \internal
-*/
-void QmlView::paintEvent(QPaintEvent *event)
-{
- int time = 0;
- if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled())
- time = d->frameTimer.restart();
- QGraphicsView::paintEvent(event);
- if (QmlViewDebugServer::isDebuggingEnabled())
- qfxViewDebugServer()->addTiming(d->frameTimer.elapsed(), time);
- if (frameRateDebug())
- qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h
deleted file mode 100644
index 1d6ef1c707..0000000000
--- a/src/declarative/util/qmlview.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 QMLVIEW_H
-#define QMLVIEW_H
-
-#include <QtCore/qdatetime.h>
-#include <QtGui/qgraphicssceneevent.h>
-#include <QtGui/qgraphicsview.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QGraphicsObject;
-class QmlEngine;
-class QmlContext;
-class QmlError;
-
-class QmlViewPrivate;
-class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView
-{
- Q_OBJECT
- Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
-public:
- explicit QmlView(QWidget *parent = 0);
- virtual ~QmlView();
-
- QUrl source() const;
- void setSource(const QUrl&);
-
- QmlEngine* engine();
- QmlContext* rootContext();
- void execute();
-
- QGraphicsObject *rootObject() const;
-
- enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
- ResizeMode resizeMode() const;
- void setResizeMode(ResizeMode);
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
-
- QList<QmlError> errors() const;
-
- QSize sizeHint() const;
-
-Q_SIGNALS:
- void sceneResized(QSize size); // ???
- void statusChanged(QmlView::Status);
-
-private Q_SLOTS:
- void continueExecute();
- void sizeChanged();
-
-protected:
- virtual void resizeEvent(QResizeEvent *);
- virtual void paintEvent(QPaintEvent *event);
- void timerEvent(QTimerEvent*);
-
- QmlViewPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLVIEW_H
diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp
deleted file mode 100644
index 58caf12714..0000000000
--- a/src/declarative/util/qmlxmllistmodel.cpp
+++ /dev/null
@@ -1,719 +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 "qmlxmllistmodel_p.h"
-
-#include <qmlcontext.h>
-#include <qmlengine.h>
-
-#include <QDebug>
-#include <QApplication>
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
-#include <QXmlQuery>
-#include <QXmlResultItems>
-#include <QXmlNodeModelIndex>
-#include <QBuffer>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt,4,6,XmlRole,QmlXmlListModelRole)
-QML_DEFINE_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel)
-
-/*!
- \qmlclass XmlRole QmlXmlListModelRole
- \since 4.7
- \brief The XmlRole element allows you to specify a role for an XmlListModel.
-*/
-
-/*!
- \qmlproperty string XmlRole::name
- The name for the role. This name is used to access the model data for this role from Qml.
-
- \qml
- XmlRole { name: "title"; query: "title/string()" }
-
- ...
-
- Component {
- id: myDelegate
- Text { text: title }
- }
- \endqml
-*/
-
-/*!
- \qmlproperty string XmlRole::query
- The relative XPath query for this role. The query should not start with a '/' (i.e. it must be
- relative).
-
- \qml
- XmlRole { name: "title"; query: "title/string()" }
- \endqml
-*/
-
-class Q_DECLARATIVE_EXPORT QmlXmlListModelRole : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString query READ query WRITE setQuery)
-
-public:
- QmlXmlListModelRole() {}
- ~QmlXmlListModelRole() {}
-
- QString name() const { return m_name; }
- void setName(const QString &name) { m_name = name; }
-
- QString query() const { return m_query; }
- void setQuery(const QString &query)
- {
- if (query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << tr("An XmlRole query must not start with '/'");
- return;
- }
- m_query = query;
- }
-
- bool isValid() {
- return !m_name.isEmpty() && !m_query.isEmpty();
- }
-
-private:
- QString m_name;
- QString m_query;
-};
-QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlXmlListModelRole)
-QT_BEGIN_NAMESPACE
-
-
-class QmlXmlQuery : public QThread
-{
- Q_OBJECT
-public:
- QmlXmlQuery(QObject *parent=0)
- : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
- }
- ~QmlXmlQuery() {
- m_mutex.lock();
- m_quit = true;
- m_condition.wakeOne();
- m_mutex.unlock();
-
- wait();
- }
-
- void abort() {
- QMutexLocker locker(&m_mutex);
- m_abort = true;
- }
-
- int doQuery(QString query, QString namespaces, QByteArray data, QList<QmlXmlListModelRole *> *roleObjects) {
- QMutexLocker locker(&m_mutex);
- m_modelData.clear();
- m_size = 0;
- m_data = data;
- m_query = QLatin1String("doc($src)") + query;
- m_namespaces = namespaces;
- m_roleObjects = roleObjects;
- if (!isRunning()) {
- m_abort = false;
- start();
- } else {
- m_restart = true;
- m_condition.wakeOne();
- }
- m_queryId++;
- return m_queryId;
- }
-
- QList<QList<QVariant> > modelData() {
- QMutexLocker locker(&m_mutex);
- return m_modelData;
- }
-
-Q_SIGNALS:
- void queryCompleted(int queryId, int size);
-
-protected:
- void run() {
- while (!m_quit) {
- m_mutex.lock();
- int queryId = m_queryId;
- doQueryJob();
- if (m_size > 0)
- doSubQueryJob();
- m_data.clear(); // no longer needed
- m_mutex.unlock();
-
- m_mutex.lock();
- if (!m_abort && m_size > 0)
- emit queryCompleted(queryId, m_size);
- if (!m_restart)
- m_condition.wait(&m_mutex);
- m_abort = false;
- m_restart = false;
- m_mutex.unlock();
- }
- }
-
-private:
- void doQueryJob();
- void doSubQueryJob();
-
-private:
- QMutex m_mutex;
- QWaitCondition m_condition;
- bool m_quit;
- bool m_restart;
- bool m_abort;
- QByteArray m_data;
- QString m_query;
- QString m_namespaces;
- QString m_prefix;
- int m_size;
- int m_queryId;
- const QList<QmlXmlListModelRole *> *m_roleObjects;
- QList<QList<QVariant> > m_modelData;
-};
-
-void QmlXmlQuery::doQueryJob()
-{
- QString r;
- QXmlQuery query;
- QBuffer buffer(&m_data);
- buffer.open(QIODevice::ReadOnly);
- query.bindVariable(QLatin1String("src"), &buffer);
- query.setQuery(m_namespaces + m_query);
- query.evaluateTo(&r);
-
- //qDebug() << r;
-
- //always need a single root element
- QByteArray xml = "<dummy:items xmlns:dummy=\"http://qtsotware.com/dummy\">\n" + r.toUtf8() + "</dummy:items>";
- QBuffer b(&xml);
- b.open(QIODevice::ReadOnly);
- //qDebug() << xml;
-
- QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + m_namespaces;
- QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- m_query.mid(m_query.lastIndexOf(QLatin1Char('/')));
-
- //figure out how many items we are dealing with
- int count = -1;
- {
- QXmlResultItems result;
- QXmlQuery countquery;
- countquery.bindVariable(QLatin1String("inputDocument"), &b);
- countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')'));
- countquery.evaluateTo(&result);
- QXmlItem item(result.next());
- if (item.isAtomicValue())
- count = item.toAtomicValue().toInt();
- }
- //qDebug() << count;
-
- m_prefix = namespaces + prefix + QLatin1Char('/');
- m_data = xml;
- if (count > 0)
- m_size = count;
-}
-
-void QmlXmlQuery::doSubQueryJob()
-{
- m_modelData.clear();
-
- QBuffer b(&m_data);
- b.open(QIODevice::ReadOnly);
-
- QXmlQuery subquery;
- subquery.bindVariable(QLatin1String("inputDocument"), &b);
-
- //### we might be able to condense even further (query for everything in one go)
- for (int i = 0; i < m_roleObjects->size(); ++i) {
- QmlXmlListModelRole *role = m_roleObjects->at(i);
- if (!role->isValid()) {
- QList<QVariant> resultList;
- for (int j = 0; j < m_size; ++j)
- resultList << QVariant();
- m_modelData << resultList;
- continue;
- }
- subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + role->query() + QLatin1String(" return if ($v) then ") + role->query() + QLatin1String(" else \"\")"));
- QXmlResultItems output3;
- subquery.evaluateTo(&output3);
- QXmlItem item(output3.next());
- QList<QVariant> resultList;
- while (!item.isNull()) {
- resultList << item.toAtomicValue(); //### we used to trim strings
- item = output3.next();
- }
- //### should warn here if things have gone wrong.
- while (resultList.count() < m_size)
- resultList << QVariant();
- m_modelData << resultList;
- b.seek(0);
- }
-
- //this method is much slower, but works better for incremental loading
- /*for (int j = 0; j < m_size; ++j) {
- QList<QVariant> resultList;
- for (int i = 0; i < m_roleObjects->size(); ++i) {
- QmlXmlListModelRole *role = m_roleObjects->at(i);
- subquery.setQuery(m_prefix.arg(j+1) + role->query());
- if (role->isStringList()) {
- QStringList data;
- subquery.evaluateTo(&data);
- resultList << QVariant(data);
- //qDebug() << data;
- } else {
- QString s;
- subquery.evaluateTo(&s);
- if (role->isCData()) {
- //un-escape
- s.replace(QLatin1String("&lt;"), QLatin1String("<"));
- s.replace(QLatin1String("&gt;"), QLatin1String(">"));
- s.replace(QLatin1String("&amp;"), QLatin1String("&"));
- }
- resultList << s.trimmed();
- //qDebug() << s;
- }
- b.seek(0);
- }
- m_modelData << resultList;
- }*/
-}
-
-class QmlXmlListModelPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QmlXmlListModel)
-public:
- QmlXmlListModelPrivate()
- : isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
- , reply(0), status(QmlXmlListModel::Null), progress(0.0)
- , queryId(-1), roleObjects() {}
-
- bool isComponentComplete;
- QUrl src;
- QString xml;
- QString query;
- QString namespaces;
- int size;
- QList<int> roles;
- QStringList roleNames;
- int highestRole;
- QNetworkReply *reply;
- QmlXmlListModel::Status status;
- qreal progress;
- QmlXmlQuery qmlXmlQuery;
- int queryId;
- QList<QmlXmlListModelRole *> roleObjects;
- static void append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role);
- static void clear_role(QmlListProperty<QmlXmlListModelRole> *list);
- static void removeAt_role(QmlListProperty<QmlXmlListModelRole> *list, int i);
- static void insert_role(QmlListProperty<QmlXmlListModelRole> *list, int i, QmlXmlListModelRole *role);
- QList<QList<QVariant> > data;
-};
-
-
-void QmlXmlListModelPrivate::append_role(QmlListProperty<QmlXmlListModelRole> *list, QmlXmlListModelRole *role)
-{
- QmlXmlListModel *_this = qobject_cast<QmlXmlListModel *>(list->object);
- if (_this) {
- int i = _this->d_func()->roleObjects.count();
- _this->d_func()->roleObjects.append(role);
- if (_this->d_func()->roleNames.contains(role->name())) {
- qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name());
- return;
- }
- _this->d_func()->roles.insert(i, _this->d_func()->highestRole);
- _this->d_func()->roleNames.insert(i, role->name());
- ++_this->d_func()->highestRole;
- }
-}
-
-//### clear needs to invalidate any cached data (in data table) as well
-// (and the model should emit the appropriate signals)
-void QmlXmlListModelPrivate::clear_role(QmlListProperty<QmlXmlListModelRole> *list)
-{
- QmlXmlListModel *_this = static_cast<QmlXmlListModel *>(list->object);
- _this->d_func()->roles.clear();
- _this->d_func()->roleNames.clear();
- _this->d_func()->roleObjects.clear();
-}
-
-/*!
- \class QmlXmlListModel
- \internal
-*/
-
-/*!
- \qmlclass XmlListModel QmlXmlListModel
- \since 4.7
- \brief The XmlListModel element allows you to specify a model using XPath expressions.
-
- XmlListModel allows you to construct a model from XML data that can then be used as a data source
- for the view classes (ListView, PathView, GridView) and any other classes that interact with model
- data (like Repeater).
-
- The following is an example of a model containing news from a Yahoo RSS feed:
- \qml
- 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()" }
- }
- \endqml
- \note The model is currently static, so the above is really just a snapshot of an RSS feed. To force a
- reload of the entire model, you can call the reload function.
-*/
-
-QmlXmlListModel::QmlXmlListModel(QObject *parent)
- : QListModelInterface(*(new QmlXmlListModelPrivate), parent)
-{
- Q_D(QmlXmlListModel);
- connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)),
- this, SLOT(queryCompleted(int,int)));
-}
-
-QmlXmlListModel::~QmlXmlListModel()
-{
-}
-
-/*!
- \qmlproperty list<XmlRole> XmlListModel::roles
-
- The roles to make available for this model.
-*/
-QmlListProperty<QmlXmlListModelRole> QmlXmlListModel::roleObjects()
-{
- Q_D(QmlXmlListModel);
- QmlListProperty<QmlXmlListModelRole> list(this, d->roleObjects);
- list.append = &QmlXmlListModelPrivate::append_role;
- list.clear = &QmlXmlListModelPrivate::clear_role;
- return list;
-}
-
-QHash<int,QVariant> QmlXmlListModel::data(int index, const QList<int> &roles) const
-{
- Q_D(const QmlXmlListModel);
- QHash<int, QVariant> rv;
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- int roleIndex = d->roles.indexOf(role);
- rv.insert(role, roleIndex == -1 ? QVariant() : d->data.at(roleIndex).at(index));
- }
- return rv;
-}
-
-QVariant QmlXmlListModel::data(int index, int role) const
-{
- Q_D(const QmlXmlListModel);
- int roleIndex = d->roles.indexOf(role);
- return (roleIndex == -1) ? QVariant() : d->data.at(roleIndex).at(index);
-}
-
-/*!
- \qmlproperty int XmlListModel::count
- The number of data entries in the model.
-*/
-int QmlXmlListModel::count() const
-{
- Q_D(const QmlXmlListModel);
- return d->size;
-}
-
-QList<int> QmlXmlListModel::roles() const
-{
- Q_D(const QmlXmlListModel);
- return d->roles;
-}
-
-QString QmlXmlListModel::toString(int role) const
-{
- Q_D(const QmlXmlListModel);
- int index = d->roles.indexOf(role);
- if (index == -1)
- return QString();
- return d->roleNames.at(index);
-}
-
-/*!
- \qmlproperty url XmlListModel::source
- The location of the XML data source.
-
- If both source and xml are set, xml will be used.
-*/
-QUrl QmlXmlListModel::source() const
-{
- Q_D(const QmlXmlListModel);
- return d->src;
-}
-
-void QmlXmlListModel::setSource(const QUrl &src)
-{
- Q_D(QmlXmlListModel);
- if (d->src != src) {
- d->src = src;
- reload();
- }
-}
-
-/*!
- \qmlproperty string XmlListModel::xml
- This property holds XML text set directly.
-
- The text is assumed to be UTF-8 encoded.
-
- If both source and xml are set, xml will be used.
-*/
-QString QmlXmlListModel::xml() const
-{
- Q_D(const QmlXmlListModel);
- return d->xml;
-}
-
-void QmlXmlListModel::setXml(const QString &xml)
-{
- Q_D(QmlXmlListModel);
- d->xml = xml;
- reload();
-}
-
-/*!
- \qmlproperty url XmlListModel::query
- An absolute XPath query representing the base query for the model items. The query should start with
- a '/' or '//'.
-*/
-QString QmlXmlListModel::query() const
-{
- Q_D(const QmlXmlListModel);
- return d->query;
-}
-
-void QmlXmlListModel::setQuery(const QString &query)
-{
- Q_D(QmlXmlListModel);
- if (!query.startsWith(QLatin1Char('/'))) {
- qmlInfo(this) << QCoreApplication::translate("QmlXmlRoleList", "An XmlListModel query must start with '/' or \"//\"");
- return;
- }
-
- if (d->query != query) {
- d->query = query;
- reload();
- }
-}
-
-/*!
- \qmlproperty string XmlListModel::namespaceDeclarations
- A set of declarations for the namespaces used in the query.
-*/
-QString QmlXmlListModel::namespaceDeclarations() const
-{
- Q_D(const QmlXmlListModel);
- return d->namespaces;
-}
-
-void QmlXmlListModel::setNamespaceDeclarations(const QString &declarations)
-{
- Q_D(QmlXmlListModel);
- if (d->namespaces != declarations) {
- d->namespaces = declarations;
- reload();
- }
-}
-
-/*!
- \qmlproperty enum XmlListModel::status
-
- This property holds the status of data source loading. It can be one of:
- \list
- \o Null - no data source has been set
- \o Ready - nthe data source has been loaded
- \o Loading - the data source is currently being loaded
- \o Error - an error occurred while loading the data source
- \endlist
-
- \sa progress
-
-*/
-QmlXmlListModel::Status QmlXmlListModel::status() const
-{
- Q_D(const QmlXmlListModel);
- return d->status;
-}
-
-/*!
- \qmlproperty real XmlListModel::progress
-
- This property holds the progress of data source loading, from 0.0 (nothing loaded)
- to 1.0 (finished).
-
- \sa status
-*/
-qreal QmlXmlListModel::progress() const
-{
- Q_D(const QmlXmlListModel);
- return d->progress;
-}
-
-void QmlXmlListModel::classBegin()
-{
- Q_D(QmlXmlListModel);
- d->isComponentComplete = false;
-}
-
-void QmlXmlListModel::componentComplete()
-{
- Q_D(QmlXmlListModel);
- d->isComponentComplete = true;
- reload();
-}
-
-/*!
- \qmlmethod XmlListModel::reload()
-
- Reloads the model. All the existing model data will be removed, and the model
- will be rebuilt from scratch.
-*/
-void QmlXmlListModel::reload()
-{
- Q_D(QmlXmlListModel);
-
- if (!d->isComponentComplete)
- return;
-
- d->qmlXmlQuery.abort();
- d->queryId = -1;
-
- //clear existing data
- int count = d->size;
- d->size = 0;
- d->data.clear();
- if (count > 0)
- emit itemsRemoved(0, count);
-
- if (d->src.isEmpty() && d->xml.isEmpty())
- return;
-
- if (d->reply) {
- d->reply->abort();
- d->reply->deleteLater();
- d->reply = 0;
- }
-
- if (!d->xml.isEmpty()) {
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
- d->progress = 1.0;
- d->status = Ready;
- emit progressChanged(d->progress);
- emit statusChanged(d->status);
- return;
- }
-
- d->progress = 0.0;
- d->status = Loading;
- emit progressChanged(d->progress);
- emit statusChanged(d->status);
-
- QNetworkRequest req(d->src);
- d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
-}
-
-void QmlXmlListModel::requestFinished()
-{
- Q_D(QmlXmlListModel);
- if (d->reply->error() != QNetworkReply::NoError) {
- disconnect(d->reply, 0, this, 0);
- d->reply->deleteLater();
- d->reply = 0;
- d->status = Error;
- } else {
- d->status = Ready;
- QByteArray data = d->reply->readAll();
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects);
- disconnect(d->reply, 0, this, 0);
- d->reply->deleteLater();
- d->reply = 0;
- }
- d->progress = 1.0;
- emit progressChanged(d->progress);
- emit statusChanged(d->status);
-}
-
-void QmlXmlListModel::requestProgress(qint64 received, qint64 total)
-{
- Q_D(QmlXmlListModel);
- if (d->status == Loading && total > 0) {
- d->progress = qreal(received)/total;
- emit progressChanged(d->progress);
- }
-}
-
-void QmlXmlListModel::queryCompleted(int id, int size)
-{
- Q_D(QmlXmlListModel);
- if (id != d->queryId)
- return;
- d->size = size;
- if (size > 0) {
- d->data = d->qmlXmlQuery.modelData();
- emit itemsInserted(0, d->size);
- emit countChanged();
- }
-}
-
-QT_END_NAMESPACE
-
-#include <qmlxmllistmodel.moc>
diff --git a/src/declarative/util/qmlxmllistmodel_p.h b/src/declarative/util/qmlxmllistmodel_p.h
deleted file mode 100644
index a6627e2e4d..0000000000
--- a/src/declarative/util/qmlxmllistmodel_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 QMLXMLLISTMODEL_H
-#define QMLXMLLISTMODEL_H
-
-#include <qml.h>
-#include <qmlinfo.h>
-
-#include "../3rdparty/qlistmodelinterface_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QmlContext;
-
-class QmlXmlListModelRole;
-
-class QmlXmlListModelPrivate;
-class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
- Q_ENUMS(Status)
-
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_PROPERTY(QString xml READ xml WRITE setXml)
- Q_PROPERTY(QString query READ query WRITE setQuery)
- Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
- Q_PROPERTY(QmlListProperty<QmlXmlListModelRole> roles READ roleObjects)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_CLASSINFO("DefaultProperty", "roles")
-
-public:
- QmlXmlListModel(QObject *parent = 0);
- ~QmlXmlListModel();
-
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
- virtual QVariant data(int index, int role) const;
- virtual int count() const;
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
-
- QmlListProperty<QmlXmlListModelRole> roleObjects();
-
- QUrl source() const;
- void setSource(const QUrl&);
-
- QString xml() const;
- void setXml(const QString&);
-
- QString query() const;
- void setQuery(const QString&);
-
- QString namespaceDeclarations() const;
- void setNamespaceDeclarations(const QString&);
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void statusChanged(Status);
- void progressChanged(qreal progress);
- void countChanged();
-
-public Q_SLOTS:
- // ### need to use/expose Expiry to guess when to call this?
- // ### property to auto-call this on reasonable Expiry?
- // ### LastModified/Age also useful to guess.
- // ### Probably also applies to other network-requesting types.
- void reload();
-
-private Q_SLOTS:
- void requestFinished();
- void requestProgress(qint64,qint64);
- void queryCompleted(int,int);
-
-private:
- Q_DECLARE_PRIVATE(QmlXmlListModel)
- Q_DISABLE_COPY(QmlXmlListModel)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlXmlListModel)
-
-QT_END_HEADER
-
-#endif // QMLXMLLISTMODEL_H
diff --git a/src/declarative/util/qnumberformat.cpp b/src/declarative/util/qnumberformat.cpp
index 42c12feb46..81d0b9036a 100644
--- a/src/declarative/util/qnumberformat.cpp
+++ b/src/declarative/util/qnumberformat.cpp
@@ -40,11 +40,10 @@
****************************************************************************/
#include "qnumberformat_p.h"
+#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
-QML_DEFINE_NOCREATE_TYPE(QNumberFormat)
-
QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal),
_groupingSize(0)
{
diff --git a/src/declarative/util/qnumberformat_p.h b/src/declarative/util/qnumberformat_p.h
index 902dcde99c..ced4442bad 100644
--- a/src/declarative/util/qnumberformat_p.h
+++ b/src/declarative/util/qnumberformat_p.h
@@ -42,7 +42,7 @@
#ifndef NUMBERFORMAT_H
#define NUMBERFORMAT_H
-#include <qml.h>
+#include <qdeclarative.h>
#include <QtCore/QLocale>
#include <QtCore/QTime>
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index b6a5c9044d..198e9e5e43 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -1,72 +1,74 @@
INCLUDEPATH += $$PWD
SOURCES += \
- $$PWD/qmlview.cpp \
+ $$PWD/qdeclarativeutilmodule.cpp\
+ $$PWD/qdeclarativeview.cpp \
$$PWD/qfxperf.cpp \
$$PWD/qperformancelog.cpp \
- $$PWD/qmlconnection.cpp \
- $$PWD/qmlpackage.cpp \
- $$PWD/qmlanimation.cpp \
- $$PWD/qmlsystempalette.cpp \
- $$PWD/qmlspringfollow.cpp \
- $$PWD/qmleasefollow.cpp \
- $$PWD/qmlstate.cpp\
- $$PWD/qmltransitionmanager.cpp \
- $$PWD/qmlstateoperations.cpp \
- $$PWD/qmlpropertychanges.cpp \
- $$PWD/qmlstategroup.cpp \
- $$PWD/qmltransition.cpp \
- $$PWD/qmllistmodel.cpp\
- $$PWD/qmllistaccessor.cpp \
- $$PWD/qmlopenmetaobject.cpp \
- $$PWD/qmltimeline.cpp \
- $$PWD/qmltimer.cpp \
- $$PWD/qmlbind.cpp \
- $$PWD/qmlpropertymap.cpp \
- $$PWD/qmlpixmapcache.cpp \
+ $$PWD/qdeclarativeconnections.cpp \
+ $$PWD/qdeclarativepackage.cpp \
+ $$PWD/qdeclarativeanimation.cpp \
+ $$PWD/qdeclarativesystempalette.cpp \
+ $$PWD/qdeclarativespringfollow.cpp \
+ $$PWD/qdeclarativeeasefollow.cpp \
+ $$PWD/qdeclarativestate.cpp\
+ $$PWD/qdeclarativetransitionmanager.cpp \
+ $$PWD/qdeclarativestateoperations.cpp \
+ $$PWD/qdeclarativepropertychanges.cpp \
+ $$PWD/qdeclarativestategroup.cpp \
+ $$PWD/qdeclarativetransition.cpp \
+ $$PWD/qdeclarativelistmodel.cpp\
+ $$PWD/qdeclarativelistaccessor.cpp \
+ $$PWD/qdeclarativeopenmetaobject.cpp \
+ $$PWD/qdeclarativetimeline.cpp \
+ $$PWD/qdeclarativetimer.cpp \
+ $$PWD/qdeclarativebind.cpp \
+ $$PWD/qdeclarativepropertymap.cpp \
+ $$PWD/qdeclarativepixmapcache.cpp \
$$PWD/qnumberformat.cpp \
- $$PWD/qmlnumberformatter.cpp \
- $$PWD/qmldatetimeformatter.cpp \
- $$PWD/qmlbehavior.cpp \
- $$PWD/qmlfontloader.cpp \
- $$PWD/qmlstyledtext.cpp
+ $$PWD/qdeclarativenumberformatter.cpp \
+ $$PWD/qdeclarativedatetimeformatter.cpp \
+ $$PWD/qdeclarativebehavior.cpp \
+ $$PWD/qdeclarativefontloader.cpp \
+ $$PWD/qdeclarativestyledtext.cpp
HEADERS += \
- $$PWD/qmlview.h \
+ $$PWD/qdeclarativeutilmodule_p.h\
+ $$PWD/qdeclarativeview.h \
$$PWD/qfxperf_p_p.h \
$$PWD/qperformancelog_p_p.h \
- $$PWD/qmlconnection_p.h \
- $$PWD/qmlpackage_p.h \
- $$PWD/qmlanimation_p.h \
- $$PWD/qmlanimation_p_p.h \
- $$PWD/qmlsystempalette_p.h \
- $$PWD/qmlspringfollow_p.h \
- $$PWD/qmleasefollow_p.h \
- $$PWD/qmlstate_p.h\
- $$PWD/qmlstateoperations_p.h \
- $$PWD/qmlpropertychanges_p.h \
- $$PWD/qmlstate_p_p.h\
- $$PWD/qmltransitionmanager_p_p.h \
- $$PWD/qmlstategroup_p.h \
- $$PWD/qmltransition_p.h \
- $$PWD/qmllistmodel_p.h\
- $$PWD/qmllistaccessor_p.h \
- $$PWD/qmlopenmetaobject_p.h \
- $$PWD/qmlnullablevalue_p_p.h \
- $$PWD/qmltimeline_p_p.h \
- $$PWD/qmltimer_p.h \
- $$PWD/qmlbind_p.h \
- $$PWD/qmlpropertymap.h \
- $$PWD/qmlpixmapcache_p.h \
+ $$PWD/qdeclarativeconnections_p.h \
+ $$PWD/qdeclarativepackage_p.h \
+ $$PWD/qdeclarativeanimation_p.h \
+ $$PWD/qdeclarativeanimation_p_p.h \
+ $$PWD/qdeclarativesystempalette_p.h \
+ $$PWD/qdeclarativespringfollow_p.h \
+ $$PWD/qdeclarativeeasefollow_p.h \
+ $$PWD/qdeclarativestate_p.h\
+ $$PWD/qdeclarativestateoperations_p.h \
+ $$PWD/qdeclarativepropertychanges_p.h \
+ $$PWD/qdeclarativestate_p_p.h\
+ $$PWD/qdeclarativetransitionmanager_p_p.h \
+ $$PWD/qdeclarativestategroup_p.h \
+ $$PWD/qdeclarativetransition_p.h \
+ $$PWD/qdeclarativelistmodel_p.h\
+ $$PWD/qdeclarativelistaccessor_p.h \
+ $$PWD/qdeclarativeopenmetaobject_p.h \
+ $$PWD/qdeclarativenullablevalue_p_p.h \
+ $$PWD/qdeclarativetimeline_p_p.h \
+ $$PWD/qdeclarativetimer_p.h \
+ $$PWD/qdeclarativebind_p.h \
+ $$PWD/qdeclarativepropertymap.h \
+ $$PWD/qdeclarativepixmapcache_p.h \
$$PWD/qnumberformat_p.h \
- $$PWD/qmlnumberformatter_p.h \
- $$PWD/qmldatetimeformatter_p.h \
- $$PWD/qmlbehavior_p.h \
- $$PWD/qmlfontloader_p.h \
- $$PWD/qmlstyledtext_p.h
+ $$PWD/qdeclarativenumberformatter_p.h \
+ $$PWD/qdeclarativedatetimeformatter_p.h \
+ $$PWD/qdeclarativebehavior_p.h \
+ $$PWD/qdeclarativefontloader_p.h \
+ $$PWD/qdeclarativestyledtext_p.h
contains(QT_CONFIG, xmlpatterns) {
QT+=xmlpatterns
- SOURCES += $$PWD/qmlxmllistmodel.cpp
- HEADERS += $$PWD/qmlxmllistmodel_p.h
+ SOURCES += $$PWD/qdeclarativexmllistmodel.cpp
+ HEADERS += $$PWD/qdeclarativexmllistmodel_p.h
}
diff --git a/src/declarative/widgets/graphicslayouts.cpp b/src/declarative/widgets/graphicslayouts.cpp
deleted file mode 100644
index 62e941a8ec..0000000000
--- a/src/declarative/widgets/graphicslayouts.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "graphicslayouts_p.h"
-
-#include <QtGui/qgraphicswidget.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_INTERFACE(QGraphicsLayoutItem)
-QML_DEFINE_INTERFACE(QGraphicsLayout)
-
-QML_DEFINE_TYPE(Qt,4,6,QGraphicsLinearLayoutStretchItem,QGraphicsLinearLayoutStretchItemObject)
-QML_DEFINE_TYPE(Qt,4,6,QGraphicsLinearLayout,QGraphicsLinearLayoutObject)
-QML_DEFINE_TYPE(Qt,4,6,QGraphicsGridLayout,QGraphicsGridLayoutObject)
-
-class LinearLayoutAttached : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
-public:
- LinearLayoutAttached(QObject *parent)
- : QObject(parent), _stretch(1), _alignment(Qt::AlignCenter)
- {
- }
-
- int stretchFactor() const { return _stretch; }
- void setStretchFactor(int f)
- {
- if (_stretch == f)
- return;
-
- _stretch = f;
- emit stretchChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _stretch);
- }
-
- Qt::Alignment alignment() const { return _alignment; }
- void setAlignment(Qt::Alignment a)
- {
- if (_alignment == a)
- return;
-
- _alignment = a;
- emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _alignment);
- }
-
-Q_SIGNALS:
- void stretchChanged(QGraphicsLayoutItem*,int);
- void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment);
-
-private:
- int _stretch;
- Qt::Alignment _alignment;
-};
-
-
-QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent)
- : QObject(parent)
-{
-}
-
-QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
-{
- Q_UNUSED(which);
- Q_UNUSED(constraint);
- return QSizeF();
-}
-
-
-QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent)
-: QObject(parent)
-{
-}
-
-QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject()
-{
-}
-
-void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item)
-{
- insertItem(index, item);
-
- //connect attached properties
- if (LinearLayoutAttached *obj = attachedProperties.value(item)) {
- setStretchFactor(item, obj->stretchFactor());
- setAlignment(item, obj->alignment());
- QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)),
- this, SLOT(updateStretch(QGraphicsLayoutItem*,int)));
- QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)),
- this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment)));
- //### need to disconnect when widget is removed?
- }
-}
-
-//### is there a better way to do this?
-void QGraphicsLinearLayoutObject::clearChildren()
-{
- for (int i = 0; i < count(); ++i)
- removeAt(i);
-}
-
-void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch)
-{
- QGraphicsLinearLayout::setStretchFactor(item, stretch);
-}
-
-void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment)
-{
- QGraphicsLinearLayout::setAlignment(item, alignment);
-}
-
-QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> QGraphicsLinearLayoutObject::attachedProperties;
-LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj)
-{
- // ### This is not allowed - you must attach to any object
- if (!qobject_cast<QGraphicsLayoutItem*>(obj))
- return 0;
- LinearLayoutAttached *rv = new LinearLayoutAttached(obj);
- attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
- return rv;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////
-// QGraphicsGridLayout-related classes
-//////////////////////////////////////////////////////////////////////////////////////////////////////
-class GridLayoutAttached : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int row READ row WRITE setRow)
- Q_PROPERTY(int column READ column WRITE setColumn)
- Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan)
- Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
-public:
- GridLayoutAttached(QObject *parent)
- : QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1)
- {
- }
-
- int row() const { return _row; }
- void setRow(int r)
- {
- if (_row == r)
- return;
-
- _row = r;
- //emit rowChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _row);
- }
-
- int column() const { return _column; }
- void setColumn(int c)
- {
- if (_column == c)
- return;
-
- _column = c;
- //emit columnChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _column);
- }
-
- int rowSpan() const { return _rowspan; }
- void setRowSpan(int rs)
- {
- if (_rowspan == rs)
- return;
-
- _rowspan = rs;
- //emit rowSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _rowSpan);
- }
-
- int columnSpan() const { return _colspan; }
- void setColumnSpan(int cs)
- {
- if (_colspan == cs)
- return;
-
- _colspan = cs;
- //emit columnSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _columnSpan);
- }
-
- Qt::Alignment alignment() const { return _alignment; }
- void setAlignment(Qt::Alignment a)
- {
- if (_alignment == a)
- return;
-
- _alignment = a;
- //emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _alignment);
- }
-
-Q_SIGNALS:
- //void rowChanged(QGraphicsLayoutItem*,int);
- //void columnSpanChanged(QGraphicsLayoutItem*,int);
- //void rowSpanChanged(QGraphicsLayoutItem*,int);
- //void columnChanged(QGraphicsLayoutItem*,int);
- //void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment);
-
-private:
- int _row;
- int _column;
- int _rowspan;
- int _colspan;
- Qt::Alignment _alignment;
-};
-
-
-QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent)
-: QObject(parent)
-{
-}
-
-QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject()
-{
-}
-
-void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid)
-{
- //use attached properties
- if (QObject *obj = attachedProperties.value(qobject_cast<QGraphicsLayoutItem*>(wid))) {
- int row = static_cast<GridLayoutAttached *>(obj)->row();
- int column = static_cast<GridLayoutAttached *>(obj)->column();
- int rowSpan = static_cast<GridLayoutAttached *>(obj)->rowSpan();
- int columnSpan = static_cast<GridLayoutAttached *>(obj)->columnSpan();
- if (row == -1 || column == -1) {
- qWarning() << "Must set row and column for an item in a grid layout";
- return;
- }
- addItem(wid, row, column, rowSpan, columnSpan);
- }
-}
-
-void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item)
-{
- //use attached properties
- if (GridLayoutAttached *obj = attachedProperties.value(item)) {
- int row = obj->row();
- int column = obj->column();
- int rowSpan = obj->rowSpan();
- int columnSpan = obj->columnSpan();
- Qt::Alignment alignment = obj->alignment();
- if (row == -1 || column == -1) {
- qWarning() << "Must set row and column for an item in a grid layout";
- return;
- }
- addItem(item, row, column, rowSpan, columnSpan);
- if (alignment != -1)
- setAlignment(item,alignment);
- }
-}
-
-//### is there a better way to do this?
-void QGraphicsGridLayoutObject::clearChildren()
-{
- for (int i = 0; i < count(); ++i)
- removeAt(i);
-}
-
-qreal QGraphicsGridLayoutObject::spacing() const
-{
- if (verticalSpacing() == horizontalSpacing())
- return verticalSpacing();
- return -1; //###
-}
-
-QHash<QGraphicsLayoutItem*, GridLayoutAttached*> QGraphicsGridLayoutObject::attachedProperties;
-GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj)
-{
- // ### This is not allowed - you must attach to any object
- if (!qobject_cast<QGraphicsLayoutItem*>(obj))
- return 0;
- GridLayoutAttached *rv = new GridLayoutAttached(obj);
- attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
- return rv;
-}
-
-QT_END_NAMESPACE
-
-#include <graphicslayouts.moc>
diff --git a/src/declarative/widgets/graphicslayouts_p.h b/src/declarative/widgets/graphicslayouts_p.h
deleted file mode 100644
index 3076af1ce3..0000000000
--- a/src/declarative/widgets/graphicslayouts_p.h
+++ /dev/null
@@ -1,168 +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 GRAPHICSLAYOUTS_H
-#define GRAPHICSLAYOUTS_H
-
-#include "graphicswidgets_p.h"
-
-#include <QtGui/QGraphicsLinearLayout>
-#include <QtGui/QGraphicsGridLayout>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsLayoutItem)
-public:
- QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0);
-
- virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const;
-};
-
-class LinearLayoutAttached;
-class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem)
-
- Q_PROPERTY(QmlListProperty<QGraphicsLayoutItem> children READ children)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
- Q_CLASSINFO("DefaultProperty", "children")
-public:
- QGraphicsLinearLayoutObject(QObject * = 0);
- ~QGraphicsLinearLayoutObject();
-
- QmlListProperty<QGraphicsLayoutItem> children() { return QmlListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); }
-
- static LinearLayoutAttached *qmlAttachedProperties(QObject *);
-
-private Q_SLOTS:
- void updateStretch(QGraphicsLayoutItem*,int);
- void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment);
-
-private:
- friend class LinearLayoutAttached;
- void clearChildren();
- void insertLayoutItem(int, QGraphicsLayoutItem *);
- static QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> attachedProperties;
-
- static void children_append(QmlListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) {
- static_cast<QGraphicsLinearLayoutObject*>(prop->object)->insertLayoutItem(-1, item);
- }
-
- static void children_clear(QmlListProperty<QGraphicsLayoutItem> *prop) {
- static_cast<QGraphicsLinearLayoutObject*>(prop->object)->clearChildren();
- }
-
- static int children_count(QmlListProperty<QGraphicsLayoutItem> *prop) {
- return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->count();
- }
-
- static QGraphicsLayoutItem *children_at(QmlListProperty<QGraphicsLayoutItem> *prop, int index) {
- return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->itemAt(index);
- }
-};
-
-class GridLayoutAttached;
-class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem)
-
- Q_PROPERTY(QmlListProperty<QGraphicsLayoutItem> children READ children)
- Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
- Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
- Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
- Q_CLASSINFO("DefaultProperty", "children")
-public:
- QGraphicsGridLayoutObject(QObject * = 0);
- ~QGraphicsGridLayoutObject();
-
- QmlListProperty<QGraphicsLayoutItem> children() { return QmlListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); }
-
- qreal spacing() const;
-
- static GridLayoutAttached *qmlAttachedProperties(QObject *);
-
-private:
- friend class GraphicsLayoutAttached;
- void addWidget(QGraphicsWidget *);
- void clearChildren();
- void addLayoutItem(QGraphicsLayoutItem *);
- static QHash<QGraphicsLayoutItem*, GridLayoutAttached*> attachedProperties;
-
- static void children_append(QmlListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) {
- static_cast<QGraphicsGridLayoutObject*>(prop->object)->addLayoutItem(item);
- }
-
- static void children_clear(QmlListProperty<QGraphicsLayoutItem> *prop) {
- static_cast<QGraphicsGridLayoutObject*>(prop->object)->clearChildren();
- }
-
- static int children_count(QmlListProperty<QGraphicsLayoutItem> *prop) {
- return static_cast<QGraphicsGridLayoutObject*>(prop->object)->count();
- }
-
- static QGraphicsLayoutItem *children_at(QmlListProperty<QGraphicsLayoutItem> *prop, int index) {
- return static_cast<QGraphicsGridLayoutObject*>(prop->object)->itemAt(index);
- }
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_INTERFACE(QGraphicsLayoutItem)
-QML_DECLARE_INTERFACE(QGraphicsLayout)
-QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject)
-QML_DECLARE_TYPE(QGraphicsLinearLayoutObject)
-QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(QGraphicsGridLayoutObject)
-QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // GRAPHICSLAYOUTS_H
diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp
deleted file mode 100644
index bb4dc740e8..0000000000
--- a/src/declarative/widgets/graphicswidgets.cpp
+++ /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$
-**
-****************************************************************************/
-
-#include "graphicswidgets_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsViewDeclarativeUI : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QGraphicsScene *scene READ scene WRITE setScene)
- Q_CLASSINFO("DefaultProperty", "scene")
-public:
- QGraphicsViewDeclarativeUI(QObject *other) : QObject(other) {}
-
- QGraphicsScene *scene() const { return static_cast<QGraphicsView *>(parent())->scene(); }
- void setScene(QGraphicsScene *scene)
- {
- static_cast<QGraphicsView *>(parent())->setScene(scene);
- }
-};
-
-class QGraphicsSceneDeclarativeUI : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QmlListProperty<QObject> children READ children)
- Q_CLASSINFO("DefaultProperty", "children")
-public:
- QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {}
-
- QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this->parent(), 0, children_append); }
-
-private:
- static void children_append(QmlListProperty<QObject> *prop, QObject *o) {
- if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o))
- static_cast<QGraphicsScene *>(prop->object)->addItem(go);
- }
-};
-
-class QGraphicsWidgetDeclarativeUI : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QmlListProperty<QGraphicsItem> children READ children)
- Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout)
- Q_CLASSINFO("DefaultProperty", "children")
-public:
- QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {}
-
- QmlListProperty<QGraphicsItem> children() { return QmlListProperty<QGraphicsItem>(this, 0, children_append); }
-
- QGraphicsLayout *layout() const { return static_cast<QGraphicsWidget *>(parent())->layout(); }
- void setLayout(QGraphicsLayout *lo)
- {
- static_cast<QGraphicsWidget *>(parent())->setLayout(lo);
- }
-
-private:
- void setItemParent(QGraphicsItem *wid)
- {
- wid->setParentItem(static_cast<QGraphicsWidget *>(parent()));
- }
-
- static void children_append(QmlListProperty<QGraphicsItem> *prop, QGraphicsItem *i) {
- static_cast<QGraphicsWidgetDeclarativeUI*>(prop->object)->setItemParent(i);
- }
-};
-
-QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsView,QGraphicsView,QGraphicsViewDeclarativeUI)
-QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsScene,QGraphicsScene,QGraphicsSceneDeclarativeUI)
-QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarativeUI)
-
-QML_DEFINE_INTERFACE(QGraphicsItem)
-
-QT_END_NAMESPACE
-
-#include <graphicswidgets.moc>
diff --git a/src/declarative/widgets/graphicswidgets_p.h b/src/declarative/widgets/graphicswidgets_p.h
deleted file mode 100644
index 6255d2bd79..0000000000
--- a/src/declarative/widgets/graphicswidgets_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 GRAPHICSWIDGETS_H
-#define GRAPHICSWIDGETS_H
-
-#include <qml.h>
-
-#include <QtGui/QGraphicsScene>
-#include <QtGui/QGraphicsView>
-#include <QtGui/QGraphicsWidget>
-#include <QtGui/QGraphicsItem>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QGraphicsView)
-QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene)
-QML_DECLARE_TYPE(QGraphicsWidget)
-QML_DECLARE_TYPE(QGraphicsObject)
-QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem)
-
-QT_END_HEADER
-
-#endif // GRAPHICSWIDGETS_H
diff --git a/src/declarative/widgets/widgets.pri b/src/declarative/widgets/widgets.pri
deleted file mode 100644
index 4cae3ff2f3..0000000000
--- a/src/declarative/widgets/widgets.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-INCLUDEPATH += $$PWD
-
-SOURCES += \
- $$PWD/graphicswidgets.cpp \
- $$PWD/graphicslayouts.cpp
-
-HEADERS += \
- $$PWD/graphicswidgets_p.h \
- $$PWD/graphicslayouts_p.h
diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm
index bdcb87228f..8af0d2be32 100644
--- a/src/gui/dialogs/qcolordialog_mac.mm
+++ b/src/gui/dialogs/qcolordialog_mac.mm
@@ -96,6 +96,7 @@ QT_USE_NAMESPACE
- (void)finishOffWithCode:(NSInteger)result;
- (void)showColorPanel;
- (void)exec;
+- (void)setResultSet:(BOOL)result;
@end
@implementation QCocoaColorPanelDelegate
@@ -158,6 +159,11 @@ QT_USE_NAMESPACE
[super dealloc];
}
+- (void)setResultSet:(BOOL)result
+{
+ mResultSet = result;
+}
+
- (BOOL)windowShouldClose:(id)window
{
Q_UNUSED(window);
@@ -320,7 +326,7 @@ QT_USE_NAMESPACE
} else {
mPriv->colorDialog()->accept();
}
- }
+ }
}
}
@@ -433,7 +439,7 @@ void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial,
priv:this];
[colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)];
}
-
+ [delegate setResultSet:false];
setCocoaPanelColor(initial);
[static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel];
}
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index 56580a935a..a4bf15dff2 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -989,34 +989,24 @@ void QFontDialog::open(QObject *receiver, const char *member)
void QFontDialog::setVisible(bool visible)
{
Q_D(QFontDialog);
- if (visible)
- d->selectedFont = QFont();
-
-#if defined(Q_WS_MAC)
- bool isCurrentlyVisible = (isVisible() || d->delegate);
-
- if (!visible == !isCurrentlyVisible)
- return;
-
if (visible) {
- if (!(d->opts & DontUseNativeDialog) && QFontDialogPrivate::sharedFontPanelAvailable) {
- d->delegate = QFontDialogPrivate::openCocoaFontPanel(
- currentFont(), parentWidget(), windowTitle(), options(), d);
- QFontDialogPrivate::sharedFontPanelAvailable = false;
- return;
- }
-
- setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
- } else {
- if (d->delegate) {
- QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
- d->delegate = 0;
- QFontDialogPrivate::sharedFontPanelAvailable = true;
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
return;
+ } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
+ return;
+#ifdef Q_WS_MAC
+ if (d->canBeNativeDialog()){
+ if (d->setVisible_sys(visible)){
+ d->nativeDialogInUse = true;
+ // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
+ // updates the state correctly, but skips showing the non-native version:
+ setAttribute(Qt::WA_DontShowOnScreen, true);
+ } else {
+ d->nativeDialogInUse = false;
+ setAttribute(Qt::WA_DontShowOnScreen, false);
}
}
-#endif
-
+#endif // Q_WS_MAC
QDialog::setVisible(visible);
}
@@ -1032,11 +1022,14 @@ void QFontDialog::done(int result)
Q_D(QFontDialog);
QDialog::done(result);
if (result == Accepted) {
- d->selectedFont = currentFont();
+ // We check if this is the same font we had before, if so we emit currentFontChanged
+ QFont selectedFont = currentFont();
+ if(selectedFont != d->selectedFont)
+ emit(currentFontChanged(selectedFont));
+ d->selectedFont = selectedFont;
emit fontSelected(d->selectedFont);
- } else {
+ } else
d->selectedFont = QFont();
- }
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(fontSelected(QFont)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
@@ -1045,6 +1038,23 @@ void QFontDialog::done(int result)
d->memberToDisconnectOnClose.clear();
}
+#ifdef Q_WS_MAC
+bool QFontDialogPrivate::canBeNativeDialog()
+{
+ Q_Q(QFontDialog);
+ if (nativeDialogInUse)
+ return true;
+ if (q->testAttribute(Qt::WA_DontShowOnScreen))
+ return false;
+ if (opts & QFontDialog::DontUseNativeDialog)
+ return false;
+
+ QLatin1String staticName(QFontDialog::staticMetaObject.className());
+ QLatin1String dynamicName(q->metaObject()->className());
+ return (staticName == dynamicName);
+}
+#endif // Q_WS_MAC
+
/*!
\fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name)
\since 4.5
diff --git a/src/gui/dialogs/qfontdialog.h b/src/gui/dialogs/qfontdialog.h
index e6f209e11e..6035a3aa6f 100644
--- a/src/gui/dialogs/qfontdialog.h
+++ b/src/gui/dialogs/qfontdialog.h
@@ -131,6 +131,9 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_styleHighlighted(int))
Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int))
Q_PRIVATE_SLOT(d_func(), void _q_updateSample())
+#if defined(Q_WS_MAC)
+ Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
+#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions)
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 68f5f005dc..67d32b8daf 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -49,6 +49,7 @@
#include <private/qfontengine_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
+#include <qabstracteventdispatcher.h>
#include <qdebug.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
@@ -372,7 +373,12 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
[NSApp endModalSession:mModalSession];
mModalSession = 0;
}
-
+ // Hack alert!
+ // Since this code path was never intended to be followed when starting from exec
+ // we need to force the dialog to communicate the new font, otherwise the signal
+ // won't get emitted.
+ if(code == NSOKButton)
+ mPriv->sampleEdit->setFont([self qtFont]);
mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
} else {
[NSApp stopModalWithCode:code];
@@ -567,7 +573,6 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
[ourPanel makeKeyAndOrderFront:ourPanel];
}
}
-
return delegate;
}
@@ -640,6 +645,145 @@ void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
[static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
}
+void *QFontDialogPrivate::_q_constructNativePanel()
+{
+ QMacCocoaAutoReleasePool pool;
+
+ bool sharedFontPanelExisted = [NSFontPanel sharedFontPanelExists];
+ NSFontPanel *sharedFontPanel = [NSFontPanel sharedFontPanel];
+ [sharedFontPanel setHidesOnDeactivate:false];
+
+ // hack to ensure that QCocoaApplication's validModesForFontPanel:
+ // implementation is honored
+ if (!sharedFontPanelExisted) {
+ [sharedFontPanel makeKeyAndOrderFront:sharedFontPanel];
+ [sharedFontPanel close];
+ }
+
+ NSPanel *ourPanel = 0;
+ NSView *stolenContentView = 0;
+ NSButton *okButton = 0;
+ NSButton *cancelButton = 0;
+
+ CGFloat dialogExtraWidth = 0.0;
+ CGFloat dialogExtraHeight = 0.0;
+
+ // compute dialogExtra{Width,Height}
+ dialogExtraWidth = 2.0 * DialogSideMargin;
+ dialogExtraHeight = DialogTopMargin + ButtonTopMargin + ButtonMinHeight
+ + ButtonBottomMargin;
+
+ // compute initial contents rectangle
+ NSRect contentRect = [sharedFontPanel contentRectForFrameRect:[sharedFontPanel frame]];
+ contentRect.size.width += dialogExtraWidth;
+ contentRect.size.height += dialogExtraHeight;
+
+ // create the new panel
+ ourPanel = [[NSPanel alloc] initWithContentRect:contentRect
+ styleMask:StyleMask
+ backing:NSBackingStoreBuffered
+ defer:YES];
+ [ourPanel setReleasedWhenClosed:YES];
+
+ stolenContentView = [sharedFontPanel contentView];
+
+ // steal the font panel's contents view
+ [stolenContentView retain];
+ [sharedFontPanel setContentView:0];
+
+ {
+ // create a new content view and add the stolen one as a subview
+ NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
+ NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
+ [ourContentView addSubview:stolenContentView];
+
+ // create OK and Cancel buttons and add these as subviews
+ okButton = macCreateButton("&OK", ourContentView);
+ cancelButton = macCreateButton("Cancel", ourContentView);
+
+ [ourPanel setContentView:ourContentView];
+ [ourPanel setDefaultButtonCell:[okButton cell]];
+ }
+ // create a delegate and set it
+ QCocoaFontPanelDelegate *delegate =
+ [[QCocoaFontPanelDelegate alloc] initWithFontPanel:sharedFontPanel
+ stolenContentView:stolenContentView
+ okButton:okButton
+ cancelButton:cancelButton
+ priv:this
+ extraWidth:dialogExtraWidth
+ extraHeight:dialogExtraHeight];
+ [ourPanel setDelegate:delegate];
+ [[NSFontManager sharedFontManager] setDelegate:delegate];
+#ifdef QT_MAC_USE_COCOA
+ [[NSFontManager sharedFontManager] setTarget:delegate];
+#endif
+ setFont(delegate, QApplication::font());
+
+ {
+ // hack to get correct initial layout
+ NSRect frameRect = [ourPanel frame];
+ frameRect.size.width += 1.0;
+ [ourPanel setFrame:frameRect display:NO];
+ frameRect.size.width -= 1.0;
+ frameRect.size = [delegate windowWillResize:ourPanel toSize:frameRect.size];
+ [ourPanel setFrame:frameRect display:NO];
+ [ourPanel center];
+ }
+ NSString *title = @"Select font";
+ [ourPanel setTitle:title];
+
+ [delegate setModalSession:[NSApp beginModalSessionForWindow:ourPanel]];
+ return delegate;
+}
+
+void QFontDialogPrivate::mac_nativeDialogModalHelp()
+{
+ // Copied from QFileDialogPrivate
+ // Do a queued meta-call to open the native modal dialog so it opens after the new
+ // event loop has started to execute (in QDialog::exec). Using a timer rather than
+ // a queued meta call is intentional to ensure that the call is only delivered when
+ // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
+ // running (which is the case if e.g a top-most QEventLoop has been
+ // interrupted, and the second-most event loop has not yet been reactivated (regardless
+ // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
+ if (nativeDialogInUse) {
+ Q_Q(QFontDialog);
+ QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+ }
+}
+
+// The problem with the native font dialog is that OS X does not
+// offer a proper dialog, but a panel (i.e. without Ok and Cancel buttons).
+// This means we need to "construct" a native dialog by taking the panel
+// and "adding" the buttons.
+void QFontDialogPrivate::_q_macRunNativeAppModalPanel()
+{
+ QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
+ Q_Q(QFontDialog);
+ QCocoaFontPanelDelegate *delegate = (QCocoaFontPanelDelegate *)_q_constructNativePanel();
+ NSWindow *ourPanel = [delegate actualPanel];
+ [ourPanel retain];
+ int rval = [NSApp runModalForWindow:ourPanel];
+ QAbstractEventDispatcher::instance()->interrupt();
+ [ourPanel release];
+ [delegate cleanUpAfterMyself];
+ [delegate release];
+ bool isOk = (rval == NSOKButton);
+ if(isOk)
+ rescode = QDialog::Accepted;
+ else
+ rescode = QDialog::Rejected;
+}
+
+bool QFontDialogPrivate::setVisible_sys(bool visible)
+{
+ Q_Q(QFontDialog);
+ if (!visible == q->isHidden())
+ return false;
+ return visible;
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/gui/dialogs/qfontdialog_p.h b/src/gui/dialogs/qfontdialog_p.h
index ca2b10bbc2..7654a80f7c 100644
--- a/src/gui/dialogs/qfontdialog_p.h
+++ b/src/gui/dialogs/qfontdialog_p.h
@@ -152,6 +152,12 @@ public:
inline QFontDialog *fontDialog() { return q_func(); }
void *delegate;
+ bool nativeDialogInUse;
+ bool canBeNativeDialog();
+ bool setVisible_sys(bool visible);
+ void *_q_constructNativePanel();
+ void _q_macRunNativeAppModalPanel();
+ void mac_nativeDialogModalHelp();
static bool sharedFontPanelAvailable;
#endif
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index ca20101c6d..5735cd6a75 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -414,12 +414,6 @@
/*!
\enum QGraphicsItem::GraphicsItemChange
- ItemVisibleHasChanged,
- ItemEnabledHasChanged,
- ItemSelectedHasChanged,
- ItemParentHasChanged,
- ItemSceneHasChanged
-
This enum describes the state changes that are notified by
QGraphicsItem::itemChange(). The notifications are sent as the state
changes, and in some cases, adjustments can be made (see the documentation
@@ -647,9 +641,16 @@
are children of a modal panel are not blocked.
The values are:
- \value NonModal The panel is not modal and does not block input to other panels.
- \value PanelModal The panel is modal to a single item hierarchy and blocks input to its parent pane, all grandparent panels, and all siblings of its parent and grandparent panels.
- \value SceneModal The window is modal to the entire scene and blocks input to all panels.
+
+ \value NonModal The panel is not modal and does not block input to
+ other panels. This is the default value for panels.
+
+ \value PanelModal The panel is modal to a single item hierarchy
+ and blocks input to its parent pane, all grandparent panels, and
+ all siblings of its parent and grandparent panels.
+
+ \value SceneModal The window is modal to the entire scene and
+ blocks input to all panels.
\sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel
*/
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 2c923645f6..4c4bfaf048 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -609,7 +609,7 @@ public:
return item->type() == QGraphicsPixmapItem::Type
&& !(item->flags() & QGraphicsItem::ItemIsSelectable)
&& item->d_ptr->children.size() == 0;
- //|| (item->d_ptr->isObject && qobject_cast<QmlGraphicsImage *>(q_func()));
+ //|| (item->d_ptr->isObject && qobject_cast<QDeclarativeImage *>(q_func()));
}
inline const QStyleOption *styleOption() const
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 40e1d2c945..365afdd46e 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -813,7 +813,8 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// do it ourselves.
if (item) {
for (int i = 0; i < views.size(); ++i)
- views.at(i)->inputContext()->reset();
+ if (views.at(i)->inputContext())
+ views.at(i)->inputContext()->reset();
}
}
#endif //QT_NO_IM
@@ -4692,7 +4693,8 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (widget)
item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
viewBoundingRect.adjust(-1, -1, 1, 1);
- drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect) : !viewBoundingRect.isEmpty();
+ drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
+ : !viewBoundingRect.normalized().isEmpty();
if (!drawItem) {
if (!itemHasChildren)
return;
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 06b74383e7..1ced3d7d83 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -3400,6 +3400,13 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
if (!d->scene->d_func()->painterStateProtection)
painter.setWorldTransform(viewTransform);
} else {
+ // Make sure we don't have unpolished items before we draw
+ if (!d->scene->d_func()->unpolishedItems.isEmpty())
+ d->scene->d_func()->_q_polishItems();
+ // We reset updateAll here (after we've issued polish events)
+ // so that we can discard update requests coming from polishEvent().
+ d->scene->d_func()->updateAll = false;
+
// Find all exposed items
bool allItems = false;
QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform);
@@ -3408,9 +3415,25 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
const int numItems = itemList.size();
QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid.
QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
+ QTransform transform(Qt::Uninitialized);
for (int i = 0; i < numItems; ++i) {
- itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], viewTransform,
- d->exposedRegion, allItems);
+ QGraphicsItem *item = itemArray[i];
+ QGraphicsItemPrivate *itemd = item->d_ptr.data();
+ itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems);
+ // Cache the item's area in view coordinates.
+ // Note that we have to do this here in case the base class implementation
+ // (QGraphicsScene::drawItems) is not called. If it is, we'll do this
+ // operation twice, but that's the price one has to pay for using indirect
+ // painting :-/.
+ const QRectF brect = adjustedItemEffectiveBoundingRect(item);
+ if (!itemd->itemIsUntransformable()) {
+ transform = item->sceneTransform();
+ if (viewTransformed)
+ transform *= viewTransform;
+ } else {
+ transform = item->deviceTransform(viewTransform);
+ }
+ itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect());
}
// Draw the items.
drawItems(&painter, numItems, itemArray, styleOptionArray);
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 22269012ff..844638789d 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -182,7 +182,7 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
qWarning() << "Error while marking the shared memory segment to be destroyed";
ok = (xshminfo.shmaddr != (char*)-1);
if (ok)
- image = QImage((uchar *)xshmimg->data, width, height, systemFormat());
+ image = QImage((uchar *)xshmimg->data, width, height, format);
}
xshminfo.readOnly = false;
if (ok)
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index adf3ce3475..bc6db90cc9 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2119,6 +2119,11 @@ void QAbstractItemView::focusOutEvent(QFocusEvent *event)
Q_D(QAbstractItemView);
QAbstractScrollArea::focusOutEvent(event);
d->viewport->update();
+
+#ifdef QT_SOFTKEYS_ENABLED
+ if(!hasEditFocus())
+ removeAction(d->doneSoftKey);
+#endif
}
/*!
@@ -2144,7 +2149,12 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
if (!hasEditFocus()) {
setEditFocus(true);
#ifdef QT_SOFTKEYS_ENABLED
- addAction(d->doneSoftKey);
+ // If we can't keypad navigate to any direction, there is no sense to add
+ // "Done" softkey, since it basically does nothing when there is
+ // only one widget in screen
+ if(QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)
+ || QWidgetPrivate::canKeypadNavigate(Qt::Vertical))
+ addAction(d->doneSoftKey);
#endif
return;
}
@@ -2160,6 +2170,26 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
event->ignore();
}
return;
+ case Qt::Key_Down:
+ case Qt::Key_Up:
+ // Let's ignore vertical navigation events, only if there is no other widget
+ // what can take the focus in vertical direction. This means widget can handle navigation events
+ // even the widget don't have edit focus, and there is no other widget in requested direction.
+ if(QApplication::keypadNavigationEnabled() && !hasEditFocus()
+ && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {
+ event->ignore();
+ return;
+ }
+ break;
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ // Similar logic as in up and down events
+ if(QApplication::keypadNavigationEnabled() && !hasEditFocus()
+ && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this))) {
+ event->ignore();
+ return;
+ }
+ break;
default:
if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
event->ignore();
@@ -2245,7 +2275,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
case Qt::Key_Down:
case Qt::Key_Up:
#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled()) {
+ if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {
event->accept(); // don't change focus
break;
}
@@ -2253,8 +2283,10 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
case Qt::Key_Left:
case Qt::Key_Right:
#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
- event->accept(); // don't change horizontal focus in directional mode
+ if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
+ && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)
+ || (QWidgetPrivate::inTabWidget(this) && d->model->columnCount(d->root) > 1))) {
+ event->accept(); // don't change focus
break;
}
#endif // QT_KEYPAD_NAVIGATION
diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp
index 40345a77f2..43a13278b9 100644
--- a/src/gui/itemviews/qabstractproxymodel.cpp
+++ b/src/gui/itemviews/qabstractproxymodel.cpp
@@ -127,6 +127,7 @@ void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
} else {
d->model = QAbstractItemModelPrivate::staticEmptyModel();
}
+ d->roleNames = d->model->roleNames();
}
/*!
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 3e2e6f67de..baefdfd1f9 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -597,7 +597,9 @@ TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCod
TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode,
keyEvent.iCode);
int keyCode;
- if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) {
+ if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used
+ keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode);
+ } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) {
// Normal characters keys.
keyCode = s60Keysym;
} else {
@@ -1146,6 +1148,10 @@ void qt_init(QApplicationPrivate * /* priv */, int)
#endif
S60->wsSession().SetAutoFlush(ETrue);
+#ifdef Q_SYMBIAN_WINDOW_SIZE_CACHE
+ TRAP_IGNORE(S60->wsSession().EnableWindowSizeCacheL());
+#endif
+
S60->updateScreenSize();
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 31d245f612..131b9bb7dd 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1905,8 +1905,13 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
if (!msg.wParam) {
+#ifdef Q_WS_WINCE
+ // On Windows CE, lParam parameter is a constant, not a char pointer.
+ if (msg.lParam == INI_INTL) {
+#else
QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
if (area == QLatin1String("intl")) {
+#endif
QLocalePrivate::updateSystemPrivate();
if (!widget->testAttribute(Qt::WA_SetLocale))
widget->dptr()->setLocale_helper(QLocale(), true);
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index 09c36c88b9..3e42d6e4bf 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -207,12 +207,12 @@ public:
KeyboardLayoutItem *keyLayout[256];
#elif defined(Q_WS_QWS)
#elif defined(Q_OS_SYMBIAN)
-private:
- QHash<TUint, int> s60ToQtKeyMap;
- void fillKeyMap();
public:
QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
int mapS60KeyToQt(TUint s60key);
+ int mapS60ScanCodesToQt(TUint s60key);
+ int mapQtToS60Key(int qtKey);
+ int mapQtToS60ScanCodes(int qtKey);
#endif
};
diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp
index 6e21420112..fd263ef2c3 100644
--- a/src/gui/kernel/qkeymapper_s60.cpp
+++ b/src/gui/kernel/qkeymapper_s60.cpp
@@ -46,7 +46,6 @@ QT_BEGIN_NAMESPACE
QKeyMapperPrivate::QKeyMapperPrivate()
{
- fillKeyMap();
}
QKeyMapperPrivate::~QKeyMapperPrivate()
@@ -74,174 +73,145 @@ QString QKeyMapperPrivate::translateKeyEvent(int keySym, Qt::KeyboardModifiers /
return QString(QChar(keySym));
}
-void QKeyMapperPrivate::fillKeyMap()
+#include <e32keys.h>
+struct KeyMapping{
+ TKeyCode s60KeyCode;
+ TStdScanCode s60ScanCode;
+ Qt::Key qtKey;
+};
+
+using namespace Qt;
+
+static const KeyMapping keyMapping[] = {
+ {EKeyBackspace, EStdKeyBackspace, Key_Backspace},
+ {EKeyTab, EStdKeyTab, Key_Tab},
+ {EKeyEnter, EStdKeyEnter, Key_Enter},
+ {EKeyEscape, EStdKeyEscape, Key_Escape},
+ {EKeySpace, EStdKeySpace, Key_Space},
+ {EKeyDelete, EStdKeyDelete, Key_Delete},
+ {EKeyPrintScreen, EStdKeyPrintScreen, Key_SysReq},
+ {EKeyPause, EStdKeyPause, Key_Pause},
+ {EKeyHome, EStdKeyHome, Key_Home},
+ {EKeyEnd, EStdKeyEnd, Key_End},
+ {EKeyPageUp, EStdKeyPageUp, Key_PageUp},
+ {EKeyPageDown, EStdKeyPageDown, Key_PageDown},
+ {EKeyInsert, EStdKeyInsert, Key_Insert},
+ {EKeyLeftArrow, EStdKeyLeftArrow, Key_Left},
+ {EKeyRightArrow, EStdKeyRightArrow, Key_Right},
+ {EKeyUpArrow, EStdKeyUpArrow, Key_Up},
+ {EKeyDownArrow, EStdKeyDownArrow, Key_Down},
+ {EKeyLeftShift, EStdKeyLeftShift, Key_Shift},
+ {EKeyRightShift, EStdKeyRightShift, Key_Shift},
+ {EKeyLeftAlt, EStdKeyLeftAlt, Key_Alt},
+ {EKeyRightAlt, EStdKeyRightAlt, Key_AltGr},
+ {EKeyLeftCtrl, EStdKeyLeftCtrl, Key_Control},
+ {EKeyRightCtrl, EStdKeyRightCtrl, Key_Control},
+ {EKeyLeftFunc, EStdKeyLeftFunc, Key_Super_L},
+ {EKeyRightFunc, EStdKeyRightFunc, Key_Super_R},
+ {EKeyCapsLock, EStdKeyCapsLock, Key_CapsLock},
+ {EKeyNumLock, EStdKeyNumLock, Key_NumLock},
+ {EKeyScrollLock, EStdKeyScrollLock, Key_ScrollLock},
+ {EKeyF1, EStdKeyF1, Key_F1},
+ {EKeyF2, EStdKeyF2, Key_F2},
+ {EKeyF3, EStdKeyF3, Key_F3},
+ {EKeyF4, EStdKeyF4, Key_F4},
+ {EKeyF5, EStdKeyF5, Key_F5},
+ {EKeyF6, EStdKeyF6, Key_F6},
+ {EKeyF7, EStdKeyF7, Key_F7},
+ {EKeyF8, EStdKeyF8, Key_F8},
+ {EKeyF9, EStdKeyF9, Key_F9},
+ {EKeyF10, EStdKeyF10, Key_F10},
+ {EKeyF11, EStdKeyF11, Key_F11},
+ {EKeyF12, EStdKeyF12, Key_F12},
+ {EKeyF13, EStdKeyF13, Key_F13},
+ {EKeyF14, EStdKeyF14, Key_F14},
+ {EKeyF15, EStdKeyF15, Key_F15},
+ {EKeyF16, EStdKeyF16, Key_F16},
+ {EKeyF17, EStdKeyF17, Key_F17},
+ {EKeyF18, EStdKeyF18, Key_F18},
+ {EKeyF19, EStdKeyF19, Key_F19},
+ {EKeyF20, EStdKeyF20, Key_F20},
+ {EKeyF21, EStdKeyF21, Key_F21},
+ {EKeyF22, EStdKeyF22, Key_F22},
+ {EKeyF23, EStdKeyF23, Key_F23},
+ {EKeyF24, EStdKeyF24, Key_F24},
+ {EKeyOff, EStdKeyOff, Key_PowerOff},
+// {EKeyMenu, EStdKeyMenu, Key_Menu}, // Menu is EKeyApplication0
+ {EKeyHelp, EStdKeyHelp, Key_Help},
+ {EKeyDial, EStdKeyDial, Key_Call},
+ {EKeyIncVolume, EStdKeyIncVolume, Key_VolumeUp},
+ {EKeyDecVolume, EStdKeyDecVolume, Key_VolumeDown},
+ {EKeyDevice0, EStdKeyDevice0, Key_Context1}, // Found by manual testing.
+ {EKeyDevice1, EStdKeyDevice1, Key_Context2}, // Found by manual testing.
+ {EKeyDevice3, EStdKeyDevice3, Key_Select},
+// {EKeyDevice7, EStdKeyDevice7, Key_Camera}, //not supported by qt yet
+ {EKeyApplication0, EStdKeyApplication0, Key_Menu}, // Found by manual testing.
+ {EKeyApplication1, EStdKeyApplication1, Key_Launch1}, // Found by manual testing.
+ {EKeyApplication2, EStdKeyApplication2, Key_MediaPlay}, // Found by manual testing.
+ {EKeyApplication3, EStdKeyApplication3, Key_MediaStop}, // Found by manual testing.
+ {EKeyApplication4, EStdKeyApplication4, Key_MediaNext}, // Found by manual testing.
+ {EKeyApplication5, EStdKeyApplication5, Key_MediaPrevious}, // Found by manual testing.
+ {EKeyApplication6, EStdKeyApplication6, Key_Launch6},
+ {EKeyApplication7, EStdKeyApplication7, Key_Launch7},
+ {EKeyApplication8, EStdKeyApplication8, Key_Launch8},
+ {EKeyApplication9, EStdKeyApplication9, Key_Launch9},
+ {EKeyApplicationA, EStdKeyApplicationA, Key_LaunchA},
+ {EKeyApplicationB, EStdKeyApplicationB, Key_LaunchB},
+ {EKeyApplicationC, EStdKeyApplicationC, Key_LaunchC},
+ {EKeyApplicationD, EStdKeyApplicationD, Key_LaunchD},
+ {EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE},
+ {EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF},
+// {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus}, //not supported by qt yet
+ {EKeyYes, EStdKeyYes, Key_Yes},
+ {EKeyNo, EStdKeyNo, Key_No},
+ {TKeyCode(0), TStdScanCode(0), Qt::Key(0)}
+};
+
+int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key)
{
- using namespace Qt;
- static const struct {
- TUint s60Key;
- int qtKey;
- } map[] = {
- {EKeyBell, Key_unknown},
- {EKeyBackspace, Key_Backspace},
- {EKeyTab, Key_Tab},
- {EKeyLineFeed, Key_unknown},
- {EKeyVerticalTab, Key_unknown},
- {EKeyFormFeed, Key_unknown},
- {EKeyEnter, Key_Enter},
- {EKeyEscape, Key_Escape},
- {EKeySpace, Key_Space},
- {EKeyDelete, Key_Delete},
- {EKeyPrintScreen, Key_SysReq},
- {EKeyPause, Key_Pause},
- {EKeyHome, Key_Home},
- {EKeyEnd, Key_End},
- {EKeyPageUp, Key_PageUp},
- {EKeyPageDown, Key_PageDown},
- {EKeyInsert, Key_Insert},
- {EKeyLeftArrow, Key_Left},
- {EKeyRightArrow, Key_Right},
- {EKeyUpArrow, Key_Up},
- {EKeyDownArrow, Key_Down},
- {EKeyLeftShift, Key_Shift},
- {EKeyRightShift, Key_Shift},
- {EKeyLeftAlt, Key_Alt},
- {EKeyRightAlt, Key_AltGr},
- {EKeyLeftCtrl, Key_Control},
- {EKeyRightCtrl, Key_Control},
- {EKeyLeftFunc, Key_Super_L},
- {EKeyRightFunc, Key_Super_R},
- {EKeyCapsLock, Key_CapsLock},
- {EKeyNumLock, Key_NumLock},
- {EKeyScrollLock, Key_ScrollLock},
- {EKeyF1, Key_F1},
- {EKeyF2, Key_F2},
- {EKeyF3, Key_F3},
- {EKeyF4, Key_F4},
- {EKeyF5, Key_F5},
- {EKeyF6, Key_F6},
- {EKeyF7, Key_F7},
- {EKeyF8, Key_F8},
- {EKeyF9, Key_F9},
- {EKeyF10, Key_F10},
- {EKeyF11, Key_F11},
- {EKeyF12, Key_F12},
- {EKeyF13, Key_F13},
- {EKeyF14, Key_F14},
- {EKeyF15, Key_F15},
- {EKeyF16, Key_F16},
- {EKeyF17, Key_F17},
- {EKeyF18, Key_F18},
- {EKeyF19, Key_F19},
- {EKeyF20, Key_F20},
- {EKeyF21, Key_F21},
- {EKeyF22, Key_F22},
- {EKeyF23, Key_F23},
- {EKeyF24, Key_F24},
- {EKeyOff, Key_unknown},
- {EKeyIncContrast, Key_unknown},
- {EKeyDecContrast, Key_unknown},
- {EKeyBacklightOn, Key_unknown},
- {EKeyBacklightOff, Key_unknown},
- {EKeyBacklightToggle, Key_unknown},
- {EKeySliderDown, Key_unknown},
- {EKeySliderUp, Key_unknown},
- {EKeyMenu, Key_Menu},
- {EKeyDictaphonePlay, Key_unknown},
- {EKeyDictaphoneStop, Key_unknown},
- {EKeyDictaphoneRecord, Key_unknown},
- {EKeyHelp, Key_unknown},
- {EKeyDial, Key_Call},
- {EKeyScreenDimension0, Key_unknown},
- {EKeyScreenDimension1, Key_unknown},
- {EKeyScreenDimension2, Key_unknown},
- {EKeyScreenDimension3, Key_unknown},
- {EKeyIncVolume, Key_unknown},
- {EKeyDecVolume, Key_unknown},
- {EKeyDevice0, Key_Context1}, // Found by manual testing, left softkey.
- {EKeyDevice1, Key_Context2}, // Found by manual testing.
- {EKeyDevice2, Key_unknown},
- {EKeyDevice3, Key_Select}, // Found by manual testing.
- {EKeyDevice4, Key_unknown},
- {EKeyDevice5, Key_unknown},
- {EKeyDevice6, Key_unknown},
- {EKeyDevice7, Key_unknown},
- {EKeyDevice8, Key_unknown},
- {EKeyDevice9, Key_unknown},
- {EKeyDeviceA, Key_unknown},
- {EKeyDeviceB, Key_unknown},
- {EKeyDeviceC, Key_unknown},
- {EKeyDeviceD, Key_unknown},
- {EKeyDeviceE, Key_unknown},
- {EKeyDeviceF, Key_unknown},
- {EKeyApplication0, Key_Launch0},
- {EKeyApplication1, Key_Launch1},
- {EKeyApplication2, Key_Launch2},
- {EKeyApplication3, Key_Launch3},
- {EKeyApplication4, Key_Launch4},
- {EKeyApplication5, Key_Launch5},
- {EKeyApplication6, Key_Launch6},
- {EKeyApplication7, Key_Launch7},
- {EKeyApplication8, Key_Launch8},
- {EKeyApplication9, Key_Launch9},
- {EKeyApplicationA, Key_LaunchA},
- {EKeyApplicationB, Key_LaunchB},
- {EKeyApplicationC, Key_LaunchC},
- {EKeyApplicationD, Key_LaunchD},
- {EKeyApplicationE, Key_LaunchE},
- {EKeyApplicationF, Key_LaunchF},
- {EKeyYes, Key_Yes},
- {EKeyNo, Key_No},
- {EKeyIncBrightness, Key_unknown},
- {EKeyDecBrightness, Key_unknown},
- {EKeyKeyboardExtend, Key_unknown},
- {EKeyDevice10, Key_unknown},
- {EKeyDevice11, Key_unknown},
- {EKeyDevice12, Key_unknown},
- {EKeyDevice13, Key_unknown},
- {EKeyDevice14, Key_unknown},
- {EKeyDevice15, Key_unknown},
- {EKeyDevice16, Key_unknown},
- {EKeyDevice17, Key_unknown},
- {EKeyDevice18, Key_unknown},
- {EKeyDevice19, Key_unknown},
- {EKeyDevice1A, Key_unknown},
- {EKeyDevice1B, Key_unknown},
- {EKeyDevice1C, Key_unknown},
- {EKeyDevice1D, Key_unknown},
- {EKeyDevice1E, Key_unknown},
- {EKeyDevice1F, Key_unknown},
- {EKeyApplication10, Key_unknown},
- {EKeyApplication11, Key_unknown},
- {EKeyApplication12, Key_unknown},
- {EKeyApplication13, Key_unknown},
- {EKeyApplication14, Key_unknown},
- {EKeyApplication15, Key_unknown},
- {EKeyApplication16, Key_unknown},
- {EKeyApplication17, Key_unknown},
- {EKeyApplication18, Key_unknown},
- {EKeyApplication19, Key_unknown},
- {EKeyApplication1A, Key_unknown},
- {EKeyApplication1B, Key_unknown},
- {EKeyApplication1C, Key_unknown},
- {EKeyApplication1D, Key_unknown},
- {EKeyApplication1E, Key_unknown},
- {EKeyApplication1F, Key_unknown}
- };
- const int mapSize = int(sizeof(map)/sizeof(map[0]));
- s60ToQtKeyMap.reserve(mapSize + 5); // +5? docs: Ideally, slightly more than number of items
- for (int i = 0; i < mapSize; ++i)
- s60ToQtKeyMap.insert(map[i].s60Key, map[i].qtKey);
+ int res = Qt::Key_unknown;
+ for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) {
+ if (keyMapping[i].s60KeyCode == s60key) {
+ res = keyMapping[i].qtKey;
+ break;
+ }
+ }
+ return res;
}
-int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key)
+int QKeyMapperPrivate::mapS60ScanCodesToQt(TUint s60scanCode)
{
- QHash<TUint, int>::const_iterator mapping;
- mapping = s60ToQtKeyMap.find(s60key);
- if (mapping != s60ToQtKeyMap.end()) {
- return *mapping;
- } else {
- return Qt::Key_unknown;
+ int res = Qt::Key_unknown;
+ for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) {
+ if (keyMapping[i].s60ScanCode == s60scanCode) {
+ res = keyMapping[i].qtKey;
+ break;
+ }
}
+ return res;
}
+int QKeyMapperPrivate::mapQtToS60Key(int qtKey)
+{
+ int res = KErrUnknown;
+ for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) {
+ if (keyMapping[i].qtKey == qtKey) {
+ res = keyMapping[i].s60KeyCode;
+ break;
+ }
+ }
+ return res;
+}
+
+int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey)
+{
+ int res = KErrUnknown;
+ for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) {
+ if (keyMapping[i].qtKey == qtKey) {
+ res = keyMapping[i].s60ScanCode;
+ break;
+ }
+ }
+ return res;
+}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 1e9b1d9552..2f6ec6be57 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -118,6 +118,10 @@
#include "private/qgraphicssystem_p.h"
#include "private/qgesturemanager_p.h"
+#ifdef QT_KEYPAD_NAVIGATION
+#include "qtabwidget.h" // Needed in inTabWidget()
+#endif // QT_KEYPAD_NAVIGATION
+
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
//#define ALIEN_DEBUG
@@ -11641,6 +11645,45 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction)
}
return targetWidget;
}
+
+/*!
+ \internal
+
+ Tells us if it there is currently a reachable widget by keypad navigation in
+ a certain \a orientation.
+ If no navigation is possible, occuring key events in that \a orientation may
+ be used to interact with the value in the focussed widget, even though it
+ currently has not the editFocus.
+
+ \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus()
+*/
+bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation)
+{
+ return orientation == Qt::Horizontal?
+ (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast)
+ || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest))
+ :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth)
+ || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth));
+}
+/*!
+ \internal
+
+ Checks, if the \a widget is inside a QTabWidget. If is is inside
+ one, left/right key events will be used to switch between tabs in keypad
+ navigation. If there is no QTabWidget, the horizontal key events can be used
+to
+ interact with the value in the focussed widget, even though it currently has
+ not the editFocus.
+
+ \sa QWidget::hasEditFocus()
+*/
+bool QWidgetPrivate::inTabWidget(QWidget *widget)
+{
+ for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget())
+ if (qobject_cast<const QTabWidget*>(tabWidget))
+ return true;
+ return false;
+}
#endif
/*!
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index da9e9eb302..dcb87fcd93 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4543,8 +4543,20 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
}
}
+ // ### Scroll the dirty regions as well, the following is not correct.
+ QRegion displayRegion = r.isNull() ? dirtyOnWidget : (dirtyOnWidget & r);
+ const QVector<QRect> &rects = dirtyOnWidget.rects();
+ const QVector<QRect>::const_iterator end = rects.end();
+ QVector<QRect>::const_iterator it = rects.begin();
+ while (it != end) {
+ const QRect rect = *it;
+ const NSRect dirtyRect = NSMakeRect(rect.x() + dx, rect.y() + dy,
+ rect.width(), rect.height());
+ [view setNeedsDisplayInRect:dirtyRect];
+ ++it;
+ }
+
NSSize deltaSize = NSMakeSize(dx, dy);
- [view translateRectsNeedingDisplayInRect:scrollRect by:deltaSize];
[view scrollRect:scrollRect by:deltaSize];
[view setNeedsDisplayInRect:deltaXRect];
[view setNeedsDisplayInRect:deltaYRect];
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 75b4c12b33..efd9a0a551 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -475,6 +475,8 @@ public:
#ifdef QT_KEYPAD_NAVIGATION
static bool navigateToDirection(Direction direction);
static QWidget *widgetInNavigationDirection(Direction direction);
+ static bool canKeypadNavigate(Qt::Orientation orientation);
+ static bool inTabWidget(QWidget *widget);
#endif
void setWindowIconText_sys(const QString &cap);
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 1f9fc32c67..bc1bece269 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -5749,6 +5749,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
}
+#ifndef QT_NO_TOOLBAR
+ case SE_ToolBarHandle:
+ if (hasStyleRule(w, PseudoElement_ToolBarHandle))
+ return ParentStyle::subElementRect(se, opt, w);
+ break;
+#endif //QT_NO_TOOLBAR
+
default:
break;
}
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 4bd7b5ab8f..2888490f23 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -47,9 +47,6 @@
#ifndef QT_NO_ACCESSIBILITY
#include "qaccessible.h"
#endif
-#ifdef QT_KEYPAD_NAVIGATION
-#include "qtabwidget.h" // Needed in inTabWidget()
-#endif // QT_KEYPAD_NAVIGATION
#include <limits.h>
QT_BEGIN_NAMESPACE
@@ -702,7 +699,7 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb
stepsToScroll = qBound(-pageStep, int(offset * pageStep), pageStep);
offset_accumulated = 0;
} else {
- // Calculate how many lines to scroll. Depending on what delta is (and
+ // Calculate how many lines to scroll. Depending on what delta is (and
// offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can
// only scroll whole lines, so we keep the reminder until next event.
qreal stepsToScrollF =
@@ -749,45 +746,7 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
}
#endif
-#ifdef QT_KEYPAD_NAVIGATION
-/*!
- \internal
-
- Tells us if it there is currently a reachable widget by keypad navigation in
- a certain \a orientation.
- If no navigation is possible, occuring key events in that \a orientation may
- be used to interact with the value in the focussed widget, even though it
- currently has not the editFocus.
- \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus()
-*/
-inline static bool canKeypadNavigate(Qt::Orientation orientation)
-{
- return orientation == Qt::Horizontal?
- (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast)
- || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest))
- :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth)
- || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth));
-}
-/*!
- \internal
-
- Checks, if the \a widget is inside a QTabWidget. If is is inside
- one, left/right key events will be used to switch between tabs in keypad
- navigation. If there is no QTabWidget, the horizontal key events can be used to
- interact with the value in the focussed widget, even though it currently has
- not the editFocus.
-
- \sa QWidget::hasEditFocus()
-*/
-inline static bool inTabWidget(QWidget *widget)
-{
- for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget())
- if (qobject_cast<const QTabWidget*>(tabWidget))
- return true;
- return false;
-}
-#endif // QT_KEYPAD_NAVIGATION
/*!
\reimp
*/
@@ -853,7 +812,8 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
if (QApplication::keypadNavigationEnabled()
&& (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
|| d->orientation == Qt::Vertical
- || !hasEditFocus() && (canKeypadNavigate(Qt::Horizontal) || inTabWidget(this)))) {
+ || !hasEditFocus()
+ && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) {
ev->ignore();
return;
}
@@ -872,7 +832,8 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
if (QApplication::keypadNavigationEnabled()
&& (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
|| d->orientation == Qt::Vertical
- || !hasEditFocus() && (canKeypadNavigate(Qt::Horizontal) || inTabWidget(this)))) {
+ || !hasEditFocus()
+ && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) {
ev->ignore();
return;
}
@@ -892,7 +853,7 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
if (QApplication::keypadNavigationEnabled()
&& (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
|| d->orientation == Qt::Horizontal
- || !hasEditFocus() && canKeypadNavigate(Qt::Vertical))) {
+ || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) {
ev->ignore();
break;
}
@@ -905,7 +866,7 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
if (QApplication::keypadNavigationEnabled()
&& (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
|| d->orientation == Qt::Horizontal
- || !hasEditFocus() && canKeypadNavigate(Qt::Vertical))) {
+ || !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical))) {
ev->ignore();
break;
}
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index 2b8cf598b1..c1b1ea3011 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -2993,8 +2993,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
QRect r = constrainedRect(placeHolder->topLevelRect, desktop.screenGeometry(dockWidget));
dockWidget->d_func()->setWindowState(true, true, r);
}
- dockWidget->show();
-// dockWidget->setVisible(!placeHolder->hidden);
+ dockWidget->setVisible(!placeHolder->hidden);
#ifdef Q_WS_X11
if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag
dockWidget->d_func()->setWindowState(true);
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index 1aa7a2bfa5..2c76a5c587 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -129,7 +129,7 @@ void QLineEditPrivate::_q_editFocusChange(bool e)
void QLineEditPrivate::_q_selectionChanged()
{
Q_Q(QLineEdit);
- if (control->preeditAreaText().isEmpty()) {
+ if (!control->text().isEmpty() && control->preeditAreaText().isEmpty()) {
QStyleOptionFrameV2 opt;
q->initStyleOption(&opt);
bool showCursor = control->hasSelectedText() ?
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp
index 45cafc1936..fd892dd551 100644
--- a/src/multimedia/audio/qaudioinput.cpp
+++ b/src/multimedia/audio/qaudioinput.cpp
@@ -190,18 +190,18 @@ QAudioInput::~QAudioInput()
Passing a QIODevice allows the data to be transfered without any extra code.
All that is required is to open the QIODevice.
+ If able to successfully get audio data from the systems audio device the
+ state() is set to either QAudio::ActiveState or QAudio::IdleState,
+ error() is set to QAudio::NoError and the stateChanged() signal is emitted.
+
+ If a problem occurs during this process the error() is set to QAudio::OpenError,
+ state() is set to QAudio::StoppedState and stateChanged() signal is emitted.
+
\sa QIODevice
*/
void QAudioInput::start(QIODevice* device)
{
- /*
- -If currently not StoppedState, stop
- -If previous start was push mode, delete internal QIODevice.
- -open audio input.
- If ok, NoError and ActiveState, else OpenError and StoppedState.
- -emit stateChanged()
- */
d->start(device);
}
@@ -210,19 +210,18 @@ void QAudioInput::start(QIODevice* device)
transfer. This QIODevice can be used to read() audio data
directly.
+ If able to access the systems audio device the state() is set to
+ QAudio::IdleState, error() is set to QAudio::NoError
+ and the stateChanged() signal is emitted.
+
+ If a problem occurs during this process the error() is set to QAudio::OpenError,
+ state() is set to QAudio::StoppedState and stateChanged() signal is emitted.
+
\sa QIODevice
*/
QIODevice* QAudioInput::start()
{
- /*
- -If currently not StoppedState, stop
- -If no internal QIODevice, create one.
- -open audio input.
- -If ok, NoError and IdleState, else OpenError and StoppedState
- -emit stateChanged()
- -return internal QIODevice
- */
return d->start(0);
}
@@ -236,17 +235,14 @@ QAudioFormat QAudioInput::format() const
}
/*!
- Stops the audio input.
+ Stops the audio input, detaching from the system resource.
+
+ Sets error() to QAudio::NoError, state() to QAudio::StoppedState and
+ emit stateChanged() signal.
*/
void QAudioInput::stop()
{
- /*
- -If StoppedState, return
- -set to StoppedState
- -detach from audio device
- -emit stateChanged()
- */
d->stop();
}
@@ -256,42 +252,32 @@ void QAudioInput::stop()
void QAudioInput::reset()
{
- /*
- -drop all buffered audio, set buffers to zero.
- -call stop()
- */
d->reset();
}
/*!
Stops processing audio data, preserving buffered audio data.
+
+ Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and
+ emit stateChanged() signal.
*/
void QAudioInput::suspend()
{
- /*
- -If not ActiveState|IdleState, return
- -stop processing audio, saving all buffered audio data
- -set NoError and SuspendedState
- -emit stateChanged()
- */
d->suspend();
}
/*!
Resumes processing audio data after a suspend().
+
+ Sets error() to QAudio::NoError.
+ Sets state() to QAudio::ActiveState if you previously called start(QIODevice*).
+ Sets state() to QAudio::IdleState if you previously called start().
+ emits stateChanged() signal.
*/
void QAudioInput::resume()
{
- /*
- -If SuspendedState, return
- -resume audio
- -(PULL MODE): set ActiveState, NoError
- -(PUSH MODE): set IdleState, NoError
- -kick start audio if needed
- -emit stateChanged()
- */
d->resume();
}
@@ -327,6 +313,9 @@ int QAudioInput::bufferSize() const
/*!
Returns the amount of audio data available to read in bytes.
+
+ NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState
+ state, otherwise returns zero.
*/
int QAudioInput::bytesReady() const
@@ -352,7 +341,10 @@ int QAudioInput::periodSize() const
/*!
Sets the interval for notify() signal to be emitted.
This is based on the \a ms of audio data processed
- not on actual real-time. The resolution of the timer is platform specific.
+ not on actual real-time.
+ The minimum resolution of the timer is platform specific and values
+ should be checked with notifyInterval() to confirm actual value
+ being used.
*/
void QAudioInput::setNotifyInterval(int ms)
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index 26e46b3376..6010f3ce33 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -217,9 +217,11 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
//set to pull mode
pullMode = true;
audioSource = device;
+ deviceState = QAudio::ActiveState;
} else {
//set to push mode
pullMode = false;
+ deviceState = QAudio::IdleState;
audioSource = new InputPrivate(this);
audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
}
@@ -413,7 +415,6 @@ bool QAudioInputPrivate::open()
timer->start(period_time*chunks/2000);
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
totalTimeValue = 0;
@@ -439,7 +440,7 @@ int QAudioInputPrivate::bytesReady() const
if(resuming)
return period_size;
- if(deviceState != QAudio::ActiveState)
+ if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
return 0;
int frames = snd_pcm_avail_update(handle);
if((int)frames > (int)buffer_frames)
@@ -450,8 +451,8 @@ int QAudioInputPrivate::bytesReady() const
qint64 QAudioInputPrivate::read(char* data, qint64 len)
{
- Q_UNUSED(data)
Q_UNUSED(len)
+
// Read in some audio data and write it to QIODevice, pull mode
if ( !handle )
return 0;
@@ -468,7 +469,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
if (readFrames >= 0) {
err = snd_pcm_frames_to_bytes(handle, readFrames);
#ifdef DEBUG_AUDIO
- qDebug()<<QString::fromLatin1("PULL: read in bytes = %1 (frames=%2)").arg(err).arg(readFrames).toLatin1().constData();
+ qDebug()<<QString::fromLatin1("read in bytes = %1 (frames=%2)").arg(err).arg(readFrames).toLatin1().constData();
#endif
break;
} else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) {
@@ -489,28 +490,46 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
if(err > 0) {
// got some send it onward
#ifdef DEBUG_AUDIO
- qDebug()<<"PULL: frames to write to QIODevice = "<<
+ qDebug()<<"frames to write to QIODevice = "<<
snd_pcm_bytes_to_frames( handle, (int)err )<<" ("<<err<<") bytes";
#endif
- if(deviceState != QAudio::ActiveState)
+ if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
return 0;
+ if (pullMode) {
+ qint64 l = audioSource->write(audioBuffer,err);
+ if(l < 0) {
+ close();
+ errorState = QAudio::IOError;
+ deviceState = QAudio::StoppedState;
+ emit stateChanged(deviceState);
+ } else if(l == 0) {
+ if (deviceState != QAudio::IdleState) {
+ errorState = QAudio::NoError;
+ deviceState = QAudio::IdleState;
+ emit stateChanged(deviceState);
+ }
+ } else {
+ totalTimeValue += err;
+ resuming = false;
+ if (deviceState != QAudio::ActiveState) {
+ errorState = QAudio::NoError;
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
+ }
+ return l;
- qint64 l = audioSource->write(audioBuffer,err);
- if(l < 0) {
- close();
- errorState = QAudio::IOError;
- deviceState = QAudio::StoppedState;
- emit stateChanged(deviceState);
- } else if(l == 0) {
- errorState = QAudio::NoError;
- deviceState = QAudio::IdleState;
} else {
- totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.frequency();
+ memcpy(data,audioBuffer,err);
+ totalTimeValue += err;
resuming = false;
- errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
+ if (deviceState != QAudio::ActiveState) {
+ errorState = QAudio::NoError;
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
+ return err;
}
- return l;
}
return 0;
}
@@ -569,7 +588,7 @@ int QAudioInputPrivate::notifyInterval() const
qint64 QAudioInputPrivate::processedUSecs() const
{
- return totalTimeValue;
+ return qint64(1000000) * totalTimeValue / settings.frequency();
}
void QAudioInputPrivate::suspend()
@@ -617,34 +636,10 @@ bool QAudioInputPrivate::deviceReady()
qint64 QAudioInputPrivate::elapsedUSecs() const
{
- if(!handle)
- return 0;
-
if (deviceState == QAudio::StoppedState)
return 0;
-#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
- snd_pcm_status_t* status;
- snd_pcm_status_alloca(&status);
-
- snd_timestamp_t t1,t2;
- if( snd_pcm_status(handle, status) >= 0) {
- snd_pcm_status_get_tstamp(status,&t1);
- snd_pcm_status_get_trigger_tstamp(status,&t2);
- t1.tv_sec-=t2.tv_sec;
-
- signed long l = (signed long)t1.tv_usec - (signed long)t2.tv_usec;
- if(l < 0) {
- t1.tv_sec--;
- l = -l;
- l %= 1000000;
- }
- return ((t1.tv_sec * 1000000)+l);
- } else
- return 0;
-#else
return clockStamp.elapsed()*1000;
-#endif
}
void QAudioInputPrivate::reset()
@@ -670,43 +665,7 @@ InputPrivate::~InputPrivate()
qint64 InputPrivate::readData( char* data, qint64 len)
{
- // push mode, user read() called
- if((audioDevice->state() != QAudio::ActiveState) && !audioDevice->resuming)
- return 0;
-
- int readFrames;
- int count=0, err = 0;
-
- while(count < 5) {
- int frames = snd_pcm_bytes_to_frames(audioDevice->handle, len);
- readFrames = snd_pcm_readi(audioDevice->handle, data, frames);
- if (readFrames >= 0) {
- err = snd_pcm_frames_to_bytes(audioDevice->handle, readFrames);
-#ifdef DEBUG_AUDIO
- qDebug()<<QString::fromLatin1("PUSH: read in bytes = %1 (frames=%2)").arg(err).arg(readFrames).toLatin1().constData();
-#endif
- break;
- } else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) {
- audioDevice->errorState = QAudio::IOError;
- err = 0;
- break;
- } else {
- if(readFrames == -EPIPE) {
- audioDevice->errorState = QAudio::UnderrunError;
- err = snd_pcm_prepare(audioDevice->handle);
- } else if(readFrames == -ESTRPIPE) {
- err = snd_pcm_prepare(audioDevice->handle);
- }
- if(err != 0) break;
- }
- count++;
- }
- if(err > 0 && readFrames > 0) {
- audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.frequency()*1000;
- audioDevice->deviceState = QAudio::ActiveState;
- return err;
- }
- return 0;
+ return audioDevice->read(data,len);
}
qint64 InputPrivate::writeData(const char* data, qint64 len)
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index cc4fdee553..594f6caf64 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -192,9 +192,11 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
//set to pull mode
pullMode = true;
audioSource = device;
+ deviceState = QAudio::ActiveState;
} else {
//set to push mode
pullMode = false;
+ deviceState = QAudio::IdleState;
audioSource = new InputPrivate(this);
audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
}
@@ -311,7 +313,6 @@ bool QAudioInputPrivate::open()
elapsedTimeOffset = 0;
totalTimeValue = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
return true;
}
@@ -320,9 +321,9 @@ void QAudioInputPrivate::close()
if(deviceState == QAudio::StoppedState)
return;
+ deviceState = QAudio::StoppedState;
waveInReset(hWaveIn);
waveInClose(hWaveIn);
- deviceState = QAudio::StoppedState;
int count = 0;
while(!finished && count < 500) {
@@ -357,7 +358,6 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
char* p = data;
qint64 l = 0;
qint64 written = 0;
-
while(!done) {
// Read in some audio data
if(waveBlocks[header].dwBytesRecorded > 0 && waveBlocks[header].dwFlags & WHDR_DONE) {
@@ -378,11 +378,12 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
errorState = QAudio::IOError;
} else {
- totalTimeValue += waveBlocks[header].dwBytesRecorded
- /((settings.channels()*settings.sampleSize()/8))
- *10000/settings.frequency()*100;
+ totalTimeValue += waveBlocks[header].dwBytesRecorded;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
resuming = false;
}
} else {
@@ -392,16 +393,17 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
#ifdef DEBUG_AUDIO
qDebug()<<"IN: "<<waveBlocks[header].dwBytesRecorded<<", OUT: "<<l;
#endif
- totalTimeValue += waveBlocks[header].dwBytesRecorded
- /((settings.channels()*settings.sampleSize()/8))
- *10000/settings.frequency()*100;
+ totalTimeValue += waveBlocks[header].dwBytesRecorded;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
resuming = false;
}
} else {
//no data, not ready yet, next time
- return 0;
+ break;
}
waveInUnprepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
@@ -510,7 +512,13 @@ int QAudioInputPrivate::notifyInterval() const
qint64 QAudioInputPrivate::processedUSecs() const
{
- return totalTimeValue;
+ if (deviceState == QAudio::StoppedState)
+ return 0;
+ qint64 result = qint64(1000000) * totalTimeValue /
+ (settings.channels()*(settings.sampleSize()/8)) /
+ settings.frequency();
+
+ return result;
}
void QAudioInputPrivate::suspend()
@@ -540,6 +548,9 @@ bool QAudioInputPrivate::deviceReady()
QTime now(QTime::currentTime());
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :deviceReady() INPUT";
#endif
+ if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
+ return true;
+
if(pullMode) {
// reads some audio data and writes it to QIODevice
read(0,0);
@@ -548,8 +559,6 @@ bool QAudioInputPrivate::deviceReady()
InputPrivate* a = qobject_cast<InputPrivate*>(audioSource);
a->trigger();
}
- if(deviceState != QAudio::ActiveState)
- return true;
if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
emit notify();
@@ -582,7 +591,8 @@ InputPrivate::~InputPrivate() {}
qint64 InputPrivate::readData( char* data, qint64 len)
{
// push mode, user read() called
- if(audioDevice->deviceState != QAudio::ActiveState)
+ if(audioDevice->deviceState != QAudio::ActiveState &&
+ audioDevice->deviceState != QAudio::IdleState)
return 0;
// Read in some audio data
return audioDevice->read(data,len);
diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp
index afd8a848d3..b0b52445da 100644
--- a/src/multimedia/audio/qaudiooutput.cpp
+++ b/src/multimedia/audio/qaudiooutput.cpp
@@ -202,18 +202,18 @@ QAudioFormat QAudioOutput::format() const
Passing a QIODevice allows the data to be transfered without any extra code.
All that is required is to open the QIODevice.
+ If able to successfully output audio data to the systems audio device the
+ state() is set to QAudio::ActiveState, error() is set to QAudio::NoError
+ and the stateChanged() signal is emitted.
+
+ If a problem occurs during this process the error() is set to QAudio::OpenError,
+ state() is set to QAudio::StoppedState and stateChanged() signal is emitted.
+
\sa QIODevice
*/
void QAudioOutput::start(QIODevice* device)
{
- /*
- -If currently not StoppedState, stop.
- -If previous start was push mode, delete internal QIODevice.
- -open audio output.
- -If ok, NoError and ActiveState, else OpenError and StoppedState
- -emit stateChanged()
- */
d->start(device);
}
@@ -221,34 +221,30 @@ void QAudioOutput::start(QIODevice* device)
Returns a pointer to the QIODevice being used to handle the data
transfer. This QIODevice can be used to write() audio data directly.
+ If able to access the systems audio device the state() is set to
+ QAudio::IdleState, error() is set to QAudio::NoError
+ and the stateChanged() signal is emitted.
+
+ If a problem occurs during this process the error() is set to QAudio::OpenError,
+ state() is set to QAudio::StoppedState and stateChanged() signal is emitted.
+
\sa QIODevice
*/
QIODevice* QAudioOutput::start()
{
- /*
- -If currently not StoppedState, stop.
- -If no internal QIODevice, create one.
- -open audio output.
- -If ok, NoError and IdleState, else OpenError and StoppedState
- -emit stateChanged()
- -return internal QIODevice
- */
return d->start(0);
}
/*!
- Stops the audio output.
+ Stops the audio output, detaching from the system resource.
+
+ Sets error() to QAudio::NoError, state() to QAudio::StoppedState and
+ emit stateChanged() signal.
*/
void QAudioOutput::stop()
{
- /*
- -If StoppedState, return
- -set to StoppedState
- -detach from audio device
- -emit stateChanged()
- */
d->stop();
}
@@ -258,55 +254,44 @@ void QAudioOutput::stop()
void QAudioOutput::reset()
{
- /*
- -drop all buffered audio, set buffers to zero.
- -call stop()
- */
d->reset();
}
/*!
Stops processing audio data, preserving buffered audio data.
+
+ Sets error() to QAudio::NoError, state() to QAudio::SuspendedState and
+ emit stateChanged() signal.
*/
void QAudioOutput::suspend()
{
- /*
- -If not ActiveState|IdleState, return
- -stop processing audio, saving all buffered audio data
- -set NoError and SuspendedState
- -emit stateChanged()
- */
d->suspend();
}
/*!
Resumes processing audio data after a suspend().
+
+ Sets error() to QAudio::NoError.
+ Sets state() to QAudio::ActiveState if you previously called start(QIODevice*).
+ Sets state() to QAudio::IdleState if you previously called start().
+ emits stateChanged() signal.
*/
void QAudioOutput::resume()
{
- /*
- -If SuspendedState, return
- -resume audio
- -(PULL MODE): set ActiveState, NoError
- -(PUSH MODE): set IdleState, NoError
- -kick start audio if needed
- -emit stateChanged()
- */
d->resume();
}
/*!
Returns the free space available in bytes in the audio buffer.
+
+ NOTE: returned value is only valid while in QAudio::ActiveState or QAudio::IdleState
+ state, otherwise returns zero.
*/
int QAudioOutput::bytesFree() const
{
- /*
- -If not ActiveState|IdleState, return 0
- -return space available in audio buffer in bytes
- */
return d->bytesFree();
}
@@ -353,7 +338,10 @@ int QAudioOutput::bufferSize() const
/*!
Sets the interval for notify() signal to be emitted.
This is based on the \a ms of audio data processed
- not on actual real-time. The resolution of the timer is platform specific.
+ not on actual real-time.
+ The minimum resolution of the timer is platform specific and values
+ should be checked with notifyInterval() to confirm actual value
+ being used.
*/
void QAudioOutput::setNotifyInterval(int ms)
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index 7b89cef69d..b127103d59 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -259,6 +259,7 @@ void QAudioOutputPrivate::stop()
{
if(deviceState == QAudio::StoppedState)
return;
+ errorState = QAudio::NoError;
deviceState = QAudio::StoppedState;
close();
emit stateChanged(deviceState);
@@ -494,10 +495,13 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
err = snd_pcm_writei( handle, data, frames );
}
if(err > 0) {
- totalTimeValue += err*1000000/settings.frequency();
+ totalTimeValue += err;
resuming = false;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
return snd_pcm_frames_to_bytes( handle, err );
} else
err = xrun_recovery(err);
@@ -542,7 +546,7 @@ int QAudioOutputPrivate::notifyInterval() const
qint64 QAudioOutputPrivate::processedUSecs() const
{
- return totalTimeValue;
+ return qint64(1000000) * totalTimeValue / settings.frequency();
}
void QAudioOutputPrivate::resume()
@@ -562,10 +566,8 @@ void QAudioOutputPrivate::resume()
bytesAvailable = (int)snd_pcm_frames_to_bytes(handle, buffer_frames);
}
resuming = true;
- if(pullMode)
- deviceState = QAudio::ActiveState;
- else
- deviceState = QAudio::IdleState;
+
+ deviceState = QAudio::ActiveState;
errorState = QAudio::NoError;
timer->start(period_time/1000);
@@ -637,7 +639,9 @@ bool QAudioOutputPrivate::deviceReady()
// Got some data to output
if(deviceState != QAudio::ActiveState)
return true;
- write(audioBuffer,l);
+ qint64 bytesWritten = write(audioBuffer,l);
+ if (bytesWritten != l)
+ audioSource->seek(audioSource->pos()-(l-bytesWritten));
bytesAvailable = bytesFree();
} else if(l == 0) {
@@ -645,9 +649,11 @@ bool QAudioOutputPrivate::deviceReady()
bytesAvailable = bytesFree();
if(bytesAvailable > snd_pcm_frames_to_bytes(handle, buffer_frames-period_frames)) {
// Underrun
- errorState = QAudio::UnderrunError;
- deviceState = QAudio::IdleState;
- emit stateChanged(deviceState);
+ if (deviceState != QAudio::IdleState) {
+ errorState = QAudio::UnderrunError;
+ deviceState = QAudio::IdleState;
+ emit stateChanged(deviceState);
+ }
}
} else if(l < 0) {
@@ -655,8 +661,17 @@ bool QAudioOutputPrivate::deviceReady()
errorState = QAudio::IOError;
emit stateChanged(deviceState);
}
- } else
+ } else {
bytesAvailable = bytesFree();
+ if(bytesAvailable > snd_pcm_frames_to_bytes(handle, buffer_frames-period_frames)) {
+ // Underrun
+ if (deviceState != QAudio::IdleState) {
+ errorState = QAudio::UnderrunError;
+ deviceState = QAudio::IdleState;
+ emit stateChanged(deviceState);
+ }
+ }
+ }
if(deviceState != QAudio::ActiveState)
return true;
@@ -671,35 +686,10 @@ bool QAudioOutputPrivate::deviceReady()
qint64 QAudioOutputPrivate::elapsedUSecs() const
{
- if(!handle)
- return 0;
-
if (deviceState == QAudio::StoppedState)
return 0;
-#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
- snd_pcm_status_t* status;
- snd_pcm_status_alloca(&status);
-
- snd_timestamp_t t1,t2;
- if( snd_pcm_status(handle, status) >= 0) {
- snd_pcm_status_get_tstamp(status,&t1);
- snd_pcm_status_get_trigger_tstamp(status,&t2);
- t1.tv_sec-=t2.tv_sec;
-
- signed long l = (signed long)t1.tv_usec - (signed long)t2.tv_usec;
- if(l < 0) {
- t1.tv_sec--;
- l = -l;
- l %= 1000000;
- }
- return ((t1.tv_sec * 1000000)+l);
- } else
- return 0;
-#else
return clockStamp.elapsed()*1000;
-#endif
- return 0;
}
void QAudioOutputPrivate::reset()
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index bce45c1214..6200160202 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -211,6 +211,13 @@ bool QAudioOutputPrivate::open()
QTime now(QTime::currentTime());
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
+ if (!(settings.frequency() >= 8000 && settings.frequency() <= 48000)) {
+ errorState = QAudio::OpenError;
+ deviceState = QAudio::StoppedState;
+ emit stateChanged(deviceState);
+ qWarning("QAudioOutput: open error, frequency out of range.");
+ return false;
+ }
if(buffer_size == 0) {
// Default buffer size, 200ms, default period size is 40ms
buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2;
@@ -289,6 +296,7 @@ void QAudioOutputPrivate::close()
return;
deviceState = QAudio::StoppedState;
+ errorState = QAudio::NoError;
int delay = (buffer_size-bytesFree())*1000/(settings.frequency()
*settings.channels()*(settings.sampleSize()/8));
waveOutReset(hWaveOut);
@@ -340,12 +348,20 @@ int QAudioOutputPrivate::notifyInterval() const
qint64 QAudioOutputPrivate::processedUSecs() const
{
- return totalTimeValue;
+ if (deviceState == QAudio::StoppedState)
+ return 0;
+ qint64 result = qint64(1000000) * totalTimeValue /
+ (settings.channels()*(settings.sampleSize()/8)) /
+ settings.frequency();
+
+ return result;
}
qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
{
// Write out some audio data
+ if (deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
+ return 0;
char* p = (char*)data;
int l = (int)len;
@@ -385,13 +401,16 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len )
current->dwBufferLength,waveFreeBlockCount);
LeaveCriticalSection(&waveOutCriticalSection);
#endif
- totalTimeValue += current->dwBufferLength
- /(settings.channels()*(settings.sampleSize()/8))
- *1000000/settings.frequency();;
+ totalTimeValue += current->dwBufferLength;
waveCurrentBlock++;
waveCurrentBlock %= buffer_size/period_size;
current = &waveBlocks[waveCurrentBlock];
current->dwUser = 0;
+ errorState = QAudio::NoError;
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
}
return (len-l);
}
@@ -409,8 +428,11 @@ void QAudioOutputPrivate::resume()
void QAudioOutputPrivate::suspend()
{
- if(deviceState == QAudio::ActiveState) {
+ if(deviceState == QAudio::ActiveState || deviceState == QAudio::IdleState) {
+ int delay = (buffer_size-bytesFree())*1000/(settings.frequency()
+ *settings.channels()*(settings.sampleSize()/8));
waveOutPause(hWaveOut);
+ Sleep(delay+10);
deviceState = QAudio::SuspendedState;
errorState = QAudio::NoError;
emit stateChanged(deviceState);
@@ -465,8 +487,16 @@ bool QAudioOutputPrivate::deviceReady()
int l = audioSource->read(audioBuffer,input);
if(l > 0) {
int out= write(audioBuffer,l);
- if(out > 0)
- deviceState = QAudio::ActiveState;
+ if(out > 0) {
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
+ }
+ if ( out < l) {
+ // Didnt write all data
+ audioSource->seek(audioSource->pos()-(l-out));
+ }
if(startup)
waveOutRestart(hWaveOut);
} else if(l == 0) {
@@ -478,16 +508,28 @@ bool QAudioOutputPrivate::deviceReady()
LeaveCriticalSection(&waveOutCriticalSection);
if(check == buffer_size/period_size) {
errorState = QAudio::UnderrunError;
- deviceState = QAudio::IdleState;
- emit stateChanged(deviceState);
+ if (deviceState != QAudio::IdleState) {
+ deviceState = QAudio::IdleState;
+ emit stateChanged(deviceState);
+ }
}
} else if(l < 0) {
bytesAvailable = bytesFree();
errorState = QAudio::IOError;
}
+ } else {
+ int buffered;
+ EnterCriticalSection(&waveOutCriticalSection);
+ buffered = waveFreeBlockCount;
+ LeaveCriticalSection(&waveOutCriticalSection);
+ errorState = QAudio::UnderrunError;
+ if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) {
+ deviceState = QAudio::IdleState;
+ emit stateChanged(deviceState);
+ }
}
- if(deviceState != QAudio::ActiveState)
+ if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
return true;
if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
diff --git a/src/multimedia/qml/multimediadeclarative.cpp b/src/multimedia/qml/multimediadeclarative.cpp
new file mode 100644
index 0000000000..7f5298f9c5
--- /dev/null
+++ b/src/multimedia/qml/multimediadeclarative.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 QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtMultimedia/multimediadeclarative.h>
+#include <QtMultimedia/private/qsoundeffect_p.h>
+#include <QtMultimedia/private/qdeclarativeaudio_p.h>
+#include <QtMultimedia/private/qdeclarativevideo_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace QtMultimedia
+{
+
+/*!
+ Register the Multimedia QML elements.
+ \internal
+*/
+
+void qRegisterDeclarativeElements(const char *uri)
+{
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.multimedia"));
+
+ qmlRegisterType<QSoundEffect>(uri, 4, 7, "SoundEffect");
+ qmlRegisterType<QDeclarativeAudio>(uri, 4, 7, "Audio");
+ qmlRegisterType<QDeclarativeVideo>(uri, 4, 7, "Video");
+}
+
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/multimedia/qml/multimediadeclarative.h b/src/multimedia/qml/multimediadeclarative.h
new file mode 100644
index 0000000000..29af65ade0
--- /dev/null
+++ b/src/multimedia/qml/multimediadeclarative.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QTMULTIMEDIA_QML_H
+#define QTMULTIMEDIA_QML_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Multimedia)
+
+namespace QtMultimedia
+{
+extern void Q_MULTIMEDIA_EXPORT qRegisterDeclarativeElements(const char *uri);
+}
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // ifndef QTMULTIMEDIA_QML_H
diff --git a/src/multimedia/qml/multimediaqml.cpp b/src/multimedia/qml/multimediaqml.cpp
deleted file mode 100644
index be499153c5..0000000000
--- a/src/multimedia/qml/multimediaqml.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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtMultimedia/multimediaqml.h>
-#include <QtMultimedia/private/qsoundeffect_p.h>
-#include <QtMultimedia/private/qmlaudio_p.h>
-#include <QtMultimedia/private/qmlgraphicsvideo_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-namespace QtMultimedia
-{
-
-/*!
- Register the Multimedia QML elements.
- \internal
-*/
-
-void qRegisterQmlElements()
-{
- qmlRegisterType<QSoundEffect>("Qt.multimedia", 4, 7, "SoundEffect", "SoundEffect");
- qmlRegisterType<QmlAudio>("Qt.multimedia", 4, 7, "Audio", "Audio");
- qmlRegisterType<QmlGraphicsVideo>("Qt.multimedia", 4, 7, "Video", "Video");
-}
-
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/multimedia/qml/multimediaqml.h b/src/multimedia/qml/multimediaqml.h
deleted file mode 100644
index 41274c8a15..0000000000
--- a/src/multimedia/qml/multimediaqml.h
+++ /dev/null
@@ -1,60 +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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QTMULTIMEDIA_QML_H
-#define QTMULTIMEDIA_QML_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Multimedia)
-
-namespace QtMultimedia
-{
-extern void Q_MULTIMEDIA_EXPORT qRegisterQmlElements();
-}
-
-QT_END_NAMESPACE
-QT_END_HEADER
-
-#endif // ifndef QTMULTIMEDIA_QML_H
diff --git a/src/multimedia/qml/qdeclarativeaudio.cpp b/src/multimedia/qml/qdeclarativeaudio.cpp
new file mode 100644
index 0000000000..1cbf594761
--- /dev/null
+++ b/src/multimedia/qml/qdeclarativeaudio.cpp
@@ -0,0 +1,327 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativeaudio_p.h"
+
+#include <QtMultimedia/qmediaplayercontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \qmlclass Audio QDeclarativeAudio
+ \since 4.7
+ \brief The Audio element allows you to add audio playback to a scene.
+
+ \qml
+ Audio { source: "audio/song.mp3" }
+ \endqml
+
+ \sa Video
+*/
+
+/*!
+ \internal
+ \class QDeclarativeAudio
+ \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView.
+*/
+
+void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString)
+{
+ m_error = QMediaPlayer::Error(errorCode);
+ m_errorString = errorString;
+
+ emit error(Error(errorCode), errorString);
+ emit errorChanged();
+}
+
+
+QDeclarativeAudio::QDeclarativeAudio(QObject *parent)
+ : QObject(parent)
+{
+ setObject(this);
+}
+
+QDeclarativeAudio::~QDeclarativeAudio()
+{
+ shutdown();
+}
+
+/*!
+ \qmlmethod Audio::play()
+
+ Starts playback of the media.
+
+ Sets the \l playing property to true, and the \l paused property to false.
+*/
+
+void QDeclarativeAudio::play()
+{
+ m_playerControl->play();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Audio::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeAudio::pause()
+{
+ m_playerControl->pause();
+
+ if (!m_paused && m_state == QMediaPlayer::PausedState) {
+ m_paused = true;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Audio::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeAudio::stop()
+{
+ m_playerControl->stop();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlproperty url Audio::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \qmlproperty bool Audio::playing
+
+ This property holds whether the media is playing.
+
+ Defaults to false, and can be set to true to start playback.
+*/
+
+/*!
+ \qmlproperty bool Audio::paused
+
+ This property holds whether the media is paused.
+
+ Defaults to false, and can be set to true to pause playback.
+*/
+
+/*!
+ \qmlsignal Audio::onStarted()
+
+ This handler is called when playback is started.
+*/
+
+/*!
+ \qmlsignal Audio::onResumed()
+
+ This handler is called when playback is resumed from the paused state.
+*/
+
+/*!
+ \qmlsignal Audio::onPaused()
+
+ This handler is called when playback is paused.
+*/
+
+/*!
+ \qmlsignal Audio::onStopped()
+
+ This handler is called when playback is stopped.
+*/
+
+/*!
+ \qmlproperty enum Audio::status
+
+ This property holds the status of media loading. It can be one of:
+
+ \list
+ \o NoMedia - no media has been set.
+ \o Loading - the media is currently being loaded.
+ \o Loaded - the media has been loaded.
+ \o Buffering - the media is buffering data.
+ \o Stalled - playback has been interrupted while the media is buffering data.
+ \o Buffered - the media has buffered data.
+ \o EndOfMedia - the media has played to the end.
+ \o InvalidMedia - the media cannot be played.
+ \o UnknownStatus - the status of the media is unknown.
+ \endlist
+*/
+
+QDeclarativeAudio::Status QDeclarativeAudio::status() const
+{
+ return Status(m_status);
+}
+
+/*!
+ \qmlsignal Audio::onLoaded()
+
+ This handler is called when the media source has been loaded.
+*/
+
+/*!
+ \qmlsignal Audio::onBuffering()
+
+ This handler is called when the media starts buffering.
+*/
+
+/*!
+ \qmlsignal Audio::onStalled()
+
+ This handler is called when playback has stalled while the media buffers.
+*/
+
+/*!
+ \qmlsignal Audio::onBuffered()
+
+ This handler is called when the media has finished buffering.
+*/
+
+/*!
+ \qmlsignal Audio::onEndOfMedia()
+
+ This handler is called when playback stops because end of the media has been reached.
+*/
+/*!
+ \qmlproperty int Audio::duration
+
+ This property holds the duration of the media in milliseconds.
+
+ If the media doesn't have a fixed duration (a live stream for example) this will be 0.
+*/
+
+/*!
+ \qmlproperty int Audio::position
+
+ This property holds the current playback position in milliseconds.
+
+ If the \l seekable property is true, this property can be set to seek to a new position.
+*/
+
+/*!
+ \qmlproperty qreal Audio::volume
+
+ This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
+*/
+
+/*!
+ \qmlproperty bool Audio::muted
+
+ This property holds whether the audio output is muted.
+*/
+
+/*!
+ \qmlproperty qreal Audio::bufferProgress
+
+ This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
+ (full).
+*/
+
+/*!
+ \qmlproperty bool Audio::seekable
+
+ This property holds whether position of the audio can be changed.
+
+ If true; setting a \l position value will cause playback to seek to the new position.
+*/
+
+/*!
+ \qmlproperty qreal Audio::playbackRate
+
+ This property holds the rate at which audio is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enum Audio::error
+
+ This property holds the error state of the audio. It can be one of:
+
+ \list
+ \o NoError - there is no current error.
+ \o ResourceError - the audio cannot be played due to a problem allocating resources.
+ \o FormatError - the audio format is not supported.
+ \o NetworkError - the audio cannot be played due to network issues.
+ \o AccessDenied - the audio cannot be played due to insufficient permissions.
+ \o ServiceMissing - the audio cannot be played because the media service could not be
+ instantiated.
+ \endlist
+*/
+
+QDeclarativeAudio::Error QDeclarativeAudio::error() const
+{
+ return Error(m_error);
+}
+
+/*!
+ \qmlproperty string Audio::errorString
+
+ This property holds a string describing the current error condition in more detail.
+*/
+
+/*!
+ \qmlsignal Audio::onError(error, errorString)
+
+ This handler is called when an \l {Error}{error} has occurred. The errorString parameter
+ may contain more detailed information about the error.
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qdeclarativeaudio_p.cpp"
+
+
diff --git a/src/multimedia/qml/qdeclarativeaudio_p.h b/src/multimedia/qml/qdeclarativeaudio_p.h
new file mode 100644
index 0000000000..d1fb275521
--- /dev/null
+++ b/src/multimedia/qml/qdeclarativeaudio_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 QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEAUDIO_P_H
+#define QDECLARATIVEAUDIO_P_H
+
+//
+// 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.
+//
+
+#include <QtMultimedia/private/qdeclarativemediabase_p.h>
+
+#include <QtCore/qbasictimer.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTimerEvent;
+
+class Q_AUTOTEST_EXPORT QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
+ Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
+ Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
+ Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
+ Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
+ Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+ Q_ENUMS(Status)
+ Q_ENUMS(Error)
+ Q_INTERFACES(QDeclarativeParserStatus)
+public:
+ enum Status
+ {
+ UnknownStatus = QMediaPlayer::UnknownMediaStatus,
+ NoMedia = QMediaPlayer::NoMedia,
+ Loading = QMediaPlayer::LoadingMedia,
+ Loaded = QMediaPlayer::LoadedMedia,
+ Stalled = QMediaPlayer::StalledMedia,
+ Buffering = QMediaPlayer::BufferingMedia,
+ Buffered = QMediaPlayer::BufferedMedia,
+ EndOfMedia = QMediaPlayer::EndOfMedia,
+ InvalidMedia = QMediaPlayer::InvalidMedia
+ };
+
+ enum Error
+ {
+ NoError = QMediaPlayer::NoError,
+ ResourceError = QMediaPlayer::ResourceError,
+ FormatError = QMediaPlayer::FormatError,
+ NetworkError = QMediaPlayer::NetworkError,
+ AccessDenied = QMediaPlayer::AccessDeniedError,
+ ServiceMissing = QMediaPlayer::ServiceMissingError
+ };
+
+ QDeclarativeAudio(QObject *parent = 0);
+ ~QDeclarativeAudio();
+
+ Status status() const;
+ Error error() const;
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+
+ void playingChanged();
+ void pausedChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void loaded();
+ void buffering();
+ void stalled();
+ void buffered();
+ void endOfMedia();
+
+ void durationChanged();
+ void positionChanged();
+
+ void volumeChanged();
+ void mutedChanged();
+
+ void bufferProgressChanged();
+
+ void seekableChanged();
+ void playbackRateChanged();
+
+ void errorChanged();
+ void error(QDeclarativeAudio::Error error, const QString &errorString);
+
+private Q_SLOTS:
+ void _q_error(int, const QString &);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeAudio)
+ Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
+
+ inline QDeclarativeMediaBase *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/multimedia/qml/qdeclarativemediabase.cpp b/src/multimedia/qml/qdeclarativemediabase.cpp
new file mode 100644
index 0000000000..e054cb2aed
--- /dev/null
+++ b/src/multimedia/qml/qdeclarativemediabase.cpp
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "QtMultimedia/private/qdeclarativemediabase_p.h"
+
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qurl.h>
+
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmediaserviceprovider.h>
+#include <QtMultimedia/qmetadatacontrol.h>
+#include <QtMultimedia/private/qmetadatacontrolmetaobject_p.h>
+
+
+
+QT_BEGIN_NAMESPACE
+
+
+class QDeclarativeMediaBaseObject : public QMediaObject
+{
+public:
+ QDeclarativeMediaBaseObject(QMediaService *service)
+ : QMediaObject(0, service)
+ {
+ }
+};
+
+class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl
+{
+public:
+ QDeclarativeMediaBasePlayerControl(QObject *parent)
+ : QMediaPlayerControl(parent)
+ {
+ }
+
+ QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; }
+ QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; }
+
+ qint64 duration() const { return 0; }
+ qint64 position() const { return 0; }
+ void setPosition(qint64) {}
+ int volume() const { return 0; }
+ void setVolume(int) {}
+ bool isMuted() const { return false; }
+ void setMuted(bool) {}
+ int bufferStatus() const { return 0; }
+ bool isAudioAvailable() const { return false; }
+ bool isVideoAvailable() const { return false; }
+ bool isSeekable() const { return false; }
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+ qreal playbackRate() const { return 1; }
+ void setPlaybackRate(qreal) {}
+ QMediaContent media() const { return QMediaContent(); }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &, QIODevice *) {}
+
+ void play() {}
+ void pause() {}
+ void stop() {}
+};
+
+class QDeclarativeMediaBaseAnimation : public QObject
+{
+public:
+ QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase *media)
+ : m_media(media)
+ {
+ }
+
+ void start() { if (!m_timer.isActive()) m_timer.start(500, this); }
+ void stop() { m_timer.stop(); }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == m_timer.timerId()) {
+ event->accept();
+
+ if (m_media->m_state == QMediaPlayer::PlayingState)
+ emit m_media->positionChanged();
+ if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia)
+ emit m_media->bufferProgressChanged();
+ } else {
+ QObject::timerEvent(event);
+ }
+ }
+
+private:
+ QDeclarativeMediaBase *m_media;
+ QBasicTimer m_timer;
+};
+
+void QDeclarativeMediaBase::_q_stateChanged(QMediaPlayer::State state)
+{
+ if (state != m_state) {
+ QMediaPlayer::State oldState = m_state;
+
+ m_state = state;
+
+ if (state == QMediaPlayer::StoppedState) {
+ emit stopped();
+ emit playingChanged();
+ } else if (oldState == QMediaPlayer::StoppedState) {
+ emit started();
+ emit playingChanged();
+ } else if (oldState == QMediaPlayer::PausedState) {
+ m_paused = false;
+
+ emit resumed();
+ emit pausedChanged();
+ }
+
+ if (state == m_state && state == QMediaPlayer::PausedState) {
+ bool wasPaused = m_paused;
+
+ m_paused = true;
+
+ emit paused();
+
+ if (!wasPaused)
+ emit pausedChanged();
+ }
+
+ if (m_state == QMediaPlayer::PlayingState
+ || m_status == QMediaPlayer::BufferingMedia
+ || m_status == QMediaPlayer::StalledMedia) {
+ m_animation->start();
+ } else {
+ m_animation->stop();
+ }
+ }
+}
+
+void QDeclarativeMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status)
+{
+ if (status != m_status) {
+ m_status = status;
+
+ switch (status) {
+ case QMediaPlayer::LoadedMedia:
+ emit loaded();
+ break;
+ case QMediaPlayer::BufferingMedia:
+ emit buffering();
+ break;
+ case QMediaPlayer::BufferedMedia:
+ emit buffered();
+ break;
+ case QMediaPlayer::StalledMedia:
+ emit stalled();
+ break;
+ case QMediaPlayer::EndOfMedia:
+ emit endOfMedia();
+ break;
+ default:
+ break;
+ }
+
+ emit statusChanged();
+
+ if (m_state == QMediaPlayer::PlayingState
+ || m_status == QMediaPlayer::BufferingMedia
+ || m_status == QMediaPlayer::StalledMedia) {
+ m_animation->start();
+ } else {
+ m_animation->stop();
+ }
+ }
+}
+
+void QDeclarativeMediaBase::_q_metaDataChanged()
+{
+ m_metaObject->metaDataChanged();
+}
+
+QDeclarativeMediaBase::QDeclarativeMediaBase()
+ : m_mediaService(0)
+ , m_playerControl(0)
+ , m_mediaObject(0)
+ , m_mediaProvider(0)
+ , m_metaDataControl(0)
+ , m_metaObject(0)
+ , m_animation(0)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_status(QMediaPlayer::NoMedia)
+ , m_error(QMediaPlayer::NoError)
+ , m_paused(false)
+{
+}
+
+QDeclarativeMediaBase::~QDeclarativeMediaBase()
+{
+}
+
+void QDeclarativeMediaBase::shutdown()
+{
+ delete m_metaObject;
+ delete m_mediaObject;
+
+ if (m_mediaProvider)
+ m_mediaProvider->releaseService(m_mediaService);
+
+ delete m_animation;
+
+}
+
+void QDeclarativeMediaBase::setObject(QObject *object)
+{
+ if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider())) {
+ if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER))) {
+ m_playerControl = qobject_cast<QMediaPlayerControl *>(
+ m_mediaService->control(QMediaPlayerControl_iid));
+ m_metaDataControl = qobject_cast<QMetaDataControl *>(
+ m_mediaService->control(QMetaDataControl_iid));
+ m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService);
+ }
+ }
+
+ if (m_playerControl) {
+ QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
+ object, SLOT(_q_stateChanged(QMediaPlayer::State)));
+ QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
+ object, SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus)));
+ QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)),
+ object, SIGNAL(sourceChanged()));
+ QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)),
+ object, SIGNAL(durationChanged()));
+ QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)),
+ object, SIGNAL(positionChanged()));
+ QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)),
+ object, SIGNAL(volumeChanged()));
+ QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)),
+ object, SIGNAL(mutedChanged()));
+ QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)),
+ object, SIGNAL(bufferProgressChanged()));
+ QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)),
+ object, SIGNAL(seekableChanged()));
+ QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)),
+ object, SIGNAL(playbackRateChanged()));
+ QObject::connect(m_playerControl, SIGNAL(error(int,QString)),
+ object, SLOT(_q_error(int,QString)));
+
+ m_animation = new QDeclarativeMediaBaseAnimation(this);
+ } else {
+ m_error = QMediaPlayer::ServiceMissingError;
+
+ m_playerControl = new QDeclarativeMediaBasePlayerControl(object);
+ }
+
+ if (m_metaDataControl) {
+ m_metaObject = new QMetaDataControlMetaObject(m_metaDataControl, object);
+
+ QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
+ object, SLOT(_q_metaDataChanged()));
+ }
+}
+
+QUrl QDeclarativeMediaBase::source() const
+{
+ return m_playerControl->media().canonicalUrl();
+}
+
+void QDeclarativeMediaBase::setSource(const QUrl &url)
+{
+ if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
+ m_error = QMediaPlayer::NoError;
+ m_errorString = QString();
+
+ emit errorChanged();
+ }
+
+ m_playerControl->setMedia(QMediaContent(url), 0);
+}
+
+bool QDeclarativeMediaBase::isPlaying() const
+{
+ return m_state != QMediaPlayer::StoppedState;
+}
+
+void QDeclarativeMediaBase::setPlaying(bool playing)
+{
+ if (playing && m_state == QMediaPlayer::StoppedState) {
+ if (m_paused)
+ m_playerControl->pause();
+ else
+ m_playerControl->play();
+ } else if (!playing) {
+ m_playerControl->stop();
+ }
+}
+
+bool QDeclarativeMediaBase::isPaused() const
+{
+ return m_paused;
+}
+
+void QDeclarativeMediaBase::setPaused(bool paused)
+{
+ if (m_paused != paused) {
+ if (paused && m_state == QMediaPlayer::PlayingState) {
+ m_playerControl->pause();
+ } else if (!paused && m_state == QMediaPlayer::PausedState) {
+ m_playerControl->play();
+ } else {
+ m_paused = paused;
+
+ emit pausedChanged();
+ }
+ }
+}
+
+int QDeclarativeMediaBase::duration() const
+{
+ return m_playerControl->duration();
+}
+
+int QDeclarativeMediaBase::position() const
+{
+ return m_playerControl->position();
+
+}
+
+void QDeclarativeMediaBase::setPosition(int position)
+{
+ m_playerControl->setPosition(position);
+}
+
+qreal QDeclarativeMediaBase::volume() const
+{
+ return qreal(m_playerControl->volume()) / 100;
+}
+
+void QDeclarativeMediaBase::setVolume(qreal volume)
+{
+ m_playerControl->setVolume(qRound(volume * 100));
+}
+
+bool QDeclarativeMediaBase::isMuted() const
+{
+ return m_playerControl->isMuted();
+}
+
+void QDeclarativeMediaBase::setMuted(bool muted)
+{
+ m_playerControl->setMuted(muted);
+}
+
+qreal QDeclarativeMediaBase::bufferProgress() const
+{
+ return qreal(m_playerControl->bufferStatus()) / 100;
+}
+
+bool QDeclarativeMediaBase::isSeekable() const
+{
+ return m_playerControl->isSeekable();
+}
+
+qreal QDeclarativeMediaBase::playbackRate() const
+{
+ return m_playerControl->playbackRate();
+}
+
+void QDeclarativeMediaBase::setPlaybackRate(qreal rate)
+{
+ m_playerControl->setPlaybackRate(rate);
+}
+
+QString QDeclarativeMediaBase::errorString() const
+{
+ return m_errorString;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/multimedia/qml/qdeclarativemediabase_p.h b/src/multimedia/qml/qdeclarativemediabase_p.h
new file mode 100644
index 0000000000..2fc48db630
--- /dev/null
+++ b/src/multimedia/qml/qdeclarativemediabase_p.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEMEDIABASE_P_H
+#define QDECLARATIVEMEDIABASE_P_H
+
+//
+// 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.
+//
+
+#include <QtCore/qbasictimer.h>
+#include <QtMultimedia/qmediaplayer.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlayerControl;
+class QMediaService;
+class QMediaServiceProvider;
+class QMetaDataControl;
+class QMetaDataControlMetaObject;
+class QDeclarativeMediaBaseAnimation;
+
+class Q_AUTOTEST_EXPORT QDeclarativeMediaBase
+{
+public:
+ QDeclarativeMediaBase();
+ virtual ~QDeclarativeMediaBase();
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ bool isPlaying() const;
+ void setPlaying(bool playing);
+
+ bool isPaused() const;
+ void setPaused(bool paused);
+
+ int duration() const;
+
+ int position() const;
+ void setPosition(int position);
+
+ qreal volume() const;
+ void setVolume(qreal volume);
+
+ bool isMuted() const;
+ void setMuted(bool muted);
+
+ qreal bufferProgress() const;
+
+ bool isSeekable() const;
+
+ qreal playbackRate() const;
+ void setPlaybackRate(qreal rate);
+
+ QString errorString() const;
+
+ void _q_stateChanged(QMediaPlayer::State state);
+ void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status);
+
+ void _q_metaDataChanged();
+
+protected:
+ void shutdown();
+
+ void setObject(QObject *object);
+
+ virtual void sourceChanged() = 0;
+
+ virtual void playingChanged() = 0;
+ virtual void pausedChanged() = 0;
+
+ virtual void started() = 0;
+ virtual void resumed() = 0;
+ virtual void paused() = 0;
+ virtual void stopped() = 0;
+
+ virtual void statusChanged() = 0;
+
+ virtual void loaded() = 0;
+ virtual void buffering() = 0;
+ virtual void stalled() = 0;
+ virtual void buffered() = 0;
+ virtual void endOfMedia() = 0;
+
+ virtual void durationChanged() = 0;
+ virtual void positionChanged() = 0;
+
+ virtual void volumeChanged() = 0;
+ virtual void mutedChanged() = 0;
+
+ virtual void bufferProgressChanged() = 0;
+
+ virtual void seekableChanged() = 0;
+ virtual void playbackRateChanged() = 0;
+
+ virtual void errorChanged() = 0;
+
+ QMediaService *m_mediaService;
+ QMediaPlayerControl *m_playerControl;
+
+ QMediaObject *m_mediaObject;
+ QMediaServiceProvider *m_mediaProvider;
+ QMetaDataControl *m_metaDataControl;
+ QMetaDataControlMetaObject *m_metaObject;
+ QDeclarativeMediaBaseAnimation *m_animation;
+
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_status;
+ QMediaPlayer::Error m_error;
+ bool m_paused;
+ QString m_errorString;
+
+ friend class QDeclarativeMediaBaseAnimation;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/multimedia/qml/qdeclarativevideo.cpp b/src/multimedia/qml/qdeclarativevideo.cpp
new file mode 100644
index 0000000000..7f6207555c
--- /dev/null
+++ b/src/multimedia/qml/qdeclarativevideo.cpp
@@ -0,0 +1,945 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativevideo_p.h"
+
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/private/qpaintervideosurface_p.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/qvideorenderercontrol.h>
+
+
+QT_BEGIN_NAMESPACE
+
+
+void QDeclarativeVideo::_q_nativeSizeChanged(const QSizeF &size)
+{
+ setImplicitWidth(size.width());
+ setImplicitHeight(size.height());
+}
+
+void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString)
+{
+ m_error = QMediaPlayer::Error(errorCode);
+ m_errorString = errorString;
+
+ emit error(Error(errorCode), errorString);
+ emit errorChanged();
+}
+
+
+/*!
+ \qmlclass Video QDeclarativeVideo
+ \since 4.7
+ \brief The Video element allows you to add videos to a scene.
+ \inherits Item
+
+ \qml
+ Video { source: "video/movie.mpg" }
+ \endqml
+
+ The video item supports untransformed, stretched, and uniformly scaled video presentation.
+ For a description of stretched uniformly scaled presentation, see the \l fillMode property
+ description.
+
+ The video item is only visible when the \l hasVideo property is true and the video is playing.
+
+ \sa Audio
+*/
+
+/*!
+ \internal
+ \class QDeclarativeVideo
+ \brief The QDeclarativeVideo class provides a video item that you can add to a QDeclarativeView.
+*/
+
+QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent)
+ : QDeclarativeItem(parent)
+ , m_graphicsItem(0)
+
+{
+ m_graphicsItem = new QGraphicsVideoItem(this);
+ connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
+ this, SLOT(_q_nativeSizeChanged(QSizeF)));
+
+ setObject(this);
+
+ if (m_mediaService) {
+ connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
+ this, SIGNAL(hasAudioChanged()));
+ connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
+ this, SIGNAL(hasVideoChanged()));
+
+ m_graphicsItem->setMediaObject(m_mediaObject);
+ }
+}
+
+QDeclarativeVideo::~QDeclarativeVideo()
+{
+ shutdown();
+
+ delete m_graphicsItem;
+}
+
+/*!
+ \qmlproperty url Video::source
+
+ This property holds the source URL of the media.
+*/
+
+/*!
+ \qmlproperty bool Video::playing
+
+ This property holds whether the media is playing.
+
+ Defaults to false, and can be set to true to start playback.
+*/
+
+/*!
+ \qmlproperty bool Video::paused
+
+ This property holds whether the media is paused.
+
+ Defaults to false, and can be set to true to pause playback.
+*/
+
+/*!
+ \qmlsignal Video::onStarted()
+
+ This handler is called when playback is started.
+*/
+
+/*!
+ \qmlsignal Video::onResumed()
+
+ This handler is called when playback is resumed from the paused state.
+*/
+
+/*!
+ \qmlsignal Video::onPaused()
+
+ This handler is called when playback is paused.
+*/
+
+/*!
+ \qmlsignal Video::onStopped()
+
+ This handler is called when playback is stopped.
+*/
+
+/*!
+ \qmlproperty enum Video::status
+
+ This property holds the status of media loading. It can be one of:
+
+ \list
+ \o NoMedia - no media has been set.
+ \o Loading - the media is currently being loaded.
+ \o Loaded - the media has been loaded.
+ \o Buffering - the media is buffering data.
+ \o Stalled - playback has been interrupted while the media is buffering data.
+ \o Buffered - the media has buffered data.
+ \o EndOfMedia - the media has played to the end.
+ \o InvalidMedia - the media cannot be played.
+ \o UnknownStatus - the status of the media is cannot be determined.
+ \endlist
+*/
+
+QDeclarativeVideo::Status QDeclarativeVideo::status() const
+{
+ return Status(m_status);
+}
+
+/*!
+ \qmlsignal Video::onLoaded()
+
+ This handler is called when the media source has been loaded.
+*/
+
+/*!
+ \qmlsignal Video::onBuffering()
+
+ This handler is called when the media starts buffering.
+*/
+
+/*!
+ \qmlsignal Video::onStalled()
+
+ This handler is called when playback has stalled while the media buffers.
+*/
+
+/*!
+ \qmlsignal Video::onBuffered()
+
+ This handler is called when the media has finished buffering.
+*/
+
+/*!
+ \qmlsignal Video::onEndOfMedia()
+
+ This handler is called when playback stops because end of the media has been reached.
+*/
+
+/*!
+ \qmlproperty int Video::duration
+
+ This property holds the duration of the media in milliseconds.
+
+ If the media doesn't have a fixed duration (a live stream for example) this will be 0.
+*/
+
+/*!
+ \qmlproperty int Video::position
+
+ This property holds the current playback position in milliseconds.
+*/
+
+/*!
+ \qmlproperty qreal Video::volume
+
+ This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
+*/
+
+/*!
+ \qmlproperty bool Video::muted
+
+ This property holds whether the audio output is muted.
+*/
+
+/*!
+ \qmlproperty bool Video::hasAudio
+
+ This property holds whether the media contains audio.
+*/
+
+bool QDeclarativeVideo::hasAudio() const
+{
+ return m_playerControl->isAudioAvailable();
+}
+
+/*!
+ \qmlproperty bool Video::hasVideo
+
+ This property holds whether the media contains video.
+*/
+
+bool QDeclarativeVideo::hasVideo() const
+{
+ return m_playerControl->isVideoAvailable();
+}
+
+/*!
+ \qmlproperty qreal Video::bufferProgress
+
+ This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
+ (full).
+*/
+
+/*!
+ \qmlproperty bool Video::seekable
+
+ This property holds whether position of the video can be changed.
+*/
+
+/*!
+ \qmlproperty qreal Video::playbackRate
+
+ This property holds the rate at which video is played at as a multiple of the normal rate.
+*/
+
+/*!
+ \qmlproperty enum Video::error
+
+ This property holds the error state of the video. It can be one of:
+
+ \list
+ \o NoError - there is no current error.
+ \o ResourceError - the video cannot be played due to a problem allocating resources.
+ \o FormatError - the video format is not supported.
+ \o NetworkError - the video cannot be played due to network issues.
+ \o AccessDenied - the video cannot be played due to insufficient permissions.
+ \o ServiceMissing - the video cannot be played because the media service could not be
+ instantiated.
+ \endlist
+*/
+
+
+QDeclarativeVideo::Error QDeclarativeVideo::error() const
+{
+ return Error(m_error);
+}
+
+/*!
+ \qmlproperty string Video::errorString
+
+ This property holds a string describing the current error condition in more detail.
+*/
+
+/*!
+ \qmlsignal Video::onError(error, errorString)
+
+ This handler is called when an \l {Error}{error} has occurred. The errorString parameter
+ may contain more detailed information about the error.
+*/
+
+/*!
+ \qmlproperty enum Video::fillMode
+
+ Set this property to define how the video is scaled to fit the target area.
+
+ \list
+ \o Stretch - the video is scaled to fit.
+ \o PreserveAspectFit - the video is scaled uniformly to fit without cropping
+ \o PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary
+ \endlist
+
+ The default fill mode is PreserveAspectFit.
+*/
+
+QDeclarativeVideo::FillMode QDeclarativeVideo::fillMode() const
+{
+ return FillMode(m_graphicsItem->aspectRatioMode());
+}
+
+void QDeclarativeVideo::setFillMode(FillMode mode)
+{
+ m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode));
+}
+
+/*!
+ \qmlmethod Video::play()
+
+ Starts playback of the media.
+
+ Sets the \l playing property to true, and the \l paused property to false.
+*/
+
+void QDeclarativeVideo::play()
+{
+ m_playerControl->play();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Video::pause()
+
+ Pauses playback of the media.
+
+ Sets the \l playing and \l paused properties to true.
+*/
+
+void QDeclarativeVideo::pause()
+{
+ m_playerControl->pause();
+
+ if (!m_paused && m_state == QMediaPlayer::PausedState) {
+ m_paused = true;
+ emit pausedChanged();
+ }
+}
+
+/*!
+ \qmlmethod Video::stop()
+
+ Stops playback of the media.
+
+ Sets the \l playing and \l paused properties to false.
+*/
+
+void QDeclarativeVideo::stop()
+{
+ m_playerControl->stop();
+
+ if (m_paused) {
+ m_paused = false;
+ emit pausedChanged();
+ }
+}
+
+void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ m_graphicsItem->setSize(newGeometry.size());
+
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+QT_END_NAMESPACE
+
+// ***************************************
+// Documentation for meta-data properties.
+// ***************************************
+
+/*!
+ \qmlproperty variant Video::title
+
+ This property holds the tile of the media.
+
+ \sa {QtMultimedia::Title}
+*/
+
+/*!
+ \qmlproperty variant Video::subTitle
+
+ This property holds the sub-title of the media.
+
+ \sa {QtMultimedia::SubTitle}
+*/
+
+/*!
+ \qmlproperty variant Video::author
+
+ This property holds the author of the media.
+
+ \sa {QtMultimedia::Author}
+*/
+
+/*!
+ \qmlproperty variant Video::comment
+
+ This property holds a user comment about the media.
+
+ \sa {QtMultimedia::Comment}
+*/
+
+/*!
+ \qmlproperty variant Video::description
+
+ This property holds a description of the media.
+
+ \sa {QtMultimedia::Description}
+*/
+
+/*!
+ \qmlproperty variant Video::category
+
+ This property holds the category of the media
+
+ \sa {QtMultimedia::Category}
+*/
+
+/*!
+ \qmlproperty variant Video::genre
+
+ This property holds the genre of the media.
+
+ \sa {QtMultimedia::Genre}
+*/
+
+/*!
+ \qmlproperty variant Video::year
+
+ This property holds the year of release of the media.
+
+ \sa {QtMultimedia::Year}
+*/
+
+/*!
+ \qmlproperty variant Video::date
+
+ This property holds the date of the media.
+
+ \sa {QtMultimedia::Date}
+*/
+
+/*!
+ \qmlproperty variant Video::userRating
+
+ This property holds a user rating of the media in the range of 0 to 100.
+
+ \sa {QtMultimedia::UserRating}
+*/
+
+/*!
+ \qmlproperty variant Video::keywords
+
+ This property holds a list of keywords describing the media.
+
+ \sa {QtMultimedia::Keywords}
+*/
+
+/*!
+ \qmlproperty variant Video::language
+
+ This property holds the language of the media, as an ISO 639-2 code.
+
+ \sa {QtMultimedia::Language}
+*/
+
+/*!
+ \qmlproperty variant Video::publisher
+
+ This property holds the publisher of the media.
+
+ \sa {QtMultimedia::Publisher}
+*/
+
+/*!
+ \qmlproperty variant Video::copyright
+
+ This property holds the media's copyright notice.
+
+ \sa {QtMultimedia::Copyright}
+*/
+
+/*!
+ \qmlproperty variant Video::parentalRating
+
+ This property holds the parental rating of the media.
+
+ \sa {QtMultimedia::ParentalRating}
+*/
+
+/*!
+ \qmlproperty variant Video::ratingOrganisation
+
+ This property holds the name of the rating organisation responsible for the
+ parental rating of the media.
+
+ \sa {QtMultimedia::RatingOrganisation}
+*/
+
+/*!
+ \qmlproperty variant Video::size
+
+ This property property holds the size of the media in bytes.
+
+ \sa {QtMultimedia::Size}
+*/
+
+/*!
+ \qmlproperty variant Video::mediaType
+
+ This property holds the type of the media.
+
+ \sa {QtMultimedia::MediaType}
+*/
+
+/*!
+ \qmlproperty variant Video::audioBitRate
+
+ This property holds the bit rate of the media's audio stream ni bits per
+ second.
+
+ \sa {QtMultimedia::AudioBitRate}
+*/
+
+/*!
+ \qmlproperty variant Video::audioCodec
+
+ This property holds the encoding of the media audio stream.
+
+ \sa {QtMultimedia::AudioCodec}
+*/
+
+/*!
+ \qmlproperty variant Video::averageLevel
+
+ This property holds the average volume level of the media.
+
+ \sa {QtMultimedia::AverageLevel}
+*/
+
+/*!
+ \qmlproperty variant Video::channelCount
+
+ This property holds the number of channels in the media's audio stream.
+
+ \sa {QtMultimedia::ChannelCount}
+*/
+
+/*!
+ \qmlproperty variant Video::peakValue
+
+ This property holds the peak volume of media's audio stream.
+
+ \sa {QtMultimedia::PeakValue}
+*/
+
+/*!
+ \qmlproperty variant Video::sampleRate
+
+ This property holds the sample rate of the media's audio stream in hertz.
+
+ \sa {QtMultimedia::SampleRate}
+*/
+
+/*!
+ \qmlproperty variant Video::albumTitle
+
+ This property holds the title of the album the media belongs to.
+
+ \sa {QtMultimedia::AlbumTitle}
+*/
+
+/*!
+ \qmlproperty variant Video::albumArtist
+
+ This property holds the name of the principal artist of the album the media
+ belongs to.
+
+ \sa {QtMultimedia::AlbumArtist}
+*/
+
+/*!
+ \qmlproperty variant Video::contributingArtist
+
+ This property holds the names of artists contributing to the media.
+
+ \sa {QtMultimedia::ContributingArtist}
+*/
+
+/*!
+ \qmlproperty variant Video::composer
+
+ This property holds the composer of the media.
+
+ \sa {QtMultimedia::Composer}
+*/
+
+/*!
+ \qmlproperty variant Video::conductor
+
+ This property holds the conductor of the media.
+
+ \sa {QtMultimedia::Conductor}
+*/
+
+/*!
+ \qmlproperty variant Video::lyrics
+
+ This property holds the lyrics to the media.
+
+ \sa {QtMultimedia::Lyrics}
+*/
+
+/*!
+ \qmlproperty variant Video::mood
+
+ This property holds the mood of the media.
+
+ \sa {QtMultimedia::Mood}
+*/
+
+/*!
+ \qmlproperty variant Video::trackNumber
+
+ This property holds the track number of the media.
+
+ \sa {QtMultimedia::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::trackCount
+
+ This property holds the number of track on the album containing the media.
+
+ \sa {QtMultimedia::TrackNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::coverArtUrlSmall
+
+ This property holds the URL of a small cover art image.
+
+ \sa {QtMultimedia::CoverArtUrlSmall}
+*/
+
+/*!
+ \qmlproperty variant Video::coverArtUrlLarge
+
+ This property holds the URL of a large cover art image.
+
+ \sa {QtMultimedia::CoverArtUrlLarge}
+*/
+
+/*!
+ \qmlproperty variant Video::resolution
+
+ This property holds the dimension of an image or video.
+
+ \sa {QtMultimedia::Resolution}
+*/
+
+/*!
+ \qmlproperty variant Video::pixelAspectRatio
+
+ This property holds the pixel aspect ratio of an image or video.
+
+ \sa {QtMultimedia::PixelAspectRatio}
+*/
+
+/*!
+ \qmlproperty variant Video::videoFrameRate
+
+ This property holds the frame rate of the media's video stream.
+
+ \sa {QtMultimedia::VideoFrameRate}
+*/
+
+/*!
+ \qmlproperty variant Video::videoBitRate
+
+ This property holds the bit rate of the media's video stream in bits per
+ second.
+
+ \sa {QtMultimedia::VideoBitRate}
+*/
+
+/*!
+ \qmlproperty variant Video::videoCodec
+
+ This property holds the encoding of the media's video stream.
+
+ \sa {QtMultimedia::VideoCodec}
+*/
+
+/*!
+ \qmlproperty variant Video::posterUrl
+
+ This property holds the URL of a poster image.
+
+ \sa {QtMultimedia::PosterUrl}
+*/
+
+/*!
+ \qmlproperty variant Video::chapterNumber
+
+ This property holds the chapter number of the media.
+
+ \sa {QtMultimedia::ChapterNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::director
+
+ This property holds the director of the media.
+
+ \sa {QtMultimedia::Director}
+*/
+
+/*!
+ \qmlproperty variant Video::leadPerformer
+
+ This property holds the lead performer in the media.
+
+ \sa {QtMultimedia::LeadPerformer}
+*/
+
+/*!
+ \qmlproperty variant Video::writer
+
+ This property holds the writer of the media.
+
+ \sa {QtMultimedia::Writer}
+*/
+
+// The remaining properties are related to photos, and are technically
+// available but will certainly never have values.
+#ifndef Q_QDOC
+
+/*!
+ \qmlproperty variant Video::cameraManufacturer
+
+ \sa {QtMultimedia::CameraManufacturer}
+*/
+
+/*!
+ \qmlproperty variant Video::cameraModel
+
+ \sa {QtMultimedia::CameraModel}
+*/
+
+/*!
+ \qmlproperty variant Video::event
+
+ \sa {QtMultimedia::Event}
+*/
+
+/*!
+ \qmlproperty variant Video::subject
+
+ \sa {QtMultimedia::Subject}
+*/
+
+/*!
+ \qmlproperty variant Video::orientation
+
+ \sa {QtMultimedia::Orientation}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureTime
+
+ \sa {QtMultimedia::ExposureTime}
+*/
+
+/*!
+ \qmlproperty variant Video::fNumber
+
+ \sa {QtMultimedia::FNumber}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureProgram
+
+ \sa {QtMultimedia::ExposureProgram}
+*/
+
+/*!
+ \qmlproperty variant Video::isoSpeedRatings
+
+ \sa {QtMultimedia::ISOSpeedRatings}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureBiasValue
+
+ \sa {QtMultimedia::ExposureBiasValue}
+*/
+
+/*!
+ \qmlproperty variant Video::dateTimeDigitized
+
+ \sa {QtMultimedia::DateTimeDigitized}
+*/
+
+/*!
+ \qmlproperty variant Video::subjectDistance
+
+ \sa {QtMultimedia::SubjectDistance}
+*/
+
+/*!
+ \qmlproperty variant Video::meteringMode
+
+ \sa {QtMultimedia::MeteringMode}
+*/
+
+/*!
+ \qmlproperty variant Video::lightSource
+
+ \sa {QtMultimedia::LightSource}
+*/
+
+/*!
+ \qmlproperty variant Video::flash
+
+ \sa {QtMultimedia::Flash}
+*/
+
+/*!
+ \qmlproperty variant Video::focalLength
+
+ \sa {QtMultimedia::FocalLength}
+*/
+
+/*!
+ \qmlproperty variant Video::exposureMode
+
+ \sa {QtMultimedia::ExposureMode}
+*/
+
+/*!
+ \qmlproperty variant Video::whiteBalance
+
+ \sa {QtMultimedia::WhiteBalance}
+*/
+
+/*!
+ \qmlproperty variant Video::DigitalZoomRatio
+
+ \sa {QtMultimedia::DigitalZoomRatio}
+*/
+
+/*!
+ \qmlproperty variant Video::focalLengthIn35mmFilm
+
+ \sa {QtMultimedia::FocalLengthIn35mmFile}
+*/
+
+/*!
+ \qmlproperty variant Video::sceneCaptureType
+
+ \sa {QtMultimedia::SceneCaptureType}
+*/
+
+/*!
+ \qmlproperty variant Video::gainControl
+
+ \sa {QtMultimedia::GainControl}
+*/
+
+/*!
+ \qmlproperty variant Video::contrast
+
+ \sa {QtMultimedia::contrast}
+*/
+
+/*!
+ \qmlproperty variant Video::saturation
+
+ \sa {QtMultimedia::Saturation}
+*/
+
+/*!
+ \qmlproperty variant Video::sharpness
+
+ \sa {QtMultimedia::Sharpness}
+*/
+
+/*!
+ \qmlproperty variant Video::deviceSettingDescription
+
+ \sa {QtMultimedia::DeviceSettingDescription}
+*/
+
+#endif
+
+#include "moc_qdeclarativevideo_p.cpp"
diff --git a/src/multimedia/qml/qdeclarativevideo_p.h b/src/multimedia/qml/qdeclarativevideo_p.h
new file mode 100644
index 0000000000..d5ebde1a7f
--- /dev/null
+++ b/src/multimedia/qml/qdeclarativevideo_p.h
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtMultimedia module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEVIDEO_H
+#define QDECLARATIVEVIDEO_H
+
+//
+// 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.
+//
+
+#include <QtMultimedia/private/qdeclarativemediabase_p.h>
+
+#include <QtMultimedia/qgraphicsvideoitem.h>
+
+#include <QtCore/qbasictimer.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTimerEvent;
+class QVideoSurfaceFormat;
+
+
+class Q_AUTOTEST_EXPORT QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
+ Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
+ Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
+ Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged)
+ Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
+ Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
+ Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
+ Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
+ Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode)
+ Q_ENUMS(FillMode)
+ Q_ENUMS(Status)
+ Q_ENUMS(Error)
+public:
+ enum FillMode
+ {
+ Stretch = Qt::IgnoreAspectRatio,
+ PreserveAspectFit = Qt::KeepAspectRatio,
+ PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
+ };
+
+ enum Status
+ {
+ UnknownStatus = QMediaPlayer::UnknownMediaStatus,
+ NoMedia = QMediaPlayer::NoMedia,
+ Loading = QMediaPlayer::LoadingMedia,
+ Loaded = QMediaPlayer::LoadedMedia,
+ Stalled = QMediaPlayer::StalledMedia,
+ Buffering = QMediaPlayer::BufferingMedia,
+ Buffered = QMediaPlayer::BufferedMedia,
+ EndOfMedia = QMediaPlayer::EndOfMedia,
+ InvalidMedia = QMediaPlayer::InvalidMedia
+ };
+
+ enum Error
+ {
+ NoError = QMediaPlayer::NoError,
+ ResourceError = QMediaPlayer::ResourceError,
+ FormatError = QMediaPlayer::FormatError,
+ NetworkError = QMediaPlayer::NetworkError,
+ AccessDenied = QMediaPlayer::AccessDeniedError,
+ ServiceMissing = QMediaPlayer::ServiceMissingError
+ };
+
+ QDeclarativeVideo(QDeclarativeItem *parent = 0);
+ ~QDeclarativeVideo();
+
+ bool hasAudio() const;
+ bool hasVideo() const;
+
+ FillMode fillMode() const;
+ void setFillMode(FillMode mode);
+
+ Status status() const;
+ Error error() const;
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+public Q_SLOTS:
+ void play();
+ void pause();
+ void stop();
+
+Q_SIGNALS:
+ void sourceChanged();
+
+ void playingChanged();
+ void pausedChanged();
+
+ void started();
+ void resumed();
+ void paused();
+ void stopped();
+
+ void statusChanged();
+
+ void loaded();
+ void buffering();
+ void stalled();
+ void buffered();
+ void endOfMedia();
+
+ void durationChanged();
+ void positionChanged();
+
+ void volumeChanged();
+ void mutedChanged();
+ void hasAudioChanged();
+ void hasVideoChanged();
+
+ void bufferProgressChanged();
+
+ void seekableChanged();
+ void playbackRateChanged();
+
+ void errorChanged();
+ void error(QDeclarativeVideo::Error error, const QString &errorString);
+
+protected:
+ void geometryChanged(const QRectF &geometry, const QRectF &);
+
+private Q_SLOTS:
+ void _q_nativeSizeChanged(const QSizeF &size);
+ void _q_error(int, const QString &);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeVideo)
+
+ QGraphicsVideoItem *m_graphicsItem;
+
+ Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
+ Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
+
+ inline QDeclarativeMediaBase *mediaBase() { return this; }
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo))
+
+QT_END_HEADER
+
+#endif
diff --git a/src/multimedia/qml/qml.pri b/src/multimedia/qml/qml.pri
index a7ca02e4ac..d0ff71d8f4 100644
--- a/src/multimedia/qml/qml.pri
+++ b/src/multimedia/qml/qml.pri
@@ -17,20 +17,20 @@ contains(QT_CONFIG, declarative) {
}
HEADERS += \
- $$PWD/multimediaqml.h \
+ $$PWD/multimediadeclarative.h \
$$PWD/qmetadatacontrolmetaobject_p.h \
- $$PWD/qmlaudio_p.h \
- $$PWD/qmlgraphicsvideo_p.h \
- $$PWD/qmlmediabase_p.h \
+ $$PWD/qdeclarativeaudio_p.h \
+ $$PWD/qdeclarativevideo_p.h \
+ $$PWD/qdeclarativemediabase_p.h \
$$PWD/qsoundeffect_p.h \
$$PWD/wavedecoder_p.h
SOURCES += \
- $$PWD/multimediaqml.cpp \
+ $$PWD/multimediadeclarative.cpp \
$$PWD/qmetadatacontrolmetaobject.cpp \
- $$PWD/qmlaudio.cpp \
- $$PWD/qmlgraphicsvideo.cpp \
- $$PWD/qmlmediabase.cpp \
+ $$PWD/qdeclarativeaudio.cpp \
+ $$PWD/qdeclarativevideo.cpp \
+ $$PWD/qdeclarativemediabase.cpp \
$$PWD/qsoundeffect.cpp \
$$PWD/wavedecoder_p.cpp
}
diff --git a/src/multimedia/qml/qmlaudio.cpp b/src/multimedia/qml/qmlaudio.cpp
deleted file mode 100644
index 80f56783ec..0000000000
--- a/src/multimedia/qml/qmlaudio.cpp
+++ /dev/null
@@ -1,327 +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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qmlaudio_p.h"
-
-#include <QtMultimedia/qmediaplayercontrol.h>
-
-QT_BEGIN_NAMESPACE
-
-
-/*!
- \qmlclass Audio QmlAudio
- \since 4.7
- \brief The Audio element allows you to add audio playback to a scene.
-
- \qml
- Audio { source: "audio/song.mp3" }
- \endqml
-
- \sa Video
-*/
-
-/*!
- \internal
- \class QmlAudio
- \brief The QmlAudio class provides an audio item that you can add to a QmlView.
-*/
-
-void QmlAudio::_q_error(int errorCode, const QString &errorString)
-{
- m_error = QMediaPlayer::Error(errorCode);
- m_errorString = errorString;
-
- emit error(Error(errorCode), errorString);
- emit errorChanged();
-}
-
-
-QmlAudio::QmlAudio(QObject *parent)
- : QObject(parent)
-{
- setObject(this);
-}
-
-QmlAudio::~QmlAudio()
-{
- shutdown();
-}
-
-/*!
- \qmlmethod Audio::play()
-
- Starts playback of the media.
-
- Sets the \l playing property to true, and the \l paused property to false.
-*/
-
-void QmlAudio::play()
-{
- m_playerControl->play();
-
- if (m_paused) {
- m_paused = false;
- emit pausedChanged();
- }
-}
-
-/*!
- \qmlmethod Audio::pause()
-
- Pauses playback of the media.
-
- Sets the \l playing and \l paused properties to true.
-*/
-
-void QmlAudio::pause()
-{
- m_playerControl->pause();
-
- if (!m_paused && m_state == QMediaPlayer::PausedState) {
- m_paused = true;
- emit pausedChanged();
- }
-}
-
-/*!
- \qmlmethod Audio::stop()
-
- Stops playback of the media.
-
- Sets the \l playing and \l paused properties to false.
-*/
-
-void QmlAudio::stop()
-{
- m_playerControl->stop();
-
- if (m_paused) {
- m_paused = false;
- emit pausedChanged();
- }
-}
-
-/*!
- \qmlproperty url Audio::source
-
- This property holds the source URL of the media.
-*/
-
-/*!
- \qmlproperty bool Audio::playing
-
- This property holds whether the media is playing.
-
- Defaults to false, and can be set to true to start playback.
-*/
-
-/*!
- \qmlproperty bool Audio::paused
-
- This property holds whether the media is paused.
-
- Defaults to false, and can be set to true to pause playback.
-*/
-
-/*!
- \qmlsignal Audio::onStarted()
-
- This handler is called when playback is started.
-*/
-
-/*!
- \qmlsignal Audio::onResumed()
-
- This handler is called when playback is resumed from the paused state.
-*/
-
-/*!
- \qmlsignal Audio::onPaused()
-
- This handler is called when playback is paused.
-*/
-
-/*!
- \qmlsignal Audio::onStopped()
-
- This handler is called when playback is stopped.
-*/
-
-/*!
- \qmlproperty enum Audio::status
-
- This property holds the status of media loading. It can be one of:
-
- \list
- \o NoMedia - no media has been set.
- \o Loading - the media is currently being loaded.
- \o Loaded - the media has been loaded.
- \o Buffering - the media is buffering data.
- \o Stalled - playback has been interrupted while the media is buffering data.
- \o Buffered - the media has buffered data.
- \o EndOfMedia - the media has played to the end.
- \o InvalidMedia - the media cannot be played.
- \o UnknownStatus - the status of the media is unknown.
- \endlist
-*/
-
-QmlAudio::Status QmlAudio::status() const
-{
- return Status(m_status);
-}
-
-/*!
- \qmlsignal Audio::onLoaded()
-
- This handler is called when the media source has been loaded.
-*/
-
-/*!
- \qmlsignal Audio::onBuffering()
-
- This handler is called when the media starts buffering.
-*/
-
-/*!
- \qmlsignal Audio::onStalled()
-
- This handler is called when playback has stalled while the media buffers.
-*/
-
-/*!
- \qmlsignal Audio::onBuffered()
-
- This handler is called when the media has finished buffering.
-*/
-
-/*!
- \qmlsignal Audio::onEndOfMedia()
-
- This handler is called when playback stops because end of the media has been reached.
-*/
-/*!
- \qmlproperty int Audio::duration
-
- This property holds the duration of the media in milliseconds.
-
- If the media doesn't have a fixed duration (a live stream for example) this will be 0.
-*/
-
-/*!
- \qmlproperty int Audio::position
-
- This property holds the current playback position in milliseconds.
-
- If the \l seekable property is true, this property can be set to seek to a new position.
-*/
-
-/*!
- \qmlproperty qreal Audio::volume
-
- This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
-*/
-
-/*!
- \qmlproperty bool Audio::muted
-
- This property holds whether the audio output is muted.
-*/
-
-/*!
- \qmlproperty qreal Audio::bufferProgress
-
- This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
- (full).
-*/
-
-/*!
- \qmlproperty bool Audio::seekable
-
- This property holds whether position of the audio can be changed.
-
- If true; setting a \l position value will cause playback to seek to the new position.
-*/
-
-/*!
- \qmlproperty qreal Audio::playbackRate
-
- This property holds the rate at which audio is played at as a multiple of the normal rate.
-*/
-
-/*!
- \qmlproperty enum Audio::error
-
- This property holds the error state of the audio. It can be one of:
-
- \list
- \o NoError - there is no current error.
- \o ResourceError - the audio cannot be played due to a problem allocating resources.
- \o FormatError - the audio format is not supported.
- \o NetworkError - the audio cannot be played due to network issues.
- \o AccessDenied - the audio cannot be played due to insufficient permissions.
- \o ServiceMissing - the audio cannot be played because the media service could not be
- instantiated.
- \endlist
-*/
-
-QmlAudio::Error QmlAudio::error() const
-{
- return Error(m_error);
-}
-
-/*!
- \qmlproperty string Audio::errorString
-
- This property holds a string describing the current error condition in more detail.
-*/
-
-/*!
- \qmlsignal Audio::onError(error, errorString)
-
- This handler is called when an \l {Error}{error} has occurred. The errorString parameter
- may contain more detailed information about the error.
-*/
-
-QT_END_NAMESPACE
-
-#include "moc_qmlaudio_p.cpp"
-
-
diff --git a/src/multimedia/qml/qmlaudio_p.h b/src/multimedia/qml/qmlaudio_p.h
deleted file mode 100644
index bb0d3012f5..0000000000
--- a/src/multimedia/qml/qmlaudio_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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QMLAUDIO_P_H
-#define QMLAUDIO_P_H
-
-//
-// 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.
-//
-
-#include <QtMultimedia/private/qmlmediabase_p.h>
-
-#include <QtCore/qbasictimer.h>
-#include <QtDeclarative/qmlgraphicsitem.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QTimerEvent;
-
-class Q_AUTOTEST_EXPORT QmlAudio : public QObject, public QmlMediaBase, public QmlParserStatus
-{
- Q_OBJECT
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
- Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
- Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
- Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
- Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
- Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
- Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
- Q_PROPERTY(Error error READ error NOTIFY errorChanged)
- Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
- Q_ENUMS(Status)
- Q_ENUMS(Error)
- Q_INTERFACES(QmlParserStatus)
-public:
- enum Status
- {
- UnknownStatus = QMediaPlayer::UnknownMediaStatus,
- NoMedia = QMediaPlayer::NoMedia,
- Loading = QMediaPlayer::LoadingMedia,
- Loaded = QMediaPlayer::LoadedMedia,
- Stalled = QMediaPlayer::StalledMedia,
- Buffering = QMediaPlayer::BufferingMedia,
- Buffered = QMediaPlayer::BufferedMedia,
- EndOfMedia = QMediaPlayer::EndOfMedia,
- InvalidMedia = QMediaPlayer::InvalidMedia
- };
-
- enum Error
- {
- NoError = QMediaPlayer::NoError,
- ResourceError = QMediaPlayer::ResourceError,
- FormatError = QMediaPlayer::FormatError,
- NetworkError = QMediaPlayer::NetworkError,
- AccessDenied = QMediaPlayer::AccessDeniedError,
- ServiceMissing = QMediaPlayer::ServiceMissingError
- };
-
- QmlAudio(QObject *parent = 0);
- ~QmlAudio();
-
- Status status() const;
- Error error() const;
-
-public Q_SLOTS:
- void play();
- void pause();
- void stop();
-
-Q_SIGNALS:
- void sourceChanged();
-
- void playingChanged();
- void pausedChanged();
-
- void started();
- void resumed();
- void paused();
- void stopped();
-
- void statusChanged();
-
- void loaded();
- void buffering();
- void stalled();
- void buffered();
- void endOfMedia();
-
- void durationChanged();
- void positionChanged();
-
- void volumeChanged();
- void mutedChanged();
-
- void bufferProgressChanged();
-
- void seekableChanged();
- void playbackRateChanged();
-
- void errorChanged();
- void error(QmlAudio::Error error, const QString &errorString);
-
-private Q_SLOTS:
- void _q_error(int, const QString &);
-
-private:
- Q_DISABLE_COPY(QmlAudio)
- Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
- Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
- Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
-
- inline QmlMediaBase *mediaBase() { return this; }
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QmlAudio))
-
-QT_END_HEADER
-
-#endif
diff --git a/src/multimedia/qml/qmlgraphicsvideo.cpp b/src/multimedia/qml/qmlgraphicsvideo.cpp
deleted file mode 100644
index baf96bac78..0000000000
--- a/src/multimedia/qml/qmlgraphicsvideo.cpp
+++ /dev/null
@@ -1,945 +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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qmlgraphicsvideo_p.h"
-
-#include <QtMultimedia/qmediaplayercontrol.h>
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/private/qpaintervideosurface_p.h>
-#include <QtMultimedia/qvideooutputcontrol.h>
-#include <QtMultimedia/qvideorenderercontrol.h>
-
-
-QT_BEGIN_NAMESPACE
-
-
-void QmlGraphicsVideo::_q_nativeSizeChanged(const QSizeF &size)
-{
- setImplicitWidth(size.width());
- setImplicitHeight(size.height());
-}
-
-void QmlGraphicsVideo::_q_error(int errorCode, const QString &errorString)
-{
- m_error = QMediaPlayer::Error(errorCode);
- m_errorString = errorString;
-
- emit error(Error(errorCode), errorString);
- emit errorChanged();
-}
-
-
-/*!
- \qmlclass Video QmlGraphicsVideo
- \since 4.7
- \brief The Video element allows you to add videos to a scene.
- \inherits Item
-
- \qml
- Video { source: "video/movie.mpg" }
- \endqml
-
- The video item supports untransformed, stretched, and uniformly scaled video presentation.
- For a description of stretched uniformly scaled presentation, see the \l fillMode property
- description.
-
- The video item is only visible when the \l hasVideo property is true and the video is playing.
-
- \sa Audio
-*/
-
-/*!
- \internal
- \class QmlGraphicsVideo
- \brief The QmlGraphicsVideo class provides a video item that you can add to a QmlView.
-*/
-
-QmlGraphicsVideo::QmlGraphicsVideo(QmlGraphicsItem *parent)
- : QmlGraphicsItem(parent)
- , m_graphicsItem(0)
-
-{
- m_graphicsItem = new QGraphicsVideoItem(this);
- connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
- this, SLOT(_q_nativeSizeChanged(QSizeF)));
-
- setObject(this);
-
- if (m_mediaService) {
- connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
- this, SIGNAL(hasAudioChanged()));
- connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
- this, SIGNAL(hasVideoChanged()));
-
- m_graphicsItem->setMediaObject(m_mediaObject);
- }
-}
-
-QmlGraphicsVideo::~QmlGraphicsVideo()
-{
- shutdown();
-
- delete m_graphicsItem;
-}
-
-/*!
- \qmlproperty url Video::source
-
- This property holds the source URL of the media.
-*/
-
-/*!
- \qmlproperty bool Video::playing
-
- This property holds whether the media is playing.
-
- Defaults to false, and can be set to true to start playback.
-*/
-
-/*!
- \qmlproperty bool Video::paused
-
- This property holds whether the media is paused.
-
- Defaults to false, and can be set to true to pause playback.
-*/
-
-/*!
- \qmlsignal Video::onStarted()
-
- This handler is called when playback is started.
-*/
-
-/*!
- \qmlsignal Video::onResumed()
-
- This handler is called when playback is resumed from the paused state.
-*/
-
-/*!
- \qmlsignal Video::onPaused()
-
- This handler is called when playback is paused.
-*/
-
-/*!
- \qmlsignal Video::onStopped()
-
- This handler is called when playback is stopped.
-*/
-
-/*!
- \qmlproperty enum Video::status
-
- This property holds the status of media loading. It can be one of:
-
- \list
- \o NoMedia - no media has been set.
- \o Loading - the media is currently being loaded.
- \o Loaded - the media has been loaded.
- \o Buffering - the media is buffering data.
- \o Stalled - playback has been interrupted while the media is buffering data.
- \o Buffered - the media has buffered data.
- \o EndOfMedia - the media has played to the end.
- \o InvalidMedia - the media cannot be played.
- \o UnknownStatus - the status of the media is cannot be determined.
- \endlist
-*/
-
-QmlGraphicsVideo::Status QmlGraphicsVideo::status() const
-{
- return Status(m_status);
-}
-
-/*!
- \qmlsignal Video::onLoaded()
-
- This handler is called when the media source has been loaded.
-*/
-
-/*!
- \qmlsignal Video::onBuffering()
-
- This handler is called when the media starts buffering.
-*/
-
-/*!
- \qmlsignal Video::onStalled()
-
- This handler is called when playback has stalled while the media buffers.
-*/
-
-/*!
- \qmlsignal Video::onBuffered()
-
- This handler is called when the media has finished buffering.
-*/
-
-/*!
- \qmlsignal Video::onEndOfMedia()
-
- This handler is called when playback stops because end of the media has been reached.
-*/
-
-/*!
- \qmlproperty int Video::duration
-
- This property holds the duration of the media in milliseconds.
-
- If the media doesn't have a fixed duration (a live stream for example) this will be 0.
-*/
-
-/*!
- \qmlproperty int Video::position
-
- This property holds the current playback position in milliseconds.
-*/
-
-/*!
- \qmlproperty qreal Video::volume
-
- This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
-*/
-
-/*!
- \qmlproperty bool Video::muted
-
- This property holds whether the audio output is muted.
-*/
-
-/*!
- \qmlproperty bool Video::hasAudio
-
- This property holds whether the media contains audio.
-*/
-
-bool QmlGraphicsVideo::hasAudio() const
-{
- return m_playerControl->isAudioAvailable();
-}
-
-/*!
- \qmlproperty bool Video::hasVideo
-
- This property holds whether the media contains video.
-*/
-
-bool QmlGraphicsVideo::hasVideo() const
-{
- return m_playerControl->isVideoAvailable();
-}
-
-/*!
- \qmlproperty qreal Video::bufferProgress
-
- This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
- (full).
-*/
-
-/*!
- \qmlproperty bool Video::seekable
-
- This property holds whether position of the video can be changed.
-*/
-
-/*!
- \qmlproperty qreal Video::playbackRate
-
- This property holds the rate at which video is played at as a multiple of the normal rate.
-*/
-
-/*!
- \qmlproperty enum Video::error
-
- This property holds the error state of the video. It can be one of:
-
- \list
- \o NoError - there is no current error.
- \o ResourceError - the video cannot be played due to a problem allocating resources.
- \o FormatError - the video format is not supported.
- \o NetworkError - the video cannot be played due to network issues.
- \o AccessDenied - the video cannot be played due to insufficient permissions.
- \o ServiceMissing - the video cannot be played because the media service could not be
- instantiated.
- \endlist
-*/
-
-
-QmlGraphicsVideo::Error QmlGraphicsVideo::error() const
-{
- return Error(m_error);
-}
-
-/*!
- \qmlproperty string Video::errorString
-
- This property holds a string describing the current error condition in more detail.
-*/
-
-/*!
- \qmlsignal Video::onError(error, errorString)
-
- This handler is called when an \l {Error}{error} has occurred. The errorString parameter
- may contain more detailed information about the error.
-*/
-
-/*!
- \qmlproperty enum Video::fillMode
-
- Set this property to define how the video is scaled to fit the target area.
-
- \list
- \o Stretch - the video is scaled to fit.
- \o PreserveAspectFit - the video is scaled uniformly to fit without cropping
- \o PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary
- \endlist
-
- The default fill mode is PreserveAspectFit.
-*/
-
-QmlGraphicsVideo::FillMode QmlGraphicsVideo::fillMode() const
-{
- return FillMode(m_graphicsItem->aspectRatioMode());
-}
-
-void QmlGraphicsVideo::setFillMode(FillMode mode)
-{
- m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode));
-}
-
-/*!
- \qmlmethod Video::play()
-
- Starts playback of the media.
-
- Sets the \l playing property to true, and the \l paused property to false.
-*/
-
-void QmlGraphicsVideo::play()
-{
- m_playerControl->play();
-
- if (m_paused) {
- m_paused = false;
- emit pausedChanged();
- }
-}
-
-/*!
- \qmlmethod Video::pause()
-
- Pauses playback of the media.
-
- Sets the \l playing and \l paused properties to true.
-*/
-
-void QmlGraphicsVideo::pause()
-{
- m_playerControl->pause();
-
- if (!m_paused && m_state == QMediaPlayer::PausedState) {
- m_paused = true;
- emit pausedChanged();
- }
-}
-
-/*!
- \qmlmethod Video::stop()
-
- Stops playback of the media.
-
- Sets the \l playing and \l paused properties to false.
-*/
-
-void QmlGraphicsVideo::stop()
-{
- m_playerControl->stop();
-
- if (m_paused) {
- m_paused = false;
- emit pausedChanged();
- }
-}
-
-void QmlGraphicsVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
-{
-}
-
-void QmlGraphicsVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- m_graphicsItem->setSize(newGeometry.size());
-
- QmlGraphicsItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-QT_END_NAMESPACE
-
-// ***************************************
-// Documentation for meta-data properties.
-// ***************************************
-
-/*!
- \qmlproperty variant Video::title
-
- This property holds the tile of the media.
-
- \sa {QtMultimedia::Title}
-*/
-
-/*!
- \qmlproperty variant Video::subTitle
-
- This property holds the sub-title of the media.
-
- \sa {QtMultimedia::SubTitle}
-*/
-
-/*!
- \qmlproperty variant Video::author
-
- This property holds the author of the media.
-
- \sa {QtMultimedia::Author}
-*/
-
-/*!
- \qmlproperty variant Video::comment
-
- This property holds a user comment about the media.
-
- \sa {QtMultimedia::Comment}
-*/
-
-/*!
- \qmlproperty variant Video::description
-
- This property holds a description of the media.
-
- \sa {QtMultimedia::Description}
-*/
-
-/*!
- \qmlproperty variant Video::category
-
- This property holds the category of the media
-
- \sa {QtMultimedia::Category}
-*/
-
-/*!
- \qmlproperty variant Video::genre
-
- This property holds the genre of the media.
-
- \sa {QtMultimedia::Genre}
-*/
-
-/*!
- \qmlproperty variant Video::year
-
- This property holds the year of release of the media.
-
- \sa {QtMultimedia::Year}
-*/
-
-/*!
- \qmlproperty variant Video::date
-
- This property holds the date of the media.
-
- \sa {QtMultimedia::Date}
-*/
-
-/*!
- \qmlproperty variant Video::userRating
-
- This property holds a user rating of the media in the range of 0 to 100.
-
- \sa {QtMultimedia::UserRating}
-*/
-
-/*!
- \qmlproperty variant Video::keywords
-
- This property holds a list of keywords describing the media.
-
- \sa {QtMultimedia::Keywords}
-*/
-
-/*!
- \qmlproperty variant Video::language
-
- This property holds the language of the media, as an ISO 639-2 code.
-
- \sa {QtMultimedia::Language}
-*/
-
-/*!
- \qmlproperty variant Video::publisher
-
- This property holds the publisher of the media.
-
- \sa {QtMultimedia::Publisher}
-*/
-
-/*!
- \qmlproperty variant Video::copyright
-
- This property holds the media's copyright notice.
-
- \sa {QtMultimedia::Copyright}
-*/
-
-/*!
- \qmlproperty variant Video::parentalRating
-
- This property holds the parental rating of the media.
-
- \sa {QtMultimedia::ParentalRating}
-*/
-
-/*!
- \qmlproperty variant Video::ratingOrganisation
-
- This property holds the name of the rating organisation responsible for the
- parental rating of the media.
-
- \sa {QtMultimedia::RatingOrganisation}
-*/
-
-/*!
- \qmlproperty variant Video::size
-
- This property property holds the size of the media in bytes.
-
- \sa {QtMultimedia::Size}
-*/
-
-/*!
- \qmlproperty variant Video::mediaType
-
- This property holds the type of the media.
-
- \sa {QtMultimedia::MediaType}
-*/
-
-/*!
- \qmlproperty variant Video::audioBitRate
-
- This property holds the bit rate of the media's audio stream ni bits per
- second.
-
- \sa {QtMultimedia::AudioBitRate}
-*/
-
-/*!
- \qmlproperty variant Video::audioCodec
-
- This property holds the encoding of the media audio stream.
-
- \sa {QtMultimedia::AudioCodec}
-*/
-
-/*!
- \qmlproperty variant Video::averageLevel
-
- This property holds the average volume level of the media.
-
- \sa {QtMultimedia::AverageLevel}
-*/
-
-/*!
- \qmlproperty variant Video::channelCount
-
- This property holds the number of channels in the media's audio stream.
-
- \sa {QtMultimedia::ChannelCount}
-*/
-
-/*!
- \qmlproperty variant Video::peakValue
-
- This property holds the peak volume of media's audio stream.
-
- \sa {QtMultimedia::PeakValue}
-*/
-
-/*!
- \qmlproperty variant Video::sampleRate
-
- This property holds the sample rate of the media's audio stream in hertz.
-
- \sa {QtMultimedia::SampleRate}
-*/
-
-/*!
- \qmlproperty variant Video::albumTitle
-
- This property holds the title of the album the media belongs to.
-
- \sa {QtMultimedia::AlbumTitle}
-*/
-
-/*!
- \qmlproperty variant Video::albumArtist
-
- This property holds the name of the principal artist of the album the media
- belongs to.
-
- \sa {QtMultimedia::AlbumArtist}
-*/
-
-/*!
- \qmlproperty variant Video::contributingArtist
-
- This property holds the names of artists contributing to the media.
-
- \sa {QtMultimedia::ContributingArtist}
-*/
-
-/*!
- \qmlproperty variant Video::composer
-
- This property holds the composer of the media.
-
- \sa {QtMultimedia::Composer}
-*/
-
-/*!
- \qmlproperty variant Video::conductor
-
- This property holds the conductor of the media.
-
- \sa {QtMultimedia::Conductor}
-*/
-
-/*!
- \qmlproperty variant Video::lyrics
-
- This property holds the lyrics to the media.
-
- \sa {QtMultimedia::Lyrics}
-*/
-
-/*!
- \qmlproperty variant Video::mood
-
- This property holds the mood of the media.
-
- \sa {QtMultimedia::Mood}
-*/
-
-/*!
- \qmlproperty variant Video::trackNumber
-
- This property holds the track number of the media.
-
- \sa {QtMultimedia::TrackNumber}
-*/
-
-/*!
- \qmlproperty variant Video::trackCount
-
- This property holds the number of track on the album containing the media.
-
- \sa {QtMultimedia::TrackNumber}
-*/
-
-/*!
- \qmlproperty variant Video::coverArtUrlSmall
-
- This property holds the URL of a small cover art image.
-
- \sa {QtMultimedia::CoverArtUrlSmall}
-*/
-
-/*!
- \qmlproperty variant Video::coverArtUrlLarge
-
- This property holds the URL of a large cover art image.
-
- \sa {QtMultimedia::CoverArtUrlLarge}
-*/
-
-/*!
- \qmlproperty variant Video::resolution
-
- This property holds the dimension of an image or video.
-
- \sa {QtMultimedia::Resolution}
-*/
-
-/*!
- \qmlproperty variant Video::pixelAspectRatio
-
- This property holds the pixel aspect ratio of an image or video.
-
- \sa {QtMultimedia::PixelAspectRatio}
-*/
-
-/*!
- \qmlproperty variant Video::videoFrameRate
-
- This property holds the frame rate of the media's video stream.
-
- \sa {QtMultimedia::VideoFrameRate}
-*/
-
-/*!
- \qmlproperty variant Video::videoBitRate
-
- This property holds the bit rate of the media's video stream in bits per
- second.
-
- \sa {QtMultimedia::VideoBitRate}
-*/
-
-/*!
- \qmlproperty variant Video::videoCodec
-
- This property holds the encoding of the media's video stream.
-
- \sa {QtMultimedia::VideoCodec}
-*/
-
-/*!
- \qmlproperty variant Video::posterUrl
-
- This property holds the URL of a poster image.
-
- \sa {QtMultimedia::PosterUrl}
-*/
-
-/*!
- \qmlproperty variant Video::chapterNumber
-
- This property holds the chapter number of the media.
-
- \sa {QtMultimedia::ChapterNumber}
-*/
-
-/*!
- \qmlproperty variant Video::director
-
- This property holds the director of the media.
-
- \sa {QtMultimedia::Director}
-*/
-
-/*!
- \qmlproperty variant Video::leadPerformer
-
- This property holds the lead performer in the media.
-
- \sa {QtMultimedia::LeadPerformer}
-*/
-
-/*!
- \qmlproperty variant Video::writer
-
- This property holds the writer of the media.
-
- \sa {QtMultimedia::Writer}
-*/
-
-// The remaining properties are related to photos, and are technically
-// available but will certainly never have values.
-#ifndef Q_QDOC
-
-/*!
- \qmlproperty variant Video::cameraManufacturer
-
- \sa {QtMultimedia::CameraManufacturer}
-*/
-
-/*!
- \qmlproperty variant Video::cameraModel
-
- \sa {QtMultimedia::CameraModel}
-*/
-
-/*!
- \qmlproperty variant Video::event
-
- \sa {QtMultimedia::Event}
-*/
-
-/*!
- \qmlproperty variant Video::subject
-
- \sa {QtMultimedia::Subject}
-*/
-
-/*!
- \qmlproperty variant Video::orientation
-
- \sa {QtMultimedia::Orientation}
-*/
-
-/*!
- \qmlproperty variant Video::exposureTime
-
- \sa {QtMultimedia::ExposureTime}
-*/
-
-/*!
- \qmlproperty variant Video::fNumber
-
- \sa {QtMultimedia::FNumber}
-*/
-
-/*!
- \qmlproperty variant Video::exposureProgram
-
- \sa {QtMultimedia::ExposureProgram}
-*/
-
-/*!
- \qmlproperty variant Video::isoSpeedRatings
-
- \sa {QtMultimedia::ISOSpeedRatings}
-*/
-
-/*!
- \qmlproperty variant Video::exposureBiasValue
-
- \sa {QtMultimedia::ExposureBiasValue}
-*/
-
-/*!
- \qmlproperty variant Video::dateTimeDigitized
-
- \sa {QtMultimedia::DateTimeDigitized}
-*/
-
-/*!
- \qmlproperty variant Video::subjectDistance
-
- \sa {QtMultimedia::SubjectDistance}
-*/
-
-/*!
- \qmlproperty variant Video::meteringMode
-
- \sa {QtMultimedia::MeteringMode}
-*/
-
-/*!
- \qmlproperty variant Video::lightSource
-
- \sa {QtMultimedia::LightSource}
-*/
-
-/*!
- \qmlproperty variant Video::flash
-
- \sa {QtMultimedia::Flash}
-*/
-
-/*!
- \qmlproperty variant Video::focalLength
-
- \sa {QtMultimedia::FocalLength}
-*/
-
-/*!
- \qmlproperty variant Video::exposureMode
-
- \sa {QtMultimedia::ExposureMode}
-*/
-
-/*!
- \qmlproperty variant Video::whiteBalance
-
- \sa {QtMultimedia::WhiteBalance}
-*/
-
-/*!
- \qmlproperty variant Video::DigitalZoomRatio
-
- \sa {QtMultimedia::DigitalZoomRatio}
-*/
-
-/*!
- \qmlproperty variant Video::focalLengthIn35mmFilm
-
- \sa {QtMultimedia::FocalLengthIn35mmFile}
-*/
-
-/*!
- \qmlproperty variant Video::sceneCaptureType
-
- \sa {QtMultimedia::SceneCaptureType}
-*/
-
-/*!
- \qmlproperty variant Video::gainControl
-
- \sa {QtMultimedia::GainControl}
-*/
-
-/*!
- \qmlproperty variant Video::contrast
-
- \sa {QtMultimedia::contrast}
-*/
-
-/*!
- \qmlproperty variant Video::saturation
-
- \sa {QtMultimedia::Saturation}
-*/
-
-/*!
- \qmlproperty variant Video::sharpness
-
- \sa {QtMultimedia::Sharpness}
-*/
-
-/*!
- \qmlproperty variant Video::deviceSettingDescription
-
- \sa {QtMultimedia::DeviceSettingDescription}
-*/
-
-#endif
-
-#include "moc_qmlgraphicsvideo_p.cpp"
diff --git a/src/multimedia/qml/qmlgraphicsvideo_p.h b/src/multimedia/qml/qmlgraphicsvideo_p.h
deleted file mode 100644
index 26252e0269..0000000000
--- a/src/multimedia/qml/qmlgraphicsvideo_p.h
+++ /dev/null
@@ -1,204 +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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QMLGRAPHICSVIDEO_H
-#define QMLGRAPHICSVIDEO_H
-
-//
-// 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.
-//
-
-#include <QtMultimedia/private/qmlmediabase_p.h>
-
-#include <QtMultimedia/qgraphicsvideoitem.h>
-
-#include <QtCore/qbasictimer.h>
-#include <QtDeclarative/qmlgraphicsitem.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QTimerEvent;
-class QVideoSurfaceFormat;
-
-
-class Q_AUTOTEST_EXPORT QmlGraphicsVideo : public QmlGraphicsItem, public QmlMediaBase
-{
- Q_OBJECT
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
- Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
- Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
- Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
- Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
- Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged)
- Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
- Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
- Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
- Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
- Q_PROPERTY(Error error READ error NOTIFY errorChanged)
- Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
- Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode)
- Q_ENUMS(FillMode)
- Q_ENUMS(Status)
- Q_ENUMS(Error)
-public:
- enum FillMode
- {
- Stretch = Qt::IgnoreAspectRatio,
- PreserveAspectFit = Qt::KeepAspectRatio,
- PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
- };
-
- enum Status
- {
- UnknownStatus = QMediaPlayer::UnknownMediaStatus,
- NoMedia = QMediaPlayer::NoMedia,
- Loading = QMediaPlayer::LoadingMedia,
- Loaded = QMediaPlayer::LoadedMedia,
- Stalled = QMediaPlayer::StalledMedia,
- Buffering = QMediaPlayer::BufferingMedia,
- Buffered = QMediaPlayer::BufferedMedia,
- EndOfMedia = QMediaPlayer::EndOfMedia,
- InvalidMedia = QMediaPlayer::InvalidMedia
- };
-
- enum Error
- {
- NoError = QMediaPlayer::NoError,
- ResourceError = QMediaPlayer::ResourceError,
- FormatError = QMediaPlayer::FormatError,
- NetworkError = QMediaPlayer::NetworkError,
- AccessDenied = QMediaPlayer::AccessDeniedError,
- ServiceMissing = QMediaPlayer::ServiceMissingError
- };
-
- QmlGraphicsVideo(QmlGraphicsItem *parent = 0);
- ~QmlGraphicsVideo();
-
- bool hasAudio() const;
- bool hasVideo() const;
-
- FillMode fillMode() const;
- void setFillMode(FillMode mode);
-
- Status status() const;
- Error error() const;
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
-
-public Q_SLOTS:
- void play();
- void pause();
- void stop();
-
-Q_SIGNALS:
- void sourceChanged();
-
- void playingChanged();
- void pausedChanged();
-
- void started();
- void resumed();
- void paused();
- void stopped();
-
- void statusChanged();
-
- void loaded();
- void buffering();
- void stalled();
- void buffered();
- void endOfMedia();
-
- void durationChanged();
- void positionChanged();
-
- void volumeChanged();
- void mutedChanged();
- void hasAudioChanged();
- void hasVideoChanged();
-
- void bufferProgressChanged();
-
- void seekableChanged();
- void playbackRateChanged();
-
- void errorChanged();
- void error(QmlGraphicsVideo::Error error, const QString &errorString);
-
-protected:
- void geometryChanged(const QRectF &geometry, const QRectF &);
-
-private Q_SLOTS:
- void _q_nativeSizeChanged(const QSizeF &size);
- void _q_error(int, const QString &);
-
-private:
- Q_DISABLE_COPY(QmlGraphicsVideo)
-
- QGraphicsVideoItem *m_graphicsItem;
-
- Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
- Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
- Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
-
- inline QmlMediaBase *mediaBase() { return this; }
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QmlGraphicsVideo))
-
-QT_END_HEADER
-
-#endif
diff --git a/src/multimedia/qml/qmlmediabase.cpp b/src/multimedia/qml/qmlmediabase.cpp
deleted file mode 100644
index 11b4337dad..0000000000
--- a/src/multimedia/qml/qmlmediabase.cpp
+++ /dev/null
@@ -1,413 +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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "QtMultimedia/private/qmlmediabase_p.h"
-
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qurl.h>
-
-#include <QtMultimedia/qmediaplayercontrol.h>
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/qmediaserviceprovider.h>
-#include <QtMultimedia/qmetadatacontrol.h>
-#include <QtMultimedia/private/qmetadatacontrolmetaobject_p.h>
-
-
-
-QT_BEGIN_NAMESPACE
-
-
-class QmlMediaBaseObject : public QMediaObject
-{
-public:
- QmlMediaBaseObject(QMediaService *service)
- : QMediaObject(0, service)
- {
- }
-};
-
-class QmlMediaBasePlayerControl : public QMediaPlayerControl
-{
-public:
- QmlMediaBasePlayerControl(QObject *parent)
- : QMediaPlayerControl(parent)
- {
- }
-
- QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; }
- QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; }
-
- qint64 duration() const { return 0; }
- qint64 position() const { return 0; }
- void setPosition(qint64) {}
- int volume() const { return 0; }
- void setVolume(int) {}
- bool isMuted() const { return false; }
- void setMuted(bool) {}
- int bufferStatus() const { return 0; }
- bool isAudioAvailable() const { return false; }
- bool isVideoAvailable() const { return false; }
- bool isSeekable() const { return false; }
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
- qreal playbackRate() const { return 1; }
- void setPlaybackRate(qreal) {}
- QMediaContent media() const { return QMediaContent(); }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &, QIODevice *) {}
-
- void play() {}
- void pause() {}
- void stop() {}
-};
-
-class QmlMediaBaseAnimation : public QObject
-{
-public:
- QmlMediaBaseAnimation(QmlMediaBase *media)
- : m_media(media)
- {
- }
-
- void start() { if (!m_timer.isActive()) m_timer.start(500, this); }
- void stop() { m_timer.stop(); }
-
-protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() == m_timer.timerId()) {
- event->accept();
-
- if (m_media->m_state == QMediaPlayer::PlayingState)
- emit m_media->positionChanged();
- if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia)
- emit m_media->bufferProgressChanged();
- } else {
- QObject::timerEvent(event);
- }
- }
-
-private:
- QmlMediaBase *m_media;
- QBasicTimer m_timer;
-};
-
-void QmlMediaBase::_q_stateChanged(QMediaPlayer::State state)
-{
- if (state != m_state) {
- QMediaPlayer::State oldState = m_state;
-
- m_state = state;
-
- if (state == QMediaPlayer::StoppedState) {
- emit stopped();
- emit playingChanged();
- } else if (oldState == QMediaPlayer::StoppedState) {
- emit started();
- emit playingChanged();
- } else if (oldState == QMediaPlayer::PausedState) {
- m_paused = false;
-
- emit resumed();
- emit pausedChanged();
- }
-
- if (state == m_state && state == QMediaPlayer::PausedState) {
- bool wasPaused = m_paused;
-
- m_paused = true;
-
- emit paused();
-
- if (!wasPaused)
- emit pausedChanged();
- }
-
- if (m_state == QMediaPlayer::PlayingState
- || m_status == QMediaPlayer::BufferingMedia
- || m_status == QMediaPlayer::StalledMedia) {
- m_animation->start();
- } else {
- m_animation->stop();
- }
- }
-}
-
-void QmlMediaBase::_q_mediaStatusChanged(QMediaPlayer::MediaStatus status)
-{
- if (status != m_status) {
- m_status = status;
-
- switch (status) {
- case QMediaPlayer::LoadedMedia:
- emit loaded();
- break;
- case QMediaPlayer::BufferingMedia:
- emit buffering();
- break;
- case QMediaPlayer::BufferedMedia:
- emit buffered();
- break;
- case QMediaPlayer::StalledMedia:
- emit stalled();
- break;
- case QMediaPlayer::EndOfMedia:
- emit endOfMedia();
- break;
- default:
- break;
- }
-
- emit statusChanged();
-
- if (m_state == QMediaPlayer::PlayingState
- || m_status == QMediaPlayer::BufferingMedia
- || m_status == QMediaPlayer::StalledMedia) {
- m_animation->start();
- } else {
- m_animation->stop();
- }
- }
-}
-
-void QmlMediaBase::_q_metaDataChanged()
-{
- m_metaObject->metaDataChanged();
-}
-
-QmlMediaBase::QmlMediaBase()
- : m_mediaService(0)
- , m_playerControl(0)
- , m_mediaObject(0)
- , m_mediaProvider(0)
- , m_metaDataControl(0)
- , m_metaObject(0)
- , m_animation(0)
- , m_state(QMediaPlayer::StoppedState)
- , m_status(QMediaPlayer::NoMedia)
- , m_error(QMediaPlayer::NoError)
- , m_paused(false)
-{
-}
-
-QmlMediaBase::~QmlMediaBase()
-{
-}
-
-void QmlMediaBase::shutdown()
-{
- delete m_metaObject;
- delete m_mediaObject;
-
- if (m_mediaProvider)
- m_mediaProvider->releaseService(m_mediaService);
-
- delete m_animation;
-
-}
-
-void QmlMediaBase::setObject(QObject *object)
-{
- if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider())) {
- if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER))) {
- m_playerControl = qobject_cast<QMediaPlayerControl *>(
- m_mediaService->control(QMediaPlayerControl_iid));
- m_metaDataControl = qobject_cast<QMetaDataControl *>(
- m_mediaService->control(QMetaDataControl_iid));
- m_mediaObject = new QmlMediaBaseObject(m_mediaService);
- }
- }
-
- if (m_playerControl) {
- QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
- object, SLOT(_q_stateChanged(QMediaPlayer::State)));
- QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
- object, SLOT(_q_mediaStatusChanged(QMediaPlayer::MediaStatus)));
- QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)),
- object, SIGNAL(sourceChanged()));
- QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)),
- object, SIGNAL(durationChanged()));
- QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)),
- object, SIGNAL(positionChanged()));
- QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)),
- object, SIGNAL(volumeChanged()));
- QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)),
- object, SIGNAL(mutedChanged()));
- QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)),
- object, SIGNAL(bufferProgressChanged()));
- QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)),
- object, SIGNAL(seekableChanged()));
- QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)),
- object, SIGNAL(playbackRateChanged()));
- QObject::connect(m_playerControl, SIGNAL(error(int,QString)),
- object, SLOT(_q_error(int,QString)));
-
- m_animation = new QmlMediaBaseAnimation(this);
- } else {
- m_error = QMediaPlayer::ServiceMissingError;
-
- m_playerControl = new QmlMediaBasePlayerControl(object);
- }
-
- if (m_metaDataControl) {
- m_metaObject = new QMetaDataControlMetaObject(m_metaDataControl, object);
-
- QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
- object, SLOT(_q_metaDataChanged()));
- }
-}
-
-QUrl QmlMediaBase::source() const
-{
- return m_playerControl->media().canonicalUrl();
-}
-
-void QmlMediaBase::setSource(const QUrl &url)
-{
- if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
- m_error = QMediaPlayer::NoError;
- m_errorString = QString();
-
- emit errorChanged();
- }
-
- m_playerControl->setMedia(QMediaContent(url), 0);
-}
-
-bool QmlMediaBase::isPlaying() const
-{
- return m_state != QMediaPlayer::StoppedState;
-}
-
-void QmlMediaBase::setPlaying(bool playing)
-{
- if (playing && m_state == QMediaPlayer::StoppedState) {
- if (m_paused)
- m_playerControl->pause();
- else
- m_playerControl->play();
- } else if (!playing) {
- m_playerControl->stop();
- }
-}
-
-bool QmlMediaBase::isPaused() const
-{
- return m_paused;
-}
-
-void QmlMediaBase::setPaused(bool paused)
-{
- if (m_paused != paused) {
- if (paused && m_state == QMediaPlayer::PlayingState) {
- m_playerControl->pause();
- } else if (!paused && m_state == QMediaPlayer::PausedState) {
- m_playerControl->play();
- } else {
- m_paused = paused;
-
- emit pausedChanged();
- }
- }
-}
-
-int QmlMediaBase::duration() const
-{
- return m_playerControl->duration();
-}
-
-int QmlMediaBase::position() const
-{
- return m_playerControl->position();
-
-}
-
-void QmlMediaBase::setPosition(int position)
-{
- m_playerControl->setPosition(position);
-}
-
-qreal QmlMediaBase::volume() const
-{
- return qreal(m_playerControl->volume()) / 100;
-}
-
-void QmlMediaBase::setVolume(qreal volume)
-{
- m_playerControl->setVolume(qRound(volume * 100));
-}
-
-bool QmlMediaBase::isMuted() const
-{
- return m_playerControl->isMuted();
-}
-
-void QmlMediaBase::setMuted(bool muted)
-{
- m_playerControl->setMuted(muted);
-}
-
-qreal QmlMediaBase::bufferProgress() const
-{
- return qreal(m_playerControl->bufferStatus()) / 100;
-}
-
-bool QmlMediaBase::isSeekable() const
-{
- return m_playerControl->isSeekable();
-}
-
-qreal QmlMediaBase::playbackRate() const
-{
- return m_playerControl->playbackRate();
-}
-
-void QmlMediaBase::setPlaybackRate(qreal rate)
-{
- m_playerControl->setPlaybackRate(rate);
-}
-
-QString QmlMediaBase::errorString() const
-{
- return m_errorString;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/multimedia/qml/qmlmediabase_p.h b/src/multimedia/qml/qmlmediabase_p.h
deleted file mode 100644
index d6ad9b3fd2..0000000000
--- a/src/multimedia/qml/qmlmediabase_p.h
+++ /dev/null
@@ -1,168 +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 QtMultimedia module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QMLMEDIABASE_P_H
-#define QMLMEDIABASE_P_H
-
-//
-// 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.
-//
-
-#include <QtCore/qbasictimer.h>
-#include <QtMultimedia/qmediaplayer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QMediaPlayerControl;
-class QMediaService;
-class QMediaServiceProvider;
-class QMetaDataControl;
-class QMetaDataControlMetaObject;
-class QmlMediaBaseAnimation;
-
-class Q_AUTOTEST_EXPORT QmlMediaBase
-{
-public:
- QmlMediaBase();
- virtual ~QmlMediaBase();
-
- QUrl source() const;
- void setSource(const QUrl &url);
-
- bool isPlaying() const;
- void setPlaying(bool playing);
-
- bool isPaused() const;
- void setPaused(bool paused);
-
- int duration() const;
-
- int position() const;
- void setPosition(int position);
-
- qreal volume() const;
- void setVolume(qreal volume);
-
- bool isMuted() const;
- void setMuted(bool muted);
-
- qreal bufferProgress() const;
-
- bool isSeekable() const;
-
- qreal playbackRate() const;
- void setPlaybackRate(qreal rate);
-
- QString errorString() const;
-
- void _q_stateChanged(QMediaPlayer::State state);
- void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status);
-
- void _q_metaDataChanged();
-
-protected:
- void shutdown();
-
- void setObject(QObject *object);
-
- virtual void sourceChanged() = 0;
-
- virtual void playingChanged() = 0;
- virtual void pausedChanged() = 0;
-
- virtual void started() = 0;
- virtual void resumed() = 0;
- virtual void paused() = 0;
- virtual void stopped() = 0;
-
- virtual void statusChanged() = 0;
-
- virtual void loaded() = 0;
- virtual void buffering() = 0;
- virtual void stalled() = 0;
- virtual void buffered() = 0;
- virtual void endOfMedia() = 0;
-
- virtual void durationChanged() = 0;
- virtual void positionChanged() = 0;
-
- virtual void volumeChanged() = 0;
- virtual void mutedChanged() = 0;
-
- virtual void bufferProgressChanged() = 0;
-
- virtual void seekableChanged() = 0;
- virtual void playbackRateChanged() = 0;
-
- virtual void errorChanged() = 0;
-
- QMediaService *m_mediaService;
- QMediaPlayerControl *m_playerControl;
-
- QMediaObject *m_mediaObject;
- QMediaServiceProvider *m_mediaProvider;
- QMetaDataControl *m_metaDataControl;
- QMetaDataControlMetaObject *m_metaObject;
- QmlMediaBaseAnimation *m_animation;
-
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_status;
- QMediaPlayer::Error m_error;
- bool m_paused;
- QString m_errorString;
-
- friend class QmlMediaBaseAnimation;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/multimedia/qml/qsoundeffect_p.h b/src/multimedia/qml/qsoundeffect_p.h
index 4b440ec24f..51ebe52abb 100644
--- a/src/multimedia/qml/qsoundeffect_p.h
+++ b/src/multimedia/qml/qsoundeffect_p.h
@@ -56,7 +56,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
-#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qdeclarative.h>
QT_BEGIN_HEADER
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 62aa2d76b8..a887449b77 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -416,13 +416,25 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
lowPriorityQueue.prepend(pair);
break;
}
+
// this used to be called via invokeMethod and a QueuedConnection
+ // It is the only place _q_startNextRequest is called directly without going
+ // through the event loop using a QueuedConnection.
+ // This is dangerous because of recursion that might occur when emitting
+ // signals as DirectConnection from this code path. Therefore all signal
+ // emissions that can come out from this code path need to
+ // be QueuedConnection.
+ // We are currently trying to fine-tune this.
_q_startNextRequest();
+
+
return reply;
}
void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair)
{
+ Q_Q(QHttpNetworkConnection);
+
QHttpNetworkRequest request = pair.first;
switch (request.priority()) {
case QHttpNetworkRequest::HighPriority:
@@ -433,8 +445,8 @@ void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair)
lowPriorityQueue.prepend(pair);
break;
}
- // this used to be called via invokeMethod and a QueuedConnection
- _q_startNextRequest();
+
+ QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
}
void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socket)
@@ -682,6 +694,8 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply)
+// This function must be called from the event loop. The only
+// exception is documented in QHttpNetworkConnectionPrivate::queueRequest
void QHttpNetworkConnectionPrivate::_q_startNextRequest()
{
//resend the necessary ones.
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index dbee72ad9c..e92b2f30ee 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -459,6 +459,8 @@ void QHttpNetworkConnectionChannel::handleUnexpectedEOF()
} else {
reconnectAttempts--;
reply->d_func()->clear();
+ reply->d_func()->connection = connection;
+ reply->d_func()->connectionChannel = this;
closeAndResendCurrentRequest();
}
}
diff --git a/src/network/access/qnetworkaccessdatabackend.cpp b/src/network/access/qnetworkaccessdatabackend.cpp
index a2e7ef5654..efb6e3ef26 100644
--- a/src/network/access/qnetworkaccessdatabackend.cpp
+++ b/src/network/access/qnetworkaccessdatabackend.cpp
@@ -44,6 +44,7 @@
#include "qnetworkreply.h"
#include "qurlinfo.h"
#include "private/qdataurl_p.h"
+#include <qcoreapplication.h>
QT_BEGIN_NAMESPACE
@@ -72,7 +73,8 @@ void QNetworkAccessDataBackend::open()
if (operation() != QNetworkAccessManager::GetOperation &&
operation() != QNetworkAccessManager::HeadOperation) {
// data: doesn't support anything but GET
- QString msg = QObject::tr("Operation not supported on %1")
+ const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
+ "Operation not supported on %1")
.arg(uri.toString());
error(QNetworkReply::ContentOperationNotPermittedError, msg);
finished();
@@ -96,7 +98,8 @@ void QNetworkAccessDataBackend::open()
}
// something wrong with this URI
- QString msg = QObject::tr("Invalid URI: %1").arg(uri.toString());
+ const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
+ "Invalid URI: %1").arg(uri.toString());
error(QNetworkReply::ProtocolFailure, msg);
finished();
}
diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp
index 5926d0b5d6..cd077e7056 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend.cpp
+++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp
@@ -252,7 +252,7 @@ void QNetworkAccessDebugPipeBackend::socketError()
break;
}
- error(code, QObject::tr("Socket error on %1: %2")
+ error(code, QNetworkAccessDebugPipeBackend::tr("Socket error on %1: %2")
.arg(url().toString(), socket.errorString()));
finished();
disconnect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
@@ -267,7 +267,7 @@ void QNetworkAccessDebugPipeBackend::socketDisconnected()
// normal close
} else {
// abnormal close
- QString msg = QObject::tr("Remote host closed the connection prematurely on %1")
+ QString msg = QNetworkAccessDebugPipeBackend::tr("Remote host closed the connection prematurely on %1")
.arg(url().toString());
error(QNetworkReply::RemoteHostClosedError, msg);
finished();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index b9bd52ae31..5876ee249a 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -110,7 +110,8 @@ static void ensureInitialized()
object, which holds the common configuration and settings for the requests
it sends. It contains the proxy and cache configuration, as well as the
signals related to such issues, and reply signals that can be used to
- monitor the progress of a network operation.
+ monitor the progress of a network operation. One QNetworkAccessManager
+ should be enough for the whole Qt application.
Once a QNetworkAccessManager object has been created, the application can
use it to send requests over the network. A group of standard functions
@@ -121,6 +122,7 @@ static void ensureInitialized()
A simple download off the network could be accomplished with:
\snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 0
+ QNetworkAccessManager has an asynchronous API.
When the \tt replyFinished slot above is called, the parameter it
takes is the QNetworkReply object containing the downloaded data
as well as meta-data (headers, etc.).
@@ -130,6 +132,11 @@ static void ensureInitialized()
delete it inside the slot connected to finished(). You can use the
deleteLater() function.
+ \note QNetworkAccessManager queues the requests it receives. The number
+ of requests executed in parallel is dependent on the protocol.
+ Currently, for the HTTP protocol on desktop platforms, 6 requests are
+ executed in parallel for one host/port combination.
+
A more involved example, assuming the manager is already existent,
can be:
\snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 1
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 2175686a96..b201380d53 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -565,7 +565,7 @@ void QNetworkReplyImplPrivate::finished()
}
} else {
error(QNetworkReply::TemporaryNetworkFailureError,
- q->tr("Temporary network failure."));
+ QNetworkReply::tr("Temporary network failure."));
}
}
}
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index e563f4ebad..61c116def2 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -138,6 +138,8 @@ QT_BEGIN_NAMESPACE
default follow redirections: it's up to the application to
determine if the requested redirection should be allowed,
according to its security policies.
+ The returned URL might be relative. Use QUrl::resolved()
+ to create an absolute URL out of it.
\value ConnectionEncryptedAttribute
Replies only, type: QVariant::Bool (default: false)
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 9de499e5a4..93f6d13954 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -165,7 +165,7 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
if (name.isEmpty()) {
QHostInfo hostInfo(id);
hostInfo.setError(QHostInfo::HostNotFound);
- hostInfo.setErrorString(QObject::tr("No host name given"));
+ hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given"));
QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
receiver, member, Qt::QueuedConnection);
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index be06b6eb7f..a186e78a19 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -193,7 +193,9 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
results.setHostName(hostName);
if (aceHostname.isEmpty()) {
results.setError(QHostInfo::HostNotFound);
- results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname"));
+ results.setErrorString(hostName.isEmpty() ?
+ QCoreApplication::translate("QHostInfoAgent", "No host name given") :
+ QCoreApplication::translate("QHostInfoAgent", "Invalid hostname"));
return results;
}
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 829df89dd8..275c4366ed 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -155,6 +155,9 @@
See the \l network/fortuneclient and \l network/blockingfortuneclient
examples for an overview of both approaches.
+ \note We discourage the use of the blocking functions together
+ with signals. One of the two possibilities should be used.
+
QAbstractSocket can be used with QTextStream and QDataStream's
stream operators (operator<<() and operator>>()). There is one
issue to be aware of, though: You must make sure that enough data
@@ -1682,9 +1685,12 @@ static int qt_timeout_value(int msecs, int elapsed)
If msecs is -1, this function will not time out.
- Note: This function may wait slightly longer than \a msecs,
+ \note This function may wait slightly longer than \a msecs,
depending on the time it takes to complete the host lookup.
+ \note Multiple calls to this functions do not accumulate the time.
+ If the function times out, the connecting process will be aborted.
+
\sa connectToHost(), connected()
*/
bool QAbstractSocket::waitForConnected(int msecs)
@@ -1722,7 +1728,7 @@ bool QAbstractSocket::waitForConnected(int msecs)
d->_q_startConnecting(QHostInfo::fromName(d->hostName));
}
if (state() == UnconnectedState)
- return false;
+ return false; // connect not im progress anymore!
bool timedOut = true;
#if defined (QABSTRACTSOCKET_DEBUG)
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 2ed185ffcd..73cd6a86fe 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -5559,7 +5559,7 @@ QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len)
quint32 level = 0;
quint32 width = pvrHeader->width;
quint32 height = pvrHeader->height;
- while (bufferSize > 0 && level < pvrHeader->mipMapCount) {
+ while (bufferSize > 0 && level <= pvrHeader->mipMapCount) {
quint32 size =
(qMax(width, minWidth) * qMax(height, minHeight) *
pvrHeader->bitsPerPixel) / 8;
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index bc9f0c971e..35f552eae4 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -130,8 +130,9 @@ public:
void draw(VGPath path, const QPen& pen, const QBrush& brush, VGint rule = VG_EVEN_ODD);
void stroke(VGPath path, const QPen& pen);
void fill(VGPath path, const QBrush& brush, VGint rule = VG_EVEN_ODD);
- VGPath vectorPathToVGPath(const QVectorPath& path);
- VGPath painterPathToVGPath(const QPainterPath& path);
+ inline void releasePath(VGPath path);
+ VGPath vectorPathToVGPath(const QVectorPath& path, bool forceNewPath = false);
+ VGPath painterPathToVGPath(const QPainterPath& path, bool forceNewPath = false);
VGPath roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode);
VGPaintType setBrush
(VGPaint paint, const QBrush& brush, VGMatrixMode mode,
@@ -177,6 +178,8 @@ public:
VGPath roundRectPath; // Cached path for quick drawing of rounded rects.
#endif
+ VGPath reusablePath; // Reusable path for vectorPathToVGPath(), etc.
+
QTransform transform; // Currently active transform.
bool simpleTransform; // True if the transform is simple (non-projective).
qreal penScale; // Pen scaling factor from "transform".
@@ -349,6 +352,8 @@ void QVGPaintEnginePrivate::init()
roundRectPath = 0;
#endif
+ reusablePath = 0;
+
simpleTransform = true;
pathTransformSet = false;
penScale = 1.0;
@@ -445,6 +450,15 @@ void QVGPaintEnginePrivate::initObjects()
VG_PATH_CAPABILITY_ALL);
vgAppendPathData(linePath, 2, segments, coords);
#endif
+
+ // This path can be reused over and over by calling vgClearPath().
+ reusablePath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ 32 + 1, // segmentCapacityHint
+ 32 * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
}
void QVGPaintEnginePrivate::destroy()
@@ -464,6 +478,8 @@ void QVGPaintEnginePrivate::destroy()
if (roundRectPath)
vgDestroyPath(roundRectPath);
#endif
+ if (reusablePath)
+ vgDestroyPath(reusablePath);
#if !defined(QVG_NO_DRAW_GLYPHS)
QVGFontCache::Iterator it;
@@ -540,19 +556,32 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev)
qt_scaleForTransform(transform, &penScale);
}
-VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
+inline void QVGPaintEnginePrivate::releasePath(VGPath path)
+{
+ if (path == reusablePath)
+ vgClearPath(path, VG_PATH_CAPABILITY_ALL);
+ else
+ vgDestroyPath(path);
+}
+
+VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path, bool forceNewPath)
{
int count = path.elementCount();
const qreal *points = path.points();
const QPainterPath::ElementType *elements = path.elements();
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath;
+ if (forceNewPath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ } else {
+ vgpath = reusablePath;
+ }
// Size is sufficient segments for drawRoundedRect() paths.
QVarLengthArray<VGubyte, 20> segments;
@@ -724,17 +753,22 @@ VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
return vgpath;
}
-VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path)
+VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path, bool forceNewPath)
{
int count = path.elementCount();
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath;
+ if (forceNewPath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ } else {
+ vgpath = reusablePath;
+ }
if (count == 0)
return vgpath;
@@ -953,13 +987,7 @@ VGPath QVGPaintEnginePrivate::roundedRectPath(const QRectF &rect, qreal xRadius,
vgModifyPathCoords(vgpath, 0, 9, pts);
}
#else
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 10, // segmentCapacityHint
- 17 * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath = reusablePath;
vgAppendPathData(vgpath, 10, roundedrect_types, pts);
#endif
@@ -1512,7 +1540,7 @@ void QVGPaintEngine::draw(const QVectorPath &path)
d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
else
d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
@@ -1523,7 +1551,7 @@ void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
d->fill(vgpath, brush, VG_EVEN_ODD);
else
d->fill(vgpath, brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
@@ -1531,7 +1559,7 @@ void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
Q_D(QVGPaintEngine);
VGPath vgpath = d->vectorPathToVGPath(path);
d->stroke(vgpath, pen);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
// Determine if a co-ordinate transform is simple enough to allow
@@ -1727,7 +1755,7 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
default: break;
}
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
vgSeti(VG_MASKING, VG_TRUE);
d->maskValid = true;
@@ -2044,7 +2072,7 @@ void QVGPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op)
default: break;
}
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
vgSeti(VG_MASKING, VG_TRUE);
d->maskValid = true;
@@ -2395,7 +2423,7 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
return;
// Check to see if we can use vgClear() for faster filling.
- if (brush.style() == Qt::SolidPattern &&
+ if (brush.style() == Qt::SolidPattern && brush.isOpaque() &&
clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
clearRect(rect, brush.color())) {
return;
@@ -2438,7 +2466,7 @@ void QVGPaintEngine::fillRect(const QRectF &rect, const QColor &color)
Q_D(QVGPaintEngine);
// Check to see if we can use vgClear() for faster filling.
- if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
+ if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && color.alpha() == 255 &&
clearRect(rect, color)) {
return;
}
@@ -2483,7 +2511,7 @@ void QVGPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad,
VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
d->draw(vgpath, s->pen, s->brush);
#if defined(QVG_NO_MODIFY_PATH)
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
#endif
} else {
QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
@@ -2632,13 +2660,7 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
Q_D(QVGPaintEngine);
if (d->simpleTransform) {
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 4, // segmentCapacityHint
- 12, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
static VGubyte segments[4] = {
VG_MOVE_TO_ABS,
VG_SCCWARC_TO_REL,
@@ -2662,7 +2684,7 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
coords[11] = 0.0f;
vgAppendPathData(path, 4, segments, coords);
d->draw(path, s->pen, s->brush);
- vgDestroyPath(path);
+ d->releasePath(path);
} else {
// The projective transform version of an ellipse is difficult.
// Generate a QVectorPath containing cubic curves and transform that.
@@ -2686,7 +2708,7 @@ void QVGPaintEngine::drawPath(const QPainterPath &path)
d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
else
d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::drawPoints(const QPointF *points, int pointCount)
@@ -2761,13 +2783,7 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
{
Q_D(QVGPaintEngine);
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
QVarLengthArray<VGfloat, 16> coords;
QVarLengthArray<VGubyte, 10> segments;
for (int i = 0; i < pointCount; ++i, ++points) {
@@ -2801,20 +2817,14 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
break;
}
- vgDestroyPath(path);
+ d->releasePath(path);
}
void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
{
Q_D(QVGPaintEngine);
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
QVarLengthArray<VGfloat, 16> coords;
QVarLengthArray<VGubyte, 10> segments;
for (int i = 0; i < pointCount; ++i, ++points) {
@@ -2848,7 +2858,7 @@ void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDr
d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
break;
}
- vgDestroyPath(path);
+ d->releasePath(path);
}
void QVGPaintEnginePrivate::setImageOptions()
@@ -3245,7 +3255,7 @@ void QVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
fontEngine->getUnscaledGlyph(glyph, &path, &metrics);
VGPath vgPath;
if (!path.isEmpty()) {
- vgPath = d->painterPathToVGPath(path);
+ vgPath = d->painterPathToVGPath(path, true);
} else {
// Probably a "space" character with no visible outline.
vgPath = VG_INVALID_HANDLE;
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index e96b80c41d..e6c871d22f 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -63,6 +63,7 @@
#include <unistd.h>
#endif
+QT_BEGIN_NAMESPACE
static QString qGetInterfaceType(const QString &interface)
{
@@ -126,14 +127,11 @@ static QString qGetInterfaceType(const QString &interface)
ifreq request;
strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
- if (ioctl(sock, SIOCGIFHWADDR, &request) >= 0) {
- switch (request.ifr_hwaddr.sa_family) {
- case ARPHRD_ETHER:
- return QLatin1String("Ethernet");
- }
- }
-
+ int result = ioctl(sock, SIOCGIFHWADDR, &request);
close(sock);
+
+ if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
+ return QLatin1String("Ethernet");
#else
Q_UNUSED(interface);
#endif
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp
index a9e93e06a4..e7c56a2416 100644
--- a/src/plugins/bearer/icd/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp
@@ -1080,14 +1080,14 @@ QString QNetworkSessionPrivateImpl::errorString() const
QString errorStr;
switch(q->error()) {
case QNetworkSession::RoamingError:
- errorStr = QObject::tr("Roaming error");
+ errorStr = QNetworkSessionPrivateImpl::tr("Roaming error");
break;
case QNetworkSession::SessionAbortedError:
- errorStr = QObject::tr("Session aborted by user or system");
+ errorStr = QNetworkSessionPrivateImpl::tr("Session aborted by user or system");
break;
default:
case QNetworkSession::UnknownSessionError:
- errorStr = QObject::tr("Unidentified Error");
+ errorStr = QNetworkSessionPrivateImpl::tr("Unidentified Error");
break;
}
return errorStr;
diff --git a/src/plugins/bearer/symbian/symbian.pro b/src/plugins/bearer/symbian/symbian.pro
index 9fd1a74125..9613defd11 100644
--- a/src/plugins/bearer/symbian/symbian.pro
+++ b/src/plugins/bearer/symbian/symbian.pro
@@ -21,6 +21,7 @@ exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) {
}
INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+symbian-abld:INCLUDEPATH += $$QT_BUILD_TREE/include/QtNetwork/private
LIBS += -lcommdb \
-lapsettingshandlerui \
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index cd4d5c29ff..cffd4e346f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -1126,6 +1126,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) {
d_ptr->directFBFlags |= BoundingRectFlip;
+ } else if (displayArgs.contains(QLatin1String("nopartialflip"), Qt::CaseInsensitive)) {
+ d_ptr->directFBFlags |= NoPartialFlip;
}
#ifdef QT_DIRECTFB_IMAGECACHE
@@ -1139,6 +1141,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
#endif
d_ptr->dfb->SetCooperativeLevel(d_ptr->dfb, DFSCL_FULLSCREEN);
+ const bool forcePremultiplied = displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive);
+
DFBSurfaceDescription description;
memset(&description, 0, sizeof(DFBSurfaceDescription));
IDirectFBSurface *surface;
@@ -1167,7 +1171,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
description.caps |= capabilities[i].cap;
}
- if (displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive)) {
+ if (forcePremultiplied) {
description.caps |= DSCAPS_PREMULTIPLIED;
}
@@ -1217,6 +1221,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied;
break;
case QImage::Format_ARGB32:
+ if (forcePremultiplied)
+ d_ptr->alphaPixmapFormat = pixelFormat = QImage::Format_ARGB32_Premultiplied;
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_ARGB4444_Premultiplied:
case QImage::Format_ARGB8555_Premultiplied:
@@ -1674,7 +1680,7 @@ bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *d
uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl)
{
- void *mem;
+ void *mem = 0;
const DFBResult result = surface->Lock(surface, flags, &mem, bpl);
if (result != DFB_OK) {
DirectFBError("QDirectFBScreen::lockSurface()", result);
@@ -1683,11 +1689,22 @@ uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFla
return reinterpret_cast<uchar*>(mem);
}
+static inline bool isFullUpdate(IDirectFBSurface *surface, const QRegion &region, const QPoint &offset)
+{
+ if (offset == QPoint(0, 0) && region.rectCount() == 1) {
+ QSize size;
+ surface->GetSize(surface, &size.rwidth(), &size.rheight());
+ if (region.boundingRect().size() == size)
+ return true;
+ }
+ return false;
+}
void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags,
const QRegion &region, const QPoint &offset)
{
- if (!(flipFlags & DSFLIP_BLIT)) {
+ if (d_ptr->directFBFlags & NoPartialFlip
+ || (!(flipFlags & DSFLIP_BLIT) && QT_PREPEND_NAMESPACE(isFullUpdate(surface, region, offset)))) {
surface->Flip(surface, 0, flipFlags);
} else {
if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.rectCount() > 1) {
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index a8c4b4362a..c483020e40 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -144,7 +144,8 @@ public:
NoFlags = 0x00,
VideoOnly = 0x01,
SystemOnly = 0x02,
- BoundingRectFlip = 0x04
+ BoundingRectFlip = 0x04,
+ NoPartialFlip = 0x08
};
Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index 6764e75f4c..a8bdb65700 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -92,10 +92,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
mode = Offscreen;
flags = Buffered;
}
-#else
- noSystemBackground = widget && widget->testAttribute(Qt::WA_NoSystemBackground);
- if (noSystemBackground)
- flags &= ~Opaque;
#endif
setSurfaceFlags(flags);
#ifdef QT_DIRECTFB_TIMING
@@ -134,33 +130,35 @@ void QDirectFBWindowSurface::createWindow(const QRect &rect)
if (!layer)
qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");
+ updateIsOpaque();
+
DFBWindowDescription description;
memset(&description, 0, sizeof(DFBWindowDescription));
+ description.flags = DWDESC_CAPS|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT;
description.caps = DWCAPS_NODECORATION;
- description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY;
-#if (Q_DIRECTFB_VERSION >= 0x010200)
- description.flags |= DWDESC_OPTIONS;
-#endif
+ description.surface_caps = DSCAPS_NONE;
+ imageFormat = screen->pixelFormat();
- if (noSystemBackground) {
+ if (!(surfaceFlags() & Opaque)) {
+ imageFormat = screen->alphaPixmapFormat();
description.caps |= DWCAPS_ALPHACHANNEL;
#if (Q_DIRECTFB_VERSION >= 0x010200)
+ description.flags |= DWDESC_OPTIONS;
description.options |= DWOP_ALPHACHANNEL;
#endif
}
-
+ description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(imageFormat);
description.posx = rect.x();
description.posy = rect.y();
description.width = rect.width();
description.height = rect.height();
- description.surface_caps = DSCAPS_NONE;
+
+ if (QDirectFBScreen::isPremultiplied(imageFormat))
+ description.surface_caps = DSCAPS_PREMULTIPLIED;
+
if (screen->directFBFlags() & QDirectFBScreen::VideoOnly)
description.surface_caps |= DSCAPS_VIDEOONLY;
- const QImage::Format format = (noSystemBackground ? screen->alphaPixmapFormat() : screen->pixelFormat());
- description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
- if (QDirectFBScreen::isPremultiplied(format))
- description.surface_caps = DSCAPS_PREMULTIPLIED;
DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow);
@@ -182,7 +180,6 @@ void QDirectFBWindowSurface::createWindow(const QRect &rect)
Q_ASSERT(!dfbSurface);
dfbWindow->GetSurface(dfbWindow, &dfbSurface);
- updateFormat();
}
static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect)
@@ -267,15 +264,17 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
}
} else { // mode == Offscreen
if (!dfbSurface) {
- dfbSurface = screen->createDFBSurface(rect.size(), screen->pixelFormat(), QDirectFBScreen::DontTrackSurface);
+ dfbSurface = screen->createDFBSurface(rect.size(), surfaceFlags() & Opaque ? screen->pixelFormat() : screen->alphaPixmapFormat(),
+ QDirectFBScreen::DontTrackSurface);
}
}
if (result != DFB_OK)
DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result);
#endif
}
- if (oldSurface != dfbSurface)
- updateFormat();
+ if (oldSurface != dfbSurface) {
+ imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;
+ }
if (oldRect.size() != rect.size()) {
QWSWindowSurface::setGeometry(rect);
@@ -296,7 +295,7 @@ void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
if (state.size() == sizeof(this)) {
sibling = *reinterpret_cast<QDirectFBWindowSurface *const*>(state.constData());
Q_ASSERT(sibling);
- sibling->setSurfaceFlags(surfaceFlags());
+ setSurfaceFlags(sibling->surfaceFlags());
}
}
@@ -359,8 +358,6 @@ void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion &region,
const quint8 windowOpacity = quint8(win->windowOpacity() * 0xff);
const QRect windowGeometry = geometry();
#ifdef QT_DIRECTFB_WM
- const bool wasNoSystemBackground = noSystemBackground;
- noSystemBackground = win->testAttribute(Qt::WA_NoSystemBackground);
quint8 currentOpacity;
Q_ASSERT(dfbWindow);
dfbWindow->GetOpacity(dfbWindow, &currentOpacity);
@@ -368,18 +365,9 @@ void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion &region,
dfbWindow->SetOpacity(dfbWindow, windowOpacity);
}
- setOpaque(noSystemBackground || windowOpacity != 0xff);
- if (wasNoSystemBackground != noSystemBackground) {
- releaseSurface();
- dfbWindow->Release(dfbWindow);
- dfbWindow = 0;
- createWindow(windowGeometry);
- win->update();
- return;
- }
screen->flipSurface(dfbSurface, flipFlags, region, offset);
#else
- setOpaque(windowOpacity != 0xff);
+ setOpaque(windowOpacity == 0xff);
if (mode == Offscreen) {
screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0);
} else {
@@ -442,11 +430,6 @@ IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget
return dfbSurface;
}
-void QDirectFBWindowSurface::updateFormat()
-{
- imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;
-}
-
void QDirectFBWindowSurface::releaseSurface()
{
if (dfbSurface) {
@@ -465,9 +448,37 @@ void QDirectFBWindowSurface::releaseSurface()
}
}
+void QDirectFBWindowSurface::updateIsOpaque()
+{
+ const QWidget *win = window();
+ Q_ASSERT(win);
+ if (win->testAttribute(Qt::WA_OpaquePaintEvent) || win->testAttribute(Qt::WA_PaintOnScreen)) {
+ setOpaque(true);
+ return;
+ }
-QT_END_NAMESPACE
+ if (qFuzzyCompare(static_cast<float>(win->windowOpacity()), 1.0f)) {
+ const QPalette &pal = win->palette();
-#endif // QT_NO_QWS_DIRECTFB
+ if (win->autoFillBackground()) {
+ const QBrush &autoFillBrush = pal.brush(win->backgroundRole());
+ if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
+ setOpaque(true);
+ return;
+ }
+ }
+
+ if (win->isWindow() && !win->testAttribute(Qt::WA_NoSystemBackground)) {
+ const QBrush &windowBrush = win->palette().brush(QPalette::Window);
+ if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
+ setOpaque(true);
+ return;
+ }
+ }
+ }
+ setOpaque(false);
+}
+QT_END_NAMESPACE
+#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
index 956806782f..a6138f6267 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
@@ -97,8 +97,8 @@ public:
IDirectFBWindow *directFBWindow() const;
#endif
private:
+ void updateIsOpaque();
void setOpaque(bool opaque);
- void updateFormat();
void releaseSurface();
QDirectFBWindowSurface *sibling;
@@ -113,7 +113,6 @@ private:
#endif
DFBSurfaceFlipFlags flipFlags;
- bool noSystemBackground;
bool boundingRectFlip;
#ifdef QT_DIRECTFB_TIMING
int frames;
diff --git a/src/plugins/imageformats/tiff/tiff.pro b/src/plugins/imageformats/tiff/tiff.pro
index 312f99c4cc..514fd6966d 100644
--- a/src/plugins/imageformats/tiff/tiff.pro
+++ b/src/plugins/imageformats/tiff/tiff.pro
@@ -47,14 +47,15 @@ contains(QT_CONFIG, system-tiff) {
../../../3rdparty/libtiff/libtiff/tif_warning.c \
../../../3rdparty/libtiff/libtiff/tif_write.c \
../../../3rdparty/libtiff/libtiff/tif_zip.c
- win32 {
+ win32:!wince*: {
SOURCES += ../../../3rdparty/libtiff/libtiff/tif_win32.c
}
unix: {
SOURCES += ../../../3rdparty/libtiff/libtiff/tif_unix.c
}
wince*: {
- SOURCES += ../../../corelib/kernel/qfunctions_wince.cpp
+ SOURCES += ../../../corelib/kernel/qfunctions_wince.cpp \
+ ../../../3rdparty/libtiff/libtiff/tif_wince.c
}
symbian*: {
SOURCES += ../../../3rdparty/libtiff/port/lfind.c
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 73686bc623..418fd81b13 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -12,6 +12,6 @@ embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers
symbian:SUBDIRS += s60
contains(QT_CONFIG, phonon): SUBDIRS *= phonon
contains(QT_CONFIG, multimedia): SUBDIRS *= audio mediaservices
-contains(QT_CONFIG, declarative): SUBDIRS *= qmlmodules
+contains(QT_CONFIG, declarative): SUBDIRS *= qdeclarativemodules
diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp b/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp
new file mode 100644
index 0000000000..8becbf3bc0
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtMultimedia/multimediadeclarative.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMultimediaQmlModule : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ QtMultimedia::qRegisterDeclarativeElements(uri);
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "multimedia.moc"
+
+Q_EXPORT_PLUGIN2(qmultimediaqmlmodule, QT_PREPEND_NAMESPACE(QMultimediaQmlModule));
+
diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro b/src/plugins/qdeclarativemodules/multimedia/multimedia.pro
new file mode 100644
index 0000000000..d8ad18eeea
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/multimedia/multimedia.pro
@@ -0,0 +1,15 @@
+TARGET = multimedia
+include(../../qpluginbase.pri)
+
+QT += multimedia declarative
+
+SOURCES += multimedia.cpp
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/multimedia
+target.path = $$[QT_INSTALL_IMPORTS]/Qt/multimedia
+
+qmldir.files += $$QT_BUILD_TREE/imports/Qt/multimedia/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/Qt/multimedia
+
+INSTALLS += target qmldir
+
diff --git a/src/plugins/qdeclarativemodules/qdeclarativemodules.pro b/src/plugins/qdeclarativemodules/qdeclarativemodules.pro
new file mode 100644
index 0000000000..0a6f444e14
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/qdeclarativemodules.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+
+SUBDIRS += widgets
+
+contains(QT_CONFIG, multimedia): SUBDIRS += multimedia
+
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp b/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp
new file mode 100644
index 0000000000..fc15ad2981
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "graphicslayouts_p.h"
+
+#include <QtGui/qgraphicswidget.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+LinearLayoutAttached::LinearLayoutAttached(QObject *parent)
+: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter)
+{
+}
+
+void LinearLayoutAttached::setStretchFactor(int f)
+{
+ if (_stretch == f)
+ return;
+
+ _stretch = f;
+ emit stretchChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _stretch);
+}
+
+void LinearLayoutAttached::setAlignment(Qt::Alignment a)
+{
+ if (_alignment == a)
+ return;
+
+ _alignment = a;
+ emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _alignment);
+}
+
+QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+Q_UNUSED(which);
+Q_UNUSED(constraint);
+return QSizeF();
+}
+
+
+QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent)
+: QObject(parent)
+{
+}
+
+QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject()
+{
+}
+
+void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item)
+{
+insertItem(index, item);
+
+//connect attached properties
+if (LinearLayoutAttached *obj = attachedProperties.value(item)) {
+ setStretchFactor(item, obj->stretchFactor());
+ setAlignment(item, obj->alignment());
+ QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)),
+ this, SLOT(updateStretch(QGraphicsLayoutItem*,int)));
+ QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)),
+ this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment)));
+ //### need to disconnect when widget is removed?
+}
+}
+
+//### is there a better way to do this?
+void QGraphicsLinearLayoutObject::clearChildren()
+{
+for (int i = 0; i < count(); ++i)
+ removeAt(i);
+}
+
+void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch)
+{
+QGraphicsLinearLayout::setStretchFactor(item, stretch);
+}
+
+void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment)
+{
+QGraphicsLinearLayout::setAlignment(item, alignment);
+}
+
+QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> QGraphicsLinearLayoutObject::attachedProperties;
+LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj)
+{
+// ### This is not allowed - you must attach to any object
+if (!qobject_cast<QGraphicsLayoutItem*>(obj))
+ return 0;
+LinearLayoutAttached *rv = new LinearLayoutAttached(obj);
+attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
+return rv;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+// QGraphicsGridLayout-related classes
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+GridLayoutAttached::GridLayoutAttached(QObject *parent)
+: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1)
+{
+}
+
+void GridLayoutAttached::setRow(int r)
+{
+ if (_row == r)
+ return;
+
+ _row = r;
+ //emit rowChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _row);
+}
+
+void GridLayoutAttached::setColumn(int c)
+{
+ if (_column == c)
+ return;
+
+ _column = c;
+ //emit columnChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _column);
+}
+
+void GridLayoutAttached::setRowSpan(int rs)
+{
+ if (_rowspan == rs)
+ return;
+
+ _rowspan = rs;
+ //emit rowSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _rowSpan);
+}
+
+void GridLayoutAttached::setColumnSpan(int cs)
+{
+ if (_colspan == cs)
+ return;
+
+ _colspan = cs;
+ //emit columnSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _columnSpan);
+}
+
+void GridLayoutAttached::setAlignment(Qt::Alignment a)
+{
+ if (_alignment == a)
+ return;
+
+ _alignment = a;
+ //emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _alignment);
+}
+
+QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent)
+: QObject(parent)
+{
+}
+
+QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject()
+{
+}
+
+void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid)
+{
+//use attached properties
+if (QObject *obj = attachedProperties.value(qobject_cast<QGraphicsLayoutItem*>(wid))) {
+ int row = static_cast<GridLayoutAttached *>(obj)->row();
+ int column = static_cast<GridLayoutAttached *>(obj)->column();
+ int rowSpan = static_cast<GridLayoutAttached *>(obj)->rowSpan();
+ int columnSpan = static_cast<GridLayoutAttached *>(obj)->columnSpan();
+ if (row == -1 || column == -1) {
+ qWarning() << "Must set row and column for an item in a grid layout";
+ return;
+ }
+ addItem(wid, row, column, rowSpan, columnSpan);
+}
+}
+
+void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item)
+{
+//use attached properties
+if (GridLayoutAttached *obj = attachedProperties.value(item)) {
+ int row = obj->row();
+ int column = obj->column();
+ int rowSpan = obj->rowSpan();
+ int columnSpan = obj->columnSpan();
+ Qt::Alignment alignment = obj->alignment();
+ if (row == -1 || column == -1) {
+ qWarning() << "Must set row and column for an item in a grid layout";
+ return;
+ }
+ addItem(item, row, column, rowSpan, columnSpan);
+ if (alignment != -1)
+ setAlignment(item,alignment);
+}
+}
+
+//### is there a better way to do this?
+void QGraphicsGridLayoutObject::clearChildren()
+{
+for (int i = 0; i < count(); ++i)
+ removeAt(i);
+}
+
+qreal QGraphicsGridLayoutObject::spacing() const
+{
+if (verticalSpacing() == horizontalSpacing())
+ return verticalSpacing();
+return -1; //###
+}
+
+QHash<QGraphicsLayoutItem*, GridLayoutAttached*> QGraphicsGridLayoutObject::attachedProperties;
+GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj)
+{
+// ### This is not allowed - you must attach to any object
+if (!qobject_cast<QGraphicsLayoutItem*>(obj))
+ return 0;
+GridLayoutAttached *rv = new GridLayoutAttached(obj);
+attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv);
+return rv;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h b/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h
new file mode 100644
index 0000000000..f9b9ae81a6
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 GRAPHICSLAYOUTS_H
+#define GRAPHICSLAYOUTS_H
+
+#include "graphicswidgets_p.h"
+
+#include <QtGui/QGraphicsLinearLayout>
+#include <QtGui/QGraphicsGridLayout>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsLayoutItem)
+public:
+ QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0);
+
+ virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const;
+};
+
+class LinearLayoutAttached;
+class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem)
+
+ Q_PROPERTY(QDeclarativeListProperty<QGraphicsLayoutItem> children READ children)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
+ Q_CLASSINFO("DefaultProperty", "children")
+public:
+ QGraphicsLinearLayoutObject(QObject * = 0);
+ ~QGraphicsLinearLayoutObject();
+
+ QDeclarativeListProperty<QGraphicsLayoutItem> children() { return QDeclarativeListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); }
+
+ static LinearLayoutAttached *qmlAttachedProperties(QObject *);
+
+private Q_SLOTS:
+ void updateStretch(QGraphicsLayoutItem*,int);
+ void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment);
+
+private:
+ friend class LinearLayoutAttached;
+ void clearChildren();
+ void insertLayoutItem(int, QGraphicsLayoutItem *);
+ static QHash<QGraphicsLayoutItem*, LinearLayoutAttached*> attachedProperties;
+
+ static void children_append(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) {
+ static_cast<QGraphicsLinearLayoutObject*>(prop->object)->insertLayoutItem(-1, item);
+ }
+
+ static void children_clear(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) {
+ static_cast<QGraphicsLinearLayoutObject*>(prop->object)->clearChildren();
+ }
+
+ static int children_count(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) {
+ return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->count();
+ }
+
+ static QGraphicsLayoutItem *children_at(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, int index) {
+ return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->itemAt(index);
+ }
+};
+
+class GridLayoutAttached;
+class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem)
+
+ Q_PROPERTY(QDeclarativeListProperty<QGraphicsLayoutItem> children READ children)
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
+ Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
+ Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
+ Q_CLASSINFO("DefaultProperty", "children")
+public:
+ QGraphicsGridLayoutObject(QObject * = 0);
+ ~QGraphicsGridLayoutObject();
+
+ QDeclarativeListProperty<QGraphicsLayoutItem> children() { return QDeclarativeListProperty<QGraphicsLayoutItem>(this, 0, children_append, children_count, children_at, children_clear); }
+
+ qreal spacing() const;
+
+ static GridLayoutAttached *qmlAttachedProperties(QObject *);
+
+private:
+ friend class GraphicsLayoutAttached;
+ void addWidget(QGraphicsWidget *);
+ void clearChildren();
+ void addLayoutItem(QGraphicsLayoutItem *);
+ static QHash<QGraphicsLayoutItem*, GridLayoutAttached*> attachedProperties;
+
+ static void children_append(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) {
+ static_cast<QGraphicsGridLayoutObject*>(prop->object)->addLayoutItem(item);
+ }
+
+ static void children_clear(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) {
+ static_cast<QGraphicsGridLayoutObject*>(prop->object)->clearChildren();
+ }
+
+ static int children_count(QDeclarativeListProperty<QGraphicsLayoutItem> *prop) {
+ return static_cast<QGraphicsGridLayoutObject*>(prop->object)->count();
+ }
+
+ static QGraphicsLayoutItem *children_at(QDeclarativeListProperty<QGraphicsLayoutItem> *prop, int index) {
+ return static_cast<QGraphicsGridLayoutObject*>(prop->object)->itemAt(index);
+ }
+};
+
+class LinearLayoutAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+public:
+ LinearLayoutAttached(QObject *parent);
+
+ int stretchFactor() const { return _stretch; }
+ void setStretchFactor(int f);
+ Qt::Alignment alignment() const { return _alignment; }
+ void setAlignment(Qt::Alignment a);
+
+Q_SIGNALS:
+ void stretchChanged(QGraphicsLayoutItem*,int);
+ void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment);
+
+private:
+ int _stretch;
+ Qt::Alignment _alignment;
+};
+
+class GridLayoutAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int row READ row WRITE setRow)
+ Q_PROPERTY(int column READ column WRITE setColumn)
+ Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan)
+ Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+public:
+ GridLayoutAttached(QObject *parent);
+
+ int row() const { return _row; }
+ void setRow(int r);
+
+ int column() const { return _column; }
+ void setColumn(int c);
+
+ int rowSpan() const { return _rowspan; }
+ void setRowSpan(int rs);
+
+ int columnSpan() const { return _colspan; }
+ void setColumnSpan(int cs);
+
+ Qt::Alignment alignment() const { return _alignment; }
+ void setAlignment(Qt::Alignment a);
+
+private:
+ int _row;
+ int _column;
+ int _rowspan;
+ int _colspan;
+ Qt::Alignment _alignment;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_INTERFACE(QGraphicsLayoutItem)
+QML_DECLARE_INTERFACE(QGraphicsLayout)
+QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject)
+QML_DECLARE_TYPE(QGraphicsLinearLayoutObject)
+QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QGraphicsGridLayoutObject)
+QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // GRAPHICSLAYOUTS_H
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp b/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp
new file mode 100644
index 0000000000..062e516300
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h b/src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h
new file mode 100644
index 0000000000..2c2b707901
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/widgets/graphicswidgets_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 GRAPHICSWIDGETS_H
+#define GRAPHICSWIDGETS_H
+
+#include <qdeclarative.h>
+
+#include <QtGui/QGraphicsScene>
+#include <QtGui/QGraphicsView>
+#include <QtGui/QGraphicsWidget>
+#include <QtGui/QGraphicsItem>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QGraphicsView)
+QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene)
+QML_DECLARE_TYPE(QGraphicsWidget)
+QML_DECLARE_TYPE(QGraphicsObject)
+QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem)
+
+QT_END_HEADER
+
+#endif // GRAPHICSWIDGETS_H
diff --git a/src/plugins/qdeclarativemodules/widgets/widgets.cpp b/src/plugins/qdeclarativemodules/widgets/widgets.cpp
new file mode 100644
index 0000000000..ec21cc41e0
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/widgets/widgets.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** 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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+
+#include "graphicslayouts_p.h"
+#include "graphicswidgets_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QGraphicsViewDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QGraphicsScene *scene READ scene WRITE setScene)
+ Q_CLASSINFO("DefaultProperty", "scene")
+public:
+ QGraphicsViewDeclarativeUI(QObject *other) : QObject(other) {}
+
+ QGraphicsScene *scene() const { return static_cast<QGraphicsView *>(parent())->scene(); }
+ void setScene(QGraphicsScene *scene)
+ {
+ static_cast<QGraphicsView *>(parent())->setScene(scene);
+ }
+};
+
+class QGraphicsSceneDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children)
+ Q_CLASSINFO("DefaultProperty", "children")
+public:
+ QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {}
+
+ QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this->parent(), 0, children_append); }
+
+private:
+ static void children_append(QDeclarativeListProperty<QObject> *prop, QObject *o) {
+ if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o))
+ static_cast<QGraphicsScene *>(prop->object)->addItem(go);
+ }
+};
+
+class QGraphicsWidgetDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QDeclarativeListProperty<QGraphicsItem> children READ children)
+ Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout)
+ Q_CLASSINFO("DefaultProperty", "children")
+public:
+ QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {}
+
+ QDeclarativeListProperty<QGraphicsItem> children() { return QDeclarativeListProperty<QGraphicsItem>(this, 0, children_append); }
+
+ QGraphicsLayout *layout() const { return static_cast<QGraphicsWidget *>(parent())->layout(); }
+ void setLayout(QGraphicsLayout *lo)
+ {
+ static_cast<QGraphicsWidget *>(parent())->setLayout(lo);
+ }
+
+private:
+ void setItemParent(QGraphicsItem *wid)
+ {
+ wid->setParentItem(static_cast<QGraphicsWidget *>(parent()));
+ }
+
+ static void children_append(QDeclarativeListProperty<QGraphicsItem> *prop, QGraphicsItem *i) {
+ static_cast<QGraphicsWidgetDeclarativeUI*>(prop->object)->setItemParent(i);
+ }
+};
+
+class QWidgetsQmlModule : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.widgets"));
+
+ QML_REGISTER_INTERFACE(QGraphicsLayoutItem);
+ QML_REGISTER_INTERFACE(QGraphicsLayout);
+ qmlRegisterType<QGraphicsLinearLayoutStretchItemObject>(uri,4,6,"QGraphicsLinearLayoutStretchItem");
+ qmlRegisterType<QGraphicsLinearLayoutObject>(uri,4,6,"QGraphicsLinearLayout");
+ qmlRegisterType<QGraphicsGridLayoutObject>(uri,4,6,"QGraphicsGridLayout");
+ qmlRegisterExtendedType<QGraphicsView, QGraphicsViewDeclarativeUI>(uri,4,6,"QGraphicsView");
+ qmlRegisterExtendedType<QGraphicsScene,QGraphicsSceneDeclarativeUI>(uri,4,6,"QGraphicsScene");
+ qmlRegisterExtendedType<QGraphicsWidget,QGraphicsWidgetDeclarativeUI>(uri,4,6,"QGraphicsWidget");
+ QML_REGISTER_INTERFACE(QGraphicsItem);
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "widgets.moc"
+
+Q_EXPORT_PLUGIN2(qtwidgetsqmlmodule, QT_PREPEND_NAMESPACE(QWidgetsQmlModule));
+
diff --git a/src/plugins/qdeclarativemodules/widgets/widgets.pro b/src/plugins/qdeclarativemodules/widgets/widgets.pro
new file mode 100644
index 0000000000..3ec38dadb2
--- /dev/null
+++ b/src/plugins/qdeclarativemodules/widgets/widgets.pro
@@ -0,0 +1,20 @@
+TARGET = widgets
+include(../../qpluginbase.pri)
+
+QT += declarative
+
+SOURCES += \
+ graphicslayouts.cpp \
+ widgets.cpp
+
+HEADERS += \
+ graphicswidgets_p.h \
+ graphicslayouts_p.h
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/widgets
+target.path = $$[QT_INSTALL_IMPORTS]/Qt/widgets
+
+qmldir.files += $$QT_BUILD_TREE/imports/Qt/widgets/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/Qt/widgets
+
+INSTALLS += target qmldir
diff --git a/src/plugins/qmlmodules/multimedia/multimedia.cpp b/src/plugins/qmlmodules/multimedia/multimedia.cpp
deleted file mode 100644
index d192ed8cc7..0000000000
--- a/src/plugins/qmlmodules/multimedia/multimedia.cpp
+++ /dev/null
@@ -1,71 +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 plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtDeclarative/qmlmoduleplugin.h>
-#include <QtDeclarative/qml.h>
-#include <QtMultimedia/multimediaqml.h>
-
-QT_BEGIN_NAMESPACE
-
-class QMultimediaQmlModule : public QmlModulePlugin
-{
- Q_OBJECT
-public:
- QStringList keys() const
- {
- return QStringList() << QLatin1String("Qt.multimedia");
- }
-
- void defineModule(const QString& uri)
- {
- Q_UNUSED(uri)
- Q_ASSERT(uri == QLatin1String("Qt.multimedia"));
-
- QtMultimedia::qRegisterQmlElements();
- }
-};
-
-QT_END_NAMESPACE
-
-#include "multimedia.moc"
-
-Q_EXPORT_PLUGIN2(qmultimediaqmlmodule, QT_PREPEND_NAMESPACE(QMultimediaQmlModule));
-
diff --git a/src/plugins/qmlmodules/multimedia/multimedia.pro b/src/plugins/qmlmodules/multimedia/multimedia.pro
deleted file mode 100644
index f04cc142c0..0000000000
--- a/src/plugins/qmlmodules/multimedia/multimedia.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGET = multimedia
-include(../../qpluginbase.pri)
-
-QT += multimedia declarative
-
-SOURCES += multimedia.cpp
-
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmlmodules
-target.path = $$[QT_INSTALL_PLUGINS]/plugins/qmlmodules
-INSTALLS += target
-
diff --git a/src/plugins/qmlmodules/qmlmodules.pro b/src/plugins/qmlmodules/qmlmodules.pro
deleted file mode 100644
index b1dc0ef653..0000000000
--- a/src/plugins/qmlmodules/qmlmodules.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-
-contains(QT_CONFIG, multimedia): SUBDIRS += multimedia
-
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 98a24d0567..d2e96d1e1e 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -844,7 +844,7 @@ static QScriptValue __setupPackage__(QScriptContext *ctx, QScriptEngine *eng)
} // namespace QScript
QScriptEnginePrivate::QScriptEnginePrivate()
- : registeredScriptValues(0), freeScriptValues(0),
+ : registeredScriptValues(0), freeScriptValues(0), freeScriptValuesCount(0),
registeredScriptStrings(0), inEval(false)
{
qMetaTypeId<QScriptValue>();
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 79294fea2a..d0d020abd7 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -354,6 +354,8 @@ public:
int agentLineNumber;
QScriptValuePrivate *registeredScriptValues;
QScriptValuePrivate *freeScriptValues;
+ static const int maxFreeScriptValues = 256;
+ int freeScriptValuesCount;
QScriptStringPrivate *registeredScriptStrings;
QHash<int, QScriptTypeInfo*> m_typeInfos;
int processEventsInterval;
@@ -521,6 +523,7 @@ inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(siz
if (freeScriptValues) {
QScriptValuePrivate *p = freeScriptValues;
freeScriptValues = p->next;
+ --freeScriptValuesCount;
return p;
}
return reinterpret_cast<QScriptValuePrivate*>(qMalloc(size));
@@ -528,8 +531,13 @@ inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(siz
inline void QScriptEnginePrivate::freeScriptValuePrivate(QScriptValuePrivate *p)
{
- p->next = freeScriptValues;
- freeScriptValues = p;
+ if (freeScriptValuesCount < maxFreeScriptValues) {
+ p->next = freeScriptValues;
+ freeScriptValues = p;
+ ++freeScriptValuesCount;
+ } else {
+ qFree(p);
+ }
}
inline void QScriptEnginePrivate::registerScriptValue(QScriptValuePrivate *value)
diff --git a/src/svg/qgraphicssvgitem.cpp b/src/svg/qgraphicssvgitem.cpp
index 7e80e50d4e..69ff7a3db9 100644
--- a/src/svg/qgraphicssvgitem.cpp
+++ b/src/svg/qgraphicssvgitem.cpp
@@ -267,6 +267,7 @@ int QGraphicsSvgItem::type() const
/*!
\property QGraphicsSvgItem::maximumCacheSize
+ \since 4.6
This property holds the maximum size of the device coordinate cache
for this item.
@@ -312,7 +313,8 @@ QSize QGraphicsSvgItem::maximumCacheSize() const
/*!
\property QGraphicsSvgItem::elementId
-
+ \since 4.6
+
This property holds the element's XML ID.
*/
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 5fd2dcaa82..2ea9ca7894 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -313,8 +313,6 @@ SUBDIRS += \
qmediaserviceprovider \
qmediatimerange \
qvideowidget \
- qmlaudio \
- qmlgraphicsvideo \
qspinbox \
qsplitter \
qsql \
@@ -485,6 +483,9 @@ contains(QT_CONFIG,opengl):SUBDIRS += qgl qglbuffer qgl_threads
contains(QT_CONFIG,qt3support):!wince*:SUBDIRS += $$Q3SUBDIRS
+contains(QT_CONFIG,multimedia):contains(QT_CONFIG,declarative):SUBDIRS += qdeclarativeaudio \
+ qdeclarativevideo
+
contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter
mac: {
SUBDIRS += macgui \
@@ -608,10 +609,3 @@ contains(QT_CONFIG, declarative): SUBDIRS += declarative
xmlpatternsxqts \
xmlpatternsxslts
-
-############### make check recursively for testcases ##################
-check.CONFIG = recursive
-check.recurse = $$SUBDIRS
-check.recurse_target = check
-QMAKE_EXTRA_TARGETS += check
-###########################################################
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 9dc72306b0..42ff523d8f 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -4,64 +4,66 @@ SUBDIRS += \
layouts \ # Cover
parserstress \ # Cover
qmetaobjectbuilder \ # Cover
- qmlanimations \ # Cover
- qmlbehaviors \ # Cover
- qmlbinding \ # Cover
- qmlconnection \ # Cover
- qmlcontext \ # Cover
- qmldatetimeformatter \ # Cover
- qmldebug \ # Cover
- qmldebugclient \ # Cover
- qmldebugservice \ # Cover
- qmldom \ # Cover
- qmleasefollow \ # Cover
- qmlecmascript \ # Cover
- qmlengine \ # Cover
- qmlerror \ # Cover
- qmlfontloader \ # Cover
- qmlgraphicsanchors \ # Cover
- qmlgraphicsanimatedimage \ # Cover
- qmlgraphicsimage \ # Cover
- qmlgraphicsborderimage \ # Cover
- qmlgraphicsflickable \ # Cover
- qmlgraphicsflipable \ # Cover
- qmlgraphicsgridview \ # Cover
- qmlgraphicsitem \ # Cover
- qmlgraphicslistview \ # Cover
- qmlgraphicsloader \ # Cover
- qmlgraphicsmousearea \ # Cover
- qmlgraphicsparticles \ # Cover
- qmlgraphicspathview \ # Cover
- qmlgraphicspositioners \ # Cover
- qmlgraphicstext \ # Cover
- qmlgraphicstextedit \ # Cover
- qmlgraphicstextinput \ # Cover
- qmlinfo \ # Cover
- qmlinstruction \ # Cover
- qmllanguage \ # Cover
- qmllist \ # Cover
- qmllistmodel \ # Cover
- qmlmetaproperty \ # Cover
- qmlmetatype \ # Cover
- qmlnumberformatter \ # Cover
- qmlpixmapcache \ # Cover
- qmlpropertymap \ # Cover
- qmlqt \ # Cover
- qmlspringfollow \ # Cover
- qmlstates \ # Cover
- qmlsystempalette \ # Cover
- qmltimer \ # Cover
- qmlxmllistmodel \ # Cover
+ qdeclarativeanimations \ # Cover
+ qdeclarativebehaviors \ # Cover
+ qdeclarativebinding \ # Cover
+ qdeclarativeconnection \ # Cover
+ qdeclarativecontext \ # Cover
+ qdeclarativedatetimeformatter \ # Cover
+ qdeclarativedebug \ # Cover
+ qdeclarativedebugclient \ # Cover
+ qdeclarativedebugservice \ # Cover
+ qdeclarativedom \ # Cover
+ qdeclarativeeasefollow \ # Cover
+ qdeclarativeecmascript \ # Cover
+ qdeclarativeengine \ # Cover
+ qdeclarativeerror \ # Cover
+ qdeclarativefontloader \ # Cover
+ qdeclarativeanchors \ # Cover
+ qdeclarativeanimatedimage \ # Cover
+ qdeclarativeimage \ # Cover
+ qdeclarativeborderimage \ # Cover
+ qdeclarativeflickable \ # Cover
+ qdeclarativeflipable \ # Cover
+ qdeclarativegridview \ # Cover
+ qdeclarativeitem \ # Cover
+ qdeclarativelistview \ # Cover
+ qdeclarativeloader \ # Cover
+ qdeclarativemousearea \ # Cover
+ qdeclarativeparticles \ # Cover
+ qdeclarativepathview \ # Cover
+ qdeclarativepositioners \ # Cover
+ qdeclarativetext \ # Cover
+ qdeclarativetextedit \ # Cover
+ qdeclarativetextinput \ # Cover
+ qdeclarativeinfo \ # Cover
+ qdeclarativeinstruction \ # Cover
+ qdeclarativelanguage \ # Cover
+ qdeclarativelistreference \ # Cover
+ qdeclarativelistmodel \ # Cover
+ qdeclarativeproperty \ # Cover
+ qdeclarativemetatype \ # Cover
+ qdeclarativemoduleplugin \ # Cover
+ qdeclarativenumberformatter \ # Cover
+ qdeclarativepixmapcache \ # Cover
+ qdeclarativepropertymap \ # Cover
+ qdeclarativeqt \ # Cover
+ qdeclarativespringfollow \ # Cover
+ qdeclarativestates \ # Cover
+ qdeclarativesystempalette \ # Cover
+ qdeclarativetimer \ # Cover
+ qdeclarativexmllistmodel \ # Cover
qpacketprotocol \ # Cover
- qmlgraphicsrepeater \ # Cover
- qmlvaluetypes \ # Cover
- qmlxmlhttprequest \ # Cover
- qmlimageprovider \ # Cover
+ qdeclarativerepeater \ # Cover
+ qdeclarativevaluetypes \ # Cover
+ qdeclarativexmlhttprequest \ # Cover
+ qdeclarativeimageprovider \ # Cover
+ qdeclarativestyledtext \ # Cover
sql # Cover
contains(QT_CONFIG, webkit) {
SUBDIRS += \
- qmlgraphicswebview # Cover
+ qdeclarativewebview # Cover
}
# Tests which should run in Pulse
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 104c2d3a6b..6160e7cda6 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -56,7 +56,7 @@ private slots:
void namingConvention();
private:
- QString qmlviewer;
+ QString qmlruntime;
QStringList excludedDirs;
void namingConvention(const QDir &);
@@ -68,11 +68,11 @@ tst_examples::tst_examples()
QString binaries = QLibraryInfo::location(QLibraryInfo::BinariesPath);
#if defined(Q_WS_MAC)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.app/Contents/MacOS/qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml");
#elif defined(Q_WS_WIN)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.exe");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.exe");
#else
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml");
#endif
@@ -190,7 +190,8 @@ void tst_examples::examples()
<< "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
<< file;
QProcess p;
- p.start(qmlviewer, arguments);
+qDebug() << qmlruntime << arguments;
+ p.start(qmlruntime, arguments);
QVERIFY(p.waitForFinished());
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
QCOMPARE(p.exitCode(), 0);
diff --git a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
index 70fafd6482..c00173d5ed 100644
--- a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
+++ b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import Qt.widgets 4.6
QGraphicsView {
objectName: "GView"
diff --git a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
index cb618c65d5..a85ceed3a5 100644
--- a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
+++ b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
@@ -40,9 +40,9 @@
****************************************************************************/
#include <qtest.h>
#include <QFile>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/graphicswidgets_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtGui/qgraphicsview.h>
class tst_graphicswidgets : public QObject
@@ -61,8 +61,8 @@ tst_graphicswidgets::tst_graphicswidgets()
void tst_graphicswidgets::widgets()
{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/graphicswidgets.qml"));
QGraphicsView *obj = qobject_cast<QGraphicsView*>(c.create());
QVERIFY(obj != 0);
diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/layouts/data/layouts.qml
index 00d785d0ed..17925008e7 100644
--- a/tests/auto/declarative/layouts/data/layouts.qml
+++ b/tests/auto/declarative/layouts/data/layouts.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import Qt.widgets 4.6
Item {
id: resizable
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index ee05574d24..942125f268 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -40,39 +40,38 @@
****************************************************************************/
#include <QtTest/QtTest>
#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicslayoutitem_p.h>
-#include <qmlexpression.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativelayoutitem_p.h>
+#include <qdeclarativeexpression.h>
#include <QStyle>
-class tst_QmlGraphicsLayouts : public QObject
+class tst_QDeclarativeLayouts : public QObject
{
Q_OBJECT
public:
- tst_QmlGraphicsLayouts();
+ tst_QDeclarativeLayouts();
private slots:
void test_qml();//GraphicsLayout set up in Qml
void test_cpp();//GraphicsLayout set up in C++
private:
- QmlView *createView(const QString &filename);
+ QDeclarativeView *createView(const QString &filename);
};
-tst_QmlGraphicsLayouts::tst_QmlGraphicsLayouts()
+tst_QDeclarativeLayouts::tst_QDeclarativeLayouts()
{
}
-void tst_QmlGraphicsLayouts::test_qml()
+void tst_QDeclarativeLayouts::test_qml()
{
- QmlView *canvas = createView(SRCDIR "/data/layouts.qml");
+ QDeclarativeView *canvas = createView(SRCDIR "/data/layouts.qml");
- canvas->execute();
qApp->processEvents();
- QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("left"));
+ QDeclarativeLayoutItem *left = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("left"));
QVERIFY(left != 0);
- QmlGraphicsLayoutItem *right = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("right"));
+ QDeclarativeLayoutItem *right = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("right"));
QVERIFY(right != 0);
qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
@@ -82,7 +81,7 @@ void tst_QmlGraphicsLayouts::test_qml()
QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins.");
qreal gvMargin = l;
- QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject());
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
QVERIFY(rootItem != 0);
//Preferred Size
@@ -129,20 +128,20 @@ void tst_QmlGraphicsLayouts::test_qml()
delete canvas;
}
-void tst_QmlGraphicsLayouts::test_cpp()
+void tst_QDeclarativeLayouts::test_cpp()
{
//TODO: Waiting on QT-2407 to write this test
}
-QmlView *tst_QmlGraphicsLayouts::createView(const QString &filename)
+QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename)
{
- QmlView *canvas = new QmlView(0);
+ QDeclarativeView *canvas = new QDeclarativeView(0);
canvas->setSource(QUrl::fromLocalFile(filename));
return canvas;
}
-QTEST_MAIN(tst_QmlGraphicsLayouts)
+QTEST_MAIN(tst_QDeclarativeLayouts)
#include "tst_layouts.moc"
diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp
index 8af1b12fc9..6ff5515c31 100644
--- a/tests/auto/declarative/parserstress/tst_parserstress.cpp
+++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include <QDir>
#include <QFile>
@@ -58,7 +58,7 @@ private slots:
private:
static QStringList findJSFiles(const QDir &);
- QmlEngine engine;
+ QDeclarativeEngine engine;
};
QStringList tst_parserstress::findJSFiles(const QDir &d)
@@ -130,7 +130,7 @@ void tst_parserstress::ecmascript()
QByteArray qmlData = qml.toUtf8();
- QmlComponent component(&engine);
+ QDeclarativeComponent component(&engine);
component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml")));
QSet<QString> failingTests;
failingTests << "uc-003.js" << "uc-005.js" << "regress-352044-02-n.js"
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml b/tests/auto/declarative/qdeclarativeanchors/data/anchors.qml
index b64d0b02ef..b64d0b02ef 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/anchors.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/anchors.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml b/tests/auto/declarative/qdeclarativeanchors/data/centerin.qml
index 09b97f6c43..09b97f6c43 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/centerin.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/centerin.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml b/tests/auto/declarative/qdeclarativeanchors/data/crash1.qml
index fd9dc554ef..fd9dc554ef 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/crash1.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/crash1.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml b/tests/auto/declarative/qdeclarativeanchors/data/fill.qml
index 902465c6e3..902465c6e3 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/fill.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/fill.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml b/tests/auto/declarative/qdeclarativeanchors/data/loop1.qml
index a266612526..a266612526 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/loop1.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/loop1.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml b/tests/auto/declarative/qdeclarativeanchors/data/loop2.qml
index acb57cdf18..acb57cdf18 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/loop2.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/loop2.qml
diff --git a/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml b/tests/auto/declarative/qdeclarativeanchors/data/margins.qml
index 4a29e770ab..4a29e770ab 100644
--- a/tests/auto/declarative/qmlgraphicsanchors/data/margins.qml
+++ b/tests/auto/declarative/qdeclarativeanchors/data/margins.qml
diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
new file mode 100644
index 0000000000..ca2f68f45a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeanchors.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
new file mode 100644
index 0000000000..9d8ba6ce1c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -0,0 +1,448 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativeanchors_p_p.h>
+
+Q_DECLARE_METATYPE(QDeclarativeAnchors::UsedAnchor)
+Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine)
+
+
+class tst_qdeclarativeanchors : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeanchors() {}
+
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id);
+
+private slots:
+ void basicAnchors();
+ void loops();
+ void illegalSets();
+ void illegalSets_data();
+ void reset();
+ void reset_data();
+ void resetConvenience();
+ void nullItem();
+ void nullItem_data();
+ void crash1();
+ void centerIn();
+ void fill();
+ void margins();
+};
+
+/*
+ Find an item with the specified id.
+*/
+template<typename T>
+T *tst_qdeclarativeanchors::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ QList<QGraphicsItem *> children = parent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(children.at(i)->toGraphicsObject());
+ if (item) {
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ return static_cast<T*>(item);
+ }
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+ }
+
+ return 0;
+}
+
+void tst_qdeclarativeanchors::basicAnchors()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
+
+ qApp->processEvents();
+
+ //sibling horizontal
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
+
+ //parent horizontal
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
+
+ //vertical
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
+
+ //stretch
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
+
+ //vertical stretch
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
+
+ //more parent horizontal
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
+
+ //centerIn
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
+
+ //margins
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
+
+ // offsets
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
+
+ //baseline
+ QDeclarativeText *text1 = findItem<QDeclarativeText>(view->rootObject(), QLatin1String("text1"));
+ QDeclarativeText *text2 = findItem<QDeclarativeText>(view->rootObject(), QLatin1String("text2"));
+ QCOMPARE(text1->y(), text2->y());
+
+ delete view;
+}
+
+// mostly testing that we don't crash
+void tst_qdeclarativeanchors::loops()
+{
+ {
+ QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
+
+ QString expect = "QML Text (" + source.toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ {
+ QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
+
+ QString expect = "QML Image (" + source.toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+}
+
+void tst_qdeclarativeanchors::illegalSets()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, warning);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
+ if (!component.isReady())
+ qWarning() << "Test errors:" << component.errors();
+ QVERIFY(component.isReady());
+ QObject *o = component.create();
+ delete o;
+}
+
+void tst_qdeclarativeanchors::illegalSets_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("warning");
+
+ QTest::newRow("H - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
+ << "QML Rectangle (file::2:23) Cannot specify left, right, and hcenter anchors.";
+
+ foreach (const QString &side, QStringList() << "left" << "right") {
+ QTest::newRow("H - anchor to V")
+ << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
+ << "QML Rectangle (file::2:13) Cannot anchor a horizontal edge to a vertical edge.";
+
+ QTest::newRow("H - anchor to non parent/sibling")
+ << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
+ << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
+
+ QTest::newRow("H - anchor to self")
+ << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
+ << "QML Rectangle (file::2:1) Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("V - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
+ << "QML Rectangle (file::2:23) Cannot specify top, bottom, and vcenter anchors.";
+
+ QTest::newRow("V - too many anchors with baseline")
+ << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
+ << "QML Text (file::2:47) Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
+
+ foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
+
+ QTest::newRow("V - anchor to H")
+ << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
+ << "QML Rectangle (file::2:13) Cannot anchor a vertical edge to a horizontal edge.";
+
+ QTest::newRow("V - anchor to non parent/sibling")
+ << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
+ << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
+
+ QTest::newRow("V - anchor to self")
+ << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
+ << "QML Rectangle (file::2:1) Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("centerIn - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
+ << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
+
+
+ QTest::newRow("fill - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
+ << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
+}
+
+void tst_qdeclarativeanchors::reset()
+{
+ QFETCH(QString, side);
+ QFETCH(QDeclarativeAnchorLine::AnchorLine, anchorLine);
+ QFETCH(QDeclarativeAnchors::UsedAnchor, usedAnchor);
+
+ QDeclarativeItem *baseItem = new QDeclarativeItem;
+
+ QDeclarativeAnchorLine anchor;
+ anchor.item = baseItem;
+ anchor.anchorLine = anchorLine;
+
+ QDeclarativeItem *item = new QDeclarativeItem;
+
+ const QMetaObject *meta = item->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
+ QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true);
+
+ QVERIFY(p.reset(item->anchors()));
+ QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qdeclarativeanchors::reset_data()
+{
+ QTest::addColumn<QString>("side");
+ QTest::addColumn<QDeclarativeAnchorLine::AnchorLine>("anchorLine");
+ QTest::addColumn<QDeclarativeAnchors::UsedAnchor>("usedAnchor");
+
+ QTest::newRow("left") << "left" << QDeclarativeAnchorLine::Left << QDeclarativeAnchors::HasLeftAnchor;
+ QTest::newRow("top") << "top" << QDeclarativeAnchorLine::Top << QDeclarativeAnchors::HasTopAnchor;
+ QTest::newRow("right") << "right" << QDeclarativeAnchorLine::Right << QDeclarativeAnchors::HasRightAnchor;
+ QTest::newRow("bottom") << "bottom" << QDeclarativeAnchorLine::Bottom << QDeclarativeAnchors::HasBottomAnchor;
+
+ QTest::newRow("hcenter") << "horizontalCenter" << QDeclarativeAnchorLine::HCenter << QDeclarativeAnchors::HasHCenterAnchor;
+ QTest::newRow("vcenter") << "verticalCenter" << QDeclarativeAnchorLine::VCenter << QDeclarativeAnchors::HasVCenterAnchor;
+ QTest::newRow("baseline") << "baseline" << QDeclarativeAnchorLine::Baseline << QDeclarativeAnchors::HasBaselineAnchor;
+}
+
+void tst_qdeclarativeanchors::resetConvenience()
+{
+ QDeclarativeItem *baseItem = new QDeclarativeItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
+
+ //fill
+ item->anchors()->setFill(baseItem);
+ QVERIFY(item->anchors()->fill() == baseItem);
+ item->anchors()->resetFill();
+ QVERIFY(item->anchors()->fill() == 0);
+
+ //centerIn
+ item->anchors()->setCenterIn(baseItem);
+ QVERIFY(item->anchors()->centerIn() == baseItem);
+ item->anchors()->resetCenterIn();
+ QVERIFY(item->anchors()->centerIn() == 0);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qdeclarativeanchors::nullItem()
+{
+ QFETCH(QString, side);
+
+ QDeclarativeAnchorLine anchor;
+ QDeclarativeItem *item = new QDeclarativeItem;
+
+ const QMetaObject *meta = item->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item.");
+ QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
+
+ delete item;
+}
+
+void tst_qdeclarativeanchors::nullItem_data()
+{
+ QTest::addColumn<QString>("side");
+
+ QTest::newRow("left") << "left";
+ QTest::newRow("top") << "top";
+ QTest::newRow("right") << "right";
+ QTest::newRow("bottom") << "bottom";
+
+ QTest::newRow("hcenter") << "horizontalCenter";
+ QTest::newRow("vcenter") << "verticalCenter";
+ QTest::newRow("baseline") << "baseline";
+}
+
+void tst_qdeclarativeanchors::crash1()
+{
+ QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
+
+ QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message
+
+ QDeclarativeView *view = new QDeclarativeView(source);
+ qApp->processEvents();
+
+ delete view;
+}
+
+void tst_qdeclarativeanchors::fill()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler"));
+ QCOMPARE(rect->x(), 0.0 + 10.0);
+ QCOMPARE(rect->y(), 0.0 + 30.0);
+ QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
+ //Alter Offsets (QTBUG-6631)
+ rect->anchors()->setLeftMargin(20.0);
+ rect->anchors()->setRightMargin(0.0);
+ rect->anchors()->setBottomMargin(0.0);
+ rect->anchors()->setTopMargin(10.0);
+ QCOMPARE(rect->x(), 0.0 + 20.0);
+ QCOMPARE(rect->y(), 0.0 + 10.0);
+ QCOMPARE(rect->width(), 200.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qdeclarativeanchors::centerIn()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("centered"));
+ QCOMPARE(rect->x(), 75.0 + 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (QTBUG-6631)
+ rect->anchors()->setHorizontalCenterOffset(-20.0);
+ rect->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rect->x(), 75.0 - 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qdeclarativeanchors::margins()
+{
+ QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
+
+ qApp->processEvents();
+ QDeclarativeRectangle* rect = findItem<QDeclarativeRectangle>(view->rootObject(), QLatin1String("filler"));
+ QCOMPARE(rect->x(), 5.0);
+ QCOMPARE(rect->y(), 6.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
+ QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
+
+ rect->anchors()->setTopMargin(0.0);
+ rect->anchors()->setMargins(20.0);
+
+ QCOMPARE(rect->x(), 5.0);
+ QCOMPARE(rect->y(), 20.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
+
+ delete view;
+}
+
+QTEST_MAIN(tst_qdeclarativeanchors)
+
+#include "tst_qdeclarativeanchors.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif
index 1270bfaa79..1270bfaa79 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.gif
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml
index 5bada340d0..5bada340d0 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/colors.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif
index 7c4cd18687..7c4cd18687 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.gif
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml
index a70db5dbe9..a70db5dbe9 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickman.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml
index 7ab17d4265..7ab17d4265 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanpause.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml
index 53b0c3a739..53b0c3a739 100644
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/data/stickmanstopped.qml
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
new file mode 100644
index 0000000000..2904986823
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative network
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
new file mode 100644
index 0000000000..31efc64287
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativeimage_p.h>
+#include <private/qdeclarativeanimatedimage_p.h>
+
+#include "../shared/testhttpserver.h"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeanimatedimage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeanimatedimage() {}
+
+private slots:
+ void play();
+ void pause();
+ void stopped();
+ void setFrame();
+ void frameCount();
+ void remote();
+ void remote_data();
+ void invalidSource();
+};
+
+void tst_qdeclarativeanimatedimage::play()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::pause()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QVERIFY(anim->isPaused());
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::stopped()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(!anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 0);
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::setFrame()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 2);
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::frameCount()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->frameCount(), 3);
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::remote()
+{
+ QFETCH(QString, fileName);
+ QFETCH(bool, paused);
+
+ TestHTTPServer server(14445);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14445/" + fileName));
+ TRY_WAIT(component.isReady());
+
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ TRY_WAIT(anim->isPlaying());
+ if (paused) {
+ TRY_WAIT(anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 2);
+ }
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::remote_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("paused");
+
+ QTest::newRow("playing") << "stickman.qml" << false;
+ QTest::newRow("paused") << "stickmanpause.qml" << true;
+}
+
+void tst_qdeclarativeanimatedimage::invalidSource()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+
+ QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) ");
+
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QVERIFY(!anim->isPlaying());
+ QVERIFY(!anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 0);
+ QCOMPARE(anim->frameCount(), 0);
+}
+
+QTEST_MAIN(tst_qdeclarativeanimatedimage)
+
+#include "tst_qdeclarativeanimatedimage.moc"
diff --git a/tests/auto/declarative/qmlanimations/data/attached.qml b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
index 0fb6f8cbca..0fb6f8cbca 100644
--- a/tests/auto/declarative/qmlanimations/data/attached.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badproperty1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml
index d31cae99d3..d31cae99d3 100644
--- a/tests/auto/declarative/qmlanimations/data/badproperty1.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badproperty2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml
index 3b8b111ac2..3b8b111ac2 100644
--- a/tests/auto/declarative/qmlanimations/data/badproperty2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml
index 6381df3409..6381df3409 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype1.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml
index 8d57e418eb..8d57e418eb 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype3.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml
index c4867c3b58..c4867c3b58 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype3.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml
diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml
index e80762fd72..e80762fd72 100644
--- a/tests/auto/declarative/qmlanimations/data/badtype4.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml
index d9660b6202..d9660b6202 100644
--- a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml
index 36417db3df..36417db3df 100644
--- a/tests/auto/declarative/qmlanimations/data/dontStart.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart2.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml
index 1a6540fde5..1a6540fde5 100644
--- a/tests/auto/declarative/qmlanimations/data/dontStart2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml
index 9f0e699da2..9f0e699da2 100644
--- a/tests/auto/declarative/qmlanimations/data/dotproperty.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml
index 67703669ad..67703669ad 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml
diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml
index 80c9473044..80c9473044 100644
--- a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml
index 7e73f57b3e..7e73f57b3e 100644
--- a/tests/auto/declarative/qmlanimations/data/properties.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties2.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml
index 6c961552b2..6c961552b2 100644
--- a/tests/auto/declarative/qmlanimations/data/properties2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties3.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml
index ff08885f07..ff08885f07 100644
--- a/tests/auto/declarative/qmlanimations/data/properties3.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties4.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml
index dab7e5fa77..dab7e5fa77 100644
--- a/tests/auto/declarative/qmlanimations/data/properties4.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml
diff --git a/tests/auto/declarative/qmlanimations/data/properties5.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml
index 38396b15f7..38396b15f7 100644
--- a/tests/auto/declarative/qmlanimations/data/properties5.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml
index b13b94b3fc..b13b94b3fc 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml
index 033c5c1f29..033c5c1f29 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml
index d0704c9429..d0704c9429 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml
index e70c95c943..e70c95c943 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml
index b9e27da523..b9e27da523 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml
diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml
index 7417ed14ee..7417ed14ee 100644
--- a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml
diff --git a/tests/auto/declarative/qmlanimations/data/valuesource.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml
index c35063dc27..c35063dc27 100644
--- a/tests/auto/declarative/qmlanimations/data/valuesource.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml
diff --git a/tests/auto/declarative/qmlanimations/data/valuesource2.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml
index 1a60542427..1a60542427 100644
--- a/tests/auto/declarative/qmlanimations/data/valuesource2.qml
+++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml
diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
new file mode 100644
index 0000000000..8eac75f10d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeanimations.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
new file mode 100644
index 0000000000..53c63b5792
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -0,0 +1,672 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativeanimation_p.h>
+#include <QVariantAnimation>
+#include <QEasingCurve>
+
+class tst_qdeclarativeanimations : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeanimations() {}
+
+private slots:
+ void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered
+
+ void simpleProperty();
+ void simpleNumber();
+ void simpleColor();
+ void alwaysRunToEnd();
+ void complete();
+ void resume();
+ void dotProperty();
+ void badTypes();
+ void badProperties();
+ void mixedTypes();
+ void properties();
+ void propertiesTransition();
+ void invalidDuration();
+ void attached();
+ void propertyValueSourceDefaultStart();
+ void dontStart();
+ void easingProperties();
+};
+
+#define QTIMED_COMPARE(lhs, rhs) do { \
+ for (int ii = 0; ii < 5; ++ii) { \
+ if (lhs == rhs) \
+ break; \
+ QTest::qWait(50); \
+ } \
+ QCOMPARE(lhs, rhs); \
+} while (false)
+
+void tst_qdeclarativeanimations::simpleProperty()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("pos");
+ animation.setTo(QPointF(200,200));
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "pos");
+ QVERIFY(animation.to().toPointF() == QPointF(200,200));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.pos(), QPointF(200,200));
+
+ rect.setPos(0,0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.pos(), QPointF(100,100));
+}
+
+void tst_qdeclarativeanimations::simpleNumber()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeNumberAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "x");
+ QVERIFY(animation.to() == 200);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.x(), qreal(200));
+
+ rect.setX(0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.x(), qreal(100));
+}
+
+void tst_qdeclarativeanimations::simpleColor()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeColorAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("color");
+ animation.setTo(QColor("red"));
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "color");
+ QVERIFY(animation.to() == QColor("red"));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.color(), QColor("red"));
+
+ rect.setColor(QColor("blue"));
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+
+ rect.setColor(QColor("green"));
+ animation.setFrom(QColor("blue"));
+ QVERIFY(animation.from() == QColor("blue"));
+ animation.restart();
+ QCOMPARE(rect.color(), QColor("blue"));
+ QVERIFY(animation.isRunning());
+ animation.setCurrentTime(125);
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+}
+
+void tst_qdeclarativeanimations::alwaysRunToEnd()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ animation.setDuration(1000);
+ animation.setRepeat(true);
+ animation.setAlwaysRunToEnd(true);
+ QVERIFY(animation.repeat() == true);
+ QVERIFY(animation.alwaysRunToEnd() == true);
+ animation.start();
+ QTest::qWait(1500);
+ animation.stop();
+ QVERIFY(rect.x() != qreal(200));
+ QTest::qWait(500);
+ QTIMED_COMPARE(rect.x(), qreal(200));
+}
+
+void tst_qdeclarativeanimations::complete()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setFrom(1);
+ animation.setTo(200);
+ animation.setDuration(500);
+ QVERIFY(animation.from() == 1);
+ animation.start();
+ QTest::qWait(50);
+ animation.stop();
+ QVERIFY(rect.x() != qreal(200));
+ animation.start();
+ QTest::qWait(50);
+ QVERIFY(animation.isRunning());
+ animation.complete();
+ QCOMPARE(rect.x(), qreal(200));
+}
+
+void tst_qdeclarativeanimations::resume()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setFrom(10);
+ animation.setTo(200);
+ animation.setDuration(500);
+ QVERIFY(animation.from() == 10);
+
+ animation.start();
+ QTest::qWait(100);
+ animation.pause();
+ qreal x = rect.x();
+ QVERIFY(x != qreal(200));
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+
+ animation.resume();
+ QVERIFY(animation.isRunning());
+ QVERIFY(!animation.isPaused());
+ QTest::qWait(100);
+ animation.stop();
+ QVERIFY(rect.x() > x);
+}
+
+void tst_qdeclarativeanimations::dotProperty()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeNumberAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("border.width");
+ animation.setTo(10);
+ animation.start();
+ QTest::qWait(animation.duration()+50);
+ QTIMED_COMPARE(rect.border()->width(), 10);
+
+ rect.border()->setWidth(0);
+ animation.start();
+ animation.pause();
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.border()->width(), 5);
+}
+
+void tst_qdeclarativeanimations::badTypes()
+{
+ //don't crash
+ {
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
+
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ //make sure we get a compiler error
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype2.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected"));
+ }
+
+ //make sure we get a compiler error
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
+ }
+
+ //don't crash
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("state1");
+ QTest::qWait(1000 + 50);
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
+ QVERIFY(myRect);
+ QCOMPARE(myRect->x(),qreal(200));
+ }
+}
+
+void tst_qdeclarativeanimations::badProperties()
+{
+ //make sure we get a runtime error
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml"));
+ QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c1.create());
+ QVERIFY(rect);
+
+ QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml"));
+ message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ rect = qobject_cast<QDeclarativeRectangle*>(c2.create());
+ QVERIFY(rect);
+
+ //### should we warn here are well?
+ //rect->setState("state1");
+ }
+}
+
+//test animating mixed types with property animation in a transition
+//for example, int + real; color + real; etc
+void tst_qdeclarativeanimations::mixedTypes()
+{
+ //assumes border.width stays a real -- not real robust
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("state1");
+ QTest::qWait(500);
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+ QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("state1");
+ QTest::qWait(500);
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+ QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
+ }
+}
+
+void tst_qdeclarativeanimations::properties()
+{
+ const int waitDuration = 300;
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(300));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ }
+}
+
+void tst_qdeclarativeanimations::propertiesTransition()
+{
+ const int waitDuration = 300;
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ /*{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *myRect = rect->findChild<QDeclarativeRectangle*>("TheRect");
+ QVERIFY(myRect);
+ rect->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }*/
+}
+
+void tst_qdeclarativeanimations::invalidDuration()
+{
+ QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0");
+ animation->setDuration(-1);
+ QCOMPARE(animation->duration(), 250);
+
+ QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "QML PauseAnimation (unknown location) Cannot set a duration of < 0");
+ pauseAnimation->setDuration(-1);
+ QCOMPARE(pauseAnimation->duration(), 250);
+}
+
+void tst_qdeclarativeanimations::attached()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "off");
+ QTest::ignoreMessage(QtDebugMsg, "on");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+}
+
+void tst_qdeclarativeanimations::propertyValueSourceDefaultStart()
+{
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml"));
+
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning());
+ }
+
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml"));
+
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning() == false);
+ }
+
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml"));
+
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+}
+
+
+void tst_qdeclarativeanimations::dontStart()
+{
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+
+ {
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ }
+}
+
+void tst_qdeclarativeanimations::easingProperties()
+{
+ {
+ QDeclarativeEngine engine;
+ QString componentStr = "import Qt 4.6\nNumberAnimation { easing.type: \"InOutQuad\" }";
+ QDeclarativeComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QString componentStr = "import Qt 4.6\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
+ QDeclarativeComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
+ QCOMPARE(animObject->easing().amplitude(), 5.0);
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QString componentStr = "import Qt 4.6\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
+ QDeclarativeComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
+ QCOMPARE(animObject->easing().amplitude(), 5.0);
+ QCOMPARE(animObject->easing().period(), 3.0);
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QString componentStr = "import Qt 4.6\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
+ QDeclarativeComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
+ QCOMPARE(animObject->easing().overshoot(), 2.0);
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativeanimations)
+
+#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/declarative/qmlbehaviors/data/binding.qml b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
index 201da37b87..201da37b87 100644
--- a/tests/auto/declarative/qmlbehaviors/data/binding.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/color.qml b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml
index 91dbbd1f85..91dbbd1f85 100644
--- a/tests/auto/declarative/qmlbehaviors/data/color.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml
index 8d032f02c7..8d032f02c7 100644
--- a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/disabled.qml b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml
index 3c7078a890..3c7078a890 100644
--- a/tests/auto/declarative/qmlbehaviors/data/disabled.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
index ba7cc9cbf0..ba7cc9cbf0 100644
--- a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/empty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml
index 95d934a531..95d934a531 100644
--- a/tests/auto/declarative/qmlbehaviors/data/empty.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/explicit.qml b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml
index 1b2025a785..1b2025a785 100644
--- a/tests/auto/declarative/qmlbehaviors/data/explicit.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml
index 14883d468a..14883d468a 100644
--- a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml
index b43ddbcd98..b43ddbcd98 100644
--- a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/loop.qml b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml
index 5f2c057e91..5f2c057e91 100644
--- a/tests/auto/declarative/qmlbehaviors/data/loop.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml
index f267a05f40..f267a05f40 100644
--- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/parent.qml b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml
index 7c7fdcb56f..7c7fdcb56f 100644
--- a/tests/auto/declarative/qmlbehaviors/data/parent.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
index ba744b1764..ba744b1764 100644
--- a/tests/auto/declarative/qmlbehaviors/data/reassignedAnimation.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
index a91ca883e2..a91ca883e2 100644
--- a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml
diff --git a/tests/auto/declarative/qmlbehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
index ac98ed05d9..ac98ed05d9 100644
--- a/tests/auto/declarative/qmlbehaviors/data/simple.qml
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml
diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
new file mode 100644
index 0000000000..a1dac32f64
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativebehaviors.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
new file mode 100644
index 0000000000..f87330d4a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -0,0 +1,301 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativebehavior_p.h>
+#include <private/qdeclarativeanimation_p.h>
+
+class tst_qdeclarativebehaviors : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativebehaviors() {}
+
+private slots:
+ void simpleBehavior();
+ void scriptTriggered();
+ void cppTriggered();
+ void loop();
+ void colorBehavior();
+ void parentBehavior();
+ void replaceBinding();
+ //void transitionOverrides();
+ void group();
+ void emptyBehavior();
+ void explicitSelection();
+ void nonSelectingBehavior();
+ void reassignedAnimation();
+ void disabled();
+ void dontStart();
+};
+
+void tst_qdeclarativebehaviors::simpleBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+ QVERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::scriptTriggered()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setColor(QColor("red"));
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::cppTriggered()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect);
+
+ innerRect->setProperty("x", 200);
+ QTest::qWait(200);
+ qreal x = innerRect->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::loop()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ //don't crash
+ rect->setState("moved");
+}
+
+void tst_qdeclarativebehaviors::colorBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("red");
+ QTest::qWait(200);
+ QColor color = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->color();
+ QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
+}
+
+void tst_qdeclarativebehaviors::parentBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("reparented");
+ QTest::qWait(200);
+ QDeclarativeItem *newParent = rect->findChild<QDeclarativeItem*>("NewParent");
+ QDeclarativeItem *parent = rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem();
+ QVERIFY(parent != newParent);
+ QTest::qWait(600);
+ parent = rect->findChild<QDeclarativeRectangle*>("MyRect")->parentItem();
+ QVERIFY(parent == newParent);
+}
+
+void tst_qdeclarativebehaviors::replaceBinding()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect);
+ qreal x = innerRect->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("basex", 10);
+ QCOMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("movedx", 210);
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)210);
+
+ rect->setState("");
+ QTest::qWait(200);
+ x = innerRect->x();
+ QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("movedx", 200);
+ QCOMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("basex", 20);
+ QTest::qWait(600);
+ QCOMPARE(innerRect->x(), (qreal)20);
+}
+
+void tst_qdeclarativebehaviors::group()
+{
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ }
+}
+
+void tst_qdeclarativebehaviors::emptyBehavior()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_qdeclarativebehaviors::explicitSelection()
+{
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ QTest::qWait(200);
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
+ }
+}
+
+void tst_qdeclarativebehaviors::nonSelectingBehavior()
+{
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+ }
+}
+
+void tst_qdeclarativebehaviors::reassignedAnimation()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
+ QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData());
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
+ qobject_cast<QDeclarativeBehavior*>(
+ rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation())->duration(), 200);
+}
+
+void tst_qdeclarativebehaviors::disabled()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
+
+ rect->setState("moved");
+ qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+}
+
+void tst_qdeclarativebehaviors::dontStart()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+}
+
+QTEST_MAIN(tst_qdeclarativebehaviors)
+
+#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/declarative/qmlbinding/data/test-binding.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml
index e9101e4759..e9101e4759 100644
--- a/tests/auto/declarative/qmlbinding/data/test-binding.qml
+++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml
diff --git a/tests/auto/declarative/qmlbinding/data/test-binding2.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml
index ea20c169fe..ea20c169fe 100644
--- a/tests/auto/declarative/qmlbinding/data/test-binding2.qml
+++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
new file mode 100644
index 0000000000..787997646f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativebinding.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
new file mode 100644
index 0000000000..826df4fd3d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativebind_p.h>
+#include <private/qdeclarativerectangle_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativebinding : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativebinding();
+
+private slots:
+ void binding();
+ void whenAfterValue();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativebinding::tst_qdeclarativebinding()
+{
+}
+
+void tst_qdeclarativebinding::binding()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+
+ QVERIFY(rect != 0);
+ QCOMPARE(rect->color(), QColor("yellow"));
+ QCOMPARE(rect->property("text").toString(), QString("Hello"));
+
+ rect->setProperty("changeColor", true);
+ QCOMPARE(rect->color(), QColor("red"));
+
+ QDeclarativeBind *binding = qobject_cast<QDeclarativeBind*>(rect->findChild<QDeclarativeBind*>("binding1"));
+ QVERIFY(binding != 0);
+ QCOMPARE(binding->object(), rect);
+ QCOMPARE(binding->property(), QLatin1String("text"));
+ QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
+
+ delete rect;
+}
+
+void tst_qdeclarativebinding::whenAfterValue()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+
+ QVERIFY(rect != 0);
+ QCOMPARE(rect->color(), QColor("yellow"));
+ QCOMPARE(rect->property("text").toString(), QString("Hello"));
+
+ rect->setProperty("changeColor", true);
+ QCOMPARE(rect->color(), QColor("red"));
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qdeclarativebinding)
+
+#include "tst_qdeclarativebinding.moc"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci
index 5d2f49f0e1..5d2f49f0e1 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/data/colors-round.sci
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png b/tests/auto/declarative/qdeclarativeborderimage/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/data/colors.png
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/colors.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/data/invalid.sci b/tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci
index 98c72c9bf1..98c72c9bf1 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/data/invalid.sci
+++ b/tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci
diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
new file mode 100644
index 0000000000..0574ddb119
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
new file mode 100644
index 0000000000..8aeba6dfee
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeborderimage_p.h>
+#include <private/qdeclarativeimagebase_p.h>
+#include <private/qdeclarativescalegrid_p_p.h>
+#include <private/qdeclarativeloader_p.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+
+#include "../shared/testhttpserver.h"
+
+
+#define SERVER_PORT 14445
+#define SERVER_ADDR "http://127.0.0.1:14445"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 60; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeborderimage : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeborderimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void smooth();
+ void tileModes();
+ void sciSource();
+ void sciSource_data();
+ void invalidSciFile();
+ void pendingRemoteRequest();
+ void pendingRemoteRequest_data();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeborderimage::tst_qdeclarativeborderimage()
+{
+}
+
+void tst_qdeclarativeborderimage::noSource()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
+ QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
+ << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
+ << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
+}
+
+void tst_qdeclarativeborderimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(QString, error);
+
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(SRCDIR "/data");
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qdeclarativeborderimage::clearSource()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: srcImage }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QDeclarativeBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QDeclarativeBorderImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+}
+
+void tst_qdeclarativeborderimage::resized()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::smooth()
+{
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::tileModes()
+{
+ {
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Repeat);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat);
+
+ delete obj;
+ }
+ {
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 150.);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Round);
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativeborderimage::sciSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, valid);
+
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(SRCDIR "/data");
+ }
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+
+ if (valid) {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready);
+ QCOMPARE(obj->border()->left(), 10);
+ QCOMPARE(obj->border()->top(), 20);
+ QCOMPARE(obj->border()->right(), 30);
+ QCOMPARE(obj->border()->bottom(), 40);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qdeclarativeborderimage::sciSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
+ QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
+}
+
+void tst_qdeclarativeborderimage::invalidSciFile()
+{
+ QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun"
+ QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea"
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->status(), QDeclarativeImageBase::Error);
+ QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeborderimage::pendingRemoteRequest()
+{
+ QFETCH(QString, source);
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeBorderImage *obj = qobject_cast<QDeclarativeBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->status(), QDeclarativeBorderImage::Loading);
+
+ // verify no crash
+ // This will cause a delayed "QThread: Destroyed while thread is still running" warning
+ delete obj;
+ QTest::qWait(50);
+}
+
+void tst_qdeclarativeborderimage::pendingRemoteRequest_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
+ QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
+}
+
+QTEST_MAIN(tst_qdeclarativeborderimage)
+
+#include "tst_qdeclarativeborderimage.moc"
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml
new file mode 100644
index 0000000000..81ab599276
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ id: screen; width: 50
+
+ property bool tested: false
+ signal testMe
+
+ Connections { target: screen; onWidthChanged: screen.tested = true }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml
new file mode 100644
index 0000000000..22e9422561
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml
@@ -0,0 +1,3 @@
+import Qt 4.6
+
+Connections { id: connection; target: connection; onTargetChanged: 1 == 1 }
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml
new file mode 100644
index 0000000000..6e396c0be1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml
@@ -0,0 +1,3 @@
+import Qt 4.6
+
+Connections {}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml
new file mode 100644
index 0000000000..736d5e870d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ id: screen; width: 50
+
+ property string tested
+ signal testMe(int param1, string param2)
+
+ Connections { target: screen; onTestMe: screen.tested = param2 + param1 }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
new file mode 100644
index 0000000000..a6adfa4523
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeconnection.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
new file mode 100644
index 0000000000..f4914e172f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeconnections_p.h>
+#include <private/qdeclarativeitem_p.h>
+#include "../../../shared/util.h"
+#include <QtDeclarative/qdeclarativescriptstring.h>
+
+class tst_qdeclarativeconnection : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeconnection();
+
+private slots:
+ void defaultValues();
+ void properties();
+ void connection();
+ void trimming();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeconnection::tst_qdeclarativeconnection()
+{
+}
+
+void tst_qdeclarativeconnection::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml"));
+ QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
+
+ QVERIFY(item != 0);
+ QVERIFY(item->target() == 0);
+
+ delete item;
+}
+
+void tst_qdeclarativeconnection::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml"));
+ QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QVERIFY(item != 0);
+ QVERIFY(item->target() == item);
+
+ delete item;
+}
+
+void tst_qdeclarativeconnection::connection()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QCOMPARE(item->property("tested").toBool(), false);
+ QCOMPARE(item->width(), 50.);
+ emit item->setWidth(100.);
+ QCOMPARE(item->width(), 100.);
+ QCOMPARE(item->property("tested").toBool(), true);
+
+ delete item;
+}
+
+void tst_qdeclarativeconnection::trimming()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QCOMPARE(item->property("tested").toString(), QString(""));
+ int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
+ QMetaMethod method = item->metaObject()->method(index);
+ method.invoke(item,
+ Qt::DirectConnection,
+ Q_ARG(int, 5),
+ Q_ARG(QString, "worked"));
+ QCOMPARE(item->property("tested").toString(), QString("worked5"));
+
+ delete item;
+}
+
+QTEST_MAIN(tst_qdeclarativeconnection)
+
+#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
new file mode 100644
index 0000000000..adace7065d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativecontext.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
new file mode 100644
index 0000000000..5f03989930
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
@@ -0,0 +1,434 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDebug>
+#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
+#include <QDeclarativeComponent>
+#include <QDeclarativeExpression>
+
+class tst_qdeclarativecontext : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativecontext() {}
+
+private slots:
+ void baseUrl();
+ void resolvedUrl();
+ void engineMethod();
+ void parentContext();
+ void setContextProperty();
+ void addDefaultObject();
+ void destruction();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativecontext::baseUrl()
+{
+ QDeclarativeContext ctxt(&engine);
+
+ QCOMPARE(ctxt.baseUrl(), QUrl());
+
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
+}
+
+void tst_qdeclarativecontext::resolvedUrl()
+{
+ // Relative to the component
+ {
+ QDeclarativeContext ctxt(&engine);
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml"));
+ }
+
+ // Relative to a parent
+ {
+ QDeclarativeContext ctxt(&engine);
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QDeclarativeContext ctxt2(&ctxt);
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+ }
+
+ // Relative to the engine
+ {
+ QDeclarativeContext ctxt(&engine);
+ QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
+ }
+
+ // Relative to a deleted parent
+ {
+ QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
+ ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QDeclarativeContext ctxt2(ctxt);
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl());
+ }
+
+ // Absolute
+ {
+ QDeclarativeContext ctxt(&engine);
+
+ QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+ QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml"));
+ }
+}
+
+void tst_qdeclarativecontext::engineMethod()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+
+ QDeclarativeContext ctxt(engine);
+ QDeclarativeContext ctxt2(&ctxt);
+ QDeclarativeContext ctxt3(&ctxt2);
+ QDeclarativeContext ctxt4(&ctxt2);
+
+ QCOMPARE(ctxt.engine(), engine);
+ QCOMPARE(ctxt2.engine(), engine);
+ QCOMPARE(ctxt3.engine(), engine);
+ QCOMPARE(ctxt4.engine(), engine);
+
+ delete engine; engine = 0;
+
+ QCOMPARE(ctxt.engine(), engine);
+ QCOMPARE(ctxt2.engine(), engine);
+ QCOMPARE(ctxt3.engine(), engine);
+ QCOMPARE(ctxt4.engine(), engine);
+}
+
+void tst_qdeclarativecontext::parentContext()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+
+ QCOMPARE(engine->rootContext()->parentContext(), (QDeclarativeContext *)0);
+
+ QDeclarativeContext *ctxt = new QDeclarativeContext(engine);
+ QDeclarativeContext *ctxt2 = new QDeclarativeContext(ctxt);
+ QDeclarativeContext *ctxt3 = new QDeclarativeContext(ctxt2);
+ QDeclarativeContext *ctxt4 = new QDeclarativeContext(ctxt2);
+ QDeclarativeContext *ctxt5 = new QDeclarativeContext(ctxt);
+ QDeclarativeContext *ctxt6 = new QDeclarativeContext(engine);
+ QDeclarativeContext *ctxt7 = new QDeclarativeContext(engine->rootContext());
+
+ QCOMPARE(ctxt->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt2->parentContext(), ctxt);
+ QCOMPARE(ctxt3->parentContext(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt7->parentContext(), engine->rootContext());
+
+ delete ctxt2; ctxt2 = 0;
+
+ QCOMPARE(ctxt->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt3->parentContext(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt7->parentContext(), engine->rootContext());
+
+ delete engine; engine = 0;
+
+ QCOMPARE(ctxt->parentContext(), (QDeclarativeContext *)0);
+ QCOMPARE(ctxt3->parentContext(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), (QDeclarativeContext *)0);
+ QCOMPARE(ctxt7->parentContext(), (QDeclarativeContext *)0);
+
+ delete ctxt7;
+ delete ctxt6;
+ delete ctxt5;
+ delete ctxt4;
+ delete ctxt3;
+ delete ctxt;
+}
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int a READ a NOTIFY aChanged)
+ Q_PROPERTY(int b READ b NOTIFY bChanged)
+ Q_PROPERTY(int c READ c NOTIFY cChanged)
+
+public:
+ TestObject() : _a(10), _b(10), _c(10) {}
+
+ int a() const { return _a; }
+ void setA(int a) { _a = a; emit aChanged(); }
+
+ int b() const { return _b; }
+ void setB(int b) { _b = b; emit bChanged(); }
+
+ int c() const { return _c; }
+ void setC(int c) { _c = c; emit cChanged(); }
+
+signals:
+ void aChanged();
+ void bChanged();
+ void cChanged();
+
+private:
+ int _a;
+ int _b;
+ int _c;
+};
+
+class TestObject2 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int b READ b NOTIFY bChanged)
+
+public:
+ TestObject2() : _b(10) {}
+
+ int b() const { return _b; }
+ void setB(int b) { _b = b; emit bChanged(); }
+
+signals:
+ void bChanged();
+
+private:
+ int _b;
+};
+
+#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
+{ \
+ QDeclarativeComponent component(&engine); \
+ component.setData("import Qt 4.6; QtObject { property var test: " #name " }", QUrl()); \
+\
+ QObject *obj = component.create(ctxt); \
+\
+ QCOMPARE(obj->property("test"), value); \
+\
+ delete obj; \
+}
+
+void tst_qdeclarativecontext::setContextProperty()
+{
+ QDeclarativeContext ctxt(&engine);
+ QDeclarativeContext ctxt2(&ctxt);
+
+ TestObject obj1;
+ obj1.setA(3345);
+ TestObject obj2;
+ obj2.setA(-19);
+
+ // Static context properties
+ ctxt.setContextProperty("a", QVariant(10));
+ ctxt.setContextProperty("b", QVariant(9));
+ ctxt2.setContextProperty("d", &obj2);
+ ctxt2.setContextProperty("b", QVariant(19));
+ ctxt2.setContextProperty("c", QVariant(QString("Hello World!")));
+ ctxt.setContextProperty("d", &obj1);
+ ctxt.setContextProperty("e", &obj1);
+
+ TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10));
+ TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19));
+ TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!")));
+ TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19));
+ TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345));
+
+ ctxt.setContextProperty("a", QVariant(13));
+ ctxt.setContextProperty("b", QVariant(4));
+ ctxt2.setContextProperty("b", QVariant(8));
+ ctxt2.setContextProperty("c", QVariant(QString("Hi World!")));
+ ctxt2.setContextProperty("d", &obj1);
+ obj1.setA(12);
+
+ TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13));
+ TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8));
+ TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!")));
+ TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12));
+
+ // Changes in context properties
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(13));
+ ctxt.setContextProperty("a", QVariant(19));
+ QCOMPARE(obj->property("test"), QVariant(19));
+
+ delete obj;
+ }
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var test: b }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(8));
+ ctxt.setContextProperty("b", QVariant(5));
+ QCOMPARE(obj->property("test"), QVariant(8));
+ ctxt2.setContextProperty("b", QVariant(1912));
+ QCOMPARE(obj->property("test"), QVariant(1912));
+
+ delete obj;
+ }
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var test: e.a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(12));
+ obj1.setA(13);
+ QCOMPARE(obj->property("test"), QVariant(13));
+
+ delete obj;
+ }
+
+ // New context properties
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(19));
+ ctxt2.setContextProperty("a", QVariant(1945));
+ QCOMPARE(obj->property("test"), QVariant(1945));
+
+ delete obj;
+ }
+
+ // Setting an object-variant context property
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property var obj: root; }", QUrl());
+
+ QDeclarativeContext ctxt(engine.rootContext());
+ ctxt.setContextProperty("ctxtProp", QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Result of expression 'ctxtProp' [undefined] is not an object.");
+ QObject *obj = component.create(&ctxt);
+
+ QVariant v = obj->property("obj");
+
+ ctxt.setContextProperty("ctxtProp", v);
+
+ QCOMPARE(obj->property("test"), QVariant(10));
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativecontext::addDefaultObject()
+{
+ QDeclarativeContext ctxt(&engine);
+
+ TestObject to;
+ TestObject2 to2;
+
+ to.setA(2);
+ to.setB(192);
+ to.setC(18);
+ to2.setB(111999);
+
+ ctxt.addDefaultObject(&to2);
+ ctxt.addDefaultObject(&to);
+ ctxt.setContextProperty("c", QVariant(9));
+
+ // Static context properties
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(111999));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
+
+ to.setA(12);
+ to.setB(100);
+ to.setC(7);
+ to2.setB(1612);
+ ctxt.setContextProperty("c", QVariant(3));
+
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(1612));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
+
+ // Changes in context properties
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt);
+
+ QCOMPARE(obj->property("test"), QVariant(12));
+ to.setA(14);
+ QCOMPARE(obj->property("test"), QVariant(14));
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativecontext::destruction()
+{
+ QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
+
+ QObject obj;
+ QDeclarativeEngine::setContextForObject(&obj, ctxt);
+ QDeclarativeExpression expr(ctxt, "a", 0);
+
+ QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+}
+
+QTEST_MAIN(tst_qdeclarativecontext)
+
+#include "tst_qdeclarativecontext.moc"
diff --git a/tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro b/tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro
new file mode 100644
index 0000000000..22f53e6d99
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedatetimeformatter/qdeclarativedatetimeformatter.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativedatetimeformatter.cpp
diff --git a/tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp b/tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp
new file mode 100644
index 0000000000..69d7900ebe
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedatetimeformatter/tst_qdeclarativedatetimeformatter.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativedatetimeformatter_p.h>
+#include <QDebug>
+
+class tst_qdeclarativedatetimeformatter : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativedatetimeformatter() {}
+
+private slots:
+ void date();
+ void time();
+ void dateTime();
+};
+
+void tst_qdeclarativedatetimeformatter::date()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData(QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
+ QUrl::fromLocalFile(""));
+ QDeclarativeDateTimeFormatter *formatter = qobject_cast<QDeclarativeDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatter != 0);
+
+ QDate date(2008,12,24);
+ QCOMPARE(formatter->date(), date);
+ QCOMPARE(formatter->dateTime().date(), date);
+ QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QVERIFY(formatter->longStyle());
+ QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setDateFormat("ddd MMMM d yy");
+ QCOMPARE(formatter->dateFormat(), QLatin1String("ddd MMMM d yy"));
+ QCOMPARE(formatter->dateText(),date.toString("ddd MMMM d yy"));
+
+ QVERIFY(formatter->timeText().isEmpty());
+ QVERIFY(formatter->dateTimeText().isEmpty());
+
+ delete formatter;
+}
+
+void tst_qdeclarativedatetimeformatter::time()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl::fromLocalFile(""));
+ QDeclarativeDateTimeFormatter *formatter = qobject_cast<QDeclarativeDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatter != 0);
+
+ QTime time(14,15,38,200);
+
+ QCOMPARE(formatter->time(),time);
+ QCOMPARE(formatter->dateTime().time(),time);
+
+ QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setTimeFormat("H:m:s a");
+ QCOMPARE(formatter->timeFormat(), QLatin1String("H:m:s a"));
+ QCOMPARE(formatter->timeText(),time.toString("H:m:s a"));
+
+ formatter->setTimeFormat("hh:mm:ss.zzz");
+ QCOMPARE(formatter->timeText(),time.toString("hh:mm:ss.zzz"));
+
+ QVERIFY(formatter->dateText().isEmpty());
+ QVERIFY(formatter->dateTimeText().isEmpty());
+
+ delete formatter;
+}
+
+void tst_qdeclarativedatetimeformatter::dateTime()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl::fromLocalFile(""));
+ QDeclarativeDateTimeFormatter *formatter = qobject_cast<QDeclarativeDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatter != 0);
+
+ QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
+ QCOMPARE(formatter->dateTime(),dateTime);
+ QCOMPARE(formatter->date(),dateTime.date());
+ QCOMPARE(formatter->time(),dateTime.time());
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleShortDate));
+
+ formatter->setLongStyle(true);
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleLongDate));
+
+ formatter->setDateTimeFormat("M/d/yy H:m:s a");
+ QCOMPARE(formatter->dateTimeFormat(), QLatin1String("M/d/yy H:m:s a"));
+ QCOMPARE(formatter->dateTimeText(),dateTime.toString("M/d/yy H:m:s a"));
+
+ delete formatter;
+}
+
+QTEST_MAIN(tst_qdeclarativedatetimeformatter)
+
+#include "tst_qdeclarativedatetimeformatter.moc"
diff --git a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
new file mode 100644
index 0000000000..ff1d0d4be5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qdeclarativedebug.cpp \
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
new file mode 100644
index 0000000000..0c3ca765bd
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -0,0 +1,843 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
+
+#include <private/qdeclarativebinding_p.h>
+#include <private/qdeclarativedebug_p.h>
+#include <private/qdeclarativeenginedebug_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativemetatype_p.h>
+#include <private/qdeclarativeproperty_p.h>
+
+#include "../shared/debugutil_p.h"
+
+Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State)
+
+
+class tst_QDeclarativeDebug : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDeclarativeDebug(QDeclarativeDebugTestData *data)
+ {
+ m_conn = data->conn;
+ m_engine = data->engine;
+ m_rootItem = data->items[0];
+ }
+
+private:
+ QDeclarativeDebugObjectReference findRootObject();
+ QDeclarativeDebugPropertyReference findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const;
+ void waitForQuery(QDeclarativeDebugQuery *query);
+
+ void recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const;
+
+ void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const;
+ void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const;
+ void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const;
+
+ QDeclarativeDebugConnection *m_conn;
+ QDeclarativeEngineDebug *m_dbg;
+ QDeclarativeEngine *m_engine;
+ QDeclarativeItem *m_rootItem;
+
+private slots:
+ void initTestCase();
+
+ void watch_property();
+ void watch_object();
+ void watch_expression();
+ void watch_expression_data();
+ void watch_context();
+ void watch_file();
+
+ void queryAvailableEngines();
+ void queryRootContexts();
+ void queryObject();
+ void queryObject_data();
+ void queryExpressionResult();
+ void queryExpressionResult_data();
+
+ void tst_QDeclarativeDebugFileReference();
+ void tst_QDeclarativeDebugEngineReference();
+ void tst_QDeclarativeDebugObjectReference();
+ void tst_QDeclarativeDebugContextReference();
+ void tst_QDeclarativeDebugPropertyReference();
+};
+
+QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject()
+{
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ if (q_engines->engines().count() == 0)
+ return QDeclarativeDebugObjectReference();
+ QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ if (q_context->rootContext().objects().count() == 0)
+ return QDeclarativeDebugObjectReference();
+ QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
+ waitForQuery(q_obj);
+
+ QDeclarativeDebugObjectReference result = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ return result;
+}
+
+QDeclarativeDebugPropertyReference tst_QDeclarativeDebug::findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const
+{
+ foreach(const QDeclarativeDebugPropertyReference &p, props) {
+ if (p.name() == name)
+ return p;
+ }
+ return QDeclarativeDebugPropertyReference();
+}
+
+void tst_QDeclarativeDebug::waitForQuery(QDeclarativeDebugQuery *query)
+{
+ QVERIFY(query);
+ QCOMPARE(query->parent(), this);
+ QVERIFY(query->state() == QDeclarativeDebugQuery::Waiting);
+ if (!QDeclarativeDebugTest::waitForSignal(query, SIGNAL(stateChanged(QDeclarativeDebugQuery::State))))
+ QFAIL("query timed out");
+}
+
+void tst_QDeclarativeDebug::recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const
+{
+ const QMetaObject *meta = o->metaObject();
+
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(o->metaObject());
+ QString className = type ? type->qmlTypeName() : QString();
+ className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
+
+ QCOMPARE(oref.debugId(), QDeclarativeDebugService::idForObject(o));
+ QCOMPARE(oref.name(), o->objectName());
+ QCOMPARE(oref.className(), className);
+ QCOMPARE(oref.contextDebugId(), QDeclarativeDebugService::idForObject(qmlContext(o)));
+
+ const QObjectList &children = o->children();
+ for (int i=0; i<children.count(); i++) {
+ QObject *child = children[i];
+ if (!qmlContext(child))
+ continue;
+ int debugId = QDeclarativeDebugService::idForObject(child);
+ QVERIFY(debugId >= 0);
+
+ QDeclarativeDebugObjectReference cref;
+ foreach (const QDeclarativeDebugObjectReference &ref, oref.children()) {
+ if (ref.debugId() == debugId) {
+ cref = ref;
+ break;
+ }
+ }
+ QVERIFY(cref.debugId() >= 0);
+
+ if (recursive)
+ recursiveObjectTest(child, cref, true);
+ }
+
+ foreach (const QDeclarativeDebugPropertyReference &p, oref.properties()) {
+ QCOMPARE(p.objectDebugId(), QDeclarativeDebugService::idForObject(o));
+
+ // signal properties are fake - they are generated from QDeclarativeBoundSignal children
+ if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
+ QVERIFY(p.value().toString().startsWith('{') && p.value().toString().endsWith('}'));
+ QVERIFY(p.valueTypeName().isEmpty());
+ QVERIFY(p.binding().isEmpty());
+ QVERIFY(!p.hasNotifySignal());
+ continue;
+ }
+
+ QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
+
+ QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
+
+ if (pmeta.type() < QVariant::UserType) // TODO test complex types
+ QCOMPARE(p.value(), pmeta.read(o));
+
+ if (p.name() == "parent")
+ QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QDeclarativeItem*");
+ else
+ QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
+
+ QDeclarativeAbstractBinding *binding =
+ QDeclarativePropertyPrivate::binding(QDeclarativeProperty(o, p.name()));
+ if (binding)
+ QCOMPARE(binding->expression(), p.binding());
+
+ QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
+
+ QVERIFY(pmeta.isValid());
+ }
+}
+
+void tst_QDeclarativeDebug::recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const
+{
+ QCOMPARE(a.debugId(), b.debugId());
+ QCOMPARE(a.className(), b.className());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.contextDebugId(), b.contextDebugId());
+
+ QCOMPARE(a.source().url(), b.source().url());
+ QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
+ QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
+
+ QCOMPARE(a.properties().count(), b.properties().count());
+ QCOMPARE(a.children().count(), b.children().count());
+
+ QList<QDeclarativeDebugPropertyReference> aprops = a.properties();
+ QList<QDeclarativeDebugPropertyReference> bprops = b.properties();
+
+ for (int i=0; i<aprops.count(); i++)
+ compareProperties(aprops[i], bprops[i]);
+
+ for (int i=0; i<a.children().count(); i++)
+ recursiveCompareObjects(a.children()[i], b.children()[i]);
+}
+
+void tst_QDeclarativeDebug::recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const
+{
+ QCOMPARE(a.debugId(), b.debugId());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.objects().count(), b.objects().count());
+ QCOMPARE(a.contexts().count(), b.contexts().count());
+
+ for (int i=0; i<a.objects().count(); i++)
+ recursiveCompareObjects(a.objects()[i], b.objects()[i]);
+
+ for (int i=0; i<a.contexts().count(); i++)
+ recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
+}
+
+void tst_QDeclarativeDebug::compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const
+{
+ QCOMPARE(a.objectDebugId(), b.objectDebugId());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.value(), b.value());
+ QCOMPARE(a.valueTypeName(), b.valueTypeName());
+ QCOMPARE(a.binding(), b.binding());
+ QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
+}
+
+void tst_QDeclarativeDebug::initTestCase()
+{
+ m_dbg = new QDeclarativeEngineDebug(m_conn, this);
+
+ qRegisterMetaType<QDeclarativeDebugWatch::State>();
+}
+
+void tst_QDeclarativeDebug::watch_property()
+{
+ QDeclarativeDebugObjectReference obj = findRootObject();
+ QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
+
+ QDeclarativeDebugPropertyWatch *watch;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ watch = unconnected->addWatch(prop, this);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QDeclarativeDebugPropertyReference(), this);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(prop, this);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+ QCOMPARE(watch->name(), prop.name());
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+
+ int origWidth = m_rootItem->property("width").toInt();
+ m_rootItem->setProperty("width", origWidth*2);
+
+ // stateChanged() is received before valueChanged()
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
+ QCOMPARE(spy.count(), 1);
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // restore original value and verify spy doesn't get additional signal since watch has been removed
+ m_rootItem->setProperty("width", origWidth);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
+ QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
+}
+
+void tst_QDeclarativeDebug::watch_object()
+{
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ Q_ASSERT(q_engines->engines().count() > 0);
+ QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ Q_ASSERT(q_context->rootContext().objects().count() > 0);
+ QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
+ waitForQuery(q_obj);
+
+ QDeclarativeDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ QDeclarativeDebugWatch *watch;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ watch = unconnected->addWatch(obj, this);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(obj, this);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+
+ int origWidth = m_rootItem->property("width").toInt();
+ int origHeight = m_rootItem->property("height").toInt();
+ m_rootItem->setProperty("width", origWidth*2);
+ m_rootItem->setProperty("height", origHeight*2);
+
+ // stateChanged() is received before any valueChanged() signals
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
+ QVERIFY(spy.count() > 0);
+
+ int newWidth = -1;
+ int newHeight = -1;
+ for (int i=0; i<spy.count(); i++) {
+ const QVariantList &values = spy[i];
+ if (values[0].value<QByteArray>() == "width")
+ newWidth = values[1].value<QVariant>().toInt();
+ else if (values[0].value<QByteArray>() == "height")
+ newHeight = values[1].value<QVariant>().toInt();
+
+ }
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // since watch has been removed, restoring the original values should not trigger a valueChanged()
+ spy.clear();
+ m_rootItem->setProperty("width", origWidth);
+ m_rootItem->setProperty("height", origHeight);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 0);
+
+ QCOMPARE(newWidth, origWidth * 2);
+ QCOMPARE(newHeight, origHeight * 2);
+}
+
+void tst_QDeclarativeDebug::watch_expression()
+{
+ QFETCH(QString, expr);
+ QFETCH(int, increment);
+ QFETCH(int, incrementCount);
+
+ int origWidth = m_rootItem->property("width").toInt();
+
+ QDeclarativeDebugObjectReference obj = findRootObject();
+
+ QDeclarativeDebugObjectExpressionWatch *watch;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ watch = unconnected->addWatch(obj, expr, this);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this);
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(obj, expr, this);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+ QCOMPARE(watch->expression(), expr);
+
+ QSignalSpy spyState(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)));
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+ int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
+
+ int width = origWidth;
+ for (int i=0; i<incrementCount+1; i++) {
+ if (i > 0) {
+ width += increment;
+ m_rootItem->setProperty("width", width);
+ }
+ if (!QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
+ QFAIL("Did not receive valueChanged() for expression");
+ }
+
+ if (spyState.count() == 0)
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
+ QCOMPARE(spyState.count(), 1);
+ QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // restore original value and verify spy doesn't get a signal since watch has been removed
+ m_rootItem->setProperty("width", origWidth);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), expectedSpyCount);
+
+ width = origWidth + increment;
+ for (int i=0; i<spy.count(); i++) {
+ QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
+ width += increment;
+ }
+}
+
+void tst_QDeclarativeDebug::watch_expression_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<int>("increment");
+ QTest::addColumn<int>("incrementCount");
+
+ QTest::newRow("width") << "width" << 0 << 0;
+ QTest::newRow("width+10") << "width + 10" << 10 << 5;
+}
+
+void tst_QDeclarativeDebug::watch_context()
+{
+ QDeclarativeDebugContextReference c;
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(c, QString(), this));
+}
+
+void tst_QDeclarativeDebug::watch_file()
+{
+ QDeclarativeDebugFileReference f;
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(f, this));
+}
+
+void tst_QDeclarativeDebug::queryAvailableEngines()
+{
+ QDeclarativeDebugEnginesQuery *q_engines;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ q_engines = unconnected->queryAvailableEngines(0);
+ QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Error);
+ delete q_engines;
+ delete unconnected;
+
+ q_engines = m_dbg->queryAvailableEngines(this);
+ delete q_engines;
+
+ q_engines = m_dbg->queryAvailableEngines(this);
+ QVERIFY(q_engines->engines().isEmpty());
+ waitForQuery(q_engines);
+
+ // TODO test multiple engines
+ QList<QDeclarativeDebugEngineReference> engines = q_engines->engines();
+ QCOMPARE(engines.count(), 1);
+
+ foreach(const QDeclarativeDebugEngineReference &e, engines) {
+ QCOMPARE(e.debugId(), QDeclarativeDebugService::idForObject(m_engine));
+ QCOMPARE(e.name(), m_engine->objectName());
+ }
+
+ delete q_engines;
+}
+
+void tst_QDeclarativeDebug::queryRootContexts()
+{
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ int engineId = q_engines->engines()[0].debugId();
+
+ QDeclarativeDebugRootContextQuery *q_context;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ q_context = unconnected->queryRootContexts(engineId, this);
+ QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
+ delete q_context;
+ delete unconnected;
+
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ delete q_context;
+
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ waitForQuery(q_context);
+
+ QDeclarativeContext *actualContext = m_engine->rootContext();
+ QDeclarativeDebugContextReference context = q_context->rootContext();
+ QCOMPARE(context.debugId(), QDeclarativeDebugService::idForObject(actualContext));
+ QCOMPARE(context.name(), actualContext->objectName());
+
+ QCOMPARE(context.objects().count(), 2); // 2 qml component objects created for context in main()
+
+ // root context query sends only root object data - it doesn't fill in
+ // the children or property info
+ QCOMPARE(context.objects()[0].properties().count(), 0);
+ QCOMPARE(context.objects()[0].children().count(), 0);
+
+ QCOMPARE(context.contexts().count(), 1);
+ QVERIFY(context.contexts()[0].debugId() >= 0);
+ QCOMPARE(context.contexts()[0].name(), QString("tst_QDeclarativeDebug_childContext"));
+
+ delete q_engines;
+ delete q_context;
+}
+
+void tst_QDeclarativeDebug::queryObject()
+{
+ QFETCH(bool, recursive);
+
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+ QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
+
+ QDeclarativeDebugObjectQuery *q_obj = 0;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
+ QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Error);
+ delete q_obj;
+ delete unconnected;
+
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ delete q_obj;
+
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ waitForQuery(q_obj);
+
+ QDeclarativeDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ // check source as defined in main()
+ QDeclarativeDebugFileReference source = obj.source();
+ QCOMPARE(source.url(), QUrl::fromLocalFile(""));
+ QCOMPARE(source.lineNumber(), 2);
+ QCOMPARE(source.columnNumber(), 1);
+
+ // generically test all properties, children and childrens' properties
+ recursiveObjectTest(m_rootItem, obj, recursive);
+
+ if (recursive) {
+ foreach(const QDeclarativeDebugObjectReference &child, obj.children())
+ QVERIFY(child.properties().count() > 0);
+
+ QDeclarativeDebugObjectReference rect;
+ QDeclarativeDebugObjectReference text;
+ foreach (const QDeclarativeDebugObjectReference &child, obj.children()) {
+ if (child.className() == "Rectangle")
+ rect = child;
+ else if (child.className() == "Text")
+ text = child;
+ }
+
+ // test specific property values
+ QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
+ QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
+ QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+
+ QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+
+ } else {
+ foreach(const QDeclarativeDebugObjectReference &child, obj.children())
+ QCOMPARE(child.properties().count(), 0);
+ }
+}
+
+void tst_QDeclarativeDebug::queryObject_data()
+{
+ QTest::addColumn<bool>("recursive");
+
+ QTest::newRow("non-recursive") << false;
+ QTest::newRow("recursive") << true;
+}
+
+void tst_QDeclarativeDebug::queryExpressionResult()
+{
+ QFETCH(QString, expr);
+ QFETCH(QVariant, result);
+
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines); // check immediate deletion is ok
+
+ QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+ int objectId = q_context->rootContext().objects()[0].debugId();
+
+ QDeclarativeDebugExpressionQuery *q_expr;
+
+ QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
+ q_expr = unconnected->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
+ delete q_expr;
+ delete unconnected;
+
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ delete q_expr;
+
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->expression(), expr);
+ waitForQuery(q_expr);
+
+ QCOMPARE(q_expr->result(), result);
+
+ delete q_engines;
+ delete q_context;
+ delete q_expr;
+}
+
+void tst_QDeclarativeDebug::queryExpressionResult_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<QVariant>("result");
+
+ QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
+ QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
+ QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
+}
+
+void tst_QDeclarativeDebug::tst_QDeclarativeDebugFileReference()
+{
+ QDeclarativeDebugFileReference ref;
+ QVERIFY(ref.url().isEmpty());
+ QCOMPARE(ref.lineNumber(), -1);
+ QCOMPARE(ref.columnNumber(), -1);
+
+ ref.setUrl(QUrl("http://test"));
+ QCOMPARE(ref.url(), QUrl("http://test"));
+ ref.setLineNumber(1);
+ QCOMPARE(ref.lineNumber(), 1);
+ ref.setColumnNumber(1);
+ QCOMPARE(ref.columnNumber(), 1);
+
+ QDeclarativeDebugFileReference copy(ref);
+ QDeclarativeDebugFileReference copyAssign;
+ copyAssign = ref;
+ foreach (const QDeclarativeDebugFileReference &r, (QList<QDeclarativeDebugFileReference>() << copy << copyAssign)) {
+ QCOMPARE(r.url(), ref.url());
+ QCOMPARE(r.lineNumber(), ref.lineNumber());
+ QCOMPARE(r.columnNumber(), ref.columnNumber());
+ }
+}
+
+void tst_QDeclarativeDebug::tst_QDeclarativeDebugEngineReference()
+{
+ QDeclarativeDebugEngineReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QVERIFY(ref.name().isEmpty());
+
+ ref = QDeclarativeDebugEngineReference(1);
+ QCOMPARE(ref.debugId(), 1);
+ QVERIFY(ref.name().isEmpty());
+
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ ref = q_engines->engines()[0];
+ delete q_engines;
+
+ QDeclarativeDebugEngineReference copy(ref);
+ QDeclarativeDebugEngineReference copyAssign;
+ copyAssign = ref;
+ foreach (const QDeclarativeDebugEngineReference &r, (QList<QDeclarativeDebugEngineReference>() << copy << copyAssign)) {
+ QCOMPARE(r.debugId(), ref.debugId());
+ QCOMPARE(r.name(), ref.name());
+ }
+}
+
+void tst_QDeclarativeDebug::tst_QDeclarativeDebugObjectReference()
+{
+ QDeclarativeDebugObjectReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QCOMPARE(ref.className(), QString());
+ QCOMPARE(ref.name(), QString());
+ QCOMPARE(ref.contextDebugId(), -1);
+ QVERIFY(ref.properties().isEmpty());
+ QVERIFY(ref.children().isEmpty());
+
+ QDeclarativeDebugFileReference source = ref.source();
+ QVERIFY(source.url().isEmpty());
+ QVERIFY(source.lineNumber() < 0);
+ QVERIFY(source.columnNumber() < 0);
+
+ ref = QDeclarativeDebugObjectReference(1);
+ QCOMPARE(ref.debugId(), 1);
+
+ QDeclarativeDebugObjectReference rootObject = findRootObject();
+ QDeclarativeDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
+ waitForQuery(query);
+ ref = query->object();
+ delete query;
+
+ QVERIFY(ref.debugId() >= 0);
+
+ QDeclarativeDebugObjectReference copy(ref);
+ QDeclarativeDebugObjectReference copyAssign;
+ copyAssign = ref;
+ foreach (const QDeclarativeDebugObjectReference &r, (QList<QDeclarativeDebugObjectReference>() << copy << copyAssign))
+ recursiveCompareObjects(r, ref);
+}
+
+void tst_QDeclarativeDebug::tst_QDeclarativeDebugContextReference()
+{
+ QDeclarativeDebugContextReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QVERIFY(ref.name().isEmpty());
+ QVERIFY(ref.objects().isEmpty());
+ QVERIFY(ref.contexts().isEmpty());
+
+ QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ ref = q_context->rootContext();
+ delete q_engines;
+ delete q_context;
+ QVERIFY(ref.debugId() >= 0);
+
+ QDeclarativeDebugContextReference copy(ref);
+ QDeclarativeDebugContextReference copyAssign;
+ copyAssign = ref;
+ foreach (const QDeclarativeDebugContextReference &r, (QList<QDeclarativeDebugContextReference>() << copy << copyAssign))
+ recursiveCompareContexts(r, ref);
+}
+
+void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
+{
+ QDeclarativeDebugObjectReference rootObject = findRootObject();
+ QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
+ waitForQuery(query);
+ QDeclarativeDebugObjectReference obj = query->object();
+ delete query;
+
+ QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
+ QVERIFY(ref.objectDebugId() > 0);
+ QVERIFY(!ref.name().isEmpty());
+ QVERIFY(!ref.value().isNull());
+ QVERIFY(!ref.valueTypeName().isEmpty());
+ QVERIFY(!ref.binding().isEmpty());
+ QVERIFY(ref.hasNotifySignal());
+
+ QDeclarativeDebugPropertyReference copy(ref);
+ QDeclarativeDebugPropertyReference copyAssign;
+ copyAssign = ref;
+ foreach (const QDeclarativeDebugPropertyReference &r, (QList<QDeclarativeDebugPropertyReference>() << copy << copyAssign))
+ compareProperties(r, ref);
+}
+
+
+class tst_QDeclarativeDebug_Factory : public QDeclarativeTestFactory
+{
+public:
+ QObject *createTest(QDeclarativeDebugTestData *data)
+ {
+ tst_QDeclarativeDebug *test = new tst_QDeclarativeDebug(data);
+ QDeclarativeContext *c = new QDeclarativeContext(data->engine->rootContext(), test);
+ c->setObjectName("tst_QDeclarativeDebug_childContext");
+ return test;
+ }
+};
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QList<QByteArray> qml;
+ qml << "import Qt 4.6\n"
+ "Item {"
+ "width: 10; height: 20; scale: blueRect.scale;"
+ "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
+ "Text { color: blueRect.color; }"
+ "MouseArea {"
+ "onEntered: { console.log('hello') }"
+ "}"
+ "}";
+ // add second component to test multiple root contexts
+ qml << "import Qt 4.6\n"
+ "Item {}";
+ tst_QDeclarativeDebug_Factory factory;
+ return QDeclarativeDebugTest::runTests(&factory, qml);
+}
+
+//QTEST_MAIN(tst_QDeclarativeDebug)
+
+#include "tst_qdeclarativedebug.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro
new file mode 100644
index 0000000000..a3afd990a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qdeclarativedebugclient.cpp \
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
new file mode 100644
index 0000000000..d3679a73f8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+
+#include <private/qdeclarativedebug_p.h>
+#include <private/qdeclarativeenginedebug_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+
+#include "../shared/debugutil_p.h"
+
+class tst_QDeclarativeDebugClient : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDeclarativeDebugClient(QDeclarativeDebugTestData *data)
+ {
+ m_conn = data->conn;
+ }
+
+ QDeclarativeDebugConnection *m_conn;
+
+private slots:
+ void name();
+ void isEnabled();
+ void setEnabled();
+ void isConnected();
+ void sendMessage();
+};
+
+void tst_QDeclarativeDebugClient::name()
+{
+ QString name = "tst_QDeclarativeDebugClient::name()";
+
+ QDeclarativeDebugClient client(name, m_conn);
+ QCOMPARE(client.name(), name);
+}
+
+void tst_QDeclarativeDebugClient::isEnabled()
+{
+ QDeclarativeDebugClient client("tst_QDeclarativeDebugClient::isEnabled()", m_conn);
+ QCOMPARE(client.isEnabled(), false);
+}
+
+void tst_QDeclarativeDebugClient::setEnabled()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::setEnabled()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::setEnabled()", m_conn);
+
+ QCOMPARE(service.isEnabled(), false);
+
+ client.setEnabled(true);
+ QCOMPARE(client.isEnabled(), true);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.isEnabled(), true);
+
+ client.setEnabled(false);
+ QCOMPARE(client.isEnabled(), false);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.isEnabled(), false);
+}
+
+void tst_QDeclarativeDebugClient::isConnected()
+{
+ QDeclarativeDebugClient client1("tst_QDeclarativeDebugClient::isConnected() A", m_conn);
+ QCOMPARE(client1.isConnected(), true);
+
+ QDeclarativeDebugConnection conn;
+ QDeclarativeDebugClient client2("tst_QDeclarativeDebugClient::isConnected() B", &conn);
+ QCOMPARE(client2.isConnected(), false);
+
+ QDeclarativeDebugClient client3("tst_QDeclarativeDebugClient::isConnected() C", 0);
+ QCOMPARE(client3.isConnected(), false);
+
+ // duplicate plugin name
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugClient: Conflicting plugin name \"tst_QDeclarativeDebugClient::isConnected() A\" ");
+ QDeclarativeDebugClient client4("tst_QDeclarativeDebugClient::isConnected() A", m_conn);
+ QCOMPARE(client4.isConnected(), false);
+}
+
+void tst_QDeclarativeDebugClient::sendMessage()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::sendMessage()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+}
+
+
+class tst_QDeclarativeDebugClient_Factory : public QDeclarativeTestFactory
+{
+public:
+ QObject *createTest(QDeclarativeDebugTestData *data) { return new tst_QDeclarativeDebugClient(data); }
+};
+
+
+// This does not use QTEST_MAIN because the test has to be created and run
+// in a separate thread.
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ tst_QDeclarativeDebugClient_Factory factory;
+ return QDeclarativeDebugTest::runTests(&factory);
+}
+
+#include "tst_qdeclarativedebugclient.moc"
diff --git a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
new file mode 100644
index 0000000000..e37588954e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qdeclarativedebugservice.cpp \
+ ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
new file mode 100644
index 0000000000..c8fc001fa3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+
+#include <private/qdeclarativedebug_p.h>
+#include <private/qdeclarativeenginedebug_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+
+#include "../shared/debugutil_p.h"
+
+class tst_QDeclarativeDebugService : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDeclarativeDebugService(QDeclarativeDebugTestData *data)
+ {
+ m_conn = data->conn;
+ }
+
+ QDeclarativeDebugConnection *m_conn;
+
+private slots:
+ void name();
+ void isEnabled();
+ void enabledChanged();
+ void sendMessage();
+ void idForObject();
+ void objectForId();
+ void objectToString();
+};
+
+void tst_QDeclarativeDebugService::name()
+{
+ QString name = "tst_QDeclarativeDebugService::name()";
+
+ QDeclarativeDebugService service(name);
+ QCOMPARE(service.name(), name);
+}
+
+void tst_QDeclarativeDebugService::isEnabled()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::isEnabled()", m_conn);
+ QCOMPARE(service.isEnabled(), false);
+
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::isEnabled()", m_conn);
+ client.setEnabled(true);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.isEnabled(), true);
+
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::isEnabled()\" ");
+ QDeclarativeDebugService duplicate("tst_QDeclarativeDebugService::isEnabled()", m_conn);
+ QCOMPARE(duplicate.isEnabled(), false);
+}
+
+void tst_QDeclarativeDebugService::enabledChanged()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::enabledChanged()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::enabledChanged()", m_conn);
+
+ QCOMPARE(service.enabled, false);
+
+ client.setEnabled(true);
+ QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QCOMPARE(service.enabled, true);
+}
+
+void tst_QDeclarativeDebugService::sendMessage()
+{
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::sendMessage()");
+ QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+}
+
+void tst_QDeclarativeDebugService::idForObject()
+{
+ QCOMPARE(QDeclarativeDebugService::idForObject(0), -1);
+
+ QObject *objA = new QObject;
+
+ int idA = QDeclarativeDebugService::idForObject(objA);
+ QVERIFY(idA >= 0);
+ QCOMPARE(QDeclarativeDebugService::objectForId(idA), objA);
+
+ int idAA = QDeclarativeDebugService::idForObject(objA);
+ QCOMPARE(idAA, idA);
+
+ QObject *objB = new QObject;
+ int idB = QDeclarativeDebugService::idForObject(objB);
+ QVERIFY(idB != idA);
+ QCOMPARE(QDeclarativeDebugService::objectForId(idB), objB);
+
+ delete objA;
+ delete objB;
+}
+
+void tst_QDeclarativeDebugService::objectForId()
+{
+ QCOMPARE(QDeclarativeDebugService::objectForId(-1), static_cast<QObject*>(0));
+ QCOMPARE(QDeclarativeDebugService::objectForId(1), static_cast<QObject*>(0));
+
+ QObject *obj = new QObject;
+ int id = QDeclarativeDebugService::idForObject(obj);
+ QCOMPARE(QDeclarativeDebugService::objectForId(id), obj);
+
+ delete obj;
+ QCOMPARE(QDeclarativeDebugService::objectForId(id), static_cast<QObject*>(0));
+}
+
+void tst_QDeclarativeDebugService::objectToString()
+{
+ QCOMPARE(QDeclarativeDebugService::objectToString(0), QString("NULL"));
+
+ QObject *obj = new QObject;
+ QCOMPARE(QDeclarativeDebugService::objectToString(obj), QString("QObject: <unnamed>"));
+
+ obj->setObjectName("Hello");
+ QCOMPARE(QDeclarativeDebugService::objectToString(obj), QString("QObject: Hello"));
+ delete obj;
+}
+
+
+class tst_QDeclarativeDebugService_Factory : public QDeclarativeTestFactory
+{
+public:
+ QObject *createTest(QDeclarativeDebugTestData *data) { return new tst_QDeclarativeDebugService(data); }
+};
+
+// This does not use QTEST_MAIN because the test has to be created and run
+// in a separate thread.
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ tst_QDeclarativeDebugService_Factory factory;
+ return QDeclarativeDebugTest::runTests(&factory);
+}
+
+#include "tst_qdeclarativedebugservice.moc"
diff --git a/tests/auto/declarative/qmldom/data/MyComponent.qml b/tests/auto/declarative/qdeclarativedom/data/MyComponent.qml
index 1472f01bfc..1472f01bfc 100644
--- a/tests/auto/declarative/qmldom/data/MyComponent.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/MyComponent.qml
diff --git a/tests/auto/declarative/qmldom/data/MyItem.qml b/tests/auto/declarative/qdeclarativedom/data/MyItem.qml
index 1472f01bfc..1472f01bfc 100644
--- a/tests/auto/declarative/qmldom/data/MyItem.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/MyItem.qml
diff --git a/tests/auto/declarative/qmldom/data/importdir/Bar.qml b/tests/auto/declarative/qdeclarativedom/data/importdir/Bar.qml
index 2d1a4a3c7b..2d1a4a3c7b 100644
--- a/tests/auto/declarative/qmldom/data/importdir/Bar.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/importdir/Bar.qml
diff --git a/tests/auto/declarative/qmldom/data/importlib/sublib/qmldir/Foo.qml b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml
index 2d1a4a3c7b..2d1a4a3c7b 100644
--- a/tests/auto/declarative/qmldom/data/importlib/sublib/qmldir/Foo.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir/Foo.qml
diff --git a/tests/auto/declarative/qmldom/data/top.qml b/tests/auto/declarative/qdeclarativedom/data/top.qml
index 2681993bc1..2681993bc1 100644
--- a/tests/auto/declarative/qmldom/data/top.qml
+++ b/tests/auto/declarative/qdeclarativedom/data/top.qml
diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
new file mode 100644
index 0000000000..35df26e906
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativedom.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
new file mode 100644
index 0000000000..95432806b9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -0,0 +1,1313 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/private/qdeclarativedom_p.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+
+class tst_qdeclarativedom : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativedom() {}
+
+private slots:
+ void loadSimple();
+ void loadProperties();
+ void loadGroupedProperties();
+ void loadChildObject();
+ void loadComposite();
+ void loadImports();
+ void loadErrors();
+ void loadSyntaxErrors();
+ void loadRemoteErrors();
+ void loadDynamicProperty();
+ void loadComponent();
+
+ void testValueSource();
+ void testValueInterceptor();
+
+ void object_dynamicProperty();
+ void object_property();
+ void object_url();
+
+ void copy();
+ void position();
+private:
+ QDeclarativeEngine engine;
+};
+
+
+void tst_qdeclarativedom::loadSimple()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+ QVERIFY(document.errors().isEmpty());
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QVERIFY(!rootObject.isComponent());
+ QVERIFY(!rootObject.isCustomType());
+ QVERIFY(rootObject.objectType() == "Qt/Item");
+ QVERIFY(rootObject.objectTypeMajorVersion() == 4);
+ QVERIFY(rootObject.objectTypeMinorVersion() == 6);
+}
+
+// Test regular properties
+void tst_qdeclarativedom::loadProperties()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { id : item; x : 300; visible : true }";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QVERIFY(rootObject.objectId() == "item");
+ QCOMPARE(rootObject.properties().size(), 3);
+
+ QDeclarativeDomProperty xProperty = rootObject.property("x");
+ QVERIFY(xProperty.propertyName() == "x");
+ QCOMPARE(xProperty.propertyNameParts().count(), 1);
+ QVERIFY(xProperty.propertyNameParts().at(0) == "x");
+ QCOMPARE(xProperty.position(), 32);
+ QCOMPARE(xProperty.length(), 1);
+ QVERIFY(xProperty.value().isLiteral());
+ QVERIFY(xProperty.value().toLiteral().literal() == "300");
+
+ QDeclarativeDomProperty visibleProperty = rootObject.property("visible");
+ QVERIFY(visibleProperty.propertyName() == "visible");
+ QCOMPARE(visibleProperty.propertyNameParts().count(), 1);
+ QVERIFY(visibleProperty.propertyNameParts().at(0) == "visible");
+ QCOMPARE(visibleProperty.position(), 41);
+ QCOMPARE(visibleProperty.length(), 7);
+ QVERIFY(visibleProperty.value().isLiteral());
+ QVERIFY(visibleProperty.value().toLiteral().literal() == "true");
+}
+
+// Test grouped properties
+void tst_qdeclarativedom::loadGroupedProperties()
+{
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { anchors.left: parent.left; anchors.right: parent.right }";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 2);
+
+ // Order is not deterministic
+ QDeclarativeDomProperty p0 = rootItem.properties().at(0);
+ QDeclarativeDomProperty p1 = rootItem.properties().at(1);
+ QDeclarativeDomProperty leftProperty;
+ QDeclarativeDomProperty rightProperty;
+ if (p0.propertyName() == "anchors.left") {
+ leftProperty = p0;
+ rightProperty = p1;
+ } else {
+ leftProperty = p1;
+ rightProperty = p0;
+ }
+
+ QVERIFY(leftProperty.propertyName() == "anchors.left");
+ QCOMPARE(leftProperty.propertyNameParts().count(), 2);
+ QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
+ QCOMPARE(leftProperty.position(), 21);
+ QCOMPARE(leftProperty.length(), 12);
+ QVERIFY(leftProperty.value().isBinding());
+ QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
+
+ QVERIFY(rightProperty.propertyName() == "anchors.right");
+ QCOMPARE(rightProperty.propertyNameParts().count(), 2);
+ QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
+ QCOMPARE(rightProperty.position(), 48);
+ QCOMPARE(rightProperty.length(), 13);
+ QVERIFY(rightProperty.value().isBinding());
+ QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
+ }
+
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { \n"
+ " anchors {\n"
+ " left: parent.left\n"
+ " right: parent.right\n"
+ " }\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 2);
+
+ // Order is not deterministic
+ QDeclarativeDomProperty p0 = rootItem.properties().at(0);
+ QDeclarativeDomProperty p1 = rootItem.properties().at(1);
+ QDeclarativeDomProperty leftProperty;
+ QDeclarativeDomProperty rightProperty;
+ if (p0.propertyName() == "anchors.left") {
+ leftProperty = p0;
+ rightProperty = p1;
+ } else {
+ leftProperty = p1;
+ rightProperty = p0;
+ }
+
+ QVERIFY(leftProperty.propertyName() == "anchors.left");
+ QCOMPARE(leftProperty.propertyNameParts().count(), 2);
+ QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
+ QCOMPARE(leftProperty.position(), 44);
+ QCOMPARE(leftProperty.length(), 4);
+ QVERIFY(leftProperty.value().isBinding());
+ QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
+
+ QVERIFY(rightProperty.propertyName() == "anchors.right");
+ QCOMPARE(rightProperty.propertyNameParts().count(), 2);
+ QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
+ QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
+ QCOMPARE(rightProperty.position(), 70);
+ QCOMPARE(rightProperty.length(), 5);
+ QVERIFY(rightProperty.value().isBinding());
+ QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
+ }
+
+}
+
+void tst_qdeclarativedom::loadChildObject()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item { Item {} }";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 1);
+
+ QDeclarativeDomProperty listProperty = rootItem.properties().at(0);
+ QVERIFY(listProperty.isDefaultProperty());
+ QVERIFY(listProperty.value().isList());
+
+ QDeclarativeDomList list = listProperty.value().toList();
+ QVERIFY(list.values().size() == 1);
+
+ QDeclarativeDomObject childItem = list.values().first().toObject();
+ QVERIFY(childItem.isValid());
+ QVERIFY(childItem.objectType() == "Qt/Item");
+}
+
+void tst_qdeclarativedom::loadComposite()
+{
+ QFile file(SRCDIR "/data/top.qml");
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, file.readAll(), QUrl::fromLocalFile(file.fileName())));
+ QVERIFY(document.errors().isEmpty());
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QCOMPARE(rootItem.objectType(), QByteArray("MyComponent"));
+ QCOMPARE(rootItem.properties().size(), 2);
+
+ QDeclarativeDomProperty widthProperty = rootItem.property("width");
+ QVERIFY(widthProperty.value().isLiteral());
+
+ QDeclarativeDomProperty heightProperty = rootItem.property("height");
+ QVERIFY(heightProperty.value().isLiteral());
+}
+
+void tst_qdeclarativedom::testValueSource()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
+
+ QDeclarativeEngine freshEngine;
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&freshEngine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QDeclarativeDomProperty heightProperty = rootItem.properties().at(0);
+ QVERIFY(heightProperty.propertyName() == "height");
+ QVERIFY(heightProperty.value().isValueSource());
+
+ const QDeclarativeDomValueValueSource valueSource = heightProperty.value().toValueSource();
+ QDeclarativeDomObject valueSourceObject = valueSource.object();
+ QVERIFY(valueSourceObject.isValid());
+
+ QVERIFY(valueSourceObject.objectType() == "Qt/SpringFollow");
+
+ const QDeclarativeDomValue springValue = valueSourceObject.property("spring").value();
+ QVERIFY(!springValue.isInvalid());
+ QVERIFY(springValue.isLiteral());
+ QVERIFY(springValue.toLiteral().literal() == "1.4");
+
+ const QDeclarativeDomValue sourceValue = valueSourceObject.property("source").value();
+ QVERIFY(!sourceValue.isInvalid());
+ QVERIFY(sourceValue.isBinding());
+ QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
+}
+
+void tst_qdeclarativedom::testValueInterceptor()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Rectangle { height: Behavior { NumberAnimation { duration: 100 } } }";
+
+ QDeclarativeEngine freshEngine;
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&freshEngine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QDeclarativeDomProperty heightProperty = rootItem.properties().at(0);
+ QVERIFY(heightProperty.propertyName() == "height");
+ QVERIFY(heightProperty.value().isValueInterceptor());
+
+ const QDeclarativeDomValueValueInterceptor valueInterceptor = heightProperty.value().toValueInterceptor();
+ QDeclarativeDomObject valueInterceptorObject = valueInterceptor.object();
+ QVERIFY(valueInterceptorObject.isValid());
+
+ QVERIFY(valueInterceptorObject.objectType() == "Qt/Behavior");
+
+ const QDeclarativeDomValue animationValue = valueInterceptorObject.property("animation").value();
+ QVERIFY(!animationValue.isInvalid());
+ QVERIFY(animationValue.isObject());
+}
+
+// Test QDeclarativeDomDocument::imports()
+void tst_qdeclarativedom::loadImports()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "import importlib.sublib 4.7\n"
+ "import importlib.sublib 4.6 as NewFoo\n"
+ "import 'import'\n"
+ "import 'import' as X\n"
+ "Item {}";
+
+ QDeclarativeEngine engine;
+ engine.addImportPath(SRCDIR "/data");
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QCOMPARE(document.imports().size(), 5);
+
+ QDeclarativeDomImport import = document.imports().at(0);
+ QCOMPARE(import.type(), QDeclarativeDomImport::Library);
+ QCOMPARE(import.uri(), QLatin1String("Qt"));
+ QCOMPARE(import.qualifier(), QString());
+ QCOMPARE(import.version(), QLatin1String("4.6"));
+
+ import = document.imports().at(1);
+ QCOMPARE(import.type(), QDeclarativeDomImport::Library);
+ QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
+ QCOMPARE(import.qualifier(), QString());
+ QCOMPARE(import.version(), QLatin1String("4.7"));
+
+ import = document.imports().at(2);
+ QCOMPARE(import.type(), QDeclarativeDomImport::Library);
+ QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
+ QCOMPARE(import.qualifier(), QLatin1String("NewFoo"));
+ QCOMPARE(import.version(), QLatin1String("4.6"));
+
+ import = document.imports().at(3);
+ QCOMPARE(import.type(), QDeclarativeDomImport::File);
+ QCOMPARE(import.uri(), QLatin1String("import"));
+ QCOMPARE(import.qualifier(), QLatin1String(""));
+ QCOMPARE(import.version(), QLatin1String(""));
+
+ import = document.imports().at(4);
+ QCOMPARE(import.type(), QDeclarativeDomImport::File);
+ QCOMPARE(import.uri(), QLatin1String("import"));
+ QCOMPARE(import.qualifier(), QLatin1String("X"));
+ QCOMPARE(import.version(), QLatin1String(""));
+}
+
+// Test loading a file with errors
+void tst_qdeclarativedom::loadErrors()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " foo: 12\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(false == document.load(&engine, qml));
+
+ QCOMPARE(document.errors().count(), 1);
+ QDeclarativeError error = document.errors().first();
+
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), 3);
+ QCOMPARE(error.column(), 3);
+ QCOMPARE(error.description(), QString("Cannot assign to non-existent property \"foo\""));
+}
+
+// Test loading a file with syntax errors
+void tst_qdeclarativedom::loadSyntaxErrors()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "asdf";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(false == document.load(&engine, qml));
+
+ QCOMPARE(document.errors().count(), 1);
+ QDeclarativeError error = document.errors().first();
+
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), 2);
+ QCOMPARE(error.column(), 1);
+ QCOMPARE(error.description(), QString("Syntax error"));
+}
+
+// Test attempting to load a file with remote references
+void tst_qdeclarativedom::loadRemoteErrors()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " Script {\n"
+ " source: \"http://localhost/exampleQmlScript.js\""
+ " }\n"
+ "}";
+ QDeclarativeDomDocument document;
+ QVERIFY(false == document.load(&engine, qml));
+
+ QCOMPARE(document.errors().count(), 1);
+ QDeclarativeError error = document.errors().first();
+
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), -1);
+ QCOMPARE(error.column(), -1);
+ QCOMPARE(error.description(), QString("QDeclarativeDomDocument supports local types only"));
+}
+
+// Test dynamic property declarations
+void tst_qdeclarativedom::loadDynamicProperty()
+{
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " property int a\n"
+ " property bool b\n"
+ " property double c\n"
+ " property real d\n"
+ " property string e\n"
+ " property url f\n"
+ " property color g\n"
+ " property date h\n"
+ " property var i\n"
+ " property variant j\n"
+ " property QtObject k\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QCOMPARE(rootObject.dynamicProperties().count(), 11);
+
+#define DP_TEST(index, name, type, test_position, test_length, propTypeName) \
+ { \
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(index); \
+ QVERIFY(d.isValid()); \
+ QVERIFY(d.propertyName() == # name ); \
+ QVERIFY(d.propertyType() == type); \
+ QVERIFY(d.propertyTypeName() == propTypeName); \
+ QVERIFY(d.isDefaultProperty() == false); \
+ QVERIFY(d.defaultValue().isValid() == false); \
+ QCOMPARE(d.position(), test_position); \
+ QCOMPARE(d.length(), test_length); \
+ } \
+
+ DP_TEST(0, a, QVariant::Int, 25, 14, "int");
+ DP_TEST(1, b, QVariant::Bool, 44, 15, "bool");
+ DP_TEST(2, c, QVariant::Double, 64, 17, "double");
+ DP_TEST(3, d, QMetaType::QReal, 86, 15, "real");
+ DP_TEST(4, e, QVariant::String, 106, 17, "string");
+ DP_TEST(5, f, QVariant::Url, 128, 14, "url");
+ DP_TEST(6, g, QVariant::Color, 147, 16, "color");
+ DP_TEST(7, h, QVariant::Date, 168, 15, "date");
+ DP_TEST(8, i, qMetaTypeId<QVariant>(), 188, 14, "var");
+ DP_TEST(9, j, qMetaTypeId<QVariant>(), 207, 18, "variant");
+ DP_TEST(10, k, -1, 230, 19, "QtObject");
+ }
+
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " property int a: 12\n"
+ " property int b: a + 6\n"
+ " default property QtObject c\n"
+ "}\n";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QCOMPARE(rootObject.dynamicProperties().count(), 3);
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(0);
+ QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.defaultValue().isValid());
+ QVERIFY(d.defaultValue().propertyName() == "a");
+ QVERIFY(d.defaultValue().value().isLiteral());
+ }
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(1);
+ QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.defaultValue().isValid());
+ QVERIFY(d.defaultValue().propertyName() == "b");
+ QVERIFY(d.defaultValue().value().isBinding());
+ }
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(2);
+ QVERIFY(d.isDefaultProperty() == true);
+ QVERIFY(d.defaultValue().isValid() == false);
+ }
+ }
+}
+
+// Test inline components
+void tst_qdeclarativedom::loadComponent()
+{
+ // Explicit component
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " Component {\n"
+ " id: myComponent\n"
+ " Item {}\n"
+ " }\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 1);
+
+ QDeclarativeDomProperty listProperty = rootItem.properties().at(0);
+ QVERIFY(listProperty.isDefaultProperty());
+ QVERIFY(listProperty.value().isList());
+
+ QDeclarativeDomList list = listProperty.value().toList();
+ QVERIFY(list.values().size() == 1);
+
+ QDeclarativeDomObject componentObject = list.values().first().toObject();
+ QVERIFY(componentObject.isValid());
+ QVERIFY(componentObject.objectClassName() == "Component");
+ QVERIFY(componentObject.isComponent());
+
+ QDeclarativeDomComponent component = componentObject.toComponent();
+ QVERIFY(component.isValid());
+ QVERIFY(component.objectType() == "Qt/Component");
+ QVERIFY(component.objectTypeMajorVersion() == 4);
+ QVERIFY(component.objectTypeMinorVersion() == 6);
+ QVERIFY(component.objectClassName() == "Component");
+ QVERIFY(component.objectId() == "myComponent");
+ QVERIFY(component.properties().isEmpty());
+ QVERIFY(component.dynamicProperties().isEmpty());
+ QVERIFY(component.isCustomType() == false);
+ QVERIFY(component.customTypeData() == "");
+ QVERIFY(component.isComponent());
+ QCOMPARE(component.position(), 25);
+ QCOMPARE(component.length(), 57);
+
+ QVERIFY(component.componentRoot().isValid());
+ QVERIFY(component.componentRoot().objectClassName() == "Item");
+ }
+
+ // Implicit component
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "ListView {\n"
+ " delegate: Item {}\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QVERIFY(rootItem.properties().size() == 1);
+
+ QDeclarativeDomProperty delegate = rootItem.property("delegate");
+
+ QDeclarativeDomObject componentObject = delegate.value().toObject();
+ QVERIFY(componentObject.isValid());
+ QVERIFY(componentObject.objectClassName() == "Component");
+ QVERIFY(componentObject.isComponent());
+
+ QDeclarativeDomComponent component = componentObject.toComponent();
+ QVERIFY(component.isValid());
+ QVERIFY(component.objectType() == "Qt/Component");
+ QVERIFY(component.objectClassName() == "Component");
+ QVERIFY(component.objectId() == "");
+ QVERIFY(component.properties().isEmpty());
+ QVERIFY(component.dynamicProperties().isEmpty());
+ QVERIFY(component.isCustomType() == false);
+ QVERIFY(component.customTypeData() == "");
+ QVERIFY(component.isComponent());
+ QCOMPARE(component.position(), 39);
+ QCOMPARE(component.length(), 7);
+
+ QVERIFY(component.componentRoot().isValid());
+ QVERIFY(component.componentRoot().objectClassName() == "Item");
+ }
+}
+
+// Test QDeclarativeDomObject::dynamicProperty() method
+void tst_qdeclarativedom::object_dynamicProperty()
+{
+ // Invalid object
+ {
+ QDeclarativeDomObject object;
+ QVERIFY(object.dynamicProperty("").isValid() == false);
+ QVERIFY(object.dynamicProperty("foo").isValid() == false);
+ }
+
+
+ // Valid object, no dynamic properties
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.dynamicProperty("").isValid() == false);
+ QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
+ }
+
+ // Valid object, dynamic properties
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " property int a\n"
+ "}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.dynamicProperty("").isValid() == false);
+ QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
+
+ QDeclarativeDomDynamicProperty p = rootObject.dynamicProperty("a");
+ QVERIFY(p.isValid());
+ QVERIFY(p.propertyName() == "a");
+ QVERIFY(p.propertyType() == QVariant::Int);
+ QVERIFY(p.propertyTypeName() == "int");
+ QVERIFY(p.isDefaultProperty() == false);
+ QCOMPARE(p.position(), 25);
+ QCOMPARE(p.length(), 14);
+ }
+
+}
+
+// Test QDeclarativeObject::property() method
+void tst_qdeclarativedom::object_property()
+{
+ // Invalid object
+ {
+ QDeclarativeDomObject object;
+ QVERIFY(object.property("").isValid() == false);
+ QVERIFY(object.property("foo").isValid() == false);
+ }
+
+ // Valid object - no default
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " x: 10\n"
+ " y: 12\n"
+ "}\n";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.property("").isValid() == false);
+ QVERIFY(rootObject.property("foo").isValid() == false);
+
+ QDeclarativeDomProperty x = rootObject.property("x");
+ QVERIFY(x.isValid());
+ QVERIFY(x.propertyName() == "x");
+ QVERIFY(x.propertyNameParts().count() == 1);
+ QVERIFY(x.propertyNameParts().at(0) == "x");
+ QVERIFY(x.isDefaultProperty() == false);
+ QVERIFY(x.value().isLiteral());
+ QVERIFY(x.value().toLiteral().literal() == "10");
+ QCOMPARE(x.position(), 25);
+ QCOMPARE(x.length(), 1);
+
+ QDeclarativeDomProperty y = rootObject.property("y");
+ QVERIFY(y.isValid());
+ QVERIFY(y.propertyName() == "y");
+ QVERIFY(y.propertyNameParts().count() == 1);
+ QVERIFY(y.propertyNameParts().at(0) == "y");
+ QVERIFY(y.isDefaultProperty() == false);
+ QVERIFY(y.value().isLiteral());
+ QVERIFY(y.value().toLiteral().literal() == "12");
+ QCOMPARE(y.position(), 35);
+ QCOMPARE(y.length(), 1);
+ }
+
+ // Valid object - with default
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {\n"
+ " x: 10\n"
+ " y: 12\n"
+ " Item {}\n"
+ "}\n";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+
+ QVERIFY(rootObject.property("").isValid() == false);
+ QVERIFY(rootObject.property("foo").isValid() == false);
+
+ QDeclarativeDomProperty x = rootObject.property("x");
+ QVERIFY(x.isValid());
+ QVERIFY(x.propertyName() == "x");
+ QVERIFY(x.propertyNameParts().count() == 1);
+ QVERIFY(x.propertyNameParts().at(0) == "x");
+ QVERIFY(x.isDefaultProperty() == false);
+ QVERIFY(x.value().isLiteral());
+ QVERIFY(x.value().toLiteral().literal() == "10");
+ QCOMPARE(x.position(), 25);
+ QCOMPARE(x.length(), 1);
+
+ QDeclarativeDomProperty y = rootObject.property("y");
+ QVERIFY(y.isValid());
+ QVERIFY(y.propertyName() == "y");
+ QVERIFY(y.propertyNameParts().count() == 1);
+ QVERIFY(y.propertyNameParts().at(0) == "y");
+ QVERIFY(y.isDefaultProperty() == false);
+ QVERIFY(y.value().isLiteral());
+ QVERIFY(y.value().toLiteral().literal() == "12");
+ QCOMPARE(y.position(), 35);
+ QCOMPARE(y.length(), 1);
+
+ QDeclarativeDomProperty data = rootObject.property("data");
+ QVERIFY(data.isValid());
+ QVERIFY(data.propertyName() == "data");
+ QVERIFY(data.propertyNameParts().count() == 1);
+ QVERIFY(data.propertyNameParts().at(0) == "data");
+ QVERIFY(data.isDefaultProperty() == true);
+ QVERIFY(data.value().isList());
+ QCOMPARE(data.position(), 45);
+ QCOMPARE(data.length(), 0);
+ }
+}
+
+// Tests the QDeclarativeDomObject::url() method
+void tst_qdeclarativedom::object_url()
+{
+ // Invalid object
+ {
+ QDeclarativeDomObject object;
+ QCOMPARE(object.url(), QUrl());
+ }
+
+ // Valid builtin object
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "Item {}";
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QCOMPARE(rootObject.url(), QUrl());
+ }
+
+ // Valid composite object
+ {
+ QByteArray qml = "import Qt 4.6\n"
+ "MyItem {}";
+
+ QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
+ QUrl subUrl = QUrl::fromLocalFile(SRCDIR "/data/MyItem.qml");
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml, myUrl));
+
+ QDeclarativeDomObject rootObject = document.rootObject();
+ QVERIFY(rootObject.isValid());
+ QCOMPARE(rootObject.url(), subUrl);
+ }
+}
+
+// Test copy constructors and operators
+void tst_qdeclarativedom::copy()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ "MyItem {\n"
+ " id: myItem\n"
+ " property int a: 10\n"
+ " x: 10\n"
+ " y: x + 10\n"
+ " z: NumberAnimation {}\n"
+ " opacity: Behavior {}\n"
+ " Component {\n"
+ " Item{}\n"
+ " }\n"
+ " children: [ Item{}, Item{} ]\n"
+ "}\n";
+
+ QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml, myUrl));
+
+ // QDeclarativeDomDocument
+ {
+ QDeclarativeDomDocument document2(document);
+ QDeclarativeDomDocument document3;
+ document3 = document;
+
+ QCOMPARE(document.imports().count(), document2.imports().count());
+ QCOMPARE(document.errors().count(), document2.errors().count());
+ QCOMPARE(document.rootObject().objectClassName(), document2.rootObject().objectClassName());
+
+ QCOMPARE(document.imports().count(), document3.imports().count());
+ QCOMPARE(document.errors().count(), document3.errors().count());
+ QCOMPARE(document.rootObject().objectClassName(), document3.rootObject().objectClassName());
+ }
+
+ // QDeclarativeDomImport
+ {
+ QCOMPARE(document.imports().count(), 1);
+ QDeclarativeDomImport import = document.imports().at(0);
+
+ QDeclarativeDomImport import2(import);
+ QDeclarativeDomImport import3;
+ import3 = import2;
+
+ QCOMPARE(import.type(), import2.type());
+ QCOMPARE(import.uri(), import2.uri());
+ QCOMPARE(import.version(), import2.version());
+ QCOMPARE(import.qualifier(), import2.qualifier());
+
+ QCOMPARE(import.type(), import3.type());
+ QCOMPARE(import.uri(), import3.uri());
+ QCOMPARE(import.version(), import3.version());
+ QCOMPARE(import.qualifier(), import3.qualifier());
+ }
+
+ // QDeclarativeDomObject
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QVERIFY(object.isValid());
+
+ QDeclarativeDomObject object2(object);
+ QDeclarativeDomObject object3;
+ object3 = object;
+
+ QCOMPARE(object.isValid(), object2.isValid());
+ QCOMPARE(object.objectType(), object2.objectType());
+ QCOMPARE(object.objectClassName(), object2.objectClassName());
+ QCOMPARE(object.objectTypeMajorVersion(), object2.objectTypeMajorVersion());
+ QCOMPARE(object.objectTypeMinorVersion(), object2.objectTypeMinorVersion());
+ QCOMPARE(object.objectId(), object2.objectId());
+ QCOMPARE(object.properties().count(), object2.properties().count());
+ QCOMPARE(object.dynamicProperties().count(), object2.dynamicProperties().count());
+ QCOMPARE(object.isCustomType(), object2.isCustomType());
+ QCOMPARE(object.customTypeData(), object2.customTypeData());
+ QCOMPARE(object.isComponent(), object2.isComponent());
+ QCOMPARE(object.position(), object2.position());
+ QCOMPARE(object.length(), object2.length());
+ QCOMPARE(object.url(), object2.url());
+
+ QCOMPARE(object.isValid(), object3.isValid());
+ QCOMPARE(object.objectType(), object3.objectType());
+ QCOMPARE(object.objectClassName(), object3.objectClassName());
+ QCOMPARE(object.objectTypeMajorVersion(), object3.objectTypeMajorVersion());
+ QCOMPARE(object.objectTypeMinorVersion(), object3.objectTypeMinorVersion());
+ QCOMPARE(object.objectId(), object3.objectId());
+ QCOMPARE(object.properties().count(), object3.properties().count());
+ QCOMPARE(object.dynamicProperties().count(), object3.dynamicProperties().count());
+ QCOMPARE(object.isCustomType(), object3.isCustomType());
+ QCOMPARE(object.customTypeData(), object3.customTypeData());
+ QCOMPARE(object.isComponent(), object3.isComponent());
+ QCOMPARE(object.position(), object3.position());
+ QCOMPARE(object.length(), object3.length());
+ QCOMPARE(object.url(), object3.url());
+ }
+
+ // QDeclarativeDomDynamicProperty
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomDynamicProperty property = object.dynamicProperty("a");
+
+ QDeclarativeDomDynamicProperty property2(property);
+ QDeclarativeDomDynamicProperty property3;
+ property3 = property;
+
+ QCOMPARE(property.isValid(), property2.isValid());
+ QCOMPARE(property.propertyName(), property2.propertyName());
+ QCOMPARE(property.propertyType(), property2.propertyType());
+ QCOMPARE(property.propertyTypeName(), property2.propertyTypeName());
+ QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
+ QCOMPARE(property.defaultValue().propertyName(), property2.defaultValue().propertyName());
+ QCOMPARE(property.position(), property2.position());
+ QCOMPARE(property.length(), property2.length());
+
+ QCOMPARE(property.isValid(), property3.isValid());
+ QCOMPARE(property.propertyName(), property3.propertyName());
+ QCOMPARE(property.propertyType(), property3.propertyType());
+ QCOMPARE(property.propertyTypeName(), property3.propertyTypeName());
+ QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
+ QCOMPARE(property.defaultValue().propertyName(), property3.defaultValue().propertyName());
+ QCOMPARE(property.position(), property3.position());
+ QCOMPARE(property.length(), property3.length());
+ }
+
+ // QDeclarativeDomProperty
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("opacity");
+
+ QDeclarativeDomProperty property2(property);
+ QDeclarativeDomProperty property3;
+ property3 = property;
+
+ QCOMPARE(property.isValid(), property2.isValid());
+ QCOMPARE(property.propertyName(), property2.propertyName());
+ QCOMPARE(property.propertyNameParts(), property2.propertyNameParts());
+ QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
+ QCOMPARE(property.value().type(), property2.value().type());
+ QCOMPARE(property.position(), property2.position());
+ QCOMPARE(property.length(), property2.length());
+
+ QCOMPARE(property.isValid(), property3.isValid());
+ QCOMPARE(property.propertyName(), property3.propertyName());
+ QCOMPARE(property.propertyNameParts(), property3.propertyNameParts());
+ QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
+ QCOMPARE(property.value().type(), property3.value().type());
+ QCOMPARE(property.position(), property3.position());
+ QCOMPARE(property.length(), property3.length());
+ }
+
+ // QDeclarativeDomValueLiteral
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("x");
+ QDeclarativeDomValueLiteral literal = property.value().toLiteral();
+ QCOMPARE(literal.literal(), QString("10"));
+
+ QDeclarativeDomValueLiteral literal2(literal);
+ QDeclarativeDomValueLiteral literal3;
+ literal3 = literal2;
+
+ QCOMPARE(literal2.literal(), QString("10"));
+ QCOMPARE(literal3.literal(), QString("10"));
+ }
+
+
+ // QDeclarativeDomValueBinding
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("y");
+ QDeclarativeDomValueBinding binding = property.value().toBinding();
+ QCOMPARE(binding.binding(), QString("x + 10"));
+
+ QDeclarativeDomValueBinding binding2(binding);
+ QDeclarativeDomValueBinding binding3;
+ binding3 = binding2;
+
+ QCOMPARE(binding2.binding(), QString("x + 10"));
+ QCOMPARE(binding3.binding(), QString("x + 10"));
+ }
+
+ // QDeclarativeDomValueValueSource
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("z");
+ QDeclarativeDomValueValueSource source = property.value().toValueSource();
+ QCOMPARE(source.object().objectClassName(), QByteArray("NumberAnimation"));
+
+ QDeclarativeDomValueValueSource source2(source);
+ QDeclarativeDomValueValueSource source3;
+ source3 = source;
+
+ QCOMPARE(source2.object().objectClassName(), QByteArray("NumberAnimation"));
+ QCOMPARE(source3.object().objectClassName(), QByteArray("NumberAnimation"));
+ }
+
+ // QDeclarativeDomValueValueInterceptor
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("opacity");
+ QDeclarativeDomValueValueInterceptor interceptor = property.value().toValueInterceptor();
+ QCOMPARE(interceptor.object().objectClassName(), QByteArray("Behavior"));
+
+ QDeclarativeDomValueValueInterceptor interceptor2(interceptor);
+ QDeclarativeDomValueValueInterceptor interceptor3;
+ interceptor3 = interceptor;
+
+ QCOMPARE(interceptor2.object().objectClassName(), QByteArray("Behavior"));
+ QCOMPARE(interceptor3.object().objectClassName(), QByteArray("Behavior"));
+ }
+
+ // QDeclarativeDomComponent
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("data");
+ QCOMPARE(property.value().toList().values().count(), 1);
+ QDeclarativeDomComponent component =
+ property.value().toList().values().at(0).toObject().toComponent();
+ QCOMPARE(component.componentRoot().objectClassName(), QByteArray("Item"));
+
+ QDeclarativeDomComponent component2(component);
+ QDeclarativeDomComponent component3;
+ component3 = component;
+
+ QCOMPARE(component.componentRoot().objectClassName(), component2.componentRoot().objectClassName());
+ QCOMPARE(component.isValid(), component2.isValid());
+ QCOMPARE(component.objectType(), component2.objectType());
+ QCOMPARE(component.objectClassName(), component2.objectClassName());
+ QCOMPARE(component.objectTypeMajorVersion(), component2.objectTypeMajorVersion());
+ QCOMPARE(component.objectTypeMinorVersion(), component2.objectTypeMinorVersion());
+ QCOMPARE(component.objectId(), component2.objectId());
+ QCOMPARE(component.properties().count(), component2.properties().count());
+ QCOMPARE(component.dynamicProperties().count(), component2.dynamicProperties().count());
+ QCOMPARE(component.isCustomType(), component2.isCustomType());
+ QCOMPARE(component.customTypeData(), component2.customTypeData());
+ QCOMPARE(component.isComponent(), component2.isComponent());
+ QCOMPARE(component.position(), component2.position());
+ QCOMPARE(component.length(), component2.length());
+ QCOMPARE(component.url(), component2.url());
+
+ QCOMPARE(component.componentRoot().objectClassName(), component3.componentRoot().objectClassName());
+ QCOMPARE(component.isValid(), component3.isValid());
+ QCOMPARE(component.objectType(), component3.objectType());
+ QCOMPARE(component.objectClassName(), component3.objectClassName());
+ QCOMPARE(component.objectTypeMajorVersion(), component3.objectTypeMajorVersion());
+ QCOMPARE(component.objectTypeMinorVersion(), component3.objectTypeMinorVersion());
+ QCOMPARE(component.objectId(), component3.objectId());
+ QCOMPARE(component.properties().count(), component3.properties().count());
+ QCOMPARE(component.dynamicProperties().count(), component3.dynamicProperties().count());
+ QCOMPARE(component.isCustomType(), component3.isCustomType());
+ QCOMPARE(component.customTypeData(), component3.customTypeData());
+ QCOMPARE(component.isComponent(), component3.isComponent());
+ QCOMPARE(component.position(), component3.position());
+ QCOMPARE(component.length(), component3.length());
+ QCOMPARE(component.url(), component3.url());
+ }
+
+ // QDeclarativeDomValue
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("data");
+ QDeclarativeDomValue value = property.value();
+
+ QDeclarativeDomValue value2(value);
+ QDeclarativeDomValue value3;
+ value3 = value;
+
+ QCOMPARE(value.type(), value2.type());
+ QCOMPARE(value.isInvalid(), value2.isInvalid());
+ QCOMPARE(value.isLiteral(), value2.isLiteral());
+ QCOMPARE(value.isBinding(), value2.isBinding());
+ QCOMPARE(value.isValueSource(), value2.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
+ QCOMPARE(value.isObject(), value2.isObject());
+ QCOMPARE(value.isList(), value2.isList());
+ QCOMPARE(value.position(), value2.position());
+ QCOMPARE(value.length(), value2.length());
+
+ QCOMPARE(value.type(), value3.type());
+ QCOMPARE(value.isInvalid(), value3.isInvalid());
+ QCOMPARE(value.isLiteral(), value3.isLiteral());
+ QCOMPARE(value.isBinding(), value3.isBinding());
+ QCOMPARE(value.isValueSource(), value3.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
+ QCOMPARE(value.isObject(), value3.isObject());
+ QCOMPARE(value.isList(), value3.isList());
+ QCOMPARE(value.position(), value3.position());
+ QCOMPARE(value.length(), value3.length());
+ }
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("x");
+ QDeclarativeDomValue value = property.value();
+
+ QDeclarativeDomValue value2(value);
+ QDeclarativeDomValue value3;
+ value3 = value;
+
+ QCOMPARE(value.type(), value2.type());
+ QCOMPARE(value.isInvalid(), value2.isInvalid());
+ QCOMPARE(value.isLiteral(), value2.isLiteral());
+ QCOMPARE(value.isBinding(), value2.isBinding());
+ QCOMPARE(value.isValueSource(), value2.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
+ QCOMPARE(value.isObject(), value2.isObject());
+ QCOMPARE(value.isList(), value2.isList());
+ QCOMPARE(value.position(), value2.position());
+ QCOMPARE(value.length(), value2.length());
+
+ QCOMPARE(value.type(), value3.type());
+ QCOMPARE(value.isInvalid(), value3.isInvalid());
+ QCOMPARE(value.isLiteral(), value3.isLiteral());
+ QCOMPARE(value.isBinding(), value3.isBinding());
+ QCOMPARE(value.isValueSource(), value3.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
+ QCOMPARE(value.isObject(), value3.isObject());
+ QCOMPARE(value.isList(), value3.isList());
+ QCOMPARE(value.position(), value3.position());
+ QCOMPARE(value.length(), value3.length());
+ }
+ {
+ QDeclarativeDomValue value;
+
+ QDeclarativeDomValue value2(value);
+ QDeclarativeDomValue value3;
+ value3 = value;
+
+ QCOMPARE(value.type(), value2.type());
+ QCOMPARE(value.isInvalid(), value2.isInvalid());
+ QCOMPARE(value.isLiteral(), value2.isLiteral());
+ QCOMPARE(value.isBinding(), value2.isBinding());
+ QCOMPARE(value.isValueSource(), value2.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
+ QCOMPARE(value.isObject(), value2.isObject());
+ QCOMPARE(value.isList(), value2.isList());
+ QCOMPARE(value.position(), value2.position());
+ QCOMPARE(value.length(), value2.length());
+
+ QCOMPARE(value.type(), value3.type());
+ QCOMPARE(value.isInvalid(), value3.isInvalid());
+ QCOMPARE(value.isLiteral(), value3.isLiteral());
+ QCOMPARE(value.isBinding(), value3.isBinding());
+ QCOMPARE(value.isValueSource(), value3.isValueSource());
+ QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
+ QCOMPARE(value.isObject(), value3.isObject());
+ QCOMPARE(value.isList(), value3.isList());
+ QCOMPARE(value.position(), value3.position());
+ QCOMPARE(value.length(), value3.length());
+ }
+
+ // QDeclarativeDomList
+ {
+ QDeclarativeDomObject object = document.rootObject();
+ QDeclarativeDomProperty property = object.property("children");
+ QDeclarativeDomList list = property.value().toList();
+ QCOMPARE(list.values().count(), 2);
+
+ QDeclarativeDomList list2(list);
+ QDeclarativeDomList list3;
+ list3 = list2;
+
+ QCOMPARE(list.values().count(), list2.values().count());
+ QCOMPARE(list.position(), list2.position());
+ QCOMPARE(list.length(), list2.length());
+ QCOMPARE(list.commaPositions(), list2.commaPositions());
+
+ QCOMPARE(list.values().count(), list3.values().count());
+ QCOMPARE(list.position(), list3.position());
+ QCOMPARE(list.length(), list3.length());
+ QCOMPARE(list.commaPositions(), list3.commaPositions());
+
+ }
+}
+
+// Tests the position/length of various elements
+void tst_qdeclarativedom::position()
+{
+ QByteArray qml = "import Qt 4.6\n"
+ /*14*/ "Item {\n"
+ /*21*/ " id: myItem\n"
+ /*36*/ " property int a: 10\n"
+ /*59*/ " x: 10\n"
+ /*69*/ " y: x + 10\n"
+ /*83*/ " z: NumberAnimation {}\n"
+ /*109*/ " opacity: Behavior {}\n"
+ /*134*/ " Component {\n"
+ /*150*/ " Item{}\n"
+ /*165*/ " }\n"
+ /*171*/ " children: [ Item{}, Item{} ]\n"
+ /*204*/ "}\n";
+
+
+ QDeclarativeDomDocument document;
+ QVERIFY(document.load(&engine, qml));
+
+ QDeclarativeDomObject root = document.rootObject();
+
+ // All QDeclarativeDomDynamicProperty
+ QDeclarativeDomDynamicProperty dynProp = root.dynamicProperty("a");
+ QCOMPARE(dynProp.position(), 40);
+ QCOMPARE(dynProp.length(), 18);
+
+ // All QDeclarativeDomProperty
+ QDeclarativeDomProperty x = root.property("x");
+ QCOMPARE(x.position(), 63);
+ QCOMPARE(x.length(), 1);
+
+ QDeclarativeDomProperty y = root.property("y");
+ QCOMPARE(y.position(), 73);
+ QCOMPARE(y.length(), 1);
+
+ QDeclarativeDomProperty z = root.property("z");
+ QCOMPARE(z.position(), 87);
+ QCOMPARE(z.length(), 1);
+
+ QDeclarativeDomProperty opacity = root.property("opacity");
+ QCOMPARE(opacity.position(), 113);
+ QCOMPARE(opacity.length(), 7);
+
+ QDeclarativeDomProperty data = root.property("data");
+ QCOMPARE(data.position(), 138);
+ QCOMPARE(data.length(), 0);
+
+ QDeclarativeDomProperty children = root.property("children");
+ QCOMPARE(children.position(), 175);
+ QCOMPARE(children.length(), 8);
+
+ QDeclarativeDomList dataList = data.value().toList();
+ QCOMPARE(dataList.values().count(), 1);
+ QDeclarativeDomList childrenList = children.value().toList();
+ QCOMPARE(childrenList.values().count(), 2);
+
+ // All QDeclarativeDomObject
+ QCOMPARE(root.position(), 14);
+ QCOMPARE(root.length(), 191);
+
+ QDeclarativeDomObject numberAnimation = z.value().toValueSource().object();
+ QCOMPARE(numberAnimation.position(), 90);
+ QCOMPARE(numberAnimation.length(), 18);
+
+ QDeclarativeDomObject behavior = opacity.value().toValueInterceptor().object();
+ QCOMPARE(behavior.position(), 122);
+ QCOMPARE(behavior.length(), 11);
+
+ QDeclarativeDomObject component = dataList.values().at(0).toObject();
+ QCOMPARE(component.position(), 138);
+ QCOMPARE(component.length(), 32);
+
+ QDeclarativeDomObject componentRoot = component.toComponent().componentRoot();
+ QCOMPARE(componentRoot.position(), 158);
+ QCOMPARE(componentRoot.length(), 6);
+
+ QDeclarativeDomObject child1 = childrenList.values().at(0).toObject();
+ QCOMPARE(child1.position(), 187);
+ QCOMPARE(child1.length(), 6);
+
+ QDeclarativeDomObject child2 = childrenList.values().at(1).toObject();
+ QCOMPARE(child2.position(), 195);
+ QCOMPARE(child2.length(), 6);
+
+ // All QDeclarativeDomValue
+ QDeclarativeDomValue xValue = x.value();
+ QCOMPARE(xValue.position(), 66);
+ QCOMPARE(xValue.length(), 2);
+
+ QDeclarativeDomValue yValue = y.value();
+ QCOMPARE(yValue.position(), 76);
+ QCOMPARE(yValue.length(), 6);
+
+ QDeclarativeDomValue zValue = z.value();
+ QCOMPARE(zValue.position(), 90);
+ QCOMPARE(zValue.length(), 18);
+
+ QDeclarativeDomValue opacityValue = opacity.value();
+ QCOMPARE(opacityValue.position(), 122);
+ QCOMPARE(opacityValue.length(), 11);
+
+ QDeclarativeDomValue dataValue = data.value();
+ QCOMPARE(dataValue.position(), 138);
+ QCOMPARE(dataValue.length(), 32);
+
+ QDeclarativeDomValue child1Value = childrenList.values().at(0);
+ QCOMPARE(child1Value.position(), 187);
+ QCOMPARE(child1Value.length(), 6);
+
+ QDeclarativeDomValue child2Value = childrenList.values().at(1);
+ QCOMPARE(child2Value.position(), 195);
+ QCOMPARE(child2Value.length(), 6);
+
+ // All QDeclarativeDomList
+ qWarning("QDeclarativeListValue position test required");
+}
+
+QTEST_MAIN(tst_qdeclarativedom)
+
+#include "tst_qdeclarativedom.moc"
diff --git a/tests/auto/declarative/qmleasefollow/data/easefollow1.qml b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow1.qml
index 0cc19ebf2f..0cc19ebf2f 100644
--- a/tests/auto/declarative/qmleasefollow/data/easefollow1.qml
+++ b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow1.qml
diff --git a/tests/auto/declarative/qmleasefollow/data/easefollow2.qml b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow2.qml
index b65964e1ac..b65964e1ac 100644
--- a/tests/auto/declarative/qmleasefollow/data/easefollow2.qml
+++ b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow2.qml
diff --git a/tests/auto/declarative/qmleasefollow/data/easefollow3.qml b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow3.qml
index f8886e965f..f8886e965f 100644
--- a/tests/auto/declarative/qmleasefollow/data/easefollow3.qml
+++ b/tests/auto/declarative/qdeclarativeeasefollow/data/easefollow3.qml
diff --git a/tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro b/tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro
new file mode 100644
index 0000000000..71df4f4d4e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeeasefollow/qdeclarativeeasefollow.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeeasefollow.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp b/tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp
new file mode 100644
index 0000000000..036eec0617
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeeasefollow/tst_qdeclarativeeasefollow.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeeasefollow_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativeeasefollow : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeeasefollow();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeeasefollow::tst_qdeclarativeeasefollow()
+{
+}
+
+void tst_qdeclarativeeasefollow::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow1.qml"));
+ QDeclarativeEaseFollow *obj = qobject_cast<QDeclarativeEaseFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 0.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->duration(), -1.);
+ QCOMPARE(obj->maximumEasingTime(), -1.);
+ QCOMPARE(obj->reversingMode(), QDeclarativeEaseFollow::Eased);
+
+ delete obj;
+}
+
+void tst_qdeclarativeeasefollow::values()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow2.qml"));
+ QDeclarativeEaseFollow *obj = qobject_cast<QDeclarativeEaseFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 10.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->duration(), 300.);
+ QCOMPARE(obj->maximumEasingTime(), -1.);
+ QCOMPARE(obj->reversingMode(), QDeclarativeEaseFollow::Immediate);
+
+ delete obj;
+}
+
+void tst_qdeclarativeeasefollow::disabled()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow3.qml"));
+ QDeclarativeEaseFollow *obj = qobject_cast<QDeclarativeEaseFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 10.);
+ QCOMPARE(obj->velocity(), 250.);
+ QCOMPARE(obj->enabled(), false);
+ QCOMPARE(obj->maximumEasingTime(), 150.);
+ QCOMPARE(obj->reversingMode(), QDeclarativeEaseFollow::Sync);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativeeasefollow)
+
+#include "tst_qdeclarativeeasefollow.moc"
diff --git a/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml
index b4a702bbbe..b4a702bbbe 100644
--- a/tests/auto/declarative/qmlecmascript/data/ConstantsOverrideBindings.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/CustomObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml
index 691d9ecb8f..691d9ecb8f 100644
--- a/tests/auto/declarative/qmlecmascript/data/CustomObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/MethodsObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml
index f51ca86633..f51ca86633 100644
--- a/tests/auto/declarative/qmlecmascript/data/MethodsObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml
index 7c32e563b2..7c32e563b2 100644
--- a/tests/auto/declarative/qmlecmascript/data/NestedTypeTransientErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/ScopeObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml
index b7bec63569..b7bec63569 100644
--- a/tests/auto/declarative/qmlecmascript/data/ScopeObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml
index 56e06252c4..56e06252c4 100644
--- a/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml
index 5c3ea1fe16..5c3ea1fe16 100644
--- a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
index db7f2b51c1..db7f2b51c1 100644
--- a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
index 128db692fb..128db692fb 100644
--- a/tests/auto/declarative/qmlecmascript/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml
index 061eda0e54..061eda0e54 100644
--- a/tests/auto/declarative/qmlecmascript/data/attachedProperty.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml b/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml
index 80545cf72b..80545cf72b 100644
--- a/tests/auto/declarative/qmlecmascript/data/bindingLoop.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml
index 3147f63989..3147f63989 100644
--- a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml
index c89bb49b45..c89bb49b45 100644
--- a/tests/auto/declarative/qmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/bug.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml
index 266de76b86..266de76b86 100644
--- a/tests/auto/declarative/qmlecmascript/data/bug.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/compositePropertyType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml
index 80a2814ef3..80a2814ef3 100644
--- a/tests/auto/declarative/qmlecmascript/data/compositePropertyType.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml
index 13c5ae5fff..13c5ae5fff 100644
--- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml
index 207a06b700..207a06b700 100644
--- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml
index ca9d1d8ab9..ca9d1d8ab9 100644
--- a/tests/auto/declarative/qmlecmascript/data/constantsOverrideBindings.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/qmlToString.qml b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml
index ac296ce293..ac296ce293 100644
--- a/tests/auto/declarative/qmlecmascript/data/qmlToString.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml
index e01f708a07..e01f708a07 100644
--- a/tests/auto/declarative/qmlecmascript/data/deferredProperties.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
index 6bc3a17a3f..6bc3a17a3f 100644
--- a/tests/auto/declarative/qmlecmascript/data/deletedObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml
index d790d634e9..d790d634e9 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.helper.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
index ed5e571cb3..ed5e571cb3 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml
index 0855b2915b..0855b2915b 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicDeletion.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/enums.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml
index 6351823230..6351823230 100644
--- a/tests/auto/declarative/qmlecmascript/data/enums.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/enums.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml
index bdc672fadc..bdc672fadc 100644
--- a/tests/auto/declarative/qmlecmascript/data/enums.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml
index a2f0d1a8b7..a2f0d1a8b7 100644
--- a/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml
index acc3163837..acc3163837 100644
--- a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml
index 44e10c1ae0..44e10c1ae0 100644
--- a/tests/auto/declarative/qmlecmascript/data/exceptionProducesWarning2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml
index 9a82ad19d7..9a82ad19d7 100644
--- a/tests/auto/declarative/qmlecmascript/data/extendedObjectPropertyLookup.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/extensionObjects.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml
index a902312802..a902312802 100644
--- a/tests/auto/declarative/qmlecmascript/data/extensionObjects.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.1.qml
index 2ac7b6e57b..2ac7b6e57b 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.2.js b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.js
index 78c3a86859..78c3a86859 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.2.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.js
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.qml
index dec657cb94..dec657cb94 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.3.qml
index d7acf3806e..d7acf3806e 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.3.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.4.qml
index 16211aaeab..16211aaeab 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.4.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.js b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.js
index 892865299f..892865299f 100644
--- a/tests/auto/declarative/qmlecmascript/data/externalScript.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/externalScript.js
diff --git a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml
index 2db0fc6050..2db0fc6050 100644
--- a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml
index f66428d419..f66428d419 100644
--- a/tests/auto/declarative/qmlecmascript/data/idShortcutInvalidates.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/jsObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml
index 4128c92679..4128c92679 100644
--- a/tests/auto/declarative/qmlecmascript/data/jsObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/listProperties.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml
index 810f9b6d7a..810f9b6d7a 100644
--- a/tests/auto/declarative/qmlecmascript/data/listProperties.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/listToVariant.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml
index 47f4e50873..47f4e50873 100644
--- a/tests/auto/declarative/qmlecmascript/data/listToVariant.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml
index 0bbee16df8..0bbee16df8 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml
index 9f0c6b15fe..9f0c6b15fe 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml
index 79efc508d7..79efc508d7 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml
index aac711cbd4..aac711cbd4 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.4.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/methods.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
index 3d45b152a3..3d45b152a3 100644
--- a/tests/auto/declarative/qmlecmascript/data/methods.5.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/multiEngineObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml
index 7da09e4701..7da09e4701 100644
--- a/tests/auto/declarative/qmlecmascript/data/multiEngineObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nonExistantAttachedObject.qml
index f9585db009..f9585db009 100644
--- a/tests/auto/declarative/qmlecmascript/data/nonExistantAttachedObject.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/nonExistantAttachedObject.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml
index 18e488a1cb..18e488a1cb 100644
--- a/tests/auto/declarative/qmlecmascript/data/objectsCompareAsEqual.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml
index 0a933e86f2..0a933e86f2 100644
--- a/tests/auto/declarative/qmlecmascript/data/outerBindingOverridesInnerBinding.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scope.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml
index 8e5aa0b26f..8e5aa0b26f 100644
--- a/tests/auto/declarative/qmlecmascript/data/scope.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml
index cccd3d38d0..cccd3d38d0 100644
--- a/tests/auto/declarative/qmlecmascript/data/scope.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptAccess.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.js
index c00d28500e..c00d28500e 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptAccess.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.js
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.qml
index feb6d167dd..feb6d167dd 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptAccess.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptAccess.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js
index 1d7b35704d..1d7b35704d 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.js
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
index c2edb416ac..c2edb416ac 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml
index 58cf8051f0..58cf8051f0 100644
--- a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml
index 074851a67b..074851a67b 100644
--- a/tests/auto/declarative/qmlecmascript/data/selfDeletingBinding.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/shutdownErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml
index 5a1963910d..5a1963910d 100644
--- a/tests/auto/declarative/qmlecmascript/data/shutdownErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalAssignment.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml
index fbd09142f7..fbd09142f7 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalAssignment.1.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
index 8addcb9125..8addcb9125 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
index 6fc8b02664..6fc8b02664 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml
index 7d419cd7e8..7d419cd7e8 100644
--- a/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/transientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml
index fa7e01c81b..fa7e01c81b 100644
--- a/tests/auto/declarative/qmlecmascript/data/transientErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml
index e73d38e2ce..e73d38e2ce 100644
--- a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml
index eceff60aa1..eceff60aa1 100644
--- a/tests/auto/declarative/qmlecmascript/data/undefinedResetsProperty.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml
diff --git a/tests/auto/declarative/qmlecmascript/data/valueTypeFunctions.qml b/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml
index 33b4a68c40..33b4a68c40 100644
--- a/tests/auto/declarative/qmlecmascript/data/valueTypeFunctions.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
new file mode 100644
index 0000000000..0e21cb2399
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative script
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeecmascript.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
new file mode 100644
index 0000000000..6a047049f8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
+
+class BaseExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged);
+public:
+ BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
+
+ int extendedProperty() const { return m_value; }
+ void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
+
+signals:
+ void extendedPropertyChanged();
+private:
+ int m_value;
+};
+
+class ExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged);
+public:
+ ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
+
+ int extendedProperty() const { return m_value; }
+ void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
+
+signals:
+ void extendedPropertyChanged();
+private:
+ int m_value;
+};
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject);
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject);
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer);
+ QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject);
+ QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject);
+ QML_REGISTER_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject);
+}
+
+#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
new file mode 100644
index 0000000000..8fbd0714b4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -0,0 +1,598 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtDeclarative/qdeclarativelist.h>
+#include <QtCore/qrect.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtCore/qdatetime.h>
+#include <QtScript/qscriptvalue.h>
+#include <QtDeclarative/qdeclarativescriptstring.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
+
+ int value() const { return 19; }
+};
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_ENUMS(MyEnum2)
+ Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
+ Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
+ Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
+ Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
+
+public:
+ MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
+
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
+ bool trueProperty() const { return true; }
+ bool falseProperty() const { return false; }
+
+ QString stringProperty() const { return m_string; }
+ void setStringProperty(const QString &s)
+ {
+ if (s == m_string)
+ return;
+ m_string = s;
+ emit stringChanged();
+ }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) {
+ if (obj == m_object)
+ return;
+ m_object = obj;
+ emit objectChanged();
+ }
+
+ QDeclarativeListProperty<QObject> objectListProperty() { return QDeclarativeListProperty<QObject>(this, m_objectQList); }
+
+ bool methodCalled() const { return m_methodCalled; }
+ bool methodIntCalled() const { return m_methodIntCalled; }
+
+ QString string() const { return m_string; }
+
+ static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new MyQmlAttachedObject(o);
+ }
+
+ int deleteOnSet() const { return 1; }
+ void setDeleteOnSet(int v) { if(v) delete this; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int v) { m_resetProperty = v; }
+ void resetProperty() { m_resetProperty = 13; }
+
+signals:
+ void basicSignal();
+ void argumentSignal(int a, QString b, qreal c);
+ void stringChanged();
+ void objectChanged();
+ void anotherBasicSignal();
+ void thirdBasicSignal();
+
+public slots:
+ void deleteMe() { delete this; }
+ void methodNoArgs() { m_methodCalled = true; }
+ void method(int a) { if(a == 163) m_methodIntCalled = true; }
+ void setString(const QString &s) { m_string = s; }
+
+private:
+ friend class tst_qdeclarativeecmascript;
+ bool m_methodCalled;
+ bool m_methodIntCalled;
+
+ QObject *m_object;
+ QString m_string;
+ QList<QObject *> m_objectQList;
+ int m_value;
+ int m_resetProperty;
+};
+
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(MyQmlObject);
+
+class MyQmlContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children CONSTANT)
+public:
+ MyQmlContainer() {}
+
+ QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
+
+private:
+ QList<MyQmlObject*> m_children;
+};
+
+QML_DECLARE_TYPE(MyQmlContainer);
+
+class MyExpression : public QDeclarativeExpression
+{
+ Q_OBJECT
+public:
+ MyExpression(QDeclarativeContext *ctxt, const QString &expr)
+ : QDeclarativeExpression(ctxt, expr, 0), changed(false)
+ {
+ QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
+ setNotifyOnValueChanged(true);
+ }
+
+ bool changed;
+
+public slots:
+ void expressionValueChanged() {
+ changed = true;
+ }
+};
+
+
+class MyDefaultObject1 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int horseLegs READ horseLegs CONSTANT);
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT);
+public:
+ int horseLegs() const { return 4; }
+ int antLegs() const { return 6; }
+};
+
+class MyDefaultObject2 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT);
+ Q_PROPERTY(int emuLegs READ emuLegs CONSTANT);
+public:
+ int antLegs() const { return 5; } // Had an accident
+ int emuLegs() const { return 2; }
+};
+
+class MyDefaultObject3 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT);
+ Q_PROPERTY(int humanLegs READ humanLegs CONSTANT);
+public:
+ int antLegs() const { return 7; } // Mutant
+ int humanLegs() const { return 2; }
+ int millipedeLegs() const { return 1000; }
+};
+
+class MyDeferredObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
+ Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2);
+ Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2");
+
+public:
+ MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; emit valueChanged(); }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) { m_object = obj; }
+
+ QObject *objectProperty2() const { return m_object2; }
+ void setObjectProperty2(QObject *obj) { m_object2 = obj; }
+
+signals:
+ void valueChanged();
+
+private:
+ int m_value;
+ QObject *m_object;
+ QObject *m_object2;
+};
+QML_DECLARE_TYPE(MyDeferredObject);
+
+class MyBaseExtendedObject : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty);
+public:
+ MyBaseExtendedObject() : m_value(0) {}
+
+ int baseProperty() const { return m_value; }
+ void setBaseProperty(int v) { m_value = v; }
+
+private:
+ int m_value;
+};
+QML_DECLARE_TYPE(MyBaseExtendedObject);
+
+class MyExtendedObject : public MyBaseExtendedObject
+{
+Q_OBJECT
+Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty);
+public:
+ MyExtendedObject() : m_value(0) {}
+
+ int coreProperty() const { return m_value; }
+ void setCoreProperty(int v) { m_value = v; }
+
+private:
+ int m_value;
+};
+QML_DECLARE_TYPE(MyExtendedObject);
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId);
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
+ Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty);
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty);
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty);
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty);
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty);
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty);
+ Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty);
+ Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty);
+ Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty);
+ Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty);
+ Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged);
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2);
+ Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty);
+
+ Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
+
+public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QDeclarativeComponent *componentPropertyValue;
+ QDeclarativeComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QDeclarativeComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
+
+ QPoint pointPropertyValue;
+ QPoint pointProperty() const {
+ return pointPropertyValue;
+ }
+ void setPointProperty(const QPoint &v) {
+ pointPropertyValue = v;
+ }
+
+ QPointF pointFPropertyValue;
+ QPointF pointFProperty() const {
+ return pointFPropertyValue;
+ }
+ void setPointFProperty(const QPointF &v) {
+ pointFPropertyValue = v;
+ }
+
+ QSize sizePropertyValue;
+ QSize sizeProperty() const {
+ return sizePropertyValue;
+ }
+ void setSizeProperty(const QSize &v) {
+ sizePropertyValue = v;
+ }
+
+ QSizeF sizeFPropertyValue;
+ QSizeF sizeFProperty() const {
+ return sizeFPropertyValue;
+ }
+ void setSizeFProperty(const QSizeF &v) {
+ sizeFPropertyValue = v;
+ }
+
+ QRect rectPropertyValue;
+ QRect rectProperty() const {
+ return rectPropertyValue;
+ }
+ void setRectProperty(const QRect &v) {
+ rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
+ }
+
+ QRectF rectFPropertyValue;
+ QRectF rectFProperty() const {
+ return rectFPropertyValue;
+ }
+ void setRectFProperty(const QRectF &v) {
+ rectFPropertyValue = v;
+ }
+
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QDeclarativeScriptString scriptPropertyValue;
+ QDeclarativeScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QDeclarativeScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
+QML_DECLARE_TYPE(MyTypeObject);
+
+Q_DECLARE_METATYPE(QScriptValue);
+class MyInvokableObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyInvokableObject() { reset(); }
+
+ int invoked() const { return m_invoked; }
+ bool error() const { return m_invokedError; }
+ const QVariantList &actuals() const { return m_actuals; }
+ void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
+
+ Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
+ Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
+
+ Q_INVOKABLE void method_NoArgs() { invoke(0); }
+ Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
+ Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.7; }
+ Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
+ Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
+ Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
+ Q_INVOKABLE QScriptValue method_NoArgs_QScriptValue() { invoke(6); return QScriptValue("Hello world"); }
+ Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
+
+ Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
+ Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
+ Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
+ Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
+ Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
+ Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_QScriptValue(QScriptValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_intQScriptValue(int a, QScriptValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
+
+ Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
+ Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
+
+private:
+ void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
+ int m_invoked;
+ bool m_invokedError;
+ QVariantList m_actuals;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
new file mode 100644
index 0000000000..60c380c076
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -0,0 +1,1662 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdebug.h>
+#include <QtDeclarative/private/qdeclarativeguard_p.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qnumeric.h>
+#include <private/qdeclarativeengine_p.h>
+#include <private/qdeclarativeglobalscriptclass_p.h>
+#include "testtypes.h"
+
+/*
+This test covers evaluation of ECMAScript expressions and bindings from within
+QML. This does not include static QML language issues.
+
+Static QML language issues are covered in qmllanguage
+*/
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+class tst_qdeclarativeecmascript : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeecmascript() {}
+
+private slots:
+ void initTestCase();
+ void assignBasicTypes();
+ void idShortcutInvalidates();
+ void boolPropertiesEvaluateAsBool();
+ void methods();
+ void signalAssignment();
+ void bindingLoop();
+ void basicExpressions();
+ void basicExpressions_data();
+ void arrayExpressions();
+ void contextPropertiesTriggerReeval();
+ void objectPropertiesTriggerReeval();
+ void deferredProperties();
+ void extensionObjects();
+ void attachedProperties();
+ void enums();
+ void valueTypeFunctions();
+ void constantsOverrideBindings();
+ void outerBindingOverridesInnerBinding();
+ void aliasPropertyAndBinding();
+ void nonExistantAttachedObject();
+ void scope();
+ void signalParameterTypes();
+ void objectsCompareAsEqual();
+ void scriptAccess();
+ void dynamicCreation_data();
+ void dynamicCreation();
+ void dynamicDestruction();
+ void objectToString();
+ void selfDeletingBinding();
+ void extendedObjectPropertyLookup();
+ void scriptErrors();
+ void signalTriggeredBindings();
+ void listProperties();
+ void exceptionClearsOnReeval();
+ void exceptionSlotProducesWarning();
+ void exceptionBindingProducesWarning();
+ void transientErrors();
+ void shutdownErrors();
+ void externalScript();
+ void compositePropertyType();
+ void jsObject();
+ void undefinedResetsProperty();
+ void listToVariant();
+ void multiEngineObject();
+ void deletedObject();
+
+ void bug1();
+
+ void callQtInvokables();
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativeecmascript::initTestCase() { registerTypes(); }
+
+void tst_qdeclarativeecmascript::assignBasicTypes()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+}
+
+void tst_qdeclarativeecmascript::idShortcutInvalidates()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ }
+}
+
+void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ }
+}
+
+void tst_qdeclarativeecmascript::signalAssignment()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->basicSignal();
+ QCOMPARE(object->string(), QString("pass"));
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->argumentSignal(19, "Hello world!", 10.3);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3"));
+ }
+}
+
+void tst_qdeclarativeecmascript::methods()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), true);
+ QCOMPARE(object->methodIntCalled(), false);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), true);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ QCOMPARE(object->property("test2").toInt(), 17);
+ QCOMPARE(object->property("test3").toInt(), 16);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("methods.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 9);
+ }
+}
+
+void tst_qdeclarativeecmascript::bindingLoop()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingLoop.qml"));
+ QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\"";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qdeclarativeecmascript::basicExpressions_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QVariant>("result");
+ QTest::addColumn<bool>("nest");
+
+ QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false;
+ QTest::newRow("Context property") << "a" << QVariant(1944) << false;
+ QTest::newRow("Context property") << "a" << QVariant(1944) << true;
+ QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false;
+ QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true;
+ QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false;
+ QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true;
+ QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false;
+ QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true;
+ QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false;
+ QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true;
+ QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false;
+ QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false;
+ QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false;
+ QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true;
+ QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true;
+ QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true;
+ QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true;
+ QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true;
+}
+
+void tst_qdeclarativeecmascript::basicExpressions()
+{
+ QFETCH(QString, expression);
+ QFETCH(QVariant, result);
+ QFETCH(bool, nest);
+
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject object3;
+ MyDefaultObject1 default1;
+ MyDefaultObject2 default2;
+ MyDefaultObject3 default3;
+ object1.setStringProperty("Object1");
+ object2.setStringProperty("Object2");
+ object3.setStringProperty("Object3");
+
+ QDeclarativeContext context(engine.rootContext());
+ QDeclarativeContext nestedContext(&context);
+
+ context.addDefaultObject(&default1);
+ context.addDefaultObject(&default2);
+ context.setContextProperty("a", QVariant(1944));
+ context.setContextProperty("b", QVariant("Milk"));
+ context.setContextProperty("object", &object1);
+ context.setContextProperty("objectOverride", &object2);
+ nestedContext.addDefaultObject(&default3);
+ nestedContext.setContextProperty("b", QVariant("Cow"));
+ nestedContext.setContextProperty("objectOverride", &object3);
+ nestedContext.setContextProperty("millipedeLegs", QVariant(100));
+
+ MyExpression expr(nest?&nestedContext:&context, expression);
+ QCOMPARE(expr.value(), result);
+}
+
+void tst_qdeclarativeecmascript::arrayExpressions()
+{
+ QObject obj1;
+ QObject obj2;
+ QObject obj3;
+
+ QDeclarativeContext context(engine.rootContext());
+ context.setContextProperty("a", &obj1);
+ context.setContextProperty("b", &obj2);
+ context.setContextProperty("c", &obj3);
+
+ MyExpression expr(&context, "[a, b, c, 10]");
+ QVariant result = expr.value();
+ QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
+ QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
+ QCOMPARE(list.count(), 4);
+ QCOMPARE(list.at(0), &obj1);
+ QCOMPARE(list.at(1), &obj2);
+ QCOMPARE(list.at(2), &obj3);
+ QCOMPARE(list.at(3), (QObject *)0);
+}
+
+// Tests that modifying a context property will reevaluate expressions
+void tst_qdeclarativeecmascript::contextPropertiesTriggerReeval()
+{
+ QDeclarativeContext context(engine.rootContext());
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject *object3 = new MyQmlObject;
+
+ object1.setStringProperty("Hello");
+ object2.setStringProperty("World");
+
+ context.setContextProperty("testProp", QVariant(1));
+ context.setContextProperty("testObj", &object1);
+ context.setContextProperty("testObj2", object3);
+
+ {
+ MyExpression expr(&context, "testProp + 1");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant(2));
+
+ context.setContextProperty("testProp", QVariant(2));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant(3));
+ }
+
+ {
+ MyExpression expr(&context, "testProp + testProp + testProp");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant(6));
+
+ context.setContextProperty("testProp", QVariant(4));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant(12));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant("Hello"));
+
+ context.setContextProperty("testObj", &object2);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty /**/");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant("World"));
+
+ context.setContextProperty("testObj", &object1);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant("Hello"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj2");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant::fromValue((QObject *)object3));
+ }
+
+}
+
+void tst_qdeclarativeecmascript::objectPropertiesTriggerReeval()
+{
+ QDeclarativeContext context(engine.rootContext());
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject object3;
+ context.setContextProperty("testObj", &object1);
+
+ object1.setStringProperty(QLatin1String("Hello"));
+ object2.setStringProperty(QLatin1String("Dog"));
+ object3.setStringProperty(QLatin1String("Cat"));
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant("Hello"));
+
+ object1.setStringProperty(QLatin1String("World"));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.value(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.objectProperty.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.value(), QVariant());
+
+ object1.setObjectProperty(&object2);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Dog"));
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Cat"));
+
+ object1.setObjectProperty(0);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant());
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Cat"));
+
+ object3.setStringProperty("Donkey");
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.value(), QVariant("Donkey"));
+ }
+}
+
+void tst_qdeclarativeecmascript::deferredProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deferredProperties.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() != 0);
+ qmlExecuteDeferred(object);
+ QCOMPARE(object->value(), 10);
+ QVERIFY(object->objectProperty() != 0);
+ MyQmlObject *qmlObject =
+ qobject_cast<MyQmlObject *>(object->objectProperty());
+ QVERIFY(qmlObject != 0);
+ QCOMPARE(qmlObject->value(), 10);
+ object->setValue(19);
+ QCOMPARE(qmlObject->value(), 19);
+}
+
+void tst_qdeclarativeecmascript::extensionObjects()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml"));
+ MyExtendedObject *object =
+ qobject_cast<MyExtendedObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->baseProperty(), 13);
+ QCOMPARE(object->coreProperty(), 9);
+
+ object->setProperty("extendedProperty", QVariant(11));
+ object->setProperty("baseExtendedProperty", QVariant(92));
+ QCOMPARE(object->coreProperty(), 11);
+ QCOMPARE(object->baseProperty(), 92);
+}
+
+void tst_qdeclarativeecmascript::attachedProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 19);
+ QCOMPARE(object->property("b").toInt(), 19);
+ QCOMPARE(object->property("c").toInt(), 19);
+ QCOMPARE(object->property("d").toInt(), 19);
+
+ // ### Need to test attached property assignment
+}
+
+void tst_qdeclarativeecmascript::enums()
+{
+ // Existant enums
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 1);
+ QCOMPARE(object->property("c").toInt(), 2);
+ QCOMPARE(object->property("d").toInt(), 3);
+ QCOMPARE(object->property("e").toInt(), 0);
+ QCOMPARE(object->property("f").toInt(), 1);
+ QCOMPARE(object->property("g").toInt(), 2);
+ QCOMPARE(object->property("h").toInt(), 3);
+ QCOMPARE(object->property("i").toInt(), 19);
+ QCOMPARE(object->property("j").toInt(), 19);
+ }
+ // Non-existent enums
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
+ QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 0);
+ }
+}
+
+void tst_qdeclarativeecmascript::valueTypeFunctions()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("valueTypeFunctions.qml"));
+ MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
+ QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
+}
+
+/*
+Tests that writing a constant to a property with a binding on it disables the
+binding.
+*/
+void tst_qdeclarativeecmascript::constantsOverrideBindings()
+{
+ // From ECMAScript
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(8));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ }
+
+ // During construction
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ }
+
+#if 0
+ // From C++
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ object->setProperty("c2", QVariant(13));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(7));
+ QCOMPARE(object->property("c1").toInt(), 7);
+ QCOMPARE(object->property("c2").toInt(), 13);
+ }
+#endif
+}
+
+/*
+Tests that assigning a binding to a property that already has a binding causes
+the original binding to be disabled.
+*/
+void tst_qdeclarativeecmascript::outerBindingOverridesInnerBinding()
+{
+ QDeclarativeComponent component(&engine,
+ TEST_FILE("outerBindingOverridesInnerBinding.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c3", QVariant(8));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 8);
+ QCOMPARE(object->property("c3").toInt(), 8);
+}
+
+/*
+Access a non-existent attached object.
+
+Tests for a regression where this used to crash.
+*/
+void tst_qdeclarativeecmascript::nonExistantAttachedObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qdeclarativeecmascript::scope()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("scope.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 1);
+ QCOMPARE(object->property("test2").toInt(), 2);
+ QCOMPARE(object->property("test3").toString(), QString("1Test"));
+ QCOMPARE(object->property("test4").toString(), QString("2Test"));
+ QCOMPARE(object->property("test5").toInt(), 1);
+ QCOMPARE(object->property("test6").toInt(), 1);
+ QCOMPARE(object->property("test7").toInt(), 2);
+ QCOMPARE(object->property("test8").toInt(), 2);
+ QCOMPARE(object->property("test9").toInt(), 1);
+ QCOMPARE(object->property("test10").toInt(), 3);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("scope.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 19);
+ QCOMPARE(object->property("test2").toInt(), 19);
+ QCOMPARE(object->property("test3").toInt(), 11);
+ QCOMPARE(object->property("test4").toInt(), 11);
+ QCOMPARE(object->property("test5").toInt(), 24);
+ QCOMPARE(object->property("test6").toInt(), 24);
+ }
+}
+
+/*
+Tests that "any" type passes through a synthesized signal parameter. This
+is essentially a test of QDeclarativeMetaType::copy()
+*/
+void tst_qdeclarativeecmascript::signalParameterTypes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("signalParameterTypes.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("intProperty").toInt(), 10);
+ QCOMPARE(object->property("realProperty").toReal(), 19.2);
+ QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
+ QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
+}
+
+/*
+Test that two JS objects for the same QObject compare as equal.
+*/
+void tst_qdeclarativeecmascript::objectsCompareAsEqual()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("objectsCompareAsEqual.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+ QCOMPARE(object->property("test5").toBool(), true);
+}
+
+/*
+Confirm bindings and alias properties can coexist.
+
+Tests for a regression where the binding would not reevaluate.
+*/
+void tst_qdeclarativeecmascript::aliasPropertyAndBinding()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyAndBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 3);
+ QCOMPARE(object->property("c3").toInt(), 3);
+
+ object->setProperty("c2", QVariant(19));
+
+ QCOMPARE(object->property("c2").toInt(), 19);
+ QCOMPARE(object->property("c3").toInt(), 19);
+}
+
+/*
+Tests that only methods of Script {} blocks are exposed.
+*/
+void tst_qdeclarativeecmascript::scriptAccess()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptAccess.qml"));
+
+ QString warning = component.url().toString() + ":16: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 10);
+ QCOMPARE(object->property("test2").toInt(), 19);
+ QCOMPARE(object->property("test3").toInt(), 0);
+}
+
+void tst_qdeclarativeecmascript::dynamicCreation_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QString>("createdName");
+
+ QTest::newRow("One") << "createOne" << "objectOne";
+ QTest::newRow("Two") << "createTwo" << "objectTwo";
+ QTest::newRow("Three") << "createThree" << "objectThree";
+}
+
+/*
+Test using createQmlObject to dynamically generate an item
+Also using createComponent is tested.
+*/
+void tst_qdeclarativeecmascript::dynamicCreation()
+{
+ QFETCH(QString, method);
+ QFETCH(QString, createdName);
+
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicCreation.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, method.toUtf8());
+ QObject *created = object->objectProperty();
+ QVERIFY(created);
+ QCOMPARE(created->objectName(), createdName);
+}
+
+/*
+ Tests the destroy function
+*/
+void tst_qdeclarativeecmascript::dynamicDestruction()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicDeletion.qml"));
+ QDeclarativeGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QDeclarativeGuard<QObject> createdQmlObject = 0;
+
+ QMetaObject::invokeMethod(object, "create");
+ createdQmlObject = object->objectProperty();
+ QVERIFY(createdQmlObject);
+ QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
+
+ QMetaObject::invokeMethod(object, "killOther");
+ QVERIFY(createdQmlObject);
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+ QVERIFY(createdQmlObject);
+ for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
+ if (createdQmlObject) {
+ QTest::qWait(100);
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+ }
+ }
+ QVERIFY(!createdQmlObject);
+
+ QMetaObject::invokeMethod(object, "killMe");
+ QVERIFY(object);
+ QTest::qWait(0);
+ QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
+ QVERIFY(!object);
+}
+
+/*
+ tests that id.toString() works
+*/
+void tst_qdeclarativeecmascript::objectToString()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("declarativeToString.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "testToString");
+ QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_"));
+ QVERIFY(object->stringProperty().endsWith(", \"objName\")"));
+}
+
+/*
+Tests bindings that indirectly cause their own deletion work.
+
+This test is best run under valgrind to ensure no invalid memory access occur.
+*/
+void tst_qdeclarativeecmascript::selfDeletingBinding()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ }
+}
+
+/*
+Test that extended object properties can be accessed.
+
+This test a regression where this used to crash. The issue was specificially
+for extended objects that did not include a synthesized meta object (so non-root
+and no synthesiszed properties).
+*/
+void tst_qdeclarativeecmascript::extendedObjectPropertyLookup()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+/*
+Test file/lineNumbers for binding/Script errors.
+*/
+void tst_qdeclarativeecmascript::scriptErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
+ QString warning2 = url + ":7: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning3 = url + ":5: Error: Invalid write to global property \"a\"";
+ QString warning4 = url + ":12: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning5 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning6 = url + ":9: Unable to assign [undefined] to int";
+ QString warning7 = url + ":14: Error: Cannot assign to read-only property \"trueProperty\"";
+ QString warning8 = url + ":15: Error: Cannot assign to non-existent property \"fakeProperty\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
+ emit object->basicSignal();
+
+ QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData());
+ emit object->anotherBasicSignal();
+
+ QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData());
+ emit object->thirdBasicSignal();
+}
+
+/*
+Test bindings still work when the reeval is triggered from within
+a signal script.
+*/
+void tst_qdeclarativeecmascript::signalTriggeredBindings()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("signalTriggeredBindings.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("base").toReal(), 50.);
+ QCOMPARE(object->property("test1").toReal(), 50.);
+ QCOMPARE(object->property("test2").toReal(), 50.);
+
+ object->basicSignal();
+
+ QCOMPARE(object->property("base").toReal(), 200.);
+ QCOMPARE(object->property("test1").toReal(), 200.);
+ QCOMPARE(object->property("test2").toReal(), 200.);
+
+ object->argumentSignal(10, QString(), 10);
+
+ QCOMPARE(object->property("base").toReal(), 400.);
+ QCOMPARE(object->property("test1").toReal(), 400.);
+ QCOMPARE(object->property("test2").toReal(), 400.);
+}
+
+/*
+Test that list properties can be iterated from ECMAScript
+*/
+void tst_qdeclarativeecmascript::listProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 21);
+ QCOMPARE(object->property("test2").toInt(), 2);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+}
+
+void tst_qdeclarativeecmascript::exceptionClearsOnReeval()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object.";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+
+ MyQmlObject object2;
+ MyQmlObject object3;
+ object2.setObjectProperty(&object3);
+ object->setObjectProperty(&object2);
+
+ QCOMPARE(object->property("test").toBool(), true);
+}
+
+void tst_qdeclarativeecmascript::exceptionSlotProducesWarning()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("exceptionProducesWarning.qml"));
+ QString url = component.url().toString();
+
+ QString warning = component.url().toString() + ":6: Error: JS exception";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+}
+
+void tst_qdeclarativeecmascript::exceptionBindingProducesWarning()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("exceptionProducesWarning2.qml"));
+ QString url = component.url().toString();
+
+ QString warning = component.url().toString() + ":5: Error: JS exception";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+}
+
+static int transientErrorsMsgCount = 0;
+static void transientErrorsMsgHandler(QtMsgType, const char *)
+{
+ ++transientErrorsMsgCount;
+}
+
+// Check that transient binding errors are not displayed
+void tst_qdeclarativeecmascript::transientErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+}
+
+// Check that errors during shutdown are minimized
+void tst_qdeclarativeecmascript::shutdownErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("shutdownErrors.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete object;
+
+ qInstallMsgHandler(old);
+ QCOMPARE(transientErrorsMsgCount, 0);
+}
+
+// Check that Script::source property works as expected
+void tst_qdeclarativeecmascript::externalScript()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+ QCOMPARE(object->property("test2").toInt(), 92);
+ QCOMPARE(object->property("test3").toBool(), false);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("externalScript.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativeecmascript::compositePropertyType()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("compositePropertyType.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "hello world");
+ QObject *object = qobject_cast<QObject *>(component.create());
+ delete object;
+}
+
+// QTBUG-5759
+void tst_qdeclarativeecmascript::jsObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("jsObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+}
+
+void tst_qdeclarativeecmascript::undefinedResetsProperty()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("undefinedResetsProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 92);
+
+ object->setProperty("setUndefined", true);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 13);
+
+ object->setProperty("setUndefined", false);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 92);
+
+ delete object;
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("undefinedResetsProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 19);
+
+ QMetaObject::invokeMethod(object, "doReset");
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 13);
+
+ delete object;
+ }
+}
+
+// QTBUG-6781
+void tst_qdeclarativeecmascript::bug1()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bug.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 14);
+
+ object->setProperty("a", 11);
+
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ object->setProperty("b", true);
+
+ QCOMPARE(object->property("test").toInt(), 9);
+
+ delete object;
+}
+
+void tst_qdeclarativeecmascript::callQtInvokables()
+{
+ MyInvokableObject o;
+
+ QDeclarativeEngine qmlengine;
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
+ QScriptEngine *engine = &ep->scriptEngine;
+ ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
+
+ // Non-existent methods
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_nonexistent()").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_nonexistent(10, 11)").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Insufficient arguments
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int()").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intint(10)").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Excessive arguments
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(10, 11)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intint(10, 11, 12)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 9);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ // Test return types
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_NoArgs()").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 0);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(engine->evaluate("object.method_NoArgs_int()").strictlyEquals(QScriptValue(engine, 6)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 2);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()");
+ QVERIFY(ret.isVariant());
+ QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 3);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ {
+ QScriptValue ret = engine->evaluate("object.method_NoArgs_QObject()");
+ QVERIFY(ret.isQObject());
+ QCOMPARE(ret.toQObject(), (QObject *)&o);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 4);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_NoArgs_unknown()").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 5);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ QScriptValue ret = engine->evaluate("object.method_NoArgs_QScriptValue()");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString("Hello world"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 6);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QVERIFY(engine->evaluate("object.method_NoArgs_QVariant()").strictlyEquals(QScriptValue(engine, "QML rocks")));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 7);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Test arg types
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(94)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(\"94\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(\"not a number\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_int(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intint(122, 9)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 9);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(122));
+ QCOMPARE(o.actuals().at(1), QVariant(9));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(94.3)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(\"94.3\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(\"not a number\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_real(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(\"Hello world\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(19)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("19"));
+
+ o.reset();
+ {
+ QString expected = "MyInvokableObject(0x" + QString::number((intptr_t)&o, 16) + ")";
+ QCOMPARE(engine->evaluate("object.method_QString(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(expected));
+ }
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QString(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(0)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPointF())").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPoint())").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(0)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(\"Hello world\")").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QObject(object)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue(null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isNull());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue(undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isUndefined());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue(19)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).strictlyEquals(QScriptValue(engine, 19)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_QScriptValue([19, 20])").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isArray());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(4, null)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(4));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isNull());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(8, undefined)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(8));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isUndefined());
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(3, 19)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(3));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).strictlyEquals(QScriptValue(engine, 19)));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_intQScriptValue(44, [19, 20])").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(44));
+ QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isArray());
+
+ // Test overloads - QML will always invoke the *last* method
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_overload()").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_overload(10)").isError(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_overload(10, 11)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 17);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(11));
+}
+
+// QTBUG-5675
+void tst_qdeclarativeecmascript::listToVariant()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("listToVariant.qml"));
+
+ MyQmlContainer container;
+
+ QDeclarativeContext context(engine.rootContext());
+ context.addDefaultObject(&container);
+
+ QObject *object = component.create(&context);
+ QVERIFY(object != 0);
+
+ QVariant v = object->property("test");
+ QCOMPARE(v.userType(), qMetaTypeId<QDeclarativeListReference>());
+ QVERIFY(qvariant_cast<QDeclarativeListReference>(v).object() == &container);
+
+ delete object;
+}
+
+// QTBUG-7957
+void tst_qdeclarativeecmascript::multiEngineObject()
+{
+ MyQmlObject obj;
+ obj.setStringProperty("Howdy planet");
+
+ QDeclarativeEngine e1;
+ e1.rootContext()->setContextProperty("thing", &obj);
+ QDeclarativeComponent c1(&e1, TEST_FILE("multiEngineObject.qml"));
+
+ QDeclarativeEngine e2;
+ e2.rootContext()->setContextProperty("thing", &obj);
+ QDeclarativeComponent c2(&e2, TEST_FILE("multiEngineObject.qml"));
+
+ QObject *o1 = c1.create();
+ QObject *o2 = c2.create();
+
+ QCOMPARE(o1->property("test").toString(), QString("Howdy planet"));
+ QCOMPARE(o2->property("test").toString(), QString("Howdy planet"));
+
+ delete o2;
+ delete o1;
+}
+
+// Test that references to QObjects are cleanup when the object is destroyed
+void tst_qdeclarativeecmascript::deletedObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deletedObject.qml"));
+
+ QObject *object = component.create();
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QEXPECT_FAIL("", "QTBUG-8077", Continue);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qdeclarativeecmascript)
+
+#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
new file mode 100644
index 0000000000..5b6530dc2e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeengine.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
new file mode 100644
index 0000000000..5dc5f19f70
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeContext>
+#include <QNetworkAccessManager>
+#include <QPointer>
+#include <QDir>
+#include <QDesktopServices>
+#include <QDebug>
+#include <QDeclarativeComponent>
+#include <QDeclarativeNetworkAccessManagerFactory>
+
+class tst_qdeclarativeengine : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeengine() {}
+
+private slots:
+ void rootContext();
+ void networkAccessManager();
+ void baseUrl();
+ void contextForObject();
+ void offlineStoragePath();
+ void clearComponentCache();
+};
+
+void tst_qdeclarativeengine::rootContext()
+{
+ QDeclarativeEngine engine;
+
+ QVERIFY(engine.rootContext());
+
+ QCOMPARE(engine.rootContext()->engine(), &engine);
+ QVERIFY(engine.rootContext()->parentContext() == 0);
+}
+
+class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
+{
+public:
+ NetworkAccessManagerFactory() : manager(0) {}
+
+ QNetworkAccessManager *create(QObject *parent) {
+ manager = new QNetworkAccessManager(parent);
+ return manager;
+ }
+
+ QNetworkAccessManager *manager;
+};
+
+void tst_qdeclarativeengine::networkAccessManager()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+
+ // Test QDeclarativeEngine created manager
+ QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
+ QVERIFY(manager != 0);
+ delete engine;
+
+ // Test factory created manager
+ engine = new QDeclarativeEngine;
+ NetworkAccessManagerFactory factory;
+ engine->setNetworkAccessManagerFactory(&factory);
+ QVERIFY(engine->networkAccessManager() == factory.manager);
+ delete engine;
+}
+
+void tst_qdeclarativeengine::baseUrl()
+{
+ QDeclarativeEngine engine;
+
+ QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+
+ QCOMPARE(engine.baseUrl(), cwd);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
+
+ QDir dir = QDir::current();
+ dir.cdUp();
+ QVERIFY(dir != QDir::current());
+ QDir::setCurrent(dir.path());
+ QVERIFY(QDir::current() == dir);
+
+ QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+ QCOMPARE(engine.baseUrl(), cwd2);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml")));
+
+ engine.setBaseUrl(cwd);
+ QCOMPARE(engine.baseUrl(), cwd);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
+}
+
+void tst_qdeclarativeengine::contextForObject()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+
+ // Test null-object
+ QVERIFY(QDeclarativeEngine::contextForObject(0) == 0);
+
+ // Test an object with no context
+ QObject object;
+ QVERIFY(QDeclarativeEngine::contextForObject(&object) == 0);
+
+ // Test setting null-object
+ QDeclarativeEngine::setContextForObject(0, engine->rootContext());
+
+ // Test setting null-context
+ QDeclarativeEngine::setContextForObject(&object, 0);
+
+ // Test setting context
+ QDeclarativeEngine::setContextForObject(&object, engine->rootContext());
+ QVERIFY(QDeclarativeEngine::contextForObject(&object) == engine->rootContext());
+
+ QDeclarativeContext context(engine->rootContext());
+
+ // Try changing context
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
+ QDeclarativeEngine::setContextForObject(&object, &context);
+ QVERIFY(QDeclarativeEngine::contextForObject(&object) == engine->rootContext());
+
+ // Delete context
+ delete engine; engine = 0;
+ QVERIFY(QDeclarativeEngine::contextForObject(&object) == 0);
+}
+
+void tst_qdeclarativeengine::offlineStoragePath()
+{
+ // Without these set, QDesktopServices::storageLocation returns
+ // strings with extra "//" at the end. We set them to ignore this problem.
+ qApp->setApplicationName("tst_qdeclarativeengine");
+ qApp->setOrganizationName("Nokia");
+ qApp->setOrganizationDomain("nokia.com");
+
+ QDeclarativeEngine engine;
+
+ QDir dir(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
+ dir.mkpath("QML");
+ dir.cd("QML");
+ dir.mkpath("OfflineStorage");
+ dir.cd("OfflineStorage");
+
+ QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path());
+
+ engine.setOfflineStoragePath(QDir::homePath());
+ QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
+}
+
+void tst_qdeclarativeengine::clearComponentCache()
+{
+ QDeclarativeEngine engine;
+
+ // Create original qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import Qt 4.6\nQtObject {\nproperty int test: 10\n}\n");
+ file.close();
+ }
+
+ // Test "test" property
+ {
+ QDeclarativeComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Modify qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import Qt 4.6\nQtObject {\nproperty int test: 11\n}\n");
+ file.close();
+ }
+
+ // Test cache hit
+ {
+ QDeclarativeComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Clear cache
+ engine.clearComponentCache();
+
+ // Test cache refresh
+ {
+ QDeclarativeComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 11);
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativeengine)
+
+#include "tst_qdeclarativeengine.moc"
diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
new file mode 100644
index 0000000000..6591406462
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeerror.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlerror/test.txt b/tests/auto/declarative/qdeclarativeerror/test.txt
index cdafd9ed82..cdafd9ed82 100644
--- a/tests/auto/declarative/qmlerror/test.txt
+++ b/tests/auto/declarative/qdeclarativeerror/test.txt
diff --git a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
new file mode 100644
index 0000000000..ba1ebae402
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeError>
+#include <QDebug>
+
+class tst_qdeclarativeerror : public QObject
+{
+ Q_OBJECT
+private slots:
+ void url();
+ void description();
+ void line();
+ void column();
+ void toString();
+
+ void copy();
+ void debug();
+};
+
+void tst_qdeclarativeerror::url()
+{
+ QDeclarativeError error;
+
+ QCOMPARE(error.url(), QUrl());
+
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+
+ QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
+
+ QDeclarativeError error2 = error;
+
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+
+ error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
+
+ QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+}
+
+void tst_qdeclarativeerror::description()
+{
+ QDeclarativeError error;
+
+ QCOMPARE(error.description(), QString());
+
+ error.setDescription("An Error");
+
+ QCOMPARE(error.description(), QString("An Error"));
+
+ QDeclarativeError error2 = error;
+
+ QCOMPARE(error2.description(), QString("An Error"));
+
+ error.setDescription("Another Error");
+
+ QCOMPARE(error.description(), QString("Another Error"));
+ QCOMPARE(error2.description(), QString("An Error"));
+}
+
+void tst_qdeclarativeerror::line()
+{
+ QDeclarativeError error;
+
+ QCOMPARE(error.line(), -1);
+
+ error.setLine(102);
+
+ QCOMPARE(error.line(), 102);
+
+ QDeclarativeError error2 = error;
+
+ QCOMPARE(error2.line(), 102);
+
+ error.setLine(4);
+
+ QCOMPARE(error.line(), 4);
+ QCOMPARE(error2.line(), 102);
+}
+
+void tst_qdeclarativeerror::column()
+{
+ QDeclarativeError error;
+
+ QCOMPARE(error.column(), -1);
+
+ error.setColumn(16);
+
+ QCOMPARE(error.column(), 16);
+
+ QDeclarativeError error2 = error;
+
+ QCOMPARE(error2.column(), 16);
+
+ error.setColumn(3);
+
+ QCOMPARE(error.column(), 3);
+ QCOMPARE(error2.column(), 16);
+}
+
+void tst_qdeclarativeerror::toString()
+{
+ {
+ QDeclarativeError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error"));
+ }
+
+ {
+ QDeclarativeError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+
+ QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error"));
+ }
+}
+
+void tst_qdeclarativeerror::copy()
+{
+ QDeclarativeError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QDeclarativeError error2(error);
+ QDeclarativeError error3;
+ error3 = error;
+
+ error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
+ error.setDescription("Another Error");
+ error.setLine(2);
+ error.setColumn(33);
+
+ QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
+ QCOMPARE(error.description(), QString("Another Error"));
+ QCOMPARE(error.line(), 2);
+ QCOMPARE(error.column(), 33);
+
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+ QCOMPARE(error2.description(), QString("An Error"));
+ QCOMPARE(error2.line(), 92);
+ QCOMPARE(error2.column(), 13);
+
+ QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml"));
+ QCOMPARE(error3.description(), QString("An Error"));
+ QCOMPARE(error3.line(), 92);
+ QCOMPARE(error3.column(), 13);
+
+}
+
+void tst_qdeclarativeerror::debug()
+{
+ {
+ QDeclarativeError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error ");
+ qWarning() << error;
+ }
+
+ {
+ QUrl url(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("test.txt")));
+ QDeclarativeError error;
+ error.setUrl(url);
+ error.setDescription("An Error");
+ error.setLine(2);
+ error.setColumn(5);
+
+ QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
+
+ qWarning() << error;
+ }
+
+ {
+ QUrl url(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("foo.txt")));
+ QDeclarativeError error;
+ error.setUrl(url);
+ error.setDescription("An Error");
+ error.setLine(2);
+ error.setColumn(5);
+
+ QString out = url.toString() + ":2:5: An Error ";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
+
+ qWarning() << error;
+ }
+}
+
+
+
+QTEST_MAIN(tst_qdeclarativeerror)
+
+#include "tst_qdeclarativeerror.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable01.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml
index 8a1843c79e..8a1843c79e 100644
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable01.qml
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml
new file mode 100644
index 0000000000..4b82d5c4e5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: row.width; contentHeight: row.height
+
+ Row {
+ id: row
+ Repeater {
+ model: 4
+ Rectangle { width: 200; height: 300; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
new file mode 100644
index 0000000000..49eed5a299
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: column.width; contentHeight: column.height
+
+ Column {
+ id: column
+ Repeater {
+ model: 4
+ Rectangle { width: 200; height: 300; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
new file mode 100644
index 0000000000..40c4606e2b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+
+Flickable {
+ width: 100; height: 100
+ contentWidth: column.width; contentHeight: column.height
+ pressDelay: 200; overShoot: false; interactive: false
+ maximumFlickVelocity: 2000
+
+ Column {
+ id: column
+ Repeater {
+ model: 4
+ Rectangle { width: 200; height: 300; color: "blue" }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
new file mode 100644
index 0000000000..4b71381266
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeflickable.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
new file mode 100644
index 0000000000..cb87977f04
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -0,0 +1,223 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeflickable_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include <math.h>
+
+class tst_qdeclarativeflickable : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeflickable();
+
+private slots:
+ void create();
+ void horizontalViewportSize();
+ void verticalViewportSize();
+ void properties();
+ void overShoot();
+ void maximumFlickVelocity();
+ void flickDeceleration();
+ void pressDelay();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeflickable::tst_qdeclarativeflickable()
+{
+}
+
+void tst_qdeclarativeflickable::create()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+
+ QCOMPARE(obj->horizontalVelocity(), 0.);
+ QCOMPARE(obj->verticalVelocity(), 0.);
+
+ QCOMPARE(obj->isInteractive(), true);
+ QCOMPARE(obj->overShoot(), true);
+ QCOMPARE(obj->pressDelay(), 0);
+ QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::horizontalViewportSize()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 800.);
+ QCOMPARE(obj->contentHeight(), 300.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::verticalViewportSize()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 200.);
+ QCOMPARE(obj->contentHeight(), 1200.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml"));
+ QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isInteractive(), false);
+ QCOMPARE(obj->overShoot(), false);
+ QCOMPARE(obj->pressDelay(), 200);
+ QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+
+ delete obj;
+}
+
+void tst_qdeclarativeflickable::overShoot()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(overShootChanged()));
+
+ QVERIFY(flickable);
+ QVERIFY(!flickable->overShoot());
+
+ flickable->setOverShoot(true);
+ QVERIFY(flickable->overShoot());
+ QCOMPARE(spy.count(),1);
+ flickable->setOverShoot(true);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setOverShoot(false);
+ QVERIFY(!flickable->overShoot());
+ QCOMPARE(spy.count(),2);
+ flickable->setOverShoot(false);
+ QCOMPARE(spy.count(),2);
+}
+
+void tst_qdeclarativeflickable::maximumFlickVelocity()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
+
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qdeclarativeflickable::flickDeceleration()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->flickDeceleration(), 1.0);
+
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(flickable->flickDeceleration(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qdeclarativeflickable::pressDelay()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
+ QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->pressDelay(), 100);
+
+ flickable->setPressDelay(200);
+ QCOMPARE(flickable->pressDelay(), 200);
+ QCOMPARE(spy.count(),1);
+ flickable->setPressDelay(200);
+ QCOMPARE(spy.count(),1);
+}
+
+QTEST_MAIN(tst_qdeclarativeflickable)
+
+#include "tst_qdeclarativeflickable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflipable/data/test-flipable.qml b/tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml
index 21d356d524..21d356d524 100644
--- a/tests/auto/declarative/qmlgraphicsflipable/data/test-flipable.qml
+++ b/tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml
diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
new file mode 100644
index 0000000000..e29d3247b1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeflipable.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp
new file mode 100644
index 0000000000..ed37c43333
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeflipable_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include <QFontMetrics>
+#include <private/qdeclarativerectangle_p.h>
+#include <math.h>
+
+class tst_qdeclarativeflipable : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeflipable();
+
+private slots:
+ void create();
+ void checkFrontAndBack();
+ void setFrontAndBack();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeflipable::tst_qdeclarativeflipable()
+{
+}
+
+void tst_qdeclarativeflipable::create()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
+ QDeclarativeFlipable *obj = qobject_cast<QDeclarativeFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ delete obj;
+}
+
+void tst_qdeclarativeflipable::checkFrontAndBack()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
+ QDeclarativeFlipable *obj = qobject_cast<QDeclarativeFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+ delete obj;
+}
+
+void tst_qdeclarativeflipable::setFrontAndBack()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
+ QDeclarativeFlipable *obj = qobject_cast<QDeclarativeFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+
+ QString message = "QML Flipable (" + c.url().toString() + ":3:1) front is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setFront(new QDeclarativeRectangle());
+
+ message = "QML Flipable (" + c.url().toString() + ":3:1) back is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setBack(new QDeclarativeRectangle());
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativeflipable)
+
+#include "tst_qdeclarativeflipable.moc"
diff --git a/tests/auto/declarative/qmlfontloader/data/dummy.ttf b/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qmlfontloader/data/dummy.ttf
+++ b/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf
diff --git a/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf b/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
index cf93f9651f..cf93f9651f 100644
--- a/tests/auto/declarative/qmlfontloader/data/tarzeau_ocr_a.ttf
+++ b/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
new file mode 100644
index 0000000000..0c736b4f77
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativefontloader.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
new file mode 100644
index 0000000000..a9762df6a3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativefontloader_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativefontloader : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativefontloader();
+
+private slots:
+ void noFont();
+ void namedFont();
+ void localFont();
+ void failLocalFont();
+ void webFont();
+ void failWebFont();
+
+private slots:
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativefontloader::tst_qdeclarativefontloader()
+{
+}
+
+void tst_qdeclarativefontloader::noFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QCOMPARE(fontObject->name(), QString(""));
+ QCOMPARE(fontObject->source(), QUrl(""));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Null);
+
+ delete fontObject;
+}
+
+void tst_qdeclarativefontloader::namedFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { name: \"Helvetica\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QCOMPARE(fontObject->source(), QUrl(""));
+ QCOMPARE(fontObject->name(), QString("Helvetica"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::localFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::failLocalFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }";
+ QTest::ignoreMessage(QtWarningMsg, QString("Cannot load font: QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" ) ").toUtf8().constData());
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
+}
+
+void tst_qdeclarativefontloader::webFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("Starburst"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::failWebFont()
+{
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }";
+ QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.com/Starburst.ttf\" ) ");
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
+}
+
+QTEST_MAIN(tst_qdeclarativefontloader)
+
+#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml b/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml
new file mode 100644
index 0000000000..d3cdcd8b48
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.color: "blue"
+ Text {
+ text: index
+ }
+ Text {
+ y: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ]
+ GridView {
+ id: grid
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ model: testModel
+ delegate: myDelegate
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
index 32833d2f08..32833d2f08 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml
index 344b4b5939..344b4b5939 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview2.qml
index 62b5bd35b4..62b5bd35b4 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview2.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview2.qml
diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview3.qml
index b133d55934..b133d55934 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview3.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview3.qml
diff --git a/tests/auto/declarative/qdeclarativegridview/data/setindex.qml b/tests/auto/declarative/qdeclarativegridview/data/setindex.qml
new file mode 100644
index 0000000000..908b365f63
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/data/setindex.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200
+ height: 200
+ Component {
+ id: appDelegate
+
+ Item {
+ id : wrapper
+ Script {
+ function startupFunction()
+ {
+ if (index == 5) view.currentIndex = index;
+
+ }
+ }
+ Component.onCompleted: startupFunction();
+ width: 30; height: 30
+ Text { text: index }
+ }
+ }
+
+ GridView {
+ id: view
+ objectName: "grid"
+ anchors.fill: parent
+ cellWidth: 30; cellHeight: 30
+ model: 35
+ delegate: appDelegate
+ focus: true
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
new file mode 100644
index 0000000000..af206d7489
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativegridview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
new file mode 100644
index 0000000000..2a60feef16
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -0,0 +1,1022 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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.h>
+#include <qdeclarativecomponent.h>
+#include <QStringListModel>
+#include <QtTest/QtTest>
+#include <private/qlistmodelinterface_p.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativegridview_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+
+class tst_QDeclarativeGridView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeGridView();
+
+private slots:
+ void items();
+ void changed();
+ void inserted();
+ void removed();
+ void moved();
+ void changeFlow();
+ void currentIndex();
+ void defaultValues();
+ void properties();
+ void positionViewAtIndex();
+ void resetModel();
+ void QTBUG_8456();
+
+private:
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
+ template<typename T>
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
+ void dumpTree(QDeclarativeItem *parent, int depth = 0);
+};
+
+class TestModel : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+ }
+
+ int count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+tst_QDeclarativeGridView::tst_QDeclarativeGridView()
+{
+}
+
+void tst_QDeclarativeGridView::items()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(gridview->count(), model.count());
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // set an empty model and confirm that items are destroyed
+ TestModel model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QVERIFY(itemCount == 0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::changed()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::inserted()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ QCOMPARE(gridview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+ QTest::qWait(300);
+
+ gridview->setContentY(120);
+ QTest::qWait(300);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+ QTest::qWait(300);
+
+ QVERIFY(gridview->contentY() == 120);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::removed()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items not visible
+ model.removeItem(25);
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items before visible
+ gridview->setContentY(120);
+ QTest::qWait(500);
+ gridview->setCurrentIndex(10);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Setting currentIndex above shouldn't cause view to scroll
+ QCOMPARE(gridview->contentY(), 120.0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ for (int i = 6; i < 18; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove currentIndex
+ QDeclarativeItem *oldCurrent = gridview->currentItem();
+ model.removeItem(9);
+ QTest::qWait(500);
+
+ QCOMPARE(gridview->currentIndex(), 9);
+ QVERIFY(gridview->currentItem() != oldCurrent);
+
+ gridview->setContentY(0);
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ // remove item outside current view.
+ gridview->setCurrentIndex(32);
+ QTest::qWait(500);
+ gridview->setContentY(240);
+
+ model.removeItem(30);
+ QVERIFY(gridview->currentIndex() == 31);
+
+ // remove current item beyond visible items.
+ gridview->setCurrentIndex(20);
+ QTest::qWait(500);
+ gridview->setContentY(0);
+ model.removeItem(20);
+ QTest::qWait(500);
+
+ QCOMPARE(gridview->currentIndex(), 20);
+ QVERIFY(gridview->currentItem() != 0);
+
+ // remove item before current, but visible
+ gridview->setCurrentIndex(8);
+ QTest::qWait(500);
+ gridview->setContentY(240);
+ oldCurrent = gridview->currentItem();
+ model.removeItem(6);
+ QTest::qWait(500);
+
+ QCOMPARE(gridview->currentIndex(), 7);
+ QVERIFY(gridview->currentItem() == oldCurrent);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::moved()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.moveItem(1, 8);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 8);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(8));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 8);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(8));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ }
+
+ gridview->setContentY(120);
+
+ // move outside visible area
+ model.moveItem(1, 25);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1;
+ for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i%3)*80));
+ QCOMPARE(item->y(), qreal((i/3)*60));
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // move from outside visible into visible
+ model.moveItem(28, 8);
+
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly and indexes correct
+ for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->x() == (i%3)*80);
+ QVERIFY(item->y() == (i/3)*60);
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::currentIndex()
+{
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(SRCDIR "/data/gridview-initCurrent.qml");
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QTest::qWait(500);
+
+ // current item should be third item
+ QCOMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 6);
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), 9);
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 6);
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 5);
+
+ // no wrap
+ gridview->setCurrentIndex(0);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->setCurrentIndex(model.count()-1);
+ QTest::qWait(500);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ // with wrap
+ gridview->setWrapEnabled(true);
+
+ gridview->setCurrentIndex(0);
+ QCOMPARE(gridview->currentIndex(), 0);
+ QTest::qWait(500);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ QTest::qWait(500);
+ QCOMPARE(gridview->contentY(), 279.0);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTest::qWait(500);
+ QCOMPARE(gridview->contentY(), 0.0);
+
+ // Test keys
+ qApp->setActiveWindow(canvas);
+ canvas->show();
+ canvas->setFocus();
+ qApp->processEvents();
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 3);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->setFlow(QDeclarativeGridView::TopToBottom);
+
+ QEXPECT_FAIL("", "QTBUG-8475", Abort);
+ QTest::keyClick(canvas, Qt::Key_Right);
+ QCOMPARE(gridview->currentIndex(), 5);
+
+ QTest::keyClick(canvas, Qt::Key_Left);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 1);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+
+ // turn off auto highlight
+ gridview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+
+ QTest::qWait(500);
+ QVERIFY(gridview->highlightItem());
+ qreal hlPosX = gridview->highlightItem()->x();
+ qreal hlPosY = gridview->highlightItem()->y();
+
+ gridview->setCurrentIndex(5);
+ QTest::qWait(500);
+ QCOMPARE(gridview->highlightItem()->x(), hlPosX);
+ QCOMPARE(gridview->highlightItem()->y(), hlPosY);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::changeFlow()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i%3)*80));
+ QCOMPARE(item->y(), qreal((i/3)*60));
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i/5)*80));
+ QCOMPARE(item->y(), qreal((i%5)*60));
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml"));
+ QDeclarativeGridView *obj = qobject_cast<QDeclarativeGridView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->model() == QVariant());
+ QVERIFY(obj->delegate() == 0);
+ QCOMPARE(obj->currentIndex(), -1);
+ QVERIFY(obj->currentItem() == 0);
+ QCOMPARE(obj->count(), 0);
+ QVERIFY(obj->highlight() == 0);
+ QVERIFY(obj->highlightItem() == 0);
+ QCOMPARE(obj->highlightFollowsCurrentItem(), true);
+ QVERIFY(obj->flow() == 0);
+ QCOMPARE(obj->isWrapEnabled(), false);
+ QCOMPARE(obj->cacheBuffer(), 0);
+ QCOMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
+ QCOMPARE(obj->cellHeight(), 100);
+ delete obj;
+}
+
+void tst_QDeclarativeGridView::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml"));
+ QDeclarativeGridView *obj = qobject_cast<QDeclarativeGridView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->model() != QVariant());
+ QVERIFY(obj->delegate() != 0);
+ QCOMPARE(obj->currentIndex(), 0);
+ QVERIFY(obj->currentItem() != 0);
+ QCOMPARE(obj->count(), 4);
+ QVERIFY(obj->highlight() != 0);
+ QVERIFY(obj->highlightItem() != 0);
+ QCOMPARE(obj->highlightFollowsCurrentItem(), false);
+ QVERIFY(obj->flow() == 0);
+ QCOMPARE(obj->isWrapEnabled(), true);
+ QCOMPARE(obj->cacheBuffer(), 200);
+ QCOMPARE(obj->cellWidth(), 100);
+ QCOMPARE(obj->cellHeight(), 100);
+ delete obj;
+}
+
+void tst_QDeclarativeGridView::positionViewAtIndex()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on a currently visible item
+ gridview->positionViewAtIndex(4);
+ QCOMPARE(gridview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item beyond the visible items
+ gridview->positionViewAtIndex(21);
+ QCOMPARE(gridview->contentY(), 420.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ gridview->positionViewAtIndex(31);
+ QCOMPARE(gridview->contentY(), 520.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position at the beginning again
+ gridview->positionViewAtIndex(0);
+ QCOMPARE(gridview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), (i%3)*80.);
+ QCOMPARE(item->y(), (i/3)*60.);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeGridView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaygrid.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+void tst_QDeclarativeGridView::QTBUG_8456()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/setindex.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QCOMPARE(gridview->currentIndex(), 0);
+}
+
+QDeclarativeView *tst_QDeclarativeGridView::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+/*
+ Find an item with the specified objectName. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+*/
+template<typename T>
+T *tst_QDeclarativeGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
+ if (context) {
+ if (context->contextProperty("index").toInt() == index) {
+ return static_cast<T*>(item);
+ }
+ }
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+template<typename T>
+QList<T*> tst_QDeclarativeGridView::findItems(QGraphicsObject *parent, const QString &objectName)
+{
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ items.append(static_cast<T*>(item));
+ //qDebug() << " found:" << item;
+ }
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+}
+
+void tst_QDeclarativeGridView::dumpTree(QDeclarativeItem *parent, int depth)
+{
+ static QString padding(" ");
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
+ qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1);
+ dumpTree(item, depth+1);
+ }
+}
+
+
+QTEST_MAIN(tst_QDeclarativeGridView)
+
+#include "tst_qdeclarativegridview.moc"
diff --git a/tests/auto/declarative/qmlgraphicsimage/data/colors.png b/tests/auto/declarative/qdeclarativeimage/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/declarative/qmlgraphicsimage/data/colors.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/colors.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png b/tests/auto/declarative/qdeclarativeimage/data/colors1.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/colors1.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
new file mode 100644
index 0000000000..7634c12797
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
new file mode 100644
index 0000000000..ed2095bc5d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeimage_p.h>
+#include <private/qdeclarativeimagebase_p.h>
+#include <private/qdeclarativeloader_p.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+
+#include "../shared/testhttpserver.h"
+
+
+#define SERVER_PORT 14445
+#define SERVER_ADDR "http://127.0.0.1:14445"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 60; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeimage : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void smooth();
+ void pixmap();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativeimage::tst_qdeclarativeimage()
+{
+}
+
+void tst_qdeclarativeimage::noSource()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: \"\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QDeclarativeImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("async");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << false << "";
+ QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << false << true << "";
+ QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
+ << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
+ QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << false
+ << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" ";
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << false << "";
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false
+ << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
+}
+
+void tst_qdeclarativeimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(bool, async);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\"; asynchronous: "
+ + (async ? QLatin1String("true") : QLatin1String("false")) + " }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote || async)
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::clearSource()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: srcImage }";
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QDeclarativeImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->progress(), 1.0);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QDeclarativeImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->progress(), 0.0);
+}
+
+void tst_qdeclarativeimage::resized()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::smooth()
+{
+ QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qdeclarativeimage::pixmap()
+{
+ QString componentStr = "import Qt 4.6\nImage { pixmap: testPixmap }";
+
+ QPixmap pixmap;
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("testPixmap", pixmap);
+
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QDeclarativeImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+ QVERIFY(obj->pixmap().isNull());
+
+ pixmap = QPixmap(SRCDIR "/data/colors.png");
+ ctxt->setContextProperty("testPixmap", pixmap);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QVERIFY(obj->status() == QDeclarativeImage::Ready);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativeimage)
+
+#include "tst_qdeclarativeimage.moc"
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/declarative/qmlimageprovider/data/exists.png
+++ b/tests/auto/declarative/qdeclarativeimageprovider/data/exists.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists1.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/declarative/qmlimageprovider/data/exists1.png
+++ b/tests/auto/declarative/qdeclarativeimageprovider/data/exists1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlimageprovider/data/exists2.png b/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/declarative/qmlimageprovider/data/exists2.png
+++ b/tests/auto/declarative/qdeclarativeimageprovider/data/exists2.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
new file mode 100644
index 0000000000..a4d3eb27fa
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeimageprovider.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
new file mode 100644
index 0000000000..c5bdfc898a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** 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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/QtTest>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeimageprovider.h>
+#include <private/qdeclarativeimage_p.h>
+
+// QDeclarativeImageProvider::request() is run in an idle thread where possible
+// Be generous in our timeout.
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 10; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(100); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+class tst_qdeclarativeimageprovider : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeimageprovider()
+ {
+ }
+
+private slots:
+ void imageSource();
+ void imageSource_data();
+ void removeProvider();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+class TestProvider : public QDeclarativeImageProvider
+{
+public:
+ QImage request(const QString &id) {
+ QImage image;
+ image.load(SRCDIR "/data/" + id);
+ return image;
+ }
+};
+
+void tst_qdeclarativeimageprovider::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("exists") << "image://test/exists.png" << "";
+ QTest::newRow("missing") << "image://test/no-such-file.png"
+ << "\"Failed to get image from provider: image://test/no-such-file.png\" ";
+ QTest::newRow("unknown provider") << "image://bogus/exists.png"
+ << "\"Failed to get image from provider: image://bogus/exists.png\" ";
+}
+
+void tst_qdeclarativeimageprovider::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(QString, error);
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.addImageProvider("test", new TestProvider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+
+ QCOMPARE(obj->source(), QUrl(source));
+
+ if (error.isEmpty()) {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 100.);
+ QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qdeclarativeimageprovider::removeProvider()
+{
+ engine.addImageProvider("test2", new TestProvider);
+ QVERIFY(engine.imageProvider("test2") != 0);
+
+ // add provider, confirm it works
+ QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
+
+ QCOMPARE(obj->width(), 100.0);
+
+ // remove the provider and confirm
+ QString error("\"Failed to get image from provider: image://test2/exists2.png\" ");
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.removeImageProvider("test2");
+
+ obj->setSource(QUrl("image://test2/exists2.png"));
+
+ TRY_WAIT(obj->status() == QDeclarativeImage::Loading);
+ TRY_WAIT(obj->status() == QDeclarativeImage::Error);
+
+ delete obj;
+}
+
+
+QTEST_MAIN(tst_qdeclarativeimageprovider)
+
+#include "tst_qdeclarativeimageprovider.moc"
diff --git a/tests/auto/declarative/qmlinfo/data/NestedObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml
index cd5b426d06..cd5b426d06 100644
--- a/tests/auto/declarative/qmlinfo/data/NestedObject.qml
+++ b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml
diff --git a/tests/auto/declarative/qmlinfo/data/nestedQmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml
index a2ce78a6fb..a2ce78a6fb 100644
--- a/tests/auto/declarative/qmlinfo/data/nestedQmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml
diff --git a/tests/auto/declarative/qmlinfo/data/qmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml
index ce05f89e78..ce05f89e78 100644
--- a/tests/auto/declarative/qmlinfo/data/qmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
new file mode 100644
index 0000000000..015c094f88
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeinfo.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
new file mode 100644
index 0000000000..aa3f03b155
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QPushButton>
+#include <QDeclarativeContext>
+#include <qdeclarativeinfo.h>
+
+class tst_qdeclarativeinfo : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeinfo() {}
+
+private slots:
+ void qmlObject();
+ void nestedQmlObject();
+ void nonQmlObject();
+ void nullObject();
+ void nonQmlContextedObject();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_qdeclarativeinfo::qmlObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("qmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QString message = "QML QObject_QML_0 (" + component.url().toString() + ":3:1) Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(object) << "Test Message";
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+
+ message = "QML QtObject (" + component.url().toString() + ":6:13) Second Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Second Test Message";
+}
+
+void tst_qdeclarativeinfo::nestedQmlObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("nestedQmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+ QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
+ QVERIFY(nested2 != 0);
+
+ QString message = "QML NestedObject (" + component.url().toString() + ":5:13) Outer Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Outer Object";
+
+ message = "QML QtObject (" + TEST_FILE("NestedObject.qml").toString() + ":6:14) Inner Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested2) << "Inner Object";
+}
+
+void tst_qdeclarativeinfo::nonQmlObject()
+{
+ QObject object;
+ QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
+ qmlInfo(&object) << "Test Message";
+
+ QPushButton pbObject;
+ QTest::ignoreMessage(QtWarningMsg, "QML QPushButton (unknown location) Test Message");
+ qmlInfo(&pbObject) << "Test Message";
+}
+
+void tst_qdeclarativeinfo::nullObject()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QML (unknown location) Null Object Test Message");
+ qmlInfo(0) << "Null Object Test Message";
+}
+
+void tst_qdeclarativeinfo::nonQmlContextedObject()
+{
+ QObject object;
+ QDeclarativeContext context(&engine);
+ QDeclarativeEngine::setContextForObject(&object, &context);
+ QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
+ qmlInfo(&object) << "Test Message";
+}
+
+QTEST_MAIN(tst_qdeclarativeinfo)
+
+#include "tst_qdeclarativeinfo.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
new file mode 100644
index 0000000000..b8f7d277b9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative script
+SOURCES += tst_qdeclarativeinstruction.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
new file mode 100644
index 0000000000..636c5e3129
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
@@ -0,0 +1,585 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <private/qdeclarativecompiler_p.h>
+
+class tst_qdeclarativeinstruction : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeinstruction() {}
+
+private slots:
+ void dump();
+};
+
+static QStringList messages;
+static void msgHandler(QtMsgType, const char *msg)
+{
+ messages << QLatin1String(msg);
+}
+
+void tst_qdeclarativeinstruction::dump()
+{
+ QDeclarativeCompiledData *data = new QDeclarativeCompiledData(0);
+ {
+ QDeclarativeInstruction i;
+ i.line = 0;
+ i.type = QDeclarativeInstruction::Init;
+ i.init.bindingsSize = 0;
+ i.init.parserStatusSize = 3;
+ i.init.contextCache = -1;
+ i.init.compiledBinding = -1;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeCompiledData::TypeReference ref;
+ ref.className = "Test";
+ data->types << ref;
+
+ QDeclarativeInstruction i;
+ i.line = 1;
+ i.type = QDeclarativeInstruction::CreateObject;
+ i.create.type = 0;
+ i.create.data = -1;
+ i.create.bindingBits = -1;
+ i.create.column = 10;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "testId";
+
+ QDeclarativeInstruction i;
+ i.line = 2;
+ i.type = QDeclarativeInstruction::SetId;
+ i.setId.value = 0;
+ i.setId.index = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 3;
+ i.type = QDeclarativeInstruction::SetDefault;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 4;
+ i.type = QDeclarativeInstruction::CreateComponent;
+ i.createComponent.count = 3;
+ i.createComponent.column = 4;
+ i.createComponent.endLine = 14;
+ i.createComponent.metaObject = 0;
+
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 5;
+ i.type = QDeclarativeInstruction::StoreMetaObject;
+ i.storeMeta.data = 3;
+ i.storeMeta.aliasData = 6;
+ i.storeMeta.propertyCache = 7;
+
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 6;
+ i.type = QDeclarativeInstruction::StoreFloat;
+ i.storeFloat.propertyIndex = 3;
+ i.storeFloat.value = 11.3;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 7;
+ i.type = QDeclarativeInstruction::StoreDouble;
+ i.storeDouble.propertyIndex = 4;
+ i.storeDouble.value = 14.8;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 8;
+ i.type = QDeclarativeInstruction::StoreInteger;
+ i.storeInteger.propertyIndex = 5;
+ i.storeInteger.value = 9;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 9;
+ i.type = QDeclarativeInstruction::StoreBool;
+ i.storeBool.propertyIndex = 6;
+ i.storeBool.value = true;
+
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "Test String";
+ QDeclarativeInstruction i;
+ i.line = 10;
+ i.type = QDeclarativeInstruction::StoreString;
+ i.storeString.propertyIndex = 7;
+ i.storeString.value = 1;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "http://www.nokia.com";
+ QDeclarativeInstruction i;
+ i.line = 11;
+ i.type = QDeclarativeInstruction::StoreUrl;
+ i.storeUrl.propertyIndex = 8;
+ i.storeUrl.value = 2;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 12;
+ i.type = QDeclarativeInstruction::StoreColor;
+ i.storeColor.propertyIndex = 9;
+ i.storeColor.value = 0xFF00FF00;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 13;
+ i.type = QDeclarativeInstruction::StoreDate;
+ i.storeDate.propertyIndex = 10;
+ i.storeDate.value = 9;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 14;
+ i.type = QDeclarativeInstruction::StoreTime;
+ i.storeTime.propertyIndex = 11;
+ i.storeTime.valueIndex = 33;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 15;
+ i.type = QDeclarativeInstruction::StoreDateTime;
+ i.storeDateTime.propertyIndex = 12;
+ i.storeDateTime.valueIndex = 44;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 16;
+ i.type = QDeclarativeInstruction::StorePoint;
+ i.storeRealPair.propertyIndex = 13;
+ i.storeRealPair.valueIndex = 3;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 17;
+ i.type = QDeclarativeInstruction::StorePointF;
+ i.storeRealPair.propertyIndex = 14;
+ i.storeRealPair.valueIndex = 9;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 18;
+ i.type = QDeclarativeInstruction::StoreSize;
+ i.storeRealPair.propertyIndex = 15;
+ i.storeRealPair.valueIndex = 8;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 19;
+ i.type = QDeclarativeInstruction::StoreSizeF;
+ i.storeRealPair.propertyIndex = 16;
+ i.storeRealPair.valueIndex = 99;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 20;
+ i.type = QDeclarativeInstruction::StoreRect;
+ i.storeRect.propertyIndex = 17;
+ i.storeRect.valueIndex = 2;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 21;
+ i.type = QDeclarativeInstruction::StoreRectF;
+ i.storeRect.propertyIndex = 18;
+ i.storeRect.valueIndex = 19;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 22;
+ i.type = QDeclarativeInstruction::StoreVector3D;
+ i.storeVector3D.propertyIndex = 19;
+ i.storeVector3D.valueIndex = 9;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "color(1, 1, 1, 1)";
+ QDeclarativeInstruction i;
+ i.line = 23;
+ i.type = QDeclarativeInstruction::StoreVariant;
+ i.storeString.propertyIndex = 20;
+ i.storeString.value = 3;
+
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 24;
+ i.type = QDeclarativeInstruction::StoreObject;
+ i.storeObject.propertyIndex = 21;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 25;
+ i.type = QDeclarativeInstruction::StoreVariantObject;
+ i.storeObject.propertyIndex = 22;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 26;
+ i.type = QDeclarativeInstruction::StoreInterface;
+ i.storeObject.propertyIndex = 23;
+ data->bytecode << i;
+ }
+
+ {
+ data->primitives << "console.log(1921)";
+
+ QDeclarativeInstruction i;
+ i.line = 27;
+ i.type = QDeclarativeInstruction::StoreSignal;
+ i.storeSignal.signalIndex = 2;
+ i.storeSignal.value = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 28;
+ i.type = QDeclarativeInstruction::StoreScript;
+ i.storeScript.value = 2;
+ //i.storeScript.fileName = 18;
+ //i.storeScript.lineNumber = 28;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 29;
+ i.type = QDeclarativeInstruction::StoreScriptString;
+ i.storeScriptString.propertyIndex = 24;
+ i.storeScriptString.value = 3;
+ i.storeScriptString.scope = 1;
+ data->bytecode << i;
+ }
+
+ {
+ data->datas << "mySignal";
+
+ QDeclarativeInstruction i;
+ i.line = 30;
+ i.type = QDeclarativeInstruction::AssignSignalObject;
+ i.assignSignalObject.signal = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 31;
+ i.type = QDeclarativeInstruction::AssignCustomType;
+ i.assignCustomType.propertyIndex = 25;
+ i.assignCustomType.valueIndex = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 32;
+ i.type = QDeclarativeInstruction::StoreBinding;
+ i.assignBinding.property = 26;
+ i.assignBinding.value = 3;
+ i.assignBinding.context = 2;
+ i.assignBinding.owner = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 33;
+ i.type = QDeclarativeInstruction::StoreCompiledBinding;
+ i.assignBinding.property = 27;
+ i.assignBinding.value = 2;
+ i.assignBinding.context = 4;
+ i.assignBinding.owner = 0;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 34;
+ i.type = QDeclarativeInstruction::StoreValueSource;
+ i.assignValueSource.property = 29;
+ i.assignValueSource.owner = 1;
+ i.assignValueSource.castValue = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 35;
+ i.type = QDeclarativeInstruction::StoreValueInterceptor;
+ i.assignValueInterceptor.property = 30;
+ i.assignValueInterceptor.owner = 2;
+ i.assignValueInterceptor.castValue = -4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 36;
+ i.type = QDeclarativeInstruction::BeginObject;
+ i.begin.castValue = 4;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 38;
+ i.type = QDeclarativeInstruction::StoreObjectQList;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 39;
+ i.type = QDeclarativeInstruction::AssignObjectList;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 40;
+ i.type = QDeclarativeInstruction::FetchAttached;
+ i.fetchAttached.id = 23;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 42;
+ i.type = QDeclarativeInstruction::FetchQList;
+ i.fetch.property = 32;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 43;
+ i.type = QDeclarativeInstruction::FetchObject;
+ i.fetch.property = 33;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 44;
+ i.type = QDeclarativeInstruction::FetchValueType;
+ i.fetchValue.property = 34;
+ i.fetchValue.type = 6;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 45;
+ i.type = QDeclarativeInstruction::PopFetchedObject;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 46;
+ i.type = QDeclarativeInstruction::PopQList;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 47;
+ i.type = QDeclarativeInstruction::PopValueType;
+ i.fetchValue.property = 35;
+ i.fetchValue.type = 8;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 48;
+ i.type = QDeclarativeInstruction::Defer;
+ i.defer.deferCount = 7;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = -1;
+ i.type = QDeclarativeInstruction::Defer;
+ i.defer.deferCount = 7;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 50;
+ i.type = (QDeclarativeInstruction::Type)(QDeclarativeInstruction::Defer + 1); // Non-existant
+ data->bytecode << i;
+ }
+
+ QStringList expect;
+ expect
+ << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
+ << "-------------------------------------------------------------------------------"
+ << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1"
+ << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\""
+ << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\""
+ << "3\t\t3\tSET_DEFAULT"
+ << "4\t\t4\tCREATE_COMPONENT\t3"
+ << "5\t\t5\tSTORE_META\t\t3"
+ << "6\t\t6\tSTORE_FLOAT\t\t3\t11.3"
+ << "7\t\t7\tSTORE_DOUBLE\t\t4\t14.8"
+ << "8\t\t8\tSTORE_INTEGER\t\t5\t9"
+ << "9\t\t9\tSTORE_BOOL\t\t6\ttrue"
+ << "10\t\t10\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
+ << "11\t\t11\tSTORE_URL\t\t8\t2\t\t\"http://www.nokia.com\""
+ << "12\t\t12\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
+ << "13\t\t13\tSTORE_DATE\t\t10\t9"
+ << "14\t\t14\tSTORE_TIME\t\t11\t33"
+ << "15\t\t15\tSTORE_DATETIME\t\t12\t44"
+ << "16\t\t16\tSTORE_POINT\t\t13\t3"
+ << "17\t\t17\tSTORE_POINTF\t\t14\t9"
+ << "18\t\t18\tSTORE_SIZE\t\t15\t8"
+ << "19\t\t19\tSTORE_SIZEF\t\t16\t99"
+ << "20\t\t20\tSTORE_RECT\t\t17\t2"
+ << "21\t\t21\tSTORE_RECTF\t\t18\t19"
+ << "22\t\t22\tSTORE_VECTOR3D\t\t19\t9"
+ << "23\t\t23\tSTORE_VARIANT\t\t20\t3\t\t\"color(1, 1, 1, 1)\""
+ << "24\t\t24\tSTORE_OBJECT\t\t21"
+ << "25\t\t25\tSTORE_VARIANT_OBJECT\t22"
+ << "26\t\t26\tSTORE_INTERFACE\t\t23"
+ << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\""
+ << "28\t\t28\tSTORE_SCRIPT\t\t2"
+ << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1"
+ << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
+ << "31\t\t31\tASSIGN_CUSTOMTYPE\t25\t4"
+ << "32\t\t32\tSTORE_BINDING\t26\t3\t2"
+ << "33\t\t33\tSTORE_COMPILED_BINDING\t27\t2\t4"
+ << "34\t\t34\tSTORE_VALUE_SOURCE\t29\t4"
+ << "35\t\t35\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
+ << "36\t\t36\tBEGIN\t\t\t4"
+ << "37\t\t38\tSTORE_OBJECT_QLIST"
+ << "38\t\t39\tASSIGN_OBJECT_LIST"
+ << "39\t\t40\tFETCH_ATTACHED\t\t23"
+ << "40\t\t42\tFETCH_QLIST\t\t32"
+ << "41\t\t43\tFETCH\t\t\t33"
+ << "42\t\t44\tFETCH_VALUE\t\t34\t6"
+ << "43\t\t45\tPOP"
+ << "44\t\t46\tPOP_QLIST"
+ << "45\t\t47\tPOP_VALUE\t\t35\t8"
+ << "46\t\t48\tDEFER\t\t\t7"
+ << "47\t\tNA\tDEFER\t\t\t7"
+ << "48\t\t50\tXXX UNKOWN INSTRUCTION\t47"
+ << "-------------------------------------------------------------------------------";
+
+ messages = QStringList();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+ data->dumpInstructions();
+ qInstallMsgHandler(old);
+
+ QCOMPARE(messages.count(), expect.count());
+ for (int ii = 0; ii < messages.count(); ++ii) {
+ QCOMPARE(messages.at(ii), expect.at(ii));
+ }
+
+ data->release();
+}
+
+QTEST_MAIN(tst_qdeclarativeinstruction)
+
+#include "tst_qdeclarativeinstruction.moc"
diff --git a/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
index 9281a17cfe..9281a17cfe 100644
--- a/tests/auto/declarative/qmlgraphicsitem/data/keynavigation.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
diff --git a/tests/auto/declarative/qmlgraphicsitem/data/keys.qml b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
index f3c1f7b546..f3c1f7b546 100644
--- a/tests/auto/declarative/qmlgraphicsitem/data/keys.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
new file mode 100644
index 0000000000..0eb2141f9c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeitem.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
new file mode 100644
index 0000000000..36dcf1f6ef
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -0,0 +1,318 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativeitem.h>
+
+class tst_QDeclarativeItem : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeItem();
+
+private slots:
+ void keys();
+ void keyNavigation();
+ void smooth();
+ void clip();
+
+private:
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName);
+ QDeclarativeEngine engine;
+};
+
+class KeysTestObject : public QObject
+{
+ Q_OBJECT
+public:
+ KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {}
+
+ void reset() {
+ mKey = 0;
+ mText = QString();
+ mModifiers = 0;
+ mForwardedKey = 0;
+ }
+
+public slots:
+ void keyPress(int key, QString text, int modifiers) {
+ mKey = key;
+ mText = text;
+ mModifiers = modifiers;
+ }
+ void keyRelease(int key, QString text, int modifiers) {
+ mKey = key;
+ mText = text;
+ mModifiers = modifiers;
+ }
+ void forwardedKey(int key) {
+ mForwardedKey = key;
+ }
+
+public:
+ int mKey;
+ QString mText;
+ int mModifiers;
+ int mForwardedKey;
+
+private:
+};
+
+
+tst_QDeclarativeItem::tst_QDeclarativeItem()
+{
+}
+
+void tst_QDeclarativeItem::keys()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ KeysTestObject *testObject = new KeysTestObject;
+ canvas->rootContext()->setContextProperty("keysTestObject", testObject);
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Return));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
+ QCOMPARE(testObject->mText, QLatin1String("Return"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_0));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
+ QCOMPARE(testObject->mText, QLatin1String("0"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_9));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
+ QCOMPARE(testObject->mText, QLatin1String("9"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(!key.isAccepted());
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QDeclarativeItem::keyNavigation()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // down
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // up
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+}
+
+void tst_QDeclarativeItem::smooth()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(smoothChanged()));
+
+ QVERIFY(item);
+ QVERIFY(!item->smooth());
+
+ item->setSmooth(true);
+ QVERIFY(item->smooth());
+ QCOMPARE(spy.count(),1);
+ item->setSmooth(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setSmooth(false);
+ QVERIFY(!item->smooth());
+ QCOMPARE(spy.count(),2);
+ item->setSmooth(false);
+ QCOMPARE(spy.count(),2);
+}
+
+void tst_QDeclarativeItem::clip()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(clipChanged()));
+
+ QVERIFY(item);
+ QVERIFY(!item->clip());
+
+ item->setClip(true);
+ QVERIFY(item->clip());
+ QCOMPARE(spy.count(),1);
+ item->setClip(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setClip(false);
+ QVERIFY(!item->clip());
+ QCOMPARE(spy.count(),2);
+ item->setClip(false);
+ QCOMPARE(spy.count(),2);
+}
+
+template<typename T>
+T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ if (!parent)
+ return 0;
+
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ return static_cast<T*>(item);
+ item = findItem<T>(item, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+
+
+QTEST_MAIN(tst_QDeclarativeItem)
+
+#include "tst_qdeclarativeitem.moc"
diff --git a/tests/auto/declarative/qmllanguage/data/Alias.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml
index 55aa2312b1..55aa2312b1 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml
diff --git a/tests/auto/declarative/qmllanguage/data/Alias2.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml
index 6362b2dd21..6362b2dd21 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/Alias3.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml
index d1e78f82b9..d1e78f82b9 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/Alias4.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml
index 573674c021..573674c021 100644
--- a/tests/auto/declarative/qmllanguage/data/Alias4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml b/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml
index 05fbc3fdbd..05fbc3fdbd 100644
--- a/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml
index 99d010f02f..99d010f02f 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType2.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml
index 86210e9072..86210e9072 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType3.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml
index d08f35bb54..d08f35bb54 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/CompositeType4.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml
index a6a8168d8f..a6a8168d8f 100644
--- a/tests/auto/declarative/qmllanguage/data/CompositeType4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml
index aefbf9a2a1..aefbf9a2a1 100644
--- a/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/HelperAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml
index dc3b382b23..dc3b382b23 100644
--- a/tests/auto/declarative/qmllanguage/data/HelperAlias.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml
diff --git a/tests/auto/declarative/qmllanguage/data/I18n.qml b/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml
index 558c836e52..558c836e52 100644
--- a/tests/auto/declarative/qmllanguage/data/I18n.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml
diff --git a/tests/auto/declarative/qmllanguage/data/I18nType30.qml b/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml
index 42dbc69044..42dbc69044 100644
--- a/tests/auto/declarative/qmllanguage/data/I18nType30.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml
diff --git a/tests/auto/declarative/qmllanguage/data/MyComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml
index 1a23277ff8..1a23277ff8 100644
--- a/tests/auto/declarative/qmllanguage/data/MyComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml
index e620e26490..e620e26490 100644
--- a/tests/auto/declarative/qmllanguage/data/MyCompositeValueSource.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml
diff --git a/tests/auto/declarative/qmllanguage/data/MyContainerComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml
index 61f54c5eb8..61f54c5eb8 100644
--- a/tests/auto/declarative/qmllanguage/data/MyContainerComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/NestedAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml
index 5155612264..5155612264 100644
--- a/tests/auto/declarative/qmllanguage/data/NestedAlias.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml
diff --git a/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml
index 5cc8d20ff2..5cc8d20ff2 100644
--- a/tests/auto/declarative/qmllanguage/data/NestedErrorsType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml
index 2889caf031..2889caf031 100644
--- a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml
index 500b0f66d6..500b0f66d6 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml
index 5c922709fe..5c922709fe 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml
index e059937b2d..e059937b2d 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml
index bd6a769367..bd6a769367 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml
index 4316d0d7d7..4316d0d7d7 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml
index e3af23090d..e3af23090d 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml
index a9a57eb2e9..a9a57eb2e9 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml
index 2b9ad85e0f..2b9ad85e0f 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml
diff --git a/tests/auto/declarative/qmllanguage/data/alias.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml
index a2a41a1729..a2a41a1729 100644
--- a/tests/auto/declarative/qmllanguage/data/alias.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml
index c86c96b7dc..c86c96b7dc 100644
--- a/tests/auto/declarative/qmllanguage/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml
index f6422bdcb1..f6422bdcb1 100644
--- a/tests/auto/declarative/qmllanguage/data/assignCompositeToType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignLiteralSignalProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml
index 399fcea04d..399fcea04d 100644
--- a/tests/auto/declarative/qmllanguage/data/assignLiteralSignalProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignObjectToSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml
index 789cc66215..789cc66215 100644
--- a/tests/auto/declarative/qmllanguage/data/assignObjectToSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignObjectToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml
index 0ff9370a0e..0ff9370a0e 100644
--- a/tests/auto/declarative/qmllanguage/data/assignObjectToVariant.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignQmlComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml
index 20bdc559c1..20bdc559c1 100644
--- a/tests/auto/declarative/qmllanguage/data/assignQmlComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml
index 2a48df8fcf..2a48df8fcf 100644
--- a/tests/auto/declarative/qmllanguage/data/assignSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/assignTypeExtremes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml
index 60ede525e4..60ede525e4 100644
--- a/tests/auto/declarative/qmllanguage/data/assignTypeExtremes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/attachedProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
index b46ec34c4f..b46ec34c4f 100644
--- a/tests/auto/declarative/qmllanguage/data/attachedProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/autoComponentCreation.qml b/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml
index 5d00144eaf..5d00144eaf 100644
--- a/tests/auto/declarative/qmllanguage/data/autoComponentCreation.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
new file mode 100644
index 0000000000..640fb54f99
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+MyQmlObject {
+ property bool receivedNotify : false
+ onPropertyWithNotifyChanged: { receivedNotify = true; }
+}
+
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt
index 091aad61fa..091aad61fa 100644
--- a/tests/auto/declarative/qmllanguage/data/component.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml
index 07e463ab76..07e463ab76 100644
--- a/tests/auto/declarative/qmllanguage/data/component.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt
index 76e7656a62..76e7656a62 100644
--- a/tests/auto/declarative/qmllanguage/data/component.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml
index 88e0f7378c..88e0f7378c 100644
--- a/tests/auto/declarative/qmllanguage/data/component.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt
index 9a1314296f..9a1314296f 100644
--- a/tests/auto/declarative/qmllanguage/data/component.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml
index 287a959173..287a959173 100644
--- a/tests/auto/declarative/qmllanguage/data/component.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt
index 2ab18685c8..2ab18685c8 100644
--- a/tests/auto/declarative/qmllanguage/data/component.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml
index ab1e29be78..ab1e29be78 100644
--- a/tests/auto/declarative/qmllanguage/data/component.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt
new file mode 100644
index 0000000000..e3c2df755f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt
@@ -0,0 +1 @@
+4:5:Component elements may not contain properties other than id
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml
index 629e9988db..629e9988db 100644
--- a/tests/auto/declarative/qmllanguage/data/component.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt
index 2b1c6ca606..2b1c6ca606 100644
--- a/tests/auto/declarative/qmllanguage/data/component.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/component.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml
index 2303ebf001..2303ebf001 100644
--- a/tests/auto/declarative/qmllanguage/data/component.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml
index 0a7249ad31..0a7249ad31 100644
--- a/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml
index e3b32ca5d8..e3b32ca5d8 100644
--- a/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/cppnamespace.qml b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml
index e1daf3b78f..e1daf3b78f 100644
--- a/tests/auto/declarative/qmllanguage/data/cppnamespace.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml
diff --git a/tests/auto/declarative/qmllanguage/data/crash2.qml b/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml
index a22c776678..a22c776678 100644
--- a/tests/auto/declarative/qmllanguage/data/crash2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt
index 43a8bb28b3..43a8bb28b3 100644
--- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml
index 00cc0c46eb..00cc0c46eb 100644
--- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml
diff --git a/tests/auto/declarative/qmllanguage/data/customParserTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml
index cf2f272a62..cf2f272a62 100644
--- a/tests/auto/declarative/qmllanguage/data/customParserTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/customVariantTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml
index 0263ed20f2..0263ed20f2 100644
--- a/tests/auto/declarative/qmllanguage/data/customVariantTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml b/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml
index 3987a3cacd..3987a3cacd 100644
--- a/tests/auto/declarative/qmllanguage/data/declaredPropertyValues.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
index 945d51b963..945d51b963 100644
--- a/tests/auto/declarative/qmllanguage/data/defaultGrouped.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml
index 0fd14047c6..0fd14047c6 100644
--- a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml
diff --git a/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml b/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml
index 3651511376..3651511376 100644
--- a/tests/auto/declarative/qmllanguage/data/defaultPropertyListOrder.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt
index 2aea251d1c..2aea251d1c 100644
--- a/tests/auto/declarative/qmllanguage/data/doubleSignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml
index fb07b9f659..fb07b9f659 100644
--- a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/duplicateIDs.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt
index 66241cf1f2..66241cf1f2 100644
--- a/tests/auto/declarative/qmllanguage/data/duplicateIDs.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml
index a993abdd37..a993abdd37 100644
--- a/tests/auto/declarative/qmllanguage/data/duplicateIDs.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicObject.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml
index 85d1052847..85d1052847 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicObject.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicObjectProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
index c80a7c04d9..c80a7c04d9 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicObjectProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml
index aef3269dc8..aef3269dc8 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml
index 7bfab672c9..7bfab672c9 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml
diff --git a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml
index 2a834e8f39..2a834e8f39 100644
--- a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml
diff --git a/tests/auto/declarative/qmllanguage/data/empty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt
index d416e76ae2..d416e76ae2 100644
--- a/tests/auto/declarative/qmllanguage/data/empty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/empty.qml b/tests/auto/declarative/qdeclarativelanguage/data/empty.qml
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qmllanguage/data/empty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/empty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
index 353bbf5d8c..353bbf5d8c 100644
--- a/tests/auto/declarative/qmllanguage/data/emptySignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/emptySignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
index 4c5a122782..4c5a122782 100644
--- a/tests/auto/declarative/qmllanguage/data/emptySignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/failingComponent.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt
index 0cf0ef3208..0cf0ef3208 100644
--- a/tests/auto/declarative/qmllanguage/data/failingComponent.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/failingComponentTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml
index 74a6acfc49..74a6acfc49 100644
--- a/tests/auto/declarative/qmllanguage/data/failingComponentTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml
diff --git a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt
index 30748234bc..30748234bc 100644
--- a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml
index d971eee4d0..d971eee4d0 100644
--- a/tests/auto/declarative/qmllanguage/data/fakeDotProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/finalOverride.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt
index 49e06cbdf5..49e06cbdf5 100644
--- a/tests/auto/declarative/qmllanguage/data/finalOverride.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/finalOverride.qml b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml
index a84393af94..a84393af94 100644
--- a/tests/auto/declarative/qmllanguage/data/finalOverride.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml
index 558c836e52..558c836e52 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml
index 74918e2764..74918e2764 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml
index c0b2f94857..c0b2f94857 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nNameSpace.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nScript.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml
index 942ed9009c..942ed9009c 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nScript.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml
index 764c92639a..764c92639a 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml
diff --git a/tests/auto/declarative/qmllanguage/data/i18nType.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml
index d7954ef718..d7954ef718 100644
--- a/tests/auto/declarative/qmllanguage/data/i18nType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/idProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml
index 90c1483a07..90c1483a07 100644
--- a/tests/auto/declarative/qmllanguage/data/idProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt
index 231998daf7..231998daf7 100644
--- a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.qml b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml
index cd112af04a..cd112af04a 100644
--- a/tests/auto/declarative/qmllanguage/data/importNamespaceConflict.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt
index c7d880e79e..c7d880e79e 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.qml b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml
index 23ed566e15..23ed566e15 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt
index 89e58ee764..89e58ee764 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.qml b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml
index 97ec22280f..97ec22280f 100644
--- a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml
diff --git a/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml b/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml
index 478f06a8df..478f06a8df 100644
--- a/tests/auto/declarative/qmllanguage/data/inlineQmlComponents.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml
diff --git a/tests/auto/declarative/qmllanguage/data/interfaceProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml
index 70879ffd21..70879ffd21 100644
--- a/tests/auto/declarative/qmllanguage/data/interfaceProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/interfaceQList.qml b/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml
index c87dfae785..c87dfae785 100644
--- a/tests/auto/declarative/qmllanguage/data/interfaceQList.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt
index 492bbb48fa..492bbb48fa 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml
index 324f79c2f4..324f79c2f4 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt
index ff2409bd2d..ff2409bd2d 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml
index b768e9f86b..b768e9f86b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.10.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt
index fee5050743..fee5050743 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml
index 7b782beb68..7b782beb68 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.11.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt
index 34de769e13..34de769e13 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml
index 1f47c61622..1f47c61622 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt
index 05161c4d10..05161c4d10 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml
index 79c2981505..79c2981505 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt
index a208bcfaa7..a208bcfaa7 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml
index af0be80e56..af0be80e56 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt
index 05161c4d10..05161c4d10 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml
index 0546322143..0546322143 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml
index 108109a317..108109a317 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml
index ccf03536f3..ccf03536f3 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt
index ff2409bd2d..ff2409bd2d 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml
index e736379112..e736379112 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml
index a0952295a6..a0952295a6 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidAttachedProperty.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt
index 810fd31b41..810fd31b41 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml
index 1167e391c4..1167e391c4 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt
index 810fd31b41..810fd31b41 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml
index a0c83062b9..a0c83062b9 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt
index f6d6f29fbf..f6d6f29fbf 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml
index 0bbfc4f529..0bbfc4f529 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt
index 69c68716d9..69c68716d9 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml
index 134fef9b0a..134fef9b0a 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt
index 2c8a970da7..2c8a970da7 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml
index 55cefe66b9..55cefe66b9 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt
index 83317256e2..83317256e2 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml
index 9ec33abe7b..9ec33abe7b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt
index 4a7e3830a8..4a7e3830a8 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml
index 977539a357..977539a357 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
index 56e3eeb6a1..56e3eeb6a1 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml
index 4fb3b298dd..4fb3b298dd 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt
index bb811cfe9d..bb811cfe9d 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml
index 668417286b..668417286b 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt
index cfe87569fa..cfe87569fa 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml
index 86010bf792..86010bf792 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt
index c167de382e..c167de382e 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml
index 5b92a1a0eb..5b92a1a0eb 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
index 160e8b5a47..160e8b5a47 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml
index 62187d9473..62187d9473 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
index 1ca678c695..1ca678c695 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidID.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml
index 04db3eb67c..04db3eb67c 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidID.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidImportID.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt
index a65f5fddd6..a65f5fddd6 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidImportID.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidImportID.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml
index 30d88d504d..30d88d504d 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidImportID.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml
diff --git a/tests/auto/declarative/qmllanguage/data/invalidRoot.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.errors.txt
index 4bcc948e92..4bcc948e92 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidRoot.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/invalidRoot.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.qml
index 427827ca89..427827ca89 100644
--- a/tests/auto/declarative/qmllanguage/data/invalidRoot.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
index d8a22a82d2..d8a22a82d2 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
index a0706addf8..a0706addf8 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml
index 93c7630128..93c7630128 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml
diff --git a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
index eeb9a05a95..eeb9a05a95 100644
--- a/tests/auto/declarative/qmllanguage/data/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt
index 8b40aa3ebb..8b40aa3ebb 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml
index e3baadb46c..e3baadb46c 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt
index 8c7b7e9c99..8c7b7e9c99 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/listAssignment.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml
index 00c4c6b543..00c4c6b543 100644
--- a/tests/auto/declarative/qmllanguage/data/listAssignment.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml b/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml
index 32b5b6c7f2..32b5b6c7f2 100644
--- a/tests/auto/declarative/qmllanguage/data/listItemDeleteSelf.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml
diff --git a/tests/auto/declarative/qmllanguage/data/listProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml
index ba9e37ce39..ba9e37ce39 100644
--- a/tests/auto/declarative/qmllanguage/data/listProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml
diff --git a/tests/auto/declarative/qmllanguage/data/missingObject.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt
index b31b562de1..b31b562de1 100644
--- a/tests/auto/declarative/qmllanguage/data/missingObject.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/missingObject.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml
index 2f17045869..2f17045869 100644
--- a/tests/auto/declarative/qmllanguage/data/missingObject.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml
diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt
index f562246288..f562246288 100644
--- a/tests/auto/declarative/qmllanguage/data/missingSignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml
index 3bf75f688d..3bf75f688d 100644
--- a/tests/auto/declarative/qmllanguage/data/missingSignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml
diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt
index caf7e55ba2..caf7e55ba2 100644
--- a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml
index 9a0fa6a26b..9a0fa6a26b 100644
--- a/tests/auto/declarative/qmllanguage/data/missingValueTypeProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
index 886da55cba..886da55cba 100644
--- a/tests/auto/declarative/qmllanguage/data/nestedErrors.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nestedErrors.qml b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml
index c0d755ae98..c0d755ae98 100644
--- a/tests/auto/declarative/qmllanguage/data/nestedErrors.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt
index 6bfce9a2c9..6bfce9a2c9 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml
index df7406ce98..df7406ce98 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml
index 06ccd37905..06ccd37905 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml
index 5b08608862..5b08608862 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml
index 65791919ba..65791919ba 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt
index c07f2b99a2..c07f2b99a2 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml
index 37af05731e..37af05731e 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt
index 89925b74c2..89925b74c2 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml
index 5cd55d0856..5cd55d0856 100644
--- a/tests/auto/declarative/qmllanguage/data/nonexistantProperty.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/nullDotProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt
index 07a40949cd..07a40949cd 100644
--- a/tests/auto/declarative/qmllanguage/data/nullDotProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/nullDotProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml
index 4e36779b5c..4e36779b5c 100644
--- a/tests/auto/declarative/qmllanguage/data/nullDotProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt
index db7d9c0f60..db7d9c0f60 100644
--- a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml
index 99247735dd..99247735dd 100644
--- a/tests/auto/declarative/qmllanguage/data/objectValueTypeProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/onCompleted.qml b/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml
index 5725f858e9..5725f858e9 100644
--- a/tests/auto/declarative/qmllanguage/data/onCompleted.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt
index 3ae6c4601b..3ae6c4601b 100644
--- a/tests/auto/declarative/qmllanguage/data/property.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml
index cadc39a745..cadc39a745 100644
--- a/tests/auto/declarative/qmllanguage/data/property.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt
index a18e21a01c..a18e21a01c 100644
--- a/tests/auto/declarative/qmllanguage/data/property.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml
index e810c6cfd2..e810c6cfd2 100644
--- a/tests/auto/declarative/qmllanguage/data/property.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt
index 5e09a25b57..5e09a25b57 100644
--- a/tests/auto/declarative/qmllanguage/data/property.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml
index 04147c2701..04147c2701 100644
--- a/tests/auto/declarative/qmllanguage/data/property.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt
index b447186849..b447186849 100644
--- a/tests/auto/declarative/qmllanguage/data/property.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml
index b2ec4826a7..b2ec4826a7 100644
--- a/tests/auto/declarative/qmllanguage/data/property.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/property.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt
index 32a8dc11e1..32a8dc11e1 100644
--- a/tests/auto/declarative/qmllanguage/data/property.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/property.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml
index 65fafbbc14..65fafbbc14 100644
--- a/tests/auto/declarative/qmllanguage/data/property.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml
index 57a6070d06..57a6070d06 100644
--- a/tests/auto/declarative/qmllanguage/data/propertyValueSource.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/propertyValueSource.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml
index ad71fcf342..ad71fcf342 100644
--- a/tests/auto/declarative/qmllanguage/data/propertyValueSource.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml
diff --git a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
index 429c327a3d..429c327a3d 100644
--- a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
index 0f57b61f20..0f57b61f20 100644
--- a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt
index b8c34042be..b8c34042be 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml
index 60757bd005..60757bd005 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt
index d857a0440e..d857a0440e 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml
index 8f1633cc11..8f1633cc11 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt
index c7e9e1bb2f..c7e9e1bb2f 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/readOnly.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml
index cd86a4828d..cd86a4828d 100644
--- a/tests/auto/declarative/qmllanguage/data/readOnly.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/rootAsQmlComponent.qml b/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml
index 8d72cd3844..8d72cd3844 100644
--- a/tests/auto/declarative/qmllanguage/data/rootAsQmlComponent.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt
index 50518ccff6..50518ccff6 100644
--- a/tests/auto/declarative/qmllanguage/data/script.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml
index 8dac8b7312..8dac8b7312 100644
--- a/tests/auto/declarative/qmllanguage/data/script.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt
new file mode 100644
index 0000000000..13f47d18ba
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt
@@ -0,0 +1 @@
+6:9:Component elements may not contain script blocks
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml
index 516e878c46..516e878c46 100644
--- a/tests/auto/declarative/qmllanguage/data/script.10.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt
index a664203880..a664203880 100644
--- a/tests/auto/declarative/qmllanguage/data/script.11.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml
index 6d2d598106..6d2d598106 100644
--- a/tests/auto/declarative/qmllanguage/data/script.11.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt
new file mode 100644
index 0000000000..f8297f5061
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt
@@ -0,0 +1 @@
+4:5:JavaScript declaration outside Script element
diff --git a/tests/auto/declarative/qmllanguage/data/script.12.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml
index 9ecb5d903c..9ecb5d903c 100644
--- a/tests/auto/declarative/qmllanguage/data/script.12.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt
index 8fb3bbd124..8fb3bbd124 100644
--- a/tests/auto/declarative/qmllanguage/data/script.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml
index dce1a41594..dce1a41594 100644
--- a/tests/auto/declarative/qmllanguage/data/script.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt
index 8fb3bbd124..8fb3bbd124 100644
--- a/tests/auto/declarative/qmllanguage/data/script.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml
index 8621a9a7a2..8621a9a7a2 100644
--- a/tests/auto/declarative/qmllanguage/data/script.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt
index 49a507feff..49a507feff 100644
--- a/tests/auto/declarative/qmllanguage/data/script.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml
index d89817c257..d89817c257 100644
--- a/tests/auto/declarative/qmllanguage/data/script.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt
index 49a507feff..49a507feff 100644
--- a/tests/auto/declarative/qmllanguage/data/script.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml
index 8986b3b632..8986b3b632 100644
--- a/tests/auto/declarative/qmllanguage/data/script.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt
index 4e53b6b172..4e53b6b172 100644
--- a/tests/auto/declarative/qmllanguage/data/script.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml
index 07e9d78d6f..07e9d78d6f 100644
--- a/tests/auto/declarative/qmllanguage/data/script.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt
index dc15ddff71..dc15ddff71 100644
--- a/tests/auto/declarative/qmllanguage/data/script.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml
index fa905e628e..fa905e628e 100644
--- a/tests/auto/declarative/qmllanguage/data/script.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt
index b5bf1a8f36..b5bf1a8f36 100644
--- a/tests/auto/declarative/qmllanguage/data/script.8.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/script.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml
index f600c886df..f600c886df 100644
--- a/tests/auto/declarative/qmllanguage/data/script.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt
new file mode 100644
index 0000000000..41e8d46786
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt
@@ -0,0 +1 @@
+5:9:Component elements may not contain script blocks
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml
index 79aa504ec0..79aa504ec0 100644
--- a/tests/auto/declarative/qmllanguage/data/script.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml
diff --git a/tests/auto/declarative/qmllanguage/data/scriptString.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml
index 40a3bbeede..40a3bbeede 100644
--- a/tests/auto/declarative/qmllanguage/data/scriptString.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml
diff --git a/tests/auto/declarative/qmllanguage/data/signal.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt
index 78d996016a..78d996016a 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/signal.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml
index fbaf017a91..fbaf017a91 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/signal.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt
index fce89285ec..fce89285ec 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/signal.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml
index 504919242c..504919242c 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/signal.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt
index bf043ac85a..bf043ac85a 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/signal.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml
index 9dd4cc7cb1..9dd4cc7cb1 100644
--- a/tests/auto/declarative/qmllanguage/data/signal.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/simpleBindings.qml b/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml
index 2fcd1a5a4f..2fcd1a5a4f 100644
--- a/tests/auto/declarative/qmllanguage/data/simpleBindings.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml
diff --git a/tests/auto/declarative/qmllanguage/data/simpleContainer.qml b/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml
index c3a795f536..c3a795f536 100644
--- a/tests/auto/declarative/qmllanguage/data/simpleContainer.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml
diff --git a/tests/auto/declarative/qmllanguage/data/simpleObject.qml b/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml
index 30c78237de..30c78237de 100644
--- a/tests/auto/declarative/qmllanguage/data/simpleObject.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml
diff --git a/tests/auto/declarative/qmllanguage/data/subdir/Test.qml b/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml
index c4d5905e4d..c4d5905e4d 100644
--- a/tests/auto/declarative/qmllanguage/data/subdir/Test.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml
diff --git a/tests/auto/declarative/qmllanguage/data/subdir/subsubdir/SubTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml
index c4d5905e4d..c4d5905e4d 100644
--- a/tests/auto/declarative/qmllanguage/data/subdir/subsubdir/SubTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml
diff --git a/tests/auto/declarative/qmllanguage/data/test.js b/tests/auto/declarative/qdeclarativelanguage/data/test.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qmllanguage/data/test.js
+++ b/tests/auto/declarative/qdeclarativelanguage/data/test.js
diff --git a/tests/auto/declarative/qmllanguage/data/test2.js b/tests/auto/declarative/qdeclarativelanguage/data/test2.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qmllanguage/data/test2.js
+++ b/tests/auto/declarative/qdeclarativelanguage/data/test2.js
diff --git a/tests/auto/declarative/qmllanguage/data/unregisteredObject.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt
index 347db05a81..347db05a81 100644
--- a/tests/auto/declarative/qmllanguage/data/unregisteredObject.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/unregisteredObject.qml b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml
index 4969f62ad5..4969f62ad5 100644
--- a/tests/auto/declarative/qmllanguage/data/unregisteredObject.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml
diff --git a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt
index 3cd626de86..3cd626de86 100644
--- a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml
index 9f19680368..9f19680368 100644
--- a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml
diff --git a/tests/auto/declarative/qmllanguage/data/valueTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml
index bf325a74ee..bf325a74ee 100644
--- a/tests/auto/declarative/qmllanguage/data/valueTypes.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt
index ba7a0766b2..ba7a0766b2 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.1.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml
index 289d37f050..289d37f050 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.1.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt
index ae75b5289d..ae75b5289d 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.10.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml
index 2cf0e50277..2cf0e50277 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.10.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt
index 23a4cda4c2..23a4cda4c2 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.11.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml
index ae77ba1fe8..ae77ba1fe8 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.11.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.12.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt
index 3092100280..3092100280 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.12.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.12.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml
index b7a366f567..b7a366f567 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.12.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.13.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt
index ba7a0766b2..ba7a0766b2 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.13.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.13.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml
index 477aff1dbe..477aff1dbe 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.13.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.14.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt
index d621fdd6cd..d621fdd6cd 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.14.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.14.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml
index 672d693c72..672d693c72 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.14.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt
index 44768e30cb..44768e30cb 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.15.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.15.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml
index 633a5ba2ba..633a5ba2ba 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.15.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt
index 9ff9f250c0..9ff9f250c0 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.2.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml
index 34b74f7e01..34b74f7e01 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt
index 6d971c6499..6d971c6499 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.3.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml
index 384181a17f..384181a17f 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.3.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt
index ef34d0ea95..ef34d0ea95 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.4.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml
index 0787bf5fda..0787bf5fda 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.4.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt
index cab10bddb8..cab10bddb8 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.5.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml
index c50ae9a26d..c50ae9a26d 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.5.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
index d0a0b001b6..d0a0b001b6 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml
index da10b7895f..da10b7895f 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.6.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt
index 614346bd2b..614346bd2b 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.7.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml
index ddc3835199..ddc3835199 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.7.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt
index 1773c00825..1773c00825 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.8.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml
index a5f6756399..a5f6756399 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.8.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt
index 8630975c57..8630975c57 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.9.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt
diff --git a/tests/auto/declarative/qmllanguage/data/wrongType.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml
index a3db732692..a3db732692 100644
--- a/tests/auto/declarative/qmllanguage/data/wrongType.9.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
new file mode 100644
index 0000000000..d7c1defb9f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
@@ -0,0 +1,14 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += script network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelanguage.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+INCLUDEPATH += ../shared/
+HEADERS += ../shared/testhttpserver.h
+SOURCES += ../shared/testhttpserver.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/LocalInternal.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml
index 836c20a1f4..836c20a1f4 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/LocalInternal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/Test.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml
index c4d5905e4d..c4d5905e4d 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/Test.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestLocal.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestLocal.qml
index 11443ca6d5..11443ca6d5 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestLocal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestLocal.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestSubDir.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestSubDir.qml
index 0dfede4093..0dfede4093 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/TestSubDir.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/TestSubDir.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/pics/blue.png b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/pics/blue.png
index 46f815f1ed..46f815f1ed 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/pics/blue.png
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/pics/blue.png
Binary files differ
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
index b32f82b251..b32f82b251 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml
index 0ea9ec6a61..0ea9ec6a61 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml
diff --git a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir
index f7016c7c0f..f7016c7c0f 100644
--- a/tests/auto/declarative/qmllanguage/qtest/declarative/qmllanguage/subdir/qmldir
+++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
new file mode 100644
index 0000000000..9ffe28a569
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
+
+void registerTypes()
+{
+ QML_REGISTER_INTERFACE(MyInterface);
+ QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
+ QML_REGISTER_TYPE(Test,1,0,MyTypeObject,MyTypeObject);
+ QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer);
+ QML_REGISTER_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource);
+ QML_REGISTER_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject);
+ QML_REGISTER_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType);
+ QML_REGISTER_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType);
+ QML_REGISTER_NOCREATE_TYPE(MyGroupedObject);
+}
+
+QVariant myCustomVariantTypeConverter(const QString &data)
+{
+ MyCustomVariantType rv;
+ rv.a = data.toInt();
+ return QVariant::fromValue(rv);
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
new file mode 100644
index 0000000000..8ac7aa6e60
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -0,0 +1,554 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qdatetime.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeparserstatus.h>
+#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
+#include <QtDeclarative/qdeclarativescriptstring.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
+
+QVariant myCustomVariantTypeConverter(const QString &data);
+
+class MyInterface
+{
+public:
+ MyInterface() : id(913) {}
+ int id;
+};
+Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
+QML_DECLARE_INTERFACE(MyInterface);
+
+struct MyCustomVariantType
+{
+ MyCustomVariantType() : a(0) {}
+ int a;
+};
+Q_DECLARE_METATYPE(MyCustomVariantType);
+
+class MyAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2)
+public:
+ MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ int value2() const { return m_value2; }
+ void setValue2(int v) { m_value2 = v; }
+
+private:
+ int m_value;
+ int m_value2;
+};
+
+class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue FINAL)
+ Q_PROPERTY(QString readOnlyString READ readOnlyString)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect)
+ Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
+ Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
+ Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal);
+ Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType);
+ Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+
+ Q_INTERFACES(MyInterface QDeclarativeParserStatus)
+public:
+ MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ QString readOnlyString() const { return QLatin1String(""); }
+
+ bool enabled() const { return false; }
+ void setEnabled(bool) {}
+
+ QRect rect() const { return QRect(); }
+ void setRect(const QRect&) {}
+
+ QMatrix matrix() const { return QMatrix(); }
+ void setMatrix(const QMatrix&) {}
+
+ MyInterface *interface() const { return m_interface; }
+ void setInterface(MyInterface *iface) { m_interface = iface; }
+
+ static MyAttachedObject *qmlAttachedProperties(QObject *other) {
+ return new MyAttachedObject(other);
+ }
+ Q_CLASSINFO("DefaultMethod", "basicSlot()");
+
+ int onLiteralSignal() const { return m_value; }
+ void setOnLiteralSignal(int v) { m_value = v; }
+
+ MyQmlObject *qmlobject() const { return m_qmlobject; }
+ void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
+
+ MyCustomVariantType customType() const { return m_custom; }
+ void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+public slots:
+ void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
+ void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
+
+signals:
+ void basicSignal();
+ void basicParameterizedSignal(int parameter);
+ void oddlyNamedNotifySignal();
+
+private:
+ friend class tst_qdeclarativelanguage;
+ int m_value;
+ MyInterface *m_interface;
+ MyQmlObject *m_qmlobject;
+ MyCustomVariantType m_custom;
+ int m_propertyWithNotify;
+};
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(MyQmlObject);
+
+class MyGroupedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript);
+public:
+ QDeclarativeScriptString script() const { return m_script; }
+ void setScript(const QDeclarativeScriptString &s) { m_script = s; }
+
+private:
+ QDeclarativeScriptString m_script;
+};
+
+QML_DECLARE_TYPE(MyGroupedObject);
+
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId);
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
+ Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty);
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty);
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty);
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty);
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty);
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty);
+ Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty);
+ Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty);
+ Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty);
+ Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty);
+ Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged);
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2);
+ Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty);
+
+ Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
+ Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT);
+ Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT);
+
+public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QDeclarativeComponent *componentPropertyValue;
+ QDeclarativeComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QDeclarativeComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
+
+ QPoint pointPropertyValue;
+ QPoint pointProperty() const {
+ return pointPropertyValue;
+ }
+ void setPointProperty(const QPoint &v) {
+ pointPropertyValue = v;
+ }
+
+ QPointF pointFPropertyValue;
+ QPointF pointFProperty() const {
+ return pointFPropertyValue;
+ }
+ void setPointFProperty(const QPointF &v) {
+ pointFPropertyValue = v;
+ }
+
+ QSize sizePropertyValue;
+ QSize sizeProperty() const {
+ return sizePropertyValue;
+ }
+ void setSizeProperty(const QSize &v) {
+ sizePropertyValue = v;
+ }
+
+ QSizeF sizeFPropertyValue;
+ QSizeF sizeFProperty() const {
+ return sizeFPropertyValue;
+ }
+ void setSizeFProperty(const QSizeF &v) {
+ sizeFPropertyValue = v;
+ }
+
+ QRect rectPropertyValue;
+ QRect rectProperty() const {
+ return rectPropertyValue;
+ }
+ void setRectProperty(const QRect &v) {
+ rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
+ }
+
+ QRectF rectFPropertyValue;
+ QRectF rectFProperty() const {
+ return rectFPropertyValue;
+ }
+ void setRectFProperty(const QRectF &v) {
+ rectFPropertyValue = v;
+ }
+
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QDeclarativeScriptString scriptPropertyValue;
+ QDeclarativeScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QDeclarativeScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ MyGroupedObject groupedValue;
+ MyGroupedObject *grouped() { return &groupedValue; }
+
+ MyGroupedObject *nullGrouped() { return 0; }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
+QML_DECLARE_TYPE(MyTypeObject);
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children)
+ Q_PROPERTY(QDeclarativeListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
+ Q_CLASSINFO("DefaultProperty", "children");
+public:
+ MyContainer() {}
+
+ QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this, m_children); }
+ QList<QObject *> *getChildren() { return &m_children; }
+ QDeclarativeListProperty<MyInterface> qlistInterfaces() { return QDeclarativeListProperty<MyInterface>(this, m_interfaces); }
+ QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
+
+ QList<QObject*> m_children;
+ QList<MyInterface *> m_interfaces;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+
+
+class MyPropertyValueSource : public QObject, public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativePropertyValueSource)
+public:
+ MyPropertyValueSource()
+ : QDeclarativePropertyValueSource() {}
+
+ QDeclarativeProperty prop;
+ virtual void setTarget(const QDeclarativeProperty &p)
+ {
+ prop = p;
+ }
+};
+QML_DECLARE_TYPE(MyPropertyValueSource);
+
+class MyDotPropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(MyQmlObject *obj READ obj)
+ Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
+public:
+ MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
+ ~MyDotPropertyObject()
+ {
+ if (m_ownRWObj)
+ delete m_rwobj;
+ }
+
+ MyQmlObject *obj() { return 0; }
+
+ MyQmlObject *readWriteObj()
+ {
+ if (!m_rwobj) {
+ m_rwobj = new MyQmlObject;
+ m_ownRWObj = true;
+ }
+ return m_rwobj;
+ }
+
+ void setReadWriteObj(MyQmlObject *obj)
+ {
+ if (m_ownRWObj) {
+ delete m_rwobj;
+ m_ownRWObj = false;
+ }
+
+ m_rwobj = obj;
+ }
+
+private:
+ MyQmlObject *m_rwobj;
+ bool m_ownRWObj;
+};
+
+QML_DECLARE_TYPE(MyDotPropertyObject);
+
+namespace MyNamespace {
+ class MyNamespacedType : public QObject
+ {
+ Q_OBJECT
+ };
+
+ class MySecondNamespacedType : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeListProperty<MyNamespace::MyNamespacedType> list READ list);
+ public:
+ QDeclarativeListProperty<MyNamespacedType> list() { return QDeclarativeListProperty<MyNamespacedType>(this, m_list); }
+
+ private:
+ QList<MyNamespacedType *> m_list;
+ };
+}
+QML_DECLARE_TYPE(MyNamespace::MyNamespacedType);
+QML_DECLARE_TYPE(MyNamespace::MySecondNamespacedType);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
new file mode 100644
index 0000000000..1ba4454d73
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -0,0 +1,1406 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+
+#include <private/qdeclarativeproperty_p.h>
+#include <private/qdeclarativemetatype_p.h>
+
+#include "testtypes.h"
+
+#include "../../../shared/util.h"
+
+/*
+This test case covers QML language issues. This covers everything that does not
+involve evaluating ECMAScript expressions and bindings.
+
+Evaluation of expressions and bindings is covered in qmlecmascript
+*/
+class tst_qdeclarativelanguage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativelanguage() {
+ QDeclarativeMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
+ QFileInfo fileInfo(__FILE__);
+ engine.addImportPath(fileInfo.absoluteDir().filePath(QLatin1String("data/lib")));
+ }
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void errors_data();
+ void errors();
+
+ void simpleObject();
+ void simpleContainer();
+ void interfaceProperty();
+ void interfaceQList();
+ void assignObjectToSignal();
+ void assignObjectToVariant();
+ void assignLiteralSignalProperty();
+ void assignQmlComponent();
+ void assignBasicTypes();
+ void assignTypeExtremes();
+ void assignCompositeToType();
+ void customParserTypes();
+ void rootAsQmlComponent();
+ void inlineQmlComponents();
+ void idProperty();
+ void autoNotifyConnection();
+ void assignSignal();
+ void dynamicProperties();
+ void dynamicPropertiesNested();
+ void listProperties();
+ void dynamicObjectProperties();
+ void dynamicSignalsAndSlots();
+ void simpleBindings();
+ void autoComponentCreation();
+ void propertyValueSource();
+ void attachedProperties();
+ void dynamicObjects();
+ void customVariantTypes();
+ void valueTypes();
+ void cppnamespace();
+ void aliasProperties();
+ void componentCompositeType();
+ void i18n();
+ void i18n_data();
+ void onCompleted();
+ void scriptString();
+ void defaultPropertyListOrder();
+ void declaredPropertyValues();
+
+ void importsBuiltin_data();
+ void importsBuiltin();
+ void importsLocal_data();
+ void importsLocal();
+ void importsRemote_data();
+ void importsRemote();
+ void importsInstalled_data();
+ void importsInstalled();
+ void importsOrder_data();
+ void importsOrder();
+
+ void qmlAttachedPropertiesObjectMethod();
+
+ // regression tests for crashes
+ void crash1();
+ void crash2();
+
+private:
+ QDeclarativeEngine engine;
+ void testType(const QString& qml, const QString& type);
+};
+
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::ReadOnly)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QDeclarativeError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QDeclarativeError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "" && expected != actual) \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
+ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::WriteOnly)); \
+ for (int ii = 0; ii < actual.count(); ++ii) { \
+ file.write(actual.at(ii)); file.write("\n"); \
+ } \
+ file.close(); \
+ } else { \
+ QCOMPARE(expected, actual); \
+ } \
+ }
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+void tst_qdeclarativelanguage::cleanupTestCase()
+{
+ QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
+}
+
+void tst_qdeclarativelanguage::errors_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
+
+ QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false;
+
+ QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false;
+ QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false;
+ QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false;
+
+ QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false;
+ QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false;
+ QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false;
+ QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false;
+ QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false;
+ QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false;
+ QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false;
+ QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false;
+ QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false;
+ QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false;
+ QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false;
+ QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false;
+
+ QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
+ QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
+
+ QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
+ QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
+
+ QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false;
+ QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false;
+ QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false;
+ QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
+ QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
+ QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
+
+ QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
+ QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
+ QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
+ QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false;
+ QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false;
+ QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false;
+ QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false;
+ QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
+ QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
+ QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
+ QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
+
+ QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
+
+ QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
+ QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
+ QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
+ QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false;
+
+ QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false;
+ QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false;
+ QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false;
+
+ QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false;
+ QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false;
+ QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false;
+ QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false;
+ QTest::newRow("property.5") << "property.5.qml" << "property.5.errors.txt" << false;
+
+ QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false;
+ QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false;
+ QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false;
+ QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false;
+ QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false;
+ QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false;
+ QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false;
+ QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false;
+ QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false;
+ QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false;
+ QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false;
+ QTest::newRow("Script.12") << "script.12.qml" << "script.12.errors.txt" << false;
+
+ QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
+ QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
+ QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
+ QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
+ QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
+ QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
+
+ QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false;
+
+ QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
+ QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
+ QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
+ QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
+ QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
+ QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+}
+
+
+void tst_qdeclarativelanguage::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
+
+ if (file == "invalidID.6.qml")
+ QTest::ignoreMessage(QtWarningMsg, "id \"StartsWithUpperCase\" is invalid: ids cannot start with uppercase letters");
+
+ QDeclarativeComponent component(&engine, TEST_FILE(file));
+
+ if(create) {
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+void tst_qdeclarativelanguage::simpleObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("simpleObject.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qdeclarativelanguage::simpleContainer()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("simpleContainer.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QCOMPARE(container->getChildren()->count(),2);
+}
+
+void tst_qdeclarativelanguage::interfaceProperty()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("interfaceProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->interface());
+ QVERIFY(object->interface()->id == 913);
+}
+
+void tst_qdeclarativelanguage::interfaceQList()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("interfaceQList.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->getQListInterfaces()->count() == 2);
+ for(int ii = 0; ii < 2; ++ii)
+ QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
+}
+
+void tst_qdeclarativelanguage::assignObjectToSignal()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToSignal.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+}
+
+void tst_qdeclarativelanguage::assignObjectToVariant()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVariant v = object->property("a");
+ QVERIFY(v.userType() == qMetaTypeId<QObject *>());
+}
+
+void tst_qdeclarativelanguage::assignLiteralSignalProperty()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->onLiteralSignal(), 10);
+}
+
+// Test is an external component can be loaded and assigned (to a qlist)
+void tst_qdeclarativelanguage::assignQmlComponent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignQmlComponent.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->getChildren()->count() == 1);
+ QObject *child = object->getChildren()->at(0);
+ QCOMPARE(child->property("x"), QVariant(10));
+ QCOMPARE(child->property("y"), QVariant(11));
+}
+
+// Test literal assignment to all the basic types
+void tst_qdeclarativelanguage::assignBasicTypes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF((float)-10.1, (float)12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF((float)0.1, (float)0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ QVERIFY(object->objectProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
+ QVERIFY(child != 0);
+ QCOMPARE(child->intProperty(), 8);
+}
+
+// Test edge case type assignments
+void tst_qdeclarativelanguage::assignTypeExtremes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignTypeExtremes.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->uintProperty(), 0xEE6B2800);
+ QCOMPARE(object->intProperty(), -0x77359400);
+}
+
+// Test that a composite type can assign to a property of its base type
+void tst_qdeclarativelanguage::assignCompositeToType()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Tests that custom parser types can be instantiated
+void tst_qdeclarativelanguage::customParserTypes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("customParserTypes.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("count") == QVariant(2));
+}
+
+// Tests that the root item can be a custom component
+void tst_qdeclarativelanguage::rootAsQmlComponent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("x"), QVariant(11));
+ QCOMPARE(object->getChildren()->count(), 2);
+}
+
+// Tests that components can be specified inline
+void tst_qdeclarativelanguage::inlineQmlComponents()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->getChildren()->count(), 1);
+ QDeclarativeComponent *comp = qobject_cast<QDeclarativeComponent *>(object->getChildren()->at(0));
+ QVERIFY(comp != 0);
+ MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
+ QVERIFY(compObject != 0);
+ QCOMPARE(compObject->value(), 11);
+}
+
+// Tests that types that have an id property have it set
+void tst_qdeclarativelanguage::idProperty()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("idProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->getChildren()->count(), 1);
+ MyTypeObject *child =
+ qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
+ QVERIFY(child != 0);
+ QCOMPARE(child->id(), QString("myObjectId"));
+ QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
+}
+
+// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
+// even if the notify signal for "blah" is not called "blahChanged"
+void tst_qdeclarativelanguage::autoNotifyConnection()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
+ QVERIFY(prop.isValid());
+
+ QCOMPARE(prop.read(object), QVariant::fromValue(false));
+ object->setPropertyWithNotify(1);
+ QCOMPARE(prop.read(object), QVariant::fromValue(true));
+}
+
+// Tests that signals can be assigned to
+void tst_qdeclarativelanguage::assignSignal()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignSignal.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)");
+ emit object->basicParameterizedSignal(9);
+}
+
+// Tests the creation and assignment of dynamic properties
+void tst_qdeclarativelanguage::dynamicProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("intProperty"), QVariant(10));
+ QCOMPARE(object->property("boolProperty"), QVariant(false));
+ QCOMPARE(object->property("doubleProperty"), QVariant(-10.1));
+ QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9));
+ QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
+ QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml")));
+ QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
+ QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
+ QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
+ QCOMPARE(object->property("variantProperty"), QVariant(12));
+}
+
+// Test that nested types can use dynamic properties
+void tst_qdeclarativelanguage::dynamicPropertiesNested()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("super_a").toInt(), 11); // Overridden
+ QCOMPARE(object->property("super_c").toInt(), 14); // Inherited
+ QCOMPARE(object->property("a").toInt(), 13); // New
+ QCOMPARE(object->property("b").toInt(), 12); // New
+
+ delete object;
+}
+
+// Tests the creation and assignment to dynamic list properties
+void tst_qdeclarativelanguage::listProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+}
+
+// Tests the creation and assignment of dynamic object properties
+// ### Not complete
+void tst_qdeclarativelanguage::dynamicObjectProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0));
+ QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0));
+}
+
+// Tests the declaration of dynamic signals and slots
+void tst_qdeclarativelanguage::dynamicSignalsAndSlots()
+{
+ QTest::ignoreMessage(QtDebugMsg, "1921");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10)));
+ QCOMPARE(object->property("test").toInt(), 10);
+}
+
+void tst_qdeclarativelanguage::simpleBindings()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("simpleBindings.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value1"), QVariant(10));
+ QCOMPARE(object->property("value2"), QVariant(10));
+ QCOMPARE(object->property("value3"), QVariant(21));
+ QCOMPARE(object->property("value4"), QVariant(10));
+ QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
+}
+
+void tst_qdeclarativelanguage::autoComponentCreation()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("autoComponentCreation.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->componentProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
+ QVERIFY(child != 0);
+ QCOMPARE(child->realProperty(), qreal(9));
+}
+
+void tst_qdeclarativelanguage::propertyValueSource()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QList<QObject *> valueSources;
+ QObjectList allChildren = object->findChildren<QObject*>();
+ foreach (QObject *child, allChildren) {
+ if (qobject_cast<QDeclarativePropertyValueSource *>(child))
+ valueSources.append(child);
+ }
+
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), object);
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.2.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QList<QObject *> valueSources;
+ QObjectList allChildren = object->findChildren<QObject*>();
+ foreach (QObject *child, allChildren) {
+ if (qobject_cast<QDeclarativePropertyValueSource *>(child))
+ valueSources.append(child);
+ }
+
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), object);
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+ }
+}
+
+void tst_qdeclarativelanguage::attachedProperties()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("attachedProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
+ QVERIFY(attached != 0);
+ QCOMPARE(attached->property("value"), QVariant(10));
+ QCOMPARE(attached->property("value2"), QVariant(13));
+}
+
+// Tests non-static object properties
+void tst_qdeclarativelanguage::dynamicObjects()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("dynamicObject.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Tests the registration of custom variant string converters
+void tst_qdeclarativelanguage::customVariantTypes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("customVariantTypes.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->customType().a, 10);
+}
+
+void tst_qdeclarativelanguage::valueTypes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("valueTypes.qml"));
+ VERIFY_ERRORS(0);
+
+ QString message = QLatin1String("QML MyTypeObject (") + component.url().toString() +
+ QLatin1String(":2:1) Binding loop detected for property \"rectProperty.width\"");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+
+
+ QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13));
+ QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13));
+ QCOMPARE(object->intProperty(), 10);
+ object->doAction();
+ QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13));
+ QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13));
+ QCOMPARE(object->intProperty(), 12);
+
+ // ###
+#if 0
+ QDeclarativeProperty p(object, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(12));
+ p.write(13);
+ QCOMPARE(p.read(), QVariant(13));
+
+ quint32 r = QDeclarativePropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
+ QDeclarativeProperty p2;
+ QDeclarativePropertyPrivate::restore(p2, r, object);
+ QCOMPARE(p2.read(), QVariant(13));
+#endif
+}
+
+void tst_qdeclarativelanguage::cppnamespace()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qdeclarativelanguage::aliasProperties()
+{
+ // Simple "int" alias
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toInt(), 10);
+ object->setProperty("value", QVariant(13));
+ QCOMPARE(object->property("valueAlias").toInt(), 13);
+
+ // Write throught alias
+ object->setProperty("valueAlias", QVariant(19));
+ QCOMPARE(object->property("valueAlias").toInt(), 19);
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+ }
+
+ // Complex object alias
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ MyQmlObject *v =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v != 0);
+ QCOMPARE(v->value(), 10);
+
+ // Write through alias
+ MyQmlObject *v2 = new MyQmlObject();
+ v2->setParent(object);
+ object->setProperty("aliasObject", qVariantFromValue(v2));
+ MyQmlObject *v3 =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v3 != 0);
+ QCOMPARE(v3, v2);
+
+ delete object;
+ }
+
+ // Nested aliases
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.3.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 1892);
+ QCOMPARE(object->property("value2").toInt(), 1892);
+
+ object->setProperty("value", QVariant(1313));
+ QCOMPARE(object->property("value").toInt(), 1313);
+ QCOMPARE(object->property("value2").toInt(), 1313);
+
+ object->setProperty("value2", QVariant(8080));
+ QCOMPARE(object->property("value").toInt(), 8080);
+ QCOMPARE(object->property("value2").toInt(), 8080);
+
+ delete object;
+ }
+
+ // Enum aliases
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.4.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("enumAlias").toInt(), 1);
+
+ delete object;
+ }
+
+ // Id aliases
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.5.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant v = object->property("otherAlias");
+ QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
+ MyQmlObject *o = qvariant_cast<MyQmlObject*>(v);
+ QCOMPARE(o->value(), 10);
+
+ delete o;
+
+ v = object->property("otherAlias");
+ QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
+ o = qvariant_cast<MyQmlObject*>(v);
+ QVERIFY(o == 0);
+
+ delete object;
+ }
+
+ // Nested aliases - this used to cause a crash
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.6.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 1923);
+ }
+
+ // Ptr Alias Cleanup - check that aliases to ptr types return 0
+ // if the object aliased to is removed
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.7.qml"));
+ VERIFY_ERRORS(0);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *object1 = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(object1 != 0);
+ QObject *object2 = qvariant_cast<QObject *>(object1->property("object"));
+ QVERIFY(object2 != 0);
+
+ QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject"));
+ QVERIFY(alias == object2);
+
+ delete object1;
+
+ QObject *alias2 = object; // "Random" start value
+ int status = -1;
+ void *a[] = { &alias2, 0, &status };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty,
+ object->metaObject()->indexOfProperty("aliasedObject"), a);
+ QVERIFY(alias2 == 0);
+ }
+
+ // Simple composite type
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.8.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 10);
+
+ delete object;
+ }
+
+ // Complex composite type
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("alias.9.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 10);
+
+ delete object;
+ }
+}
+
+// Test that the root element in a composite type can be a Component
+void tst_qdeclarativelanguage::componentCompositeType()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+class TestType : public QObject {
+ Q_OBJECT
+public:
+ TestType(QObject *p=0) : QObject(p) {}
+};
+
+class TestType2 : public QObject {
+ Q_OBJECT
+public:
+ TestType2(QObject *p=0) : QObject(p) {}
+};
+
+void tst_qdeclarativelanguage::i18n_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("stringProperty");
+ QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
+ QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
+ QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
+ QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
+ QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
+ QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
+}
+
+void tst_qdeclarativelanguage::i18n()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, stringProperty);
+ QDeclarativeComponent component(&engine, TEST_FILE(file));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), stringProperty);
+
+ delete object;
+}
+
+// Check that the Component::onCompleted attached property works
+void tst_qdeclarativelanguage::onCompleted()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("onCompleted.qml"));
+ VERIFY_ERRORS(0);
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Check that assignments to QDeclarativeScriptString properties work
+void tst_qdeclarativelanguage::scriptString()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("foo + bar"));
+ QCOMPARE(object->scriptProperty().scopeObject(), object);
+ QCOMPARE(object->scriptProperty().context(), qmlContext(object));
+
+ QVERIFY(object->grouped() != 0);
+ QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)"));
+ QCOMPARE(object->grouped()->script().scopeObject(), object);
+ QCOMPARE(object->grouped()->script().context(), qmlContext(object));
+}
+
+// Check that default property assignments are correctly spliced into explicit
+// property assignments
+void tst_qdeclarativelanguage::defaultPropertyListOrder()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
+ VERIFY_ERRORS(0);
+
+ MyContainer *container = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->getChildren()->count(), 6);
+ QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
+ QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
+ QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
+ QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
+ QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
+ QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
+}
+
+void tst_qdeclarativelanguage::declaredPropertyValues()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
+ QEXPECT_FAIL("", "QTBUG-7860", Abort);
+ VERIFY_ERRORS(0);
+}
+
+// Check that first child of qml is of given type. Empty type insists on error.
+void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type)
+{
+ QDeclarativeComponent component(&engine);
+ component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
+
+ QTRY_VERIFY(!component.isLoading());
+
+ if (type.isEmpty()) {
+ QVERIFY(component.isError());
+ } else {
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(QString(object->metaObject()->className()), type);
+ }
+}
+
+QML_DECLARE_TYPE(TestType)
+QML_DECLARE_TYPE(TestType2)
+
+// Import tests (QT-558)
+
+void tst_qdeclarativelanguage::importsBuiltin_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ // import built-ins
+ QTest::newRow("missing import")
+ << "Test {}"
+ << "";
+ QTest::newRow("not in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "Test {}"
+ << "";
+ QTest::newRow("in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "TestTP {}"
+ << "TestType";
+ QTest::newRow("qualified in version 0.0")
+ << "import com.nokia.Test 0.0 as T\n"
+ "T.TestTP {}"
+ << "TestType";
+ QTest::newRow("in version 1.0")
+ << "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << "TestType";
+ QTest::newRow("qualified wrong")
+ << "import com.nokia.Test 1.0 as T\n" // QT-610
+ "Test {}"
+ << "";
+ QTest::newRow("qualified right")
+ << "import com.nokia.Test 1.0 as T\n"
+ "T.Test {}"
+ << "TestType";
+ QTest::newRow("qualified right but not in version 0.0")
+ << "import com.nokia.Test 0.0 as T\n"
+ "T.Test {}"
+ << "";
+ QTest::newRow("in version 1.1")
+ << "import com.nokia.Test 1.1\n"
+ "Test {}"
+ << "TestType";
+ QTest::newRow("in version 1.3")
+ << "import com.nokia.Test 1.3\n"
+ "Test {}"
+ << "TestType";
+ QTest::newRow("in version 1.5")
+ << "import com.nokia.Test 1.5\n"
+ "Test {}"
+ << "TestType";
+ QTest::newRow("changed in version 1.8")
+ << "import com.nokia.Test 1.8\n"
+ "Test {}"
+ << "TestType2";
+ QTest::newRow("in version 1.12")
+ << "import com.nokia.Test 1.12\n"
+ "Test {}"
+ << "TestType2";
+ QTest::newRow("old in version 1.9")
+ << "import com.nokia.Test 1.9\n"
+ "OldTest {}"
+ << "TestType";
+ QTest::newRow("old in version 1.11")
+ << "import com.nokia.Test 1.11\n"
+ "OldTest {}"
+ << "TestType";
+ QTest::newRow("multiversion 1")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "Test {}"
+ << "TestType2";
+ QTest::newRow("multiversion 2")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "OldTest {}"
+ << "TestType";
+ QTest::newRow("qualified multiversion 3")
+ << "import com.nokia.Test 1.0 as T0\n"
+ "import com.nokia.Test 1.8 as T8\n"
+ "T0.Test {}"
+ << "TestType";
+ QTest::newRow("qualified multiversion 4")
+ << "import com.nokia.Test 1.0 as T0\n"
+ "import com.nokia.Test 1.8 as T8\n"
+ "T8.Test {}"
+ << "TestType2";
+}
+
+void tst_qdeclarativelanguage::importsBuiltin()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::importsLocal_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ // import locals
+ QTest::newRow("local import")
+ << "import \"subdir\"\n" // QT-613
+ "Test {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("local import second")
+ << "import Qt 4.6\nimport \"subdir\"\n"
+ "Test {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("local import subsubdir")
+ << "import Qt 4.6\nimport \"subdir/subsubdir\"\n"
+ "SubTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("local import QTBUG-7721 A")
+ << "subdir.Test {}" // no longer allowed (QTBUG-7721)
+ << "";
+ QTest::newRow("local import QTBUG-7721 B")
+ << "import \"subdir\" as X\n"
+ "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
+ << "";
+ QTest::newRow("local import as")
+ << "import \"subdir\" as T\n"
+ "T.Test {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("wrong local import as")
+ << "import \"subdir\" as T\n"
+ "Test {}"
+ << "";
+ QTest::newRow("library precedence over local import")
+ << "import \"subdir\"\n"
+ "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << "TestType";
+}
+
+void tst_qdeclarativelanguage::importsLocal()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::importsRemote_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage";
+
+ QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle";
+ QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText";
+ QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage";
+}
+
+#include "testhttpserver.h"
+
+void tst_qdeclarativelanguage::importsRemote()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+
+ TestHTTPServer server(14445);
+ server.serveDirectory(SRCDIR);
+
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::importsInstalled_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ // import installed
+ QTest::newRow("installed import 0")
+ << "import com.nokia.installedtest 0.0\n"
+ "InstalledTestTP {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 0 as TP")
+ << "import com.nokia.installedtest 0.0 as TP\n"
+ "TP.InstalledTestTP {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 1")
+ << "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 2")
+ << "import com.nokia.installedtest 1.3\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import 3")
+ << "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import 4")
+ << "import com.nokia.installedtest 1.10\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import visibility") // QT-614
+ << "import com.nokia.installedtest 1.4\n"
+ "PrivateType {}"
+ << "";
+}
+
+void tst_qdeclarativelanguage::importsInstalled()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+
+void tst_qdeclarativelanguage::importsOrder_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ QTest::newRow("installed import overrides 1") <<
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import re-overrides 1") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QDeclarativeText";
+ QTest::newRow("installed import re-overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QDeclarativeRectangle";
+
+ QTest::newRow("installed import versus builtin 1") <<
+ "import com.nokia.installedtest 1.5\n"
+ "import Qt 4.6\n"
+ "Rectangle {}"
+ << "QDeclarativeRectangle";
+ QTest::newRow("installed import versus builtin 2") <<
+ "import Qt 4.6\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << "QDeclarativeText";
+ QTest::newRow("namespaces cannot be overridden by types 1") <<
+ "import Qt 4.6 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << "";
+ QTest::newRow("namespaces cannot be overridden by types 2") <<
+ "import Qt 4.6 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle.Image {}"
+ << "QDeclarativeImage";
+}
+
+void tst_qdeclarativelanguage::importsOrder()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod()
+{
+ QObject object;
+
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0);
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0);
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
+ }
+}
+
+void tst_qdeclarativelanguage::crash1()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nComponent {}", QUrl());
+}
+
+void tst_qdeclarativelanguage::crash2()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml"));
+}
+
+
+void tst_qdeclarativelanguage::initTestCase()
+{
+ registerTypes();
+
+ QML_REGISTER_TYPE(com.nokia.Test, 0, 0, TestTP, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 0, Test, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 5, Test, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 8, Test, TestType2);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 9, OldTest, TestType);
+ QML_REGISTER_TYPE(com.nokia.Test, 1, 12, Test, TestType2);
+
+ // Create locale-specific file
+ // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
+ // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
+ // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
+ QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
+ QVERIFY(in.open(QIODevice::ReadOnly));
+ QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
+ QVERIFY(out.open(QIODevice::WriteOnly));
+ out.write(in.readAll());
+}
+
+QTEST_MAIN(tst_qdeclarativelanguage)
+
+#include "tst_qdeclarativelanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
new file mode 100644
index 0000000000..d728d082a8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += script
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelistmodel.cpp
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
new file mode 100644
index 0000000000..a1e6d6bfea
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -0,0 +1,346 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
+#include <QtDeclarative/private/qdeclarativeexpression_p.h>
+#include <QDeclarativeComponent>
+#include <QDebug>
+
+class tst_QDeclarativeListModel : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeListModel() {}
+
+private slots:
+ void static_types();
+ void static_types_data();
+ void static_i18n();
+ void static_nestedElements();
+ void static_nestedElements_data();
+ void dynamic_data();
+ void dynamic();
+ void error_data();
+ void error();
+};
+
+void tst_QDeclarativeListModel::static_i18n()
+{
+ QString expect = QString::fromUtf8("na\303\257ve");
+ QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }";
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+ QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(obj != 0);
+ QString prop = obj->get(0).property(QLatin1String("prop1")).toString();
+ QCOMPARE(prop,expect);
+ delete obj;
+}
+
+void tst_QDeclarativeListModel::static_nestedElements()
+{
+ QFETCH(int, elementCount);
+
+ QStringList elements;
+ for (int i=0; i<elementCount; i++)
+ elements.append("ListElement { a: 1; b: 2 }");
+ QString elementsStr = elements.join(",\n") + "\n";
+
+ QString componentStr =
+ "import Qt 4.6\n"
+ "ListModel {\n"
+ " ListElement {\n"
+ " attributes: [\n";
+ componentStr += elementsStr.toUtf8().constData();
+ componentStr +=
+ " ]\n"
+ " }\n"
+ "}";
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+
+ QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(obj != 0);
+
+ QScriptValue prop = obj->get(0).property(QLatin1String("attributes")).property(QLatin1String("count"));
+ QVERIFY(prop.isNumber());
+ QCOMPARE(prop.toInt32(), qint32(elementCount));
+
+ delete obj;
+}
+
+void tst_QDeclarativeListModel::static_nestedElements_data()
+{
+ QTest::addColumn<int>("elementCount");
+
+ QTest::newRow("0 items") << 0;
+ QTest::newRow("1 item") << 1;
+ QTest::newRow("2 items") << 2;
+ QTest::newRow("many items") << 5;
+}
+
+void tst_QDeclarativeListModel::dynamic_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+ QTest::addColumn<QString>("warning");
+
+ // Simple flat model
+
+ QTest::newRow("count") << "count" << 0 << "";
+
+ QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+ QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range";
+
+ QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
+ QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
+ QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "";
+ QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "";
+ QTest::newRow("append4a") << "{append(123)}" << 0 << "QML ListModel (unknown location) append: value is not an object";
+ QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML ListModel (unknown location) append: value is not an object";
+
+ QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
+ QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
+ QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+
+ QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "";
+ QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "";
+ QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "";
+ QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "";
+ QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+ QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range";
+ QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
+ QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
+ QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range";
+
+ QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "";
+ QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range";
+ QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "";
+ QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "";
+ QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "";
+ QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "";
+ QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "";
+ QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) insert: index -1 out of range";
+ QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
+ QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
+
+ QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "";
+ QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
+ QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
+ QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
+ QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
+ QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
+ QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object";
+ QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object";
+ QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "";
+
+ QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "";
+ QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "";
+ QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "";
+ QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "";
+ QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
+ QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
+ QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range";
+ QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "";
+
+ QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "";
+ QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "";
+ QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "";
+ QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "";
+ QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "";
+ QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "";
+ QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "";
+ QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "";
+ QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "";
+ QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML ListModel (unknown location) move: out of range";
+ QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
+ QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML ListModel (unknown location) move: out of range";
+ QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
+
+ // Structured model
+
+ QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "";
+ QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "";
+ QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "";
+}
+
+void tst_QDeclarativeListModel::dynamic()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+
+ QDeclarativeEngine engine;
+ QDeclarativeListModel model;
+ QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->addDefaultObject(&model);
+ QDeclarativeExpression e(engine.rootContext(), script, &model);
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+ int actual = e.value().toInt();
+ if (e.hasError())
+ qDebug() << e.error(); // errors not expected
+ QVERIFY(!e.hasError());
+ QCOMPARE(actual,result);
+}
+
+void tst_QDeclarativeListModel::static_types_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+
+ QTest::newRow("string")
+ << "ListElement { foo: \"bar\" }"
+ << QVariant(QString("bar"));
+
+ QTest::newRow("real")
+ << "ListElement { foo: 10.5 }"
+ << QVariant(10.5);
+
+ QTest::newRow("real0")
+ << "ListElement { foo: 0 }"
+ << QVariant(double(0));
+
+ QTest::newRow("bool")
+ << "ListElement { foo: false }"
+ << QVariant(false);
+
+ QTest::newRow("bool")
+ << "ListElement { foo: true }"
+ << QVariant(true);
+
+ QTest::newRow("enum")
+ << "ListElement { foo: Text.AlignHCenter }"
+ << QVariant("QTBUG-5974:ListElement: constant script support for property value");
+}
+
+void tst_QDeclarativeListModel::static_types()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+
+ qml = "import Qt 4.6\nListModel { " + qml + " }";
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+
+ if (value.toString().startsWith("QTBUG-"))
+ QEXPECT_FAIL("",value.toString().toLatin1(),Abort);
+
+ QVERIFY(!component.isError());
+
+ QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
+ QVERIFY(obj != 0);
+
+ QScriptValue actual = obj->get(0).property(QLatin1String("foo"));
+
+ QCOMPARE(actual.isString(), value.type() == QVariant::String);
+ QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool);
+ QCOMPARE(actual.isNumber(), value.type() == QVariant::Double);
+
+ QCOMPARE(actual.toString(), value.toString());
+
+ delete obj;
+}
+
+void tst_QDeclarativeListModel::error_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("id not allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { id: fred } }"
+ << "ListElement: cannot use reserved \"id\" property";
+
+ QTest::newRow("id allowed in ListModel")
+ << "import Qt 4.6\nListModel { id:model }"
+ << "";
+
+ QTest::newRow("random properties not allowed in ListModel")
+ << "import Qt 4.6\nListModel { foo:123 }"
+ << "ListModel: undefined property 'foo'";
+
+ QTest::newRow("random properties allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { foo:123 } }"
+ << "";
+
+ QTest::newRow("bindings not allowed in ListElement")
+ << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
+ << "ListElement: cannot use script for property value"; // but note QTBUG-5974
+
+ QTest::newRow("random object list properties allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
+ << "";
+
+ QTest::newRow("default properties not allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { Item { } } }"
+ << "QTBUG-6082 ListElement should not allow child objects";
+}
+
+void tst_QDeclarativeListModel::error()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, error);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ if (error.isEmpty()) {
+ QVERIFY(!component.isError());
+ } else {
+ if (error.startsWith(QLatin1String("QTBUG-")))
+ QEXPECT_FAIL("",error.toLatin1(),Abort);
+ QVERIFY(component.isError());
+ QList<QDeclarativeError> errors = component.errors();
+ QCOMPARE(errors.count(),1);
+ QCOMPARE(errors.at(0).description(),error);
+ }
+}
+
+QTEST_MAIN(tst_QDeclarativeListModel)
+
+#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/declarative/qmllist/data/MyType.qml b/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml
index d08f35bb54..d08f35bb54 100644
--- a/tests/auto/declarative/qmllist/data/MyType.qml
+++ b/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml
diff --git a/tests/auto/declarative/qmllist/data/engineTypes.qml b/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml
index 670aee470d..670aee470d 100644
--- a/tests/auto/declarative/qmllist/data/engineTypes.qml
+++ b/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml
diff --git a/tests/auto/declarative/qmllist/data/variantToList.qml b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml
index 0c2d0aa2fc..0c2d0aa2fc 100644
--- a/tests/auto/declarative/qmllist/data/variantToList.qml
+++ b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml
diff --git a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
new file mode 100644
index 0000000000..0c9b2d976b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelistreference.cpp
diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
new file mode 100644
index 0000000000..1b7af19c48
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
@@ -0,0 +1,580 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativeprivate.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
+#include <QDebug>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+class tst_qdeclarativelistreference : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativelistreference() {}
+
+private slots:
+ void initTestCase();
+ void qmllistreference();
+ void qmllistreference_invalid();
+ void isValid();
+ void object();
+ void listElementType();
+ void canAppend();
+ void canAt();
+ void canClear();
+ void canCount();
+ void append();
+ void at();
+ void clear();
+ void count();
+ void copy();
+ void qmlmetaproperty();
+ void engineTypes();
+ void variantToList();
+};
+
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeListProperty<TestType> data READ dataProperty);
+ Q_PROPERTY(int intProperty READ intProperty);
+
+public:
+ TestType() : property(this, data) {}
+ QDeclarativeListProperty<TestType> dataProperty() { return property; }
+ int intProperty() const { return 10; }
+
+ QList<TestType *> data;
+ QDeclarativeListProperty<TestType> property;
+};
+QML_DECLARE_TYPE(TestType);
+
+void tst_qdeclarativelistreference::initTestCase()
+{
+ QML_REGISTER_NOCREATE_TYPE(TestType);
+}
+
+void tst_qdeclarativelistreference::qmllistreference()
+{
+ TestType tt;
+
+ QDeclarativeListReference r(&tt, "data");
+ QVERIFY(r.isValid() == true);
+ QCOMPARE(r.count(), 0);
+
+ tt.data.append(&tt);
+ QCOMPARE(r.count(), 1);
+}
+
+void tst_qdeclarativelistreference::qmllistreference_invalid()
+{
+ TestType tt;
+
+ // Invalid
+ {
+ QDeclarativeListReference r;
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-property
+ {
+ QDeclarativeListReference r(&tt, "blah");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-list property
+ {
+ QDeclarativeListReference r(&tt, "intProperty");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+}
+
+void tst_qdeclarativelistreference::isValid()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.isValid() == true);
+ delete tt;
+ QVERIFY(ref.isValid() == false);
+ }
+}
+
+void tst_qdeclarativelistreference::object()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.object() == tt);
+ delete tt;
+ QVERIFY(ref.object() == 0);
+ }
+}
+
+void tst_qdeclarativelistreference::listElementType()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+ delete tt;
+ QVERIFY(ref.listElementType() == 0);
+ }
+}
+
+void tst_qdeclarativelistreference::canAppend()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.canAppend() == true);
+ delete tt;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.canAppend() == false);
+ }
+}
+
+void tst_qdeclarativelistreference::canAt()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.canAt() == true);
+ delete tt;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.at = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.canAt() == false);
+ }
+}
+
+void tst_qdeclarativelistreference::canClear()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.canClear() == true);
+ delete tt;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.canClear() == false);
+ }
+}
+
+void tst_qdeclarativelistreference::canCount()
+{
+ TestType *tt = new TestType;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.canCount() == true);
+ delete tt;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.count = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.canCount() == false);
+ }
+}
+
+void tst_qdeclarativelistreference::append()
+{
+ TestType *tt = new TestType;
+ QObject object;
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.append(tt) == true);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(&object) == false);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(0) == true);
+ QVERIFY(tt->data.count() == 2);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(tt->data.at(1) == 0);
+ delete tt;
+ QVERIFY(ref.append(0) == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.append(&tt) == false);
+ }
+}
+
+void tst_qdeclarativelistreference::at()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.at(0) == tt);
+ QVERIFY(ref.at(1) == 0);
+ QVERIFY(ref.at(2) == tt);
+ delete tt;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.at = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.at(0) == 0);
+ }
+}
+
+void tst_qdeclarativelistreference::clear()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.clear() == true);
+ QVERIFY(tt->data.count() == 0);
+ delete tt;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.clear() == false);
+ }
+}
+
+void tst_qdeclarativelistreference::count()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QDeclarativeListReference ref;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "blah");
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QDeclarativeListReference ref(tt, "data");
+ QVERIFY(ref.count() == 3);
+ tt->data.removeAt(1);
+ QVERIFY(ref.count() == 2);
+ delete tt;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.count = 0;
+ QDeclarativeListReference ref(&tt, "data");
+ QVERIFY(ref.count() == 0);
+ }
+}
+
+void tst_qdeclarativelistreference::copy()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QDeclarativeListReference *r1 = new QDeclarativeListReference(&tt, "data");
+ QVERIFY(r1->count() == 3);
+
+ QDeclarativeListReference r2(*r1);
+ QDeclarativeListReference r3;
+ r3 = *r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ delete r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ tt.data.removeAt(2);
+
+ QVERIFY(r2.count() == 2);
+ QVERIFY(r3.count() == 2);
+}
+
+void tst_qdeclarativelistreference::qmlmetaproperty()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QDeclarativeProperty prop(&tt, QLatin1String("data"));
+ QVariant v = prop.read();
+ QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
+ QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
+ QVERIFY(ref.count() == 3);
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+}
+
+void tst_qdeclarativelistreference::engineTypes()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("engineTypes.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QDeclarativeProperty p1(o, QLatin1String("myList"));
+ QVERIFY(p1.propertyTypeCategory() == QDeclarativeProperty::Normal);
+
+ QDeclarativeProperty p2(o, QLatin1String("myList"), engine.rootContext());
+ QVERIFY(p2.propertyTypeCategory() == QDeclarativeProperty::List);
+ QVariant v = p2.read();
+ QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
+ QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
+ QVERIFY(ref.count() == 2);
+ QVERIFY(ref.listElementType());
+ QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
+
+ delete o;
+}
+
+void tst_qdeclarativelistreference::variantToList()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("variantToList.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QVERIFY(o->property("value").userType() == qMetaTypeId<QDeclarativeListReference>());
+ QCOMPARE(o->property("test").toInt(), 1);
+
+ delete o;
+}
+
+QTEST_MAIN(tst_qdeclarativelistreference)
+
+#include "tst_qdeclarativelistreference.moc"
diff --git a/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
new file mode 100644
index 0000000000..7b124a56ff
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
@@ -0,0 +1,43 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ objectName: "displayText"
+ text: display
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ },
+ Component {
+ id: myHighlight
+ Rectangle { color: "green" }
+ }
+ ]
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+ highlight: myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
index e6b5c8fa52..e6b5c8fa52 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-enforcerange.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml
index 46fddae5ad..46fddae5ad 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-enforcerange.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
index 74f5ef494f..74f5ef494f 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml
index 4b5bea6648..4b5bea6648 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview-sections.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview.qml b/tests/auto/declarative/qdeclarativelistview/data/listview.qml
new file mode 100644
index 0000000000..1c1b3f8c7c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview.qml
@@ -0,0 +1,119 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ function checkProperties() {
+ testObject.error = false;
+ if (list.model != testModel) {
+ console.log("model property incorrect");
+ testObject.error = true;
+ }
+ if (!testObject.animate && list.delegate != myDelegate) {
+ console.log("delegate property incorrect - expected myDelegate");
+ testObject.error = true;
+ }
+ if (testObject.animate && list.delegate != animatedDelegate) {
+ console.log("delegate property incorrect - expected animatedDelegate");
+ testObject.error = true;
+ }
+ if (testObject.invalidHighlight && list.highlight != invalidHl) {
+ console.log("highlight property incorrect - expected invalidHl");
+ testObject.error = true;
+ }
+ if (!testObject.invalidHighlight && list.highlight != myHighlight) {
+ console.log("highlight property incorrect - expected myHighlight");
+ testObject.error = true;
+ }
+ }
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 120
+ id: textNumber
+ objectName: "textNumber"
+ text: number
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ },
+ Component {
+ id: animatedDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 120
+ id: textNumber
+ objectName: "textNumber"
+ text: number
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ ListView.onRemove: SequentialAnimation {
+ ScriptAction { script: console.log("Fix PropertyAction with attached properties") }
+/*
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+*/
+ }
+ }
+ },
+ Component {
+ id: myHighlight
+ Rectangle { color: "green" }
+ },
+ Component {
+ id: invalidHl
+ EaseFollow {}
+ }
+ ]
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ model: testModel
+ delegate: testObject.animate ? animatedDelegate : myDelegate
+ highlight: testObject.invalidHighlight ? invalidHl : myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
+ cacheBuffer: testObject.cacheBuffer
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
new file mode 100644
index 0000000000..3a076f8b47
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativelistview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
new file mode 100644
index 0000000000..f15f26bf36
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -0,0 +1,1413 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+#include <QStringListModel>
+#include <private/qlistmodelinterface_p.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativelistview_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativevisualitemmodel_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+
+class tst_QDeclarativeListView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeListView();
+
+private slots:
+ // Test both QListModelInterface and QAbstractItemModel model types
+ void qListModelInterface_items();
+ void qAbstractItemModel_items();
+
+ void qListModelInterface_changed();
+ void qAbstractItemModel_changed();
+
+ void qListModelInterface_inserted();
+ void qAbstractItemModel_inserted();
+
+ void qListModelInterface_removed();
+ void qAbstractItemModel_removed();
+
+ void qListModelInterface_moved();
+ void qAbstractItemModel_moved();
+
+ void qListModelInterface_clear();
+ void qAbstractItemModel_clear();
+
+ void itemList();
+ void currentIndex();
+ void enforceRange();
+ void spacing();
+ void sections();
+ void cacheBuffer();
+ void positionViewAtIndex();
+ void resetModel();
+
+private:
+ template <class T> void items();
+ template <class T> void changed();
+ template <class T> void inserted();
+ template <class T> void removed(bool animated);
+ template <class T> void moved();
+ template <class T> void clear();
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
+ template<typename T>
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
+ void dumpTree(QDeclarativeItem *parent, int depth = 0);
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
+ Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
+ Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
+
+public:
+ TestObject(QObject *parent = 0)
+ : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
+ , mCacheBuffer(0) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; emit changedError(); }
+
+ bool animate() const { return mAnimate; }
+ void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
+
+ bool invalidHighlight() const { return mInvalidHighlight; }
+ void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
+
+ int cacheBuffer() const { return mCacheBuffer; }
+ void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
+
+signals:
+ void changedError();
+ void changedAnim();
+ void changedHl();
+ void changedCacheBuffer();
+
+public:
+ bool mError;
+ bool mAnimate;
+ bool mInvalidHighlight;
+ int mCacheBuffer;
+};
+
+class TestModel : public QListModelInterface
+{
+ Q_OBJECT
+public:
+ TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
+ ~TestModel() {}
+
+ enum Roles { Name, Number };
+
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ int count() const { return list.count(); }
+
+ QList<int> roles() const { return QList<int>() << Name << Number; }
+ QString toString(int role) const {
+ switch(role) {
+ case Name:
+ return "name";
+ case Number:
+ return "number";
+ default:
+ return "";
+ }
+ }
+
+ QVariant data(int index, int role) const
+ {
+ if (role==0)
+ return list.at(index).first;
+ if (role==1)
+ return list.at(index).second;
+ return QVariant();
+ }
+ QHash<int, QVariant> data(int index, const QList<int> &roles) const {
+ QHash<int,QVariant> returnHash;
+
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ QVariant info;
+ switch(role) {
+ case Name:
+ info = list.at(index).first;
+ break;
+ case Number:
+ info = list.at(index).second;
+ break;
+ default:
+ break;
+ }
+ returnHash.insert(role, info);
+ }
+ return returnHash;
+ }
+
+ void addItem(const QString &name, const QString &number) {
+ list.append(QPair<QString,QString>(name, number));
+ emit itemsInserted(list.count()-1, 1);
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit itemsInserted(index, 1);
+ }
+
+ void removeItem(int index) {
+ list.removeAt(index);
+ emit itemsRemoved(index, 1);
+ }
+
+ void moveItem(int from, int to) {
+ list.move(from, to);
+ emit itemsMoved(from, to, 1);
+ }
+
+ void modifyItem(int index, const QString &name, const QString &number) {
+ list[index] = QPair<QString,QString>(name, number);
+ emit itemsChanged(index, 1, roles());
+ }
+
+ void clear() {
+ int count = list.count();
+ list.clear();
+ emit itemsRemoved(0, count);
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+class TestModel2 : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel2(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+ }
+
+ int count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+ void clear() {
+ int count = list.count();
+ emit beginRemoveRows(QModelIndex(), 0, count-1);
+ list.clear();
+ emit endRemoveRows();
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+tst_QDeclarativeListView::tst_QDeclarativeListView()
+{
+}
+
+template <class T>
+void tst_QDeclarativeListView::items()
+{
+ QDeclarativeView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QVERIFY(listview->highlightItem() != 0);
+ QCOMPARE(listview->count(), model.count());
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ // current item should be first item
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // switch to other delegate
+ testObject->setAnimate(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+
+ // set invalid highlight
+ testObject->setInvalidHighlight(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+ QVERIFY(listview->highlightItem() == 0);
+
+ // back to normal highlight
+ testObject->setInvalidHighlight(false);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+ QVERIFY(listview->highlightItem() != 0);
+
+ // set an empty model and confirm that items are destroyed
+ T model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ // Allow deleteLaters to process
+ QTest::qWait(500);
+
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QVERIFY(itemCount == 0);
+
+ QCOMPARE(listview->highlightResizeSpeed(), 1000.0);
+ QCOMPARE(listview->highlightMoveSpeed(), 1000.0);
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::changed()
+{
+ QDeclarativeView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::inserted()
+{
+ QDeclarativeView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ QCOMPARE(listview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+ QTest::qWait(500);
+
+ listview->setContentY(80);
+ QTest::qWait(500);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+ QTest::qWait(500);
+
+ QVERIFY(listview->contentY() == 80);
+
+ // Confirm items positioned correctly
+ for (int i = 5; i < 5+15; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0 - 20.0);
+ }
+
+// QCOMPARE(listview->viewportHeight(), model.count() * 20.0);
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::removed(bool animated)
+{
+ QDeclarativeView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ testObject->setAnimate(animated);
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.removeItem(1);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0); // post: top item starts at 20
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),i*20.0 + 20.0);
+ }
+
+ // Remove items not visible
+ model.removeItem(18);
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),i*20.0+20.0);
+ }
+
+ // Remove items before visible
+ listview->setContentY(80);
+ listview->setCurrentIndex(10);
+
+ model.removeItem(1); // post: top item will be at 40
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly
+ for (int i = 2; i < 18; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),40+i*20.0);
+ }
+
+ // Remove current index
+ QVERIFY(listview->currentIndex() == 9);
+ QDeclarativeItem *oldCurrent = listview->currentItem();
+ model.removeItem(9);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 9);
+ QVERIFY(listview->currentItem() != oldCurrent);
+
+ listview->setContentY(40); // That's the top now
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(),40+i*20.0);
+ }
+
+ // remove current item beyond visible items.
+ listview->setCurrentIndex(20);
+ QTest::qWait(500);
+ listview->setContentY(40);
+ model.removeItem(20);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 20);
+ QVERIFY(listview->currentItem() != 0);
+
+ // remove item before current, but visible
+ listview->setCurrentIndex(8);
+ QTest::qWait(500);
+ oldCurrent = listview->currentItem();
+ model.removeItem(6);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 7);
+ QVERIFY(listview->currentItem() == oldCurrent);
+
+ delete canvas;
+}
+
+template <class T>
+void tst_QDeclarativeListView::clear()
+{
+ QDeclarativeView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.clear();
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QVERIFY(listview->count() == 0);
+ QVERIFY(listview->currentItem() == 0);
+ QVERIFY(listview->contentY() == 0);
+
+ delete canvas;
+}
+
+
+template <class T>
+void tst_QDeclarativeListView::moved()
+{
+ QDeclarativeView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ model.moveItem(1, 4);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(1));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(1));
+
+ name = findItem<QDeclarativeText>(viewport, "textName", 4);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(4));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", 4);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(4));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ listview->setContentY(80);
+
+ // move outside visible area
+ model.moveItem(1, 18);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly and indexes correct
+ for (int i = 3; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0 + 20);
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ // move from outside visible into visible
+ model.moveItem(20, 4);
+
+ // let transitions settle.
+ QTest::qWait(500);
+
+ // Confirm items positioned correctly and indexes correct
+ for (int i = 3; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0 + 20);
+ name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::enforceRange()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QCOMPARE(listview->preferredHighlightBegin(), 100.0);
+ QCOMPARE(listview->preferredHighlightEnd(), 100.0);
+ QCOMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // view should be positioned at the top of the range.
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(listview->contentY(), -100.0);
+
+ QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(0));
+ QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when viewport moves
+ listview->setContentY(20);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 6);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::spacing()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ listview->setSpacing(10);
+ QVERIFY(listview->spacing() == 10);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*30);
+ }
+
+ listview->setSpacing(0);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::sections()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QVERIFY(item);
+ QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
+ }
+
+ // Remove section boundary
+ model.removeItem(5);
+
+ // New section header created
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 40.0);
+
+ model.insertItem(3, "New Item", "0");
+
+ // Section header moved
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 20.0);
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 40.0);
+
+ // insert item which will become a section header
+ model.insertItem(6, "Replace header", "1");
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 40.0);
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 7);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 20.0);
+
+ QCOMPARE(listview->currentSection(), QString("0"));
+
+ listview->setContentY(140);
+ QCOMPARE(listview->currentSection(), QString("1"));
+
+ listview->setContentY(20);
+ QCOMPARE(listview->currentSection(), QString("0"));
+
+ item = findItem<QDeclarativeItem>(viewport, "wrapper", 1);
+ QVERIFY(item);
+ QCOMPARE(item->height(), 20.0);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::currentIndex()
+{
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ QString filename(SRCDIR "/data/listview-initCurrent.qml");
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QTest::qWait(500);
+
+ // current item should be third item
+ QCOMPARE(listview->currentIndex(), 3);
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
+ QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+
+ // no wrap
+ listview->setCurrentIndex(0);
+ QCOMPARE(listview->currentIndex(), 0);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 1);
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // with wrap
+ ctxt->setContextProperty("testWrap", QVariant(true));
+ QVERIFY(listview->isWrapEnabled());
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), model.count()-1);
+
+ QTest::qWait(1000);
+ QCOMPARE(listview->contentY(), 279.0);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QTest::qWait(1000);
+ QCOMPARE(listview->contentY(), 0.0);
+
+ // Test keys
+ canvas->show();
+ qApp->processEvents();
+
+ QEvent wa(QEvent::WindowActivate);
+ QApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QApplication::sendEvent(canvas, &fe);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(listview->currentIndex(), 1);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // turn off auto highlight
+ listview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
+
+ QTest::qWait(500);
+ QVERIFY(listview->highlightItem());
+ qreal hlPos = listview->highlightItem()->y();
+
+ listview->setCurrentIndex(4);
+ QTest::qWait(500);
+ QCOMPARE(listview->highlightItem()->y(), hlPos);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::itemList()
+{
+ QDeclarativeView *canvas = createView();
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "view");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild<QDeclarativeVisualItemModel*>("itemModel");
+ QVERIFY(model != 0);
+
+ QVERIFY(model->count() == 3);
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "item1");
+ QVERIFY(item);
+ QCOMPARE(item->x(), 0.0);
+
+ QDeclarativeText *text = findItem<QDeclarativeText>(viewport, "text1");
+ QVERIFY(text);
+ QCOMPARE(text->text(), QLatin1String("index: 0"));
+
+ listview->setCurrentIndex(2);
+ QTest::qWait(1000);
+
+ item = findItem<QDeclarativeItem>(viewport, "item3");
+ QVERIFY(item);
+ QCOMPARE(item->x(), 480.0);
+
+ text = findItem<QDeclarativeText>(viewport, "text3");
+ QVERIFY(text);
+ QCOMPARE(text->text(), QLatin1String("index: 2"));
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::cacheBuffer()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+ QVERIFY(listview->delegate() != 0);
+ QVERIFY(listview->model() != 0);
+ QVERIFY(listview->highlight() != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ testObject->setCacheBuffer(400);
+ QVERIFY(listview->cacheBuffer() == 400);
+
+ int newItemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ QVERIFY(newItemCount > itemCount);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < newItemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::positionViewAtIndex()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position on a currently visible item
+ listview->positionViewAtIndex(3);
+ QCOMPARE(listview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item beyond the visible items
+ listview->positionViewAtIndex(22);
+ QCOMPARE(listview->contentY(), 440.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ listview->positionViewAtIndex(28);
+ QCOMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ // Position at the beginning again
+ listview->positionViewAtIndex(0);
+ QCOMPARE(listview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->y(), i*20.);
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativeListView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+void tst_QDeclarativeListView::qListModelInterface_items()
+{
+ items<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_items()
+{
+ items<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_changed()
+{
+ changed<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_changed()
+{
+ changed<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_inserted()
+{
+ inserted<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_inserted()
+{
+ inserted<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_removed()
+{
+ removed<TestModel>(false);
+ removed<TestModel>(true);
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_removed()
+{
+ removed<TestModel2>(false);
+ removed<TestModel2>(true);
+}
+
+void tst_QDeclarativeListView::qListModelInterface_moved()
+{
+ moved<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_moved()
+{
+ moved<TestModel2>();
+}
+
+void tst_QDeclarativeListView::qListModelInterface_clear()
+{
+ clear<TestModel>();
+}
+
+void tst_QDeclarativeListView::qAbstractItemModel_clear()
+{
+ clear<TestModel2>();
+}
+
+QDeclarativeView *tst_QDeclarativeListView::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+/*
+ Find an item with the specified objectName. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+*/
+template<typename T>
+T *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeExpression e(qmlContext(item), "index", item);
+ if (e.value().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+template<typename T>
+QList<T*> tst_QDeclarativeListView::findItems(QGraphicsObject *parent, const QString &objectName)
+{
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+}
+
+void tst_QDeclarativeListView::dumpTree(QDeclarativeItem *parent, int depth)
+{
+ static QString padding(" ");
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ qDebug() << padding.left(depth*2) << item;
+ dumpTree(item, depth+1);
+ }
+}
+
+
+QTEST_MAIN(tst_QDeclarativeListView)
+
+#include "tst_qdeclarativelistview.moc"
diff --git a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
new file mode 100644
index 0000000000..4ebf3664c0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+import Qt.widgets 4.6
+
+QGraphicsWidget {
+ size: "250x250"
+}
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
index cfbb55a6e7..cfbb55a6e7 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
index 5eab96506f..5eab96506f 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml b/tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml
index aa4b0c28b8..aa4b0c28b8 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml b/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml
index 1db56c408f..1db56c408f 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
index 568a1363b8..568a1363b8 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
index a7108033c4..a7108033c4 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
index b52fa03762..b52fa03762 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
index 1a107e130f..1a107e130f 100644
--- a/tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml
+++ b/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml
diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
new file mode 100644
index 0000000000..8ff2be4901
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../shared/
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativeloader.cpp \
+ ../shared/testhttpserver.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
new file mode 100644
index 0000000000..61b2800bde
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -0,0 +1,464 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtGui/QGraphicsWidget>
+#include <QtGui/QGraphicsScene>
+
+#include <QSignalSpy>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeloader_p.h>
+#include "testhttpserver.h"
+
+#define SERVER_PORT 14445
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+class tst_QDeclarativeLoader : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeLoader();
+
+private slots:
+ void url();
+ void invalidUrl();
+ void component();
+ void clear();
+ void urlToComponent();
+ void componentToUrl();
+ void sizeLoaderToItem();
+ void sizeItemToLoader();
+ void noResize();
+ void sizeLoaderToGraphicsWidget();
+ void sizeGraphicsWidgetToLoader();
+ void noResizeGraphicsWidget();
+ void networkRequestUrl();
+ void failNetworkRequest();
+// void networkComponent();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+
+tst_QDeclarativeLoader::tst_QDeclarativeLoader()
+{
+}
+
+void tst_QDeclarativeLoader::url()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml"));
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::component()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::invalidUrl()
+{
+ QTest::ignoreMessage(QtWarningMsg, QString("(:-1: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ") ").toUtf8().constData());
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Error);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::clear()
+{
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray(
+ "import Qt 4.6\n"
+ " Loader { id: loader\n"
+ " source: 'Rect120x60.qml'\n"
+ " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
+ " }")
+ , TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ QTest::qWait(500);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Null);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+ }
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ loader->setSourceComponent(0);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Null);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+ }
+}
+
+void tst_QDeclarativeLoader::urlToComponent()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\n"
+ "Loader {\n"
+ " id: loader\n"
+ " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
+ " source: \"Rect120x60.qml\"\n"
+ " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
+ "}" )
+ , TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QTest::qWait(500);
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+ QCOMPARE(loader->width(), 10.0);
+ QCOMPARE(loader->height(), 10.0);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::componentToUrl()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ loader->setSource(TEST_FILE("/Rect120x60.qml"));
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ delete loader;
+}
+
+void tst_QDeclarativeLoader::sizeLoaderToItem()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ // Check resize
+ QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
+ QVERIFY(rect);
+ rect->setWidth(150);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 150.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader);
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ // notify
+ QSignalSpy spy(loader, SIGNAL(resizeModeChanged()));
+ loader->setResizeMode(QDeclarativeLoader::NoResize);
+ QCOMPARE(spy.count(),1);
+ loader->setResizeMode(QDeclarativeLoader::NoResize);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_QDeclarativeLoader::sizeItemToLoader()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 200.0);
+ QCOMPARE(rect->height(), 80.0);
+
+ // Check resize
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem);
+ rect->setWidth(160);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 160.0);
+ QCOMPARE(loader->height(), 45.0);
+}
+
+void tst_QDeclarativeLoader::noResize()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 120.0);
+ QCOMPARE(rect->height(), 60.0);
+}
+
+void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QGraphicsScene scene;
+ scene.addItem(loader);
+
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeLoaderToItem);
+ QCOMPARE(loader->width(), 250.0);
+ QCOMPARE(loader->height(), 250.0);
+
+ // Check resize
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
+ QVERIFY(widget);
+ widget->resize(QSizeF(150,45));
+ QCOMPARE(loader->width(), 150.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeItemToLoader);
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(widget->size().width(), 180.0);
+ QCOMPARE(widget->size().height(), 30.0);
+}
+
+void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QGraphicsScene scene;
+ scene.addItem(loader);
+
+ QVERIFY(loader != 0);
+ QVERIFY(loader->resizeMode() == QDeclarativeLoader::SizeItemToLoader);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
+ QVERIFY(widget);
+ QCOMPARE(widget->size().width(), 200.0);
+ QCOMPARE(widget->size().height(), 80.0);
+
+ // Check resize
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(widget->size().width(), 180.0);
+ QCOMPARE(widget->size().height(), 30.0);
+
+ // Switch mode
+ loader->setResizeMode(QDeclarativeLoader::SizeLoaderToItem);
+ widget->resize(QSizeF(160,45));
+ QCOMPARE(loader->width(), 160.0);
+ QCOMPARE(loader->height(), 45.0);
+}
+
+void tst_QDeclarativeLoader::noResizeGraphicsWidget()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml"));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QGraphicsScene scene;
+ scene.addItem(loader);
+
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
+ QVERIFY(widget);
+ QCOMPARE(widget->size().width(), 250.0);
+ QCOMPARE(widget->size().height(), 250.0);
+}
+
+void tst_QDeclarativeLoader::networkRequestUrl()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+
+/* XXX Component waits until all dependencies are loaded. Is this actually possible?
+void tst_QDeclarativeLoader::networkComponent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory("slowdata", TestHTTPServer::Delay);
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray(
+ "import Qt 4.6\n"
+ "import \"http://127.0.0.1:14445/\" as NW\n"
+ "Item {\n"
+ " Component { id: comp; NW.SlowRect {} }\n"
+ " Loader { sourceComponent: comp } }")
+ , TEST_FILE(""));
+
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(item);
+
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ TRY_WAIT(loader->status() == QDeclarativeLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QDeclarativeLoader::Ready);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+*/
+
+void tst_QDeclarativeLoader::failNetworkRequest()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+
+ QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) ");
+
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/IDontExist.qml\" }"), TEST_FILE(""));
+ QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ TRY_WAIT(loader->status() == QDeclarativeLoader::Error);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
+
+ delete loader;
+}
+
+QTEST_MAIN(tst_QDeclarativeLoader)
+
+#include "tst_qdeclarativeloader.moc"
diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
new file mode 100644
index 0000000000..2f7ff824ec
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativemetatype.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
new file mode 100644
index 0000000000..818f1089ec
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QLocale>
+#include <QPixmap>
+#include <QBitmap>
+#include <QPen>
+#include <QTextLength>
+#include <QMatrix4x4>
+#include <QVector2D>
+#include <QVector3D>
+#include <QVector4D>
+#include <QQuaternion>
+#include <qdeclarative.h>
+
+#include <private/qdeclarativemetatype_p.h>
+
+class tst_qdeclarativemetatype : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativemetatype() {}
+
+private slots:
+ void initTestCase();
+
+ void copy();
+
+ void qmlParserStatusCast();
+ void qmlPropertyValueSourceCast();
+ void qmlPropertyValueInterceptorCast();
+
+ void isList();
+
+ void defaultObject();
+};
+
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo);
+
+ Q_CLASSINFO("DefaultProperty", "foo");
+public:
+ int foo() { return 0; }
+};
+QML_DECLARE_TYPE(TestType);
+
+class ParserStatusTestType : public QObject, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "foo"); // Missing default property
+};
+QML_DECLARE_TYPE(ParserStatusTestType);
+
+class ValueSourceTestType : public QObject, public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativePropertyValueSource)
+public:
+ virtual void setTarget(const QDeclarativeProperty &) {}
+};
+QML_DECLARE_TYPE(ValueSourceTestType);
+
+class ValueInterceptorTestType : public QObject, public QDeclarativePropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativePropertyValueInterceptor)
+public:
+ virtual void setTarget(const QDeclarativeProperty &) {}
+ virtual void write(const QVariant &) {}
+};
+QML_DECLARE_TYPE(ValueInterceptorTestType);
+
+
+#define COPY_TEST(cpptype, metatype, value, defaultvalue) \
+{ \
+ cpptype v = (value); cpptype v2 = (value); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, 0)); \
+ QVERIFY(v == (defaultvalue)); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, &v2)); \
+ QVERIFY(v == (value)); \
+}
+
+#define QT_COPY_TEST(type, value) \
+{ \
+ type v = (value); type v2 = (value); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: type, &v, 0)); \
+ QVERIFY(v == (type ())); \
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: type, &v, &v2)); \
+ QVERIFY(v == (value)); \
+}
+
+void tst_qdeclarativemetatype::initTestCase()
+{
+ QML_REGISTER_TYPE(Test, 1, 0, TestType, TestType);
+ QML_REGISTER_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType);
+ QML_REGISTER_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType);
+ QML_REGISTER_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType);
+}
+
+void tst_qdeclarativemetatype::copy()
+{
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::Void, 0, 0));
+
+ COPY_TEST(bool, Bool, true, false);
+ COPY_TEST(int, Int, 10, 0);
+ COPY_TEST(unsigned int, UInt, 10, 0);
+ COPY_TEST(long long, LongLong, 10, 0);
+ COPY_TEST(unsigned long long, ULongLong, 10, 0);
+ COPY_TEST(double, Double, 19.2, 0);
+
+ QT_COPY_TEST(QChar, QChar('a'));
+
+ QVariantMap variantMap;
+ variantMap.insert("Hello World!", QVariant(10));
+ QT_COPY_TEST(QVariantMap, variantMap);
+
+ QT_COPY_TEST(QVariantList, QVariantList() << QVariant(19.2));
+ QT_COPY_TEST(QString, QString("QML Rocks!"));
+ QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks");
+ QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD"));
+ QT_COPY_TEST(QBitArray, QBitArray(102, true));
+ QDate cd = QDate::currentDate();
+ QT_COPY_TEST(QDate, cd);
+ QTime ct = QTime::currentTime();
+ QT_COPY_TEST(QTime, ct);
+ QDateTime cdt = QDateTime::currentDateTime();
+ QT_COPY_TEST(QDateTime, cdt);
+ QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com"));
+ QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia));
+ QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99));
+ QT_COPY_TEST(QRectF, QRectF(-10.2, 1.2, 102, 99.6));
+ QT_COPY_TEST(QSize, QSize(100, 2));
+ QT_COPY_TEST(QSizeF, QSizeF(20.2, -100234.2));
+ QT_COPY_TEST(QLine, QLine(0, 0, 100, 100));
+ QT_COPY_TEST(QLineF, QLineF(-10.2, 0, 103, 1));
+ QT_COPY_TEST(QPoint, QPoint(-1912, 1613));
+ QT_COPY_TEST(QPointF, QPointF(-908.1, 1612));
+ QT_COPY_TEST(QRegExp, QRegExp("(\\d+)(?:\\s*)(cm|inch)"));
+
+ QVariantHash variantHash;
+ variantHash.insert("Hello World!", QVariant(19));
+ QT_COPY_TEST(QVariantHash, variantHash);
+
+#ifdef QT3_SUPPORT
+ QT_COPY_TEST(QColorGroup, QColorGroup(Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red));
+#endif
+
+ QT_COPY_TEST(QFont, QFont("Helvetica", 1024));
+
+ {
+ QPixmap v = QPixmap(100, 100); QPixmap v2 = QPixmap(100, 100);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QPixmap, &v, 0));
+ QVERIFY(v.size() == QPixmap().size());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QPixmap , &v, &v2));
+ QVERIFY(v.size() == QPixmap(100,100).size());
+ }
+
+ QT_COPY_TEST(QBrush, QBrush(Qt::blue));
+ QT_COPY_TEST(QColor, QColor("lightsteelblue"));
+ QT_COPY_TEST(QPalette, QPalette(Qt::green));
+
+ {
+ QPixmap icon(100, 100);
+
+ QIcon v = QIcon(icon); QIcon v2 = QIcon(icon);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QIcon, &v, 0));
+ QVERIFY(v.isNull() == QIcon().isNull());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QIcon , &v, &v2));
+ QVERIFY(v.isNull() == QIcon(icon).isNull());
+ }
+
+ {
+ QImage v = QImage(100, 100, QImage::Format_RGB32);
+ QImage v2 = QImage(100, 100, QImage::Format_RGB32);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QImage, &v, 0));
+ QVERIFY(v.size() == QImage().size());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QImage , &v, &v2));
+ QVERIFY(v.size() == QImage(100,100, QImage::Format_RGB32).size());
+ }
+
+ QT_COPY_TEST(QPolygon, QPolygon(QRect(100, 100, 200, 103)));
+ QT_COPY_TEST(QRegion, QRegion(QRect(0, 10, 99, 87)));
+
+ {
+ QBitmap v = QBitmap(100, 100); QBitmap v2 = QBitmap(100, 100);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QBitmap, &v, 0));
+ QVERIFY(v.size() == QBitmap().size());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QBitmap , &v, &v2));
+ QVERIFY(v.size() == QBitmap(100,100).size());
+ }
+
+ {
+ QCursor v = QCursor(Qt::SizeFDiagCursor); QCursor v2 = QCursor(Qt::SizeFDiagCursor);
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QCursor, &v, 0));
+ QVERIFY(v.shape() == QCursor().shape());
+ QVERIFY(QDeclarativeMetaType::copy(QMetaType::QCursor , &v, &v2));
+ QVERIFY(v.shape() == QCursor(Qt::SizeFDiagCursor).shape());
+ }
+
+ QT_COPY_TEST(QSizePolicy, QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum));
+ QT_COPY_TEST(QKeySequence, QKeySequence("Ctrl+O"));
+ QT_COPY_TEST(QPen, QPen(Qt::red));
+ QT_COPY_TEST(QTextLength, QTextLength(QTextLength::FixedLength, 10.2));
+ QT_COPY_TEST(QTextFormat, QTextFormat(QTextFormat::ListFormat));
+ QT_COPY_TEST(QMatrix, QMatrix().translate(10, 10));
+ QT_COPY_TEST(QTransform, QTransform().translate(10, 10));
+ QT_COPY_TEST(QMatrix4x4, QMatrix4x4(1,0,2,3,0,1,0,0,9,0,1,0,0,0,10,1));
+ QT_COPY_TEST(QVector2D, QVector2D(10.2, 1));
+ QT_COPY_TEST(QVector3D, QVector3D(10.2, 1, -2));
+ QT_COPY_TEST(QVector4D, QVector4D(10.2, 1, -2, 1.2));
+ QT_COPY_TEST(QQuaternion, QQuaternion(1.0, 10.2, 1, -2));
+
+ int voidValue;
+ COPY_TEST(void *, VoidStar, (void *)&voidValue, (void *)0);
+ COPY_TEST(long, Long, 10, 0);
+ COPY_TEST(short, Short, 10, 0);
+ COPY_TEST(char, Char, 'a', 0);
+ COPY_TEST(unsigned long, ULong, 10, 0);
+ COPY_TEST(unsigned short, UShort, 10, 0);
+ COPY_TEST(unsigned char, UChar, 'a', 0);
+ COPY_TEST(float, Float, 10.5, 0);
+
+ QObject objectValue;
+ QWidget widgetValue;
+ COPY_TEST(QObject *, QObjectStar, &objectValue, 0);
+ COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0);
+ COPY_TEST(qreal, QReal, 10.2, 0);
+
+ {
+ QVariant tv = QVariant::fromValue(QVariant(10));
+ QVariant v(tv); QVariant v2(tv);
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<QVariant>(), &v, 0));
+ QVERIFY(v == QVariant());
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<QVariant>(), &v, &v2));
+ QVERIFY(v == tv);
+ }
+
+ {
+ TestType t; QVariant tv = QVariant::fromValue(&t);
+
+ QVariant v(tv); QVariant v2(tv);
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<TestType *>(), &v, 0));
+ QVERIFY(v == QVariant::fromValue((TestType *)0));
+ QVERIFY(QDeclarativeMetaType::copy(qMetaTypeId<TestType *>(), &v, &v2));
+ QVERIFY(v == tv);
+ }
+}
+
+void tst_qdeclarativemetatype::qmlParserStatusCast()
+{
+ QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
+ QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
+
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ParserStatusTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativeParserStatus *)&t));
+
+ QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(status, &t);
+}
+
+void tst_qdeclarativemetatype::qmlPropertyValueSourceCast()
+{
+ QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
+
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
+ int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ValueSourceTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueSource *)&t));
+
+ QDeclarativePropertyValueSource *source = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(source, &t);
+}
+
+void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast()
+{
+ QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
+
+ QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
+ int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ValueInterceptorTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueInterceptor *)&t));
+
+ QDeclarativePropertyValueInterceptor *interceptor = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(interceptor, &t);
+}
+
+void tst_qdeclarativemetatype::isList()
+{
+ QCOMPARE(QDeclarativeMetaType::isList(QVariant::Invalid), false);
+ QCOMPARE(QDeclarativeMetaType::isList(QVariant::Int), false);
+
+ QDeclarativeListProperty<TestType> list;
+
+ QCOMPARE(QDeclarativeMetaType::isList(qMetaTypeId<QDeclarativeListProperty<TestType> >()), true);
+}
+
+void tst_qdeclarativemetatype::defaultObject()
+{
+ QVERIFY(QDeclarativeMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
+ QVERIFY(QDeclarativeMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
+ QCOMPARE(QString(QDeclarativeMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
+
+ QObject o;
+ TestType t;
+ ParserStatusTestType p;
+
+ QVERIFY(QDeclarativeMetaType::defaultProperty((QObject *)0).name() == 0);
+ QVERIFY(QDeclarativeMetaType::defaultProperty(&o).name() == 0);
+ QVERIFY(QDeclarativeMetaType::defaultProperty(&p).name() == 0);
+ QCOMPARE(QString(QDeclarativeMetaType::defaultProperty(&t).name()), QString("foo"));
+}
+
+QTEST_MAIN(tst_qdeclarativemetatype)
+
+#include "tst_qdeclarativemetatype.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir
new file mode 100644
index 0000000000..0a8b5d46eb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/com/nokia/AutoTestQmlPluginType/qmldir
@@ -0,0 +1 @@
+plugin plugin
diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin.qml b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.qml
index f29ae24ea2..f29ae24ea2 100644
--- a/tests/auto/declarative/qmlmoduleplugin/plugin.qml
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
new file mode 100644
index 0000000000..fd94cc61ec
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QStringList>
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+QML_DECLARE_TYPE(MyPluginType);
+
+
+class MyPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyPlugin()
+ {
+ qWarning("plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
new file mode 100644
index 0000000000..035cb7dcd8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
@@ -0,0 +1,6 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core declarative
+DESTDIR = ../com/nokia/AutoTestQmlPluginType
+
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
new file mode 100644
index 0000000000..96f4454198
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
@@ -0,0 +1,7 @@
+QT = core
+TEMPLATE = subdirs
+SUBDIRS = plugin
+tst_qdeclarativemoduleplugin_pro.depends += plugin
+SUBDIRS += tst_qdeclarativemoduleplugin.pro
+
+
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
new file mode 100644
index 0000000000..f3caa7f23e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <qdir.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QDebug>
+
+class tst_qdeclarativemoduleplugin : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativemoduleplugin() {
+ QCoreApplication::addLibraryPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin"));
+qDebug() << QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin");
+ }
+
+private slots:
+ void importsPlugin();
+};
+
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::ReadOnly)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QDeclarativeError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QDeclarativeError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "" && expected != actual) \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
+ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::WriteOnly)); \
+ for (int ii = 0; ii < actual.count(); ++ii) { \
+ file.write(actual.at(ii)); file.write("\n"); \
+ } \
+ file.close(); \
+ } else { \
+ QCOMPARE(expected, actual); \
+ } \
+ }
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename));
+}
+
+
+void tst_qdeclarativemoduleplugin::importsPlugin()
+{
+ QDeclarativeEngine engine;
+ QTest::ignoreMessage(QtWarningMsg, "plugin created");
+ QTest::ignoreMessage(QtWarningMsg, "import worked");
+ QDeclarativeComponent component(&engine, TEST_FILE("plugin.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+}
+
+QTEST_MAIN(tst_qdeclarativemoduleplugin)
+
+#include "tst_qdeclarativemoduleplugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
new file mode 100644
index 0000000000..d895ed070c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+SOURCES = tst_qdeclarativemoduleplugin.cpp
+QT += declarative
+CONFIG -= app_bundle
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml b/tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml
index 4cd78da4f2..4cd78da4f2 100644
--- a/tests/auto/declarative/qmlgraphicsmousearea/data/dragproperties.qml
+++ b/tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml
diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
new file mode 100644
index 0000000000..d01955be1d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
new file mode 100644
index 0000000000..769cf32d3e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** 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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qdeclarativemousearea_p.h>
+#include <QtDeclarative/qdeclarativeview.h>
+
+class tst_QDeclarativeMouseArea: public QObject
+{
+ Q_OBJECT
+private slots:
+ void dragProperties();
+private:
+ QDeclarativeView *createView(const QString &filename);
+};
+
+void tst_QDeclarativeMouseArea::dragProperties()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/dragproperties.qml");
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarativeMouseArea*>("mouseregion");
+ QDeclarativeDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ QCOMPARE(drag->axis(), QDeclarativeDrag::XandYAxis);
+ QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
+ drag->setAxis(QDeclarativeDrag::XAxis);
+ QCOMPARE(drag->axis(), QDeclarativeDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ drag->setAxis(QDeclarativeDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum properties
+ QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(drag->xmin(), 0.0);
+ QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(drag->ymin(), 0.0);
+ QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(drag->xmin(), 10.0);
+ QCOMPARE(drag->xmax(), 10.0);
+ QCOMPARE(drag->ymin(), 10.0);
+ QCOMPARE(drag->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+}
+
+QDeclarativeView *tst_QDeclarativeMouseArea::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QDeclarativeMouseArea)
+
+#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro b/tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro
new file mode 100644
index 0000000000..672e95c8e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativenumberformatter/qdeclarativenumberformatter.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativenumberformatter.cpp
diff --git a/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp b/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp
new file mode 100644
index 0000000000..26ff3d5509
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDebug>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qnumberformat_p.h>
+#include <private/qdeclarativenumberformatter_p.h>
+
+class tst_qdeclarativenumberformatter : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativenumberformatter();
+
+ void init() {}
+ void initTestCase() {}
+
+ void cleanup() {}
+ void cleanupTestCase() {}
+
+private slots:
+ void text_data();
+ void text();
+
+private:
+ QStringList strings;
+ QStringList formats;
+ QStringList texts;
+};
+
+tst_qdeclarativenumberformatter::tst_qdeclarativenumberformatter()
+{
+ strings << "100.0"
+ << "12345"
+ << "1234567"
+ << "0.123"
+ << "0.9999"
+ << "0.989"
+ << "1"
+ << "1.0"
+ << "1.01";
+
+ formats << ""
+ << "0000"
+ << "0000.00"
+ << "##"
+ << "##.##"
+ << "#0.00#"
+ << "##,##0.##"
+ << "(000) 000 - 000"
+ << "00000,000.0000";
+
+ //US locale only.
+ texts << "100.000000"
+ << "12345.000000"
+ << "1234567.000000"
+ << "0.123000"
+ << "0.999900"
+ << "0.989000"
+ << "1.000000"
+ << "1.000000"
+ << "1.010000" //end ""
+ << "0100"
+ << "12345"
+ << "1234567"
+ << "0000"
+ << "0001"
+ << "0001"
+ << "0001"
+ << "0001"
+ << "0001" // end "0000"
+ << "0100.00"
+ << "12345.00"
+ << "1234567.00"
+ << "0000.12"
+ << "0001.00"
+ << "0000.99"
+ << "0001.00"
+ << "0001.00"
+ << "0001.01" // end "0000.00"
+ << "100"
+ << "12345"
+ << "1234567"
+ << "0"
+ << "1"
+ << "1"
+ << "1"
+ << "1"
+ << "1" // end "##"
+ << "100"//start "##.##"
+ << "12345"
+ << "1234567"
+ << "0.12"
+ << "1"
+ << "0.99"
+ << "1"
+ << "1"
+ << "1.01" // end "##.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
+ << "100.00" //start "#0.00#"
+ << "12345.00"
+ << "1234567.00"
+ << "0.123"
+ << "1.00"
+ << "0.989"
+ << "1.00"
+ << "1.00"
+ << "1.01" //end "#0.00#"
+ << "100" //start "##,##0.##"
+ << "12,345"
+ << "1,234,567"
+ << "0.12"
+ << "1"
+ << "0.99"
+ << "1"
+ << "1"
+ << "1.01" //end "##,##0.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
+ << "(000) 000 - 100" //start "(000) 000 - 000"
+ << "(000) 012 - 345"
+ << "(001) 234 - 567"
+ << "(000) 000 - 000"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001"
+ << "(000) 000 - 001" // end "(000) 000 - 000"
+ << "00,000,100.0000" // start "00000,000.0000"
+ << "00,012,345.0000"
+ << "01,234,567.0000"
+ << "00,000,000.1230"
+ << "00,000,000.9999"
+ << "00,000,000.9890"
+ << "00,000,001.0000"
+ << "00,000,001.0000"
+ << "00,000,001.0100"; // end
+
+ qDebug() << "strings.size()" << strings.size()
+ << "\nformats.size()" << formats.size()
+ << "texts.size()" << texts.size();
+}
+
+void tst_qdeclarativenumberformatter::text_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QString>("text");
+
+ for (int j=0; j < formats.size(); j++)
+ {
+ for (int i=0; i < strings.size(); i++)
+ {
+ QTest::newRow(QString("%1, %2").arg(strings.at(i)).arg(formats.at(j)).toAscii())
+ << strings.at(i) << formats.at(j) << texts.at(j*formats.size()+i);
+ }
+ }
+
+}
+
+void tst_qdeclarativenumberformatter::text()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, format);
+ QFETCH(QString, text);
+
+ QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: ") + string + QString("; format: \"") + format + QString("\" }");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent formatterComponent(&engine);
+ formatterComponent.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatterComponent.isReady());
+ QDeclarativeNumberFormatter *formatter = qobject_cast<QDeclarativeNumberFormatter*>(formatterComponent.create());
+ QVERIFY(formatter != 0);
+
+ QCOMPARE(formatter->format(), format);
+ QCOMPARE(formatter->text(), text);
+
+ delete formatter;
+}
+
+QTEST_MAIN(tst_qdeclarativenumberformatter)
+
+#include "tst_qdeclarativenumberformatter.moc"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particle.png b/tests/auto/declarative/qdeclarativeparticles/data/particle.png
index defbde53ca..defbde53ca 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/data/particle.png
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particle.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
new file mode 100644
index 0000000000..ace61fe07b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+Rectangle {
+ width: 240
+ height: 320
+ color: "black"
+ Particles {
+ objectName: "particles"
+ anchors.fill: parent
+ width: 1
+ height: 1
+ source: "particle.png"
+ lifeSpan: 5000
+ count: 200
+ angle: 270
+ angleDeviation: 45
+ velocity: 50
+ velocityDeviation: 30
+ ParticleMotionGravity {
+ objectName: "motionGravity"
+ yattractor: 1000
+ xattractor: 0
+ acceleration: 25
+ }
+ }
+ resources: [
+ ParticleMotionWander {
+ objectName: "motionWander"
+ xvariance: 30
+ yvariance: 30
+ pace: 100
+ }
+ ]
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
index c58927e05d..c58927e05d 100644
--- a/tests/auto/declarative/qmlgraphicsparticles/data/particles.qml
+++ b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml
diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
new file mode 100644
index 0000000000..043bb85408
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeparticles.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
new file mode 100644
index 0000000000..6090a07b8d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativeparticles_p.h>
+
+class tst_QDeclarativeParticles : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeParticles();
+
+private slots:
+ void properties();
+ void motionGravity();
+ void motionWander();
+ void runs();
+private:
+ QDeclarativeView *createView(const QString &filename);
+
+};
+
+tst_QDeclarativeParticles::tst_QDeclarativeParticles()
+{
+}
+
+void tst_QDeclarativeParticles::properties()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+
+ particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
+ QCOMPARE(particles->source(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
+
+ particles->setLifeSpanDeviation(1000);
+ QCOMPARE(particles->lifeSpanDeviation(), 1000);
+
+ particles->setFadeInDuration(1000);
+ QCOMPARE(particles->fadeInDuration(), 1000);
+
+ particles->setFadeOutDuration(1000);
+ QCOMPARE(particles->fadeOutDuration(), 1000);
+
+ particles->setAngle(100.0);
+ QCOMPARE(particles->angle(), 100.0);
+
+ particles->setAngleDeviation(100.0);
+ QCOMPARE(particles->angleDeviation(), 100.0);
+
+ particles->setVelocity(100.0);
+ QCOMPARE(particles->velocity(), 100.0);
+
+ particles->setVelocityDeviation(100.0);
+ QCOMPARE(particles->velocityDeviation(), 100.0);
+
+ particles->setEmissionVariance(0.5);
+ QCOMPARE(particles->emissionVariance(),0.5);
+
+ particles->setEmissionRate(12);
+ QCOMPARE(particles->emissionRate(), 12);
+}
+
+void tst_QDeclarativeParticles::motionGravity()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+
+ QDeclarativeParticleMotionGravity* motionGravity = canvas->rootObject()->findChild<QDeclarativeParticleMotionGravity*>("motionGravity");
+ QCOMPARE(particles->motion(), motionGravity);
+
+ QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged()));
+ QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged()));
+ QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged()));
+
+ QCOMPARE(motionGravity->xAttractor(), 0.0);
+ QCOMPARE(motionGravity->yAttractor(), 1000.0);
+ QCOMPARE(motionGravity->acceleration(), 25.0);
+
+ motionGravity->setXAttractor(20.0);
+ motionGravity->setYAttractor(10.0);
+ motionGravity->setAcceleration(10.0);
+
+ QCOMPARE(motionGravity->xAttractor(), 20.0);
+ QCOMPARE(motionGravity->yAttractor(), 10.0);
+ QCOMPARE(motionGravity->acceleration(), 10.0);
+
+ QCOMPARE(xattractorSpy.count(), 1);
+ QCOMPARE(yattractorSpy.count(), 1);
+ QCOMPARE(accelerationSpy.count(), 1);
+
+ motionGravity->setXAttractor(20.0);
+ motionGravity->setYAttractor(10.0);
+ motionGravity->setAcceleration(10.0);
+
+ QCOMPARE(xattractorSpy.count(), 1);
+ QCOMPARE(yattractorSpy.count(), 1);
+ QCOMPARE(accelerationSpy.count(), 1);
+}
+
+void tst_QDeclarativeParticles::motionWander()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+
+ QSignalSpy motionSpy(particles, SIGNAL(motionChanged()));
+ QDeclarativeParticleMotionWander* motionWander = canvas->rootObject()->findChild<QDeclarativeParticleMotionWander*>("motionWander");
+
+ particles->setMotion(motionWander);
+ QCOMPARE(particles->motion(),motionWander);
+ QCOMPARE(motionSpy.count(), 1);
+
+ particles->setMotion(motionWander);
+ QCOMPARE(motionSpy.count(), 1);
+
+ QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged()));
+ QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged()));
+ QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged()));
+
+ QCOMPARE(motionWander->xVariance(), 30.0);
+ QCOMPARE(motionWander->yVariance(), 30.0);
+ QCOMPARE(motionWander->pace(), 100.0);
+
+ motionWander->setXVariance(20.0);
+ motionWander->setYVariance(10.0);
+ motionWander->setPace(10.0);
+
+ QCOMPARE(motionWander->xVariance(), 20.0);
+ QCOMPARE(motionWander->yVariance(), 10.0);
+ QCOMPARE(motionWander->pace(), 10.0);
+
+ QCOMPARE(xvarianceSpy.count(), 1);
+ QCOMPARE(yvarianceSpy.count(), 1);
+ QCOMPARE(paceSpy.count(), 1);
+
+ motionWander->setXVariance(20.0);
+ motionWander->setYVariance(10.0);
+ motionWander->setPace(10.0);
+
+ QCOMPARE(xvarianceSpy.count(), 1);
+ QCOMPARE(yvarianceSpy.count(), 1);
+ QCOMPARE(paceSpy.count(), 1);
+}
+
+void tst_QDeclarativeParticles::runs()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml");
+ QVERIFY(canvas->rootObject());
+ QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles");
+ QVERIFY(particles);
+ QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
+}
+
+QDeclarativeView *tst_QDeclarativeParticles::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+QTEST_MAIN(tst_QDeclarativeParticles)
+
+#include "tst_qdeclarativeparticles.moc"
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
index 8d07db2a53..8d07db2a53 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
new file mode 100644
index 0000000000..627f38ab64
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: delegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 60
+ color: "white"
+ border.color: "black"
+ Text {
+ text: index
+ }
+ Text {
+ x: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ }
+ }
+ ]
+ PathView {
+ id: view
+ objectName: "view"
+ width: 240
+ height: 320
+ model: testModel
+ delegate: delegate
+ snapPosition: 0.01
+ path: Path {
+ startY: 120
+ startX: 160
+ PathQuad {
+ y: 120
+ x: 80
+ controlY: 330
+ controlX: 100
+ }
+ PathLine {
+ y: 160
+ x: 20
+ }
+ PathCubic {
+ y: 120
+ x: 160
+ control1Y: 0
+ control1X: 100
+ control2Y: 000
+ control2X: 200
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/path.qml b/tests/auto/declarative/qdeclarativepathview/data/path.qml
index 7e82a4814c..7e82a4814c 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/path.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/path.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
index 8fa8d59d55..8fa8d59d55 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview1.qml
index b3b0a9ae43..b3b0a9ae43 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview1.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml
index 0d5c98be7f..0d5c98be7f 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
index 412cca24d7..412cca24d7 100644
--- a/tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml
diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
new file mode 100644
index 0000000000..2f6ae3253d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativepathview.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
new file mode 100644
index 0000000000..79bc6079a2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -0,0 +1,529 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <private/qdeclarativepathview_p.h>
+#include <private/qdeclarativepath_p.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarativeexpression.h>
+#include <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/private/qdeclarativetext_p.h>
+#include <QtDeclarative/private/qdeclarativerectangle_p.h>
+#include <QAbstractListModel>
+#include <QStringListModel>
+#include <QFile>
+#include <private/qdeclarativevaluetype_p.h>
+#include "../../../shared/util.h"
+
+class tst_QDeclarativePathView : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativePathView();
+
+private slots:
+ void initValues();
+ void items();
+ void dataModel();
+ void pathview2();
+ void pathview3();
+ void path();
+ void pathMoved();
+ void resetModel();
+
+private:
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1);
+ template<typename T>
+ QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError)
+ Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
+ Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
+
+public:
+ TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; }
+
+ bool useModel() const { return mUseModel; }
+ void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
+
+ int pathItemCount() const { return mPathItemCount; }
+ void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
+
+signals:
+ void useModelChanged();
+ void pathItemCountChanged();
+
+private:
+ bool mError;
+ bool mUseModel;
+ int mPathItemCount;
+};
+
+class TestModel : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+ }
+
+ int count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+tst_QDeclarativePathView::tst_QDeclarativePathView()
+{
+}
+
+void tst_QDeclarativePathView::initValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml"));
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() == 0);
+ QVERIFY(obj->delegate() == 0);
+ QCOMPARE(obj->model(), QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 0.);
+ QCOMPARE(obj->snapPosition(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 0);
+ QCOMPARE(obj->pathItemCount(), -1);
+}
+
+void tst_QDeclarativePathView::items()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
+
+ for (int i = 0; i < model.count(); ++i) {
+ QDeclarativeText *name = findItem<QDeclarativeText>(pathview, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QDeclarativeText *number = findItem<QDeclarativeText>(pathview, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::pathview2()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml"));
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 0.);
+ QCOMPARE(obj->snapPosition(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 10);
+}
+
+void tst_QDeclarativePathView::pathview3()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml"));
+ QDeclarativePathView *obj = qobject_cast<QDeclarativePathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 50.); // ???
+ QCOMPARE(obj->snapPosition(), 0.5); // ???
+ QCOMPARE(obj->dragMargin(), 24.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 4);
+}
+
+void tst_QDeclarativePathView::path()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/path.qml"));
+ QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->startX(), 120.);
+ QCOMPARE(obj->startY(), 100.);
+ QVERIFY(obj->path() != QPainterPath());
+
+ QDeclarativeListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 5);
+
+ QDeclarativePathAttribute* attr = qobject_cast<QDeclarativePathAttribute*>(list.at(0));
+ QVERIFY(attr != 0);
+ QCOMPARE(attr->name(), QString("scale"));
+ QCOMPARE(attr->value(), 1.0);
+
+ QDeclarativePathQuad* quad = qobject_cast<QDeclarativePathQuad*>(list.at(1));
+ QVERIFY(quad != 0);
+ QCOMPARE(quad->x(), 120.);
+ QCOMPARE(quad->y(), 25.);
+ QCOMPARE(quad->controlX(), 260.);
+ QCOMPARE(quad->controlY(), 75.);
+
+ QDeclarativePathPercent* perc = qobject_cast<QDeclarativePathPercent*>(list.at(2));
+ QVERIFY(perc != 0);
+ QCOMPARE(perc->value(), 0.3);
+
+ QDeclarativePathLine* line = qobject_cast<QDeclarativePathLine*>(list.at(3));
+ QVERIFY(line != 0);
+ QCOMPARE(line->x(), 120.);
+ QCOMPARE(line->y(), 100.);
+
+ QDeclarativePathCubic* cubic = qobject_cast<QDeclarativePathCubic*>(list.at(4));
+ QVERIFY(cubic != 0);
+ QCOMPARE(cubic->x(), 180.);
+ QCOMPARE(cubic->y(), 0.);
+ QCOMPARE(cubic->control1X(), -10.);
+ QCOMPARE(cubic->control1Y(), 90.);
+ QCOMPARE(cubic->control2X(), 210.);
+ QCOMPARE(cubic->control2Y(), 90.);
+}
+
+void tst_QDeclarativePathView::dataModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ TestModel model;
+ model.addItem("red", "1");
+ model.addItem("green", "2");
+ model.addItem("blue", "3");
+ model.addItem("purple", "4");
+ model.addItem("gray", "5");
+ model.addItem("brown", "6");
+ model.addItem("yellow", "7");
+ model.addItem("thistle", "8");
+ model.addItem("cyan", "9");
+
+ ctxt->setContextProperty("testData", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/datamodel.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(pathview, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), 110.0);
+ QCOMPARE(item->y(), 10.0);
+
+ model.insertItem(4, "orange", "10");
+
+ int itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 10);
+
+ QDeclarativeText *text = findItem<QDeclarativeText>(pathview, "myText", 4);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(4));
+
+ model.removeItem(2);
+ text = findItem<QDeclarativeText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+
+ testObject->setPathItemCount(5);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ QDeclarativeRectangle *testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 4);
+ QVERIFY(testItem != 0);
+ testItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 5);
+ QVERIFY(testItem == 0);
+
+ model.insertItem(2, "pink", "2");
+
+ itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ text = findItem<QDeclarativeText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+
+ model.removeItem(3);
+ itemCount = findItems<QDeclarativeItem>(pathview, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+ text = findItem<QDeclarativeText>(pathview, "myText", 3);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(3));
+
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::pathMoved()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QDeclarativeRectangle *firstItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QCOMPARE(firstItem->pos() + offset, start);
+ pathview->setOffset(10);
+ QTest::qWait(1000);//Moving is animated?
+
+ for(int i=0; i<model.count(); i++){
+ QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i);
+ QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
+ }
+
+ pathview->setOffset(100);
+ QTest::qWait(1000);//Moving is animated?
+ QCOMPARE(firstItem->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QDeclarativePathView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+
+QDeclarativeView *tst_QDeclarativePathView::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+/*
+ Find an item with the specified objectName. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+ */
+template<typename T>
+T *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->childItems().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QDeclarativeExpression e(qmlContext(item), "index", item);
+ if (e.value().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+template<typename T>
+QList<T*> tst_QDeclarativePathView::findItems(QGraphicsObject *parent, const QString &objectName)
+{
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+}
+
+QTEST_MAIN(tst_QDeclarativePathView)
+
+#include "tst_qdeclarativepathview.moc"
diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists.png b/tests/auto/declarative/qdeclarativepixmapcache/data/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/declarative/qmlpixmapcache/data/exists.png
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/exists.png
Binary files differ
diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists1.png b/tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/declarative/qmlpixmapcache/data/exists1.png
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/exists1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists2.png b/tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/declarative/qmlpixmapcache/data/exists2.png
+++ b/tests/auto/declarative/qdeclarativepixmapcache/data/exists2.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
new file mode 100644
index 0000000000..899c43fe52
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativepixmapcache.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
new file mode 100644
index 0000000000..223f54fc85
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
@@ -0,0 +1,282 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/QtTest>
+#include <private/qdeclarativepixmapcache_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QNetworkReply>
+
+// These don't let normal people run tests!
+//#include "../network-settings.h"
+
+class tst_qdeclarativepixmapcache : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativepixmapcache() :
+ thisfile(QUrl::fromLocalFile(__FILE__))
+ {
+ }
+
+private slots:
+ void single();
+ void single_data();
+ void parallel();
+ void parallel_data();
+
+private:
+ QDeclarativeEngine engine;
+ QUrl thisfile;
+};
+
+
+static int slotters=0;
+
+class Slotter : public QObject
+{
+ Q_OBJECT
+public:
+ Slotter()
+ {
+ gotslot = false;
+ slotters++;
+ }
+ bool gotslot;
+
+public slots:
+ void got()
+ {
+ gotslot = true;
+ --slotters;
+ if (slotters==0)
+ QTestEventLoop::instance().exitLoop();
+ }
+};
+
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+static const bool localfile_optimized = true;
+#else
+static const bool localfile_optimized = false;
+#endif
+
+void tst_qdeclarativepixmapcache::single_data()
+{
+ // Note, since QDeclarativePixmapCache is shared, tests affect each other!
+ // so use different files fore all test functions.
+
+ QTest::addColumn<QUrl>("target");
+ QTest::addColumn<bool>("incache");
+ QTest::addColumn<bool>("exists");
+ QTest::addColumn<bool>("neterror");
+
+ // File URLs are optimized
+ QTest::newRow("local") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false;
+ QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false;
+ QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false;
+ QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true;
+}
+
+void tst_qdeclarativepixmapcache::single()
+{
+ QFETCH(QUrl, target);
+ QFETCH(bool, incache);
+ QFETCH(bool, exists);
+ QFETCH(bool, neterror);
+
+ if (neterror) {
+ QString expected = "\"Error downloading " + target.toString() + " - server replied: Not Found\" ";
+ QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
+ } else if (!exists) {
+ QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) ";
+ QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
+ }
+
+ QPixmap pixmap;
+ QVERIFY(pixmap.width() <= 0); // Check Qt assumption
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap);
+
+ if (incache) {
+ if (exists) {
+ QVERIFY(status == QDeclarativePixmapReply::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(status == QDeclarativePixmapReply::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ } else {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(&engine, target);
+ QVERIFY(reply);
+ QVERIFY(pixmap.width() <= 0);
+
+ Slotter getter;
+ connect(reply, SIGNAL(finished()), &getter, SLOT(got()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(getter.gotslot);
+ if (exists) {
+ QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ }
+
+ QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0);
+}
+
+void tst_qdeclarativepixmapcache::parallel_data()
+{
+ // Note, since QDeclarativePixmapCache is shared, tests affect each other!
+ // so use different files fore all test functions.
+
+ QTest::addColumn<QUrl>("target1");
+ QTest::addColumn<QUrl>("target2");
+ QTest::addColumn<int>("incache");
+ QTest::addColumn<int>("cancel"); // which one to cancel
+ QTest::addColumn<int>("requests");
+
+ QTest::newRow("local")
+ << thisfile.resolved(QUrl("data/exists1.png"))
+ << thisfile.resolved(QUrl("data/exists2.png"))
+ << (localfile_optimized ? 2 : 0)
+ << -1
+ << (localfile_optimized ? 0 : 2)
+ ;
+
+ QTest::newRow("remote")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
+ << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
+ << 0
+ << -1
+ << 2
+ ;
+
+ QTest::newRow("remoteagain")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
+ << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
+ << 2
+ << -1
+ << 0
+ ;
+
+ QTest::newRow("remotecopy")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
+ << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
+ << 0
+ << -1
+ << 1
+ ;
+
+ QTest::newRow("remotecopycancel")
+ << QUrl("http://qt.nokia.com/rounded_block_bg.png")
+ << QUrl("http://qt.nokia.com/rounded_block_bg.png")
+ << 0
+ << 0
+ << 1
+ ;
+}
+
+void tst_qdeclarativepixmapcache::parallel()
+{
+ QFETCH(QUrl, target1);
+ QFETCH(QUrl, target2);
+ QFETCH(int, incache);
+ QFETCH(int, cancel);
+ QFETCH(int, requests);
+
+ QList<QUrl> targets;
+ targets << target1 << target2;
+
+ QList<QDeclarativePixmapReply*> replies;
+ QList<Slotter*> getters;
+ for (int i=0; i<targets.count(); ++i) {
+ QUrl target = targets.at(i);
+ QPixmap pixmap;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap);
+ QDeclarativePixmapReply *reply = 0;
+ if (status != QDeclarativePixmapReply::Error && status != QDeclarativePixmapReply::Ready)
+ reply = QDeclarativePixmapCache::request(&engine, target);
+ replies.append(reply);
+ if (!reply) {
+ QVERIFY(pixmap.width() > 0);
+ getters.append(0);
+ } else {
+ QVERIFY(pixmap.width() <= 0);
+ getters.append(new Slotter);
+ connect(reply, SIGNAL(finished()), getters[i], SLOT(got()));
+ }
+ }
+
+ QCOMPARE(incache+slotters, targets.count());
+ QCOMPARE(QDeclarativePixmapCache::pendingRequests(), requests);
+
+ if (cancel >= 0) {
+ QDeclarativePixmapCache::cancel(targets.at(cancel), getters[cancel]);
+ slotters--;
+ }
+
+ if (slotters) {
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+
+ for (int i=0; i<targets.count(); ++i) {
+ QDeclarativePixmapReply *reply = replies[i];
+ if (reply) {
+ if (i == cancel) {
+ QVERIFY(!getters[i]->gotslot);
+ } else {
+ QVERIFY(getters[i]->gotslot);
+ QPixmap pixmap;
+ QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap) == QDeclarativePixmapReply::Ready);
+ QVERIFY(pixmap.width() > 0);
+ }
+ delete getters[i];
+ }
+ }
+
+ QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0);
+}
+
+QTEST_MAIN(tst_qdeclarativepixmapcache)
+
+#include "tst_qdeclarativepixmapcache.moc"
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml
index f6376a153e..f6376a153e 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml
index 5b4a30dfd9..5b4a30dfd9 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-spacing.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid.qml
index 830df6acd0..830df6acd0 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/grid.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/grid.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml
index c113a367bc..c113a367bc 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml
index 32bf775588..32bf775588 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-spacing.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal.qml b/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml
index 06ae151494..06ae151494 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml
diff --git a/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml
new file mode 100644
index 0000000000..4370a1825e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Grid {
+ id: myGrid
+
+ width: 270
+ height: 270
+ x: 3
+ y: 3
+ columns: 4
+ spacing: 3
+
+ add: columnTransition
+ move: columnTransition
+
+ Repeater {
+ model: 20
+ Rectangle { color: "black"; width: 50; height: 50 }
+ }
+
+ data: [
+ Transition {
+ id: rowTransition
+ objectName: "rowTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing.type: "OutInCubic"
+ }
+ },
+ Transition {
+ id: columnTransition
+ objectName: "columnTransition"
+ NumberAnimation {
+ properties: "x,y";
+ easing.type: "OutInCubic"
+ }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/repeater.qml b/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml
index 2bc5e94775..2bc5e94775 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/repeater.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml
index 10f6cbb3d1..10f6cbb3d1 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-spacing.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml
index 69a8256c39..69a8256c39 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-spacing.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml
diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical.qml b/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml
index 856c180a45..856c180a45 100644
--- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml
diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
new file mode 100644
index 0000000000..5edfa55292
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativepositioners.cpp
+macx:CONFIG -= app_bundle
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
new file mode 100644
index 0000000000..3a8a892e4e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -0,0 +1,455 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+#include <private/qlistmodelinterface_p.h>
+#include <qdeclarativeview.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativepositioners_p.h>
+#include <private/qdeclarativetransition_p.h>
+#include <qdeclarativeexpression.h>
+#include "../../../shared/util.h"
+
+class tst_QDeclarativePositioners : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativePositioners();
+
+private slots:
+ void test_horizontal();
+ void test_horizontal_spacing();
+ void test_horizontal_animated();
+ void test_vertical();
+ void test_vertical_spacing();
+ void test_vertical_animated();
+ void test_grid();
+ void test_grid_spacing();
+ void test_grid_animated();
+ void test_propertychanges();
+ void test_repeater();
+private:
+ QDeclarativeView *createView(const QString &filename);
+};
+
+tst_QDeclarativePositioners::tst_QDeclarativePositioners()
+{
+}
+
+void tst_QDeclarativePositioners::test_horizontal()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+}
+
+void tst_QDeclarativePositioners::test_horizontal_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 60.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+}
+
+void tst_QDeclarativePositioners::test_horizontal_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setOpacity(1.0);
+ QCOMPARE(two->opacity(), 1.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), 50.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+}
+
+void tst_QDeclarativePositioners::test_vertical()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+}
+
+void tst_QDeclarativePositioners::test_vertical_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 60.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 80.0);
+}
+
+void tst_QDeclarativePositioners::test_vertical_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
+
+ //Note that they animate in
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->y(), -100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 50.0);
+ QTRY_COMPARE(three->x(), 0.0);
+
+ //Add 'two'
+ two->setOpacity(1.0);
+ QTRY_COMPARE(two->opacity(), 1.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(three->y(), 50.0);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
+
+}
+
+void tst_QDeclarativePositioners::test_grid()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+}
+
+void tst_QDeclarativePositioners::test_grid_spacing()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four");
+ QVERIFY(four != 0);
+ QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 54.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 78.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 54.0);
+ QCOMPARE(five->x(), 54.0);
+ QCOMPARE(five->y(), 54.0);
+}
+
+void tst_QDeclarativePositioners::test_grid_animated()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml");
+
+ //Note that all animate in
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QDeclarativeRectangle *four = canvas->rootObject()->findChild<QDeclarativeRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QDeclarativeRectangle *five = canvas->rootObject()->findChild<QDeclarativeRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->opacity(), 0.0);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 0.0);
+
+ //Add 'two'
+ two->setOpacity(1.0);
+ QCOMPARE(two->opacity(), 1.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 0.0);
+ QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+}
+void tst_QDeclarativePositioners::test_propertychanges()
+{
+ QDeclarativeView *canvas = createView("data/propertychanges.qml");
+
+ QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(canvas->rootObject());
+ QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("rowTransition");
+ QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("columnTransition");
+
+ QSignalSpy addSpy(grid, SIGNAL(addChanged()));
+ QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
+ QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
+ QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
+
+ QVERIFY(grid);
+ QVERIFY(rowTransition);
+ QVERIFY(columnTransition);
+ QCOMPARE(grid->add(), columnTransition);
+ QCOMPARE(grid->move(), columnTransition);
+ QCOMPARE(grid->columns(), 4);
+ QCOMPARE(grid->rows(), -1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(grid->add(), rowTransition);
+ QCOMPARE(grid->move(), rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(0);
+ grid->setMove(0);
+ QCOMPARE(addSpy.count(),2);
+ QCOMPARE(moveSpy.count(),2);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(grid->columns(), -1);
+ QCOMPARE(grid->rows(), 3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(2);
+ grid->setRows(2);
+ QCOMPARE(columnsSpy.count(),2);
+ QCOMPARE(rowsSpy.count(),2);
+}
+
+void tst_QDeclarativePositioners::test_repeater()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/repeater.qml");
+
+ QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QDeclarativeRectangle *two = canvas->rootObject()->findChild<QDeclarativeRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QDeclarativeRectangle *three = canvas->rootObject()->findChild<QDeclarativeRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+}
+
+QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+
+QTEST_MAIN(tst_QDeclarativePositioners)
+
+#include "tst_qdeclarativepositioners.moc"
diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
new file mode 100644
index 0000000000..22e50cc558
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativeproperty.cpp
diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
new file mode 100644
index 0000000000..0333d98295
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
@@ -0,0 +1,1322 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
+#include <QtDeclarative/private/qdeclarativeproperty_p.h>
+#include <private/qguard_p.h>
+#include <private/qdeclarativebinding_p.h>
+#include <QtGui/QLineEdit>
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyQmlObject() {}
+};
+
+QML_DECLARE_TYPE(MyQmlObject);
+
+class MyAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+public:
+ MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
+
+ int foo() const { return m_foo; }
+ void setFoo(int f) { m_foo = f; }
+
+private:
+ int m_foo;
+};
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children)
+public:
+ MyContainer() {}
+
+ QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
+
+ static MyAttached *qmlAttachedProperties(QObject *o) {
+ return new MyAttached(o);
+ }
+
+private:
+ QList<MyQmlObject*> m_children;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
+
+class tst_qdeclarativeproperty : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeproperty() {}
+
+private slots:
+ void initTestCase();
+
+ // Constructors
+ void qmlmetaproperty();
+ void qmlmetaproperty_object();
+ void qmlmetaproperty_object_string();
+ void qmlmetaproperty_object_context();
+ void qmlmetaproperty_object_string_context();
+
+ // Methods
+ void name();
+ void read();
+ void write();
+ void reset();
+
+ // Functionality
+ void writeObjectToList();
+ void writeListToList();
+
+ //writeToReadOnly();
+
+ // Bugs
+ void crashOnValueProperty();
+
+ void copy();
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativeproperty::qmlmetaproperty()
+{
+ QDeclarativeProperty prop;
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+}
+
+class PropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int defaultProperty READ defaultProperty);
+ Q_PROPERTY(QRect rectProperty READ rectProperty);
+ Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty);
+ Q_PROPERTY(QUrl url READ url WRITE setUrl);
+ Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty);
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+
+ Q_CLASSINFO("DefaultProperty", "defaultProperty");
+public:
+ PropertyObject() : m_resetProperty(9) {}
+
+ int defaultProperty() { return 10; }
+ QRect rectProperty() { return QRect(10, 10, 1, 209); }
+
+ QRect wrectProperty() { return m_rect; }
+ void setWRectProperty(const QRect &r) { m_rect = r; }
+
+ QUrl url() { return m_url; }
+ void setUrl(const QUrl &u) { m_url = u; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int r) { m_resetProperty = r; }
+ void resetProperty() { m_resetProperty = 9; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+
+signals:
+ void clicked();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_resetProperty;
+ QRect m_rect;
+ QUrl m_url;
+ int m_propertyWithNotify;
+};
+
+QML_DECLARE_TYPE(PropertyObject);
+
+void tst_qdeclarativeproperty::qmlmetaproperty_object()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QDeclarativeProperty prop(&object);
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject);
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativeproperty::qmlmetaproperty_object_string()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QDeclarativeProperty prop(&object, QString("defaultProperty"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("defaultProperty"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onClicked"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativeproperty::qmlmetaproperty_object_context()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QDeclarativeProperty prop(&object, engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QDeclarativeProperty prop(&object, QString("defaultProperty"), engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QDeclarativeProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onClicked"), engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
+
+ QGuard<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding->setTarget(prop);
+ QVERIFY(binding != 0);
+ QGuard<QDeclarativeExpression> expression(new QDeclarativeExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), &dobject);
+ QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
+ QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qdeclarativeproperty::name()
+{
+ {
+ QDeclarativeProperty p;
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.name(), QString("defaultProperty"));
+ }
+
+ {
+ QObject o;
+ QDeclarativeProperty p(&o, QString("objectName"));
+ QCOMPARE(p.name(), QString("objectName"));
+ }
+
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString("onClicked"));
+ }
+
+ {
+ QObject o;
+ QDeclarativeProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal"));
+ }
+
+ {
+ QObject o;
+ QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QObject o;
+ QDeclarativeProperty p(&o, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QDeclarativeProperty p(0, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "rectProperty");
+ QCOMPARE(p.name(), QString("rectProperty"));
+ }
+
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "rectProperty.x");
+ QCOMPARE(p.name(), QString("rectProperty.x"));
+ }
+
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "rectProperty.foo");
+ QCOMPARE(p.name(), QString());
+ }
+}
+
+void tst_qdeclarativeproperty::read()
+{
+ // Invalid
+ {
+ QDeclarativeProperty p;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Default prop
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Value prop by name
+ {
+ QObject o;
+
+ QDeclarativeProperty p(&o, "objectName");
+ QCOMPARE(p.read(), QVariant(QString()));
+
+ o.setObjectName("myName");
+
+ QCOMPARE(p.read(), QVariant("myName"));
+ }
+
+ // Value-type prop
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid value-type prop
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "rectProperty.foo");
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onClicked");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
+ QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
+ QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QDeclarativeProperty p(o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ delete o;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Attached property
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(13));
+ delete object;
+ }
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(10));
+ delete object;
+ }
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(10));
+ delete object;
+ }
+}
+
+void tst_qdeclarativeproperty::write()
+{
+ // Invalid
+ {
+ QDeclarativeProperty p;
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only prop by name
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Writable prop by name
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, QString("objectName"));
+ QCOMPARE(o.objectName(), QString());
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o.objectName(), QString("myName"));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QDeclarativeProperty p(o, QString("objectName"));
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o->objectName(), QString("myName"));
+
+ delete o;
+
+ QCOMPARE(p.write(QVariant(QString("myName"))), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onClicked");
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
+ QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
+ QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
+ }
+
+ // Value-type property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "wrectProperty");
+
+ QCOMPARE(o.wrectProperty(), QRect());
+ QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
+ QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
+
+ QDeclarativeProperty p2(&o, "wrectProperty.x");
+ QCOMPARE(p2.read(), QVariant(1));
+ QCOMPARE(p2.write(QVariant(6)), true);
+ QCOMPARE(p2.read(), QVariant(6));
+ QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
+ }
+
+ // URL-property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "url");
+
+ QCOMPARE(p.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), QUrl("main.qml"));
+
+ QDeclarativeProperty p2(&o, "url", engine.rootContext());
+
+ QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
+ QVERIFY(result != QUrl("main.qml"));
+
+ QCOMPARE(p2.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), result);
+ }
+
+ // Attached property
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
+ p.write(QVariant(99));
+ QCOMPARE(p.read(), QVariant(99));
+ delete object;
+ }
+ {
+ QDeclarativeComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
+ p.write(QVariant(99));
+ QCOMPARE(p.read(), QVariant(99));
+ delete object;
+ }
+}
+
+void tst_qdeclarativeproperty::reset()
+{
+ // Invalid
+ {
+ QDeclarativeProperty p;
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QDeclarativeProperty p(&o);
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Non-resettable-only prop by name
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Resettable prop by name
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, QString("resettableProperty"));
+
+ QCOMPARE(p.read(), QVariant(9));
+ QCOMPARE(p.write(QVariant(11)), true);
+ QCOMPARE(p.read(), QVariant(11));
+
+ QCOMPARE(p.isResettable(), true);
+ QCOMPARE(p.reset(), true);
+
+ QCOMPARE(p.read(), QVariant(9));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+
+ QDeclarativeProperty p(o, QString("resettableProperty"));
+
+ QCOMPARE(p.isResettable(), true);
+ QCOMPARE(p.reset(), true);
+
+ delete o;
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onClicked");
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+}
+
+void tst_qdeclarativeproperty::writeObjectToList()
+{
+ QDeclarativeComponent containerComponent(&engine);
+ containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QDeclarativeListReference list(container, "children");
+ QVERIFY(list.count() == 1);
+
+ MyQmlObject *object = new MyQmlObject;
+ QDeclarativeProperty prop(container, "children");
+ prop.write(qVariantFromValue(object));
+ QCOMPARE(list.count(), 1);
+ QCOMPARE(list.at(0), object);
+}
+
+Q_DECLARE_METATYPE(QList<QObject *>);
+void tst_qdeclarativeproperty::writeListToList()
+{
+ QDeclarativeComponent containerComponent(&engine);
+ containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QDeclarativeListReference list(container, "children");
+ QVERIFY(list.count() == 1);
+
+ QList<QObject*> objList;
+ objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
+ QDeclarativeProperty prop(container, "children");
+ prop.write(qVariantFromValue(objList));
+ QCOMPARE(list.count(), 4);
+
+ //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
+ /*QList<MyQmlObject*> typedObjList;
+ typedObjList << new MyQmlObject();
+ prop.write(qVariantFromValue(&typedObjList));
+ QCOMPARE(container->children()->size(), 1);*/
+}
+
+void tst_qdeclarativeproperty::crashOnValueProperty()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+ QDeclarativeComponent component(engine);
+
+ component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
+ PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
+ QVERIFY(obj != 0);
+
+ QDeclarativeProperty p(obj, "wrectProperty.x", qmlContext(obj));
+ QCOMPARE(p.name(), QString("wrectProperty.x"));
+
+ QCOMPARE(p.read(), QVariant(10));
+
+ //don't crash once the engine is deleted
+ delete engine;
+ engine = 0;
+
+ QCOMPARE(p.propertyTypeName(), "int");
+ QCOMPARE(p.read(), QVariant(10));
+ p.write(QVariant(20));
+ QCOMPARE(p.read(), QVariant(20));
+}
+
+void tst_qdeclarativeproperty::copy()
+{
+ PropertyObject object;
+
+ QDeclarativeProperty *property = new QDeclarativeProperty(&object, QLatin1String("defaultProperty"));
+ QCOMPARE(property->name(), QString("defaultProperty"));
+ QCOMPARE(property->read(), QVariant(10));
+ QCOMPARE(property->type(), QDeclarativeProperty::Property);
+ QCOMPARE(property->propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(property->propertyType(), (int)QVariant::Int);
+
+ QDeclarativeProperty p1(*property);
+ QCOMPARE(p1.name(), QString("defaultProperty"));
+ QCOMPARE(p1.read(), QVariant(10));
+ QCOMPARE(p1.type(), QDeclarativeProperty::Property);
+ QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(p1.propertyType(), (int)QVariant::Int);
+
+ QDeclarativeProperty p2(&object, QLatin1String("url"));
+ QCOMPARE(p2.name(), QString("url"));
+ p2 = *property;
+ QCOMPARE(p2.name(), QString("defaultProperty"));
+ QCOMPARE(p2.read(), QVariant(10));
+ QCOMPARE(p2.type(), QDeclarativeProperty::Property);
+ QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(p2.propertyType(), (int)QVariant::Int);
+
+ delete property; property = 0;
+
+ QCOMPARE(p1.name(), QString("defaultProperty"));
+ QCOMPARE(p1.read(), QVariant(10));
+ QCOMPARE(p1.type(), QDeclarativeProperty::Property);
+ QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(p1.propertyType(), (int)QVariant::Int);
+
+ QCOMPARE(p2.name(), QString("defaultProperty"));
+ QCOMPARE(p2.read(), QVariant(10));
+ QCOMPARE(p2.type(), QDeclarativeProperty::Property);
+ QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal);
+ QCOMPARE(p2.propertyType(), (int)QVariant::Int);
+}
+
+void tst_qdeclarativeproperty::initTestCase()
+{
+ QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
+ QML_REGISTER_TYPE(Test,1,0,PropertyObject,PropertyObject);
+ QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer);
+}
+
+
+QTEST_MAIN(tst_qdeclarativeproperty)
+
+#include "tst_qdeclarativeproperty.moc"
diff --git a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
new file mode 100644
index 0000000000..aeccf9b233
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativepropertymap.cpp
diff --git a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
new file mode 100644
index 0000000000..22c5581f2e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativepropertymap.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetext_p.h>
+#include <QSignalSpy>
+
+class tst_QDeclarativePropertyMap : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativePropertyMap() {}
+
+private slots:
+ void insert();
+ void operatorInsert();
+ void operatorValue();
+ void clear();
+ void changed();
+ void count();
+};
+
+void tst_QDeclarativePropertyMap::insert()
+{
+ QDeclarativePropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(map.contains(QLatin1String("key1")));
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map.insert(QLatin1String("key1"),"Hello World");
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QDeclarativePropertyMap::operatorInsert()
+{
+ QDeclarativePropertyMap map;
+ map[QLatin1String("key1")] = 100;
+ map[QLatin1String("key2")] = 200;
+ QVERIFY(map.keys().count() == 2);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map[QLatin1String("key1")] = "Hello World";
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QDeclarativePropertyMap::operatorValue()
+{
+ QDeclarativePropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QVERIFY(map.count() == 2);
+ QVERIFY(map.contains(QLatin1String("key1")));
+
+ const QDeclarativePropertyMap &constMap = map;
+
+ QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
+ QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
+ QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
+}
+
+void tst_QDeclarativePropertyMap::clear()
+{
+ QDeclarativePropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ QVERIFY(map.keys().count() == 1);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+
+ map.clear(QLatin1String("key1"));
+ QVERIFY(map.keys().count() == 1);
+ QVERIFY(map.contains(QLatin1String("key1")));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant());
+}
+
+void tst_QDeclarativePropertyMap::changed()
+{
+ QDeclarativePropertyMap map;
+ QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&)));
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QCOMPARE(spy.count(), 0);
+
+ map.clear(QLatin1String("key1"));
+ QCOMPARE(spy.count(), 0);
+
+ //make changes in QML
+ QDeclarativeEngine engine;
+ QDeclarativeContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty(QLatin1String("testdata"), &map);
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.6\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
+ QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+ QDeclarativeText *txt = qobject_cast<QDeclarativeText*>(component.create());
+ QVERIFY(txt);
+ QCOMPARE(txt->text(), QString('X'));
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QDeclarativePropertyMap::count()
+{
+ QDeclarativePropertyMap map;
+ QCOMPARE(map.isEmpty(), true);
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QCOMPARE(map.count(), 2);
+ QCOMPARE(map.isEmpty(), false);
+
+ map.insert(QLatin1String("key3"),"Hello World");
+ QCOMPARE(map.count(), 3);
+
+ //clearing doesn't remove the key
+ map.clear(QLatin1String("key3"));
+ QCOMPARE(map.count(), 3);
+ QCOMPARE(map.size(), map.count());
+}
+
+QTEST_MAIN(tst_QDeclarativePropertyMap)
+
+#include "tst_qdeclarativepropertymap.moc"
diff --git a/tests/auto/declarative/qmlqt/data/closestangle.qml b/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml
index b5f7fc637d..b5f7fc637d 100644
--- a/tests/auto/declarative/qmlqt/data/closestangle.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml
diff --git a/tests/auto/declarative/qmlqt/data/consoleLog.qml b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml
index e657ff1a4b..e657ff1a4b 100644
--- a/tests/auto/declarative/qmlqt/data/consoleLog.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml
diff --git a/tests/auto/declarative/qmlqt/data/createComponent.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
index d9b70ec671..d9b70ec671 100644
--- a/tests/auto/declarative/qmlqt/data/createComponent.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
diff --git a/tests/auto/declarative/qmlqt/data/createComponentData.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml
index a5e99a0ee8..a5e99a0ee8 100644
--- a/tests/auto/declarative/qmlqt/data/createComponentData.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml
diff --git a/tests/auto/declarative/qmlqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
index 9150782ffa..9150782ffa 100644
--- a/tests/auto/declarative/qmlqt/data/createQmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
diff --git a/tests/auto/declarative/qmlqt/data/darker.qml b/tests/auto/declarative/qdeclarativeqt/data/darker.qml
index 2df067e240..2df067e240 100644
--- a/tests/auto/declarative/qmlqt/data/darker.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/darker.qml
diff --git a/tests/auto/declarative/qmlqt/data/enums.qml b/tests/auto/declarative/qdeclarativeqt/data/enums.qml
index 1efa6f5931..1efa6f5931 100644
--- a/tests/auto/declarative/qmlqt/data/enums.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/enums.qml
diff --git a/tests/auto/declarative/qmlqt/data/hsla.qml b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml
index df51ccdbff..df51ccdbff 100644
--- a/tests/auto/declarative/qmlqt/data/hsla.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml
diff --git a/tests/auto/declarative/qmlqt/data/lighter.qml b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
index 4e0c43110b..4e0c43110b 100644
--- a/tests/auto/declarative/qmlqt/data/lighter.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
diff --git a/tests/auto/declarative/qmlqt/data/md5.qml b/tests/auto/declarative/qdeclarativeqt/data/md5.qml
index c474b7185e..c474b7185e 100644
--- a/tests/auto/declarative/qmlqt/data/md5.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/md5.qml
diff --git a/tests/auto/declarative/qmlqt/data/point.qml b/tests/auto/declarative/qdeclarativeqt/data/point.qml
index c383bebe2f..c383bebe2f 100644
--- a/tests/auto/declarative/qmlqt/data/point.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/point.qml
diff --git a/tests/auto/declarative/qmlqt/data/rect.qml b/tests/auto/declarative/qdeclarativeqt/data/rect.qml
index 82b642892d..82b642892d 100644
--- a/tests/auto/declarative/qmlqt/data/rect.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/rect.qml
diff --git a/tests/auto/declarative/qmlqt/data/rgba.qml b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml
index 6dd656584e..6dd656584e 100644
--- a/tests/auto/declarative/qmlqt/data/rgba.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml
diff --git a/tests/auto/declarative/qmlqt/data/size.qml b/tests/auto/declarative/qdeclarativeqt/data/size.qml
index 05b0317a9b..05b0317a9b 100644
--- a/tests/auto/declarative/qmlqt/data/size.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/size.qml
diff --git a/tests/auto/declarative/qmlqt/data/tint.qml b/tests/auto/declarative/qdeclarativeqt/data/tint.qml
index da8afe2e5c..da8afe2e5c 100644
--- a/tests/auto/declarative/qmlqt/data/tint.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/tint.qml
diff --git a/tests/auto/declarative/qmlqt/data/vector.qml b/tests/auto/declarative/qdeclarativeqt/data/vector.qml
index a471c7a7bb..a471c7a7bb 100644
--- a/tests/auto/declarative/qmlqt/data/vector.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/vector.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
new file mode 100644
index 0000000000..aff00ad14f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_qdeclarativeqt.cpp
+macx:CONFIG -= app_bundle
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
new file mode 100644
index 0000000000..9ec68727ae
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -0,0 +1,369 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDebug>
+#include <QDeclarativeEngine>
+#include <QFileInfo>
+#include <QDeclarativeComponent>
+#include <QDir>
+#include <QVector3D>
+#include <QCryptographicHash>
+#include <QDeclarativeItem>
+
+class tst_qdeclarativeqt : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativeqt() {}
+
+private slots:
+ void enums();
+ void rgba();
+ void hsla();
+ void rect();
+ void point();
+ void size();
+ void vector();
+ void lighter();
+ void darker();
+ void tint();
+ void closestAngle();
+ void playSound();
+ void openUrlExternally();
+ void md5();
+ void createComponent();
+ void createQmlObject();
+ void consoleLog();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_qdeclarativeqt::enums()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape);
+ QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder);
+ QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle);
+ QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight);
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::rgba()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
+ QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
+ QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
+ QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::hsla()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
+ QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
+ QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
+ QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::rect()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("rect.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109));
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6));
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF());
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF());
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::point()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("point.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34));
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2));
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF());
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::size()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("size.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF());
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::vector()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("vector.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9));
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1));
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D());
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::lighter()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::darker()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("darker.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::tint()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("tint.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor";
+ QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0));
+ QEXPECT_FAIL("", "QT-2424",Continue);
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0, 0));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::closestAngle()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("closestangle.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11);
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::playSound()
+{
+ QEXPECT_FAIL("", "How do we test this?", Abort);
+ QVERIFY(false);
+}
+
+void tst_qdeclarativeqt::openUrlExternally()
+{
+ QEXPECT_FAIL("", "How do we test this?", Abort);
+ QVERIFY(false);
+}
+
+void tst_qdeclarativeqt::md5()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("md5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex()));
+ QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::createComponent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
+ QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
+ QCOMPARE(object->property("emptyArg").toBool(), true);
+
+ QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
+ QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString());
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::createQmlObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml"));
+
+ QString warning1 = "QDeclarativeEngine::createQmlObject():";
+ QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name";
+ QString warning3 = "QDeclarativeEngine::createQmlObject(): Component is not ready";
+ QString warning4 = "QDeclarativeEngine::createQmlObject():";
+ QString warning5 = " " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
+ QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
+ QCOMPARE(object->property("emptyArg").toBool(), true);
+ QCOMPARE(object->property("errors").toBool(), true);
+ QCOMPARE(object->property("noParent").toBool(), true);
+ QCOMPARE(object->property("notReady").toBool(), true);
+ QCOMPARE(object->property("runtimeError").toBool(), true);
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(object);
+ QVERIFY(item != 0);
+ QVERIFY(item->childItems().count() == 1);
+
+ delete object;
+}
+
+void tst_qdeclarativeqt::consoleLog()
+{
+ QTest::ignoreMessage(QtDebugMsg, "completed ok");
+ QTest::ignoreMessage(QtDebugMsg, "completed ok");
+ QDeclarativeComponent component(&engine, TEST_FILE("consoleLog.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+QTEST_MAIN(tst_qdeclarativeqt)
+
+#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml b/tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml
index cf1fb4da6c..cf1fb4da6c 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml
index fc6b34c8ad..fc6b34c8ad 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/objlist.qml b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
index e6d0acb849..e6d0acb849 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/objlist.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml b/tests/auto/declarative/qdeclarativerepeater/data/properties.qml
index 550ce8dba7..550ce8dba7 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/properties.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater.qml
index 7d832309b7..7d832309b7 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater.qml
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater2.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
index c3c3260e39..c3c3260e39 100644
--- a/tests/auto/declarative/qmlgraphicsrepeater/data/repeater2.qml
+++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml
diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
new file mode 100644
index 0000000000..132123a827
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativerepeater.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
new file mode 100644
index 0000000000..7a97e60217
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
@@ -0,0 +1,385 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qlistmodelinterface_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <private/qdeclarativerepeater_p.h>
+#include <private/qdeclarativetext_p.h>
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+class tst_QDeclarativeRepeater : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDeclarativeRepeater();
+
+private slots:
+ void numberModel();
+ void objectList();
+ void stringList();
+ void dataModel();
+ void itemModel();
+ void properties();
+
+private:
+ QDeclarativeView *createView();
+ template<typename T>
+ T *findItem(QGraphicsObject *parent, const QString &id);
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError)
+ Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
+
+public:
+ TestObject() : QObject(), mError(true), mUseModel(false) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; }
+
+ bool useModel() const { return mUseModel; }
+ void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
+
+signals:
+ void useModelChanged();
+
+private:
+ bool mError;
+ bool mUseModel;
+};
+
+class TestModel : public QAbstractListModel
+{
+public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ TestModel(QObject *parent=0) : QAbstractListModel(parent) {
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+ }
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+ }
+
+ int count() const { return rowCount(); }
+ QString name(int index) const { return list.at(index).first; }
+ QString number(int index) const { return list.at(index).second; }
+
+ void addItem(const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void insertItem(int index, const QString &name, const QString &number) {
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+ }
+
+ void removeItem(int index) {
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+ }
+
+ void moveItem(int from, int to) {
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+ }
+
+ void modifyItem(int idx, const QString &name, const QString &number) {
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+ }
+
+private:
+ QList<QPair<QString,QString> > list;
+};
+
+
+tst_QDeclarativeRepeater::tst_QDeclarativeRepeater()
+{
+}
+
+void tst_QDeclarativeRepeater::numberModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", 5);
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeRepeater::objectList()
+{
+ QDeclarativeView *canvas = createView();
+
+ QObjectList data;
+ for(int i=0; i<100; i++){
+ data << new QObject();
+ data.back()->setProperty("idx", i);
+ }
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
+ QCOMPARE(repeater->property("instantiated").toInt(), 100);
+}
+
+/*
+The Repeater element creates children at its own position in its parent's
+stacking order. In this test we insert a repeater between two other Text
+elements to test this.
+*/
+void tst_QDeclarativeRepeater::stringList()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList data;
+ data << "One";
+ data << "Two";
+ data << "Three";
+ data << "Four";
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", data);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), data.count() + 3);
+
+ bool saw_repeater = false;
+ for (int i = 0; i < container->childItems().count(); ++i) {
+
+ if (i == 0) {
+ QDeclarativeText *name = qobject_cast<QDeclarativeText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Zero"));
+ } else if (i == container->childItems().count() - 2) {
+ // The repeater itself
+ QDeclarativeRepeater *rep = qobject_cast<QDeclarativeRepeater*>(container->childItems().at(i));
+ QCOMPARE(rep, repeater);
+ saw_repeater = true;
+ continue;
+ } else if (i == container->childItems().count() - 1) {
+ QDeclarativeText *name = qobject_cast<QDeclarativeText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Last"));
+ } else {
+ QDeclarativeText *name = qobject_cast<QDeclarativeText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-1));
+ }
+ }
+ QVERIFY(saw_repeater);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeRepeater::dataModel()
+{
+ QDeclarativeView *canvas = createView();
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ TestModel testModel;
+ testModel.addItem("one", "1");
+ testModel.addItem("two", "2");
+ testModel.addItem("three", "3");
+
+ ctxt->setContextProperty("testData", &testModel);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), 4);
+
+ testModel.addItem("four", "4");
+ QCOMPARE(container->childItems().count(), 5);
+
+ testModel.removeItem(2);
+ QCOMPARE(container->childItems().count(), 4);
+}
+
+void tst_QDeclarativeRepeater::itemModel()
+{
+ QDeclarativeView *canvas = createView();
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), 1);
+
+ testObject->setUseModel(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QCOMPARE(container->childItems().count(), 4);
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
+ QVERIFY(container->childItems().at(3) == repeater);
+
+ delete canvas;
+}
+
+void tst_QDeclarativeRepeater::properties()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("/properties.qml"));
+
+ QDeclarativeItem *rootObject = qobject_cast<QDeclarativeItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+
+ QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
+
+ QDeclarativeComponent rectComponent(&engine);
+ rectComponent.setData("import Qt 4.6; Rectangle {}", QUrl::fromLocalFile(""));
+
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+}
+
+QDeclarativeView *tst_QDeclarativeRepeater::createView()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setFixedSize(240,320);
+
+ return canvas;
+}
+
+template<typename T>
+T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName)
+{
+ const QMetaObject &mo = T::staticMetaObject;
+ if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
+ return static_cast<T*>(parent);
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QDeclarativeItem *child = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
+ if (!child)
+ continue;
+ QDeclarativeItem *item = findItem<T>(child, objectName);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+}
+
+QTEST_MAIN(tst_QDeclarativeRepeater)
+
+#include "tst_qdeclarativerepeater.moc"
diff --git a/tests/auto/declarative/qmlspringfollow/data/springfollow1.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml
index 959d206b37..959d206b37 100644
--- a/tests/auto/declarative/qmlspringfollow/data/springfollow1.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow1.qml
diff --git a/tests/auto/declarative/qmlspringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
index 7c81fb5b8d..7c81fb5b8d 100644
--- a/tests/auto/declarative/qmlspringfollow/data/springfollow2.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
diff --git a/tests/auto/declarative/qmlspringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
index 6fec55bdf2..6fec55bdf2 100644
--- a/tests/auto/declarative/qmlspringfollow/data/springfollow3.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
diff --git a/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
new file mode 100644
index 0000000000..61aad0f65c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativespringfollow/qdeclarativespringfollow.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativespringfollow.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
new file mode 100644
index 0000000000..7a60e78b6f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativespringfollow_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativespringfollow : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativespringfollow();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativespringfollow::tst_qdeclarativespringfollow()
+{
+}
+
+void tst_qdeclarativespringfollow::defaultValues()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow1.qml"));
+ QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 0.);
+ QCOMPARE(obj->velocity(), 0.);
+ QCOMPARE(obj->spring(), 0.);
+ QCOMPARE(obj->damping(), 0.);
+ QCOMPARE(obj->epsilon(), 0.01);
+ QCOMPARE(obj->modulus(), 0.);
+ QCOMPARE(obj->value(), 0.);
+ QCOMPARE(obj->mass(), 1.);
+ QCOMPARE(obj->enabled(), true);
+ QCOMPARE(obj->inSync(), true);
+
+ delete obj;
+}
+
+void tst_qdeclarativespringfollow::values()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow2.qml"));
+ QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 1.44);
+ QCOMPARE(obj->velocity(), 0.9);
+ QCOMPARE(obj->spring(), 1.0);
+ QCOMPARE(obj->damping(), 0.5);
+ QCOMPARE(obj->epsilon(), 0.25);
+ QCOMPARE(obj->modulus(), 360.0);
+ QCOMPARE(obj->mass(), 2.0);
+ QCOMPARE(obj->enabled(), true);
+
+ QTRY_COMPARE(obj->value(), 1.44);
+ QTRY_COMPARE(obj->inSync(), true);
+
+ delete obj;
+}
+
+void tst_qdeclarativespringfollow::disabled()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow3.qml"));
+ QDeclarativeSpringFollow *obj = qobject_cast<QDeclarativeSpringFollow*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->sourceValue(), 1.44);
+ QCOMPARE(obj->velocity(), 0.9);
+ QCOMPARE(obj->spring(), 1.0);
+ QCOMPARE(obj->damping(), 0.5);
+ QCOMPARE(obj->epsilon(), 0.25);
+ QCOMPARE(obj->modulus(), 360.0);
+ QCOMPARE(obj->mass(), 2.0);
+ QCOMPARE(obj->enabled(), false);
+
+ QCOMPARE(obj->value(), 0.0);
+ QCOMPARE(obj->inSync(), false);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qdeclarativespringfollow)
+
+#include "tst_qdeclarativespringfollow.moc"
diff --git a/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml b/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml
index 8d646635df..8d646635df 100644
--- a/tests/auto/declarative/qmlstates/data/ExtendedRectangle.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml
index 7dce88955b..7dce88955b 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
index 545345e539..545345e539 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
index 9d5b317786..9d5b317786 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
index f12898908d..f12898908d 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml
diff --git a/tests/auto/declarative/qmlstates/data/anchorChanges5.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
index 4e6d34b25f..4e6d34b25f 100644
--- a/tests/auto/declarative/qmlstates/data/anchorChanges5.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml
diff --git a/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
index 693a5c5a0e..693a5c5a0e 100644
--- a/tests/auto/declarative/qmlstates/data/autoStateAtStartupRestoreBug.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml
index 652811380f..652811380f 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding2.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml
index 2e7b4cf614..2e7b4cf614 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding3.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml
index a3c47d9db6..a3c47d9db6 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicBinding4.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml
index 1f52d0e773..1f52d0e773 100644
--- a/tests/auto/declarative/qmlstates/data/basicBinding4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicChanges.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml
index 88ea2565ed..88ea2565ed 100644
--- a/tests/auto/declarative/qmlstates/data/basicChanges.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml
index 4dd293f6f0..4dd293f6f0 100644
--- a/tests/auto/declarative/qmlstates/data/basicChanges2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml
diff --git a/tests/auto/declarative/qmlstates/data/basicChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml
index 62ab1d58a6..62ab1d58a6 100644
--- a/tests/auto/declarative/qmlstates/data/basicChanges3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml
diff --git a/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml
new file mode 100644
index 0000000000..a373cfcde6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml
@@ -0,0 +1,19 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyRectangle {
+ id: rect
+ width: 100; height: 100
+ color: "red"
+
+ states: State {
+ name: "aBlueDay"
+ PropertyChanges {
+ target: rect
+ onPropertyWithNotifyChanged: { rect.color = "blue"; }
+ }
+ }
+
+ Component.onCompleted: rect.state = "aBlueDay"
+}
+
diff --git a/tests/auto/declarative/qmlstates/data/basicExtension.qml b/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml
index 1836f8a077..1836f8a077 100644
--- a/tests/auto/declarative/qmlstates/data/basicExtension.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml
diff --git a/tests/auto/declarative/qmlstates/data/deleting.qml b/tests/auto/declarative/qdeclarativestates/data/deleting.qml
index 3da0b12356..3da0b12356 100644
--- a/tests/auto/declarative/qmlstates/data/deleting.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/deleting.qml
diff --git a/tests/auto/declarative/qmlstates/data/deletingState.qml b/tests/auto/declarative/qdeclarativestates/data/deletingState.qml
index a5e8ed3a97..a5e8ed3a97 100644
--- a/tests/auto/declarative/qmlstates/data/deletingState.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/deletingState.qml
diff --git a/tests/auto/declarative/qmlstates/data/explicit.qml b/tests/auto/declarative/qdeclarativestates/data/explicit.qml
index 7543f84414..7543f84414 100644
--- a/tests/auto/declarative/qmlstates/data/explicit.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/explicit.qml
diff --git a/tests/auto/declarative/qmlstates/data/fakeExtension.qml b/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml
index c7975e12ef..c7975e12ef 100644
--- a/tests/auto/declarative/qmlstates/data/fakeExtension.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml
diff --git a/tests/auto/declarative/qmlstates/data/illegalTempState.qml b/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml
index 0dc39ae155..0dc39ae155 100644
--- a/tests/auto/declarative/qmlstates/data/illegalTempState.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml
diff --git a/tests/auto/declarative/qmlstates/data/legalTempState.qml b/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml
index 9be984cc30..9be984cc30 100644
--- a/tests/auto/declarative/qmlstates/data/legalTempState.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml
diff --git a/tests/auto/declarative/qmlstates/data/nonExistantProp.qml b/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml
index a5dd86a71c..a5dd86a71c 100644
--- a/tests/auto/declarative/qmlstates/data/nonExistantProp.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange.qml
index b8c781808e..b8c781808e 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange2.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml
index 8b23591350..8b23591350 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange3.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml
index ddf92683a8..ddf92683a8 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange3.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange4.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml
index 34d667a0c4..34d667a0c4 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange4.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml
diff --git a/tests/auto/declarative/qmlstates/data/parentChange5.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml
index 56bdd89b7e..56bdd89b7e 100644
--- a/tests/auto/declarative/qmlstates/data/parentChange5.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml
diff --git a/tests/auto/declarative/qmlstates/data/propertyErrors.qml b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
index 080e833879..080e833879 100644
--- a/tests/auto/declarative/qmlstates/data/propertyErrors.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml
new file mode 100644
index 0000000000..a0a2b8c8c5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+Rectangle {
+ width: 640
+ height: 480
+ Text {
+ id: theText
+ width: 50
+ wrap: true
+ text: "a text string that is longer than 50 pixels"
+ }
+
+ states: State {
+ name: "state1"
+ PropertyChanges {
+ target: theText
+ width: undefined
+ }
+ }
+}
diff --git a/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml b/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml
index 088c6081c6..088c6081c6 100644
--- a/tests/auto/declarative/qmlstates/data/restoreEntryValues.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml
diff --git a/tests/auto/declarative/qmlstates/data/script.qml b/tests/auto/declarative/qdeclarativestates/data/script.qml
index 3c5f33e9e4..3c5f33e9e4 100644
--- a/tests/auto/declarative/qmlstates/data/script.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/script.qml
diff --git a/tests/auto/declarative/qmlstates/data/signalOverride.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml
index 5ba1566b39..5ba1566b39 100644
--- a/tests/auto/declarative/qmlstates/data/signalOverride.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml
diff --git a/tests/auto/declarative/qmlstates/data/signalOverride2.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml
index 527e165048..527e165048 100644
--- a/tests/auto/declarative/qmlstates/data/signalOverride2.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml
diff --git a/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml
index 702fa86964..702fa86964 100644
--- a/tests/auto/declarative/qmlstates/data/signalOverrideCrash.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml
diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
new file mode 100644
index 0000000000..f874803511
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativestates.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
new file mode 100644
index 0000000000..8d3ca7a837
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -0,0 +1,969 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativeanchors_p_p.h>
+#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativepropertychanges_p.h>
+#include <private/qdeclarativestategroup_p.h>
+
+
+class MyRect : public QDeclarativeRectangle
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+public:
+ MyRect() {}
+
+ void doSomething() { emit didSomething(); }
+
+ int propertyWithNotify() const { return m_prop; }
+ void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); }
+Q_SIGNALS:
+ void didSomething();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_prop;
+};
+
+QML_DECLARE_TYPE(MyRect)
+
+
+class tst_qdeclarativestates : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativestates() {}
+
+private:
+ static QByteArray fullDataPath(const QString &path);
+
+private slots:
+ void initTestCase();
+
+ void basicChanges();
+ void basicExtension();
+ void basicBinding();
+ void signalOverride();
+ void signalOverrideCrash();
+ void parentChange();
+ void parentChangeErrors();
+ void anchorChanges();
+ void anchorChanges2();
+ void anchorChanges3();
+ void anchorChanges4();
+ void anchorChanges5();
+ void script();
+ void restoreEntryValues();
+ void explicitChanges();
+ void propertyErrors();
+ void incorrectRestoreBug();
+ void autoStateAtStartupRestoreBug();
+ void deletingChange();
+ void deletingState();
+ void tempState();
+ void illegalTempState();
+ void nonExistantProperty();
+ void reset();
+};
+
+void tst_qdeclarativestates::initTestCase()
+{
+ QML_REGISTER_TYPE(Qt.test, 1, 0, MyRectangle,MyRect);
+}
+
+QByteArray tst_qdeclarativestates::fullDataPath(const QString &path)
+{
+ return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8();
+}
+
+void tst_qdeclarativestates::basicChanges()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+ //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ }
+
+ {
+ // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
+ // signal using 'onPropertyWithNotifyChanged' even though the signal name is
+ // actually 'oddlyNamedNotifySignal'
+
+ QDeclarativeComponent component(&engine, SRCDIR "/data/basicChanges4.qml");
+ QVERIFY(component.isReady());
+
+ MyRect *rect = qobject_cast<MyRect*>(component.create());
+ QVERIFY(rect != 0);
+
+ QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
+ QVERIFY(prop.hasNotifySignal());
+ QString notifySignal = QByteArray(prop.notifySignal().signature());
+ QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
+
+ QCOMPARE(rect->color(), QColor(Qt::red));
+
+ rect->setPropertyWithNotify(100);
+ QCOMPARE(rect->color(), QColor(Qt::blue));
+ }
+}
+
+void tst_qdeclarativestates::basicExtension()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+
+ rect->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2);
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1);
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+}
+
+void tst_qdeclarativestates::basicBinding()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("red"));
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor2", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor2", QColor("green"));
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("purple"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("purple"));
+
+ rect->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+}
+
+void tst_qdeclarativestates::signalOverride()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("white"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("extendedRect"));
+
+ innerRect->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(innerRect->color(),QColor("green"));
+ QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
+ }
+}
+
+void tst_qdeclarativestates::signalOverrideCrash()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml");
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ rect->setState("overridden");
+ rect->doSomething();
+}
+
+void tst_qdeclarativestates::parentChange()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeParentChange *pChange = qobject_cast<QDeclarativeParentChange*>(state->operationAt(0));
+ QVERIFY(pChange != 0);
+ QDeclarativeItem *nParent = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("NewParent"));
+ QVERIFY(nParent != 0);
+
+ QCOMPARE(pChange->parent(), nParent);
+
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-133));
+ QCOMPARE(innerRect->y(), qreal(-300));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(15));
+ QCOMPARE(innerRect->scale(), qreal(.5));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(-37));
+ QCOMPARE(innerRect->scale(), qreal(.25));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
+
+ rect->setState("");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ //do a non-qFuzzyCompare fuzzy compare
+ QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
+ }
+}
+
+void tst_qdeclarativestates::parentChangeErrors()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange4.qml") + ":25:9) Unable to preserve appearance under non-uniform scale").constData());
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(5));
+ }
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange5.qml") + ":25:9) Unable to preserve appearance under complex transform").constData());
+ rect->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(5));
+ }
+}
+
+void tst_qdeclarativestates::anchorChanges()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+ QCOMPARE(aChanges->reset(), QString("left"));
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->right().item, rect->right().item);
+ QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges2()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("right");
+ QEXPECT_FAIL("", "QTBUG-5338", Continue);
+ QCOMPARE(innerRect->x(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges3()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->left().item, leftGuideline->left().item);
+ QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine);
+ QCOMPARE(aChanges->right().item, rect->right().item);
+ QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->top().item, rect->top().item);
+ QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine);
+ QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item);
+ QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
+
+ QCOMPARE(innerRect->x(), qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ QCOMPARE(innerRect->width(), qreal(190));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ QCOMPARE(innerRect->width(), qreal(150));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges4()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item);
+ QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::anchorChanges5()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeRectangle *innerRect = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativeAnchorChanges *aChanges = qobject_cast<QDeclarativeAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item);
+ QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine);
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::script()
+{
+ QDeclarativeEngine engine;
+
+ {
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
+ }
+}
+
+void tst_qdeclarativestates::restoreEntryValues()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("blue"));
+}
+
+void tst_qdeclarativestates::explicitChanges()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeListReference list(rect, "states");
+ QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QDeclarativePropertyChanges *changes = qobject_cast<QDeclarativePropertyChanges*>(rect->findChild<QDeclarativePropertyChanges*>("changes"));
+ QVERIFY(changes != 0);
+ QVERIFY(changes->isExplicit());
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+}
+
+void tst_qdeclarativestates::propertyErrors()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData());
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData());
+ rect->setState("blue");
+}
+
+void tst_qdeclarativestates::incorrectRestoreBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ // make sure if we change the base state value, we then restore to it correctly
+ rect->setColor(QColor("green"));
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+}
+
+void tst_qdeclarativestates::autoStateAtStartupRestoreBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent component(&engine, SRCDIR "/data/autoStateAtStartupRestoreBug.qml");
+ QObject *obj = component.create();
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 3);
+
+ obj->setProperty("input", 2);
+
+ QCOMPARE(obj->property("test").toInt(), 9);
+
+ delete obj;
+}
+
+void tst_qdeclarativestates::deletingChange()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ rect->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(0));
+
+ QDeclarativePropertyChanges *pc = rect->findChild<QDeclarativePropertyChanges*>("pc1");
+ QVERIFY(pc != 0);
+ delete pc;
+
+ QDeclarativeState *state = rect->findChild<QDeclarativeState*>();
+ QVERIFY(state != 0);
+ qmlExecuteDeferred(state);
+ QCOMPARE(state->operationCount(), 1);
+
+ rect->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::deletingState()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeStateGroup *sg = rect->findChild<QDeclarativeStateGroup*>();
+ QVERIFY(sg != 0);
+ QVERIFY(sg->findState("blue") != 0);
+
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ sg->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QDeclarativeState *state = rect->findChild<QDeclarativeState*>();
+ QVERIFY(state != 0);
+ delete state;
+
+ QVERIFY(sg->findState("blue") == 0);
+
+ //### should we warn that state doesn't exist
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ delete rect;
+}
+
+void tst_qdeclarativestates::tempState()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QTest::ignoreMessage(QtDebugMsg, "entering placed");
+ QTest::ignoreMessage(QtDebugMsg, "entering idle");
+ rect->setState("placed");
+ QCOMPARE(rect->state(), QLatin1String("idle"));
+}
+
+void tst_qdeclarativestates::illegalTempState()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. ");
+ rect->setState("placed");
+ QCOMPARE(rect->state(), QLatin1String("placed"));
+}
+
+void tst_qdeclarativestates::nonExistantProperty()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData());
+ rect->setState("blue");
+ QCOMPARE(rect->state(), QLatin1String("blue"));
+}
+
+void tst_qdeclarativestates::reset()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeText *text = rect->findChild<QDeclarativeText*>();
+ QVERIFY(text != 0);
+ QCOMPARE(text->width(), qreal(50.));
+ QVERIFY(text->width() < text->height());
+
+ rect->setState("state1");
+
+ QVERIFY(text->width() > 51);
+ QVERIFY(text->width() > text->height());
+}
+
+QTEST_MAIN(tst_qdeclarativestates)
+
+#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro b/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
new file mode 100644
index 0000000000..bd4d829728
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestyledtext/qdeclarativestyledtext.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+QT += network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativestyledtext.cpp
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
diff --git a/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
new file mode 100644
index 0000000000..7b1293e54a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/QtTest>
+#include <QtGui/QTextLayout>
+#include <private/qdeclarativestyledtext_p.h>
+
+class tst_qdeclarativestyledtext : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativestyledtext()
+ {
+ }
+
+private slots:
+ void textOutput();
+ void textOutput_data();
+};
+
+// For malformed input all we test is that we get the expected text out.
+//
+void tst_qdeclarativestyledtext::textOutput_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("output");
+
+ QTest::newRow("bold") << "<b>bold</b>" << "bold";
+ QTest::newRow("italic") << "<b>italic</b>" << "italic";
+ QTest::newRow("missing >") << "<b>text</b" << "text";
+ QTest::newRow("missing b>") << "<b>text</" << "text";
+ QTest::newRow("missing /b>") << "<b>text<" << "text";
+ QTest::newRow("missing </b>") << "<b>text" << "text";
+ QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic";
+ QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text";
+ QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text";
+ QTest::newRow("font empty") << "<font>text</font>" << "text";
+ QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text";
+ QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "";
+ QTest::newRow("extra close") << "<b>text</b></b>" << "text";
+ QTest::newRow("empty") << "" << "";
+}
+
+void tst_qdeclarativestyledtext::textOutput()
+{
+ QFETCH(QString, input);
+ QFETCH(QString, output);
+
+ QTextLayout layout;
+ QDeclarativeStyledText::parse(input, layout);
+
+ QCOMPARE(layout.text(), output);
+}
+
+
+QTEST_MAIN(tst_qdeclarativestyledtext)
+
+#include "tst_qdeclarativestyledtext.moc"
diff --git a/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
new file mode 100644
index 0000000000..0781774266
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativesystempalette/qdeclarativesystempalette.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativesystempalette.cpp
diff --git a/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
new file mode 100644
index 0000000000..5c9395283a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDebug>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativesystempalette_p.h>
+#include <qpalette.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativesystempalette : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativesystempalette();
+
+private slots:
+ void activePalette();
+ void inactivePalette();
+ void disabledPalette();
+ void paletteChanged();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativesystempalette::tst_qdeclarativesystempalette()
+{
+}
+
+void tst_qdeclarativesystempalette::activePalette()
+{
+ QString componentStr = "import Qt 4.6\nSystemPalette { }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Active);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qdeclarativesystempalette::inactivePalette()
+{
+ QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Inactive }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+ QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Inactive);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Inactive);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qdeclarativesystempalette::disabledPalette()
+{
+ QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Disabled }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+ QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Disabled);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Disabled);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qdeclarativesystempalette::paletteChanged()
+{
+ QString componentStr = "import Qt 4.6\nSystemPalette { }";
+ QDeclarativeComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+
+ QPalette p;
+ p.setCurrentColorGroup(QPalette::Active);
+ p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
+ p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
+ p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
+
+ qApp->setPalette(p);
+
+ object->setColorGroup(QDeclarativeSystemPalette::Active);
+ QTRY_COMPARE(QColor("red"), object->text());
+ QTRY_COMPARE(QColor("green"), object->buttonText());
+ QTRY_COMPARE(QColor("blue"), object->windowText());
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qdeclarativesystempalette)
+
+#include "tst_qdeclarativesystempalette.moc"
diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
new file mode 100644
index 0000000000..8b4b4d1382
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetext.cpp
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
new file mode 100644
index 0000000000..bbbbd836b5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -0,0 +1,844 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QTextDocument>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativevaluetype_p.h>
+#include <QFontMetrics>
+#include <QGraphicsSceneMouseEvent>
+#include <qmath.h>
+
+class tst_qdeclarativetext : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetext();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void elide();
+ void textFormat();
+
+ // ### these tests may be trivial
+ void horizontalAlignment();
+ void verticalAlignment();
+ void font();
+ void style();
+ void color();
+ void smooth();
+
+ // QDeclarativeFontValueType
+ void weight();
+ void underline();
+ void overline();
+ void strikeout();
+ void capitalization();
+ void letterSpacing();
+ void wordSpacing();
+
+ void clickLink();
+
+private:
+ QStringList standard;
+ QStringList richText;
+
+ QStringList horizontalAlignmentmentStrings;
+ QStringList verticalAlignmentmentStrings;
+
+ QList<Qt::Alignment> verticalAlignmentments;
+ QList<Qt::Alignment> horizontalAlignmentments;
+
+ QStringList styleStrings;
+ QList<QDeclarativeText::TextStyle> styles;
+
+ QStringList colorStrings;
+
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativetext::tst_qdeclarativetext()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog";
+
+ richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ horizontalAlignmentmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ verticalAlignmentmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ horizontalAlignmentments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ verticalAlignmentments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ styleStrings << "Normal"
+ << "Outline"
+ << "Raised"
+ << "Sunken";
+
+ styles << QDeclarativeText::Normal
+ << QDeclarativeText::Outline
+ << QDeclarativeText::Raised
+ << QDeclarativeText::Sunken;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+void tst_qdeclarativetext::text()
+{
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), QString(""));
+ QVERIFY(textObject->width() == 0);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), standard.at(i));
+ QVERIFY(textObject->width() > 0);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QString expected = richText.at(i);
+ QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
+ QVERIFY(textObject->width() > 0);
+ }
+}
+
+void tst_qdeclarativetext::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 0.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
+
+ QFont f;
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = qCeil(metricWidth);
+
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), qreal(metricWidth));
+ QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
+
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+
+ int documentWidth = document.idealWidth();
+
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), qreal(documentWidth));
+ QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format
+ }
+}
+
+void tst_qdeclarativetext::wrap()
+{
+ int textHeight = 0;
+ // for specified width and wrap set true
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ textHeight = textObject->height();
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrap() == true);
+ QCOMPARE(textObject->width(), 300.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+ }
+
+}
+
+void tst_qdeclarativetext::elide()
+{
+ for (QDeclarativeText::TextElideMode m = QDeclarativeText::ElideLeft; m<=QDeclarativeText::ElideNone; m=QDeclarativeText::TextElideMode(int(m)+1)) {
+ const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
+ QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
+
+ // XXX Poor coverage.
+
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(("import Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+ }
+
+ // richtext - does nothing
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+ }
+ }
+}
+
+void tst_qdeclarativetext::textFormat()
+{
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeText::RichText);
+ }
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeText::PlainText);
+ }
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qdeclarativetext::horizontalAlignment()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetext::verticalAlignment()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetext::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pointSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.pixelSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pixelSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().bold(), true);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().italic(), true);
+ QCOMPARE(textObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString(""));
+ }
+}
+
+void tst_qdeclarativetext::style()
+{
+ //test style
+ for (int i = 0; i < styles.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->style(), (int)styles.at(i));
+ QCOMPARE(textObject->styleColor(), QColor("white"));
+ }
+}
+
+void tst_qdeclarativetext::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor());
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
+ // default color to black?
+ QCOMPARE(textObject->color(), QColor("black"));
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ for (int j = 0; j < colorStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
+ }
+ }
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), testColor);
+ }
+}
+
+void tst_qdeclarativetext::smooth()
+{
+ for (int i = 0; i < standard.size(); i++)
+ {
+ {
+ QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+ }
+ }
+ for (int i = 0; i < richText.size(); i++)
+ {
+ {
+ QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+ }
+ }
+}
+
+void tst_qdeclarativetext::weight()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold);
+ }
+}
+
+void tst_qdeclarativetext::underline()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), false);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), true);
+ }
+}
+
+void tst_qdeclarativetext::overline()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), false);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), true);
+ }
+}
+
+void tst_qdeclarativetext::strikeout()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), false);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), true);
+ }
+}
+
+void tst_qdeclarativetext::capitalization()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize);
+ }
+}
+
+void tst_qdeclarativetext::letterSpacing()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 0.0);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), -50.);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 200.);
+ }
+}
+
+void tst_qdeclarativetext::wordSpacing()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 0.0);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), -50.);
+ }
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 200.);
+ }
+}
+
+class EventSender : public QGraphicsItem
+{
+public:
+ void sendEvent(QEvent *event) { sceneEvent(event); }
+};
+
+class LinkTest : public QObject
+{
+ Q_OBJECT
+public:
+ LinkTest() {}
+
+ QString link;
+
+public slots:
+ void linkClicked(QString l) { link = l; }
+};
+
+void tst_qdeclarativetext::clickLink()
+{
+ {
+ QString componentStr = "import Qt 4.6\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ LinkTest test;
+ QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
+ me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
+ me.setButton(Qt::LeftButton);
+ static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
+ }
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease);
+ me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
+ me.setButton(Qt::LeftButton);
+ static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
+ }
+
+ QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativetext)
+
+#include "tst_qdeclarativetext.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/cursorTest.qml b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
index e5df8f103e..e5df8f103e 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/cursorTest.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/ErrItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml
index 34b3883431..34b3883431 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/ErrItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/NormItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml
index 718cb719a7..718cb719a7 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/NormItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTest.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml
index 3c31e112ff..3c31e112ff 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTest.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml
index a44aec25cd..a44aec25cd 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail1.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml
index 57d3e47352..57d3e47352 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestFail2.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestPass.qml b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
index a44e8675af..a44e8675af 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/http/cursorHttpTestPass.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/httpfail/FailItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml
index ddbf526f3d..ddbf526f3d 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/httpfail/FailItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/httpslow/WaitItem.qml b/tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml
index ddbf526f3d..ddbf526f3d 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/httpslow/WaitItem.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml b/tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml
index c3d4c160b2..c3d4c160b2 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/inputmethodhints.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml b/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml
index 8d7dbbc082..8d7dbbc082 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/navigation.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml
diff --git a/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml
index 103a6278d5..103a6278d5 100644
--- a/tests/auto/declarative/qmlgraphicstextedit/data/readOnly.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml
diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro
new file mode 100644
index 0000000000..2228f11deb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro
@@ -0,0 +1,9 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui network
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp
+HEADERS += ../shared/testhttpserver.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
new file mode 100644
index 0000000000..b677fec13d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -0,0 +1,791 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include "../../../shared/util.h"
+#include "../shared/testhttpserver.h"
+#include <math.h>
+#include <QFile>
+#include <QTextDocument>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecontext.h>
+#include <QtDeclarative/qdeclarativeexpression.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetextedit_p.h>
+#include <QFontMetrics>
+#include <QDeclarativeView>
+#include <QStyle>
+#include <QInputContext>
+
+class tst_qdeclarativetextedit : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetextedit();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void textFormat();
+
+ // ### these tests may be trivial
+ void hAlign();
+ void vAlign();
+ void font();
+ void color();
+ void textMargin();
+ void persistentSelection();
+ void focusOnPress();
+ void selection();
+ void inputMethodHints();
+
+ void cursorDelegate();
+ void delegateLoading();
+ void navigation();
+ void readOnly();
+ void sendRequestSoftwareInputPanelEvent();
+
+private:
+ void simulateKey(QDeclarativeView *, int key);
+ QDeclarativeView *createView(const QString &filename);
+
+ QStringList standard;
+ QStringList richText;
+
+ QStringList hAlignmentStrings;
+ QStringList vAlignmentStrings;
+
+ QList<Qt::Alignment> vAlignments;
+ QList<Qt::Alignment> hAlignments;
+
+ QStringList colorStrings;
+
+ QDeclarativeEngine engine;
+};
+
+tst_qdeclarativetextedit::tst_qdeclarativetextedit()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog";
+
+ richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ hAlignmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ vAlignmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ hAlignments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ vAlignments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+void tst_qdeclarativetextedit::text()
+{
+ {
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QString actual = textEditObject->text();
+ QString expected = richText.at(i);
+ actual.replace(QRegExp(".*<body[^>]*>"),"");
+ actual.replace(QRegExp("(<[^>]*>)+"),"<>");
+ expected.replace(QRegExp("(<[^>]*>)+"),"<>");
+ QCOMPARE(actual.simplified(),expected.simplified());
+ }
+}
+
+void tst_qdeclarativetextedit::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 1.);//+1 for cursor
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = floor(metricWidth);
+
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character.
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+
+ int documentWidth = document.idealWidth();
+
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3));
+ }
+}
+
+void tst_qdeclarativetextedit::wrap()
+{
+ // for specified width and wrap set true
+ {
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+}
+
+void tst_qdeclarativetextedit::textFormat()
+{
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QDeclarativeTextEdit *textObject = qobject_cast<QDeclarativeTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeTextEdit::RichText);
+ }
+ {
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData("import Qt 4.6\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QDeclarativeTextEdit *textObject = qobject_cast<QDeclarativeTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QDeclarativeTextEdit::PlainText);
+ }
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qdeclarativetextedit::hAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetextedit::vAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qdeclarativetextedit::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().pointSize(), 40);
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().bold(), true);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().italic(), true);
+ QCOMPARE(textEditObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString(""));
+ }
+}
+
+void tst_qdeclarativetextedit::color()
+{
+ //test normal
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ //test selection
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
+ }
+
+ //test selected text
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), testColor);
+ }
+}
+
+void tst_qdeclarativetextedit::textMargin()
+{
+ for(qreal i=0; i<=10; i+=0.3){
+ QString componentStr = "import Qt 4.6\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->textMargin(), i);
+ }
+}
+
+void tst_qdeclarativetextedit::persistentSelection()
+{
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->persistentSelection(), true);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: false; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->persistentSelection(), false);
+ }
+}
+
+void tst_qdeclarativetextedit::focusOnPress()
+{
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: true; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), true);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: false; text: \"Hello World\" }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), false);
+ }
+}
+
+void tst_qdeclarativetextedit::selection()
+{
+ QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }";
+ QDeclarativeComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+
+
+ //Test selection follows cursor
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorPosition(), i);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QVERIFY(textEditObject->selectedText().isNull());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setSelectionStart(i);
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textEditObject->setSelectionStart(i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
+ textEditObject->setSelectionEnd(i+1);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textEditObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textEditObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
+ textEditObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textEditObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionEnd(-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionEnd(100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(0);
+ textEditObject->setSelectionEnd(10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionStart(-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionStart(100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionEnd(-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionEnd(100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+}
+
+void tst_qdeclarativetextedit::inputMethodHints()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+}
+
+void tst_qdeclarativetextedit::cursorDelegate()
+{
+ QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
+ view->show();
+ view->setFocus();
+ QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject");
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textEditObject->setFocus(true);
+ QDeclarativeItem* delegateObject = textEditObject->findChild<QDeclarativeItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textEditObject->text().length(); i++){
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
+}
+
+void tst_qdeclarativetextedit::delegateLoading()
+{
+ TestHTTPServer server(42332);
+ server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect);
+ server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
+ server.serveDirectory(SRCDIR "/data/http");
+ QDeclarativeView* view = new QDeclarativeView(0);
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
+ view->show();
+ view->setFocus();
+ QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
+ QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild<QDeclarativeTextEdit*>("textEditObject");
+ // view->rootObject()->dumpObjectTree();
+ QVERIFY(textEditObject != 0);
+ textEditObject->setFocus(true);
+ QDeclarativeItem *delegate;
+ delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateOkay");
+ QVERIFY(delegate);
+ delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateSlow");
+ QVERIFY(delegate);
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
+ view->show();
+ view->setFocus();
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+ view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
+ view->show();
+ view->setFocus();
+ QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
+ //ErrorB should get a component which is ready but component.create() returns null
+ //Not sure how to accomplish this with QDeclarativeTextEdits cursor delegate
+ //###This could be a case of overzealous defensive programming
+ //delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateErrorB");
+ //QVERIFY(!delegate);
+}
+
+/*
+TextEdit element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+*/
+void tst_qdeclarativetextedit::navigation()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == true);
+}
+
+void tst_qdeclarativetextedit::readOnly()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextEdit *edit = qobject_cast<QDeclarativeTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(edit != 0);
+ QTRY_VERIFY(edit->hasFocus() == true);
+ QVERIFY(edit->isReadOnly() == true);
+ QString initial = edit->text();
+ for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ simulateKey(canvas, k);
+ simulateKey(canvas, Qt::Key_Return);
+ simulateKey(canvas, Qt::Key_Space);
+ simulateKey(canvas, Qt::Key_Escape);
+ QCOMPARE(edit->text(), initial);
+}
+
+void tst_qdeclarativetextedit::simulateKey(QDeclarativeView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QApplication::sendEvent(view, &press);
+ QApplication::sendEvent(view, &release);
+}
+
+QDeclarativeView *tst_qdeclarativetextedit::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
+class MyInputContext : public QInputContext
+{
+public:
+ MyInputContext() : softwareInputPanelEventReceived(false) {}
+ ~MyInputContext() {}
+
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {}
+
+ bool isComposing() const { return false; }
+
+ bool filterEvent( const QEvent *event )
+ {
+ if (event->type() == QEvent::RequestSoftwareInputPanel)
+ softwareInputPanelEventReceived = true;
+ return QInputContext::filterEvent(event);
+ }
+ bool softwareInputPanelEventReceived;
+};
+
+void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ MyInputContext ic;
+ view.viewport()->setInputContext(&ic);
+ QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
+ view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ if ((behavior != QStyle::RSIP_OnMouseClick))
+ QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
+ QDeclarativeTextEdit edit;
+ edit.setText("Hello world");
+ edit.setPos(0, 0);
+ scene.addItem(&edit);
+ view.show();
+ qApp->setAutoSipEnabled(true);
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.softwareInputPanelEventReceived, true);
+}
+QTEST_MAIN(tst_qdeclarativetextedit)
+
+#include "tst_qdeclarativetextedit.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/cursorTest.qml b/tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml
index ddc98cc763..ddc98cc763 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/cursorTest.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml b/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml
index b404682b9c..b404682b9c 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/inputmethodhints.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml b/tests/auto/declarative/qdeclarativetextinput/data/masks.qml
index 08a857cea0..08a857cea0 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/masks.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/masks.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml b/tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml
index 7cbeadd027..7cbeadd027 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/maxLength.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml
index 493db5b83c..493db5b83c 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml
index c47371a4ed..c47371a4ed 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/readOnly.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml
index 0c81548dc0..0c81548dc0 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
+++ b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml
diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
new file mode 100644
index 0000000000..5aed51fe58
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetextinput.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
new file mode 100644
index 0000000000..8b513e851a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -0,0 +1,656 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include "../../../shared/util.h"
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QFile>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <private/qdeclarativetextinput_p.h>
+#include <QDebug>
+#include <QStyle>
+#include <QInputContext>
+
+class tst_qdeclarativetextinput : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetextinput();
+
+private slots:
+ void text();
+ void width();
+ void font();
+ void color();
+ void selection();
+
+ void maxLength();
+ void masks();
+ void validators();
+ void inputMethodHints();
+
+ void cursorDelegate();
+ void navigation();
+ void readOnly();
+
+ void sendRequestSoftwareInputPanelEvent();
+
+private:
+ void simulateKey(QDeclarativeView *, int key);
+ QDeclarativeView *createView(const QString &filename);
+
+ QDeclarativeEngine engine;
+ QStringList standard;
+ QStringList colorStrings;
+};
+
+tst_qdeclarativetextinput::tst_qdeclarativetextinput()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "It's supercalifragisiticexpialidocious!"
+ << "Hello, world!";
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+}
+
+void tst_qdeclarativetextinput::text()
+{
+ {
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), standard.at(i));
+ }
+
+}
+
+void tst_qdeclarativetextinput::width()
+{
+ // uses Font metrics to find the width for standard
+ {
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), 1.);//1 for the cursor
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.width(standard.at(i));
+
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
+ }
+}
+
+void tst_qdeclarativetextinput::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().pointSize(), 40);
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().bold(), true);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().italic(), true);
+ QCOMPARE(textinputObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString(""));
+ }
+}
+
+void tst_qdeclarativetextinput::color()
+{
+ //test color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ //test selection color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
+ }
+
+ //test selected text color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), testColor);
+ }
+}
+
+void tst_qdeclarativetextinput::selection()
+{
+ QString testStr = standard[0];
+ QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }";
+ QDeclarativeComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+
+ //Test selection follows cursor
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setCursorPosition(i);
+ QCOMPARE(textinputObject->cursorPosition(), i);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QVERIFY(textinputObject->selectedText().isNull());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionEnd(i+1);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textinputObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(0);
+ textinputObject->setSelectionEnd(10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+}
+
+void tst_qdeclarativetextinput::maxLength()
+{
+ //QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
+ QDeclarativeView *canvas = createView(SRCDIR "/data/maxLength.qml");
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textinputObject != 0);
+ QVERIFY(textinputObject->text().isEmpty());
+ QVERIFY(textinputObject->maxLength() == 10);
+ foreach(const QString &str, standard){
+ QVERIFY(textinputObject->text().length() <= 10);
+ textinputObject->setText(str);
+ QVERIFY(textinputObject->text().length() <= 10);
+ }
+
+ textinputObject->setText("");
+ QTRY_VERIFY(textinputObject->hasFocus() == true);
+ for(int i=0; i<20; i++){
+ QCOMPARE(textinputObject->text().length(), qMin(i,10));
+ //simulateKey(canvas, Qt::Key_A);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ }
+}
+
+void tst_qdeclarativetextinput::masks()
+{
+ //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
+ //QString componentStr = "import Qt 4.6\nTextInput { inputMask: 'HHHHhhhh'; }";
+ QDeclarativeView *canvas = createView(SRCDIR "/data/masks.qml");
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textinputObject != 0);
+ QTRY_VERIFY(textinputObject->hasFocus() == true);
+ QVERIFY(textinputObject->text().length() == 0);
+ QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
+ for(int i=0; i<10; i++){
+ QCOMPARE(qMin(i,8), textinputObject->text().length());
+ QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
+ //simulateKey(canvas, Qt::Key_A);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ }
+}
+
+void tst_qdeclarativetextinput::validators()
+{
+ // Note that this test assumes that the validators are working properly
+ // so you may need to run their tests first. All validators are checked
+ // here to ensure that their exposure to QML is working.
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/validators.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *intInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
+ QVERIFY(intInput);
+ intInput->setFocus(true);
+ QTRY_VERIFY(intInput->hasFocus());
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_2);
+ QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_0);
+ QTest::keyRelease(canvas, Qt::Key_0, Qt::NoModifier ,10);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+
+ QDeclarativeTextInput *dblInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
+ QTRY_VERIFY(dblInput);
+ dblInput->setFocus(true);
+ QVERIFY(dblInput->hasFocus() == true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_2);
+ QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_Period);
+ QTest::keyRelease(canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12."));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+
+ QDeclarativeTextInput *strInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
+ QTRY_VERIFY(strInput);
+ strInput->setFocus(true);
+ QVERIFY(strInput->hasFocus() == true);
+ QTest::keyPress(canvas, Qt::Key_1);
+ QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QEXPECT_FAIL("","Will not work until QTBUG-8025 is resolved", Abort);
+ QCOMPARE(strInput->text(), QLatin1String(""));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("a"));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QTest::keyPress(canvas, Qt::Key_A);
+ QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+}
+
+void tst_qdeclarativetextinput::inputMethodHints()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textinputObject != 0);
+ QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+}
+
+/*
+TextInput element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+
+*/
+void tst_qdeclarativetextinput::navigation()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ input->setCursorPosition(0);
+ QTRY_VERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == true);
+ //QT-2944: If text is selected, then we should deselect first.
+ input->setCursorPosition(input->text().length());
+ input->setSelectionStart(0);
+ input->setSelectionEnd(input->text().length());
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->selectionStart() == input->selectionEnd());
+ QVERIFY(input->selectionStart() == input->text().length());
+ QVERIFY(input->hasFocus() == true);
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->hasFocus() == false);
+ simulateKey(canvas, Qt::Key_Left);
+ QVERIFY(input->hasFocus() == true);
+}
+
+void tst_qdeclarativetextinput::cursorDelegate()
+{
+ QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
+ view->show();
+ view->setFocus();
+ QDeclarativeTextInput *textInputObject = view->rootObject()->findChild<QDeclarativeTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+ QVERIFY(textInputObject->findChild<QDeclarativeItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textInputObject->setFocus(true);
+ QDeclarativeItem* delegateObject = textInputObject->findChild<QDeclarativeItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textInputObject->text().length(); i++){
+ textInputObject->setCursorPosition(i);
+ //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position
+ QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textInputObject->setCursorPosition(0);
+ QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textInputObject->setCursorDelegate(0);
+ QVERIFY(!textInputObject->findChild<QDeclarativeItem*>("cursorInstance"));
+}
+
+void tst_qdeclarativetextinput::readOnly()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");
+ canvas->show();
+ canvas->setFocus();
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasFocus() == true);
+ QVERIFY(input->isReadOnly() == true);
+ QString initial = input->text();
+ for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ simulateKey(canvas, k);
+ simulateKey(canvas, Qt::Key_Return);
+ simulateKey(canvas, Qt::Key_Space);
+ simulateKey(canvas, Qt::Key_Escape);
+ QCOMPARE(input->text(), initial);
+}
+
+void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QApplication::sendEvent(view, &press);
+ QApplication::sendEvent(view, &release);
+}
+
+QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ return canvas;
+}
+
+class MyInputContext : public QInputContext
+{
+public:
+ MyInputContext() : softwareInputPanelEventReceived(false) {}
+ ~MyInputContext() {}
+
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {}
+
+ bool isComposing() const { return false; }
+
+ bool filterEvent( const QEvent *event )
+ {
+ if (event->type() == QEvent::RequestSoftwareInputPanel)
+ softwareInputPanelEventReceived = true;
+ return QInputContext::filterEvent(event);
+ }
+ bool softwareInputPanelEventReceived;
+};
+
+void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ MyInputContext ic;
+ view.viewport()->setInputContext(&ic);
+ QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
+ view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ if ((behavior != QStyle::RSIP_OnMouseClick))
+ QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
+ QDeclarativeTextInput input;
+ input.setText("Hello world");
+ input.setPos(0, 0);
+ scene.addItem(&input);
+ view.show();
+ qApp->setAutoSipEnabled(true);
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
+ QApplication::processEvents();
+ QCOMPARE(ic.softwareInputPanelEventReceived, true);
+}
+
+QTEST_MAIN(tst_qdeclarativetextinput)
+
+#include "tst_qdeclarativetextinput.moc"
diff --git a/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
new file mode 100644
index 0000000000..b162739f21
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetimer/qdeclarativetimer.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativetimer.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
new file mode 100644
index 0000000000..b120d5d5a2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetimer_p.h>
+#include <QDebug>
+
+class tst_qdeclarativetimer : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativetimer();
+
+private slots:
+ void notRepeating();
+ void notRepeatingStart();
+ void repeat();
+ void noTriggerIfNotRunning();
+ void triggeredOnStart();
+ void triggeredOnStartRepeat();
+ void changeDuration();
+ void restart();
+};
+
+class TimerHelper : public QObject
+{
+ Q_OBJECT
+public:
+ TimerHelper() : QObject(), count(0)
+ {
+ }
+
+ int count;
+
+public slots:
+ void timeout() {
+ ++count;
+ }
+};
+
+#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
+// Increase wait as emulator startup can cause unexpected delays
+#define TIMEOUT_TIMEOUT 2000
+#else
+#define TIMEOUT_TIMEOUT 200
+#endif
+
+tst_qdeclarativetimer::tst_qdeclarativetimer()
+{
+}
+
+void tst_qdeclarativetimer::notRepeating()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(timer->isRunning());
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(timer->interval(), 100);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning() == false);
+}
+
+void tst_qdeclarativetimer::notRepeatingStart()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(!timer->isRunning());
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 0);
+
+ timer->start();
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning() == false);
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::repeat()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 0);
+ int oldCount = helper.count;
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+ QVERIFY(timer->isRunning());
+
+ oldCount = helper.count;
+ timer->stop();
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count == oldCount);
+ QVERIFY(timer->isRunning() == false);
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::triggeredOnStart()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(timer->triggeredOnStart());
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QTest::qWait(1);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 2);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning() == false);
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::triggeredOnStartRepeat()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QTest::qWait(1);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 1);
+ int oldCount = helper.count;
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::noTriggerIfNotRunning()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray(
+ "import Qt 4.6\n"
+ "Item { property bool ok: true\n"
+ "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
+ "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
+ "}"
+ ), QUrl::fromLocalFile(""));
+ QObject *item = component.create();
+ QVERIFY(item != 0);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(item->property("ok").toBool(), true);
+
+ delete item;
+}
+
+void tst_qdeclarativetimer::changeDuration()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 2);
+
+ timer->setInterval(500);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 3);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+void tst_qdeclarativetimer::restart()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(QByteArray("import Qt 4.6\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(300);
+
+ timer->restart();
+
+ QTest::qWait(700);
+
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+QTEST_MAIN(tst_qdeclarativetimer)
+
+#include "tst_qdeclarativetimer.moc"
diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml
index ce2e82d0f8..ce2e82d0f8 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml
index c82b533633..c82b533633 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.3.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml
index a8a72f515b..a8a72f515b 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/autoBindingRemoval.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml
index a65218669b..a65218669b 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingAssignment.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml
index fd25c9f0a7..fd25c9f0a7 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingConflict.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml
index 538d776fba..538d776fba 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingRead.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml
index 691a56cc92..691a56cc92 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/bindingVariantCopy.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js
index af298ffbd0..af298ffbd0 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.js
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js
diff --git a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml
index 05459f46f2..05459f46f2 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/deletedObject.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
new file mode 100644
index 0000000000..0eadd507e6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.capitalization: "MixedCase"
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
new file mode 100644
index 0000000000..81f1c922ef
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.capitalization: if (1) "MixedCase"
+}
+
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml
index e1d1ce0962..e1d1ce0962 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml
index b559389efb..b559389efb 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_write.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml
index 913ac50738..913ac50738 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_write.3.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/font_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml
index ff4d0a1004..ff4d0a1004 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/font_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/point_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml
index 3e67de6ccc..3e67de6ccc 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/point_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/point_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml
index 063525a6f0..063525a6f0 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/point_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml
index d845a5be28..d845a5be28 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/pointf_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml
index 9ee3fc1bda..9ee3fc1bda 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/pointf_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml
index 536443148d..536443148d 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rect_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml
index 8add45305c..8add45305c 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rect_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml
index aeb9f413f8..aeb9f413f8 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rectf_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml
index 1e6ff4ff90..1e6ff4ff90 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/rectf_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml
index 96592ebc0d..96592ebc0d 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/scriptAccess.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml
index 29157e8c67..29157e8c67 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/scriptVariantCopy.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/size_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml
index 86dba03224..86dba03224 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/size_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/size_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml
index 2f9d10e45f..2f9d10e45f 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/size_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml
index c6f34e42ca..c6f34e42ca 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/sizef_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml
index f16f0bdf93..f16f0bdf93 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/sizef_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml
index b687f89eef..b687f89eef 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/staticAssignment.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml
index 026ae83444..026ae83444 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/valueInterceptors.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml
index d4d43915ff..d4d43915ff 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/valueSources.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml
index abdf9f04cf..abdf9f04cf 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/vector3d_read.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml
diff --git a/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml
index 9c1bf7620a..9c1bf7620a 100644
--- a/tests/auto/declarative/qmlvaluetypes/data/vector3d_write.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
new file mode 100644
index 0000000000..028fc5754f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+macx:CONFIG -= app_bundle
+
+HEADERS += testtypes.h
+
+SOURCES += tst_qdeclarativevaluetypes.cpp \
+ testtypes.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp
new file mode 100644
index 0000000000..aa8bd6e1bf
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject);
+ QML_REGISTER_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource);
+ QML_REGISTER_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor);
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
new file mode 100644
index 0000000000..dfc28297eb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QObject>
+#include <QPoint>
+#include <QPointF>
+#include <QSize>
+#include <QSizeF>
+#include <QRect>
+#include <QRectF>
+#include <QVector3D>
+#include <QFont>
+#include <qdeclarative.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeProperty>
+#include <private/qdeclarativeproperty_p.h>
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed);
+ Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed);
+ Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed);
+ Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed);
+ Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed);
+ Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed);
+ Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed);
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed);
+
+public:
+ MyTypeObject() :
+ m_point(10, 4),
+ m_pointf(11.3, -10.9),
+ m_size(1912, 1913),
+ m_sizef(0.1, 100923.2),
+ m_rect(2, 3, 109, 102),
+ m_rectf(103.8, 99.2, 88.1, 77.6),
+ m_vector(23.88, 3.1, 4.3)
+ {
+ m_font.setFamily("Arial");
+ m_font.setBold(true);
+ m_font.setWeight(QFont::DemiBold);
+ m_font.setItalic(true);
+ m_font.setUnderline(true);
+ m_font.setOverline(true);
+ m_font.setStrikeOut(true);
+ m_font.setPointSize(29);
+ m_font.setCapitalization(QFont::AllUppercase);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
+ m_font.setWordSpacing(19.7);
+ }
+
+ QPoint m_point;
+ QPoint point() const { return m_point; }
+ void setPoint(const QPoint &v) { m_point = v; emit changed(); }
+
+ QPointF m_pointf;
+ QPointF pointf() const { return m_pointf; }
+ void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
+
+ QSize m_size;
+ QSize size() const { return m_size; }
+ void setSize(const QSize &v) { m_size = v; emit changed(); }
+
+ QSizeF m_sizef;
+ QSizeF sizef() const { return m_sizef; }
+ void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
+
+ QRect m_rect;
+ QRect rect() const { return m_rect; }
+ void setRect(const QRect &v) { m_rect = v; emit changed(); }
+
+ QRectF m_rectf;
+ QRectF rectf() const { return m_rectf; }
+ void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
+
+ QVector3D m_vector;
+ QVector3D vector() const { return m_vector; }
+ void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
+
+ QFont m_font;
+ QFont font() const { return m_font; }
+ void setFont(const QFont &v) { m_font = v; emit changed(); }
+
+ void emitRunScript() { emit runScript(); }
+
+signals:
+ void changed();
+ void runScript();
+};
+QML_DECLARE_TYPE(MyTypeObject);
+
+class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource
+{
+ Q_OBJECT
+public:
+ virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); }
+};
+QML_DECLARE_TYPE(MyConstantValueSource);
+
+class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor
+{
+ Q_OBJECT
+public:
+ virtual void setTarget(const QDeclarativeProperty &p) { prop = p; }
+ virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); }
+
+private:
+ QDeclarativeProperty prop;
+};
+QML_DECLARE_TYPE(MyOffsetValueInterceptor);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
new file mode 100644
index 0000000000..69646b9b61
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -0,0 +1,616 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include <private/qdeclarativevaluetype_p.h>
+#include "testtypes.h"
+
+class tst_qdeclarativevaluetypes : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativevaluetypes() {}
+
+private slots:
+ void initTestCase();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void rect();
+ void rectf();
+ void vector3d();
+ void font();
+
+ void bindingAssignment();
+ void bindingRead();
+ void staticAssignment();
+ void scriptAccess();
+ void autoBindingRemoval();
+ void valueSources();
+ void valueInterceptors();
+ void bindingConflict();
+ void deletedObject();
+ void bindingVariantCopy();
+ void scriptVariantCopy();
+ void cppClasses();
+ void enums();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativevaluetypes::initTestCase()
+{
+ registerTypes();
+}
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+void tst_qdeclarativevaluetypes::point()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("point_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toInt(), 10);
+ QCOMPARE(object->property("p_y").toInt(), 4);
+ QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("point_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->point(), QPoint(11, 12));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::pointf()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("pointf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toDouble(), 11.3);
+ QCOMPARE(object->property("p_y").toDouble(), -10.9);
+ QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("pointf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::size()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("size_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("size_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->size(), QSize(13, 88));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::sizef()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizef_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toDouble(), 0.1);
+ QCOMPARE(object->property("s_height").toDouble(), 100923.2);
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizef_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::rect()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rect_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toInt(), 2);
+ QCOMPARE(object->property("r_y").toInt(), 3);
+ QCOMPARE(object->property("r_width").toInt(), 109);
+ QCOMPARE(object->property("r_height").toInt(), 102);
+ QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rect_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::rectf()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rectf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toDouble(), 103.8);
+ QCOMPARE(object->property("r_y").toDouble(), 99.2);
+ QCOMPARE(object->property("r_width").toDouble(), 88.1);
+ QCOMPARE(object->property("r_height").toDouble(), 77.6);
+ QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("rectf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::vector3d()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector3d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("vector3d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativevaluetypes::font()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("font_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("f_family").toString(), object->font().family());
+ QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
+ QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
+ QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
+ QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
+ QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
+ QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
+ QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
+ QCOMPARE(object->property("f_pixelSize").toInt(), object->font().pixelSize());
+ QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
+ QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
+ QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
+
+ QCOMPARE(object->property("copy"), QVariant(object->font()));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("font_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QFont font;
+ font.setFamily("Helvetica");
+ font.setBold(false);
+ font.setWeight(QFont::Normal);
+ font.setItalic(false);
+ font.setUnderline(false);
+ font.setStrikeOut(false);
+ font.setPointSize(15);
+ font.setCapitalization(QFont::AllLowercase);
+ font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
+ font.setWordSpacing(11.2);
+
+ QEXPECT_FAIL("", "QT-2920", Continue);
+ QCOMPARE(object->font(), font);
+
+ delete object;
+ }
+
+ // Test pixelSize
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("font_write.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+
+ // Test pixelSize and pointSize
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("font_write.3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+}
+
+// Test bindings can write to value types
+void tst_qdeclarativevaluetypes::bindingAssignment()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 92);
+
+ delete object;
+}
+
+// Test bindings can read from value types
+void tst_qdeclarativevaluetypes::bindingRead()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingRead.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 2);
+
+ object->setRect(QRect(19, 3, 88, 2));
+
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+}
+
+// Test static values can assign to value types
+void tst_qdeclarativevaluetypes::staticAssignment()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("staticAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 9);
+
+ delete object;
+}
+
+// Test scripts can read/write value types
+void tst_qdeclarativevaluetypes::scriptAccess()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptAccess.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("valuePre").toInt(), 2);
+ QCOMPARE(object->rect().x(), 19);
+ QCOMPARE(object->property("valuePost").toInt(), 19);
+
+ delete object;
+}
+
+// Test that assigning a constant from script removes any binding
+void tst_qdeclarativevaluetypes::autoBindingRemoval()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect().x(), 42);
+
+ object->setProperty("value", QVariant(92));
+
+ QEXPECT_FAIL("", "QT-2920", Continue);
+ QCOMPARE(object->rect().x(), 42);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
+
+ QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
+
+ QEXPECT_FAIL("", "QT-2920", Continue);
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ delete object;
+ }
+
+}
+
+// Test that property value sources assign to value types
+void tst_qdeclarativevaluetypes::valueSources()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("valueSources.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 3345);
+
+ delete object;
+}
+
+static void checkNoErrors(QDeclarativeComponent& component)
+{
+ QList<QDeclarativeError> errors = component.errors();
+ if (errors.isEmpty())
+ return;
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QDeclarativeError &error = errors.at(ii);
+ qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
+ }
+}
+
+// Test that property value interceptors can be applied to value types
+void tst_qdeclarativevaluetypes::valueInterceptors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("valueInterceptors.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ checkNoErrors(component);
+ QEXPECT_FAIL("", "QT-2920", Abort);
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 26);
+
+ object->setProperty("value", 99);
+
+ QCOMPARE(object->rect().x(), 112);
+
+ delete object;
+}
+
+// Test that you can't assign a binding to the "root" value type, and a sub-property
+void tst_qdeclarativevaluetypes::bindingConflict()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingConflict.qml"));
+ QCOMPARE(component.isError(), true);
+}
+
+#define CPP_TEST(type, v) \
+{ \
+ type *t = new type; \
+ QVariant value(v); \
+ t->setValue(value); \
+ QCOMPARE(t->value(), value); \
+ delete t; \
+}
+
+// Test that accessing a reference to a valuetype after the owning object is deleted
+// doesn't crash
+void tst_qdeclarativevaluetypes::deletedObject()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deletedObject.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "Test: 2");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(dObject != 0);
+ delete dObject;
+
+ QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
+ object->emitRunScript();
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in a binding
+void tst_qdeclarativevaluetypes::bindingVariantCopy()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in script
+void tst_qdeclarativevaluetypes::scriptVariantCopy()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("scriptVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+
+// Test that the value type classes can be used manually
+void tst_qdeclarativevaluetypes::cppClasses()
+{
+ CPP_TEST(QDeclarativePointValueType, QPoint(19, 33));
+ CPP_TEST(QDeclarativePointFValueType, QPointF(33.6, -23));
+ CPP_TEST(QDeclarativeSizeValueType, QSize(-100, 18));
+ CPP_TEST(QDeclarativeSizeFValueType, QSizeF(-100.7, 18.2));
+ CPP_TEST(QDeclarativeRectValueType, QRect(13, 39, 10928, 88));
+ CPP_TEST(QDeclarativeRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
+ CPP_TEST(QDeclarativeVector3DValueType, QVector3D(18.2, 19.7, 1002));
+ CPP_TEST(QDeclarativeFontValueType, QFont("Helvetica"));
+
+}
+
+void tst_qdeclarativevaluetypes::enums()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ delete object;
+ }
+}
+
+QTEST_MAIN(tst_qdeclarativevaluetypes)
+
+#include "tst_qdeclarativevaluetypes.moc"
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.html b/tests/auto/declarative/qdeclarativewebview/data/basic.html
index 22e3e243d0..22e3e243d0 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.ico b/tests/auto/declarative/qdeclarativewebview/data/basic.ico
index 8f3d05e718..8f3d05e718 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.ico
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.ico
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.png b/tests/auto/declarative/qdeclarativewebview/data/basic.png
index 35717cca58..35717cca58 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.png
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.png
Binary files differ
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
index 5394837310..5394837310 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/basic.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/basic.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/elements.html b/tests/auto/declarative/qdeclarativewebview/data/elements.html
index 923686794b..923686794b 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/elements.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/elements.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
index 7c030e6449..7c030e6449 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/elements.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/elements.qml
diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.html b/tests/auto/declarative/qdeclarativewebview/data/forward.html
new file mode 100644
index 0000000000..62ab62da92
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/data/forward.html
@@ -0,0 +1,12 @@
+<html>
+<head><title>Forward</title>
+<link rel="icon" sizes="32x32" href="forward.png">
+</head>
+<body leftmargin="0" marginwidth="0">
+<table width="123">
+<tbody>
+<tr><td>This is more.</td></tr>
+</tbody>
+</table>
+</body>
+</html>
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.html b/tests/auto/declarative/qdeclarativewebview/data/javaScript.html
index 35270bc472..35270bc472 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
index 07eee8885a..07eee8885a 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
index 1460f30990..1460f30990 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/loadError.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html b/tests/auto/declarative/qdeclarativewebview/data/newwindows.html
index dd541f9b16..dd541f9b16 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
index 0bc82633d2..0bc82633d2 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.html b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html
index 9412674091..9412674091 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.html
+++ b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.html
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.qml b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml
index 08e4d65719..08e4d65719 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/pixelCache.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/pixelCache.qml
diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
new file mode 100644
index 0000000000..3dd4e51c2e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+Item {
+ width: 240
+ height: 160
+ Grid {
+ anchors.fill: parent
+ objectName: "newWindowParent"
+ id: newWindowParent
+ }
+
+ Row {
+ anchors.fill: parent
+ id: oldWindowParent
+ objectName: "oldWindowParent"
+ }
+
+ Loader {
+ sourceComponent: webViewComponent
+ }
+ Component {
+ id: webViewComponent
+ WebView {
+ id: webView
+ objectName: "webView"
+ newWindowComponent: webViewComponent
+ newWindowParent: oldWindowParent
+ url: "basic.html"
+ renderingEnabled: true
+ pressGrabTime: 200
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
index 063b5a8c7e..063b5a8c7e 100644
--- a/tests/auto/declarative/qmlgraphicswebview/data/sethtml.qml
+++ b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml
diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
new file mode 100644
index 0000000000..6af0a60048
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+contains(QT_CONFIG,webkit): QT += webkit
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativewebview.cpp testtypes.cpp
+HEADERS += testtypes.h
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp b/tests/auto/declarative/qdeclarativewebview/testtypes.cpp
new file mode 100644
index 0000000000..7efc2143c1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/testtypes.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
+
+void MyWebView::drawContents(QPainter *p, const QRect &r)
+{
+ pp += r.width()*r.height();
+ QDeclarativeWebView::drawContents(p,r);
+}
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Test,1,0,MyWebView,MyWebView);
+}
diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.h b/tests/auto/declarative/qdeclarativewebview/testtypes.h
new file mode 100644
index 0000000000..8eb703f17e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/testtypes.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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
+#define TESTTYPES_H
+
+#include <private/qdeclarativewebview_p.h>
+
+class MyWebView : public QDeclarativeWebView
+{
+ Q_OBJECT
+ Q_PROPERTY(int pixelsPainted READ pixelsPainted);
+
+public:
+ MyWebView() : pp(0) {}
+
+ int pixelsPainted() const { return pp; }
+
+ void drawContents(QPainter *p, const QRect &r);
+
+private:
+ int pp;
+};
+
+QML_DECLARE_TYPE(MyWebView);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
new file mode 100644
index 0000000000..6d1605691e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp
@@ -0,0 +1,513 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/QSignalSpy>
+#include "../../../shared/util.h"
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativewebview_p.h>
+#include <private/qdeclarativewebview_p_p.h>
+#include <private/qdeclarativepositioners_p.h>
+#include <QtWebKit/qwebpage.h>
+#include <QtWebKit/qwebframe.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtGui/qpainter.h>
+#include "testtypes.h"
+
+class tst_qdeclarativewebview : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativewebview() {}
+
+private slots:
+ void initTestCase();
+ void basicProperties();
+ void settings();
+ void historyNav();
+ void multipleWindows();
+ void elementAreaAt();
+ void loadError();
+ void setHtml();
+ void javaScript();
+ void cleanupTestCase();
+ void pixelCache();
+ void newWindowParent();
+ void newWindowComponent();
+ void renderingEnabled();
+ void pressGrabTime();
+
+private:
+ void checkNoErrors(const QDeclarativeComponent& component);
+ QDeclarativeEngine engine;
+ QString tmpDir() const
+ {
+ static QString tmpd = QDir::tempPath()+"/tst_qdeclarativewebview-"
+ + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
+ return tmpd;
+ }
+};
+
+void tst_qdeclarativewebview::initTestCase()
+{
+ registerTypes();
+}
+
+static QString strippedHtml(QString html)
+{
+ html.replace(QRegExp("\\s+"),"");
+ return html;
+}
+
+static QString fileContents(const QString& filename)
+{
+ QFile file(filename);
+ file.open(QIODevice::ReadOnly);
+ return QString::fromUtf8(file.readAll());
+}
+
+
+static void removeRecursive(const QString& dirname)
+{
+ QDir dir(dirname);
+ QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
+ for (int i = 0; i < entries.count(); ++i)
+ if (entries[i].isDir())
+ removeRecursive(entries[i].filePath());
+ else
+ dir.remove(entries[i].fileName());
+ QDir().rmdir(dirname);
+}
+
+void tst_qdeclarativewebview::cleanupTestCase()
+{
+ removeRecursive(tmpDir());
+}
+
+void tst_qdeclarativewebview::checkNoErrors(const QDeclarativeComponent& component)
+{
+ // Wait until the component is ready
+ QTRY_VERIFY(component.isReady());
+
+
+ if (component.isError()) {
+ QList<QDeclarativeError> errors = component.errors();
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QDeclarativeError &error = errors.at(ii);
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" +
+ QByteArray::number(error.column()) + ":" +
+ error.description().toUtf8();
+ qWarning() << errorStr;
+ }
+ }
+ QVERIFY(!component.isError());
+}
+
+void tst_qdeclarativewebview::basicProperties()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
+ checkNoErrors(component);
+ QWebSettings::enablePersistentStorage(tmpDir());
+
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Basic"));
+ QTRY_COMPARE(wv->icon().width(), 48);
+ QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
+ QCOMPARE(wv->statusText(),QString("status here"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->width(), 123.0);
+ QCOMPARE(wv->preferredWidth(), 0);
+ QCOMPARE(wv->preferredHeight(), 0);
+ QCOMPARE(wv->zoomFactor(), 1.0);
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(!wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(!wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+
+ wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything!
+ QCOMPARE(wv->pixelCacheSize(),0);
+ wv->reloadAction()->trigger();
+ QTRY_COMPARE(wv->progress(), 1.0);
+}
+
+void tst_qdeclarativewebview::settings()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QDeclarativeWebSettings *s = wv->settingsObject();
+
+ // merely tests that setting gets stored (in QWebSettings)
+ // behavioural tests are in WebKit.
+ for (int b=0; b<=1; ++b) {
+ bool on = !!b;
+
+ s->setAutoLoadImages(on);
+ s->setDeveloperExtrasEnabled(on);
+ s->setJavaEnabled(on);
+ s->setJavascriptCanAccessClipboard(on);
+ s->setJavascriptCanOpenWindows(on);
+ s->setJavascriptEnabled(on);
+ s->setLinksIncludedInFocusChain(on);
+ s->setLocalContentCanAccessRemoteUrls(on);
+ s->setLocalStorageDatabaseEnabled(on);
+ s->setOfflineStorageDatabaseEnabled(on);
+ s->setOfflineWebApplicationCacheEnabled(on);
+ s->setPluginsEnabled(on);
+ s->setPrintElementBackgrounds(on);
+ s->setPrivateBrowsingEnabled(on);
+ s->setZoomTextOnly(on);
+
+ QVERIFY(s->autoLoadImages() == on);
+ QVERIFY(s->developerExtrasEnabled() == on);
+ QVERIFY(s->javaEnabled() == on);
+ QVERIFY(s->javascriptCanAccessClipboard() == on);
+ QVERIFY(s->javascriptCanOpenWindows() == on);
+ QVERIFY(s->javascriptEnabled() == on);
+ QVERIFY(s->linksIncludedInFocusChain() == on);
+ QVERIFY(s->localContentCanAccessRemoteUrls() == on);
+ QVERIFY(s->localStorageDatabaseEnabled() == on);
+ QVERIFY(s->offlineStorageDatabaseEnabled() == on);
+ QVERIFY(s->offlineWebApplicationCacheEnabled() == on);
+ QVERIFY(s->pluginsEnabled() == on);
+ QVERIFY(s->printElementBackgrounds() == on);
+ QVERIFY(s->privateBrowsingEnabled() == on);
+ QVERIFY(s->zoomTextOnly() == on);
+
+ QVERIFY(s->property("autoLoadImages") == on);
+ QVERIFY(s->property("developerExtrasEnabled") == on);
+ QVERIFY(s->property("javaEnabled") == on);
+ QVERIFY(s->property("javascriptCanAccessClipboard") == on);
+ QVERIFY(s->property("javascriptCanOpenWindows") == on);
+ QVERIFY(s->property("javascriptEnabled") == on);
+ QVERIFY(s->property("linksIncludedInFocusChain") == on);
+ QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
+ QVERIFY(s->property("localStorageDatabaseEnabled") == on);
+ QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
+ QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
+ QVERIFY(s->property("pluginsEnabled") == on);
+ QVERIFY(s->property("printElementBackgrounds") == on);
+ QVERIFY(s->property("privateBrowsingEnabled") == on);
+ QVERIFY(s->property("zoomTextOnly") == on);
+ }
+}
+
+void tst_qdeclarativewebview::historyNav()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
+ checkNoErrors(component);
+ QWebSettings::enablePersistentStorage(tmpDir());
+
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ for (int i=1; i<=2; ++i) {
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Basic"));
+ QTRY_COMPARE(wv->icon().width(), 48);
+ QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
+ QCOMPARE(wv->statusText(),QString("status here"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->width(), 123.0);
+ QCOMPARE(wv->preferredWidth(), 0);
+ QCOMPARE(wv->zoomFactor(), 1.0);
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(!wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(!wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+
+ wv->reloadAction()->trigger();
+ }
+
+ wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Forward"));
+ QTRY_COMPARE(wv->icon().width(), 32);
+ QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/forward.png"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QCOMPARE(wv->statusText(),QString(""));
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(!wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+
+ wv->backAction()->trigger();
+
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString("Basic"));
+ QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
+ QCOMPARE(wv->status(), QDeclarativeWebView::Ready);
+ QVERIFY(wv->reloadAction());
+ QVERIFY(wv->reloadAction()->isEnabled());
+ QVERIFY(wv->backAction());
+ QVERIFY(!wv->backAction()->isEnabled());
+ QVERIFY(wv->forwardAction());
+ QVERIFY(wv->forwardAction()->isEnabled());
+ QVERIFY(wv->stopAction());
+ QVERIFY(!wv->stopAction()->isEnabled());
+}
+
+void tst_qdeclarativewebview::multipleWindows()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/newwindows.qml"));
+ checkNoErrors(component);
+
+ QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(component.create());
+ QVERIFY(grid != 0);
+ QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews
+ QDeclarativeItem* popup = qobject_cast<QDeclarativeItem*>(grid->children().at(3)); // first popup after Component, Loaded, original.
+ QVERIFY(popup != 0);
+ QTRY_COMPARE(popup->x(), 150.0);
+}
+
+void tst_qdeclarativewebview::loadError()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/loadError.qml"));
+ checkNoErrors(component);
+ QWebSettings::enablePersistentStorage(tmpDir());
+
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ for (int i=1; i<=2; ++i) {
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->title(),QString(""));
+ QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message
+ QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
+ QCOMPARE(wv->status(), QDeclarativeWebView::Error);
+
+ wv->reloadAction()->trigger();
+ }
+}
+
+void tst_qdeclarativewebview::setHtml()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
+
+ QSignalSpy spy(wv, SIGNAL(htmlChanged()));
+ wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>"));
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qdeclarativewebview::elementAreaAt()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html
+ QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B
+ QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view
+ QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC
+ QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view
+}
+
+void tst_qdeclarativewebview::javaScript()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml"));
+ checkNoErrors(component);
+ QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123);
+ QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here"));
+ QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue"));
+}
+
+void tst_qdeclarativewebview::pixelCache()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml"));
+ checkNoErrors(component);
+ MyWebView *wv = qobject_cast<MyWebView*>(component.create());
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QPixmap pm(150,150);
+ QPainter p(&pm);
+ wv->paint(&p,0,0);
+ const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area
+ QCOMPARE(wv->pixelsPainted(), expected);
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted
+ wv->setPixelCacheSize(0); // clears the cache
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted
+ // Note that painted things always go into the cache (even if they don't "fit"),
+ // just that they will be removed if anything else needs to be painted.
+ wv->setPixelCacheSize(expected); // won't clear the cache
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected*2); // still there
+ wv->setPixelCacheSize(expected-1); // too small - will clear the cache
+ wv->paint(&p,0,0);
+ QCOMPARE(wv->pixelsPainted(), expected*3); // repainted
+}
+
+void tst_qdeclarativewebview::newWindowParent()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QDeclarativeItem* oldWindowParent = rootItem->findChild<QDeclarativeItem*>("oldWindowParent");
+ QCOMPARE(wv->newWindowParent(), oldWindowParent);
+ QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged()));
+
+ QDeclarativeItem* newWindowParent = rootItem->findChild<QDeclarativeItem*>("newWindowParent");
+ wv->setNewWindowParent(newWindowParent);
+ QVERIFY(oldWindowParent);
+ QVERIFY(oldWindowParent->childItems().count() == 0);
+ QCOMPARE(wv->newWindowParent(), newWindowParent);
+ QCOMPARE(newWindowParentSpy.count(),1);
+
+ wv->setNewWindowParent(newWindowParent);
+ QCOMPARE(newWindowParentSpy.count(),1);
+
+ wv->setNewWindowParent(0);
+ QCOMPARE(newWindowParentSpy.count(),2);
+}
+
+void tst_qdeclarativewebview::newWindowComponent()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QDeclarativeComponent substituteComponent(&engine);
+ substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile(""));
+ QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged()));
+
+ wv->setNewWindowComponent(&substituteComponent);
+ QCOMPARE(wv->newWindowComponent(), &substituteComponent);
+ QCOMPARE(newWindowComponentSpy.count(),1);
+
+ wv->setNewWindowComponent(&substituteComponent);
+ QCOMPARE(newWindowComponentSpy.count(),1);
+
+ wv->setNewWindowComponent(0);
+ QCOMPARE(newWindowComponentSpy.count(),2);
+}
+
+void tst_qdeclarativewebview::renderingEnabled()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+
+ QVERIFY(wv->renderingEnabled());
+ QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged()));
+
+ wv->setRenderingEnabled(false);
+ QVERIFY(!wv->renderingEnabled());
+ QCOMPARE(renderingEnabledSpy.count(),1);
+
+ wv->setRenderingEnabled(false);
+ QCOMPARE(renderingEnabledSpy.count(),1);
+
+ wv->setRenderingEnabled(true);
+ QCOMPARE(renderingEnabledSpy.count(),2);
+}
+
+void tst_qdeclarativewebview::pressGrabTime()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ checkNoErrors(component);
+ QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+ QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView");
+ QVERIFY(rootItem != 0);
+ QVERIFY(wv != 0);
+ QTRY_COMPARE(wv->progress(), 1.0);
+ QCOMPARE(wv->pressGrabTime(), 200);
+ QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged()));
+
+ wv->setPressGrabTime(100);
+ QCOMPARE(wv->pressGrabTime(), 100);
+ QCOMPARE(pressGrabTimeSpy.count(),1);
+
+ wv->setPressGrabTime(100);
+ QCOMPARE(pressGrabTimeSpy.count(),1);
+
+ wv->setPressGrabTime(0);
+ QCOMPARE(pressGrabTimeSpy.count(),2);
+}
+
+QTEST_MAIN(tst_qdeclarativewebview)
+
+#include "tst_qdeclarativewebview.moc"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
index f43e04345b..f43e04345b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
index d7b9266ede..d7b9266ede 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
index 72a45e7caf..72a45e7caf 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
index aa78cde20e..aa78cde20e 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
index 9049fc7004..9049fc7004 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
index 2aa64a3d00..2aa64a3d00 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
index 9255922d55..9255922d55 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
index b2d0209bc8..b2d0209bc8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
index 061d37c0b6..061d37c0b6 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
index 93e44fd9e2..93e44fd9e2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
index 4dcf6f9fd3..4dcf6f9fd3 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/document.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
index e3723619c6..e3723619c6 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/document.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/document.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
index fb693ea193..fb693ea193 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/document.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
index de5ee4f762..de5ee4f762 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/element.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
index 78c0374f8a..78c0374f8a 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/element.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/element.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
index 071ffae057..071ffae057 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/element.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
index 8d67fad3de..8d67fad3de 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
index 37124c76a9..37124c76a9 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
index 505e4b1871..505e4b1871 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
index 20fb040c73..20fb040c73 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
index a740c79cf8..a740c79cf8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
index 2f949e1480..2f949e1480 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
index c4b4bb2763..c4b4bb2763 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
index d5aa4b1c69..d5aa4b1c69 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
index 7538ffdd6d..7538ffdd6d 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
index 3b55802c19..3b55802c19 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
index b8d01c4218..b8d01c4218 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
index b30989bc73..b30989bc73 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
index c06bae3b13..c06bae3b13 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
index b6d4c321aa..b6d4c321aa 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
index 8c86c20771..8c86c20771 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
index 69f79ae531..69f79ae531 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
index a740c79cf8..a740c79cf8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
index 1477279980..1477279980 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
index 19e37fa07f..19e37fa07f 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
index 983ea14522..983ea14522 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
index 6b345ccc21..6b345ccc21 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
index c0321dc344..c0321dc344 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
index f6fabdba4b..f6fabdba4b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
index 95f35e01c7..95f35e01c7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
index 4bb3a7afd1..4bb3a7afd1 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
index 63f288e8fc..63f288e8fc 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
index a33f44bcb5..a33f44bcb5 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
index 0bad7df5d7..0bad7df5d7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
index 81dd4a00e9..81dd4a00e9 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
index 03543a9f35..03543a9f35 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
index 79a27b62b6..79a27b62b6 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
index e0487691f5..e0487691f5 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
index 8fcf3ac8d9..8fcf3ac8d9 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
index 7ab0b278e8..7ab0b278e8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
index 29bf2c216d..29bf2c216d 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
index 97e6facde2..97e6facde2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
index 135f45c6f7..135f45c6f7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
index 4a09527632..4a09527632 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
index dd5fa46d6a..dd5fa46d6a 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
index a740c79cf8..a740c79cf8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect
index 991bd59f95..991bd59f95 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
index 7f51ecfa62..7f51ecfa62 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
index 4600f2abe1..4600f2abe1 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
index b0723aa7a5..b0723aa7a5 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
index 8305ae1f3d..8305ae1f3d 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
index bf31eca4ef..bf31eca4ef 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
index c2bbc6ee29..c2bbc6ee29 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
index 30bc93e129..30bc93e129 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
index ec1c5d8e32..ec1c5d8e32 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
index 2e29f56d41..2e29f56d41 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
index a740c79cf8..a740c79cf8 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.expect
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
index 04202c41c5..04202c41c5 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/status.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
index 8becc3b3d7..8becc3b3d7 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
index 8fe0f4b0e2..8fe0f4b0e2 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
index 4615a07a47..4615a07a47 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/text.qml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
index e7416888fd..e7416888fd 100644
--- a/tests/auto/declarative/qmlxmlhttprequest/data/text.xml
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
new file mode 100644
index 0000000000..7bc92af18a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative network
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../shared/
+HEADERS += ../shared/testhttpserver.h
+
+SOURCES += tst_qdeclarativexmlhttprequest.cpp \
+ ../shared/testhttpserver.cpp
+
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
new file mode 100644
index 0000000000..37d48faa4b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
@@ -0,0 +1,1315 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include <QNetworkCookieJar>
+#include "testhttpserver.h"
+
+#define SERVER_PORT 14445
+
+class tst_qdeclarativexmlhttprequest : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativexmlhttprequest() {}
+
+private slots:
+ void initTestCase() {
+ if (QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')) != QLatin1String("en-US")) {
+ qWarning() << "Test will fail unless LANG is en_US";
+ }
+ }
+
+ void domExceptionCodes();
+ void callbackException();
+ void callbackException_data();
+ void staticStateValues();
+ void instanceStateValues();
+ void constructor();
+ void defaultState();
+ void open();
+ void open_invalid_method();
+ void open_sync();
+ void open_arg_count();
+ void setRequestHeader();
+ void setRequestHeader_unsent();
+ void setRequestHeader_illegalName_data();
+ void setRequestHeader_illegalName();
+ void setRequestHeader_sent();
+ void setRequestHeader_args();
+ void send_unsent();
+ void send_alreadySent();
+ void send_ignoreData();
+ void send_withdata();
+ void abort();
+ void abort_unsent();
+ void abort_opened();
+ void getResponseHeader();
+ void getResponseHeader_unsent();
+ void getResponseHeader_sent();
+ void getResponseHeader_args();
+ void getAllResponseHeaders();
+ void getAllResponseHeaders_unsent();
+ void getAllResponseHeaders_sent();
+ void getAllResponseHeaders_args();
+ void status();
+ void statusText();
+ void responseText();
+ void responseXML_invalid();
+ void invalidMethodUsage();
+ void redirects();
+
+ // Attributes
+ void document();
+ void element();
+ void attr();
+ void text();
+ void cdata();
+
+ // Crashes
+ // void outstanding_request_at_shutdown();
+
+ // void network_errors()
+ // void readyState()
+
+private:
+ QDeclarativeEngine engine;
+};
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
+}
+
+// Test that the dom exception codes are correct
+void tst_qdeclarativexmlhttprequest::domExceptionCodes()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("domExceptionCodes.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("index_size_err").toInt(), 1);
+ QCOMPARE(object->property("domstring_size_err").toInt(), 2);
+ QCOMPARE(object->property("hierarchy_request_err").toInt(), 3);
+ QCOMPARE(object->property("wrong_document_err").toInt(), 4);
+ QCOMPARE(object->property("invalid_character_err").toInt(), 5);
+ QCOMPARE(object->property("no_data_allowed_err").toInt(), 6);
+ QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7);
+ QCOMPARE(object->property("not_found_err").toInt(), 8);
+ QCOMPARE(object->property("not_supported_err").toInt(), 9);
+ QCOMPARE(object->property("inuse_attribute_err").toInt(), 10);
+ QCOMPARE(object->property("invalid_state_err").toInt(), 11);
+ QCOMPARE(object->property("syntax_err").toInt(), 12);
+ QCOMPARE(object->property("invalid_modification_err").toInt(), 13);
+ QCOMPARE(object->property("namespace_err").toInt(), 14);
+ QCOMPARE(object->property("invalid_access_err").toInt(), 15);
+ QCOMPARE(object->property("validation_err").toInt(), 16);
+ QCOMPARE(object->property("type_mismatch_err").toInt(), 17);
+
+ delete object;
+}
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
+
+void tst_qdeclarativexmlhttprequest::callbackException_data()
+{
+ QTest::addColumn<QString>("which");
+ QTest::addColumn<int>("line");
+
+ QTest::newRow("on-opened") << "1" << 15;
+ QTest::newRow("on-loading") << "3" << 15;
+ QTest::newRow("on-done") << "4" << 15;
+}
+
+void tst_qdeclarativexmlhttprequest::callbackException()
+{
+ // Test exception reporting for exceptions thrown at various points.
+
+ QFETCH(QString, which);
+ QFETCH(int, line);
+
+ QString expect = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QDeclarativeComponent component(&engine, TEST_FILE("callbackException.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ object->setProperty("which", which);
+ component.completeCreate();
+
+ TRY_WAIT(object->property("threw").toBool() == true);
+
+ delete object;
+}
+
+// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
+// ### WebKit does not do this, but it seems to fit the standard and QML better
+void tst_qdeclarativexmlhttprequest::staticStateValues()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("staticStateValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("unsent").toInt(), 0);
+ QCOMPARE(object->property("opened").toInt(), 1);
+ QCOMPARE(object->property("headers_received").toInt(), 2);
+ QCOMPARE(object->property("loading").toInt(), 3);
+ QCOMPARE(object->property("done").toInt(), 4);
+
+ delete object;
+}
+
+// Test that the state value properties on instances have the correct values.
+void tst_qdeclarativexmlhttprequest::instanceStateValues()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("instanceStateValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("unsent").toInt(), 0);
+ QCOMPARE(object->property("opened").toInt(), 1);
+ QCOMPARE(object->property("headers_received").toInt(), 2);
+ QCOMPARE(object->property("loading").toInt(), 3);
+ QCOMPARE(object->property("done").toInt(), 4);
+
+ delete object;
+}
+
+// Test calling constructor
+void tst_qdeclarativexmlhttprequest::constructor()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("constructor.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("calledAsConstructor").toBool(), true);
+ QCOMPARE(object->property("calledAsFunction").toBool(), true);
+
+ delete object;
+}
+
+// Test that all the properties are set correctly before any request is sent
+void tst_qdeclarativexmlhttprequest::defaultState()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("defaultState.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("readState").toInt(), 0);
+ QCOMPARE(object->property("statusIsException").toBool(), true);
+ QCOMPARE(object->property("statusTextIsException").toBool(), true);
+ QCOMPARE(object->property("responseText").toString(), QString());
+ QCOMPARE(object->property("responseXMLIsNull").toBool(), true);
+
+ delete object;
+}
+
+// Test valid XMLHttpRequest.open() calls
+void tst_qdeclarativexmlhttprequest::open()
+{
+ // Relative url
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Absolute url
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", TEST_FILE("testdocument.html").toString());
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Absolute network url
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("open.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // User/pass
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("open_user.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ // ### Check that the username/password were sent to the server
+
+ delete object;
+ }
+}
+
+// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
+void tst_qdeclarativexmlhttprequest::open_invalid_method()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("open_invalid_method.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Test that calling XMLHttpRequest.open() with sync raises an exception
+void tst_qdeclarativexmlhttprequest::open_sync()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("open_sync.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Calling with incorrect arg count raises an exception
+void tst_qdeclarativexmlhttprequest::open_arg_count()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("open_arg_count.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("open_arg_count.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+}
+
+// Test valid setRequestHeader() calls
+void tst_qdeclarativexmlhttprequest::setRequestHeader()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
+ TEST_FILE("setRequestHeader.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test setting headers before open() throws exception
+void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName_data()
+{
+ QTest::addColumn<QString>("name");
+
+ QTest::newRow("Accept-Charset") << "AccePT-CHArset";
+ QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding";
+ QTest::newRow("Connection") << "ConnECtion";
+ QTest::newRow("Content-Length") << "ContEnt-LenGth";
+ QTest::newRow("Cookie") << "CookIe";
+ QTest::newRow("Cookie2") << "CoOkie2";
+ QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding";
+ QTest::newRow("Date") << "DaTE";
+ QTest::newRow("Expect") << "ExPect";
+ QTest::newRow("Host") << "HoST";
+ QTest::newRow("Keep-Alive") << "KEEP-aLive";
+ QTest::newRow("Referer") << "ReferEr";
+ QTest::newRow("TE") << "Te";
+ QTest::newRow("Trailer") << "TraILEr";
+ QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding";
+ QTest::newRow("Upgrade") << "UpgrADe";
+ QTest::newRow("User-Agent") << "uSEr-Agent";
+ QTest::newRow("Via") << "vIa";
+ QTest::newRow("Proxy-") << "ProXy-";
+ QTest::newRow("Sec-") << "SeC-";
+ QTest::newRow("Proxy-*") << "Proxy-BLAH";
+ QTest::newRow("Sec-*") << "Sec-F";
+}
+
+// Tests that using illegal header names has no effect
+void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName()
+{
+ QFETCH(QString, name);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_illegalName.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("header", name);
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that attempting to set a header after a request is sent throws an exception
+void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("open_network.expect"),
+ TEST_FILE("open_network.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_sent.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Test that calling send() in UNSENT state throws an exception
+void tst_qdeclarativexmlhttprequest::send_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("send_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test attempting to resend a sent request throws an exception
+void tst_qdeclarativexmlhttprequest::send_alreadySent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("send_alreadySent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that send for a GET or HEAD ignores data
+void tst_qdeclarativexmlhttprequest::send_ignoreData()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"),
+ TEST_FILE("send_ignoreData.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "GET");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_ignoreData_PUT.expect"),
+ TEST_FILE("send_ignoreData.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "HEAD");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+}
+
+// Test that send()'ing data works
+void tst_qdeclarativexmlhttprequest::send_withdata()
+{
+ // No content-type
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.1.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Correct content-type
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.2.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Incorrect content-type
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.3.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Correct content-type - out of order
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.4.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Incorrect content-type - out of order
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.5.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // PUT
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.6.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.6.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ // Correct content-type - no charset
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
+ TEST_FILE("send_data.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("send_data.7.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+}
+
+// Test abort() has no effect in unsent state
+void tst_qdeclarativexmlhttprequest::abort_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("abort_unsent.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() cancels an open (but unsent) request
+void tst_qdeclarativexmlhttprequest::abort_opened()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("abort_opened.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() aborts in progress send
+void tst_qdeclarativexmlhttprequest::abort()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("abort.expect"),
+ TEST_FILE("abort.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("abort.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("seenDone").toBool(), true);
+ QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
+ QCOMPARE(object->property("endStateUnsent").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qdeclarativexmlhttprequest::getResponseHeader()
+{
+ QDeclarativeEngine engine; // Avoid cookie contamination
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
+ TEST_FILE("getResponseHeader.reply"),
+ TEST_FILE("testdocument.html")));
+
+
+ QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("headersReceivedState").toBool(), true);
+ QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true);
+
+ QCOMPARE(object->property("doneState").toBool(), true);
+ QCOMPARE(object->property("doneNullHeader").toBool(), true);
+ QCOMPARE(object->property("doneValidHeader").toBool(), true);
+ QCOMPARE(object->property("doneMultiValidHeader").toBool(), true);
+ QCOMPARE(object->property("doneCookieHeader").toBool(), true);
+
+ delete object;
+}
+
+// Test getResponseHeader throws an exception in an invalid state
+void tst_qdeclarativexmlhttprequest::getResponseHeader_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test getResponseHeader throws an exception in an invalid state
+void tst_qdeclarativexmlhttprequest::getResponseHeader_sent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
+{
+ QDeclarativeEngine engine; // Avoid cookie contamination
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
+ TEST_FILE("getResponseHeader.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("headersReceivedState").toBool(), true);
+ QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
+
+ QCOMPARE(object->property("doneState").toBool(), true);
+ QCOMPARE(object->property("doneHeader").toBool(), true);
+
+ delete object;
+}
+
+// Test getAllResponseHeaders throws an exception in an invalid state
+void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_unsent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test getAllResponseHeaders throws an exception in an invalid state
+void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_sent()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qdeclarativexmlhttprequest::status()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", 200);
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.404.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", 404);
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativexmlhttprequest::statusText()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", "OK");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.404.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", "Document not found");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativexmlhttprequest::responseText()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedText", "QML Rocks!\n");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsent").toBool(), true);
+ QCOMPARE(object->property("opened").toBool(), true);
+ QCOMPARE(object->property("sent").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("reset").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.200.reply"),
+ QUrl()));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsent").toBool(), true);
+ QCOMPARE(object->property("opened").toBool(), true);
+ QCOMPARE(object->property("sent").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("reset").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(TEST_FILE("status.expect"),
+ TEST_FILE("status.404.reply"),
+ TEST_FILE("testdocument.html")));
+
+ QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsent").toBool(), true);
+ QCOMPARE(object->property("opened").toBool(), true);
+ QCOMPARE(object->property("sent").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("reset").toBool(), true);
+
+ delete object;
+ }
+}
+
+// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
+// throws an exception
+void tst_qdeclarativexmlhttprequest::invalidMethodUsage()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("onreadystatechange").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QCOMPARE(object->property("open").toBool(), true);
+ QCOMPARE(object->property("setRequestHeader").toBool(), true);
+ QCOMPARE(object->property("send").toBool(), true);
+ QCOMPARE(object->property("abort").toBool(), true);
+ QCOMPARE(object->property("getResponseHeader").toBool(), true);
+ QCOMPARE(object->property("getAllResponseHeaders").toBool(), true);
+
+ delete object;
+}
+
+// Test that XMLHttpRequest transparently redirects
+void tst_qdeclarativexmlhttprequest::redirects()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
+ server.serveDirectory("data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("redirects.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("done").toBool() == true);
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
+ server.serveDirectory("data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("redirectError.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ TRY_WAIT(object->property("done").toBool() == true);
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
+ server.serveDirectory("data");
+
+ QDeclarativeComponent component(&engine, TEST_FILE("redirectRecur.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ for (int ii = 0; ii < 60; ++ii) {
+ if (object->property("done").toBool()) break;
+ QTest::qWait(50);
+ }
+ QVERIFY(object->property("done").toBool() == true);
+
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qdeclarativexmlhttprequest::responseXML_invalid()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("responseXML_invalid.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlNull").toBool(), true);
+
+ delete object;
+}
+
+// Test the Document DOM element
+void tst_qdeclarativexmlhttprequest::document()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("document.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Element DOM element
+void tst_qdeclarativexmlhttprequest::element()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("element.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Attr DOM element
+void tst_qdeclarativexmlhttprequest::attr()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("attr.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Text DOM element
+void tst_qdeclarativexmlhttprequest::text()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("text.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the CDataSection DOM element
+void tst_qdeclarativexmlhttprequest::cdata()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("cdata.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ TRY_WAIT(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qdeclarativexmlhttprequest)
+
+#include "tst_qdeclarativexmlhttprequest.moc"
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
index 2cbb0276ab..2cbb0276ab 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/model.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model.xml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.xml
index 40cd6d0432..40cd6d0432 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/model.xml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.xml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model2.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model2.qml
index 140e0ada80..140e0ada80 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/model2.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model2.qml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/recipes.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
index 13dea919f3..13dea919f3 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/recipes.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/recipes.xml b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.xml
index d71de60710..d71de60710 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/recipes.xml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.xml
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/roleErrors.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
index 26c533fd45..26c533fd45 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/roleErrors.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
new file mode 100644
index 0000000000..b90e57ef55
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+XmlListModel {
+ query: "/data/item"
+ XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true }
+ XmlRole { name: "age"; query: "age/number()"; isKey: true }
+ XmlRole { name: "sport"; query: "sport/string()" }
+
+ function disableNameKey() {
+ nameRole.isKey = false;
+ }
+}
+
diff --git a/tests/auto/declarative/qmlxmllistmodel/data/unique.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
index ed0f293395..ed0f293395 100644
--- a/tests/auto/declarative/qmlxmllistmodel/data/unique.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
new file mode 100644
index 0000000000..88832dc895
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+contains(QT_CONFIG,xmlpatterns) {
+ QT += xmlpatterns
+ DEFINES += QTEST_XMLPATTERNS
+}
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativexmllistmodel.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
new file mode 100644
index 0000000000..e19e03d0c1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -0,0 +1,457 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtCore/qtimer.h>
+
+#ifdef QTEST_XMLPATTERNS
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativexmllistmodel_p.h>
+#include "../../../shared/util.h"
+
+typedef QPair<int, int> QDeclarativeXmlListRange;
+typedef QList<QVariantList> QDeclarativeXmlModelData;
+
+Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>)
+Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
+
+class tst_qdeclarativexmllistmodel : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativexmllistmodel() {}
+
+private slots:
+ void buildModel();
+ void missingFields();
+ void cdata();
+ void attributes();
+ void roles();
+ void roleErrors();
+ void uniqueRoleNames();
+ void useKeys();
+ void useKeys_data();
+ void noKeysValueChanges();
+ void keysChanged();
+
+private:
+ QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
+ {
+ if (modelData)
+ modelData->clear();
+ QString xml;
+
+ if (!data.isEmpty()) {
+ QStringList items = data.split(";");
+ foreach(const QString &item, items) {
+ QVariantList variants;
+ xml += QLatin1String("<item>");
+ QStringList fields = item.split(",");
+ foreach(const QString &field, fields) {
+ QStringList values = field.split("=");
+ Q_ASSERT(values.count() == 2);
+ xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
+ if (!modelData)
+ continue;
+ bool isNum = false;
+ int number = values[1].toInt(&isNum);
+ if (isNum)
+ variants << number;
+ else
+ variants << values[1];
+ }
+ xml += QLatin1String("</item>");
+ if (modelData)
+ modelData->append(variants);
+ }
+ }
+
+ QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
+ return decl + QLatin1String("<data>") + xml + QLatin1String("</data>");
+ }
+
+ QDeclarativeEngine engine;
+};
+
+void tst_qdeclarativexmllistmodel::buildModel()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
+ QHash<int, QVariant> data = listModel->data(3, roles);
+ QVERIFY(data.count() == 4);
+ QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot"));
+ QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog"));
+ QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9);
+ QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium"));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::missingFields()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model2.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3 << Qt::UserRole + 4;
+ QHash<int, QVariant> data = listModel->data(5, roles);
+ QVERIFY(data.count() == 5);
+ QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String(""));
+ QCOMPARE(data.value(Qt::UserRole+4).toString(), QLatin1String(""));
+
+ data = listModel->data(7, roles);
+ QVERIFY(data.count() == 5);
+ QCOMPARE(data.value(Qt::UserRole+2).toString(), QLatin1String(""));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::cdata()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 5);
+
+ QList<int> roles;
+ roles << Qt::UserRole + 2;
+ QHash<int, QVariant> data = listModel->data(2, roles);
+ QVERIFY(data.count() == 1);
+ QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::attributes()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 5);
+
+ QList<int> roles;
+ roles << Qt::UserRole;
+ QHash<int, QVariant> data = listModel->data(2, roles);
+ QVERIFY(data.count() == 1);
+ QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::roles()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles = listModel->roles();
+ QCOMPARE(roles.count(), 4);
+ QCOMPARE(listModel->toString(roles.at(0)), QLatin1String("name"));
+ QCOMPARE(listModel->toString(roles.at(1)), QLatin1String("type"));
+ QCOMPARE(listModel->toString(roles.at(2)), QLatin1String("age"));
+ QCOMPARE(listModel->toString(roles.at(3)), QLatin1String("size"));
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::roleErrors()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml"));
+ QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5) An XmlRole query must not start with '/'").toUtf8().constData());
+ //### make sure we receive all expected warning messages.
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
+ QHash<int, QVariant> data = listModel->data(3, roles);
+ QVERIFY(data.count() == 4);
+
+ //### should any of these return valid values?
+ QCOMPARE(data.value(Qt::UserRole), QVariant());
+ QCOMPARE(data.value(Qt::UserRole+1), QVariant());
+ QCOMPARE(data.value(Qt::UserRole+2), QVariant());
+
+ QEXPECT_FAIL("", "QT-2456", Continue);
+ QCOMPARE(data.value(Qt::UserRole+3), QVariant());
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::uniqueRoleNames()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml"));
+ QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5) \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
+ QDeclarativeXmlListModel *listModel = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles = listModel->roles();
+ QCOMPARE(roles.count(), 1);
+
+ delete listModel;
+}
+
+void tst_qdeclarativexmllistmodel::useKeys()
+{
+ // If using incremental updates through keys, the model should only
+ // insert & remove some of the items, instead of throwing everything
+ // away and causing the view to repaint the whole view.
+
+ QFETCH(QString, oldXml);
+ QFETCH(int, oldCount);
+ QFETCH(QString, newXml);
+ QFETCH(QDeclarativeXmlModelData, newData);
+ QFETCH(QList<QDeclarativeXmlListRange>, insertRanges);
+ QFETCH(QList<QDeclarativeXmlListRange>, removeRanges);
+
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ model->setXml(oldXml);
+ QTRY_COMPARE(model->count(), oldCount);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ model->setXml(newXml);
+
+ if (oldCount != newData.count()) {
+ QTRY_COMPARE(model->count(), newData.count());
+ QCOMPARE(spyCount.count(), 1);
+ } else {
+ QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
+ QCOMPARE(spyCount.count(), 0);
+ }
+
+ QList<int> roles = model->roles();
+ for (int i=0; i<model->count(); i++) {
+ for (int j=0; j<roles.count(); j++)
+ QCOMPARE(model->data(i, roles[j]), newData[i][j]);
+ }
+
+ QCOMPARE(spyInsert.count(), insertRanges.count());
+ for (int i=0; i<spyInsert.count(); i++) {
+ QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first);
+ QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second);
+ }
+
+ QCOMPARE(spyRemove.count(), removeRanges.count());
+ for (int i=0; i<spyRemove.count(); i++) {
+ QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
+ QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
+ }
+}
+
+void tst_qdeclarativexmllistmodel::useKeys_data()
+{
+ QTest::addColumn<QString>("oldXml");
+ QTest::addColumn<int>("oldCount");
+ QTest::addColumn<QString>("newXml");
+ QTest::addColumn<QDeclarativeXmlModelData>("newData");
+ QTest::addColumn<QList<QDeclarativeXmlListRange> >("insertRanges");
+ QTest::addColumn<QList<QDeclarativeXmlListRange> >("removeRanges");
+
+ QDeclarativeXmlModelData modelData;
+
+ QTest::newRow("append 1")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData)
+ << modelData
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
+ << QList<QDeclarativeXmlListRange>();
+
+ QTest::newRow("append multiple")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
+ << QList<QDeclarativeXmlListRange>();
+
+ QTest::newRow("insert in different spots")
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2))
+ << QList<QDeclarativeXmlListRange>();
+
+ QTest::newRow("insert in middle")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
+ << QList<QDeclarativeXmlListRange>();
+
+ QTest::newRow("remove first")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData)
+ << modelData
+ << QList<QDeclarativeXmlListRange>()
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
+
+ QTest::newRow("remove last")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
+ << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData)
+ << modelData
+ << QList<QDeclarativeXmlListRange>()
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1));
+
+ QTest::newRow("remove from multiple spots")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << QList<QDeclarativeXmlListRange>()
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1) << qMakePair(3,2));
+
+ QTest::newRow("remove all")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
+ << makeItemXmlAndData("", &modelData)
+ << modelData
+ << QList<QDeclarativeXmlListRange>()
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 3));
+
+ QTest::newRow("replace item")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
+ << modelData
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1))
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
+
+ QTest::newRow("add and remove simultaneously")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
+ << modelData
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
+ << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
+}
+
+void tst_qdeclarativexmllistmodel::noKeysValueChanges()
+{
+ // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml.
+ // If a 'sport' value is changed, the model should not be reloaded,
+ // since 'sport' is not marked as a key.
+
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml;
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setXml(xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
+ model->setXml(xml);
+
+ // wait for the new xml data to be set, and verify no signals were emitted
+ for (int i=0; i<50; i++) {
+ QTest::qWait(100);
+ if (model->data(0, model->roles()[2]).toString() != QLatin1String("AussieRules"))
+ break;
+ }
+ QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
+
+ QVERIFY(spyInsert.count() == 0);
+ QVERIFY(spyRemove.count() == 0);
+ QVERIFY(spyCount.count() == 0);
+
+ QCOMPARE(model->count(), 2);
+}
+
+void tst_qdeclarativexmllistmodel::keysChanged()
+{
+ // If the key roles change, the next time the data is reloaded, it should
+ // delete all its data and build a clean model (i.e. same behaviour as
+ // if no keys are set).
+
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setXml(xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
+ model->setXml(xml);
+
+ QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
+
+ QCOMPARE(spyInsert.count(), 1);
+ QCOMPARE(spyInsert[0][0].toInt(), 0);
+ QCOMPARE(spyInsert[0][1].toInt(), 2);
+
+ QCOMPARE(spyRemove.count(), 1);
+ QCOMPARE(spyRemove[0][0].toInt(), 0);
+ QCOMPARE(spyRemove[0][1].toInt(), 2);
+
+ QCOMPARE(spyCount.count(), 0);
+}
+
+QTEST_MAIN(tst_qdeclarativexmllistmodel)
+
+#include "tst_qdeclarativexmllistmodel.moc"
+
+#else
+QTEST_NOOP_MAIN
+#endif
diff --git a/tests/auto/declarative/qmlanimations/qmlanimations.pro b/tests/auto/declarative/qmlanimations/qmlanimations.pro
deleted file mode 100644
index 447fb0fd0b..0000000000
--- a/tests/auto/declarative/qmlanimations/qmlanimations.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlanimations.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
deleted file mode 100644
index 9eae308cac..0000000000
--- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp
+++ /dev/null
@@ -1,672 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlanimation_p.h>
-#include <QVariantAnimation>
-
-class tst_qmlanimations : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlanimations() {}
-
-private slots:
- void initTestCase() { QmlEngine engine; } // ensure types are registered
-
- void simpleProperty();
- void simpleNumber();
- void simpleColor();
- void alwaysRunToEnd();
- void complete();
- void resume();
- void dotProperty();
- void badTypes();
- void badProperties();
- void mixedTypes();
- void properties();
- void propertiesTransition();
- void easingStringConversion();
- void invalidDuration();
- void attached();
- void propertyValueSourceDefaultStart();
- void dontStart();
-};
-
-#define QTIMED_COMPARE(lhs, rhs) do { \
- for (int ii = 0; ii < 5; ++ii) { \
- if (lhs == rhs) \
- break; \
- QTest::qWait(50); \
- } \
- QCOMPARE(lhs, rhs); \
-} while (false)
-
-void tst_qmlanimations::simpleProperty()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("pos");
- animation.setTo(QPointF(200,200));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "pos");
- QVERIFY(animation.to().toPointF() == QPointF(200,200));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.pos(), QPointF(200,200));
-
- rect.setPos(0,0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.pos(), QPointF(100,100));
-}
-
-void tst_qmlanimations::simpleNumber()
-{
- QmlGraphicsRectangle rect;
- QmlNumberAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to() == 200);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.x(), qreal(200));
-
- rect.setX(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(), qreal(100));
-}
-
-void tst_qmlanimations::simpleColor()
-{
- QmlGraphicsRectangle rect;
- QmlColorAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("color");
- animation.setTo(QColor("red"));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "color");
- QVERIFY(animation.to() == QColor("red"));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.color(), QColor("red"));
-
- rect.setColor(QColor("blue"));
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-
- rect.setColor(QColor("green"));
- animation.setFrom(QColor("blue"));
- QVERIFY(animation.from() == QColor("blue"));
- animation.restart();
- QCOMPARE(rect.color(), QColor("blue"));
- QVERIFY(animation.isRunning());
- animation.setCurrentTime(125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-}
-
-void tst_qmlanimations::alwaysRunToEnd()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setRepeat(true);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.repeat() == true);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- QTest::qWait(1500);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(500);
- QTIMED_COMPARE(rect.x(), qreal(200));
-}
-
-void tst_qmlanimations::complete()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setFrom(1);
- animation.setTo(200);
- animation.setDuration(500);
- QVERIFY(animation.from() == 1);
- animation.start();
- QTest::qWait(50);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- animation.start();
- QTest::qWait(50);
- QVERIFY(animation.isRunning());
- animation.complete();
- QCOMPARE(rect.x(), qreal(200));
-}
-
-void tst_qmlanimations::resume()
-{
- QmlGraphicsRectangle rect;
- QmlPropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setFrom(10);
- animation.setTo(200);
- animation.setDuration(500);
- QVERIFY(animation.from() == 10);
-
- animation.start();
- QTest::qWait(100);
- animation.pause();
- qreal x = rect.x();
- QVERIFY(x != qreal(200));
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
-
- animation.resume();
- QVERIFY(animation.isRunning());
- QVERIFY(!animation.isPaused());
- QTest::qWait(100);
- animation.stop();
- QVERIFY(rect.x() > x);
-}
-
-void tst_qmlanimations::dotProperty()
-{
- QmlGraphicsRectangle rect;
- QmlNumberAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("border.width");
- animation.setTo(10);
- animation.start();
- QTest::qWait(animation.duration()+50);
- QTIMED_COMPARE(rect.border()->width(), 10);
-
- rect.border()->setWidth(0);
- animation.start();
- animation.pause();
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.border()->width(), 5);
-}
-
-void tst_qmlanimations::badTypes()
-{
- //don't crash
- {
- QmlView *view = new QmlView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
-
- view->execute();
- qApp->processEvents();
-
- delete view;
- }
-
- //make sure we get a compiler error
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected"));
- }
-
- //make sure we get a compiler error
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
- }
-
- //don't crash
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("state1");
- QTest::qWait(1000 + 50);
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("MyRect");
- QVERIFY(myRect);
- QCOMPARE(myRect->x(),qreal(200));
- }
-}
-
-void tst_qmlanimations::badProperties()
-{
- //make sure we get a runtime error
- {
- QmlEngine engine;
-
- QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml"));
- QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c1.create());
- QVERIFY(rect);
-
- QmlComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml"));
- message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- rect = qobject_cast<QmlGraphicsRectangle*>(c2.create());
- QVERIFY(rect);
-
- //### should we warn here are well?
- //rect->setState("state1");
- }
-}
-
-//test animating mixed types with property animation in a transition
-//for example, int + real; color + real; etc
-void tst_qmlanimations::mixedTypes()
-{
- //assumes border.width stays a real -- not real robust
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("state1");
- QTest::qWait(500);
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("state1");
- QTest::qWait(500);
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
- }
-}
-
-void tst_qmlanimations::properties()
-{
- const int waitDuration = 300;
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(300));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-}
-
-void tst_qmlanimations::propertiesTransition()
-{
- const int waitDuration = 300;
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- /*{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect");
- QVERIFY(myRect);
- rect->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }*/
-}
-
-void tst_qmlanimations::easingStringConversion()
-{
- QmlNumberAnimation *animation = new QmlNumberAnimation;
- animation->setEasing("easeInOutQuad");
- QCOMPARE(animation->easing(),QLatin1String("easeInOutQuad"));
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutQuad));
-
- animation->setEasing("OutQuad");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::OutQuad));
-
- animation->setEasing("easeOutBounce(amplitude: 5)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutBounce);
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5));
-
- animation->setEasing("easeOutElastic(amplitude: 5, period: 3)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutElastic);
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5));
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().period(), qreal(3));
-
- animation->setEasing("easeInOutBack(overshoot: 2)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutBack);
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().overshoot(), qreal(2));
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unmatched parenthesis in easing function \"easeInOutBack(overshoot: 2\"");
- animation->setEasing("easeInOutBack(overshoot: 2");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Easing function \"InOutBack(overshoot: 2)\" must start with \"ease\"");
- animation->setEasing("InOutBack(overshoot: 2)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\"");
- animation->setEasing("NonExistantEase");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude 5)\"");
- animation->setEasing("easeInOutElastic(amplitude 5)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic);
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude: yes)\"");
- animation->setEasing("easeInOutElastic(amplitude: yes)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic);
- QVERIFY(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5));
-
- QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistentproperty\"");
- animation->setEasing("easeOutQuad(nonexistentproperty: 12)");
- QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad);
-
- delete animation;
-}
-
-void tst_qmlanimations::invalidDuration()
-{
- QmlPropertyAnimation *animation = new QmlPropertyAnimation;
- QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0");
- animation->setDuration(-1);
- QCOMPARE(animation->duration(), 250);
-
- QmlPauseAnimation *pauseAnimation = new QmlPauseAnimation;
- QTest::ignoreMessage(QtWarningMsg, "QML PauseAnimation (unknown location) Cannot set a duration of < 0");
- pauseAnimation->setDuration(-1);
- QCOMPARE(pauseAnimation->duration(), 250);
-}
-
-void tst_qmlanimations::attached()
-{
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml"));
- QTest::ignoreMessage(QtDebugMsg, "off");
- QTest::ignoreMessage(QtDebugMsg, "on");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-}
-
-void tst_qmlanimations::propertyValueSourceDefaultStart()
-{
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml"));
-
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning());
- }
-
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml"));
-
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning() == false);
- }
-
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml"));
-
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-}
-
-
-void tst_qmlanimations::dontStart()
-{
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
-
- QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-
- {
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml"));
-
- QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-}
-
-QTEST_MAIN(tst_qmlanimations)
-
-#include "tst_qmlanimations.moc"
diff --git a/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro b/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro
deleted file mode 100644
index 1e685eecc3..0000000000
--- a/tests/auto/declarative/qmlbehaviors/qmlbehaviors.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlbehaviors.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
deleted file mode 100644
index e31b6004ef..0000000000
--- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp
+++ /dev/null
@@ -1,301 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlbehavior_p.h>
-#include <private/qmlanimation_p.h>
-
-class tst_qmlbehaviors : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlbehaviors() {}
-
-private slots:
- void simpleBehavior();
- void scriptTriggered();
- void cppTriggered();
- void loop();
- void colorBehavior();
- void parentBehavior();
- void replaceBinding();
- //void transitionOverrides();
- void group();
- void emptyBehavior();
- void explicitSelection();
- void nonSelectingBehavior();
- void reassignedAnimation();
- void disabled();
- void dontStart();
-};
-
-void tst_qmlbehaviors::simpleBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
- QVERIFY(qobject_cast<QmlBehavior*>(rect->findChild<QmlBehavior*>("MyBehavior"))->animation());
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::scriptTriggered()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setColor(QColor("red"));
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::cppTriggered()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect);
-
- innerRect->setProperty("x", 200);
- QTest::qWait(200);
- qreal x = innerRect->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::loop()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- //don't crash
- rect->setState("moved");
-}
-
-void tst_qmlbehaviors::colorBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("red");
- QTest::qWait(200);
- QColor color = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->color();
- QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered
-}
-
-void tst_qmlbehaviors::parentBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("reparented");
- QTest::qWait(200);
- QmlGraphicsItem *newParent = rect->findChild<QmlGraphicsItem*>("NewParent");
- QmlGraphicsItem *parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem();
- QVERIFY(parent != newParent);
- QTest::qWait(600);
- parent = rect->findChild<QmlGraphicsRectangle*>("MyRect")->parentItem();
- QVERIFY(parent == newParent);
-}
-
-void tst_qmlbehaviors::replaceBinding()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect);
- qreal x = innerRect->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("basex", 10);
- QCOMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("movedx", 210);
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)210);
-
- rect->setState("");
- QTest::qWait(200);
- x = innerRect->x();
- QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("movedx", 200);
- QCOMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("basex", 20);
- QTest::qWait(600);
- QCOMPARE(innerRect->x(), (qreal)20);
-}
-
-void tst_qmlbehaviors::group()
-{
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- }
-
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- }
-}
-
-void tst_qmlbehaviors::emptyBehavior()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-}
-
-void tst_qmlbehaviors::explicitSelection()
-{
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- QTest::qWait(200);
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered
- }
-}
-
-void tst_qmlbehaviors::nonSelectingBehavior()
-{
- {
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- rect->setState("moved");
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
- }
-}
-
-void tst_qmlbehaviors::reassignedAnimation()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
- QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData());
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(qobject_cast<QmlNumberAnimation*>(
- qobject_cast<QmlBehavior*>(
- rect->findChild<QmlBehavior*>("MyBehavior"))->animation())->duration(), 200);
-}
-
-void tst_qmlbehaviors::disabled()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(rect->findChild<QmlBehavior*>("MyBehavior")->enabled(), false);
-
- rect->setState("moved");
- qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-}
-
-void tst_qmlbehaviors::dontStart()
-{
- QmlEngine engine;
-
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
-
- QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
- QVERIFY(rect);
-
- QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
-}
-
-QTEST_MAIN(tst_qmlbehaviors)
-
-#include "tst_qmlbehaviors.moc"
diff --git a/tests/auto/declarative/qmlbinding/qmlbinding.pro b/tests/auto/declarative/qmlbinding/qmlbinding.pro
deleted file mode 100644
index dfaca9123f..0000000000
--- a/tests/auto/declarative/qmlbinding/qmlbinding.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlbinding.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp b/tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp
deleted file mode 100644
index 92d1b69df6..0000000000
--- a/tests/auto/declarative/qmlbinding/tst_qmlbinding.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlbind_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlbinding : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlbinding();
-
-private slots:
- void binding();
- void whenAfterValue();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlbinding::tst_qmlbinding()
-{
-}
-
-void tst_qmlbinding::binding()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
-
- QVERIFY(rect != 0);
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- QmlBind *binding = qobject_cast<QmlBind*>(rect->findChild<QmlBind*>("binding1"));
- QVERIFY(binding != 0);
- QCOMPARE(binding->object(), rect);
- QCOMPARE(binding->property(), QLatin1String("text"));
- QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
-
- delete rect;
-}
-
-void tst_qmlbinding::whenAfterValue()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create());
-
- QVERIFY(rect != 0);
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qmlbinding)
-
-#include "tst_qmlbinding.moc"
diff --git a/tests/auto/declarative/qmlconnection/data/test-connection.qml b/tests/auto/declarative/qmlconnection/data/test-connection.qml
deleted file mode 100644
index 9534621055..0000000000
--- a/tests/auto/declarative/qmlconnection/data/test-connection.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import Qt 4.6
-
-Item {
- id: screen; width: 50
-
- property bool tested: false
- signal testMe
-
- Connection { sender: screen; signal: "widthChanged()"; script: screen.tested = true }
-}
diff --git a/tests/auto/declarative/qmlconnection/data/test-connection2.qml b/tests/auto/declarative/qmlconnection/data/test-connection2.qml
deleted file mode 100644
index 65fe23a0f8..0000000000
--- a/tests/auto/declarative/qmlconnection/data/test-connection2.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import Qt 4.6
-
-Connection { id: connection; sender: connection; signal: "widthChanged()"; script: 1 == 1 }
diff --git a/tests/auto/declarative/qmlconnection/data/test-connection3.qml b/tests/auto/declarative/qmlconnection/data/test-connection3.qml
deleted file mode 100644
index 32133f9edf..0000000000
--- a/tests/auto/declarative/qmlconnection/data/test-connection3.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import Qt 4.6
-
-Connection {}
diff --git a/tests/auto/declarative/qmlconnection/data/trimming.qml b/tests/auto/declarative/qmlconnection/data/trimming.qml
deleted file mode 100644
index c27dc46973..0000000000
--- a/tests/auto/declarative/qmlconnection/data/trimming.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import Qt 4.6
-
-Item {
- id: screen; width: 50
-
- property string tested
- signal testMe(int param1, string param2)
-
- Connection { sender: screen; signal: "testMe(param1, param2)"; script: screen.tested = param2 + param1 }
-}
diff --git a/tests/auto/declarative/qmlconnection/qmlconnection.pro b/tests/auto/declarative/qmlconnection/qmlconnection.pro
deleted file mode 100644
index 3d46fa6185..0000000000
--- a/tests/auto/declarative/qmlconnection/qmlconnection.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlconnection.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp b/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp
deleted file mode 100644
index 2aba7b53bc..0000000000
--- a/tests/auto/declarative/qmlconnection/tst_qmlconnection.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlconnection_p.h>
-#include <private/qmlgraphicsitem_p.h>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qmlscriptstring.h>
-
-class tst_qmlconnection : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlconnection();
-
-private slots:
- void defaultValues();
- void properties();
- void connection();
- void trimming();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlconnection::tst_qmlconnection()
-{
-}
-
-void tst_qmlconnection::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml"));
- QmlConnection *item = qobject_cast<QmlConnection*>(c.create());
-
- QVERIFY(item != 0);
- QVERIFY(item->signalSender() == 0);
- QCOMPARE(item->script().script(), QString());
- QCOMPARE(item->signal(), QString());
-
- delete item;
-}
-
-void tst_qmlconnection::properties()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml"));
- QmlConnection *item = qobject_cast<QmlConnection*>(c.create());
-
- QVERIFY(item != 0);
-
- QVERIFY(item != 0);
- QVERIFY(item->signalSender() == item);
- QCOMPARE(item->script().script(), QString("1 == 1"));
- QCOMPARE(item->signal(), QString("widthChanged()"));
-
- delete item;
-}
-
-void tst_qmlconnection::connection()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toBool(), false);
- QCOMPARE(item->width(), 50.);
- emit item->setWidth(100.);
- QCOMPARE(item->width(), 100.);
- QCOMPARE(item->property("tested").toBool(), true);
-
- delete item;
-}
-
-void tst_qmlconnection::trimming()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toString(), QString(""));
- int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
- QMetaMethod method = item->metaObject()->method(index);
- method.invoke(item,
- Qt::DirectConnection,
- Q_ARG(int, 5),
- Q_ARG(QString, "worked"));
- QCOMPARE(item->property("tested").toString(), QString("worked5"));
-
- delete item;
-}
-
-QTEST_MAIN(tst_qmlconnection)
-
-#include "tst_qmlconnection.moc"
diff --git a/tests/auto/declarative/qmlcontext/qmlcontext.pro b/tests/auto/declarative/qmlcontext/qmlcontext.pro
deleted file mode 100644
index 9e6642957a..0000000000
--- a/tests/auto/declarative/qmlcontext/qmlcontext.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlcontext.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp b/tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp
deleted file mode 100644
index 7ff7af2ed9..0000000000
--- a/tests/auto/declarative/qmlcontext/tst_qmlcontext.cpp
+++ /dev/null
@@ -1,434 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QDebug>
-#include <QmlEngine>
-#include <QmlContext>
-#include <QmlComponent>
-#include <QmlExpression>
-
-class tst_qmlcontext : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlcontext() {}
-
-private slots:
- void baseUrl();
- void resolvedUrl();
- void engineMethod();
- void parentContext();
- void setContextProperty();
- void addDefaultObject();
- void destruction();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlcontext::baseUrl()
-{
- QmlContext ctxt(&engine);
-
- QCOMPARE(ctxt.baseUrl(), QUrl());
-
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
-}
-
-void tst_qmlcontext::resolvedUrl()
-{
- // Relative to the component
- {
- QmlContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml"));
- }
-
- // Relative to a parent
- {
- QmlContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QmlContext ctxt2(&ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- }
-
- // Relative to the engine
- {
- QmlContext ctxt(&engine);
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
- }
-
- // Relative to a deleted parent
- {
- QmlContext *ctxt = new QmlContext(&engine);
- ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QmlContext ctxt2(ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl());
- }
-
- // Absolute
- {
- QmlContext ctxt(&engine);
-
- QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml"));
- }
-}
-
-void tst_qmlcontext::engineMethod()
-{
- QmlEngine *engine = new QmlEngine;
-
- QmlContext ctxt(engine);
- QmlContext ctxt2(&ctxt);
- QmlContext ctxt3(&ctxt2);
- QmlContext ctxt4(&ctxt2);
-
- QCOMPARE(ctxt.engine(), engine);
- QCOMPARE(ctxt2.engine(), engine);
- QCOMPARE(ctxt3.engine(), engine);
- QCOMPARE(ctxt4.engine(), engine);
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt.engine(), engine);
- QCOMPARE(ctxt2.engine(), engine);
- QCOMPARE(ctxt3.engine(), engine);
- QCOMPARE(ctxt4.engine(), engine);
-}
-
-void tst_qmlcontext::parentContext()
-{
- QmlEngine *engine = new QmlEngine;
-
- QCOMPARE(engine->rootContext()->parentContext(), (QmlContext *)0);
-
- QmlContext *ctxt = new QmlContext(engine);
- QmlContext *ctxt2 = new QmlContext(ctxt);
- QmlContext *ctxt3 = new QmlContext(ctxt2);
- QmlContext *ctxt4 = new QmlContext(ctxt2);
- QmlContext *ctxt5 = new QmlContext(ctxt);
- QmlContext *ctxt6 = new QmlContext(engine);
- QmlContext *ctxt7 = new QmlContext(engine->rootContext());
-
- QCOMPARE(ctxt->parentContext(), engine->rootContext());
- QCOMPARE(ctxt2->parentContext(), ctxt);
- QCOMPARE(ctxt3->parentContext(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete ctxt2; ctxt2 = 0;
-
- QCOMPARE(ctxt->parentContext(), engine->rootContext());
- QCOMPARE(ctxt3->parentContext(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt->parentContext(), (QmlContext *)0);
- QCOMPARE(ctxt3->parentContext(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), (QmlContext *)0);
- QCOMPARE(ctxt7->parentContext(), (QmlContext *)0);
-
- delete ctxt7;
- delete ctxt6;
- delete ctxt5;
- delete ctxt4;
- delete ctxt3;
- delete ctxt;
-}
-
-class TestObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int a READ a NOTIFY aChanged)
- Q_PROPERTY(int b READ b NOTIFY bChanged)
- Q_PROPERTY(int c READ c NOTIFY cChanged)
-
-public:
- TestObject() : _a(10), _b(10), _c(10) {}
-
- int a() const { return _a; }
- void setA(int a) { _a = a; emit aChanged(); }
-
- int b() const { return _b; }
- void setB(int b) { _b = b; emit bChanged(); }
-
- int c() const { return _c; }
- void setC(int c) { _c = c; emit cChanged(); }
-
-signals:
- void aChanged();
- void bChanged();
- void cChanged();
-
-private:
- int _a;
- int _b;
- int _c;
-};
-
-class TestObject2 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int b READ b NOTIFY bChanged)
-
-public:
- TestObject2() : _b(10) {}
-
- int b() const { return _b; }
- void setB(int b) { _b = b; emit bChanged(); }
-
-signals:
- void bChanged();
-
-private:
- int _b;
-};
-
-#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
-{ \
- QmlComponent component(&engine); \
- component.setData("import Qt 4.6; QtObject { property var test: " #name " }", QUrl()); \
-\
- QObject *obj = component.create(ctxt); \
-\
- QCOMPARE(obj->property("test"), value); \
-\
- delete obj; \
-}
-
-void tst_qmlcontext::setContextProperty()
-{
- QmlContext ctxt(&engine);
- QmlContext ctxt2(&ctxt);
-
- TestObject obj1;
- obj1.setA(3345);
- TestObject obj2;
- obj2.setA(-19);
-
- // Static context properties
- ctxt.setContextProperty("a", QVariant(10));
- ctxt.setContextProperty("b", QVariant(9));
- ctxt2.setContextProperty("d", &obj2);
- ctxt2.setContextProperty("b", QVariant(19));
- ctxt2.setContextProperty("c", QVariant(QString("Hello World!")));
- ctxt.setContextProperty("d", &obj1);
- ctxt.setContextProperty("e", &obj1);
-
- TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10));
- TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19));
- TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!")));
- TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19));
- TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345));
-
- ctxt.setContextProperty("a", QVariant(13));
- ctxt.setContextProperty("b", QVariant(4));
- ctxt2.setContextProperty("b", QVariant(8));
- ctxt2.setContextProperty("c", QVariant(QString("Hi World!")));
- ctxt2.setContextProperty("d", &obj1);
- obj1.setA(12);
-
- TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13));
- TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8));
- TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!")));
- TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12));
-
- // Changes in context properties
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(13));
- ctxt.setContextProperty("a", QVariant(19));
- QCOMPARE(obj->property("test"), QVariant(19));
-
- delete obj;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var test: b }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(8));
- ctxt.setContextProperty("b", QVariant(5));
- QCOMPARE(obj->property("test"), QVariant(8));
- ctxt2.setContextProperty("b", QVariant(1912));
- QCOMPARE(obj->property("test"), QVariant(1912));
-
- delete obj;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var test: e.a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(12));
- obj1.setA(13);
- QCOMPARE(obj->property("test"), QVariant(13));
-
- delete obj;
- }
-
- // New context properties
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(19));
- ctxt2.setContextProperty("a", QVariant(1945));
- QCOMPARE(obj->property("test"), QVariant(1945));
-
- delete obj;
- }
-
- // Setting an object-variant context property
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property var obj: root; }", QUrl());
-
- QmlContext ctxt(engine.rootContext());
- ctxt.setContextProperty("ctxtProp", QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Result of expression 'ctxtProp' [undefined] is not an object.");
- QObject *obj = component.create(&ctxt);
-
- QVariant v = obj->property("obj");
-
- ctxt.setContextProperty("ctxtProp", v);
-
- QCOMPARE(obj->property("test"), QVariant(10));
-
- delete obj;
- }
-}
-
-void tst_qmlcontext::addDefaultObject()
-{
- QmlContext ctxt(&engine);
-
- TestObject to;
- TestObject2 to2;
-
- to.setA(2);
- to.setB(192);
- to.setC(18);
- to2.setB(111999);
-
- ctxt.addDefaultObject(&to2);
- ctxt.addDefaultObject(&to);
- ctxt.setContextProperty("c", QVariant(9));
-
- // Static context properties
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(111999));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
-
- to.setA(12);
- to.setB(100);
- to.setC(7);
- to2.setB(1612);
- ctxt.setContextProperty("c", QVariant(3));
-
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(1612));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
-
- // Changes in context properties
- {
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; QtObject { property var test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt);
-
- QCOMPARE(obj->property("test"), QVariant(12));
- to.setA(14);
- QCOMPARE(obj->property("test"), QVariant(14));
-
- delete obj;
- }
-}
-
-void tst_qmlcontext::destruction()
-{
- QmlContext *ctxt = new QmlContext(&engine);
-
- QObject obj;
- QmlEngine::setContextForObject(&obj, ctxt);
- QmlExpression expr(ctxt, "a", 0);
-
- QCOMPARE(ctxt, QmlEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt, QmlEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-}
-
-QTEST_MAIN(tst_qmlcontext)
-
-#include "tst_qmlcontext.moc"
diff --git a/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro b/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro
deleted file mode 100644
index 2b1947d5cd..0000000000
--- a/tests/auto/declarative/qmldatetimeformatter/qmldatetimeformatter.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmldatetimeformatter.cpp
diff --git a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
deleted file mode 100644
index 4b5dc1de0d..0000000000
--- a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp
+++ /dev/null
@@ -1,150 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmldatetimeformatter_p.h>
-#include <QDebug>
-
-class tst_qmldatetimeformatter : public QObject
-{
- Q_OBJECT
-public:
- tst_qmldatetimeformatter() {}
-
-private slots:
- void date();
- void time();
- void dateTime();
-};
-
-void tst_qmldatetimeformatter::date()
-{
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData(QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
- QUrl::fromLocalFile(""));
- QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatter != 0);
-
- QDate date(2008,12,24);
- QCOMPARE(formatter->date(), date);
- QCOMPARE(formatter->dateTime().date(), date);
- QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleShortDate));
-
- formatter->setLongStyle(true);
- QVERIFY(formatter->longStyle());
- QCOMPARE(formatter->dateText(),date.toString(Qt::SystemLocaleLongDate));
-
- formatter->setDateFormat("ddd MMMM d yy");
- QCOMPARE(formatter->dateFormat(), QLatin1String("ddd MMMM d yy"));
- QCOMPARE(formatter->dateText(),date.toString("ddd MMMM d yy"));
-
- QVERIFY(formatter->timeText().isEmpty());
- QVERIFY(formatter->dateTimeText().isEmpty());
-
- delete formatter;
-}
-
-void tst_qmldatetimeformatter::time()
-{
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl::fromLocalFile(""));
- QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatter != 0);
-
- QTime time(14,15,38,200);
-
- QCOMPARE(formatter->time(),time);
- QCOMPARE(formatter->dateTime().time(),time);
-
- QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleShortDate));
-
- formatter->setLongStyle(true);
- QCOMPARE(formatter->timeText(),time.toString(Qt::SystemLocaleLongDate));
-
- formatter->setTimeFormat("H:m:s a");
- QCOMPARE(formatter->timeFormat(), QLatin1String("H:m:s a"));
- QCOMPARE(formatter->timeText(),time.toString("H:m:s a"));
-
- formatter->setTimeFormat("hh:mm:ss.zzz");
- QCOMPARE(formatter->timeText(),time.toString("hh:mm:ss.zzz"));
-
- QVERIFY(formatter->dateText().isEmpty());
- QVERIFY(formatter->dateTimeText().isEmpty());
-
- delete formatter;
-}
-
-void tst_qmldatetimeformatter::dateTime()
-{
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl::fromLocalFile(""));
- QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatter != 0);
-
- QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
- QCOMPARE(formatter->dateTime(),dateTime);
- QCOMPARE(formatter->date(),dateTime.date());
- QCOMPARE(formatter->time(),dateTime.time());
- QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleShortDate));
-
- formatter->setLongStyle(true);
- QCOMPARE(formatter->dateTimeText(),dateTime.toString(Qt::SystemLocaleLongDate));
-
- formatter->setDateTimeFormat("M/d/yy H:m:s a");
- QCOMPARE(formatter->dateTimeFormat(), QLatin1String("M/d/yy H:m:s a"));
- QCOMPARE(formatter->dateTimeText(),dateTime.toString("M/d/yy H:m:s a"));
-
- delete formatter;
-}
-
-QTEST_MAIN(tst_qmldatetimeformatter)
-
-#include "tst_qmldatetimeformatter.moc"
diff --git a/tests/auto/declarative/qmldebug/qmldebug.pro b/tests/auto/declarative/qmldebug/qmldebug.pro
deleted file mode 100644
index f79829df9e..0000000000
--- a/tests/auto/declarative/qmldebug/qmldebug.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += network declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qmldebug.cpp \
- ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
deleted file mode 100644
index ba07331ac8..0000000000
--- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp
+++ /dev/null
@@ -1,841 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtDeclarative/qmlmetatype.h>
-#include <QtDeclarative/qmlmetaproperty.h>
-#include <QtDeclarative/qmlbinding.h>
-
-#include <private/qmldebug_p.h>
-#include <private/qmlenginedebug_p.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
-
-#include "../shared/debugutil_p.h"
-
-Q_DECLARE_METATYPE(QmlDebugWatch::State)
-
-
-class tst_QmlDebug : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QmlDebug(QmlDebugTestData *data)
- {
- m_conn = data->conn;
- m_engine = data->engine;
- m_rootItem = data->items[0];
- }
-
-private:
- QmlDebugObjectReference findRootObject();
- QmlDebugPropertyReference findProperty(const QList<QmlDebugPropertyReference> &props, const QString &name) const;
- void waitForQuery(QmlDebugQuery *query);
-
- void recursiveObjectTest(QObject *o, const QmlDebugObjectReference &oref, bool recursive) const;
-
- void recursiveCompareObjects(const QmlDebugObjectReference &a, const QmlDebugObjectReference &b) const;
- void recursiveCompareContexts(const QmlDebugContextReference &a, const QmlDebugContextReference &b) const;
- void compareProperties(const QmlDebugPropertyReference &a, const QmlDebugPropertyReference &b) const;
-
- QmlDebugConnection *m_conn;
- QmlEngineDebug *m_dbg;
- QmlEngine *m_engine;
- QmlGraphicsItem *m_rootItem;
-
-private slots:
- void initTestCase();
-
- void watch_property();
- void watch_object();
- void watch_expression();
- void watch_expression_data();
- void watch_context();
- void watch_file();
-
- void queryAvailableEngines();
- void queryRootContexts();
- void queryObject();
- void queryObject_data();
- void queryExpressionResult();
- void queryExpressionResult_data();
-
- void tst_QmlDebugFileReference();
- void tst_QmlDebugEngineReference();
- void tst_QmlDebugObjectReference();
- void tst_QmlDebugContextReference();
- void tst_QmlDebugPropertyReference();
-};
-
-QmlDebugObjectReference tst_QmlDebug::findRootObject()
-{
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- if (q_engines->engines().count() == 0)
- return QmlDebugObjectReference();
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- if (q_context->rootContext().objects().count() == 0)
- return QmlDebugObjectReference();
- QmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
- waitForQuery(q_obj);
-
- QmlDebugObjectReference result = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- return result;
-}
-
-QmlDebugPropertyReference tst_QmlDebug::findProperty(const QList<QmlDebugPropertyReference> &props, const QString &name) const
-{
- foreach(const QmlDebugPropertyReference &p, props) {
- if (p.name() == name)
- return p;
- }
- return QmlDebugPropertyReference();
-}
-
-void tst_QmlDebug::waitForQuery(QmlDebugQuery *query)
-{
- QVERIFY(query);
- QCOMPARE(query->parent(), this);
- QVERIFY(query->state() == QmlDebugQuery::Waiting);
- if (!QmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QmlDebugQuery::State))))
- QFAIL("query timed out");
-}
-
-void tst_QmlDebug::recursiveObjectTest(QObject *o, const QmlDebugObjectReference &oref, bool recursive) const
-{
- const QMetaObject *meta = o->metaObject();
-
- QmlType *type = QmlMetaType::qmlType(o->metaObject());
- QString className = type ? type->qmlTypeName() : QString();
- className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
-
- QCOMPARE(oref.debugId(), QmlDebugService::idForObject(o));
- QCOMPARE(oref.name(), o->objectName());
- QCOMPARE(oref.className(), className);
- QCOMPARE(oref.contextDebugId(), QmlDebugService::idForObject(qmlContext(o)));
-
- const QObjectList &children = o->children();
- for (int i=0; i<children.count(); i++) {
- QObject *child = children[i];
- if (!qmlContext(child))
- continue;
- int debugId = QmlDebugService::idForObject(child);
- QVERIFY(debugId >= 0);
-
- QmlDebugObjectReference cref;
- foreach (const QmlDebugObjectReference &ref, oref.children()) {
- if (ref.debugId() == debugId) {
- cref = ref;
- break;
- }
- }
- QVERIFY(cref.debugId() >= 0);
-
- if (recursive)
- recursiveObjectTest(child, cref, true);
- }
-
- foreach (const QmlDebugPropertyReference &p, oref.properties()) {
- QCOMPARE(p.objectDebugId(), QmlDebugService::idForObject(o));
-
- // signal properties are fake - they are generated from QmlBoundSignal children
- if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
- QVERIFY(p.value().toString().startsWith('{') && p.value().toString().endsWith('}'));
- QVERIFY(p.valueTypeName().isEmpty());
- QVERIFY(p.binding().isEmpty());
- QVERIFY(!p.hasNotifySignal());
- continue;
- }
-
- QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
-
- QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
-
- if (pmeta.type() < QVariant::UserType) // TODO test complex types
- QCOMPARE(p.value(), pmeta.read(o));
-
- if (p.name() == "parent")
- QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QmlGraphicsItem*");
- else
- QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
-
- QmlAbstractBinding *binding = QmlMetaProperty(o, p.name()).binding();
- if (binding)
- QCOMPARE(binding->expression(), p.binding());
-
- QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
-
- QVERIFY(pmeta.isValid());
- }
-}
-
-void tst_QmlDebug::recursiveCompareObjects(const QmlDebugObjectReference &a, const QmlDebugObjectReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.className(), b.className());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.contextDebugId(), b.contextDebugId());
-
- QCOMPARE(a.source().url(), b.source().url());
- QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
- QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
-
- QCOMPARE(a.properties().count(), b.properties().count());
- QCOMPARE(a.children().count(), b.children().count());
-
- QList<QmlDebugPropertyReference> aprops = a.properties();
- QList<QmlDebugPropertyReference> bprops = b.properties();
-
- for (int i=0; i<aprops.count(); i++)
- compareProperties(aprops[i], bprops[i]);
-
- for (int i=0; i<a.children().count(); i++)
- recursiveCompareObjects(a.children()[i], b.children()[i]);
-}
-
-void tst_QmlDebug::recursiveCompareContexts(const QmlDebugContextReference &a, const QmlDebugContextReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.objects().count(), b.objects().count());
- QCOMPARE(a.contexts().count(), b.contexts().count());
-
- for (int i=0; i<a.objects().count(); i++)
- recursiveCompareObjects(a.objects()[i], b.objects()[i]);
-
- for (int i=0; i<a.contexts().count(); i++)
- recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
-}
-
-void tst_QmlDebug::compareProperties(const QmlDebugPropertyReference &a, const QmlDebugPropertyReference &b) const
-{
- QCOMPARE(a.objectDebugId(), b.objectDebugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.value(), b.value());
- QCOMPARE(a.valueTypeName(), b.valueTypeName());
- QCOMPARE(a.binding(), b.binding());
- QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
-}
-
-void tst_QmlDebug::initTestCase()
-{
- m_dbg = new QmlEngineDebug(m_conn, this);
-
- qRegisterMetaType<QmlDebugWatch::State>();
-}
-
-void tst_QmlDebug::watch_property()
-{
- QmlDebugObjectReference obj = findRootObject();
- QmlDebugPropertyReference prop = findProperty(obj.properties(), "width");
-
- QmlDebugPropertyWatch *watch;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- watch = unconnected->addWatch(prop, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QmlDebugPropertyReference(), this);
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(prop, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->name(), prop.name());
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
-
- int origWidth = m_rootItem->property("width").toInt();
- m_rootItem->setProperty("width", origWidth*2);
-
- // stateChanged() is received before valueChanged()
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Active);
- QCOMPARE(spy.count(), 1);
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // restore original value and verify spy doesn't get additional signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
- QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
-}
-
-void tst_QmlDebug::watch_object()
-{
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- Q_ASSERT(q_engines->engines().count() > 0);
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- Q_ASSERT(q_context->rootContext().objects().count() > 0);
- QmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
- waitForQuery(q_obj);
-
- QmlDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QmlDebugWatch *watch;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- watch = unconnected->addWatch(obj, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QmlDebugObjectReference(), this);
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
-
- int origWidth = m_rootItem->property("width").toInt();
- int origHeight = m_rootItem->property("height").toInt();
- m_rootItem->setProperty("width", origWidth*2);
- m_rootItem->setProperty("height", origHeight*2);
-
- // stateChanged() is received before any valueChanged() signals
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Active);
- QVERIFY(spy.count() > 0);
-
- int newWidth = -1;
- int newHeight = -1;
- for (int i=0; i<spy.count(); i++) {
- const QVariantList &values = spy[i];
- if (values[0].value<QByteArray>() == "width")
- newWidth = values[1].value<QVariant>().toInt();
- else if (values[0].value<QByteArray>() == "height")
- newHeight = values[1].value<QVariant>().toInt();
-
- }
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // since watch has been removed, restoring the original values should not trigger a valueChanged()
- spy.clear();
- m_rootItem->setProperty("width", origWidth);
- m_rootItem->setProperty("height", origHeight);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
-
- QCOMPARE(newWidth, origWidth * 2);
- QCOMPARE(newHeight, origHeight * 2);
-}
-
-void tst_QmlDebug::watch_expression()
-{
- QFETCH(QString, expr);
- QFETCH(int, increment);
- QFETCH(int, incrementCount);
-
- int origWidth = m_rootItem->property("width").toInt();
-
- QmlDebugObjectReference obj = findRootObject();
-
- QmlDebugObjectExpressionWatch *watch;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- watch = unconnected->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QmlDebugObjectReference(), expr, this);
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(watch->state(), QmlDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QmlDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->expression(), expr);
-
- QSignalSpy spyState(watch, SIGNAL(stateChanged(QmlDebugWatch::State)));
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
- int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
-
- int width = origWidth;
- for (int i=0; i<incrementCount+1; i++) {
- if (i > 0) {
- width += increment;
- m_rootItem->setProperty("width", width);
- }
- if (!QmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
- QFAIL("Did not receive valueChanged() for expression");
- }
-
- if (spyState.count() == 0)
- QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
- QCOMPARE(spyState.count(), 1);
- QCOMPARE(watch->state(), QmlDebugWatch::Active);
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // restore original value and verify spy doesn't get a signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
- QTest::qWait(100);
- QCOMPARE(spy.count(), expectedSpyCount);
-
- width = origWidth + increment;
- for (int i=0; i<spy.count(); i++) {
- QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
- width += increment;
- }
-}
-
-void tst_QmlDebug::watch_expression_data()
-{
- QTest::addColumn<QString>("expr");
- QTest::addColumn<int>("increment");
- QTest::addColumn<int>("incrementCount");
-
- QTest::newRow("width") << "width" << 0 << 0;
- QTest::newRow("width+10") << "width + 10" << 10 << 5;
-}
-
-void tst_QmlDebug::watch_context()
-{
- QmlDebugContextReference c;
- QTest::ignoreMessage(QtWarningMsg, "QmlEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(c, QString(), this));
-}
-
-void tst_QmlDebug::watch_file()
-{
- QmlDebugFileReference f;
- QTest::ignoreMessage(QtWarningMsg, "QmlEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(f, this));
-}
-
-void tst_QmlDebug::queryAvailableEngines()
-{
- QmlDebugEnginesQuery *q_engines;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_engines = unconnected->queryAvailableEngines(0);
- QCOMPARE(q_engines->state(), QmlDebugQuery::Error);
- delete q_engines;
- delete unconnected;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- delete q_engines;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- QVERIFY(q_engines->engines().isEmpty());
- waitForQuery(q_engines);
-
- // TODO test multiple engines
- QList<QmlDebugEngineReference> engines = q_engines->engines();
- QCOMPARE(engines.count(), 1);
-
- foreach(const QmlDebugEngineReference &e, engines) {
- QCOMPARE(e.debugId(), QmlDebugService::idForObject(m_engine));
- QCOMPARE(e.name(), m_engine->objectName());
- }
-
- delete q_engines;
-}
-
-void tst_QmlDebug::queryRootContexts()
-{
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- int engineId = q_engines->engines()[0].debugId();
-
- QmlDebugRootContextQuery *q_context;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_context = unconnected->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QmlDebugQuery::Error);
- delete q_context;
- delete unconnected;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- delete q_context;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- waitForQuery(q_context);
-
- QmlContext *actualContext = m_engine->rootContext();
- QmlDebugContextReference context = q_context->rootContext();
- QCOMPARE(context.debugId(), QmlDebugService::idForObject(actualContext));
- QCOMPARE(context.name(), actualContext->objectName());
-
- QCOMPARE(context.objects().count(), 2); // 2 qml component objects created for context in main()
-
- // root context query sends only root object data - it doesn't fill in
- // the children or property info
- QCOMPARE(context.objects()[0].properties().count(), 0);
- QCOMPARE(context.objects()[0].children().count(), 0);
-
- QCOMPARE(context.contexts().count(), 1);
- QVERIFY(context.contexts()[0].debugId() >= 0);
- QCOMPARE(context.contexts()[0].name(), QString("tst_QmlDebug_childContext"));
-
- delete q_engines;
- delete q_context;
-}
-
-void tst_QmlDebug::queryObject()
-{
- QFETCH(bool, recursive);
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- QmlDebugObjectReference rootObject = q_context->rootContext().objects()[0];
-
- QmlDebugObjectQuery *q_obj = 0;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QmlDebugQuery::Error);
- delete q_obj;
- delete unconnected;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- delete q_obj;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- waitForQuery(q_obj);
-
- QmlDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- // check source as defined in main()
- QmlDebugFileReference source = obj.source();
- QCOMPARE(source.url(), QUrl::fromLocalFile(""));
- QCOMPARE(source.lineNumber(), 2);
- QCOMPARE(source.columnNumber(), 1);
-
- // generically test all properties, children and childrens' properties
- recursiveObjectTest(m_rootItem, obj, recursive);
-
- if (recursive) {
- foreach(const QmlDebugObjectReference &child, obj.children())
- QVERIFY(child.properties().count() > 0);
-
- QmlDebugObjectReference rect;
- QmlDebugObjectReference text;
- foreach (const QmlDebugObjectReference &child, obj.children()) {
- if (child.className() == "Rectangle")
- rect = child;
- else if (child.className() == "Text")
- text = child;
- }
-
- // test specific property values
- QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
- QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
- QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
-
- QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
-
- } else {
- foreach(const QmlDebugObjectReference &child, obj.children())
- QCOMPARE(child.properties().count(), 0);
- }
-}
-
-void tst_QmlDebug::queryObject_data()
-{
- QTest::addColumn<bool>("recursive");
-
- QTest::newRow("non-recursive") << false;
- QTest::newRow("recursive") << true;
-}
-
-void tst_QmlDebug::queryExpressionResult()
-{
- QFETCH(QString, expr);
- QFETCH(QVariant, result);
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines); // check immediate deletion is ok
-
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- int objectId = q_context->rootContext().objects()[0].debugId();
-
- QmlDebugExpressionQuery *q_expr;
-
- QmlEngineDebug *unconnected = new QmlEngineDebug(0);
- q_expr = unconnected->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QmlDebugQuery::Error);
- delete q_expr;
- delete unconnected;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- delete q_expr;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->expression(), expr);
- waitForQuery(q_expr);
-
- QCOMPARE(q_expr->result(), result);
-
- delete q_engines;
- delete q_context;
- delete q_expr;
-}
-
-void tst_QmlDebug::queryExpressionResult_data()
-{
- QTest::addColumn<QString>("expr");
- QTest::addColumn<QVariant>("result");
-
- QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
- QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
- QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
-}
-
-void tst_QmlDebug::tst_QmlDebugFileReference()
-{
- QmlDebugFileReference ref;
- QVERIFY(ref.url().isEmpty());
- QCOMPARE(ref.lineNumber(), -1);
- QCOMPARE(ref.columnNumber(), -1);
-
- ref.setUrl(QUrl("http://test"));
- QCOMPARE(ref.url(), QUrl("http://test"));
- ref.setLineNumber(1);
- QCOMPARE(ref.lineNumber(), 1);
- ref.setColumnNumber(1);
- QCOMPARE(ref.columnNumber(), 1);
-
- QmlDebugFileReference copy(ref);
- QmlDebugFileReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugFileReference &r, (QList<QmlDebugFileReference>() << copy << copyAssign)) {
- QCOMPARE(r.url(), ref.url());
- QCOMPARE(r.lineNumber(), ref.lineNumber());
- QCOMPARE(r.columnNumber(), ref.columnNumber());
- }
-}
-
-void tst_QmlDebug::tst_QmlDebugEngineReference()
-{
- QmlDebugEngineReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
-
- ref = QmlDebugEngineReference(1);
- QCOMPARE(ref.debugId(), 1);
- QVERIFY(ref.name().isEmpty());
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- ref = q_engines->engines()[0];
- delete q_engines;
-
- QmlDebugEngineReference copy(ref);
- QmlDebugEngineReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugEngineReference &r, (QList<QmlDebugEngineReference>() << copy << copyAssign)) {
- QCOMPARE(r.debugId(), ref.debugId());
- QCOMPARE(r.name(), ref.name());
- }
-}
-
-void tst_QmlDebug::tst_QmlDebugObjectReference()
-{
- QmlDebugObjectReference ref;
- QCOMPARE(ref.debugId(), -1);
- QCOMPARE(ref.className(), QString());
- QCOMPARE(ref.name(), QString());
- QCOMPARE(ref.contextDebugId(), -1);
- QVERIFY(ref.properties().isEmpty());
- QVERIFY(ref.children().isEmpty());
-
- QmlDebugFileReference source = ref.source();
- QVERIFY(source.url().isEmpty());
- QVERIFY(source.lineNumber() < 0);
- QVERIFY(source.columnNumber() < 0);
-
- ref = QmlDebugObjectReference(1);
- QCOMPARE(ref.debugId(), 1);
-
- QmlDebugObjectReference rootObject = findRootObject();
- QmlDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(query);
- ref = query->object();
- delete query;
-
- QVERIFY(ref.debugId() >= 0);
-
- QmlDebugObjectReference copy(ref);
- QmlDebugObjectReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugObjectReference &r, (QList<QmlDebugObjectReference>() << copy << copyAssign))
- recursiveCompareObjects(r, ref);
-}
-
-void tst_QmlDebug::tst_QmlDebugContextReference()
-{
- QmlDebugContextReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
- QVERIFY(ref.objects().isEmpty());
- QVERIFY(ref.contexts().isEmpty());
-
- QmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- QmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- ref = q_context->rootContext();
- delete q_engines;
- delete q_context;
- QVERIFY(ref.debugId() >= 0);
-
- QmlDebugContextReference copy(ref);
- QmlDebugContextReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugContextReference &r, (QList<QmlDebugContextReference>() << copy << copyAssign))
- recursiveCompareContexts(r, ref);
-}
-
-void tst_QmlDebug::tst_QmlDebugPropertyReference()
-{
- QmlDebugObjectReference rootObject = findRootObject();
- QmlDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
- waitForQuery(query);
- QmlDebugObjectReference obj = query->object();
- delete query;
-
- QmlDebugPropertyReference ref = findProperty(obj.properties(), "scale");
- QVERIFY(ref.objectDebugId() > 0);
- QVERIFY(!ref.name().isEmpty());
- QVERIFY(!ref.value().isNull());
- QVERIFY(!ref.valueTypeName().isEmpty());
- QVERIFY(!ref.binding().isEmpty());
- QVERIFY(ref.hasNotifySignal());
-
- QmlDebugPropertyReference copy(ref);
- QmlDebugPropertyReference copyAssign;
- copyAssign = ref;
- foreach (const QmlDebugPropertyReference &r, (QList<QmlDebugPropertyReference>() << copy << copyAssign))
- compareProperties(r, ref);
-}
-
-
-class tst_QmlDebug_Factory : public QmlTestFactory
-{
-public:
- QObject *createTest(QmlDebugTestData *data)
- {
- tst_QmlDebug *test = new tst_QmlDebug(data);
- QmlContext *c = new QmlContext(data->engine->rootContext(), test);
- c->setObjectName("tst_QmlDebug_childContext");
- return test;
- }
-};
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QList<QByteArray> qml;
- qml << "import Qt 4.6\n"
- "Item {"
- "width: 10; height: 20; scale: blueRect.scale;"
- "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
- "Text { color: blueRect.color; }"
- "MouseArea {"
- "onEntered: { console.log('hello') }"
- "}"
- "}";
- // add second component to test multiple root contexts
- qml << "import Qt 4.6\n"
- "Item {}";
- tst_QmlDebug_Factory factory;
- return QmlDebugTest::runTests(&factory, qml);
-}
-
-//QTEST_MAIN(tst_QmlDebug)
-
-#include "tst_qmldebug.moc"
diff --git a/tests/auto/declarative/qmldebugclient/qmldebugclient.pro b/tests/auto/declarative/qmldebugclient/qmldebugclient.pro
deleted file mode 100644
index 36aa818a2e..0000000000
--- a/tests/auto/declarative/qmldebugclient/qmldebugclient.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += network declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qmldebugclient.cpp \
- ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp b/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp
deleted file mode 100644
index 3c87d71730..0000000000
--- a/tests/auto/declarative/qmldebugclient/tst_qmldebugclient.cpp
+++ /dev/null
@@ -1,157 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qmlengine.h>
-
-#include <private/qmldebug_p.h>
-#include <private/qmlenginedebug_p.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-
-#include "../shared/debugutil_p.h"
-
-class tst_QmlDebugClient : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QmlDebugClient(QmlDebugTestData *data)
- {
- m_conn = data->conn;
- }
-
- QmlDebugConnection *m_conn;
-
-private slots:
- void name();
- void isEnabled();
- void setEnabled();
- void isConnected();
- void sendMessage();
-};
-
-void tst_QmlDebugClient::name()
-{
- QString name = "tst_QmlDebugClient::name()";
-
- QmlDebugClient client(name, m_conn);
- QCOMPARE(client.name(), name);
-}
-
-void tst_QmlDebugClient::isEnabled()
-{
- QmlDebugClient client("tst_QmlDebugClient::isEnabled()", m_conn);
- QCOMPARE(client.isEnabled(), false);
-}
-
-void tst_QmlDebugClient::setEnabled()
-{
- QmlDebugTestService service("tst_QmlDebugClient::setEnabled()");
- QmlDebugTestClient client("tst_QmlDebugClient::setEnabled()", m_conn);
-
- QCOMPARE(service.isEnabled(), false);
-
- client.setEnabled(true);
- QCOMPARE(client.isEnabled(), true);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.isEnabled(), true);
-
- client.setEnabled(false);
- QCOMPARE(client.isEnabled(), false);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.isEnabled(), false);
-}
-
-void tst_QmlDebugClient::isConnected()
-{
- QmlDebugClient client1("tst_QmlDebugClient::isConnected() A", m_conn);
- QCOMPARE(client1.isConnected(), true);
-
- QmlDebugConnection conn;
- QmlDebugClient client2("tst_QmlDebugClient::isConnected() B", &conn);
- QCOMPARE(client2.isConnected(), false);
-
- QmlDebugClient client3("tst_QmlDebugClient::isConnected() C", 0);
- QCOMPARE(client3.isConnected(), false);
-
- // duplicate plugin name
- QTest::ignoreMessage(QtWarningMsg, "QmlDebugClient: Conflicting plugin name \"tst_QmlDebugClient::isConnected() A\" ");
- QmlDebugClient client4("tst_QmlDebugClient::isConnected() A", m_conn);
- QCOMPARE(client4.isConnected(), false);
-}
-
-void tst_QmlDebugClient::sendMessage()
-{
- QmlDebugTestService service("tst_QmlDebugClient::sendMessage()");
- QmlDebugTestClient client("tst_QmlDebugClient::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-}
-
-
-class tst_QmlDebugClient_Factory : public QmlTestFactory
-{
-public:
- QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebugClient(data); }
-};
-
-
-// This does not use QTEST_MAIN because the test has to be created and run
-// in a separate thread.
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- tst_QmlDebugClient_Factory factory;
- return QmlDebugTest::runTests(&factory);
-}
-
-#include "tst_qmldebugclient.moc"
diff --git a/tests/auto/declarative/qmldebugservice/qmldebugservice.pro b/tests/auto/declarative/qmldebugservice/qmldebugservice.pro
deleted file mode 100644
index 9995f1f2c9..0000000000
--- a/tests/auto/declarative/qmldebugservice/qmldebugservice.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += network declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qmldebugservice.cpp \
- ../shared/debugutil.cpp
diff --git a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
deleted file mode 100644
index e9e31cafab..0000000000
--- a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qmlengine.h>
-
-#include <private/qmldebug_p.h>
-#include <private/qmlenginedebug_p.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-
-#include "../shared/debugutil_p.h"
-
-class tst_QmlDebugService : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QmlDebugService(QmlDebugTestData *data)
- {
- m_conn = data->conn;
- }
-
- QmlDebugConnection *m_conn;
-
-private slots:
- void name();
- void isEnabled();
- void enabledChanged();
- void sendMessage();
- void idForObject();
- void objectForId();
- void objectToString();
-};
-
-void tst_QmlDebugService::name()
-{
- QString name = "tst_QmlDebugService::name()";
-
- QmlDebugService service(name);
- QCOMPARE(service.name(), name);
-}
-
-void tst_QmlDebugService::isEnabled()
-{
- QmlDebugTestService service("tst_QmlDebugService::isEnabled()", m_conn);
- QCOMPARE(service.isEnabled(), false);
-
- QmlDebugTestClient client("tst_QmlDebugService::isEnabled()", m_conn);
- client.setEnabled(true);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.isEnabled(), true);
-
- QTest::ignoreMessage(QtWarningMsg, "QmlDebugService: Conflicting plugin name \"tst_QmlDebugService::isEnabled()\" ");
- QmlDebugService duplicate("tst_QmlDebugService::isEnabled()", m_conn);
- QCOMPARE(duplicate.isEnabled(), false);
-}
-
-void tst_QmlDebugService::enabledChanged()
-{
- QmlDebugTestService service("tst_QmlDebugService::enabledChanged()");
- QmlDebugTestClient client("tst_QmlDebugService::enabledChanged()", m_conn);
-
- QCOMPARE(service.enabled, false);
-
- client.setEnabled(true);
- QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
- QCOMPARE(service.enabled, true);
-}
-
-void tst_QmlDebugService::sendMessage()
-{
- QmlDebugTestService service("tst_QmlDebugService::sendMessage()");
- QmlDebugTestClient client("tst_QmlDebugService::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-}
-
-void tst_QmlDebugService::idForObject()
-{
- QCOMPARE(QmlDebugService::idForObject(0), -1);
-
- QObject *objA = new QObject;
-
- int idA = QmlDebugService::idForObject(objA);
- QVERIFY(idA >= 0);
- QCOMPARE(QmlDebugService::objectForId(idA), objA);
-
- int idAA = QmlDebugService::idForObject(objA);
- QCOMPARE(idAA, idA);
-
- QObject *objB = new QObject;
- int idB = QmlDebugService::idForObject(objB);
- QVERIFY(idB != idA);
- QCOMPARE(QmlDebugService::objectForId(idB), objB);
-
- delete objA;
- delete objB;
-}
-
-void tst_QmlDebugService::objectForId()
-{
- QCOMPARE(QmlDebugService::objectForId(-1), static_cast<QObject*>(0));
- QCOMPARE(QmlDebugService::objectForId(1), static_cast<QObject*>(0));
-
- QObject *obj = new QObject;
- int id = QmlDebugService::idForObject(obj);
- QCOMPARE(QmlDebugService::objectForId(id), obj);
-
- delete obj;
- QCOMPARE(QmlDebugService::objectForId(id), static_cast<QObject*>(0));
-}
-
-void tst_QmlDebugService::objectToString()
-{
- QCOMPARE(QmlDebugService::objectToString(0), QString("NULL"));
-
- QObject *obj = new QObject;
- QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: <unnamed>"));
-
- obj->setObjectName("Hello");
- QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: Hello"));
- delete obj;
-}
-
-
-class tst_QmlDebugService_Factory : public QmlTestFactory
-{
-public:
- QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebugService(data); }
-};
-
-// This does not use QTEST_MAIN because the test has to be created and run
-// in a separate thread.
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- tst_QmlDebugService_Factory factory;
- return QmlDebugTest::runTests(&factory);
-}
-
-#include "tst_qmldebugservice.moc"
diff --git a/tests/auto/declarative/qmldom/qmldom.pro b/tests/auto/declarative/qmldom/qmldom.pro
deleted file mode 100644
index 7ff317d766..0000000000
--- a/tests/auto/declarative/qmldom/qmldom.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmldom.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp
deleted file mode 100644
index 16cdef041b..0000000000
--- a/tests/auto/declarative/qmldom/tst_qmldom.cpp
+++ /dev/null
@@ -1,1313 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/private/qmldom_p.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QFile>
-
-class tst_qmldom : public QObject
-{
- Q_OBJECT
-public:
- tst_qmldom() {}
-
-private slots:
- void loadSimple();
- void loadProperties();
- void loadGroupedProperties();
- void loadChildObject();
- void loadComposite();
- void loadImports();
- void loadErrors();
- void loadSyntaxErrors();
- void loadRemoteErrors();
- void loadDynamicProperty();
- void loadComponent();
-
- void testValueSource();
- void testValueInterceptor();
-
- void object_dynamicProperty();
- void object_property();
- void object_url();
-
- void copy();
- void position();
-private:
- QmlEngine engine;
-};
-
-
-void tst_qmldom::loadSimple()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item {}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
- QVERIFY(document.errors().isEmpty());
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QVERIFY(!rootObject.isComponent());
- QVERIFY(!rootObject.isCustomType());
- QVERIFY(rootObject.objectType() == "Qt/Item");
- QVERIFY(rootObject.objectTypeMajorVersion() == 4);
- QVERIFY(rootObject.objectTypeMinorVersion() == 6);
-}
-
-// Test regular properties
-void tst_qmldom::loadProperties()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item { id : item; x : 300; visible : true }";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QVERIFY(rootObject.objectId() == "item");
- QCOMPARE(rootObject.properties().size(), 3);
-
- QmlDomProperty xProperty = rootObject.property("x");
- QVERIFY(xProperty.propertyName() == "x");
- QCOMPARE(xProperty.propertyNameParts().count(), 1);
- QVERIFY(xProperty.propertyNameParts().at(0) == "x");
- QCOMPARE(xProperty.position(), 32);
- QCOMPARE(xProperty.length(), 1);
- QVERIFY(xProperty.value().isLiteral());
- QVERIFY(xProperty.value().toLiteral().literal() == "300");
-
- QmlDomProperty visibleProperty = rootObject.property("visible");
- QVERIFY(visibleProperty.propertyName() == "visible");
- QCOMPARE(visibleProperty.propertyNameParts().count(), 1);
- QVERIFY(visibleProperty.propertyNameParts().at(0) == "visible");
- QCOMPARE(visibleProperty.position(), 41);
- QCOMPARE(visibleProperty.length(), 7);
- QVERIFY(visibleProperty.value().isLiteral());
- QVERIFY(visibleProperty.value().toLiteral().literal() == "true");
-}
-
-// Test grouped properties
-void tst_qmldom::loadGroupedProperties()
-{
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item { anchors.left: parent.left; anchors.right: parent.right }";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 2);
-
- // Order is not deterministic
- QmlDomProperty p0 = rootItem.properties().at(0);
- QmlDomProperty p1 = rootItem.properties().at(1);
- QmlDomProperty leftProperty;
- QmlDomProperty rightProperty;
- if (p0.propertyName() == "anchors.left") {
- leftProperty = p0;
- rightProperty = p1;
- } else {
- leftProperty = p1;
- rightProperty = p0;
- }
-
- QVERIFY(leftProperty.propertyName() == "anchors.left");
- QCOMPARE(leftProperty.propertyNameParts().count(), 2);
- QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
- QCOMPARE(leftProperty.position(), 21);
- QCOMPARE(leftProperty.length(), 12);
- QVERIFY(leftProperty.value().isBinding());
- QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
-
- QVERIFY(rightProperty.propertyName() == "anchors.right");
- QCOMPARE(rightProperty.propertyNameParts().count(), 2);
- QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
- QCOMPARE(rightProperty.position(), 48);
- QCOMPARE(rightProperty.length(), 13);
- QVERIFY(rightProperty.value().isBinding());
- QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
- }
-
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item { \n"
- " anchors {\n"
- " left: parent.left\n"
- " right: parent.right\n"
- " }\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 2);
-
- // Order is not deterministic
- QmlDomProperty p0 = rootItem.properties().at(0);
- QmlDomProperty p1 = rootItem.properties().at(1);
- QmlDomProperty leftProperty;
- QmlDomProperty rightProperty;
- if (p0.propertyName() == "anchors.left") {
- leftProperty = p0;
- rightProperty = p1;
- } else {
- leftProperty = p1;
- rightProperty = p0;
- }
-
- QVERIFY(leftProperty.propertyName() == "anchors.left");
- QCOMPARE(leftProperty.propertyNameParts().count(), 2);
- QVERIFY(leftProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(leftProperty.propertyNameParts().at(1) == "left");
- QCOMPARE(leftProperty.position(), 44);
- QCOMPARE(leftProperty.length(), 4);
- QVERIFY(leftProperty.value().isBinding());
- QVERIFY(leftProperty.value().toBinding().binding() == "parent.left");
-
- QVERIFY(rightProperty.propertyName() == "anchors.right");
- QCOMPARE(rightProperty.propertyNameParts().count(), 2);
- QVERIFY(rightProperty.propertyNameParts().at(0) == "anchors");
- QVERIFY(rightProperty.propertyNameParts().at(1) == "right");
- QCOMPARE(rightProperty.position(), 70);
- QCOMPARE(rightProperty.length(), 5);
- QVERIFY(rightProperty.value().isBinding());
- QVERIFY(rightProperty.value().toBinding().binding() == "parent.right");
- }
-
-}
-
-void tst_qmldom::loadChildObject()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item { Item {} }";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 1);
-
- QmlDomProperty listProperty = rootItem.properties().at(0);
- QVERIFY(listProperty.isDefaultProperty());
- QVERIFY(listProperty.value().isList());
-
- QmlDomList list = listProperty.value().toList();
- QVERIFY(list.values().size() == 1);
-
- QmlDomObject childItem = list.values().first().toObject();
- QVERIFY(childItem.isValid());
- QVERIFY(childItem.objectType() == "Qt/Item");
-}
-
-void tst_qmldom::loadComposite()
-{
- QFile file(SRCDIR "/data/top.qml");
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, file.readAll(), QUrl::fromLocalFile(file.fileName())));
- QVERIFY(document.errors().isEmpty());
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QCOMPARE(rootItem.objectType(), QByteArray("MyComponent"));
- QCOMPARE(rootItem.properties().size(), 2);
-
- QmlDomProperty widthProperty = rootItem.property("width");
- QVERIFY(widthProperty.value().isLiteral());
-
- QmlDomProperty heightProperty = rootItem.property("height");
- QVERIFY(heightProperty.value().isLiteral());
-}
-
-void tst_qmldom::testValueSource()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
-
- QmlEngine freshEngine;
- QmlDomDocument document;
- QVERIFY(document.load(&freshEngine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QmlDomProperty heightProperty = rootItem.properties().at(0);
- QVERIFY(heightProperty.propertyName() == "height");
- QVERIFY(heightProperty.value().isValueSource());
-
- const QmlDomValueValueSource valueSource = heightProperty.value().toValueSource();
- QmlDomObject valueSourceObject = valueSource.object();
- QVERIFY(valueSourceObject.isValid());
-
- QVERIFY(valueSourceObject.objectType() == "Qt/SpringFollow");
-
- const QmlDomValue springValue = valueSourceObject.property("spring").value();
- QVERIFY(!springValue.isInvalid());
- QVERIFY(springValue.isLiteral());
- QVERIFY(springValue.toLiteral().literal() == "1.4");
-
- const QmlDomValue sourceValue = valueSourceObject.property("source").value();
- QVERIFY(!sourceValue.isInvalid());
- QVERIFY(sourceValue.isBinding());
- QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
-}
-
-void tst_qmldom::testValueInterceptor()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Rectangle { height: Behavior { NumberAnimation { duration: 100 } } }";
-
- QmlEngine freshEngine;
- QmlDomDocument document;
- QVERIFY(document.load(&freshEngine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QmlDomProperty heightProperty = rootItem.properties().at(0);
- QVERIFY(heightProperty.propertyName() == "height");
- QVERIFY(heightProperty.value().isValueInterceptor());
-
- const QmlDomValueValueInterceptor valueInterceptor = heightProperty.value().toValueInterceptor();
- QmlDomObject valueInterceptorObject = valueInterceptor.object();
- QVERIFY(valueInterceptorObject.isValid());
-
- QVERIFY(valueInterceptorObject.objectType() == "Qt/Behavior");
-
- const QmlDomValue animationValue = valueInterceptorObject.property("animation").value();
- QVERIFY(!animationValue.isInvalid());
- QVERIFY(animationValue.isObject());
-}
-
-// Test QmlDomDocument::imports()
-void tst_qmldom::loadImports()
-{
- QByteArray qml = "import Qt 4.6\n"
- "import importlib.sublib 4.7\n"
- "import importlib.sublib 4.6 as NewFoo\n"
- "import 'import'\n"
- "import 'import' as X\n"
- "Item {}";
-
- QmlEngine engine;
- engine.addImportPath(SRCDIR "/data");
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QCOMPARE(document.imports().size(), 5);
-
- QmlDomImport import = document.imports().at(0);
- QCOMPARE(import.type(), QmlDomImport::Library);
- QCOMPARE(import.uri(), QLatin1String("Qt"));
- QCOMPARE(import.qualifier(), QString());
- QCOMPARE(import.version(), QLatin1String("4.6"));
-
- import = document.imports().at(1);
- QCOMPARE(import.type(), QmlDomImport::Library);
- QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
- QCOMPARE(import.qualifier(), QString());
- QCOMPARE(import.version(), QLatin1String("4.7"));
-
- import = document.imports().at(2);
- QCOMPARE(import.type(), QmlDomImport::Library);
- QCOMPARE(import.uri(), QLatin1String("importlib.sublib"));
- QCOMPARE(import.qualifier(), QLatin1String("NewFoo"));
- QCOMPARE(import.version(), QLatin1String("4.6"));
-
- import = document.imports().at(3);
- QCOMPARE(import.type(), QmlDomImport::File);
- QCOMPARE(import.uri(), QLatin1String("import"));
- QCOMPARE(import.qualifier(), QLatin1String(""));
- QCOMPARE(import.version(), QLatin1String(""));
-
- import = document.imports().at(4);
- QCOMPARE(import.type(), QmlDomImport::File);
- QCOMPARE(import.uri(), QLatin1String("import"));
- QCOMPARE(import.qualifier(), QLatin1String("X"));
- QCOMPARE(import.version(), QLatin1String(""));
-}
-
-// Test loading a file with errors
-void tst_qmldom::loadErrors()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " foo: 12\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(false == document.load(&engine, qml));
-
- QCOMPARE(document.errors().count(), 1);
- QmlError error = document.errors().first();
-
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), 3);
- QCOMPARE(error.column(), 3);
- QCOMPARE(error.description(), QString("Cannot assign to non-existent property \"foo\""));
-}
-
-// Test loading a file with syntax errors
-void tst_qmldom::loadSyntaxErrors()
-{
- QByteArray qml = "import Qt 4.6\n"
- "asdf";
-
- QmlDomDocument document;
- QVERIFY(false == document.load(&engine, qml));
-
- QCOMPARE(document.errors().count(), 1);
- QmlError error = document.errors().first();
-
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), 2);
- QCOMPARE(error.column(), 1);
- QCOMPARE(error.description(), QString("Syntax error"));
-}
-
-// Test attempting to load a file with remote references
-void tst_qmldom::loadRemoteErrors()
-{
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " Script {\n"
- " source: \"http://localhost/exampleQmlScript.js\""
- " }\n"
- "}";
- QmlDomDocument document;
- QVERIFY(false == document.load(&engine, qml));
-
- QCOMPARE(document.errors().count(), 1);
- QmlError error = document.errors().first();
-
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), -1);
- QCOMPARE(error.column(), -1);
- QCOMPARE(error.description(), QString("QmlDomDocument supports local types only"));
-}
-
-// Test dynamic property declarations
-void tst_qmldom::loadDynamicProperty()
-{
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " property int a\n"
- " property bool b\n"
- " property double c\n"
- " property real d\n"
- " property string e\n"
- " property url f\n"
- " property color g\n"
- " property date h\n"
- " property var i\n"
- " property variant j\n"
- " property QtObject k\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QCOMPARE(rootObject.dynamicProperties().count(), 11);
-
-#define DP_TEST(index, name, type, test_position, test_length, propTypeName) \
- { \
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(index); \
- QVERIFY(d.isValid()); \
- QVERIFY(d.propertyName() == # name ); \
- QVERIFY(d.propertyType() == type); \
- QVERIFY(d.propertyTypeName() == propTypeName); \
- QVERIFY(d.isDefaultProperty() == false); \
- QVERIFY(d.defaultValue().isValid() == false); \
- QCOMPARE(d.position(), test_position); \
- QCOMPARE(d.length(), test_length); \
- } \
-
- DP_TEST(0, a, QVariant::Int, 25, 14, "int");
- DP_TEST(1, b, QVariant::Bool, 44, 15, "bool");
- DP_TEST(2, c, QVariant::Double, 64, 17, "double");
- DP_TEST(3, d, QMetaType::QReal, 86, 15, "real");
- DP_TEST(4, e, QVariant::String, 106, 17, "string");
- DP_TEST(5, f, QVariant::Url, 128, 14, "url");
- DP_TEST(6, g, QVariant::Color, 147, 16, "color");
- DP_TEST(7, h, QVariant::Date, 168, 15, "date");
- DP_TEST(8, i, qMetaTypeId<QVariant>(), 188, 14, "var");
- DP_TEST(9, j, qMetaTypeId<QVariant>(), 207, 18, "variant");
- DP_TEST(10, k, -1, 230, 19, "QtObject");
- }
-
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " property int a: 12\n"
- " property int b: a + 6\n"
- " default property QtObject c\n"
- "}\n";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QCOMPARE(rootObject.dynamicProperties().count(), 3);
-
- {
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(0);
- QVERIFY(d.isDefaultProperty() == false);
- QVERIFY(d.defaultValue().isValid());
- QVERIFY(d.defaultValue().propertyName() == "a");
- QVERIFY(d.defaultValue().value().isLiteral());
- }
-
- {
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(1);
- QVERIFY(d.isDefaultProperty() == false);
- QVERIFY(d.defaultValue().isValid());
- QVERIFY(d.defaultValue().propertyName() == "b");
- QVERIFY(d.defaultValue().value().isBinding());
- }
-
- {
- QmlDomDynamicProperty d = rootObject.dynamicProperties().at(2);
- QVERIFY(d.isDefaultProperty() == true);
- QVERIFY(d.defaultValue().isValid() == false);
- }
- }
-}
-
-// Test inline components
-void tst_qmldom::loadComponent()
-{
- // Explicit component
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " Component {\n"
- " id: myComponent\n"
- " Item {}\n"
- " }\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 1);
-
- QmlDomProperty listProperty = rootItem.properties().at(0);
- QVERIFY(listProperty.isDefaultProperty());
- QVERIFY(listProperty.value().isList());
-
- QmlDomList list = listProperty.value().toList();
- QVERIFY(list.values().size() == 1);
-
- QmlDomObject componentObject = list.values().first().toObject();
- QVERIFY(componentObject.isValid());
- QVERIFY(componentObject.objectClassName() == "Component");
- QVERIFY(componentObject.isComponent());
-
- QmlDomComponent component = componentObject.toComponent();
- QVERIFY(component.isValid());
- QVERIFY(component.objectType() == "Qt/Component");
- QVERIFY(component.objectTypeMajorVersion() == 4);
- QVERIFY(component.objectTypeMinorVersion() == 6);
- QVERIFY(component.objectClassName() == "Component");
- QVERIFY(component.objectId() == "myComponent");
- QVERIFY(component.properties().isEmpty());
- QVERIFY(component.dynamicProperties().isEmpty());
- QVERIFY(component.isCustomType() == false);
- QVERIFY(component.customTypeData() == "");
- QVERIFY(component.isComponent());
- QCOMPARE(component.position(), 25);
- QCOMPARE(component.length(), 57);
-
- QVERIFY(component.componentRoot().isValid());
- QVERIFY(component.componentRoot().objectClassName() == "Item");
- }
-
- // Implicit component
- {
- QByteArray qml = "import Qt 4.6\n"
- "ListView {\n"
- " delegate: Item {}\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootItem = document.rootObject();
- QVERIFY(rootItem.isValid());
- QVERIFY(rootItem.properties().size() == 1);
-
- QmlDomProperty delegate = rootItem.property("delegate");
-
- QmlDomObject componentObject = delegate.value().toObject();
- QVERIFY(componentObject.isValid());
- QVERIFY(componentObject.objectClassName() == "Component");
- QVERIFY(componentObject.isComponent());
-
- QmlDomComponent component = componentObject.toComponent();
- QVERIFY(component.isValid());
- QVERIFY(component.objectType() == "Qt/Component");
- QVERIFY(component.objectClassName() == "Component");
- QVERIFY(component.objectId() == "");
- QVERIFY(component.properties().isEmpty());
- QVERIFY(component.dynamicProperties().isEmpty());
- QVERIFY(component.isCustomType() == false);
- QVERIFY(component.customTypeData() == "");
- QVERIFY(component.isComponent());
- QCOMPARE(component.position(), 39);
- QCOMPARE(component.length(), 7);
-
- QVERIFY(component.componentRoot().isValid());
- QVERIFY(component.componentRoot().objectClassName() == "Item");
- }
-}
-
-// Test QmlDomObject::dynamicProperty() method
-void tst_qmldom::object_dynamicProperty()
-{
- // Invalid object
- {
- QmlDomObject object;
- QVERIFY(object.dynamicProperty("").isValid() == false);
- QVERIFY(object.dynamicProperty("foo").isValid() == false);
- }
-
-
- // Valid object, no dynamic properties
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.dynamicProperty("").isValid() == false);
- QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
- }
-
- // Valid object, dynamic properties
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " property int a\n"
- "}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.dynamicProperty("").isValid() == false);
- QVERIFY(rootObject.dynamicProperty("foo").isValid() == false);
-
- QmlDomDynamicProperty p = rootObject.dynamicProperty("a");
- QVERIFY(p.isValid());
- QVERIFY(p.propertyName() == "a");
- QVERIFY(p.propertyType() == QVariant::Int);
- QVERIFY(p.propertyTypeName() == "int");
- QVERIFY(p.isDefaultProperty() == false);
- QCOMPARE(p.position(), 25);
- QCOMPARE(p.length(), 14);
- }
-
-}
-
-// Test QmlObject::property() method
-void tst_qmldom::object_property()
-{
- // Invalid object
- {
- QmlDomObject object;
- QVERIFY(object.property("").isValid() == false);
- QVERIFY(object.property("foo").isValid() == false);
- }
-
- // Valid object - no default
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " x: 10\n"
- " y: 12\n"
- "}\n";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.property("").isValid() == false);
- QVERIFY(rootObject.property("foo").isValid() == false);
-
- QmlDomProperty x = rootObject.property("x");
- QVERIFY(x.isValid());
- QVERIFY(x.propertyName() == "x");
- QVERIFY(x.propertyNameParts().count() == 1);
- QVERIFY(x.propertyNameParts().at(0) == "x");
- QVERIFY(x.isDefaultProperty() == false);
- QVERIFY(x.value().isLiteral());
- QVERIFY(x.value().toLiteral().literal() == "10");
- QCOMPARE(x.position(), 25);
- QCOMPARE(x.length(), 1);
-
- QmlDomProperty y = rootObject.property("y");
- QVERIFY(y.isValid());
- QVERIFY(y.propertyName() == "y");
- QVERIFY(y.propertyNameParts().count() == 1);
- QVERIFY(y.propertyNameParts().at(0) == "y");
- QVERIFY(y.isDefaultProperty() == false);
- QVERIFY(y.value().isLiteral());
- QVERIFY(y.value().toLiteral().literal() == "12");
- QCOMPARE(y.position(), 35);
- QCOMPARE(y.length(), 1);
- }
-
- // Valid object - with default
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {\n"
- " x: 10\n"
- " y: 12\n"
- " Item {}\n"
- "}\n";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
-
- QVERIFY(rootObject.property("").isValid() == false);
- QVERIFY(rootObject.property("foo").isValid() == false);
-
- QmlDomProperty x = rootObject.property("x");
- QVERIFY(x.isValid());
- QVERIFY(x.propertyName() == "x");
- QVERIFY(x.propertyNameParts().count() == 1);
- QVERIFY(x.propertyNameParts().at(0) == "x");
- QVERIFY(x.isDefaultProperty() == false);
- QVERIFY(x.value().isLiteral());
- QVERIFY(x.value().toLiteral().literal() == "10");
- QCOMPARE(x.position(), 25);
- QCOMPARE(x.length(), 1);
-
- QmlDomProperty y = rootObject.property("y");
- QVERIFY(y.isValid());
- QVERIFY(y.propertyName() == "y");
- QVERIFY(y.propertyNameParts().count() == 1);
- QVERIFY(y.propertyNameParts().at(0) == "y");
- QVERIFY(y.isDefaultProperty() == false);
- QVERIFY(y.value().isLiteral());
- QVERIFY(y.value().toLiteral().literal() == "12");
- QCOMPARE(y.position(), 35);
- QCOMPARE(y.length(), 1);
-
- QmlDomProperty data = rootObject.property("data");
- QVERIFY(data.isValid());
- QVERIFY(data.propertyName() == "data");
- QVERIFY(data.propertyNameParts().count() == 1);
- QVERIFY(data.propertyNameParts().at(0) == "data");
- QVERIFY(data.isDefaultProperty() == true);
- QVERIFY(data.value().isList());
- QCOMPARE(data.position(), 45);
- QCOMPARE(data.length(), 0);
- }
-}
-
-// Tests the QmlDomObject::url() method
-void tst_qmldom::object_url()
-{
- // Invalid object
- {
- QmlDomObject object;
- QCOMPARE(object.url(), QUrl());
- }
-
- // Valid builtin object
- {
- QByteArray qml = "import Qt 4.6\n"
- "Item {}";
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QCOMPARE(rootObject.url(), QUrl());
- }
-
- // Valid composite object
- {
- QByteArray qml = "import Qt 4.6\n"
- "MyItem {}";
-
- QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
- QUrl subUrl = QUrl::fromLocalFile(SRCDIR "/data/MyItem.qml");
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml, myUrl));
-
- QmlDomObject rootObject = document.rootObject();
- QVERIFY(rootObject.isValid());
- QCOMPARE(rootObject.url(), subUrl);
- }
-}
-
-// Test copy constructors and operators
-void tst_qmldom::copy()
-{
- QByteArray qml = "import Qt 4.6\n"
- "MyItem {\n"
- " id: myItem\n"
- " property int a: 10\n"
- " x: 10\n"
- " y: x + 10\n"
- " z: NumberAnimation {}\n"
- " opacity: Behavior {}\n"
- " Component {\n"
- " Item{}\n"
- " }\n"
- " children: [ Item{}, Item{} ]\n"
- "}\n";
-
- QUrl myUrl = QUrl::fromLocalFile(SRCDIR "/data/main.qml");
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml, myUrl));
-
- // QmlDomDocument
- {
- QmlDomDocument document2(document);
- QmlDomDocument document3;
- document3 = document;
-
- QCOMPARE(document.imports().count(), document2.imports().count());
- QCOMPARE(document.errors().count(), document2.errors().count());
- QCOMPARE(document.rootObject().objectClassName(), document2.rootObject().objectClassName());
-
- QCOMPARE(document.imports().count(), document3.imports().count());
- QCOMPARE(document.errors().count(), document3.errors().count());
- QCOMPARE(document.rootObject().objectClassName(), document3.rootObject().objectClassName());
- }
-
- // QmlDomImport
- {
- QCOMPARE(document.imports().count(), 1);
- QmlDomImport import = document.imports().at(0);
-
- QmlDomImport import2(import);
- QmlDomImport import3;
- import3 = import2;
-
- QCOMPARE(import.type(), import2.type());
- QCOMPARE(import.uri(), import2.uri());
- QCOMPARE(import.version(), import2.version());
- QCOMPARE(import.qualifier(), import2.qualifier());
-
- QCOMPARE(import.type(), import3.type());
- QCOMPARE(import.uri(), import3.uri());
- QCOMPARE(import.version(), import3.version());
- QCOMPARE(import.qualifier(), import3.qualifier());
- }
-
- // QmlDomObject
- {
- QmlDomObject object = document.rootObject();
- QVERIFY(object.isValid());
-
- QmlDomObject object2(object);
- QmlDomObject object3;
- object3 = object;
-
- QCOMPARE(object.isValid(), object2.isValid());
- QCOMPARE(object.objectType(), object2.objectType());
- QCOMPARE(object.objectClassName(), object2.objectClassName());
- QCOMPARE(object.objectTypeMajorVersion(), object2.objectTypeMajorVersion());
- QCOMPARE(object.objectTypeMinorVersion(), object2.objectTypeMinorVersion());
- QCOMPARE(object.objectId(), object2.objectId());
- QCOMPARE(object.properties().count(), object2.properties().count());
- QCOMPARE(object.dynamicProperties().count(), object2.dynamicProperties().count());
- QCOMPARE(object.isCustomType(), object2.isCustomType());
- QCOMPARE(object.customTypeData(), object2.customTypeData());
- QCOMPARE(object.isComponent(), object2.isComponent());
- QCOMPARE(object.position(), object2.position());
- QCOMPARE(object.length(), object2.length());
- QCOMPARE(object.url(), object2.url());
-
- QCOMPARE(object.isValid(), object3.isValid());
- QCOMPARE(object.objectType(), object3.objectType());
- QCOMPARE(object.objectClassName(), object3.objectClassName());
- QCOMPARE(object.objectTypeMajorVersion(), object3.objectTypeMajorVersion());
- QCOMPARE(object.objectTypeMinorVersion(), object3.objectTypeMinorVersion());
- QCOMPARE(object.objectId(), object3.objectId());
- QCOMPARE(object.properties().count(), object3.properties().count());
- QCOMPARE(object.dynamicProperties().count(), object3.dynamicProperties().count());
- QCOMPARE(object.isCustomType(), object3.isCustomType());
- QCOMPARE(object.customTypeData(), object3.customTypeData());
- QCOMPARE(object.isComponent(), object3.isComponent());
- QCOMPARE(object.position(), object3.position());
- QCOMPARE(object.length(), object3.length());
- QCOMPARE(object.url(), object3.url());
- }
-
- // QmlDomDynamicProperty
- {
- QmlDomObject object = document.rootObject();
- QmlDomDynamicProperty property = object.dynamicProperty("a");
-
- QmlDomDynamicProperty property2(property);
- QmlDomDynamicProperty property3;
- property3 = property;
-
- QCOMPARE(property.isValid(), property2.isValid());
- QCOMPARE(property.propertyName(), property2.propertyName());
- QCOMPARE(property.propertyType(), property2.propertyType());
- QCOMPARE(property.propertyTypeName(), property2.propertyTypeName());
- QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
- QCOMPARE(property.defaultValue().propertyName(), property2.defaultValue().propertyName());
- QCOMPARE(property.position(), property2.position());
- QCOMPARE(property.length(), property2.length());
-
- QCOMPARE(property.isValid(), property3.isValid());
- QCOMPARE(property.propertyName(), property3.propertyName());
- QCOMPARE(property.propertyType(), property3.propertyType());
- QCOMPARE(property.propertyTypeName(), property3.propertyTypeName());
- QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
- QCOMPARE(property.defaultValue().propertyName(), property3.defaultValue().propertyName());
- QCOMPARE(property.position(), property3.position());
- QCOMPARE(property.length(), property3.length());
- }
-
- // QmlDomProperty
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("opacity");
-
- QmlDomProperty property2(property);
- QmlDomProperty property3;
- property3 = property;
-
- QCOMPARE(property.isValid(), property2.isValid());
- QCOMPARE(property.propertyName(), property2.propertyName());
- QCOMPARE(property.propertyNameParts(), property2.propertyNameParts());
- QCOMPARE(property.isDefaultProperty(), property2.isDefaultProperty());
- QCOMPARE(property.value().type(), property2.value().type());
- QCOMPARE(property.position(), property2.position());
- QCOMPARE(property.length(), property2.length());
-
- QCOMPARE(property.isValid(), property3.isValid());
- QCOMPARE(property.propertyName(), property3.propertyName());
- QCOMPARE(property.propertyNameParts(), property3.propertyNameParts());
- QCOMPARE(property.isDefaultProperty(), property3.isDefaultProperty());
- QCOMPARE(property.value().type(), property3.value().type());
- QCOMPARE(property.position(), property3.position());
- QCOMPARE(property.length(), property3.length());
- }
-
- // QmlDomValueLiteral
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("x");
- QmlDomValueLiteral literal = property.value().toLiteral();
- QCOMPARE(literal.literal(), QString("10"));
-
- QmlDomValueLiteral literal2(literal);
- QmlDomValueLiteral literal3;
- literal3 = literal2;
-
- QCOMPARE(literal2.literal(), QString("10"));
- QCOMPARE(literal3.literal(), QString("10"));
- }
-
-
- // QmlDomValueBinding
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("y");
- QmlDomValueBinding binding = property.value().toBinding();
- QCOMPARE(binding.binding(), QString("x + 10"));
-
- QmlDomValueBinding binding2(binding);
- QmlDomValueBinding binding3;
- binding3 = binding2;
-
- QCOMPARE(binding2.binding(), QString("x + 10"));
- QCOMPARE(binding3.binding(), QString("x + 10"));
- }
-
- // QmlDomValueValueSource
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("z");
- QmlDomValueValueSource source = property.value().toValueSource();
- QCOMPARE(source.object().objectClassName(), QByteArray("NumberAnimation"));
-
- QmlDomValueValueSource source2(source);
- QmlDomValueValueSource source3;
- source3 = source;
-
- QCOMPARE(source2.object().objectClassName(), QByteArray("NumberAnimation"));
- QCOMPARE(source3.object().objectClassName(), QByteArray("NumberAnimation"));
- }
-
- // QmlDomValueValueInterceptor
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("opacity");
- QmlDomValueValueInterceptor interceptor = property.value().toValueInterceptor();
- QCOMPARE(interceptor.object().objectClassName(), QByteArray("Behavior"));
-
- QmlDomValueValueInterceptor interceptor2(interceptor);
- QmlDomValueValueInterceptor interceptor3;
- interceptor3 = interceptor;
-
- QCOMPARE(interceptor2.object().objectClassName(), QByteArray("Behavior"));
- QCOMPARE(interceptor3.object().objectClassName(), QByteArray("Behavior"));
- }
-
- // QmlDomComponent
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("data");
- QCOMPARE(property.value().toList().values().count(), 1);
- QmlDomComponent component =
- property.value().toList().values().at(0).toObject().toComponent();
- QCOMPARE(component.componentRoot().objectClassName(), QByteArray("Item"));
-
- QmlDomComponent component2(component);
- QmlDomComponent component3;
- component3 = component;
-
- QCOMPARE(component.componentRoot().objectClassName(), component2.componentRoot().objectClassName());
- QCOMPARE(component.isValid(), component2.isValid());
- QCOMPARE(component.objectType(), component2.objectType());
- QCOMPARE(component.objectClassName(), component2.objectClassName());
- QCOMPARE(component.objectTypeMajorVersion(), component2.objectTypeMajorVersion());
- QCOMPARE(component.objectTypeMinorVersion(), component2.objectTypeMinorVersion());
- QCOMPARE(component.objectId(), component2.objectId());
- QCOMPARE(component.properties().count(), component2.properties().count());
- QCOMPARE(component.dynamicProperties().count(), component2.dynamicProperties().count());
- QCOMPARE(component.isCustomType(), component2.isCustomType());
- QCOMPARE(component.customTypeData(), component2.customTypeData());
- QCOMPARE(component.isComponent(), component2.isComponent());
- QCOMPARE(component.position(), component2.position());
- QCOMPARE(component.length(), component2.length());
- QCOMPARE(component.url(), component2.url());
-
- QCOMPARE(component.componentRoot().objectClassName(), component3.componentRoot().objectClassName());
- QCOMPARE(component.isValid(), component3.isValid());
- QCOMPARE(component.objectType(), component3.objectType());
- QCOMPARE(component.objectClassName(), component3.objectClassName());
- QCOMPARE(component.objectTypeMajorVersion(), component3.objectTypeMajorVersion());
- QCOMPARE(component.objectTypeMinorVersion(), component3.objectTypeMinorVersion());
- QCOMPARE(component.objectId(), component3.objectId());
- QCOMPARE(component.properties().count(), component3.properties().count());
- QCOMPARE(component.dynamicProperties().count(), component3.dynamicProperties().count());
- QCOMPARE(component.isCustomType(), component3.isCustomType());
- QCOMPARE(component.customTypeData(), component3.customTypeData());
- QCOMPARE(component.isComponent(), component3.isComponent());
- QCOMPARE(component.position(), component3.position());
- QCOMPARE(component.length(), component3.length());
- QCOMPARE(component.url(), component3.url());
- }
-
- // QmlDomValue
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("data");
- QmlDomValue value = property.value();
-
- QmlDomValue value2(value);
- QmlDomValue value3;
- value3 = value;
-
- QCOMPARE(value.type(), value2.type());
- QCOMPARE(value.isInvalid(), value2.isInvalid());
- QCOMPARE(value.isLiteral(), value2.isLiteral());
- QCOMPARE(value.isBinding(), value2.isBinding());
- QCOMPARE(value.isValueSource(), value2.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
- QCOMPARE(value.isObject(), value2.isObject());
- QCOMPARE(value.isList(), value2.isList());
- QCOMPARE(value.position(), value2.position());
- QCOMPARE(value.length(), value2.length());
-
- QCOMPARE(value.type(), value3.type());
- QCOMPARE(value.isInvalid(), value3.isInvalid());
- QCOMPARE(value.isLiteral(), value3.isLiteral());
- QCOMPARE(value.isBinding(), value3.isBinding());
- QCOMPARE(value.isValueSource(), value3.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
- QCOMPARE(value.isObject(), value3.isObject());
- QCOMPARE(value.isList(), value3.isList());
- QCOMPARE(value.position(), value3.position());
- QCOMPARE(value.length(), value3.length());
- }
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("x");
- QmlDomValue value = property.value();
-
- QmlDomValue value2(value);
- QmlDomValue value3;
- value3 = value;
-
- QCOMPARE(value.type(), value2.type());
- QCOMPARE(value.isInvalid(), value2.isInvalid());
- QCOMPARE(value.isLiteral(), value2.isLiteral());
- QCOMPARE(value.isBinding(), value2.isBinding());
- QCOMPARE(value.isValueSource(), value2.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
- QCOMPARE(value.isObject(), value2.isObject());
- QCOMPARE(value.isList(), value2.isList());
- QCOMPARE(value.position(), value2.position());
- QCOMPARE(value.length(), value2.length());
-
- QCOMPARE(value.type(), value3.type());
- QCOMPARE(value.isInvalid(), value3.isInvalid());
- QCOMPARE(value.isLiteral(), value3.isLiteral());
- QCOMPARE(value.isBinding(), value3.isBinding());
- QCOMPARE(value.isValueSource(), value3.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
- QCOMPARE(value.isObject(), value3.isObject());
- QCOMPARE(value.isList(), value3.isList());
- QCOMPARE(value.position(), value3.position());
- QCOMPARE(value.length(), value3.length());
- }
- {
- QmlDomValue value;
-
- QmlDomValue value2(value);
- QmlDomValue value3;
- value3 = value;
-
- QCOMPARE(value.type(), value2.type());
- QCOMPARE(value.isInvalid(), value2.isInvalid());
- QCOMPARE(value.isLiteral(), value2.isLiteral());
- QCOMPARE(value.isBinding(), value2.isBinding());
- QCOMPARE(value.isValueSource(), value2.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value2.isValueInterceptor());
- QCOMPARE(value.isObject(), value2.isObject());
- QCOMPARE(value.isList(), value2.isList());
- QCOMPARE(value.position(), value2.position());
- QCOMPARE(value.length(), value2.length());
-
- QCOMPARE(value.type(), value3.type());
- QCOMPARE(value.isInvalid(), value3.isInvalid());
- QCOMPARE(value.isLiteral(), value3.isLiteral());
- QCOMPARE(value.isBinding(), value3.isBinding());
- QCOMPARE(value.isValueSource(), value3.isValueSource());
- QCOMPARE(value.isValueInterceptor(), value3.isValueInterceptor());
- QCOMPARE(value.isObject(), value3.isObject());
- QCOMPARE(value.isList(), value3.isList());
- QCOMPARE(value.position(), value3.position());
- QCOMPARE(value.length(), value3.length());
- }
-
- // QmlDomList
- {
- QmlDomObject object = document.rootObject();
- QmlDomProperty property = object.property("children");
- QmlDomList list = property.value().toList();
- QCOMPARE(list.values().count(), 2);
-
- QmlDomList list2(list);
- QmlDomList list3;
- list3 = list2;
-
- QCOMPARE(list.values().count(), list2.values().count());
- QCOMPARE(list.position(), list2.position());
- QCOMPARE(list.length(), list2.length());
- QCOMPARE(list.commaPositions(), list2.commaPositions());
-
- QCOMPARE(list.values().count(), list3.values().count());
- QCOMPARE(list.position(), list3.position());
- QCOMPARE(list.length(), list3.length());
- QCOMPARE(list.commaPositions(), list3.commaPositions());
-
- }
-}
-
-// Tests the position/length of various elements
-void tst_qmldom::position()
-{
- QByteArray qml = "import Qt 4.6\n"
- /*14*/ "Item {\n"
- /*21*/ " id: myItem\n"
- /*36*/ " property int a: 10\n"
- /*59*/ " x: 10\n"
- /*69*/ " y: x + 10\n"
- /*83*/ " z: NumberAnimation {}\n"
- /*109*/ " opacity: Behavior {}\n"
- /*134*/ " Component {\n"
- /*150*/ " Item{}\n"
- /*165*/ " }\n"
- /*171*/ " children: [ Item{}, Item{} ]\n"
- /*204*/ "}\n";
-
-
- QmlDomDocument document;
- QVERIFY(document.load(&engine, qml));
-
- QmlDomObject root = document.rootObject();
-
- // All QmlDomDynamicProperty
- QmlDomDynamicProperty dynProp = root.dynamicProperty("a");
- QCOMPARE(dynProp.position(), 40);
- QCOMPARE(dynProp.length(), 18);
-
- // All QmlDomProperty
- QmlDomProperty x = root.property("x");
- QCOMPARE(x.position(), 63);
- QCOMPARE(x.length(), 1);
-
- QmlDomProperty y = root.property("y");
- QCOMPARE(y.position(), 73);
- QCOMPARE(y.length(), 1);
-
- QmlDomProperty z = root.property("z");
- QCOMPARE(z.position(), 87);
- QCOMPARE(z.length(), 1);
-
- QmlDomProperty opacity = root.property("opacity");
- QCOMPARE(opacity.position(), 113);
- QCOMPARE(opacity.length(), 7);
-
- QmlDomProperty data = root.property("data");
- QCOMPARE(data.position(), 138);
- QCOMPARE(data.length(), 0);
-
- QmlDomProperty children = root.property("children");
- QCOMPARE(children.position(), 175);
- QCOMPARE(children.length(), 8);
-
- QmlDomList dataList = data.value().toList();
- QCOMPARE(dataList.values().count(), 1);
- QmlDomList childrenList = children.value().toList();
- QCOMPARE(childrenList.values().count(), 2);
-
- // All QmlDomObject
- QCOMPARE(root.position(), 14);
- QCOMPARE(root.length(), 191);
-
- QmlDomObject numberAnimation = z.value().toValueSource().object();
- QCOMPARE(numberAnimation.position(), 90);
- QCOMPARE(numberAnimation.length(), 18);
-
- QmlDomObject behavior = opacity.value().toValueInterceptor().object();
- QCOMPARE(behavior.position(), 122);
- QCOMPARE(behavior.length(), 11);
-
- QmlDomObject component = dataList.values().at(0).toObject();
- QCOMPARE(component.position(), 138);
- QCOMPARE(component.length(), 32);
-
- QmlDomObject componentRoot = component.toComponent().componentRoot();
- QCOMPARE(componentRoot.position(), 158);
- QCOMPARE(componentRoot.length(), 6);
-
- QmlDomObject child1 = childrenList.values().at(0).toObject();
- QCOMPARE(child1.position(), 187);
- QCOMPARE(child1.length(), 6);
-
- QmlDomObject child2 = childrenList.values().at(1).toObject();
- QCOMPARE(child2.position(), 195);
- QCOMPARE(child2.length(), 6);
-
- // All QmlDomValue
- QmlDomValue xValue = x.value();
- QCOMPARE(xValue.position(), 66);
- QCOMPARE(xValue.length(), 2);
-
- QmlDomValue yValue = y.value();
- QCOMPARE(yValue.position(), 76);
- QCOMPARE(yValue.length(), 6);
-
- QmlDomValue zValue = z.value();
- QCOMPARE(zValue.position(), 90);
- QCOMPARE(zValue.length(), 18);
-
- QmlDomValue opacityValue = opacity.value();
- QCOMPARE(opacityValue.position(), 122);
- QCOMPARE(opacityValue.length(), 11);
-
- QmlDomValue dataValue = data.value();
- QCOMPARE(dataValue.position(), 138);
- QCOMPARE(dataValue.length(), 32);
-
- QmlDomValue child1Value = childrenList.values().at(0);
- QCOMPARE(child1Value.position(), 187);
- QCOMPARE(child1Value.length(), 6);
-
- QmlDomValue child2Value = childrenList.values().at(1);
- QCOMPARE(child2Value.position(), 195);
- QCOMPARE(child2Value.length(), 6);
-
- // All QmlDomList
- qWarning("QmlListValue position test required");
-}
-
-QTEST_MAIN(tst_qmldom)
-
-#include "tst_qmldom.moc"
diff --git a/tests/auto/declarative/qmleasefollow/qmleasefollow.pro b/tests/auto/declarative/qmleasefollow/qmleasefollow.pro
deleted file mode 100644
index 4224a7e8a8..0000000000
--- a/tests/auto/declarative/qmleasefollow/qmleasefollow.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmleasefollow.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp b/tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp
deleted file mode 100644
index f28311fb53..0000000000
--- a/tests/auto/declarative/qmleasefollow/tst_qmleasefollow.cpp
+++ /dev/null
@@ -1,122 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmleasefollow_p.h>
-#include <private/qmlvaluetype_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmleasefollow : public QObject
-{
- Q_OBJECT
-public:
- tst_qmleasefollow();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmleasefollow::tst_qmleasefollow()
-{
-}
-
-void tst_qmleasefollow::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow1.qml"));
- QmlEaseFollow *obj = qobject_cast<QmlEaseFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 0.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->duration(), -1.);
- QCOMPARE(obj->maximumEasingTime(), -1.);
- QCOMPARE(obj->reversingMode(), QmlEaseFollow::Eased);
-
- delete obj;
-}
-
-void tst_qmleasefollow::values()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow2.qml"));
- QmlEaseFollow *obj = qobject_cast<QmlEaseFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 10.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->duration(), 300.);
- QCOMPARE(obj->maximumEasingTime(), -1.);
- QCOMPARE(obj->reversingMode(), QmlEaseFollow::Immediate);
-
- delete obj;
-}
-
-void tst_qmleasefollow::disabled()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/easefollow3.qml"));
- QmlEaseFollow *obj = qobject_cast<QmlEaseFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 10.);
- QCOMPARE(obj->velocity(), 250.);
- QCOMPARE(obj->enabled(), false);
- QCOMPARE(obj->maximumEasingTime(), 150.);
- QCOMPARE(obj->reversingMode(), QmlEaseFollow::Sync);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmleasefollow)
-
-#include "tst_qmleasefollow.moc"
diff --git a/tests/auto/declarative/qmlecmascript/qmlecmascript.pro b/tests/auto/declarative/qmlecmascript/qmlecmascript.pro
deleted file mode 100644
index 9f592e8b34..0000000000
--- a/tests/auto/declarative/qmlecmascript/qmlecmascript.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative script
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlecmascript.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.cpp b/tests/auto/declarative/qmlecmascript/testtypes.cpp
deleted file mode 100644
index 3c6b256a92..0000000000
--- a/tests/auto/declarative/qmlecmascript/testtypes.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
-
-class BaseExtensionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged);
-public:
- BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
-
- int extendedProperty() const { return m_value; }
- void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
-
-signals:
- void extendedPropertyChanged();
-private:
- int m_value;
-};
-
-class ExtensionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged);
-public:
- ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
-
- int extendedProperty() const { return m_value; }
- void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
-
-signals:
- void extendedPropertyChanged();
-private:
- int m_value;
-};
-
-QML_DEFINE_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject);
-QML_DEFINE_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject);
-QML_DEFINE_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer);
-QML_DEFINE_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject);
-QML_DEFINE_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject);
-QML_DEFINE_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject);
-
-#include "testtypes.moc"
diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h
deleted file mode 100644
index 0af72cbd8c..0000000000
--- a/tests/auto/declarative/qmlecmascript/testtypes.h
+++ /dev/null
@@ -1,592 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtDeclarative/qmllist.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtCore/qdatetime.h>
-#include <QtScript/qscriptvalue.h>
-#include <QtDeclarative/qmlscriptstring.h>
-#include <QtDeclarative/qmlcomponent.h>
-
-class MyQmlAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value CONSTANT)
-public:
- MyQmlAttachedObject(QObject *parent) : QObject(parent) {}
-
- int value() const { return 19; }
-};
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_ENUMS(MyEnum2)
- Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
- Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
- Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- Q_PROPERTY(QmlListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
-
-public:
- MyQmlObject(): m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {}
-
- enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
- enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
-
- bool trueProperty() const { return true; }
- bool falseProperty() const { return false; }
-
- QString stringProperty() const { return m_string; }
- void setStringProperty(const QString &s)
- {
- if (s == m_string)
- return;
- m_string = s;
- emit stringChanged();
- }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) {
- if (obj == m_object)
- return;
- m_object = obj;
- emit objectChanged();
- }
-
- QmlListProperty<QObject> objectListProperty() { return QmlListProperty<QObject>(this, m_objectQList); }
-
- bool methodCalled() const { return m_methodCalled; }
- bool methodIntCalled() const { return m_methodIntCalled; }
-
- QString string() const { return m_string; }
-
- static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
- return new MyQmlAttachedObject(o);
- }
-
- int deleteOnSet() const { return 1; }
- void setDeleteOnSet(int v) { if(v) delete this; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int v) { m_resetProperty = v; }
- void resetProperty() { m_resetProperty = 13; }
-
-signals:
- void basicSignal();
- void argumentSignal(int a, QString b, qreal c);
- void stringChanged();
- void objectChanged();
- void anotherBasicSignal();
- void thirdBasicSignal();
-
-public slots:
- void deleteMe() { delete this; }
- void methodNoArgs() { m_methodCalled = true; }
- void method(int a) { if(a == 163) m_methodIntCalled = true; }
- void setString(const QString &s) { m_string = s; }
-
-private:
- friend class tst_qmlecmascript;
- bool m_methodCalled;
- bool m_methodIntCalled;
-
- QObject *m_object;
- QString m_string;
- QList<QObject *> m_objectQList;
- int m_value;
- int m_resetProperty;
-};
-
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(MyQmlObject);
-
-class MyQmlContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children CONSTANT)
-public:
- MyQmlContainer() {}
-
- QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-QML_DECLARE_TYPE(MyQmlContainer);
-
-class MyExpression : public QmlExpression
-{
-public:
- MyExpression(QmlContext *ctxt, const QString &expr)
- : QmlExpression(ctxt, expr, 0), changed(false)
- {
- }
-
- void emitValueChanged() {
- changed = true;
- QmlExpression::emitValueChanged();
- }
- bool changed;
-};
-
-
-class MyDefaultObject1 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int horseLegs READ horseLegs CONSTANT);
- Q_PROPERTY(int antLegs READ antLegs CONSTANT);
-public:
- int horseLegs() const { return 4; }
- int antLegs() const { return 6; }
-};
-
-class MyDefaultObject2 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int antLegs READ antLegs CONSTANT);
- Q_PROPERTY(int emuLegs READ emuLegs CONSTANT);
-public:
- int antLegs() const { return 5; } // Had an accident
- int emuLegs() const { return 2; }
-};
-
-class MyDefaultObject3 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int antLegs READ antLegs CONSTANT);
- Q_PROPERTY(int humanLegs READ humanLegs CONSTANT);
-public:
- int antLegs() const { return 7; } // Mutant
- int humanLegs() const { return 2; }
- int millipedeLegs() const { return 1000; }
-};
-
-class MyDeferredObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
- Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2);
- Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2");
-
-public:
- MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; emit valueChanged(); }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) { m_object = obj; }
-
- QObject *objectProperty2() const { return m_object2; }
- void setObjectProperty2(QObject *obj) { m_object2 = obj; }
-
-signals:
- void valueChanged();
-
-private:
- int m_value;
- QObject *m_object;
- QObject *m_object2;
-};
-QML_DECLARE_TYPE(MyDeferredObject);
-
-class MyBaseExtendedObject : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty);
-public:
- MyBaseExtendedObject() : m_value(0) {}
-
- int baseProperty() const { return m_value; }
- void setBaseProperty(int v) { m_value = v; }
-
-private:
- int m_value;
-};
-QML_DECLARE_TYPE(MyBaseExtendedObject);
-
-class MyExtendedObject : public MyBaseExtendedObject
-{
-Q_OBJECT
-Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty);
-public:
- MyExtendedObject() : m_value(0) {}
-
- int coreProperty() const { return m_value; }
- void setCoreProperty(int v) { m_value = v; }
-
-private:
- int m_value;
-};
-QML_DECLARE_TYPE(MyExtendedObject);
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_FLAGS(MyFlags)
-
- Q_PROPERTY(QString id READ id WRITE setId);
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
- Q_PROPERTY(QmlComponent *componentProperty READ componentProperty WRITE setComponentProperty);
- Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty);
- Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty);
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty);
- Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty);
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
- Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
- Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
- Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
- Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
- Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
- Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
- Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty);
- Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty);
- Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty);
- Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty);
- Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty);
- Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged);
- Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2);
- Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
- Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
- Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
- Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty);
-
- Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
-
-public:
- MyTypeObject()
- : objectPropertyValue(0), componentPropertyValue(0) {}
-
- QString idValue;
- QString id() const {
- return idValue;
- }
- void setId(const QString &v) {
- idValue = v;
- }
-
- QObject *objectPropertyValue;
- QObject *objectProperty() const {
- return objectPropertyValue;
- }
- void setObjectProperty(QObject *v) {
- objectPropertyValue = v;
- }
-
- QmlComponent *componentPropertyValue;
- QmlComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QmlComponent *v) {
- componentPropertyValue = v;
- }
-
- enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
- Q_DECLARE_FLAGS(MyFlags, MyFlag)
- MyFlags flagPropertyValue;
- MyFlags flagProperty() const {
- return flagPropertyValue;
- }
- void setFlagProperty(MyFlags v) {
- flagPropertyValue = v;
- }
-
- enum MyEnum { EnumVal1, EnumVal2 };
- MyEnum enumPropertyValue;
- MyEnum enumProperty() const {
- return enumPropertyValue;
- }
- void setEnumProperty(MyEnum v) {
- enumPropertyValue = v;
- }
-
- QString stringPropertyValue;
- QString stringProperty() const {
- return stringPropertyValue;
- }
- void setStringProperty(const QString &v) {
- stringPropertyValue = v;
- }
-
- uint uintPropertyValue;
- uint uintProperty() const {
- return uintPropertyValue;
- }
- void setUintProperty(const uint &v) {
- uintPropertyValue = v;
- }
-
- int intPropertyValue;
- int intProperty() const {
- return intPropertyValue;
- }
- void setIntProperty(const int &v) {
- intPropertyValue = v;
- }
-
- qreal realPropertyValue;
- qreal realProperty() const {
- return realPropertyValue;
- }
- void setRealProperty(const qreal &v) {
- realPropertyValue = v;
- }
-
- double doublePropertyValue;
- double doubleProperty() const {
- return doublePropertyValue;
- }
- void setDoubleProperty(const double &v) {
- doublePropertyValue = v;
- }
-
- float floatPropertyValue;
- float floatProperty() const {
- return floatPropertyValue;
- }
- void setFloatProperty(const float &v) {
- floatPropertyValue = v;
- }
-
- QColor colorPropertyValue;
- QColor colorProperty() const {
- return colorPropertyValue;
- }
- void setColorProperty(const QColor &v) {
- colorPropertyValue = v;
- }
-
- QDate datePropertyValue;
- QDate dateProperty() const {
- return datePropertyValue;
- }
- void setDateProperty(const QDate &v) {
- datePropertyValue = v;
- }
-
- QTime timePropertyValue;
- QTime timeProperty() const {
- return timePropertyValue;
- }
- void setTimeProperty(const QTime &v) {
- timePropertyValue = v;
- }
-
- QDateTime dateTimePropertyValue;
- QDateTime dateTimeProperty() const {
- return dateTimePropertyValue;
- }
- void setDateTimeProperty(const QDateTime &v) {
- dateTimePropertyValue = v;
- }
-
- QPoint pointPropertyValue;
- QPoint pointProperty() const {
- return pointPropertyValue;
- }
- void setPointProperty(const QPoint &v) {
- pointPropertyValue = v;
- }
-
- QPointF pointFPropertyValue;
- QPointF pointFProperty() const {
- return pointFPropertyValue;
- }
- void setPointFProperty(const QPointF &v) {
- pointFPropertyValue = v;
- }
-
- QSize sizePropertyValue;
- QSize sizeProperty() const {
- return sizePropertyValue;
- }
- void setSizeProperty(const QSize &v) {
- sizePropertyValue = v;
- }
-
- QSizeF sizeFPropertyValue;
- QSizeF sizeFProperty() const {
- return sizeFPropertyValue;
- }
- void setSizeFProperty(const QSizeF &v) {
- sizeFPropertyValue = v;
- }
-
- QRect rectPropertyValue;
- QRect rectProperty() const {
- return rectPropertyValue;
- }
- void setRectProperty(const QRect &v) {
- rectPropertyValue = v;
- emit rectPropertyChanged();
- }
-
- QRect rectPropertyValue2;
- QRect rectProperty2() const {
- return rectPropertyValue2;
- }
- void setRectProperty2(const QRect &v) {
- rectPropertyValue2 = v;
- }
-
- QRectF rectFPropertyValue;
- QRectF rectFProperty() const {
- return rectFPropertyValue;
- }
- void setRectFProperty(const QRectF &v) {
- rectFPropertyValue = v;
- }
-
- bool boolPropertyValue;
- bool boolProperty() const {
- return boolPropertyValue;
- }
- void setBoolProperty(const bool &v) {
- boolPropertyValue = v;
- }
-
- QVariant variantPropertyValue;
- QVariant variantProperty() const {
- return variantPropertyValue;
- }
- void setVariantProperty(const QVariant &v) {
- variantPropertyValue = v;
- }
-
- QVector3D vectorPropertyValue;
- QVector3D vectorProperty() const {
- return vectorPropertyValue;
- }
- void setVectorProperty(const QVector3D &v) {
- vectorPropertyValue = v;
- }
-
- QUrl urlPropertyValue;
- QUrl urlProperty() const {
- return urlPropertyValue;
- }
- void setUrlProperty(const QUrl &v) {
- urlPropertyValue = v;
- }
-
- QmlScriptString scriptPropertyValue;
- QmlScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QmlScriptString &v) {
- scriptPropertyValue = v;
- }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-QML_DECLARE_TYPE(MyTypeObject);
-
-Q_DECLARE_METATYPE(QScriptValue);
-class MyInvokableObject : public QObject
-{
- Q_OBJECT
-public:
- MyInvokableObject() { reset(); }
-
- int invoked() const { return m_invoked; }
- bool error() const { return m_invokedError; }
- const QVariantList &actuals() const { return m_actuals; }
- void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
-
- Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
- Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
-
- Q_INVOKABLE void method_NoArgs() { invoke(0); }
- Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
- Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.7; }
- Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
- Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
- Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
- Q_INVOKABLE QScriptValue method_NoArgs_QScriptValue() { invoke(6); return QScriptValue("Hello world"); }
- Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
-
- Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
- Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
- Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
- Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
- Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
- Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_QScriptValue(QScriptValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_intQScriptValue(int a, QScriptValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
-
- Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
- Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
-
-private:
- void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
- int m_invoked;
- bool m_invokedError;
- QVariantList m_actuals;
-};
-
-#endif // TESTTYPES_H
-
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
deleted file mode 100644
index b30ad1c1b1..0000000000
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ /dev/null
@@ -1,1659 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdebug.h>
-#include <QtDeclarative/private/qmlguard_p.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qnumeric.h>
-#include <private/qmlengine_p.h>
-#include <private/qmlglobalscriptclass_p.h>
-#include "testtypes.h"
-
-/*
-This test covers evaluation of ECMAScript expressions and bindings from within
-QML. This does not include static QML language issues.
-
-Static QML language issues are covered in qmllanguage
-*/
-inline QUrl TEST_FILE(const QString &filename)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-class tst_qmlecmascript : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlecmascript() {}
-
-private slots:
- void assignBasicTypes();
- void idShortcutInvalidates();
- void boolPropertiesEvaluateAsBool();
- void methods();
- void signalAssignment();
- void bindingLoop();
- void basicExpressions();
- void basicExpressions_data();
- void arrayExpressions();
- void contextPropertiesTriggerReeval();
- void objectPropertiesTriggerReeval();
- void deferredProperties();
- void extensionObjects();
- void attachedProperties();
- void enums();
- void valueTypeFunctions();
- void constantsOverrideBindings();
- void outerBindingOverridesInnerBinding();
- void aliasPropertyAndBinding();
- void nonExistantAttachedObject();
- void scope();
- void signalParameterTypes();
- void objectsCompareAsEqual();
- void scriptAccess();
- void dynamicCreation_data();
- void dynamicCreation();
- void dynamicDestruction();
- void objectToString();
- void selfDeletingBinding();
- void extendedObjectPropertyLookup();
- void scriptErrors();
- void signalTriggeredBindings();
- void listProperties();
- void exceptionClearsOnReeval();
- void exceptionSlotProducesWarning();
- void exceptionBindingProducesWarning();
- void transientErrors();
- void shutdownErrors();
- void externalScript();
- void compositePropertyType();
- void jsObject();
- void undefinedResetsProperty();
- void listToVariant();
- void multiEngineObject();
- void deletedObject();
-
- void bug1();
-
- void callQtInvokables();
-private:
- QmlEngine engine;
-};
-
-void tst_qmlecmascript::assignBasicTypes()
-{
- {
- QmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.7));
- QCOMPARE((float)object->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
- {
- QmlComponent component(&engine, TEST_FILE("assignBasicTypes.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.7));
- QCOMPARE((float)object->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
-}
-
-void tst_qmlecmascript::idShortcutInvalidates()
-{
- {
- QmlComponent component(&engine, TEST_FILE("idShortcutInvalidates.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("idShortcutInvalidates.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- }
-}
-
-void tst_qmlecmascript::boolPropertiesEvaluateAsBool()
-{
- {
- QmlComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- }
- {
- QmlComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- }
-}
-
-void tst_qmlecmascript::signalAssignment()
-{
- {
- QmlComponent component(&engine, TEST_FILE("signalAssignment.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->basicSignal();
- QCOMPARE(object->string(), QString("pass"));
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("signalAssignment.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.3);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3"));
- }
-}
-
-void tst_qmlecmascript::methods()
-{
- {
- QmlComponent component(&engine, TEST_FILE("methods.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), false);
- emit object->basicSignal();
- QCOMPARE(object->methodCalled(), true);
- QCOMPARE(object->methodIntCalled(), false);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("methods.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), false);
- emit object->basicSignal();
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), true);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("methods.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("methods.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- QCOMPARE(object->property("test2").toInt(), 17);
- QCOMPARE(object->property("test3").toInt(), 16);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("methods.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 9);
- }
-}
-
-void tst_qmlecmascript::bindingLoop()
-{
- QmlComponent component(&engine, TEST_FILE("bindingLoop.qml"));
- QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\"";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qmlecmascript::basicExpressions_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QVariant>("result");
- QTest::addColumn<bool>("nest");
-
- QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false;
- QTest::newRow("Context property") << "a" << QVariant(1944) << false;
- QTest::newRow("Context property") << "a" << QVariant(1944) << true;
- QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false;
- QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true;
- QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false;
- QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true;
- QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false;
- QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true;
- QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false;
- QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true;
- QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false;
- QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false;
- QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false;
- QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true;
- QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true;
- QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true;
- QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true;
- QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true;
-}
-
-void tst_qmlecmascript::basicExpressions()
-{
- QFETCH(QString, expression);
- QFETCH(QVariant, result);
- QFETCH(bool, nest);
-
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- MyDefaultObject1 default1;
- MyDefaultObject2 default2;
- MyDefaultObject3 default3;
- object1.setStringProperty("Object1");
- object2.setStringProperty("Object2");
- object3.setStringProperty("Object3");
-
- QmlContext context(engine.rootContext());
- QmlContext nestedContext(&context);
-
- context.addDefaultObject(&default1);
- context.addDefaultObject(&default2);
- context.setContextProperty("a", QVariant(1944));
- context.setContextProperty("b", QVariant("Milk"));
- context.setContextProperty("object", &object1);
- context.setContextProperty("objectOverride", &object2);
- nestedContext.addDefaultObject(&default3);
- nestedContext.setContextProperty("b", QVariant("Cow"));
- nestedContext.setContextProperty("objectOverride", &object3);
- nestedContext.setContextProperty("millipedeLegs", QVariant(100));
-
- MyExpression expr(nest?&nestedContext:&context, expression);
- QCOMPARE(expr.value(), result);
-}
-
-void tst_qmlecmascript::arrayExpressions()
-{
- QObject obj1;
- QObject obj2;
- QObject obj3;
-
- QmlContext context(engine.rootContext());
- context.setContextProperty("a", &obj1);
- context.setContextProperty("b", &obj2);
- context.setContextProperty("c", &obj3);
-
- MyExpression expr(&context, "[a, b, c, 10]");
- QVariant result = expr.value();
- QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
- QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
- QCOMPARE(list.count(), 4);
- QCOMPARE(list.at(0), &obj1);
- QCOMPARE(list.at(1), &obj2);
- QCOMPARE(list.at(2), &obj3);
- QCOMPARE(list.at(3), (QObject *)0);
-}
-
-// Tests that modifying a context property will reevaluate expressions
-void tst_qmlecmascript::contextPropertiesTriggerReeval()
-{
- QmlContext context(engine.rootContext());
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject *object3 = new MyQmlObject;
-
- object1.setStringProperty("Hello");
- object2.setStringProperty("World");
-
- context.setContextProperty("testProp", QVariant(1));
- context.setContextProperty("testObj", &object1);
- context.setContextProperty("testObj2", object3);
-
- {
- MyExpression expr(&context, "testProp + 1");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant(2));
-
- context.setContextProperty("testProp", QVariant(2));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant(3));
- }
-
- {
- MyExpression expr(&context, "testProp + testProp + testProp");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant(6));
-
- context.setContextProperty("testProp", QVariant(4));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant(12));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("Hello"));
-
- context.setContextProperty("testObj", &object2);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty /**/");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("World"));
-
- context.setContextProperty("testObj", &object1);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("Hello"));
- }
-
- {
- MyExpression expr(&context, "testObj2");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant::fromValue((QObject *)object3));
- }
-
-}
-
-void tst_qmlecmascript::objectPropertiesTriggerReeval()
-{
- QmlContext context(engine.rootContext());
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- context.setContextProperty("testObj", &object1);
-
- object1.setStringProperty(QLatin1String("Hello"));
- object2.setStringProperty(QLatin1String("Dog"));
- object3.setStringProperty(QLatin1String("Cat"));
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant("Hello"));
-
- object1.setStringProperty(QLatin1String("World"));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.value(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.objectProperty.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.value(), QVariant());
-
- object1.setObjectProperty(&object2);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Dog"));
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Cat"));
-
- object1.setObjectProperty(0);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant());
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Cat"));
-
- object3.setStringProperty("Donkey");
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.value(), QVariant("Donkey"));
- }
-}
-
-void tst_qmlecmascript::deferredProperties()
-{
- QmlComponent component(&engine, TEST_FILE("deferredProperties.qml"));
- MyDeferredObject *object =
- qobject_cast<MyDeferredObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->value(), 0);
- QVERIFY(object->objectProperty() == 0);
- QVERIFY(object->objectProperty2() != 0);
- qmlExecuteDeferred(object);
- QCOMPARE(object->value(), 10);
- QVERIFY(object->objectProperty() != 0);
- MyQmlObject *qmlObject =
- qobject_cast<MyQmlObject *>(object->objectProperty());
- QVERIFY(qmlObject != 0);
- QCOMPARE(qmlObject->value(), 10);
- object->setValue(19);
- QCOMPARE(qmlObject->value(), 19);
-}
-
-void tst_qmlecmascript::extensionObjects()
-{
- QmlComponent component(&engine, TEST_FILE("extensionObjects.qml"));
- MyExtendedObject *object =
- qobject_cast<MyExtendedObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->baseProperty(), 13);
- QCOMPARE(object->coreProperty(), 9);
-
- object->setProperty("extendedProperty", QVariant(11));
- object->setProperty("baseExtendedProperty", QVariant(92));
- QCOMPARE(object->coreProperty(), 11);
- QCOMPARE(object->baseProperty(), 92);
-}
-
-void tst_qmlecmascript::attachedProperties()
-{
- QmlComponent component(&engine, TEST_FILE("attachedProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 19);
- QCOMPARE(object->property("b").toInt(), 19);
- QCOMPARE(object->property("c").toInt(), 19);
- QCOMPARE(object->property("d").toInt(), 19);
-
- // ### Need to test attached property assignment
-}
-
-void tst_qmlecmascript::enums()
-{
- // Existant enums
- {
- QmlComponent component(&engine, TEST_FILE("enums.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 0);
- QCOMPARE(object->property("b").toInt(), 1);
- QCOMPARE(object->property("c").toInt(), 2);
- QCOMPARE(object->property("d").toInt(), 3);
- QCOMPARE(object->property("e").toInt(), 0);
- QCOMPARE(object->property("f").toInt(), 1);
- QCOMPARE(object->property("g").toInt(), 2);
- QCOMPARE(object->property("h").toInt(), 3);
- QCOMPARE(object->property("i").toInt(), 19);
- QCOMPARE(object->property("j").toInt(), 19);
- }
- // Non-existent enums
- {
- QmlComponent component(&engine, TEST_FILE("enums.2.qml"));
-
- QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
- QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 0);
- QCOMPARE(object->property("b").toInt(), 0);
- }
-}
-
-void tst_qmlecmascript::valueTypeFunctions()
-{
- QmlComponent component(&engine, TEST_FILE("valueTypeFunctions.qml"));
- MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
- QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
-}
-
-/*
-Tests that writing a constant to a property with a binding on it disables the
-binding.
-*/
-void tst_qmlecmascript::constantsOverrideBindings()
-{
- // From ECMAScript
- {
- QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 0);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c2").toInt(), 9);
-
- emit object->basicSignal();
-
- QCOMPARE(object->property("c2").toInt(), 13);
- object->setProperty("c1", QVariant(8));
- QCOMPARE(object->property("c2").toInt(), 13);
- }
-
- // During construction
- {
- QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c2").toInt(), 10);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 10);
- }
-
-#if 0
- // From C++
- {
- QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 0);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c2").toInt(), 9);
-
- object->setProperty("c2", QVariant(13));
- QCOMPARE(object->property("c2").toInt(), 13);
- object->setProperty("c1", QVariant(7));
- QCOMPARE(object->property("c1").toInt(), 7);
- QCOMPARE(object->property("c2").toInt(), 13);
- }
-#endif
-}
-
-/*
-Tests that assigning a binding to a property that already has a binding causes
-the original binding to be disabled.
-*/
-void tst_qmlecmascript::outerBindingOverridesInnerBinding()
-{
- QmlComponent component(&engine,
- TEST_FILE("outerBindingOverridesInnerBinding.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c2").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 0);
-
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 0);
-
- object->setProperty("c3", QVariant(8));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 8);
- QCOMPARE(object->property("c3").toInt(), 8);
-}
-
-/*
-Access a non-existent attached object.
-
-Tests for a regression where this used to crash.
-*/
-void tst_qmlecmascript::nonExistantAttachedObject()
-{
- QmlComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qmlecmascript::scope()
-{
- {
- QmlComponent component(&engine, TEST_FILE("scope.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 1);
- QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toString(), QString("1Test"));
- QCOMPARE(object->property("test4").toString(), QString("2Test"));
- QCOMPARE(object->property("test5").toInt(), 1);
- QCOMPARE(object->property("test6").toInt(), 1);
- QCOMPARE(object->property("test7").toInt(), 2);
- QCOMPARE(object->property("test8").toInt(), 2);
- QCOMPARE(object->property("test9").toInt(), 1);
- QCOMPARE(object->property("test10").toInt(), 3);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("scope.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 19);
- QCOMPARE(object->property("test2").toInt(), 19);
- QCOMPARE(object->property("test3").toInt(), 11);
- QCOMPARE(object->property("test4").toInt(), 11);
- QCOMPARE(object->property("test5").toInt(), 24);
- QCOMPARE(object->property("test6").toInt(), 24);
- }
-}
-
-/*
-Tests that "any" type passes through a synthesized signal parameter. This
-is essentially a test of QmlMetaType::copy()
-*/
-void tst_qmlecmascript::signalParameterTypes()
-{
- QmlComponent component(&engine, TEST_FILE("signalParameterTypes.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- emit object->basicSignal();
-
- QCOMPARE(object->property("intProperty").toInt(), 10);
- QCOMPARE(object->property("realProperty").toReal(), 19.2);
- QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
- QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
-}
-
-/*
-Test that two JS objects for the same QObject compare as equal.
-*/
-void tst_qmlecmascript::objectsCompareAsEqual()
-{
- QmlComponent component(&engine, TEST_FILE("objectsCompareAsEqual.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
- QCOMPARE(object->property("test5").toBool(), true);
-}
-
-/*
-Confirm bindings and alias properties can coexist.
-
-Tests for a regression where the binding would not reevaluate.
-*/
-void tst_qmlecmascript::aliasPropertyAndBinding()
-{
- QmlComponent component(&engine, TEST_FILE("aliasPropertyAndBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 3);
- QCOMPARE(object->property("c3").toInt(), 3);
-
- object->setProperty("c2", QVariant(19));
-
- QCOMPARE(object->property("c2").toInt(), 19);
- QCOMPARE(object->property("c3").toInt(), 19);
-}
-
-/*
-Tests that only methods of Script {} blocks are exposed.
-*/
-void tst_qmlecmascript::scriptAccess()
-{
- QmlComponent component(&engine, TEST_FILE("scriptAccess.qml"));
-
- QString warning = component.url().toString() + ":16: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 10);
- QCOMPARE(object->property("test2").toInt(), 19);
- QCOMPARE(object->property("test3").toInt(), 0);
-}
-
-void tst_qmlecmascript::dynamicCreation_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QString>("createdName");
-
- QTest::newRow("One") << "createOne" << "objectOne";
- QTest::newRow("Two") << "createTwo" << "objectTwo";
- QTest::newRow("Three") << "createThree" << "objectThree";
-}
-
-/*
-Test using createQmlObject to dynamically generate an item
-Also using createComponent is tested.
-*/
-void tst_qmlecmascript::dynamicCreation()
-{
- QFETCH(QString, method);
- QFETCH(QString, createdName);
-
- QmlComponent component(&engine, TEST_FILE("dynamicCreation.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, method.toUtf8());
- QObject *created = object->objectProperty();
- QVERIFY(created);
- QCOMPARE(created->objectName(), createdName);
-}
-
-/*
- Tests the destroy function
-*/
-void tst_qmlecmascript::dynamicDestruction()
-{
- QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml"));
- QmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QmlGuard<QObject> createdQmlObject = 0;
-
- QMetaObject::invokeMethod(object, "create");
- createdQmlObject = object->objectProperty();
- QVERIFY(createdQmlObject);
- QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
-
- QMetaObject::invokeMethod(object, "killOther");
- QVERIFY(createdQmlObject);
- QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
- QVERIFY(createdQmlObject);
- for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
- if (createdQmlObject) {
- QTest::qWait(100);
- QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
- }
- }
- QVERIFY(!createdQmlObject);
-
- QMetaObject::invokeMethod(object, "killMe");
- QVERIFY(object);
- QTest::qWait(0);
- QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion);
- QVERIFY(!object);
-}
-
-/*
- tests that id.toString() works
-*/
-void tst_qmlecmascript::objectToString()
-{
- QmlComponent component(&engine, TEST_FILE("qmlToString.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "testToString");
- QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_"));
- QVERIFY(object->stringProperty().endsWith(", \"objName\")"));
-}
-
-/*
-Tests bindings that indirectly cause their own deletion work.
-
-This test is best run under valgrind to ensure no invalid memory access occur.
-*/
-void tst_qmlecmascript::selfDeletingBinding()
-{
- {
- QmlComponent component(&engine, TEST_FILE("selfDeletingBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("selfDeletingBinding.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- }
-}
-
-/*
-Test that extended object properties can be accessed.
-
-This test a regression where this used to crash. The issue was specificially
-for extended objects that did not include a synthesized meta object (so non-root
-and no synthesiszed properties).
-*/
-void tst_qmlecmascript::extendedObjectPropertyLookup()
-{
- QmlComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-/*
-Test file/lineNumbers for binding/Script errors.
-*/
-void tst_qmlecmascript::scriptErrors()
-{
- QmlComponent component(&engine, TEST_FILE("scriptErrors.qml"));
- QString url = component.url().toString();
-
- QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
- QString warning2 = url + ":7: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning3 = url + ":5: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":12: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning5 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning6 = url + ":9: Unable to assign [undefined] to int";
- QString warning7 = url + ":14: Error: Cannot assign to read-only property \"trueProperty\"";
- QString warning8 = url + ":15: Error: Cannot assign to non-existent property \"fakeProperty\"";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
- emit object->basicSignal();
-
- QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData());
- emit object->anotherBasicSignal();
-
- QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData());
- emit object->thirdBasicSignal();
-}
-
-/*
-Test bindings still work when the reeval is triggered from within
-a signal script.
-*/
-void tst_qmlecmascript::signalTriggeredBindings()
-{
- QmlComponent component(&engine, TEST_FILE("signalTriggeredBindings.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("base").toReal(), 50.);
- QCOMPARE(object->property("test1").toReal(), 50.);
- QCOMPARE(object->property("test2").toReal(), 50.);
-
- object->basicSignal();
-
- QCOMPARE(object->property("base").toReal(), 200.);
- QCOMPARE(object->property("test1").toReal(), 200.);
- QCOMPARE(object->property("test2").toReal(), 200.);
-
- object->argumentSignal(10, QString(), 10);
-
- QCOMPARE(object->property("base").toReal(), 400.);
- QCOMPARE(object->property("test1").toReal(), 400.);
- QCOMPARE(object->property("test2").toReal(), 400.);
-}
-
-/*
-Test that list properties can be iterated from ECMAScript
-*/
-void tst_qmlecmascript::listProperties()
-{
- QmlComponent component(&engine, TEST_FILE("listProperties.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 21);
- QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
-}
-
-void tst_qmlecmascript::exceptionClearsOnReeval()
-{
- QmlComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml"));
- QString url = component.url().toString();
-
- QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object.";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
-
- MyQmlObject object2;
- MyQmlObject object3;
- object2.setObjectProperty(&object3);
- object->setObjectProperty(&object2);
-
- QCOMPARE(object->property("test").toBool(), true);
-}
-
-void tst_qmlecmascript::exceptionSlotProducesWarning()
-{
- QmlComponent component(&engine, TEST_FILE("exceptionProducesWarning.qml"));
- QString url = component.url().toString();
-
- QString warning = component.url().toString() + ":6: Error: JS exception";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-}
-
-void tst_qmlecmascript::exceptionBindingProducesWarning()
-{
- QmlComponent component(&engine, TEST_FILE("exceptionProducesWarning2.qml"));
- QString url = component.url().toString();
-
- QString warning = component.url().toString() + ":5: Error: JS exception";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-}
-
-static int transientErrorsMsgCount = 0;
-static void transientErrorsMsgHandler(QtMsgType, const char *)
-{
- ++transientErrorsMsgCount;
-}
-
-// Check that transient binding errors are not displayed
-void tst_qmlecmascript::transientErrors()
-{
- QmlComponent component(&engine, TEST_FILE("transientErrors.qml"));
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-}
-
-// Check that errors during shutdown are minimized
-void tst_qmlecmascript::shutdownErrors()
-{
- QmlComponent component(&engine, TEST_FILE("shutdownErrors.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete object;
-
- qInstallMsgHandler(old);
- QCOMPARE(transientErrorsMsgCount, 0);
-}
-
-// Check that Script::source property works as expected
-void tst_qmlecmascript::externalScript()
-{
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
- QCOMPARE(object->property("test2").toInt(), 92);
- QCOMPARE(object->property("test3").toBool(), false);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("externalScript.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qmlecmascript::compositePropertyType()
-{
- QmlComponent component(&engine, TEST_FILE("compositePropertyType.qml"));
- QTest::ignoreMessage(QtDebugMsg, "hello world");
- QObject *object = qobject_cast<QObject *>(component.create());
- delete object;
-}
-
-// QTBUG-5759
-void tst_qmlecmascript::jsObject()
-{
- QmlComponent component(&engine, TEST_FILE("jsObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
-}
-
-void tst_qmlecmascript::undefinedResetsProperty()
-{
- {
- QmlComponent component(&engine, TEST_FILE("undefinedResetsProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 92);
-
- object->setProperty("setUndefined", true);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 13);
-
- object->setProperty("setUndefined", false);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 92);
-
- delete object;
- }
- {
- QmlComponent component(&engine, TEST_FILE("undefinedResetsProperty.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 19);
-
- QMetaObject::invokeMethod(object, "doReset");
-
- QCOMPARE(object->property("resettableProperty").toInt(), 13);
-
- delete object;
- }
-}
-
-// QTBUG-6781
-void tst_qmlecmascript::bug1()
-{
- QmlComponent component(&engine, TEST_FILE("bug.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 14);
-
- object->setProperty("a", 11);
-
- QCOMPARE(object->property("test").toInt(), 3);
-
- object->setProperty("b", true);
-
- QCOMPARE(object->property("test").toInt(), 9);
-
- delete object;
-}
-
-void tst_qmlecmascript::callQtInvokables()
-{
- MyInvokableObject o;
-
- QmlEngine qmlengine;
- QmlEnginePrivate *ep = QmlEnginePrivate::get(&qmlengine);
- QScriptEngine *engine = &ep->scriptEngine;
- ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
-
- // Non-existent methods
- o.reset();
- QCOMPARE(engine->evaluate("object.method_nonexistent()").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_nonexistent(10, 11)").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Insufficient arguments
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int()").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intint(10)").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Excessive arguments
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(10, 11)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(10));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intint(10, 11, 12)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 9);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(11));
-
- // Test return types
- o.reset();
- QCOMPARE(engine->evaluate("object.method_NoArgs()").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 0);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_int()").strictlyEquals(QScriptValue(engine, 6)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 2);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()");
- QVERIFY(ret.isVariant());
- QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 3);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- {
- QScriptValue ret = engine->evaluate("object.method_NoArgs_QObject()");
- QVERIFY(ret.isQObject());
- QCOMPARE(ret.toQObject(), (QObject *)&o);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 4);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_NoArgs_unknown()").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 5);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- QScriptValue ret = engine->evaluate("object.method_NoArgs_QScriptValue()");
- QVERIFY(ret.isString());
- QCOMPARE(ret.toString(), QString("Hello world"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 6);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_QVariant()").strictlyEquals(QScriptValue(engine, "QML rocks")));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 7);
- QCOMPARE(o.actuals().count(), 0);
-
- // Test arg types
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(94)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(\"94\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(\"not a number\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_int(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intint(122, 9)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 9);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(122));
- QCOMPARE(o.actuals().at(1), QVariant(9));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(94.3)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(\"94.3\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(\"not a number\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_real(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(\"Hello world\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(19)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("19"));
-
- o.reset();
- {
- QString expected = "MyInvokableObject(0x" + QString::number((intptr_t)&o, 16) + ")";
- QCOMPARE(engine->evaluate("object.method_QString(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(expected));
- }
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QString(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(0)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPointF())").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QPointF(object.method_get_QPoint())").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(0)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(\"Hello world\")").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QObject(object)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue(null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isNull());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue(undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isUndefined());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue(19)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).strictlyEquals(QScriptValue(engine, 19)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_QScriptValue([19, 20])").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(0)).isArray());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(4, null)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(4));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isNull());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(8, undefined)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(8));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isUndefined());
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(3, 19)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(3));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).strictlyEquals(QScriptValue(engine, 19)));
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_intQScriptValue(44, [19, 20])").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(44));
- QVERIFY(qvariant_cast<QScriptValue>(o.actuals().at(1)).isArray());
-
- // Test overloads - QML will always invoke the *last* method
- o.reset();
- QCOMPARE(engine->evaluate("object.method_overload()").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_overload(10)").isError(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QCOMPARE(engine->evaluate("object.method_overload(10, 11)").isUndefined(), true);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 17);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(11));
-}
-
-// QTBUG-5675
-void tst_qmlecmascript::listToVariant()
-{
- QmlComponent component(&engine, TEST_FILE("listToVariant.qml"));
-
- MyQmlContainer container;
-
- QmlContext context(engine.rootContext());
- context.addDefaultObject(&container);
-
- QObject *object = component.create(&context);
- QVERIFY(object != 0);
-
- QVariant v = object->property("test");
- QCOMPARE(v.userType(), qMetaTypeId<QmlListReference>());
- QVERIFY(qvariant_cast<QmlListReference>(v).object() == &container);
-
- delete object;
-}
-
-// QTBUG-7957
-void tst_qmlecmascript::multiEngineObject()
-{
- MyQmlObject obj;
- obj.setStringProperty("Howdy planet");
-
- QmlEngine e1;
- e1.rootContext()->setContextProperty("thing", &obj);
- QmlComponent c1(&e1, TEST_FILE("multiEngineObject.qml"));
-
- QmlEngine e2;
- e2.rootContext()->setContextProperty("thing", &obj);
- QmlComponent c2(&e2, TEST_FILE("multiEngineObject.qml"));
-
- QObject *o1 = c1.create();
- QObject *o2 = c2.create();
-
- QCOMPARE(o1->property("test").toString(), QString("Howdy planet"));
- QCOMPARE(o2->property("test").toString(), QString("Howdy planet"));
-
- delete o2;
- delete o1;
-}
-
-// Test that references to QObjects are cleanup when the object is destroyed
-void tst_qmlecmascript::deletedObject()
-{
- QmlComponent component(&engine, TEST_FILE("deletedObject.qml"));
-
- QObject *object = component.create();
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QEXPECT_FAIL("", "QTBUG-8077", Continue);
- QCOMPARE(object->property("test4").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qmlecmascript)
-
-#include "tst_qmlecmascript.moc"
diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro
deleted file mode 100644
index 1a0e5f4f90..0000000000
--- a/tests/auto/declarative/qmlengine/qmlengine.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlengine.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
deleted file mode 100644
index 6504d032b5..0000000000
--- a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlContext>
-#include <QNetworkAccessManager>
-#include <QPointer>
-#include <QDir>
-#include <QDesktopServices>
-#include <QDebug>
-#include <QmlComponent>
-#include <QmlNetworkAccessManagerFactory>
-
-class tst_qmlengine : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlengine() {}
-
-private slots:
- void rootContext();
- void networkAccessManager();
- void baseUrl();
- void contextForObject();
- void offlineStoragePath();
- void clearComponentCache();
-};
-
-void tst_qmlengine::rootContext()
-{
- QmlEngine engine;
-
- QVERIFY(engine.rootContext());
-
- QCOMPARE(engine.rootContext()->engine(), &engine);
- QVERIFY(engine.rootContext()->parentContext() == 0);
-}
-
-class NetworkAccessManagerFactory : public QmlNetworkAccessManagerFactory
-{
-public:
- NetworkAccessManagerFactory() : manager(0) {}
-
- QNetworkAccessManager *create(QObject *parent) {
- manager = new QNetworkAccessManager(parent);
- return manager;
- }
-
- QNetworkAccessManager *manager;
-};
-
-void tst_qmlengine::networkAccessManager()
-{
- QmlEngine *engine = new QmlEngine;
-
- // Test QmlEngine created manager
- QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
- QVERIFY(manager != 0);
- delete engine;
-
- // Test factory created manager
- engine = new QmlEngine;
- NetworkAccessManagerFactory factory;
- engine->setNetworkAccessManagerFactory(&factory);
- QVERIFY(engine->networkAccessManager() == factory.manager);
- delete engine;
-}
-
-void tst_qmlengine::baseUrl()
-{
- QmlEngine engine;
-
- QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
-
- QCOMPARE(engine.baseUrl(), cwd);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
-
- QDir dir = QDir::current();
- dir.cdUp();
- QVERIFY(dir != QDir::current());
- QDir::setCurrent(dir.path());
- QVERIFY(QDir::current() == dir);
-
- QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
- QCOMPARE(engine.baseUrl(), cwd2);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml")));
-
- engine.setBaseUrl(cwd);
- QCOMPARE(engine.baseUrl(), cwd);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
-}
-
-void tst_qmlengine::contextForObject()
-{
- QmlEngine *engine = new QmlEngine;
-
- // Test null-object
- QVERIFY(QmlEngine::contextForObject(0) == 0);
-
- // Test an object with no context
- QObject object;
- QVERIFY(QmlEngine::contextForObject(&object) == 0);
-
- // Test setting null-object
- QmlEngine::setContextForObject(0, engine->rootContext());
-
- // Test setting null-context
- QmlEngine::setContextForObject(&object, 0);
-
- // Test setting context
- QmlEngine::setContextForObject(&object, engine->rootContext());
- QVERIFY(QmlEngine::contextForObject(&object) == engine->rootContext());
-
- QmlContext context(engine->rootContext());
-
- // Try changing context
- QTest::ignoreMessage(QtWarningMsg, "QmlEngine::setContextForObject(): Object already has a QmlContext");
- QmlEngine::setContextForObject(&object, &context);
- QVERIFY(QmlEngine::contextForObject(&object) == engine->rootContext());
-
- // Delete context
- delete engine; engine = 0;
- QVERIFY(QmlEngine::contextForObject(&object) == 0);
-}
-
-void tst_qmlengine::offlineStoragePath()
-{
- // Without these set, QDesktopServices::storageLocation returns
- // strings with extra "//" at the end. We set them to ignore this problem.
- qApp->setApplicationName("tst_qmlengine");
- qApp->setOrganizationName("Nokia");
- qApp->setOrganizationDomain("nokia.com");
-
- QmlEngine engine;
-
- QDir dir(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
- dir.mkpath("QML");
- dir.cd("QML");
- dir.mkpath("OfflineStorage");
- dir.cd("OfflineStorage");
-
- QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path());
-
- engine.setOfflineStoragePath(QDir::homePath());
- QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
-}
-
-void tst_qmlengine::clearComponentCache()
-{
- QmlEngine engine;
-
- // Create original qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import Qt 4.6\nQtObject {\nproperty int test: 10\n}\n");
- file.close();
- }
-
- // Test "test" property
- {
- QmlComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 10);
- delete obj;
- }
-
- // Modify qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import Qt 4.6\nQtObject {\nproperty int test: 11\n}\n");
- file.close();
- }
-
- // Test cache hit
- {
- QmlComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 10);
- delete obj;
- }
-
- // Clear cache
- engine.clearComponentCache();
-
- // Test cache refresh
- {
- QmlComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 11);
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_qmlengine)
-
-#include "tst_qmlengine.moc"
diff --git a/tests/auto/declarative/qmlerror/qmlerror.pro b/tests/auto/declarative/qmlerror/qmlerror.pro
deleted file mode 100644
index fa9b79e887..0000000000
--- a/tests/auto/declarative/qmlerror/qmlerror.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlerror.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlerror/tst_qmlerror.cpp b/tests/auto/declarative/qmlerror/tst_qmlerror.cpp
deleted file mode 100644
index 12dde57f3c..0000000000
--- a/tests/auto/declarative/qmlerror/tst_qmlerror.cpp
+++ /dev/null
@@ -1,242 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlError>
-#include <QDebug>
-
-class tst_qmlerror : public QObject
-{
- Q_OBJECT
-private slots:
- void url();
- void description();
- void line();
- void column();
- void toString();
-
- void copy();
- void debug();
-};
-
-void tst_qmlerror::url()
-{
- QmlError error;
-
- QCOMPARE(error.url(), QUrl());
-
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
-
- QmlError error2 = error;
-
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
-
- error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
-}
-
-void tst_qmlerror::description()
-{
- QmlError error;
-
- QCOMPARE(error.description(), QString());
-
- error.setDescription("An Error");
-
- QCOMPARE(error.description(), QString("An Error"));
-
- QmlError error2 = error;
-
- QCOMPARE(error2.description(), QString("An Error"));
-
- error.setDescription("Another Error");
-
- QCOMPARE(error.description(), QString("Another Error"));
- QCOMPARE(error2.description(), QString("An Error"));
-}
-
-void tst_qmlerror::line()
-{
- QmlError error;
-
- QCOMPARE(error.line(), -1);
-
- error.setLine(102);
-
- QCOMPARE(error.line(), 102);
-
- QmlError error2 = error;
-
- QCOMPARE(error2.line(), 102);
-
- error.setLine(4);
-
- QCOMPARE(error.line(), 4);
- QCOMPARE(error2.line(), 102);
-}
-
-void tst_qmlerror::column()
-{
- QmlError error;
-
- QCOMPARE(error.column(), -1);
-
- error.setColumn(16);
-
- QCOMPARE(error.column(), 16);
-
- QmlError error2 = error;
-
- QCOMPARE(error2.column(), 16);
-
- error.setColumn(3);
-
- QCOMPARE(error.column(), 3);
- QCOMPARE(error2.column(), 16);
-}
-
-void tst_qmlerror::toString()
-{
- {
- QmlError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error"));
- }
-
- {
- QmlError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
-
- QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error"));
- }
-}
-
-void tst_qmlerror::copy()
-{
- QmlError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QmlError error2(error);
- QmlError error3;
- error3 = error;
-
- error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
- error.setDescription("Another Error");
- error.setLine(2);
- error.setColumn(33);
-
- QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
- QCOMPARE(error.description(), QString("Another Error"));
- QCOMPARE(error.line(), 2);
- QCOMPARE(error.column(), 33);
-
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
- QCOMPARE(error2.description(), QString("An Error"));
- QCOMPARE(error2.line(), 92);
- QCOMPARE(error2.column(), 13);
-
- QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml"));
- QCOMPARE(error3.description(), QString("An Error"));
- QCOMPARE(error3.line(), 92);
- QCOMPARE(error3.column(), 13);
-
-}
-
-void tst_qmlerror::debug()
-{
- {
- QmlError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error ");
- qWarning() << error;
- }
-
- {
- QUrl url(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("test.txt")));
- QmlError error;
- error.setUrl(url);
- error.setDescription("An Error");
- error.setLine(2);
- error.setColumn(5);
-
- QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
-
- qWarning() << error;
- }
-
- {
- QUrl url(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("foo.txt")));
- QmlError error;
- error.setUrl(url);
- error.setDescription("An Error");
- error.setLine(2);
- error.setColumn(5);
-
- QString out = url.toString() + ":2:5: An Error ";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
-
- qWarning() << error;
- }
-}
-
-
-
-QTEST_MAIN(tst_qmlerror)
-
-#include "tst_qmlerror.moc"
diff --git a/tests/auto/declarative/qmlfontloader/qmlfontloader.pro b/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
deleted file mode 100644
index bc89639393..0000000000
--- a/tests/auto/declarative/qmlfontloader/qmlfontloader.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlfontloader.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
deleted file mode 100644
index 41b5359655..0000000000
--- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlfontloader_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlfontloader : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlfontloader();
-
-private slots:
- void noFont();
- void namedFont();
- void localFont();
- void failLocalFont();
- void webFont();
- void failWebFont();
-
-private slots:
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlfontloader::tst_qmlfontloader()
-{
-}
-
-void tst_qmlfontloader::noFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->name(), QString(""));
- QCOMPARE(fontObject->source(), QUrl(""));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Null);
-
- delete fontObject;
-}
-
-void tst_qmlfontloader::namedFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { name: \"Helvetica\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->source(), QUrl(""));
- QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
-}
-
-void tst_qmlfontloader::localFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
-}
-
-void tst_qmlfontloader::failLocalFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("Cannot load font: QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" ) ").toUtf8().constData());
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
-}
-
-void tst_qmlfontloader::webFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("Starburst"));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready);
-}
-
-void tst_qmlfontloader::failWebFont()
-{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.com/Starburst.ttf\" ) ");
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QmlFontLoader::Error);
-}
-
-QTEST_MAIN(tst_qmlfontloader)
-
-#include "tst_qmlfontloader.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro b/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro
deleted file mode 100644
index 755de3f4a4..0000000000
--- a/tests/auto/declarative/qmlgraphicsanchors/qmlgraphicsanchors.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlgraphicsanchors.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
deleted file mode 100644
index aa6b56ae8d..0000000000
--- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp
+++ /dev/null
@@ -1,459 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlgraphicstext_p.h>
-#include <QtDeclarative/private/qmlgraphicsanchors_p_p.h>
-
-Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor)
-Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine)
-
-
-class tst_qmlgraphicsanchors : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsanchors() {}
-
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id);
-
-private slots:
- void basicAnchors();
- void loops();
- void illegalSets();
- void illegalSets_data();
- void reset();
- void reset_data();
- void resetConvenience();
- void nullItem();
- void nullItem_data();
- void crash1();
- void centerIn();
- void fill();
- void margins();
-};
-
-/*
- Find an item with the specified id.
-*/
-template<typename T>
-T *tst_qmlgraphicsanchors::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- QList<QGraphicsItem *> children = parent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(children.at(i)->toGraphicsObject());
- if (item) {
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- return static_cast<T*>(item);
- }
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
- }
-
- return 0;
-}
-
-void tst_qmlgraphicsanchors::basicAnchors()
-{
- QmlView *view = new QmlView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
-
- view->execute();
- qApp->processEvents();
-
- //sibling horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
-
- //parent horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
-
- //vertical
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
-
- //stretch
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
-
- //centerIn
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
-
- //margins
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
-
- //baseline
- QmlGraphicsText *text1 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text1"));
- QmlGraphicsText *text2 = findItem<QmlGraphicsText>(view->rootObject(), QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-// mostly testing that we don't crash
-void tst_qmlgraphicsanchors::loops()
-{
- {
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
-
- QString expect = "QML Text (" + view->source().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- qApp->processEvents();
-
- delete view;
- }
-
- {
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
-
- QString expect = "QML Image (" + view->source().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- view->execute();
- qApp->processEvents();
-
- delete view;
- }
-}
-
-void tst_qmlgraphicsanchors::illegalSets()
-{
- QFETCH(QString, qml);
- QFETCH(QString, warning);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
- if (!component.isReady())
- qWarning() << "Test errors:" << component.errors();
- QVERIFY(component.isReady());
- QObject *o = component.create();
- delete o;
-}
-
-void tst_qmlgraphicsanchors::illegalSets_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("warning");
-
- QTest::newRow("H - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
- << "QML Rectangle (file::2:23) Cannot specify left, right, and hcenter anchors.";
-
- foreach (const QString &side, QStringList() << "left" << "right") {
- QTest::newRow("H - anchor to V")
- << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
- << "QML Rectangle (file::2:13) Cannot anchor a horizontal edge to a vertical edge.";
-
- QTest::newRow("H - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("H - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "QML Rectangle (file::2:1) Cannot anchor item to self.";
- }
-
-
- QTest::newRow("V - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
- << "QML Rectangle (file::2:23) Cannot specify top, bottom, and vcenter anchors.";
-
- QTest::newRow("V - too many anchors with baseline")
- << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
- << "QML Text (file::2:47) Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
-
- foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
-
- QTest::newRow("V - anchor to H")
- << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
- << "QML Rectangle (file::2:13) Cannot anchor a vertical edge to a horizontal edge.";
-
- QTest::newRow("V - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("V - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "QML Rectangle (file::2:1) Cannot anchor item to self.";
- }
-
-
- QTest::newRow("centerIn - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
- << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
-
-
- QTest::newRow("fill - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
- << "QML Rectangle (file::2:45) Cannot anchor to an item that isn't a parent or sibling.";
-}
-
-void tst_qmlgraphicsanchors::reset()
-{
- QFETCH(QString, side);
- QFETCH(QmlGraphicsAnchorLine::AnchorLine, anchorLine);
- QFETCH(QmlGraphicsAnchors::UsedAnchor, usedAnchor);
-
- QmlGraphicsItem *baseItem = new QmlGraphicsItem;
-
- QmlGraphicsAnchorLine anchor;
- anchor.item = baseItem;
- anchor.anchorLine = anchorLine;
-
- QmlGraphicsItem *item = new QmlGraphicsItem;
-
- const QMetaObject *meta = item->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true);
-
- QVERIFY(p.reset(item->anchors()));
- QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qmlgraphicsanchors::reset_data()
-{
- QTest::addColumn<QString>("side");
- QTest::addColumn<QmlGraphicsAnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QmlGraphicsAnchors::UsedAnchor>("usedAnchor");
-
- QTest::newRow("left") << "left" << QmlGraphicsAnchorLine::Left << QmlGraphicsAnchors::HasLeftAnchor;
- QTest::newRow("top") << "top" << QmlGraphicsAnchorLine::Top << QmlGraphicsAnchors::HasTopAnchor;
- QTest::newRow("right") << "right" << QmlGraphicsAnchorLine::Right << QmlGraphicsAnchors::HasRightAnchor;
- QTest::newRow("bottom") << "bottom" << QmlGraphicsAnchorLine::Bottom << QmlGraphicsAnchors::HasBottomAnchor;
-
- QTest::newRow("hcenter") << "horizontalCenter" << QmlGraphicsAnchorLine::HCenter << QmlGraphicsAnchors::HasHCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QmlGraphicsAnchorLine::VCenter << QmlGraphicsAnchors::HasVCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QmlGraphicsAnchorLine::Baseline << QmlGraphicsAnchors::HasBaselineAnchor;
-}
-
-void tst_qmlgraphicsanchors::resetConvenience()
-{
- QmlGraphicsItem *baseItem = new QmlGraphicsItem;
- QmlGraphicsItem *item = new QmlGraphicsItem;
-
- //fill
- item->anchors()->setFill(baseItem);
- QVERIFY(item->anchors()->fill() == baseItem);
- item->anchors()->resetFill();
- QVERIFY(item->anchors()->fill() == 0);
-
- //centerIn
- item->anchors()->setCenterIn(baseItem);
- QVERIFY(item->anchors()->centerIn() == baseItem);
- item->anchors()->resetCenterIn();
- QVERIFY(item->anchors()->centerIn() == 0);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qmlgraphicsanchors::nullItem()
-{
- QFETCH(QString, side);
-
- QmlGraphicsAnchorLine anchor;
- QmlGraphicsItem *item = new QmlGraphicsItem;
-
- const QMetaObject *meta = item->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QTest::ignoreMessage(QtWarningMsg, "QML Item (unknown location) Cannot anchor to a null item.");
- QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor)));
-
- delete item;
-}
-
-void tst_qmlgraphicsanchors::nullItem_data()
-{
- QTest::addColumn<QString>("side");
-
- QTest::newRow("left") << "left";
- QTest::newRow("top") << "top";
- QTest::newRow("right") << "right";
- QTest::newRow("bottom") << "bottom";
-
- QTest::newRow("hcenter") << "horizontalCenter";
- QTest::newRow("vcenter") << "verticalCenter";
- QTest::newRow("baseline") << "baseline";
-}
-
-void tst_qmlgraphicsanchors::crash1()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
-
- QString expect = "QML Text (" + view->source().toString() + ":4:5" + ") Possible anchor loop detected on fill.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message
- view->execute();
- qApp->processEvents();
-
- delete view;
-}
-
-void tst_qmlgraphicsanchors::fill()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
-
- view->execute();
- qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler"));
- QCOMPARE(rect->x(), 0.0 + 10.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (QTBUG-6631)
- rect->anchors()->setLeftMargin(20.0);
- rect->anchors()->setRightMargin(0.0);
- rect->anchors()->setBottomMargin(0.0);
- rect->anchors()->setTopMargin(10.0);
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-
-void tst_qmlgraphicsanchors::centerIn()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
-
- view->execute();
- qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("centered"));
- QCOMPARE(rect->x(), 75.0 + 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (QTBUG-6631)
- rect->anchors()->setHorizontalCenterOffset(-20.0);
- rect->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 - 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- delete view;
-}
-
-void tst_qmlgraphicsanchors::margins()
-{
- QmlView *view = new QmlView;
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
-
- view->execute();
- qApp->processEvents();
- QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler"));
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rect->anchors()->setTopMargin(0.0);
- rect->anchors()->setMargins(20.0);
-
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-QTEST_MAIN(tst_qmlgraphicsanchors)
-
-#include "tst_qmlgraphicsanchors.moc"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro b/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro
deleted file mode 100644
index 877dfab8b5..0000000000
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/qmlgraphicsanimatedimage.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative network
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsanimatedimage.cpp ../shared/testhttpserver.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp
deleted file mode 100644
index 2342f25888..0000000000
--- a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlgraphicsimage_p.h>
-#include <private/qmlgraphicsanimatedimage_p.h>
-
-#include "../shared/testhttpserver.h"
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlgraphicsanimatedimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsanimatedimage() {}
-
-private slots:
- void play();
- void pause();
- void stopped();
- void setFrame();
- void frameCount();
- void remote();
- void remote_data();
- void invalidSource();
-};
-
-void tst_qmlgraphicsanimatedimage::play()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::pause()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QVERIFY(anim->isPaused());
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::stopped()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(!anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 0);
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::setFrame()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 2);
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::frameCount()
-{
- QmlEngine engine;
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml"));
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->frameCount(), 3);
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::remote()
-{
- QFETCH(QString, fileName);
- QFETCH(bool, paused);
-
- TestHTTPServer server(14445);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QmlEngine engine;
- QmlComponent component(&engine, QUrl("http://127.0.0.1:14445/" + fileName));
- TRY_WAIT(component.isReady());
-
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- TRY_WAIT(anim->isPlaying());
- if (paused) {
- TRY_WAIT(anim->isPaused());
- QCOMPARE(anim->currentFrame(), 2);
- }
-
- delete anim;
-}
-
-void tst_qmlgraphicsanimatedimage::remote_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::addColumn<bool>("paused");
-
- QTest::newRow("playing") << "stickman.qml" << false;
- QTest::newRow("paused") << "stickmanpause.qml" << true;
-}
-
-void tst_qmlgraphicsanimatedimage::invalidSource()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
-
- QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) ");
-
- QmlGraphicsAnimatedImage *anim = qobject_cast<QmlGraphicsAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QVERIFY(!anim->isPlaying());
- QVERIFY(!anim->isPaused());
- QCOMPARE(anim->currentFrame(), 0);
- QCOMPARE(anim->frameCount(), 0);
-}
-
-QTEST_MAIN(tst_qmlgraphicsanimatedimage)
-
-#include "tst_qmlgraphicsanimatedimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
deleted file mode 100644
index 1f606e5cee..0000000000
--- a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsborderimage.cpp ../shared/testhttpserver.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
deleted file mode 100644
index bb978d129c..0000000000
--- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsborderimage_p.h>
-#include <private/qmlgraphicsimagebase_p.h>
-#include <private/qmlgraphicsscalegrid_p_p.h>
-#include <private/qmlgraphicsloader_p.h>
-#include <QtDeclarative/qmlcontext.h>
-
-#include "../shared/testhttpserver.h"
-
-
-#define SERVER_PORT 14445
-#define SERVER_ADDR "http://127.0.0.1:14445"
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlgraphicsborderimage : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsborderimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void tileModes();
- void sciSource();
- void sciSource_data();
- void invalidSciFile();
- void pendingRemoteRequest();
- void pendingRemoteRequest_data();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsborderimage::tst_qmlgraphicsborderimage()
-{
-}
-
-void tst_qmlgraphicsborderimage::noSource()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
- << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
- << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
-}
-
-void tst_qmlgraphicsborderimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, remote);
- QFETCH(QString, error);
-
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(SRCDIR "/data");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qmlgraphicsborderimage::clearSource()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: srcImage }";
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QmlGraphicsBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QmlGraphicsBorderImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
-}
-
-void tst_qmlgraphicsborderimage::resized()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::smooth()
-{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::tileModes()
-{
- {
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Repeat);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
-
- delete obj;
- }
- {
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 150.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Round);
-
- delete obj;
- }
-}
-
-void tst_qmlgraphicsborderimage::sciSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, valid);
-
- bool remote = source.startsWith("http");
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(SRCDIR "/data");
- }
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
-
- if (valid) {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qmlgraphicsborderimage::sciSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("valid");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
-}
-
-void tst_qmlgraphicsborderimage::invalidSciFile()
-{
- QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun"
- QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea"
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->status(), QmlGraphicsImageBase::Error);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsborderimage::pendingRemoteRequest()
-{
- QFETCH(QString, source);
-
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->status(), QmlGraphicsBorderImage::Loading);
-
- // verify no crash
- // This will cause a delayed "QThread: Destroyed while thread is still running" warning
- delete obj;
- QTest::qWait(50);
-}
-
-void tst_qmlgraphicsborderimage::pendingRemoteRequest_data()
-{
- QTest::addColumn<QString>("source");
-
- QTest::newRow("png file") << "http://no-such-qt-server-like-this/none.png";
- QTest::newRow("sci file") << "http://no-such-qt-server-like-this/none.sci";
-}
-
-QTEST_MAIN(tst_qmlgraphicsborderimage)
-
-#include "tst_qmlgraphicsborderimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml
deleted file mode 100644
index 3e08359f08..0000000000
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import Qt 4.6
-
-Flickable {
- width: 100; height: 100
- viewportWidth: row.width; viewportHeight: row.height
-
- Row {
- id: row
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml
deleted file mode 100644
index 3ed173d53a..0000000000
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import Qt 4.6
-
-Flickable {
- width: 100; height: 100
- viewportWidth: column.width; viewportHeight: column.height
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml
deleted file mode 100644
index 1425d85b93..0000000000
--- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import Qt 4.6
-
-Flickable {
- width: 100; height: 100
- viewportWidth: column.width; viewportHeight: column.height
- pressDelay: 200; overShoot: false; interactive: false
- maximumFlickVelocity: 2000
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro b/tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro
deleted file mode 100644
index 7c4c95994f..0000000000
--- a/tests/auto/declarative/qmlgraphicsflickable/qmlgraphicsflickable.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsflickable.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
deleted file mode 100644
index b503571268..0000000000
--- a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp
+++ /dev/null
@@ -1,224 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsflickable_p.h>
-#include <private/qmlvaluetype_p.h>
-#include <math.h>
-
-class tst_qmlgraphicsflickable : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsflickable();
-
-private slots:
- void create();
- void horizontalViewportSize();
- void verticalViewportSize();
- void properties();
- void overShoot();
- void maximumFlickVelocity();
- void flickDeceleration();
- void pressDelay();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsflickable::tst_qmlgraphicsflickable()
-{
-}
-
-void tst_qmlgraphicsflickable::create()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
- QCOMPARE(obj->viewportX(), 0.);
- QCOMPARE(obj->viewportY(), 0.);
-
- QCOMPARE(obj->horizontalVelocity(), 0.);
- QCOMPARE(obj->verticalVelocity(), 0.);
- QCOMPARE(obj->reportedVelocitySmoothing(), 100.);
-
- QCOMPARE(obj->isInteractive(), true);
- QCOMPARE(obj->overShoot(), true);
- QCOMPARE(obj->pressDelay(), 0);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::horizontalViewportSize()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->viewportWidth(), 800.);
- QCOMPARE(obj->viewportHeight(), 300.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::verticalViewportSize()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->viewportWidth(), 200.);
- QCOMPARE(obj->viewportHeight(), 1200.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::properties()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml"));
- QmlGraphicsFlickable *obj = qobject_cast<QmlGraphicsFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isInteractive(), false);
- QCOMPARE(obj->overShoot(), false);
- QCOMPARE(obj->pressDelay(), 200);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- delete obj;
-}
-
-void tst_qmlgraphicsflickable::overShoot()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(overShootChanged()));
-
- QVERIFY(flickable);
- QVERIFY(!flickable->overShoot());
-
- flickable->setOverShoot(true);
- QVERIFY(flickable->overShoot());
- QCOMPARE(spy.count(),1);
- flickable->setOverShoot(true);
- QCOMPARE(spy.count(),1);
-
- flickable->setOverShoot(false);
- QVERIFY(!flickable->overShoot());
- QCOMPARE(spy.count(),2);
- flickable->setOverShoot(false);
- QCOMPARE(spy.count(),2);
-}
-
-void tst_qmlgraphicsflickable::maximumFlickVelocity()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
-
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qmlgraphicsflickable::flickDeceleration()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickDeceleration(), 1.0);
-
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(flickable->flickDeceleration(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qmlgraphicsflickable::pressDelay()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
- QmlGraphicsFlickable *flickable = qobject_cast<QmlGraphicsFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->pressDelay(), 100);
-
- flickable->setPressDelay(200);
- QCOMPARE(flickable->pressDelay(), 200);
- QCOMPARE(spy.count(),1);
- flickable->setPressDelay(200);
- QCOMPARE(spy.count(),1);
-}
-
-QTEST_MAIN(tst_qmlgraphicsflickable)
-
-#include "tst_qmlgraphicsflickable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro b/tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro
deleted file mode 100644
index b046086eee..0000000000
--- a/tests/auto/declarative/qmlgraphicsflipable/qmlgraphicsflipable.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsflipable.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp b/tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp
deleted file mode 100644
index 24dc2e8874..0000000000
--- a/tests/auto/declarative/qmlgraphicsflipable/tst_qmlgraphicsflipable.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsflipable_p.h>
-#include <private/qmlvaluetype_p.h>
-#include <QFontMetrics>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <math.h>
-
-class tst_qmlgraphicsflipable : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsflipable();
-
-private slots:
- void create();
- void checkFrontAndBack();
- void setFrontAndBack();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsflipable::tst_qmlgraphicsflipable()
-{
-}
-
-void tst_qmlgraphicsflipable::create()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QmlGraphicsFlipable *obj = qobject_cast<QmlGraphicsFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- delete obj;
-}
-
-void tst_qmlgraphicsflipable::checkFrontAndBack()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QmlGraphicsFlipable *obj = qobject_cast<QmlGraphicsFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
- delete obj;
-}
-
-void tst_qmlgraphicsflipable::setFrontAndBack()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QmlGraphicsFlipable *obj = qobject_cast<QmlGraphicsFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
-
- QString message = "QML Flipable (" + c.url().toString() + ":3:1) front is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setFront(new QmlGraphicsRectangle());
-
- message = "QML Flipable (" + c.url().toString() + ":3:1) back is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setBack(new QmlGraphicsRectangle());
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlgraphicsflipable)
-
-#include "tst_qmlgraphicsflipable.moc"
diff --git a/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro b/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro
deleted file mode 100644
index 8eae8ae57a..0000000000
--- a/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsgridview.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
deleted file mode 100644
index 2520d4aac6..0000000000
--- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
+++ /dev/null
@@ -1,967 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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.h>
-#include <qmlcomponent.h>
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicsgridview_p.h>
-#include <private/qmlgraphicstext_p.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-
-class tst_QmlGraphicsGridView : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsGridView();
-
-private slots:
- void items();
- void changed();
- void inserted();
- void removed();
- void moved();
- void changeFlow();
- void currentIndex();
- void defaultValues();
- void properties();
- void positionViewAtIndex();
-
-private:
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
- void dumpTree(QmlGraphicsItem *parent, int depth = 0);
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-tst_QmlGraphicsGridView::tst_QmlGraphicsGridView()
-{
-}
-
-void tst_QmlGraphicsGridView::items()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- QCOMPARE(gridview->count(), model.count());
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // set an empty model and confirm that items are destroyed
- TestModel model2;
- ctxt->setContextProperty("testModel", &model2);
-
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- QVERIFY(itemCount == 0);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::changed()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.modifyItem(1, "Will", "9876");
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::inserted()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.insertItem(1, "Will", "9876");
-
- // let transitions settle.
- QTest::qWait(300);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- // let transitions settle.
- QTest::qWait(300);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- QCOMPARE(gridview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(300);
-
- gridview->setViewportY(120);
- QTest::qWait(300);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
- QTest::qWait(300);
-
- QVERIFY(gridview->viewportY() == 120);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::removed()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.removeItem(1);
-
- // let transitions settle.
- QTest::qWait(300);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
-
- // let transitions settle.
- QTest::qWait(300);
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items not visible
- model.removeItem(25);
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items before visible
- gridview->setViewportY(120);
- QTest::qWait(500);
- gridview->setCurrentIndex(10);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Setting currentIndex above shouldn't cause view to scroll
- QCOMPARE(gridview->viewportY(), 120.0);
-
- model.removeItem(1);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- for (int i = 6; i < 18; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // Remove currentIndex
- QmlGraphicsItem *oldCurrent = gridview->currentItem();
- model.removeItem(9);
- QTest::qWait(500);
-
- QCOMPARE(gridview->currentIndex(), 9);
- QVERIFY(gridview->currentItem() != oldCurrent);
-
- gridview->setViewportY(0);
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- // remove item outside current view.
- gridview->setCurrentIndex(32);
- QTest::qWait(500);
- gridview->setViewportY(240);
-
- model.removeItem(30);
- QVERIFY(gridview->currentIndex() == 31);
-
- // remove current item beyond visible items.
- gridview->setCurrentIndex(20);
- QTest::qWait(500);
- gridview->setViewportY(0);
- model.removeItem(20);
- QTest::qWait(500);
-
- QCOMPARE(gridview->currentIndex(), 20);
- QVERIFY(gridview->currentItem() != 0);
-
- // remove item before current, but visible
- gridview->setCurrentIndex(8);
- QTest::qWait(500);
- gridview->setViewportY(240);
- oldCurrent = gridview->currentItem();
- model.removeItem(6);
- QTest::qWait(500);
-
- QCOMPARE(gridview->currentIndex(), 7);
- QVERIFY(gridview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::moved()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- model.moveItem(1, 8);
-
- // let transitions settle.
- QTest::qWait(300);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 8);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(8));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 8);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(8));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- gridview->setViewportY(120);
-
- // move outside visible area
- model.moveItem(1, 25);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count()-1;
- for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // move from outside visible into visible
- model.moveItem(28, 8);
-
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::currentIndex()
-{
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(SRCDIR "/data/gridview-initCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- QTest::qWait(500);
-
- // current item should be third item
- QCOMPARE(gridview->currentIndex(), 5);
- QCOMPARE(gridview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 5));
- QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 6);
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), 9);
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 6);
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 5);
-
- // no wrap
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setCurrentIndex(model.count()-1);
- QTest::qWait(500);
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- // with wrap
- gridview->setWrapEnabled(true);
-
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
- QTest::qWait(500);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- QTest::qWait(500);
- QCOMPARE(gridview->viewportY(), 279.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTest::qWait(500);
- QCOMPARE(gridview->viewportY(), 0.0);
-
- // Test keys
- qApp->setActiveWindow(canvas);
- canvas->show();
- canvas->setFocus();
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 3);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setFlow(QmlGraphicsGridView::TopToBottom);
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 5);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
-
- QTest::qWait(500);
- QVERIFY(gridview->highlightItem());
- qreal hlPosX = gridview->highlightItem()->x();
- qreal hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTest::qWait(500);
- QCOMPARE(gridview->highlightItem()->x(), hlPosX);
- QCOMPARE(gridview->highlightItem()->y(), hlPosY);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::changeFlow()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
- QTest::qWait(500);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i/5)*80));
- QCOMPARE(item->y(), qreal((i%5)*60));
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsGridView::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml"));
- QmlGraphicsGridView *obj = qobject_cast<QmlGraphicsGridView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->model() == QVariant());
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->currentIndex(), -1);
- QVERIFY(obj->currentItem() == 0);
- QCOMPARE(obj->count(), 0);
- QVERIFY(obj->highlight() == 0);
- QVERIFY(obj->highlightItem() == 0);
- QCOMPARE(obj->highlightFollowsCurrentItem(), true);
- QVERIFY(obj->flow() == 0);
- QCOMPARE(obj->isWrapEnabled(), false);
- QCOMPARE(obj->cacheBuffer(), 0);
- QCOMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
- QCOMPARE(obj->cellHeight(), 100);
- delete obj;
-}
-
-void tst_QmlGraphicsGridView::properties()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml"));
- QmlGraphicsGridView *obj = qobject_cast<QmlGraphicsGridView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->model() != QVariant());
- QVERIFY(obj->delegate() != 0);
- QCOMPARE(obj->currentIndex(), 0);
- QVERIFY(obj->currentItem() != 0);
- QCOMPARE(obj->count(), 4);
- QVERIFY(obj->highlight() != 0);
- QVERIFY(obj->highlightItem() != 0);
- QCOMPARE(obj->highlightFollowsCurrentItem(), false);
- QVERIFY(obj->flow() == 0);
- QCOMPARE(obj->isWrapEnabled(), true);
- QCOMPARE(obj->cacheBuffer(), 200);
- QCOMPARE(obj->cellWidth(), 100);
- QCOMPARE(obj->cellHeight(), 100);
- delete obj;
-}
-
-void tst_QmlGraphicsGridView::positionViewAtIndex()
-{
- QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QmlGraphicsItem *viewport = gridview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(4);
- QCOMPARE(gridview->viewportY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21);
- QCOMPARE(gridview->viewportY(), 420.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31);
- QCOMPARE(gridview->viewportY(), 520.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0);
- QCOMPARE(gridview->viewportY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), (i%3)*80.);
- QCOMPARE(item->y(), (i/3)*60.);
- }
-
- delete canvas;
-}
-
-QmlView *tst_QmlGraphicsGridView::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QmlGraphicsGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlContext *context = QmlEngine::contextForObject(item);
- if (context) {
- if (context->contextProperty("index").toInt() == index) {
- return static_cast<T*>(item);
- }
- }
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-QList<T*> tst_QmlGraphicsGridView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- items.append(static_cast<T*>(item));
- //qDebug() << " found:" << item;
- }
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-void tst_QmlGraphicsGridView::dumpTree(QmlGraphicsItem *parent, int depth)
-{
- static QString padding(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- QmlContext *context = QmlEngine::contextForObject(item);
- qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1);
- dumpTree(item, depth+1);
- }
-}
-
-
-QTEST_MAIN(tst_QmlGraphicsGridView)
-
-#include "tst_qmlgraphicsgridview.moc"
diff --git a/tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro b/tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro
deleted file mode 100644
index b5f7f83d6b..0000000000
--- a/tests/auto/declarative/qmlgraphicsimage/qmlgraphicsimage.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsimage.cpp ../shared/testhttpserver.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
deleted file mode 100644
index a25dcd209e..0000000000
--- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
+++ /dev/null
@@ -1,247 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsimage_p.h>
-#include <private/qmlgraphicsimagebase_p.h>
-#include <private/qmlgraphicsloader_p.h>
-#include <QtDeclarative/qmlcontext.h>
-
-#include "../shared/testhttpserver.h"
-
-
-#define SERVER_PORT 14445
-#define SERVER_ADDR "http://127.0.0.1:14445"
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 60; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlgraphicsimage : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void pixmap();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlgraphicsimage::tst_qmlgraphicsimage()
-{
-}
-
-void tst_qmlgraphicsimage::noSource()
-{
- QString componentStr = "import Qt 4.6\nImage { source: \"\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QmlGraphicsImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
- << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) ";
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
- << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" ";
-}
-
-void tst_qmlgraphicsimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, remote);
- QFETCH(QString, error);
-
- TestHTTPServer server(SERVER_PORT);
- if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::clearSource()
-{
- QString componentStr = "import Qt 4.6\nImage { source: srcImage }";
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QmlGraphicsImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->progress(), 1.0);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QmlGraphicsImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->progress(), 0.0);
-}
-
-void tst_qmlgraphicsimage::resized()
-{
- QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::smooth()
-{
- QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
-
- delete obj;
-}
-
-void tst_qmlgraphicsimage::pixmap()
-{
- QString componentStr = "import Qt 4.6\nImage { pixmap: testPixmap }";
-
- QPixmap pixmap;
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("testPixmap", pixmap);
-
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QmlGraphicsImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 0.0);
- QVERIFY(obj->pixmap().isNull());
-
- pixmap = QPixmap(SRCDIR "/data/colors.png");
- ctxt->setContextProperty("testPixmap", pixmap);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QVERIFY(obj->status() == QmlGraphicsImage::Ready);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlgraphicsimage)
-
-#include "tst_qmlgraphicsimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro b/tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro
deleted file mode 100644
index ddabf9aa0f..0000000000
--- a/tests/auto/declarative/qmlgraphicsitem/qmlgraphicsitem.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsitem.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
deleted file mode 100644
index 820a6de514..0000000000
--- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp
+++ /dev/null
@@ -1,321 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlview.h>
-#include <QtDeclarative/qmlgraphicsitem.h>
-
-class tst_QmlGraphicsItem : public QObject
-
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsItem();
-
-private slots:
- void keys();
- void keyNavigation();
- void smooth();
- void clip();
-
-private:
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName);
- QmlEngine engine;
-};
-
-class KeysTestObject : public QObject
-{
- Q_OBJECT
-public:
- KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {}
-
- void reset() {
- mKey = 0;
- mText = QString();
- mModifiers = 0;
- mForwardedKey = 0;
- }
-
-public slots:
- void keyPress(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void keyRelease(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void forwardedKey(int key) {
- mForwardedKey = key;
- }
-
-public:
- int mKey;
- QString mText;
- int mModifiers;
- int mForwardedKey;
-
-private:
-};
-
-
-tst_QmlGraphicsItem::tst_QmlGraphicsItem()
-{
-}
-
-void tst_QmlGraphicsItem::keys()
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml"));
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
-
- canvas->execute();
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mText, QLatin1String("Return"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_0));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
- QCOMPARE(testObject->mText, QLatin1String("0"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_9));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
- QCOMPARE(testObject->mText, QLatin1String("9"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(!key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QmlGraphicsItem::keyNavigation()
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml"));
- canvas->execute();
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QmlGraphicsItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasFocus());
-}
-
-void tst_QmlGraphicsItem::smooth()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile(""));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged()));
-
- QVERIFY(item);
- QVERIFY(!item->smooth());
-
- item->setSmooth(true);
- QVERIFY(item->smooth());
- QCOMPARE(spy.count(),1);
- item->setSmooth(true);
- QCOMPARE(spy.count(),1);
-
- item->setSmooth(false);
- QVERIFY(!item->smooth());
- QCOMPARE(spy.count(),2);
- item->setSmooth(false);
- QCOMPARE(spy.count(),2);
-}
-
-void tst_QmlGraphicsItem::clip()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile(""));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged()));
-
- QVERIFY(item);
- QVERIFY(!item->clip());
-
- item->setClip(true);
- QVERIFY(item->clip());
- QCOMPARE(spy.count(),1);
- item->setClip(true);
- QCOMPARE(spy.count(),1);
-
- item->setClip(false);
- QVERIFY(!item->clip());
- QCOMPARE(spy.count(),2);
- item->setClip(false);
- QCOMPARE(spy.count(),2);
-}
-
-template<typename T>
-T *tst_QmlGraphicsItem::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- if (!parent)
- return 0;
-
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- return static_cast<T*>(item);
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-
-
-QTEST_MAIN(tst_QmlGraphicsItem)
-
-#include "tst_qmlgraphicsitem.moc"
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
deleted file mode 100644
index 99b3db645b..0000000000
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
+++ /dev/null
@@ -1,119 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- function checkProperties() {
- testObject.error = false;
- if (list.model != testModel) {
- console.log("model property incorrect");
- testObject.error = true;
- }
- if (!testObject.animate && list.delegate != myDelegate) {
- console.log("delegate property incorrect - expected myDelegate");
- testObject.error = true;
- }
- if (testObject.animate && list.delegate != animatedDelegate) {
- console.log("delegate property incorrect - expected animatedDelegate");
- testObject.error = true;
- }
- if (testObject.invalidHighlight && list.highlight != invalidHl) {
- console.log("highlight property incorrect - expected invalidHl");
- testObject.error = true;
- }
- if (!testObject.invalidHighlight && list.highlight != myHighlight) {
- console.log("highlight property incorrect - expected myHighlight");
- testObject.error = true;
- }
- }
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- },
- Component {
- id: animatedDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- ListView.onRemove: SequentialAnimation {
- ScriptAction { script: console.log("Fix PropertyAction with attached properties") }
-/*
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
-*/
- }
- }
- },
- Component {
- id: myHighlight
- Rectangle { color: "green" }
- },
- Component {
- id: invalidHl
- EaseFollow {}
- }
- ]
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- model: testModel
- delegate: testObject.animate ? animatedDelegate : myDelegate
- highlight: testObject.invalidHighlight ? invalidHl : myHighlight
- highlightMoveSpeed: 1000
- highlightResizeSpeed: 1000
- cacheBuffer: testObject.cacheBuffer
- }
-}
diff --git a/tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro b/tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro
deleted file mode 100644
index f00de3930c..0000000000
--- a/tests/auto/declarative/qmlgraphicslistview/qmlgraphicslistview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicslistview.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
deleted file mode 100644
index 13ed41df7c..0000000000
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ /dev/null
@@ -1,1374 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicslistview_p.h>
-#include <private/qmlgraphicstext_p.h>
-#include <private/qmlgraphicsvisualitemmodel_p.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-
-class tst_QmlGraphicsListView : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsListView();
-
-private slots:
- // Test both QListModelInterface and QAbstractItemModel model types
- void qListModelInterface_items();
- void qAbstractItemModel_items();
-
- void qListModelInterface_changed();
- void qAbstractItemModel_changed();
-
- void qListModelInterface_inserted();
- void qAbstractItemModel_inserted();
-
- void qListModelInterface_removed();
- void qAbstractItemModel_removed();
-
- void qListModelInterface_moved();
- void qAbstractItemModel_moved();
-
- void qListModelInterface_clear();
- void qAbstractItemModel_clear();
-
- void itemList();
- void currentIndex();
- void enforceRange();
- void spacing();
- void sections();
- void cacheBuffer();
- void positionViewAtIndex();
-
-private:
- template <class T> void items();
- template <class T> void changed();
- template <class T> void inserted();
- template <class T> void removed(bool animated);
- template <class T> void moved();
- template <class T> void clear();
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
- void dumpTree(QmlGraphicsItem *parent, int depth = 0);
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
- Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
- Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
-
-public:
- TestObject(QObject *parent = 0)
- : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
- , mCacheBuffer(0) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; emit changedError(); }
-
- bool animate() const { return mAnimate; }
- void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
-
- bool invalidHighlight() const { return mInvalidHighlight; }
- void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
-
- int cacheBuffer() const { return mCacheBuffer; }
- void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
-
-signals:
- void changedError();
- void changedAnim();
- void changedHl();
- void changedCacheBuffer();
-
-public:
- bool mError;
- bool mAnimate;
- bool mInvalidHighlight;
- int mCacheBuffer;
-};
-
-class TestModel : public QListModelInterface
-{
- Q_OBJECT
-public:
- TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
- ~TestModel() {}
-
- enum Roles { Name, Number };
-
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- int count() const { return list.count(); }
-
- QList<int> roles() const { return QList<int>() << Name << Number; }
- QString toString(int role) const {
- switch(role) {
- case Name:
- return "name";
- case Number:
- return "number";
- default:
- return "";
- }
- }
-
- QVariant data(int index, int role) const
- {
- if (role==0)
- return list.at(index).first;
- if (role==1)
- return list.at(index).second;
- return QVariant();
- }
- QHash<int, QVariant> data(int index, const QList<int> &roles) const {
- QHash<int,QVariant> returnHash;
-
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- QVariant info;
- switch(role) {
- case Name:
- info = list.at(index).first;
- break;
- case Number:
- info = list.at(index).second;
- break;
- default:
- break;
- }
- returnHash.insert(role, info);
- }
- return returnHash;
- }
-
- void addItem(const QString &name, const QString &number) {
- list.append(QPair<QString,QString>(name, number));
- emit itemsInserted(list.count()-1, 1);
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- list.insert(index, QPair<QString,QString>(name, number));
- emit itemsInserted(index, 1);
- }
-
- void removeItem(int index) {
- list.removeAt(index);
- emit itemsRemoved(index, 1);
- }
-
- void moveItem(int from, int to) {
- list.move(from, to);
- emit itemsMoved(from, to, 1);
- }
-
- void modifyItem(int index, const QString &name, const QString &number) {
- list[index] = QPair<QString,QString>(name, number);
- emit itemsChanged(index, 1, roles());
- }
-
- void clear() {
- int count = list.count();
- list.clear();
- emit itemsRemoved(0, count);
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-class TestModel2 : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel2(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
- void clear() {
- int count = list.count();
- emit beginRemoveRows(QModelIndex(), 0, count-1);
- list.clear();
- emit endRemoveRows();
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-tst_QmlGraphicsListView::tst_QmlGraphicsListView()
-{
-}
-
-template <class T>
-void tst_QmlGraphicsListView::items()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QVERIFY(listview->highlightItem() != 0);
- QCOMPARE(listview->count(), model.count());
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- // current item should be first item
- QCOMPARE(listview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 0));
-
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // switch to other delegate
- testObject->setAnimate(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
-
- // set invalid highlight
- testObject->setInvalidHighlight(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
- QVERIFY(listview->highlightItem() == 0);
-
- // back to normal highlight
- testObject->setInvalidHighlight(false);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
- QVERIFY(listview->currentItem());
- QVERIFY(listview->highlightItem() != 0);
-
- // set an empty model and confirm that items are destroyed
- T model2;
- ctxt->setContextProperty("testModel", &model2);
-
- // Allow deleteLaters to process
- QTest::qWait(500);
-
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- QVERIFY(itemCount == 0);
-
- QCOMPARE(listview->highlightResizeSpeed(), 1000.0);
- QCOMPARE(listview->highlightMoveSpeed(), 1000.0);
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::changed()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.modifyItem(1, "Will", "9876");
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::inserted()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.insertItem(1, "Will", "9876");
-
- // let transitions settle.
- QTest::qWait(500);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QCOMPARE(item->y(), i*20.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- // let transitions settle.
- QTest::qWait(500);
-
- QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- QCOMPARE(listview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QCOMPARE(item->y(), i*20.0);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
- QTest::qWait(500);
-
- listview->setViewportY(80);
- QTest::qWait(500);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
- QTest::qWait(500);
-
- QVERIFY(listview->viewportY() == 80);
-
- // Confirm items positioned correctly
- for (int i = 5; i < 5+15; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 - 20.0);
- }
-
-// QCOMPARE(listview->viewportHeight(), model.count() * 20.0);
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::removed(bool animated)
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- testObject->setAnimate(animated);
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.removeItem(1);
-
- // let transitions settle.
- QTest::qWait(500);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0); // post: top item starts at 20
-
- // let transitions settle.
- QTest::qWait(500);
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),i*20.0 + 20.0);
- }
-
- // Remove items not visible
- model.removeItem(18);
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),i*20.0+20.0);
- }
-
- // Remove items before visible
- listview->setViewportY(80);
- listview->setCurrentIndex(10);
-
- model.removeItem(1); // post: top item will be at 40
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly
- for (int i = 2; i < 18; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),40+i*20.0);
- }
-
- // Remove current index
- QVERIFY(listview->currentIndex() == 9);
- QmlGraphicsItem *oldCurrent = listview->currentItem();
- model.removeItem(9);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 9);
- QVERIFY(listview->currentItem() != oldCurrent);
-
- listview->setViewportY(40); // That's the top now
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(),40+i*20.0);
- }
-
- // remove current item beyond visible items.
- listview->setCurrentIndex(20);
- QTest::qWait(500);
- listview->setViewportY(40);
- model.removeItem(20);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 20);
- QVERIFY(listview->currentItem() != 0);
-
- // remove item before current, but visible
- listview->setCurrentIndex(8);
- QTest::qWait(500);
- oldCurrent = listview->currentItem();
- model.removeItem(6);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 7);
- QVERIFY(listview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-template <class T>
-void tst_QmlGraphicsListView::clear()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.clear();
-
- // let transitions settle.
- QTest::qWait(500);
-
- QVERIFY(listview->count() == 0);
- QVERIFY(listview->currentItem() == 0);
- QVERIFY(listview->viewportY() == 0);
-
- delete canvas;
-}
-
-
-template <class T>
-void tst_QmlGraphicsListView::moved()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- model.moveItem(1, 4);
-
- // let transitions settle.
- QTest::qWait(500);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(1));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 1);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(1));
-
- name = findItem<QmlGraphicsText>(viewport, "textName", 4);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(4));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", 4);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(4));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- listview->setViewportY(80);
-
- // move outside visible area
- model.moveItem(1, 18);
-
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 + 20);
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- // move from outside visible into visible
- model.moveItem(20, 4);
-
- // let transitions settle.
- QTest::qWait(500);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0 + 20);
- name = findItem<QmlGraphicsText>(viewport, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QmlGraphicsText>(viewport, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::enforceRange()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview-enforcerange.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QCOMPARE(listview->preferredHighlightBegin(), 100.0);
- QCOMPARE(listview->preferredHighlightEnd(), 100.0);
- QCOMPARE(listview->highlightRangeMode(), QmlGraphicsListView::StrictlyEnforceRange);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // view should be positioned at the top of the range.
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(listview->viewportY(), -100.0);
-
- QmlGraphicsText *name = findItem<QmlGraphicsText>(viewport, "textName", 0);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(0));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(viewport, "textNumber", 0);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when viewport moves
- listview->setViewportY(20);
- QTest::qWait(500);
-
- QCOMPARE(listview->currentIndex(), 6);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- listview->setSpacing(10);
- QVERIFY(listview->spacing() == 10);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*30);
- }
-
- listview->setSpacing(0);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.0);
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::sections()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview-sections.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- QVERIFY(item);
- QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
- }
-
- // Remove section boundary
- model.removeItem(5);
-
- // New section header created
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", 5);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
-
- model.insertItem(3, "New Item", "0");
-
- // Section header moved
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 5);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 6);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
-
- // insert item which will become a section header
- model.insertItem(6, "Replace header", "1");
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 6);
- QVERIFY(item);
- QCOMPARE(item->height(), 40.0);
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 7);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
-
- QCOMPARE(listview->currentSection(), QString("0"));
-
- listview->setViewportY(140);
- QCOMPARE(listview->currentSection(), QString("1"));
-
- listview->setViewportY(20);
- QCOMPARE(listview->currentSection(), QString("0"));
-
- item = findItem<QmlGraphicsItem>(viewport, "wrapper", 1);
- QVERIFY(item);
- QCOMPARE(item->height(), 20.0);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::currentIndex()
-{
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- QString filename(SRCDIR "/data/listview-initCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QTest::qWait(500);
-
- // current item should be third item
- QCOMPARE(listview->currentIndex(), 3);
- QCOMPARE(listview->currentItem(), findItem<QmlGraphicsItem>(viewport, "wrapper", 3));
- QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
-
- // no wrap
- listview->setCurrentIndex(0);
- QCOMPARE(listview->currentIndex(), 0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 1);
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- // with wrap
- ctxt->setContextProperty("testWrap", QVariant(true));
- QVERIFY(listview->isWrapEnabled());
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), model.count()-1);
-
- QTest::qWait(1000);
- QCOMPARE(listview->viewportY(), 279.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- QTest::qWait(1000);
- QCOMPARE(listview->viewportY(), 0.0);
-
- // Test keys
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
- QCOMPARE(listview->currentIndex(), 1);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
- QCOMPARE(listview->currentIndex(), 0);
-
- // turn off auto highlight
- listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
-
- QTest::qWait(500);
- QVERIFY(listview->highlightItem());
- qreal hlPos = listview->highlightItem()->y();
-
- listview->setCurrentIndex(4);
- QTest::qWait(500);
- QCOMPARE(listview->highlightItem()->y(), hlPos);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::itemList()
-{
- QmlView *canvas = createView(SRCDIR "/data/itemlist.qml");
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "view");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- QmlGraphicsVisualItemModel *model = canvas->rootObject()->findChild<QmlGraphicsVisualItemModel*>("itemModel");
- QVERIFY(model != 0);
-
- QVERIFY(model->count() == 3);
- QCOMPARE(listview->currentIndex(), 0);
-
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "item1");
- QVERIFY(item);
- QCOMPARE(item->x(), 0.0);
-
- QmlGraphicsText *text = findItem<QmlGraphicsText>(viewport, "text1");
- QVERIFY(text);
- QCOMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
- QTest::qWait(1000);
-
- item = findItem<QmlGraphicsItem>(viewport, "item3");
- QVERIFY(item);
- QCOMPARE(item->x(), 480.0);
-
- text = findItem<QmlGraphicsText>(viewport, "text3");
- QVERIFY(text);
- QCOMPARE(text->text(), QLatin1String("index: 2"));
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::cacheBuffer()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
- QVERIFY(listview->delegate() != 0);
- QVERIFY(listview->model() != 0);
- QVERIFY(listview->highlight() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- testObject->setCacheBuffer(400);
- QVERIFY(listview->cacheBuffer() == 400);
-
- int newItemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- QVERIFY(newItemCount > itemCount);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::positionViewAtIndex()
-{
- QmlView *canvas = createView(SRCDIR "/data/listview.qml");
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
-
- QmlGraphicsItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position on a currently visible item
- listview->positionViewAtIndex(3);
- QCOMPARE(listview->viewportY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position on an item beyond the visible items
- listview->positionViewAtIndex(22);
- QCOMPARE(listview->viewportY(), 440.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- listview->positionViewAtIndex(28);
- QCOMPARE(listview->viewportY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- // Position at the beginning again
- listview->positionViewAtIndex(0);
- QCOMPARE(listview->viewportY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->y(), i*20.);
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_items()
-{
- items<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_items()
-{
- items<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_changed()
-{
- changed<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_changed()
-{
- changed<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_inserted()
-{
- inserted<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_inserted()
-{
- inserted<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_removed()
-{
- removed<TestModel>(false);
- removed<TestModel>(true);
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_removed()
-{
- removed<TestModel2>(false);
- removed<TestModel2>(true);
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_moved()
-{
- moved<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_moved()
-{
- moved<TestModel2>();
-}
-
-void tst_QmlGraphicsListView::qListModelInterface_clear()
-{
- clear<TestModel>();
-}
-
-void tst_QmlGraphicsListView::qAbstractItemModel_clear()
-{
- clear<TestModel2>();
-}
-
-QmlView *tst_QmlGraphicsListView::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QmlGraphicsListView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-QList<T*> tst_QmlGraphicsListView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-void tst_QmlGraphicsListView::dumpTree(QmlGraphicsItem *parent, int depth)
-{
- static QString padding(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- qDebug() << padding.left(depth*2) << item;
- dumpTree(item, depth+1);
- }
-}
-
-
-QTEST_MAIN(tst_QmlGraphicsListView)
-
-#include "tst_qmlgraphicslistview.moc"
diff --git a/tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml b/tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml
deleted file mode 100644
index 627c7df143..0000000000
--- a/tests/auto/declarative/qmlgraphicsloader/data/GraphicsWidget250x250.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import Qt 4.6
-
-QGraphicsWidget {
- size: "250x250"
-}
diff --git a/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro b/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro
deleted file mode 100644
index 4837075302..0000000000
--- a/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../shared/
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsloader.cpp \
- ../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
deleted file mode 100644
index 2d3d5eefa4..0000000000
--- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp
+++ /dev/null
@@ -1,464 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtGui/QGraphicsWidget>
-#include <QtGui/QGraphicsScene>
-
-#include <QSignalSpy>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsloader_p.h>
-#include "testhttpserver.h"
-
-#define SERVER_PORT 14445
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-class tst_QmlGraphicsLoader : public QObject
-
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsLoader();
-
-private slots:
- void url();
- void invalidUrl();
- void component();
- void clear();
- void urlToComponent();
- void componentToUrl();
- void sizeLoaderToItem();
- void sizeItemToLoader();
- void noResize();
- void sizeLoaderToGraphicsWidget();
- void sizeGraphicsWidgetToLoader();
- void noResizeGraphicsWidget();
- void networkRequestUrl();
- void failNetworkRequest();
-// void networkComponent();
-
-private:
- QmlEngine engine;
-};
-
-
-tst_QmlGraphicsLoader::tst_QmlGraphicsLoader()
-{
-}
-
-void tst_QmlGraphicsLoader::url()
-{
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml"));
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::component()
-{
- QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::invalidUrl()
-{
- QTest::ignoreMessage(QtWarningMsg, QString("(:-1: File error for URL " + QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ") ").toUtf8().constData());
-
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Error);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::clear()
-{
- {
- QmlComponent component(&engine);
- component.setData(QByteArray(
- "import Qt 4.6\n"
- " Loader { id: loader\n"
- " source: 'Rect120x60.qml'\n"
- " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
- " }")
- , TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- QTest::qWait(500);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
- }
- {
- QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- loader->setSourceComponent(0);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
- }
-}
-
-void tst_QmlGraphicsLoader::urlToComponent()
-{
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\n"
- "Loader {\n"
- " id: loader\n"
- " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
- " source: \"Rect120x60.qml\"\n"
- " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
- "}" )
- , TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QTest::qWait(500);
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->width(), 10.0);
- QCOMPARE(loader->height(), 10.0);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::componentToUrl()
-{
- QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- loader->setSource(TEST_FILE("/Rect120x60.qml"));
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- delete loader;
-}
-
-void tst_QmlGraphicsLoader::sizeLoaderToItem()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeLoaderToItem);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- // Check resize
- QmlGraphicsItem *rect = qobject_cast<QmlGraphicsItem*>(loader->item());
- QVERIFY(rect);
- rect->setWidth(150);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeItemToLoader);
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- // notify
- QSignalSpy spy(loader, SIGNAL(resizeModeChanged()));
- loader->setResizeMode(QmlGraphicsLoader::NoResize);
- QCOMPARE(spy.count(),1);
- loader->setResizeMode(QmlGraphicsLoader::NoResize);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_QmlGraphicsLoader::sizeItemToLoader()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeItemToLoader);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QmlGraphicsItem *rect = qobject_cast<QmlGraphicsItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 200.0);
- QCOMPARE(rect->height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeLoaderToItem);
- rect->setWidth(160);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-}
-
-void tst_QmlGraphicsLoader::noResize()
-{
- QmlComponent component(&engine, TEST_FILE("/NoResize.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QmlGraphicsItem *rect = qobject_cast<QmlGraphicsItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 120.0);
- QCOMPARE(rect->height(), 60.0);
-}
-
-void tst_QmlGraphicsLoader::sizeLoaderToGraphicsWidget()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeLoaderToItem);
- QCOMPARE(loader->width(), 250.0);
- QCOMPARE(loader->height(), 250.0);
-
- // Check resize
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- widget->resize(QSizeF(150,45));
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeItemToLoader);
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(widget->size().width(), 180.0);
- QCOMPARE(widget->size().height(), 30.0);
-}
-
-void tst_QmlGraphicsLoader::sizeGraphicsWidgetToLoader()
-{
- QmlComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeItemToLoader);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- QCOMPARE(widget->size().width(), 200.0);
- QCOMPARE(widget->size().height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(widget->size().width(), 180.0);
- QCOMPARE(widget->size().height(), 30.0);
-
- // Switch mode
- loader->setResizeMode(QmlGraphicsLoader::SizeLoaderToItem);
- widget->resize(QSizeF(160,45));
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-}
-
-void tst_QmlGraphicsLoader::noResizeGraphicsWidget()
-{
- QmlComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml"));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- QCOMPARE(widget->size().width(), 250.0);
- QCOMPARE(widget->size().height(), 250.0);
-}
-
-void tst_QmlGraphicsLoader::networkRequestUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
-
- TRY_WAIT(loader->status() == QmlGraphicsLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-/* XXX Component waits until all dependencies are loaded. Is this actually possible?
-void tst_QmlGraphicsLoader::networkComponent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory("slowdata", TestHTTPServer::Delay);
-
- QmlComponent component(&engine);
- component.setData(QByteArray(
- "import Qt 4.6\n"
- "import \"http://127.0.0.1:14445/\" as NW\n"
- "Item {\n"
- " Component { id: comp; NW.SlowRect {} }\n"
- " Loader { sourceComponent: comp } }")
- , TEST_FILE(""));
-
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(item);
-
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- TRY_WAIT(loader->status() == QmlGraphicsLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QmlGraphicsLoader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-*/
-
-void tst_QmlGraphicsLoader::failNetworkRequest()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) ");
-
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/IDontExist.qml\" }"), TEST_FILE(""));
- QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create());
- QVERIFY(loader != 0);
-
- TRY_WAIT(loader->status() == QmlGraphicsLoader::Error);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
-}
-
-QTEST_MAIN(tst_QmlGraphicsLoader)
-
-#include "tst_qmlgraphicsloader.moc"
diff --git a/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro b/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro
deleted file mode 100644
index f85bf0fe7f..0000000000
--- a/tests/auto/declarative/qmlgraphicsmousearea/qmlgraphicsmousearea.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/testhttpserver.h
-SOURCES += tst_qmlgraphicsmousearea.cpp ../shared/testhttpserver.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp b/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp
deleted file mode 100644
index 869a7bd54b..0000000000
--- a/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp
+++ /dev/null
@@ -1,139 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qmlgraphicsmousearea_p.h>
-#include <QtDeclarative/qmlview.h>
-
-class tst_QmlGraphicsMouseArea: public QObject
-{
- Q_OBJECT
-private slots:
- void dragProperties();
-private:
- QmlView *createView(const QString &filename);
-};
-
-void tst_QmlGraphicsMouseArea::dragProperties()
-{
- QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsMouseArea *mouseRegion = canvas->rootObject()->findChild<QmlGraphicsMouseArea*>("mouseregion");
- QmlGraphicsDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QmlGraphicsItem *blackRect = canvas->rootObject()->findChild<QmlGraphicsItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(drag->axis(), QmlGraphicsDrag::XandYAxis);
- QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
- drag->setAxis(QmlGraphicsDrag::XAxis);
- QCOMPARE(drag->axis(), QmlGraphicsDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
- drag->setAxis(QmlGraphicsDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum properties
- QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
-
- QCOMPARE(drag->xmin(), 0.0);
- QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(drag->ymin(), 0.0);
- QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(drag->xmin(), 10.0);
- QCOMPARE(drag->xmax(), 10.0);
- QCOMPARE(drag->ymin(), 10.0);
- QCOMPARE(drag->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-}
-
-QmlView *tst_QmlGraphicsMouseArea::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QmlGraphicsMouseArea)
-
-#include "tst_qmlgraphicsmousearea.moc"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro b/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro
deleted file mode 100644
index 94eeb4e3f1..0000000000
--- a/tests/auto/declarative/qmlgraphicsparticles/qmlgraphicsparticles.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsparticles.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
deleted file mode 100644
index a5c0b78c58..0000000000
--- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp
+++ /dev/null
@@ -1,122 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-#include <qmlview.h>
-#include <private/qmlgraphicsparticles_p.h>
-
-class tst_QmlGraphicsParticles : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsParticles();
-
-private slots:
- void properties();
- void runs();
-private:
- QmlView *createView(const QString &filename);
-
-};
-
-tst_QmlGraphicsParticles::tst_QmlGraphicsParticles()
-{
-}
-
-void tst_QmlGraphicsParticles::properties()
-{
- QmlView *canvas = createView(SRCDIR "/data/particles.qml");
- QVERIFY(canvas->rootObject());
- QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
- QVERIFY(particles);
-
- particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
- QCOMPARE(particles->source(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
-
- particles->setLifeSpanDeviation(1000);
- QCOMPARE(particles->lifeSpanDeviation(), 1000);
-
- particles->setFadeInDuration(1000);
- QCOMPARE(particles->fadeInDuration(), 1000);
-
- particles->setFadeOutDuration(1000);
- QCOMPARE(particles->fadeOutDuration(), 1000);
-
- particles->setAngle(100.0);
- QCOMPARE(particles->angle(), 100.0);
-
- particles->setAngleDeviation(100.0);
- QCOMPARE(particles->angleDeviation(), 100.0);
-
- particles->setVelocity(100.0);
- QCOMPARE(particles->velocity(), 100.0);
-
- particles->setVelocityDeviation(100.0);
- QCOMPARE(particles->velocityDeviation(), 100.0);
-
- particles->setEmissionVariance(0.5);
- QCOMPARE(particles->emissionVariance(),0.5);
-
- particles->setEmissionRate(12);
- QCOMPARE(particles->emissionRate(), 12);
-}
-
-void tst_QmlGraphicsParticles::runs()
-{
- QmlView *canvas = createView(SRCDIR "/data/particles.qml");
- QVERIFY(canvas->rootObject());
- QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles");
- QVERIFY(particles);
- QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
-}
-
-QmlView *tst_QmlGraphicsParticles::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->execute();
-
- return canvas;
-}
-QTEST_MAIN(tst_QmlGraphicsParticles)
-
-#include "tst_qmlgraphicsparticles.moc"
diff --git a/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro b/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro
deleted file mode 100644
index 142a25698f..0000000000
--- a/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicspathview.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
deleted file mode 100644
index b986a64833..0000000000
--- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp
+++ /dev/null
@@ -1,491 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <private/qmlgraphicspathview_p.h>
-#include <private/qmlgraphicspath_p.h>
-#include <qmlcontext.h>
-#include <qmlexpression.h>
-#include <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlview.h>
-#include <QtDeclarative/private/qmlgraphicstext_p.h>
-#include <QtDeclarative/private/qmlgraphicsrectangle_p.h>
-#include <QAbstractListModel>
-#include <QFile>
-#include <private/qmlvaluetype_p.h>
-#include "../../../shared/util.h"
-
-class tst_QmlGraphicsPathView : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsPathView();
-
-private slots:
- void initValues();
- void items();
- void dataModel();
- void pathview2();
- void pathview3();
- void path();
- void pathMoved();
-
-private:
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
- Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
- int pathItemCount() const { return mPathItemCount; }
- void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
-
-signals:
- void useModelChanged();
- void pathItemCountChanged();
-
-private:
- bool mError;
- bool mUseModel;
- int mPathItemCount;
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-tst_QmlGraphicsPathView::tst_QmlGraphicsPathView()
-{
-}
-
-void tst_QmlGraphicsPathView::initValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml"));
- QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() == 0);
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->model(), QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->snapPosition(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 0);
- QCOMPARE(obj->pathItemCount(), -1);
-}
-
-void tst_QmlGraphicsPathView::items()
-{
- QmlView *canvas = createView(SRCDIR "/data/pathview.qml");
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
-
- for (int i = 0; i < model.count(); ++i) {
- QmlGraphicsText *name = findItem<QmlGraphicsText>(pathview, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QmlGraphicsText *number = findItem<QmlGraphicsText>(pathview, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QmlGraphicsPathView::pathview2()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml"));
- QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->snapPosition(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 10);
-}
-
-void tst_QmlGraphicsPathView::pathview3()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml"));
- QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 50.); // ???
- QCOMPARE(obj->snapPosition(), 0.5); // ???
- QCOMPARE(obj->dragMargin(), 24.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 4);
-}
-
-void tst_QmlGraphicsPathView::path()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/path.qml"));
- QmlGraphicsPath *obj = qobject_cast<QmlGraphicsPath*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->startX(), 120.);
- QCOMPARE(obj->startY(), 100.);
- QVERIFY(obj->path() != QPainterPath());
-
- QmlListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 5);
-
- QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list.at(0));
- QVERIFY(attr != 0);
- QCOMPARE(attr->name(), QString("scale"));
- QCOMPARE(attr->value(), 1.0);
-
- QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list.at(1));
- QVERIFY(quad != 0);
- QCOMPARE(quad->x(), 120.);
- QCOMPARE(quad->y(), 25.);
- QCOMPARE(quad->controlX(), 260.);
- QCOMPARE(quad->controlY(), 75.);
-
- QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list.at(2));
- QVERIFY(perc != 0);
- QCOMPARE(perc->value(), 0.3);
-
- QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list.at(3));
- QVERIFY(line != 0);
- QCOMPARE(line->x(), 120.);
- QCOMPARE(line->y(), 100.);
-
- QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list.at(4));
- QVERIFY(cubic != 0);
- QCOMPARE(cubic->x(), 180.);
- QCOMPARE(cubic->y(), 0.);
- QCOMPARE(cubic->control1X(), -10.);
- QCOMPARE(cubic->control1Y(), 90.);
- QCOMPARE(cubic->control2X(), 210.);
- QCOMPARE(cubic->control2Y(), 90.);
-}
-
-void tst_QmlGraphicsPathView::dataModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/datamodel.qml");
-
- QmlContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel model;
- model.addItem("red", "1");
- model.addItem("green", "2");
- model.addItem("blue", "3");
- model.addItem("purple", "4");
- model.addItem("gray", "5");
- model.addItem("brown", "6");
- model.addItem("yellow", "7");
- model.addItem("thistle", "8");
- model.addItem("cyan", "9");
-
- ctxt->setContextProperty("testData", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QmlGraphicsItem *item = findItem<QmlGraphicsItem>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 110.0);
- QCOMPARE(item->y(), 10.0);
-
- model.insertItem(4, "orange", "10");
-
- int itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 10);
-
- QmlGraphicsText *text = findItem<QmlGraphicsText>(pathview, "myText", 4);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(4));
-
- model.removeItem(2);
- text = findItem<QmlGraphicsText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- testObject->setPathItemCount(5);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- QmlGraphicsRectangle *testItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 4);
- QVERIFY(testItem != 0);
- testItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 5);
- QVERIFY(testItem == 0);
-
- model.insertItem(2, "pink", "2");
-
- itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- text = findItem<QmlGraphicsText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- model.removeItem(3);
- itemCount = findItems<QmlGraphicsItem>(pathview, "wrapper").count();
- QCOMPARE(itemCount, 5);
- text = findItem<QmlGraphicsText>(pathview, "myText", 3);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(3));
-
- delete canvas;
-}
-
-void tst_QmlGraphicsPathView::pathMoved()
-{
- QmlView *canvas = createView(SRCDIR "/data/pathview.qml");
-
- TestModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QmlGraphicsRectangle *firstItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QmlGraphicsPath *path = qobject_cast<QmlGraphicsPath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QCOMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(10);
- QTest::qWait(1000);//Moving is animated?
-
- for(int i=0; i<model.count(); i++){
- QmlGraphicsRectangle *curItem = findItem<QmlGraphicsRectangle>(pathview, "wrapper", i);
- QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25));
- }
-
- pathview->setOffset(100);
- QTest::qWait(1000);//Moving is animated?
- QCOMPARE(firstItem->pos() + offset, start);
-
- delete canvas;
-}
-
-QmlView *tst_QmlGraphicsPathView::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
- */
-template<typename T>
-T *tst_QmlGraphicsPathView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-QList<T*> tst_QmlGraphicsPathView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-QTEST_MAIN(tst_QmlGraphicsPathView)
-
-#include "tst_qmlgraphicspathview.moc"
diff --git a/tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro b/tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro
deleted file mode 100644
index d15102669c..0000000000
--- a/tests/auto/declarative/qmlgraphicspositioners/qmlgraphicspositioners.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlgraphicspositioners.cpp
-macx:CONFIG -= app_bundle
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
deleted file mode 100644
index b51266ab44..0000000000
--- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp
+++ /dev/null
@@ -1,417 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qmlview.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <qmlexpression.h>
-#include "../../../shared/util.h"
-
-class tst_QmlGraphicsPositioners : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsPositioners();
-
-private slots:
- void test_horizontal();
- void test_horizontal_spacing();
- void test_horizontal_animated();
- void test_vertical();
- void test_vertical_spacing();
- void test_vertical_animated();
- void test_grid();
- void test_grid_spacing();
- void test_grid_animated();
-
- void test_repeater();
-private:
- QmlView *createView(const QString &filename);
-};
-
-tst_QmlGraphicsPositioners::tst_QmlGraphicsPositioners()
-{
-}
-
-void tst_QmlGraphicsPositioners::test_horizontal()
-{
- QmlView *canvas = createView(SRCDIR "/data/horizontal.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
-}
-
-void tst_QmlGraphicsPositioners::test_horizontal_spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 60.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-}
-
-void tst_QmlGraphicsPositioners::test_horizontal_animated()
-{
- QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), 50.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-}
-
-void tst_QmlGraphicsPositioners::test_vertical()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 60.0);
-}
-
-void tst_QmlGraphicsPositioners::test_vertical_spacing()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 60.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 80.0);
-}
-
-void tst_QmlGraphicsPositioners::test_vertical_animated()
-{
- QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
-
- canvas->execute();
-
- //Note that they animate in
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->y(), -100.0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->y(), -100.0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->y(), -100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->x(), 0.0);
- QTRY_COMPARE(three->y(), 50.0);
- QTRY_COMPARE(three->x(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QTRY_COMPARE(two->opacity(), 1.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(three->y(), 50.0);
-
- QTRY_COMPARE(two->y(), 50.0);
- QTRY_COMPARE(three->y(), 100.0);
-
-}
-
-void tst_QmlGraphicsPositioners::test_grid()
-{
- QmlView *canvas = createView("data/grid.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-}
-
-void tst_QmlGraphicsPositioners::test_grid_spacing()
-{
- QmlView *canvas = createView("data/grid-spacing.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 54.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 78.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 54.0);
- QCOMPARE(five->x(), 54.0);
- QCOMPARE(five->y(), 54.0);
-}
-
-void tst_QmlGraphicsPositioners::test_grid_animated()
-{
- QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml");
- canvas->execute();
-
- //Note that all animate in
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QmlGraphicsRectangle *four = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QmlGraphicsRectangle *five = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
-}
-
-void tst_QmlGraphicsPositioners::test_repeater()
-{
- QmlView *canvas = createView("data/repeater.qml");
-
- canvas->execute();
-
- QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one");
- QVERIFY(one != 0);
-
- QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two");
- QVERIFY(two != 0);
-
- QmlGraphicsRectangle *three = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
-}
-
-QmlView *tst_QmlGraphicsPositioners::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-
-QTEST_MAIN(tst_QmlGraphicsPositioners)
-
-#include "tst_qmlgraphicspositioners.moc"
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro b/tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro
deleted file mode 100644
index 0a10ec69ae..0000000000
--- a/tests/auto/declarative/qmlgraphicsrepeater/qmlgraphicsrepeater.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicsrepeater.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp
deleted file mode 100644
index c971840025..0000000000
--- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qlistmodelinterface_p.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlview.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <private/qmlgraphicsrepeater_p.h>
-#include <private/qmlgraphicstext_p.h>
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-class tst_QmlGraphicsRepeater : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlGraphicsRepeater();
-
-private slots:
- void numberModel();
- void objectList();
- void stringList();
- void dataModel();
- void itemModel();
- void properties();
-
-private:
- QmlView *createView(const QString &filename);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id);
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(false) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
-signals:
- void useModelChanged();
-
-private:
- bool mError;
- bool mUseModel;
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-tst_QmlGraphicsRepeater::tst_QmlGraphicsRepeater()
-{
-}
-
-void tst_QmlGraphicsRepeater::numberModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/intmodel.qml");
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", 5);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsRepeater::objectList()
-{
- QmlView *canvas = createView(SRCDIR "/data/objlist.qml");
-
- QObjectList data;
- for(int i=0; i<100; i++){
- data << new QObject();
- data.back()->setProperty("idx", i);
- }
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
- QCOMPARE(repeater->property("instantiated").toInt(), 100);
-}
-
-/*
-The Repeater element creates children at its own position in its parent's
-stacking order. In this test we insert a repeater between two other Text
-elements to test this.
-*/
-void tst_QmlGraphicsRepeater::stringList()
-{
- QmlView *canvas = createView(SRCDIR "/data/repeater.qml");
-
- QStringList data;
- data << "One";
- data << "Two";
- data << "Three";
- data << "Four";
-
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", data);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), data.count() + 3);
-
- bool saw_repeater = false;
- for (int i = 0; i < container->childItems().count(); ++i) {
-
- if (i == 0) {
- QmlGraphicsText *name = qobject_cast<QmlGraphicsText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Zero"));
- } else if (i == container->childItems().count() - 2) {
- // The repeater itself
- QmlGraphicsRepeater *rep = qobject_cast<QmlGraphicsRepeater*>(container->childItems().at(i));
- QCOMPARE(rep, repeater);
- saw_repeater = true;
- continue;
- } else if (i == container->childItems().count() - 1) {
- QmlGraphicsText *name = qobject_cast<QmlGraphicsText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Last"));
- } else {
- QmlGraphicsText *name = qobject_cast<QmlGraphicsText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
- }
- }
- QVERIFY(saw_repeater);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsRepeater::dataModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/repeater2.qml");
- QmlContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
-
- ctxt->setContextProperty("testData", &testModel);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), 4);
-
- testModel.addItem("four", "4");
- QCOMPARE(container->childItems().count(), 5);
-
- testModel.removeItem(2);
- QCOMPARE(container->childItems().count(), 4);
-}
-
-void tst_QmlGraphicsRepeater::itemModel()
-{
- QmlView *canvas = createView(SRCDIR "/data/itemlist.qml");
- QmlContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->execute();
- qApp->processEvents();
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QmlGraphicsItem *container = findItem<QmlGraphicsItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), 1);
-
- testObject->setUseModel(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QCOMPARE(container->childItems().count(), 4);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
- QVERIFY(container->childItems().at(3) == repeater);
-
- delete canvas;
-}
-
-void tst_QmlGraphicsRepeater::properties()
-{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("/properties.qml"));
-
- QmlGraphicsItem *rootObject = qobject_cast<QmlGraphicsItem*>(component.create());
- QVERIFY(rootObject);
-
- QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
-
- QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
-
- QmlComponent rectComponent(&engine);
- rectComponent.setData("import Qt 4.6; Rectangle {}", QUrl::fromLocalFile(""));
-
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
-}
-
-QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-template<typename T>
-T *tst_QmlGraphicsRepeater::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
- return static_cast<T*>(parent);
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem*>(parent->childItems().at(i));
- if (!child)
- continue;
- QmlGraphicsItem *item = findItem<T>(child, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_QmlGraphicsRepeater)
-
-#include "tst_qmlgraphicsrepeater.moc"
diff --git a/tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro b/tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro
deleted file mode 100644
index 1d8c59fbbb..0000000000
--- a/tests/auto/declarative/qmlgraphicstext/qmlgraphicstext.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicstext.cpp
diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
deleted file mode 100644
index 2c1e09bc20..0000000000
--- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp
+++ /dev/null
@@ -1,844 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QTextDocument>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstext_p.h>
-#include <private/qmlvaluetype_p.h>
-#include <QFontMetrics>
-#include <QGraphicsSceneMouseEvent>
-#include <qmath.h>
-
-class tst_qmlgraphicstext : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicstext();
-
-private slots:
- void text();
- void width();
- void wrap();
- void elide();
- void textFormat();
-
- // ### these tests may be trivial
- void horizontalAlignment();
- void verticalAlignment();
- void font();
- void style();
- void color();
- void smooth();
-
- // QmlFontValueType
- void weight();
- void underline();
- void overline();
- void strikeout();
- void capitalization();
- void letterSpacing();
- void wordSpacing();
-
- void clickLink();
-
-private:
- QStringList standard;
- QStringList richText;
-
- QStringList horizontalAlignmentmentStrings;
- QStringList verticalAlignmentmentStrings;
-
- QList<Qt::Alignment> verticalAlignmentments;
- QList<Qt::Alignment> horizontalAlignmentments;
-
- QStringList styleStrings;
- QList<QmlGraphicsText::TextStyle> styles;
-
- QStringList colorStrings;
-
- QmlEngine engine;
-};
-
-tst_qmlgraphicstext::tst_qmlgraphicstext()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- horizontalAlignmentmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- verticalAlignmentmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- horizontalAlignmentments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- verticalAlignmentments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- styleStrings << "Normal"
- << "Outline"
- << "Raised"
- << "Sunken";
-
- styles << QmlGraphicsText::Normal
- << QmlGraphicsText::Outline
- << QmlGraphicsText::Raised
- << QmlGraphicsText::Sunken;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-void tst_qmlgraphicstext::text()
-{
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), QString(""));
- QVERIFY(textObject->width() == 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), standard.at(i));
- QVERIFY(textObject->width() > 0);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QString expected = richText.at(i);
- QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
- QVERIFY(textObject->width() > 0);
- }
-}
-
-void tst_qmlgraphicstext::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 0.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
-
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = qCeil(metricWidth);
-
- QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), qreal(metricWidth));
- QVERIFY(textObject->textFormat() == QmlGraphicsText::AutoText); // setting text doesn't change format
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
-
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
-
- int documentWidth = document.idealWidth();
-
- QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), qreal(documentWidth));
- QVERIFY(textObject->textFormat() == QmlGraphicsText::AutoText); // setting text doesn't change format
- }
-}
-
-void tst_qmlgraphicstext::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrap() == true);
- QCOMPARE(textObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
- }
-
-}
-
-void tst_qmlgraphicstext::elide()
-{
- for (QmlGraphicsText::TextElideMode m = QmlGraphicsText::ElideLeft; m<=QmlGraphicsText::ElideNone; m=QmlGraphicsText::TextElideMode(int(m)+1)) {
- const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
- QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
-
- // XXX Poor coverage.
-
- {
- QmlComponent textComponent(&engine);
- textComponent.setData(("import Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
- }
-
- // richtext - does nothing
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
- }
- }
-}
-
-void tst_qmlgraphicstext::textFormat()
-{
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsText::RichText);
- }
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsText::PlainText);
- }
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qmlgraphicstext::horizontalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstext::verticalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstext::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pointSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.pixelSize: 40; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pixelSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().bold(), true);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().italic(), true);
- QCOMPARE(textObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString("Helvetica"));
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString(""));
- }
-}
-
-void tst_qmlgraphicstext::style()
-{
- //test style
- for (int i = 0; i < styles.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE((int)textObject->style(), (int)styles.at(i));
- QCOMPARE(textObject->styleColor(), QColor("white"));
- }
-}
-
-void tst_qmlgraphicstext::color()
-{
- //test style
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor());
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
- // default color to black?
- QCOMPARE(textObject->color(), QColor("black"));
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- for (int j = 0; j < colorStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
- }
- }
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), testColor);
- }
-}
-
-void tst_qmlgraphicstext::smooth()
-{
- for (int i = 0; i < standard.size(); i++)
- {
- {
- QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
- }
- }
- for (int i = 0; i < richText.size(); i++)
- {
- {
- QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
- }
- }
-}
-
-void tst_qmlgraphicstext::weight()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Normal);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Bold);
- }
-}
-
-void tst_qmlgraphicstext::underline()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), false);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), true);
- }
-}
-
-void tst_qmlgraphicstext::overline()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), false);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), true);
- }
-}
-
-void tst_qmlgraphicstext::strikeout()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), false);
- }
- {
- QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), true);
- }
-}
-
-void tst_qmlgraphicstext::capitalization()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::MixedCase);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllUppercase);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllLowercase);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::SmallCaps);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::Capitalize);
- }
-}
-
-void tst_qmlgraphicstext::letterSpacing()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 0.0);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), -50.);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 200.);
- }
-}
-
-void tst_qmlgraphicstext::wordSpacing()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 0.0);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), -50.);
- }
- {
- QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 200.);
- }
-}
-
-class EventSender : public QGraphicsItem
-{
-public:
- void sendEvent(QEvent *event) { sceneEvent(event); }
-};
-
-class LinkTest : public QObject
-{
- Q_OBJECT
-public:
- LinkTest() {}
-
- QString link;
-
-public slots:
- void linkClicked(QString l) { link = l; }
-};
-
-void tst_qmlgraphicstext::clickLink()
-{
- {
- QString componentStr = "import Qt 4.6\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
- QmlComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- LinkTest test;
- QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
-
- {
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
- me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
- me.setButton(Qt::LeftButton);
- static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
- }
-
- {
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease);
- me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
- me.setButton(Qt::LeftButton);
- static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
- }
-
- QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
- }
-}
-
-QTEST_MAIN(tst_qmlgraphicstext)
-
-#include "tst_qmlgraphicstext.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro b/tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro
deleted file mode 100644
index a129120f4d..0000000000
--- a/tests/auto/declarative/qmlgraphicstextedit/qmlgraphicstextedit.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicstextedit.cpp ../shared/testhttpserver.cpp
-HEADERS += ../shared/testhttpserver.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp
deleted file mode 100644
index cc2f929d0c..0000000000
--- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include "../../../shared/util.h"
-#include "../shared/testhttpserver.h"
-#include <math.h>
-#include <QFile>
-#include <QTextDocument>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlexpression.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstextedit_p.h>
-#include <QFontMetrics>
-#include <QmlView>
-#include <QStyle>
-#include <QInputContext>
-
-class tst_qmlgraphicstextedit : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicstextedit();
-
-private slots:
- void text();
- void width();
- void wrap();
- void textFormat();
-
- // ### these tests may be trivial
- void hAlign();
- void vAlign();
- void font();
- void color();
- void textMargin();
- void persistentSelection();
- void focusOnPress();
- void selection();
- void inputMethodHints();
-
- void cursorDelegate();
- void delegateLoading();
- void navigation();
- void readOnly();
- void sendRequestSoftwareInputPanelEvent();
-
-private:
- void simulateKey(QmlView *, int key);
- QmlView *createView(const QString &filename);
-
- QStringList standard;
- QStringList richText;
-
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
-
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
-
- QStringList colorStrings;
-
- QmlEngine engine;
-};
-
-tst_qmlgraphicstextedit::tst_qmlgraphicstextedit()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- hAlignmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- vAlignmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- hAlignments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- vAlignments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-void tst_qmlgraphicstextedit::text()
-{
- {
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), QString(""));
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QString actual = textEditObject->text();
- QString expected = richText.at(i);
- actual.replace(QRegExp(".*<body[^>]*>"),"");
- actual.replace(QRegExp("(<[^>]*>)+"),"<>");
- expected.replace(QRegExp("(<[^>]*>)+"),"<>");
- QCOMPARE(actual.simplified(),expected.simplified());
- }
-}
-
-void tst_qmlgraphicstextedit::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 1.);//+1 for cursor
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = floor(metricWidth);
-
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(metricWidth + 1 + 3));//+3 is the current way of accounting for space between cursor and last character.
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
-
- int documentWidth = document.idealWidth();
-
- QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(documentWidth + 1 + 3));
- }
-}
-
-void tst_qmlgraphicstextedit::wrap()
-{
- // for specified width and wrap set true
- {
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
-}
-
-void tst_qmlgraphicstextedit::textFormat()
-{
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QmlGraphicsTextEdit *textObject = qobject_cast<QmlGraphicsTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsTextEdit::RichText);
- }
- {
- QmlComponent textComponent(&engine);
- textComponent.setData("import Qt 4.6\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QmlGraphicsTextEdit *textObject = qobject_cast<QmlGraphicsTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QmlGraphicsTextEdit::PlainText);
- }
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qmlgraphicstextedit::hAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstextedit::vAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
-}
-
-void tst_qmlgraphicstextedit::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().pointSize(), 40);
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().bold(), true);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().italic(), true);
- QCOMPARE(textEditObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString(""));
- }
-}
-
-void tst_qmlgraphicstextedit::color()
-{
- //test normal
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
- }
-
- //test selection
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
- }
-
- //test selected text
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), testColor);
- }
-}
-
-void tst_qmlgraphicstextedit::textMargin()
-{
- for(qreal i=0; i<=10; i+=0.3){
- QString componentStr = "import Qt 4.6\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->textMargin(), i);
- }
-}
-
-void tst_qmlgraphicstextedit::persistentSelection()
-{
- {
- QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->persistentSelection(), true);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: false; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->persistentSelection(), false);
- }
-}
-
-void tst_qmlgraphicstextedit::focusOnPress()
-{
- {
- QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), true);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: false; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), false);
- }
-}
-
-void tst_qmlgraphicstextedit::selection()
-{
- QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }";
- QmlComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
-
-
- //Test selection follows cursor
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorPosition(), i);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- QVERIFY(textEditObject->selectedText().isNull());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test selection
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
- }
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->setSelectionStart(i);
- QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- for(int i=0; i< testStr.size(); i++) {
- textEditObject->setSelectionStart(i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
- textEditObject->setSelectionEnd(i+1);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(testStr.mid(i,1), textEditObject->selectedText());
- }
-
- for(int i= testStr.size() - 1; i>0; i--) {
- textEditObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
- textEditObject->setSelectionStart(i-1);
- QCOMPARE(testStr.mid(i-1,1), textEditObject->selectedText());
- }
-
- //Test Error Ignoring behaviour
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionStart(-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionStart(100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionEnd(-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionEnd(100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->setSelectionStart(0);
- textEditObject->setSelectionEnd(10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionStart(-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionStart(100);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionEnd(-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->setSelectionEnd(100);
- QVERIFY(textEditObject->selectedText().size() == 10);
-}
-
-void tst_qmlgraphicstextedit::inputMethodHints()
-{
- QmlView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
-}
-
-void tst_qmlgraphicstextedit::cursorDelegate()
-{
- QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
- view->execute();
- view->show();
- view->setFocus();
- QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject");
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->findChild<QmlGraphicsItem*>("cursorInstance"));
- //Test Delegate gets created
- textEditObject->setFocus(true);
- QmlGraphicsItem* delegateObject = textEditObject->findChild<QmlGraphicsItem*>("cursorInstance");
- QVERIFY(delegateObject);
- //Test Delegate gets moved
- for(int i=0; i<= textEditObject->text().length(); i++){
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
- }
- textEditObject->setCursorPosition(0);
- QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textEditObject->setCursorDelegate(0);
- QVERIFY(!textEditObject->findChild<QmlGraphicsItem*>("cursorInstance"));
-}
-
-void tst_qmlgraphicstextedit::delegateLoading()
-{
- TestHTTPServer server(42332);
- server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect);
- server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
- server.serveDirectory(SRCDIR "/data/http");
- QmlView* view = new QmlView(0);
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml"));
- view->execute();
- view->show();
- view->setFocus();
- QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
- QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject");
- // view->rootObject()->dumpObjectTree();
- QVERIFY(textEditObject != 0);
- textEditObject->setFocus(true);
- QmlGraphicsItem *delegate;
- delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateSlow");
- QVERIFY(delegate);
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml"));
- view->execute();
- view->show();
- view->setFocus();
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml"));
- view->execute();
- view->show();
- view->setFocus();
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- //ErrorB should get a component which is ready but component.create() returns null
- //Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate
- //###This could be a case of overzealous defensive programming
- //delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateErrorB");
- //QVERIFY(!delegate);
-}
-
-/*
-TextEdit element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-*/
-void tst_qmlgraphicstextedit::navigation()
-{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == true);
-}
-
-void tst_qmlgraphicstextedit::readOnly()
-{
- QmlView *canvas = createView(SRCDIR "/data/readOnly.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextEdit *edit = qobject_cast<QmlGraphicsTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasFocus() == true);
- QVERIFY(edit->isReadOnly() == true);
- QString initial = edit->text();
- for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(canvas, k);
- simulateKey(canvas, Qt::Key_Return);
- simulateKey(canvas, Qt::Key_Space);
- simulateKey(canvas, Qt::Key_Escape);
- QCOMPARE(edit->text(), initial);
-}
-
-void tst_qmlgraphicstextedit::simulateKey(QmlView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QApplication::sendEvent(view, &press);
- QApplication::sendEvent(view, &release);
-}
-
-QmlView *tst_qmlgraphicstextedit::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- return canvas;
-}
-
-class MyInputContext : public QInputContext
-{
-public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
- ~MyInputContext() {}
-
- QString identifierName() { return QString(); }
- QString language() { return QString(); }
-
- void reset() {}
-
- bool isComposing() const { return false; }
-
- bool filterEvent( const QEvent *event )
- {
- if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
- return QInputContext::filterEvent(event);
- }
- bool softwareInputPanelEventReceived;
-};
-
-void tst_qmlgraphicstextedit::sendRequestSoftwareInputPanelEvent()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- if ((behavior != QStyle::RSIP_OnMouseClick))
- QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
- QmlGraphicsTextEdit edit;
- edit.setText("Hello world");
- edit.setPos(0, 0);
- scene.addItem(&edit);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
-}
-QTEST_MAIN(tst_qmlgraphicstextedit)
-
-#include "tst_qmlgraphicstextedit.moc"
diff --git a/tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro b/tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro
deleted file mode 100644
index fd75feceef..0000000000
--- a/tests/auto/declarative/qmlgraphicstextinput/qmlgraphicstextinput.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicstextinput.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
deleted file mode 100644
index 8b45fc775a..0000000000
--- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
+++ /dev/null
@@ -1,663 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qmlengine.h>
-#include <QFile>
-#include <QtDeclarative/qmlview.h>
-#include <private/qmlgraphicstextinput_p.h>
-#include <QDebug>
-#include <QStyle>
-#include <QInputContext>
-
-class tst_qmlgraphicstextinput : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlgraphicstextinput();
-
-private slots:
- void text();
- void width();
- void font();
- void color();
- void selection();
-
- void maxLength();
- void masks();
- void validators();
- void inputMethodHints();
-
- void cursorDelegate();
- void navigation();
- void readOnly();
-
- void sendRequestSoftwareInputPanelEvent();
-
-private:
- void simulateKey(QmlView *, int key);
- QmlView *createView(const QString &filename);
-
- QmlEngine engine;
- QStringList standard;
- QStringList colorStrings;
-};
-
-tst_qmlgraphicstextinput::tst_qmlgraphicstextinput()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "It's supercalifragisiticexpialidocious!"
- << "Hello, world!";
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
-}
-
-void tst_qmlgraphicstextinput::text()
-{
- {
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), QString(""));
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), standard.at(i));
- }
-
-}
-
-void tst_qmlgraphicstextinput::width()
-{
- // uses Font metrics to find the width for standard
- {
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), 1.);//1 for the cursor
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.width(standard.at(i));
-
- QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
- }
-}
-
-void tst_qmlgraphicstextinput::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().pointSize(), 40);
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().bold(), true);
- QCOMPARE(textinputObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().italic(), true);
- QCOMPARE(textinputObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString(""));
- }
-}
-
-void tst_qmlgraphicstextinput::color()
-{
- //test color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
- }
-
- //test selection color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
- }
-
- //test selected text color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import Qt 4.6\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), testColor);
- }
-}
-
-void tst_qmlgraphicstextinput::selection()
-{
- QString testStr = standard[0];
- QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }";
- QmlComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
-
- //Test selection follows cursor
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->setCursorPosition(i);
- QCOMPARE(textinputObject->cursorPosition(), i);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- QVERIFY(textinputObject->selectedText().isNull());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test selection
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
- }
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->setSelectionStart(i);
- QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- for(int i=0; i< testStr.size(); i++) {
- textinputObject->setSelectionStart(i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
- textinputObject->setSelectionEnd(i+1);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(testStr.mid(i,1), textinputObject->selectedText());
- }
-
- for(int i= testStr.size() - 1; i>0; i--) {
- textinputObject->setSelectionEnd(i);
- QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
- textinputObject->setSelectionStart(i-1);
- QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText());
- }
-
- //Test Error Ignoring behaviour
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionStart(-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionStart(100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionEnd(-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionEnd(100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->setSelectionStart(0);
- textinputObject->setSelectionEnd(10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionStart(-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionStart(100);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionEnd(-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->setSelectionEnd(100);
- QVERIFY(textinputObject->selectedText().size() == 10);
-}
-
-void tst_qmlgraphicstextinput::maxLength()
-{
- //QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }";
- QmlView *canvas = createView(SRCDIR "/data/maxLength.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QVERIFY(textinputObject->text().isEmpty());
- QVERIFY(textinputObject->maxLength() == 10);
- foreach(const QString &str, standard){
- QVERIFY(textinputObject->text().length() <= 10);
- textinputObject->setText(str);
- QVERIFY(textinputObject->text().length() <= 10);
- }
-
- textinputObject->setText("");
- QTRY_VERIFY(textinputObject->hasFocus() == true);
- for(int i=0; i<20; i++){
- QCOMPARE(textinputObject->text().length(), qMin(i,10));
- //simulateKey(canvas, Qt::Key_A);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- }
-}
-
-void tst_qmlgraphicstextinput::masks()
-{
- //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
- //QString componentStr = "import Qt 4.6\nTextInput { inputMask: 'HHHHhhhh'; }";
- QmlView *canvas = createView(SRCDIR "/data/masks.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasFocus() == true);
- QVERIFY(textinputObject->text().length() == 0);
- QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
- for(int i=0; i<10; i++){
- QCOMPARE(qMin(i,8), textinputObject->text().length());
- QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
- //simulateKey(canvas, Qt::Key_A);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- }
-}
-
-void tst_qmlgraphicstextinput::validators()
-{
- // Note that this test assumes that the validators are working properly
- // so you may need to run their tests first. All validators are checked
- // here to ensure that their exposure to QML is working.
-
- QmlView *canvas = createView(SRCDIR "/data/validators.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextInput *intInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
- QVERIFY(intInput);
- intInput->setFocus(true);
- QTRY_VERIFY(intInput->hasFocus());
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_2);
- QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_0);
- QTest::keyRelease(canvas, Qt::Key_0, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
-
- QmlGraphicsTextInput *dblInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
- QTRY_VERIFY(dblInput);
- dblInput->setFocus(true);
- QVERIFY(dblInput->hasFocus() == true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_2);
- QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_Period);
- QTest::keyRelease(canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
-
- QmlGraphicsTextInput *strInput = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
- QTRY_VERIFY(strInput);
- strInput->setFocus(true);
- QVERIFY(strInput->hasFocus() == true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QEXPECT_FAIL("","Will not work until QTBUG-8025 is resolved", Abort);
- QCOMPARE(strInput->text(), QLatin1String(""));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("a"));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
-}
-
-void tst_qmlgraphicstextinput::inputMethodHints()
-{
- QmlView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
- QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly);
-}
-
-/*
-TextInput element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-
-*/
-void tst_qmlgraphicstextinput::navigation()
-{
- QmlView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == true);
- //QT-2944: If text is selected, then we should deselect first.
- input->setCursorPosition(input->text().length());
- input->setSelectionStart(0);
- input->setSelectionEnd(input->text().length());
- QVERIFY(input->selectionStart() != input->selectionEnd());
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->selectionStart() == input->selectionEnd());
- QVERIFY(input->selectionStart() == input->text().length());
- QVERIFY(input->hasFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == false);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == true);
-}
-
-void tst_qmlgraphicstextinput::cursorDelegate()
-{
- QmlView* view = createView(SRCDIR "/data/cursorTest.qml");
- view->execute();
- view->show();
- view->setFocus();
- QmlGraphicsTextInput *textInputObject = view->rootObject()->findChild<QmlGraphicsTextInput*>("textInputObject");
- QVERIFY(textInputObject != 0);
- QVERIFY(textInputObject->findChild<QmlGraphicsItem*>("cursorInstance"));
- //Test Delegate gets created
- textInputObject->setFocus(true);
- QmlGraphicsItem* delegateObject = textInputObject->findChild<QmlGraphicsItem*>("cursorInstance");
- QVERIFY(delegateObject);
- //Test Delegate gets moved
- for(int i=0; i<= textInputObject->text().length(); i++){
- textInputObject->setCursorPosition(i);
- //+5 is because the TextInput cursorRect is just a 10xHeight area centered on cursor position
- QCOMPARE(textInputObject->cursorRect().x() + 5, qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
- }
- textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRect().x()+5, qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRect().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textInputObject->setCursorDelegate(0);
- QVERIFY(!textInputObject->findChild<QmlGraphicsItem*>("cursorInstance"));
-}
-
-void tst_qmlgraphicstextinput::readOnly()
-{
- QmlView *canvas = createView(SRCDIR "/data/readOnly.qml");
- canvas->execute();
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == true);
- QVERIFY(input->isReadOnly() == true);
- QString initial = input->text();
- for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(canvas, k);
- simulateKey(canvas, Qt::Key_Return);
- simulateKey(canvas, Qt::Key_Space);
- simulateKey(canvas, Qt::Key_Escape);
- QCOMPARE(input->text(), initial);
-}
-
-void tst_qmlgraphicstextinput::simulateKey(QmlView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QApplication::sendEvent(view, &press);
- QApplication::sendEvent(view, &release);
-}
-
-QmlView *tst_qmlgraphicstextinput::createView(const QString &filename)
-{
- QmlView *canvas = new QmlView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-class MyInputContext : public QInputContext
-{
-public:
- MyInputContext() : softwareInputPanelEventReceived(false) {}
- ~MyInputContext() {}
-
- QString identifierName() { return QString(); }
- QString language() { return QString(); }
-
- void reset() {}
-
- bool isComposing() const { return false; }
-
- bool filterEvent( const QEvent *event )
- {
- if (event->type() == QEvent::RequestSoftwareInputPanel)
- softwareInputPanelEventReceived = true;
- return QInputContext::filterEvent(event);
- }
- bool softwareInputPanelEventReceived;
-};
-
-void tst_qmlgraphicstextinput::sendRequestSoftwareInputPanelEvent()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- MyInputContext ic;
- view.viewport()->setInputContext(&ic);
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- if ((behavior != QStyle::RSIP_OnMouseClick))
- QSKIP("This test need to have a style with RSIP_OnMouseClick", SkipSingle);
- QmlGraphicsTextInput input;
- input.setText("Hello world");
- input.setPos(0, 0);
- scene.addItem(&input);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.softwareInputPanelEventReceived, true);
-}
-
-QTEST_MAIN(tst_qmlgraphicstextinput)
-
-#include "tst_qmlgraphicstextinput.moc"
diff --git a/tests/auto/declarative/qmlgraphicswebview/data/forward.html b/tests/auto/declarative/qmlgraphicswebview/data/forward.html
deleted file mode 100644
index 030446a886..0000000000
--- a/tests/auto/declarative/qmlgraphicswebview/data/forward.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<html>
-<head><title>Forward</title>
-<link rel="icon" sizes="48x48" href="basic.png">
-</head>
-<body leftmargin="0" marginwidth="0">
-<table width="123">
-<tbody>
-<tr><td>This is more.</td></tr>
-</tbody>
-</table>
-</body>
-</html>
diff --git a/tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro b/tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro
deleted file mode 100644
index a5906168b3..0000000000
--- a/tests/auto/declarative/qmlgraphicswebview/qmlgraphicswebview.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-contains(QT_CONFIG,webkit): QT += webkit
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlgraphicswebview.cpp testtypes.cpp
-HEADERS += testtypes.h
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp b/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp
deleted file mode 100644
index 00c1b67836..0000000000
--- a/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp
+++ /dev/null
@@ -1,49 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
-
-void MyWebView::drawContents(QPainter *p, const QRect &r)
-{
- pp += r.width()*r.height();
- QmlGraphicsWebView::drawContents(p,r);
-}
-
-QML_DEFINE_TYPE(Test,1,0,MyWebView,MyWebView);
diff --git a/tests/auto/declarative/qmlgraphicswebview/testtypes.h b/tests/auto/declarative/qmlgraphicswebview/testtypes.h
deleted file mode 100644
index 0b3176dd0e..0000000000
--- a/tests/auto/declarative/qmlgraphicswebview/testtypes.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
-#define TESTTYPES_H
-
-#include <private/qmlgraphicswebview_p.h>
-
-class MyWebView : public QmlGraphicsWebView
-{
- Q_OBJECT
- Q_PROPERTY(int pixelsPainted READ pixelsPainted);
-
-public:
- MyWebView() : pp(0) {}
-
- int pixelsPainted() const { return pp; }
-
- void drawContents(QPainter *p, const QRect &r);
-
-private:
- int pp;
-};
-
-QML_DECLARE_TYPE(MyWebView);
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
deleted file mode 100644
index f3c39f8ecc..0000000000
--- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp
+++ /dev/null
@@ -1,396 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include "../../../shared/util.h"
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicswebview_p.h>
-#include <private/qmlgraphicswebview_p_p.h>
-#include <private/qmlgraphicspositioners_p.h>
-#include <QtWebKit/qwebpage.h>
-#include <QtWebKit/qwebframe.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include <QtGui/qpainter.h>
-#include "testtypes.h"
-
-class tst_qmlgraphicswebview : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicswebview() {}
-
-private slots:
- void basicProperties();
- void settings();
- void historyNav();
- void multipleWindows();
- void elementAreaAt();
- void loadError();
- void setHtml();
- void javaScript();
- void cleanupTestCase();
- void pixelCache();
-
-private:
- void checkNoErrors(const QmlComponent& component);
- QmlEngine engine;
- QString tmpDir() const
- {
- static QString tmpd = QDir::tempPath()+"/tst_qmlgraphicswebview-"
- + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
- return tmpd;
- }
-};
-
-static QString strippedHtml(QString html)
-{
- html.replace(QRegExp("\\s+"),"");
- return html;
-}
-
-static QString fileContents(const QString& filename)
-{
- QFile file(filename);
- file.open(QIODevice::ReadOnly);
- return QString::fromUtf8(file.readAll());
-}
-
-
-static void removeRecursive(const QString& dirname)
-{
- QDir dir(dirname);
- QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
- if (entries[i].isDir())
- removeRecursive(entries[i].filePath());
- else
- dir.remove(entries[i].fileName());
- QDir().rmdir(dirname);
-}
-
-void tst_qmlgraphicswebview::cleanupTestCase()
-{
- removeRecursive(tmpDir());
-}
-
-void tst_qmlgraphicswebview::checkNoErrors(const QmlComponent& component)
-{
- // Wait until the component is ready
- QTRY_VERIFY(component.isReady());
-
-
- if (component.isError()) {
- QList<QmlError> errors = component.errors();
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QmlError &error = errors.at(ii);
- QByteArray errorStr = QByteArray::number(error.line()) + ":" +
- QByteArray::number(error.column()) + ":" +
- error.description().toUtf8();
- qWarning() << errorStr;
- }
- }
- QVERIFY(!component.isError());
-}
-
-void tst_qmlgraphicswebview::basicProperties()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QTRY_COMPARE(wv->icon().width(), 48);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->statusText(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->width(), 123.0);
- QCOMPARE(wv->preferredWidth(), 0);
- QCOMPARE(wv->preferredHeight(), 0);
- QCOMPARE(wv->zoomFactor(), 1.0);
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(!wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(!wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-
- wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything!
- QCOMPARE(wv->pixelCacheSize(),0);
- wv->reloadAction()->trigger();
- QTRY_COMPARE(wv->progress(), 1.0);
-}
-
-void tst_qmlgraphicswebview::settings()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
-
- QmlGraphicsWebSettings *s = wv->settingsObject();
-
- // merely tests that setting gets stored (in QWebSettings)
- // behavioural tests are in WebKit.
- for (int b=0; b<=1; ++b) {
- bool on = !!b;
-
- s->setAutoLoadImages(on);
- s->setDeveloperExtrasEnabled(on);
- s->setJavaEnabled(on);
- s->setJavascriptCanAccessClipboard(on);
- s->setJavascriptCanOpenWindows(on);
- s->setJavascriptEnabled(on);
- s->setLinksIncludedInFocusChain(on);
- s->setLocalContentCanAccessRemoteUrls(on);
- s->setLocalStorageDatabaseEnabled(on);
- s->setOfflineStorageDatabaseEnabled(on);
- s->setOfflineWebApplicationCacheEnabled(on);
- s->setPluginsEnabled(on);
- s->setPrintElementBackgrounds(on);
- s->setPrivateBrowsingEnabled(on);
- s->setZoomTextOnly(on);
-
- QVERIFY(s->autoLoadImages() == on);
- QVERIFY(s->developerExtrasEnabled() == on);
- QVERIFY(s->javaEnabled() == on);
- QVERIFY(s->javascriptCanAccessClipboard() == on);
- QVERIFY(s->javascriptCanOpenWindows() == on);
- QVERIFY(s->javascriptEnabled() == on);
- QVERIFY(s->linksIncludedInFocusChain() == on);
- QVERIFY(s->localContentCanAccessRemoteUrls() == on);
- QVERIFY(s->localStorageDatabaseEnabled() == on);
- QVERIFY(s->offlineStorageDatabaseEnabled() == on);
- QVERIFY(s->offlineWebApplicationCacheEnabled() == on);
- QVERIFY(s->pluginsEnabled() == on);
- QVERIFY(s->printElementBackgrounds() == on);
- QVERIFY(s->privateBrowsingEnabled() == on);
- QVERIFY(s->zoomTextOnly() == on);
-
- QVERIFY(s->property("autoLoadImages") == on);
- QVERIFY(s->property("developerExtrasEnabled") == on);
- QVERIFY(s->property("javaEnabled") == on);
- QVERIFY(s->property("javascriptCanAccessClipboard") == on);
- QVERIFY(s->property("javascriptCanOpenWindows") == on);
- QVERIFY(s->property("javascriptEnabled") == on);
- QVERIFY(s->property("linksIncludedInFocusChain") == on);
- QVERIFY(s->property("localContentCanAccessRemoteUrls") == on);
- QVERIFY(s->property("localStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineStorageDatabaseEnabled") == on);
- QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on);
- QVERIFY(s->property("pluginsEnabled") == on);
- QVERIFY(s->property("printElementBackgrounds") == on);
- QVERIFY(s->property("privateBrowsingEnabled") == on);
- QVERIFY(s->property("zoomTextOnly") == on);
- }
-}
-
-void tst_qmlgraphicswebview::historyNav()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QTRY_COMPARE(wv->icon().width(), 48);
- QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png"));
- QCOMPARE(wv->statusText(),QString("status here"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->width(), 123.0);
- QCOMPARE(wv->preferredWidth(), 0);
- QCOMPARE(wv->zoomFactor(), 1.0);
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(!wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(!wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-
- wv->reloadAction()->trigger();
- }
-
- wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Forward"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QCOMPARE(wv->statusText(),QString(""));
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(!wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-
- wv->backAction()->trigger();
-
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString("Basic"));
- QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html()));
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html"));
- QCOMPARE(wv->status(), QmlGraphicsWebView::Ready);
- QVERIFY(wv->reloadAction());
- QVERIFY(wv->reloadAction()->isEnabled());
- QVERIFY(wv->backAction());
- QVERIFY(!wv->backAction()->isEnabled());
- QVERIFY(wv->forwardAction());
- QVERIFY(wv->forwardAction()->isEnabled());
- QVERIFY(wv->stopAction());
- QVERIFY(!wv->stopAction()->isEnabled());
-}
-
-void tst_qmlgraphicswebview::multipleWindows()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/newwindows.qml"));
- checkNoErrors(component);
-
- QmlGraphicsGrid *grid = qobject_cast<QmlGraphicsGrid*>(component.create());
- QVERIFY(grid != 0);
- QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews
- QmlGraphicsItem* popup = qobject_cast<QmlGraphicsItem*>(grid->children().at(3)); // first popup after Component, Loaded, original.
- QVERIFY(popup != 0);
- QTRY_COMPARE(popup->x(), 150.0);
-}
-
-void tst_qmlgraphicswebview::loadError()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/loadError.qml"));
- checkNoErrors(component);
- QWebSettings::enablePersistentStorage(tmpDir());
-
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- for (int i=1; i<=2; ++i) {
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->title(),QString(""));
- QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message
- QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url
- QCOMPARE(wv->status(), QmlGraphicsWebView::Error);
-
- wv->reloadAction()->trigger();
- }
-}
-
-void tst_qmlgraphicswebview::setHtml()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>"));
-}
-
-void tst_qmlgraphicswebview::elementAreaAt()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
-
- QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html
- QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B
- QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view
- QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC
- QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view
-}
-
-void tst_qmlgraphicswebview::javaScript()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml"));
- checkNoErrors(component);
- QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123);
- QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here"));
- QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue"));
-}
-
-void tst_qmlgraphicswebview::pixelCache()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml"));
- checkNoErrors(component);
- MyWebView *wv = qobject_cast<MyWebView*>(component.create());
- QVERIFY(wv != 0);
- QTRY_COMPARE(wv->progress(), 1.0);
- QPixmap pm(150,150);
- QPainter p(&pm);
- wv->paint(&p,0,0);
- const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area
- QCOMPARE(wv->pixelsPainted(), expected);
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted
- wv->setPixelCacheSize(0); // clears the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted
- // Note that painted things always go into the cache (even if they don't "fit"),
- // just that they will be removed if anything else needs to be painted.
- wv->setPixelCacheSize(expected); // won't clear the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*2); // still there
- wv->setPixelCacheSize(expected-1); // too small - will clear the cache
- wv->paint(&p,0,0);
- QCOMPARE(wv->pixelsPainted(), expected*3); // repainted
-}
-
-QTEST_MAIN(tst_qmlgraphicswebview)
-
-#include "tst_qmlgraphicswebview.moc"
diff --git a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro
deleted file mode 100644
index 0ef773923b..0000000000
--- a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlimageprovider.cpp
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp
deleted file mode 100644
index d07558a035..0000000000
--- a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp
+++ /dev/null
@@ -1,166 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtTest/QtTest>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlimageprovider.h>
-#include <private/qmlgraphicsimage_p.h>
-
-// QmlImageProvider::request() is run in an idle thread where possible
-// Be generous in our timeout.
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 10; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(100); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-class tst_qmlimageprovider : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlimageprovider()
- {
- }
-
-private slots:
- void imageSource();
- void imageSource_data();
- void removeProvider();
-
-private:
- QmlEngine engine;
-};
-
-class TestProvider : public QmlImageProvider
-{
-public:
- QImage request(const QString &id) {
- QImage image;
- image.load(SRCDIR "/data/" + id);
- return image;
- }
-};
-
-void tst_qmlimageprovider::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("exists") << "image://test/exists.png" << "";
- QTest::newRow("missing") << "image://test/no-such-file.png"
- << "\"Failed to get image from provider: image://test/no-such-file.png\" ";
- QTest::newRow("unknown provider") << "image://bogus/exists.png"
- << "\"Failed to get image from provider: image://bogus/exists.png\" ";
-}
-
-void tst_qmlimageprovider::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(QString, error);
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.addImageProvider("test", new TestProvider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
-
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
-
- QCOMPARE(obj->source(), QUrl(source));
-
- if (error.isEmpty()) {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 100.);
- QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qmlimageprovider::removeProvider()
-{
- engine.addImageProvider("test2", new TestProvider);
- QVERIFY(engine.imageProvider("test2") != 0);
-
- // add provider, confirm it works
- QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create());
- QVERIFY(obj != 0);
-
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
- TRY_WAIT(obj->status() == QmlGraphicsImage::Ready);
-
- QCOMPARE(obj->width(), 100.0);
-
- // remove the provider and confirm
- QString error("\"Failed to get image from provider: image://test2/exists2.png\" ");
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.removeImageProvider("test2");
-
- obj->setSource(QUrl("image://test2/exists2.png"));
-
- TRY_WAIT(obj->status() == QmlGraphicsImage::Loading);
- TRY_WAIT(obj->status() == QmlGraphicsImage::Error);
-
- delete obj;
-}
-
-
-QTEST_MAIN(tst_qmlimageprovider)
-
-#include "tst_qmlimageprovider.moc"
diff --git a/tests/auto/declarative/qmlinfo/qmlinfo.pro b/tests/auto/declarative/qmlinfo/qmlinfo.pro
deleted file mode 100644
index dbebf92f7e..0000000000
--- a/tests/auto/declarative/qmlinfo/qmlinfo.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlinfo.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp b/tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp
deleted file mode 100644
index e4da9934c8..0000000000
--- a/tests/auto/declarative/qmlinfo/tst_qmlinfo.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QPushButton>
-#include <QmlContext>
-#include <qmlinfo.h>
-
-class tst_qmlinfo : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlinfo() {}
-
-private slots:
- void qmlObject();
- void nestedQmlObject();
- void nonQmlObject();
- void nullObject();
- void nonQmlContextedObject();
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_qmlinfo::qmlObject()
-{
- QmlComponent component(&engine, TEST_FILE("qmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QString message = "QML QObject_QML_0 (" + component.url().toString() + ":3:1) Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(object) << "Test Message";
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
-
- message = "QML QtObject (" + component.url().toString() + ":6:13) Second Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Second Test Message";
-}
-
-void tst_qmlinfo::nestedQmlObject()
-{
- QmlComponent component(&engine, TEST_FILE("nestedQmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
- QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
- QVERIFY(nested2 != 0);
-
- QString message = "QML NestedObject (" + component.url().toString() + ":5:13) Outer Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Outer Object";
-
- message = "QML QtObject (" + TEST_FILE("NestedObject.qml").toString() + ":6:14) Inner Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested2) << "Inner Object";
-}
-
-void tst_qmlinfo::nonQmlObject()
-{
- QObject object;
- QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
- qmlInfo(&object) << "Test Message";
-
- QPushButton pbObject;
- QTest::ignoreMessage(QtWarningMsg, "QML QPushButton (unknown location) Test Message");
- qmlInfo(&pbObject) << "Test Message";
-}
-
-void tst_qmlinfo::nullObject()
-{
- QTest::ignoreMessage(QtWarningMsg, "QML (unknown location) Null Object Test Message");
- qmlInfo(0) << "Null Object Test Message";
-}
-
-void tst_qmlinfo::nonQmlContextedObject()
-{
- QObject object;
- QmlContext context(&engine);
- QmlEngine::setContextForObject(&object, &context);
- QTest::ignoreMessage(QtWarningMsg, "QML QtObject (unknown location) Test Message");
- qmlInfo(&object) << "Test Message";
-}
-
-QTEST_MAIN(tst_qmlinfo)
-
-#include "tst_qmlinfo.moc"
diff --git a/tests/auto/declarative/qmlinstruction/qmlinstruction.pro b/tests/auto/declarative/qmlinstruction/qmlinstruction.pro
deleted file mode 100644
index 41be488463..0000000000
--- a/tests/auto/declarative/qmlinstruction/qmlinstruction.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative script
-SOURCES += tst_qmlinstruction.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
deleted file mode 100644
index 38d024ac76..0000000000
--- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp
+++ /dev/null
@@ -1,585 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <private/qmlcompiler_p.h>
-
-class tst_qmlinstruction : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlinstruction() {}
-
-private slots:
- void dump();
-};
-
-static QStringList messages;
-static void msgHandler(QtMsgType, const char *msg)
-{
- messages << QLatin1String(msg);
-}
-
-void tst_qmlinstruction::dump()
-{
- QmlCompiledData *data = new QmlCompiledData(0);
- {
- QmlInstruction i;
- i.line = 0;
- i.type = QmlInstruction::Init;
- i.init.bindingsSize = 0;
- i.init.parserStatusSize = 3;
- i.init.contextCache = -1;
- i.init.compiledBinding = -1;
- data->bytecode << i;
- }
-
- {
- QmlCompiledData::TypeReference ref;
- ref.className = "Test";
- data->types << ref;
-
- QmlInstruction i;
- i.line = 1;
- i.type = QmlInstruction::CreateObject;
- i.create.type = 0;
- i.create.data = -1;
- i.create.bindingBits = -1;
- i.create.column = 10;
- data->bytecode << i;
- }
-
- {
- data->primitives << "testId";
-
- QmlInstruction i;
- i.line = 2;
- i.type = QmlInstruction::SetId;
- i.setId.value = 0;
- i.setId.index = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 3;
- i.type = QmlInstruction::SetDefault;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 4;
- i.type = QmlInstruction::CreateComponent;
- i.createComponent.count = 3;
- i.createComponent.column = 4;
- i.createComponent.endLine = 14;
- i.createComponent.metaObject = 0;
-
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 5;
- i.type = QmlInstruction::StoreMetaObject;
- i.storeMeta.data = 3;
- i.storeMeta.aliasData = 6;
- i.storeMeta.propertyCache = 7;
-
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 6;
- i.type = QmlInstruction::StoreFloat;
- i.storeFloat.propertyIndex = 3;
- i.storeFloat.value = 11.3;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 7;
- i.type = QmlInstruction::StoreDouble;
- i.storeDouble.propertyIndex = 4;
- i.storeDouble.value = 14.8;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 8;
- i.type = QmlInstruction::StoreInteger;
- i.storeInteger.propertyIndex = 5;
- i.storeInteger.value = 9;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 9;
- i.type = QmlInstruction::StoreBool;
- i.storeBool.propertyIndex = 6;
- i.storeBool.value = true;
-
- data->bytecode << i;
- }
-
- {
- data->primitives << "Test String";
- QmlInstruction i;
- i.line = 10;
- i.type = QmlInstruction::StoreString;
- i.storeString.propertyIndex = 7;
- i.storeString.value = 1;
- data->bytecode << i;
- }
-
- {
- data->primitives << "http://www.nokia.com";
- QmlInstruction i;
- i.line = 11;
- i.type = QmlInstruction::StoreUrl;
- i.storeUrl.propertyIndex = 8;
- i.storeUrl.value = 2;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 12;
- i.type = QmlInstruction::StoreColor;
- i.storeColor.propertyIndex = 9;
- i.storeColor.value = 0xFF00FF00;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 13;
- i.type = QmlInstruction::StoreDate;
- i.storeDate.propertyIndex = 10;
- i.storeDate.value = 9;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 14;
- i.type = QmlInstruction::StoreTime;
- i.storeTime.propertyIndex = 11;
- i.storeTime.valueIndex = 33;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 15;
- i.type = QmlInstruction::StoreDateTime;
- i.storeDateTime.propertyIndex = 12;
- i.storeDateTime.valueIndex = 44;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 16;
- i.type = QmlInstruction::StorePoint;
- i.storeRealPair.propertyIndex = 13;
- i.storeRealPair.valueIndex = 3;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 17;
- i.type = QmlInstruction::StorePointF;
- i.storeRealPair.propertyIndex = 14;
- i.storeRealPair.valueIndex = 9;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 18;
- i.type = QmlInstruction::StoreSize;
- i.storeRealPair.propertyIndex = 15;
- i.storeRealPair.valueIndex = 8;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 19;
- i.type = QmlInstruction::StoreSizeF;
- i.storeRealPair.propertyIndex = 16;
- i.storeRealPair.valueIndex = 99;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 20;
- i.type = QmlInstruction::StoreRect;
- i.storeRect.propertyIndex = 17;
- i.storeRect.valueIndex = 2;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 21;
- i.type = QmlInstruction::StoreRectF;
- i.storeRect.propertyIndex = 18;
- i.storeRect.valueIndex = 19;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 22;
- i.type = QmlInstruction::StoreVector3D;
- i.storeVector3D.propertyIndex = 19;
- i.storeVector3D.valueIndex = 9;
- data->bytecode << i;
- }
-
- {
- data->primitives << "color(1, 1, 1, 1)";
- QmlInstruction i;
- i.line = 23;
- i.type = QmlInstruction::StoreVariant;
- i.storeString.propertyIndex = 20;
- i.storeString.value = 3;
-
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 24;
- i.type = QmlInstruction::StoreObject;
- i.storeObject.propertyIndex = 21;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 25;
- i.type = QmlInstruction::StoreVariantObject;
- i.storeObject.propertyIndex = 22;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 26;
- i.type = QmlInstruction::StoreInterface;
- i.storeObject.propertyIndex = 23;
- data->bytecode << i;
- }
-
- {
- data->primitives << "console.log(1921)";
-
- QmlInstruction i;
- i.line = 27;
- i.type = QmlInstruction::StoreSignal;
- i.storeSignal.signalIndex = 2;
- i.storeSignal.value = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 28;
- i.type = QmlInstruction::StoreScript;
- i.storeScript.value = 2;
- //i.storeScript.fileName = 18;
- //i.storeScript.lineNumber = 28;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 29;
- i.type = QmlInstruction::StoreScriptString;
- i.storeScriptString.propertyIndex = 24;
- i.storeScriptString.value = 3;
- i.storeScriptString.scope = 1;
- data->bytecode << i;
- }
-
- {
- data->datas << "mySignal";
-
- QmlInstruction i;
- i.line = 30;
- i.type = QmlInstruction::AssignSignalObject;
- i.assignSignalObject.signal = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 31;
- i.type = QmlInstruction::AssignCustomType;
- i.assignCustomType.propertyIndex = 25;
- i.assignCustomType.valueIndex = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 32;
- i.type = QmlInstruction::StoreBinding;
- i.assignBinding.property = 26;
- i.assignBinding.value = 3;
- i.assignBinding.context = 2;
- i.assignBinding.owner = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 33;
- i.type = QmlInstruction::StoreCompiledBinding;
- i.assignBinding.property = 27;
- i.assignBinding.value = 2;
- i.assignBinding.context = 4;
- i.assignBinding.owner = 0;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 34;
- i.type = QmlInstruction::StoreValueSource;
- i.assignValueSource.property = 29;
- i.assignValueSource.owner = 1;
- i.assignValueSource.castValue = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 35;
- i.type = QmlInstruction::StoreValueInterceptor;
- i.assignValueInterceptor.property = 30;
- i.assignValueInterceptor.owner = 2;
- i.assignValueInterceptor.castValue = -4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 36;
- i.type = QmlInstruction::BeginObject;
- i.begin.castValue = 4;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 38;
- i.type = QmlInstruction::StoreObjectQList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 39;
- i.type = QmlInstruction::AssignObjectList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 40;
- i.type = QmlInstruction::FetchAttached;
- i.fetchAttached.id = 23;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 42;
- i.type = QmlInstruction::FetchQList;
- i.fetch.property = 32;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 43;
- i.type = QmlInstruction::FetchObject;
- i.fetch.property = 33;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 44;
- i.type = QmlInstruction::FetchValueType;
- i.fetchValue.property = 34;
- i.fetchValue.type = 6;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 45;
- i.type = QmlInstruction::PopFetchedObject;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 46;
- i.type = QmlInstruction::PopQList;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 47;
- i.type = QmlInstruction::PopValueType;
- i.fetchValue.property = 35;
- i.fetchValue.type = 8;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 48;
- i.type = QmlInstruction::Defer;
- i.defer.deferCount = 7;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = -1;
- i.type = QmlInstruction::Defer;
- i.defer.deferCount = 7;
- data->bytecode << i;
- }
-
- {
- QmlInstruction i;
- i.line = 50;
- i.type = (QmlInstruction::Type)(QmlInstruction::Defer + 1); // Non-existant
- data->bytecode << i;
- }
-
- QStringList expect;
- expect
- << "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
- << "-------------------------------------------------------------------------------"
- << "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1"
- << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\""
- << "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\""
- << "3\t\t3\tSET_DEFAULT"
- << "4\t\t4\tCREATE_COMPONENT\t3"
- << "5\t\t5\tSTORE_META\t\t3"
- << "6\t\t6\tSTORE_FLOAT\t\t3\t11.3"
- << "7\t\t7\tSTORE_DOUBLE\t\t4\t14.8"
- << "8\t\t8\tSTORE_INTEGER\t\t5\t9"
- << "9\t\t9\tSTORE_BOOL\t\t6\ttrue"
- << "10\t\t10\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
- << "11\t\t11\tSTORE_URL\t\t8\t2\t\t\"http://www.nokia.com\""
- << "12\t\t12\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
- << "13\t\t13\tSTORE_DATE\t\t10\t9"
- << "14\t\t14\tSTORE_TIME\t\t11\t33"
- << "15\t\t15\tSTORE_DATETIME\t\t12\t44"
- << "16\t\t16\tSTORE_POINT\t\t13\t3"
- << "17\t\t17\tSTORE_POINTF\t\t14\t9"
- << "18\t\t18\tSTORE_SIZE\t\t15\t8"
- << "19\t\t19\tSTORE_SIZEF\t\t16\t99"
- << "20\t\t20\tSTORE_RECT\t\t17\t2"
- << "21\t\t21\tSTORE_RECTF\t\t18\t19"
- << "22\t\t22\tSTORE_VECTOR3D\t\t19\t9"
- << "23\t\t23\tSTORE_VARIANT\t\t20\t3\t\t\"color(1, 1, 1, 1)\""
- << "24\t\t24\tSTORE_OBJECT\t\t21"
- << "25\t\t25\tSTORE_VARIANT_OBJECT\t22"
- << "26\t\t26\tSTORE_INTERFACE\t\t23"
- << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\""
- << "28\t\t28\tSTORE_SCRIPT\t\t2"
- << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1"
- << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\""
- << "31\t\t31\tASSIGN_CUSTOMTYPE\t25\t4"
- << "32\t\t32\tSTORE_BINDING\t26\t3\t2"
- << "33\t\t33\tSTORE_COMPILED_BINDING\t27\t2\t4"
- << "34\t\t34\tSTORE_VALUE_SOURCE\t29\t4"
- << "35\t\t35\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
- << "36\t\t36\tBEGIN\t\t\t4"
- << "37\t\t38\tSTORE_OBJECT_QLIST"
- << "38\t\t39\tASSIGN_OBJECT_LIST"
- << "39\t\t40\tFETCH_ATTACHED\t\t23"
- << "40\t\t42\tFETCH_QLIST\t\t32"
- << "41\t\t43\tFETCH\t\t\t33"
- << "42\t\t44\tFETCH_VALUE\t\t34\t6"
- << "43\t\t45\tPOP"
- << "44\t\t46\tPOP_QLIST"
- << "45\t\t47\tPOP_VALUE\t\t35\t8"
- << "46\t\t48\tDEFER\t\t\t7"
- << "47\t\tNA\tDEFER\t\t\t7"
- << "48\t\t50\tXXX UNKOWN INSTRUCTION\t47"
- << "-------------------------------------------------------------------------------";
-
- messages = QStringList();
- QtMsgHandler old = qInstallMsgHandler(msgHandler);
- data->dumpInstructions();
- qInstallMsgHandler(old);
-
- QCOMPARE(messages.count(), expect.count());
- for (int ii = 0; ii < messages.count(); ++ii) {
- QCOMPARE(messages.at(ii), expect.at(ii));
- }
-
- data->release();
-}
-
-QTEST_MAIN(tst_qmlinstruction)
-
-#include "tst_qmlinstruction.moc"
diff --git a/tests/auto/declarative/qmllanguage/data/component.5.errors.txt b/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
deleted file mode 100644
index 5e889007a8..0000000000
--- a/tests/auto/declarative/qmllanguage/data/component.5.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-4:5:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.10.errors.txt b/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
deleted file mode 100644
index 8299d23feb..0000000000
--- a/tests/auto/declarative/qmllanguage/data/script.10.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-6:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/data/script.12.errors.txt b/tests/auto/declarative/qmllanguage/data/script.12.errors.txt
deleted file mode 100644
index 85c8396611..0000000000
--- a/tests/auto/declarative/qmllanguage/data/script.12.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-4:5:QmlJS declaration outside Script element
diff --git a/tests/auto/declarative/qmllanguage/data/script.9.errors.txt b/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
deleted file mode 100644
index dc1eb539bb..0000000000
--- a/tests/auto/declarative/qmllanguage/data/script.9.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-5:9:Invalid component specification
diff --git a/tests/auto/declarative/qmllanguage/qmllanguage.pro b/tests/auto/declarative/qmllanguage/qmllanguage.pro
deleted file mode 100644
index d1876ef204..0000000000
--- a/tests/auto/declarative/qmllanguage/qmllanguage.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += script network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllanguage.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-INCLUDEPATH += ../shared/
-HEADERS += ../shared/testhttpserver.h
-SOURCES += ../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmllanguage/testtypes.cpp b/tests/auto/declarative/qmllanguage/testtypes.cpp
deleted file mode 100644
index a2950547c0..0000000000
--- a/tests/auto/declarative/qmllanguage/testtypes.cpp
+++ /dev/null
@@ -1,59 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
-
-QML_DEFINE_INTERFACE(MyInterface);
-QML_DEFINE_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
-QML_DEFINE_TYPE(Test,1,0,MyTypeObject,MyTypeObject);
-QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer);
-QML_DEFINE_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource);
-QML_DEFINE_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject);
-QML_DEFINE_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType);
-QML_DEFINE_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType);
-QML_DEFINE_NOCREATE_TYPE(MyGroupedObject);
-
-QVariant myCustomVariantTypeConverter(const QString &data)
-{
- MyCustomVariantType rv;
- rv.a = data.toInt();
- return QVariant::fromValue(rv);
-}
-
diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h
deleted file mode 100644
index 27b45e48aa..0000000000
--- a/tests/auto/declarative/qmllanguage/testtypes.h
+++ /dev/null
@@ -1,545 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qdatetime.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlparserstatus.h>
-#include <QtDeclarative/qmlpropertyvaluesource.h>
-#include <QtDeclarative/qmlscriptstring.h>
-
-QVariant myCustomVariantTypeConverter(const QString &data);
-
-class MyInterface
-{
-public:
- MyInterface() : id(913) {}
- int id;
-};
-Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
-QML_DECLARE_INTERFACE(MyInterface);
-
-struct MyCustomVariantType
-{
- MyCustomVariantType() : a(0) {}
- int a;
-};
-Q_DECLARE_METATYPE(MyCustomVariantType);
-
-class MyAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2)
-public:
- MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
-
-private:
- int m_value;
- int m_value2;
-};
-
-class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue FINAL)
- Q_PROPERTY(QString readOnlyString READ readOnlyString)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(QRect rect READ rect WRITE setRect)
- Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
- Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
- Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal);
- Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType);
- Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
-
- Q_INTERFACES(MyInterface QmlParserStatus)
-public:
- MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- QString readOnlyString() const { return QLatin1String(""); }
-
- bool enabled() const { return false; }
- void setEnabled(bool) {}
-
- QRect rect() const { return QRect(); }
- void setRect(const QRect&) {}
-
- QMatrix matrix() const { return QMatrix(); }
- void setMatrix(const QMatrix&) {}
-
- MyInterface *interface() const { return m_interface; }
- void setInterface(MyInterface *iface) { m_interface = iface; }
-
- static MyAttachedObject *qmlAttachedProperties(QObject *other) {
- return new MyAttachedObject(other);
- }
- Q_CLASSINFO("DefaultMethod", "basicSlot()");
-
- int onLiteralSignal() const { return m_value; }
- void setOnLiteralSignal(int v) { m_value = v; }
-
- MyQmlObject *qmlobject() const { return m_qmlobject; }
- void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
-
- MyCustomVariantType customType() const { return m_custom; }
- void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
-public slots:
- void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
- void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); }
-
-signals:
- void basicSignal();
- void basicParameterizedSignal(int parameter);
-
-private:
- friend class tst_qmllanguage;
- int m_value;
- MyInterface *m_interface;
- MyQmlObject *m_qmlobject;
- MyCustomVariantType m_custom;
-};
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(MyQmlObject);
-
-class MyGroupedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlScriptString script READ script WRITE setScript);
-public:
- QmlScriptString script() const { return m_script; }
- void setScript(const QmlScriptString &s) { m_script = s; }
-
-private:
- QmlScriptString m_script;
-};
-
-QML_DECLARE_TYPE(MyGroupedObject);
-
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_FLAGS(MyFlags)
-
- Q_PROPERTY(QString id READ id WRITE setId);
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty);
- Q_PROPERTY(QmlComponent *componentProperty READ componentProperty WRITE setComponentProperty);
- Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty);
- Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty);
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty);
- Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty);
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty);
- Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty);
- Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty);
- Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty);
- Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty);
- Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty);
- Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty);
- Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty);
- Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty);
- Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty);
- Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty);
- Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty);
- Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged);
- Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2);
- Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty);
- Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty);
- Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty);
- Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty);
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty);
-
- Q_PROPERTY(QmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty);
- Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT);
- Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT);
-
-public:
- MyTypeObject()
- : objectPropertyValue(0), componentPropertyValue(0) {}
-
- QString idValue;
- QString id() const {
- return idValue;
- }
- void setId(const QString &v) {
- idValue = v;
- }
-
- QObject *objectPropertyValue;
- QObject *objectProperty() const {
- return objectPropertyValue;
- }
- void setObjectProperty(QObject *v) {
- objectPropertyValue = v;
- }
-
- QmlComponent *componentPropertyValue;
- QmlComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QmlComponent *v) {
- componentPropertyValue = v;
- }
-
- enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
- Q_DECLARE_FLAGS(MyFlags, MyFlag)
- MyFlags flagPropertyValue;
- MyFlags flagProperty() const {
- return flagPropertyValue;
- }
- void setFlagProperty(MyFlags v) {
- flagPropertyValue = v;
- }
-
- enum MyEnum { EnumVal1, EnumVal2 };
- MyEnum enumPropertyValue;
- MyEnum enumProperty() const {
- return enumPropertyValue;
- }
- void setEnumProperty(MyEnum v) {
- enumPropertyValue = v;
- }
-
- QString stringPropertyValue;
- QString stringProperty() const {
- return stringPropertyValue;
- }
- void setStringProperty(const QString &v) {
- stringPropertyValue = v;
- }
-
- uint uintPropertyValue;
- uint uintProperty() const {
- return uintPropertyValue;
- }
- void setUintProperty(const uint &v) {
- uintPropertyValue = v;
- }
-
- int intPropertyValue;
- int intProperty() const {
- return intPropertyValue;
- }
- void setIntProperty(const int &v) {
- intPropertyValue = v;
- }
-
- qreal realPropertyValue;
- qreal realProperty() const {
- return realPropertyValue;
- }
- void setRealProperty(const qreal &v) {
- realPropertyValue = v;
- }
-
- double doublePropertyValue;
- double doubleProperty() const {
- return doublePropertyValue;
- }
- void setDoubleProperty(const double &v) {
- doublePropertyValue = v;
- }
-
- float floatPropertyValue;
- float floatProperty() const {
- return floatPropertyValue;
- }
- void setFloatProperty(const float &v) {
- floatPropertyValue = v;
- }
-
- QColor colorPropertyValue;
- QColor colorProperty() const {
- return colorPropertyValue;
- }
- void setColorProperty(const QColor &v) {
- colorPropertyValue = v;
- }
-
- QDate datePropertyValue;
- QDate dateProperty() const {
- return datePropertyValue;
- }
- void setDateProperty(const QDate &v) {
- datePropertyValue = v;
- }
-
- QTime timePropertyValue;
- QTime timeProperty() const {
- return timePropertyValue;
- }
- void setTimeProperty(const QTime &v) {
- timePropertyValue = v;
- }
-
- QDateTime dateTimePropertyValue;
- QDateTime dateTimeProperty() const {
- return dateTimePropertyValue;
- }
- void setDateTimeProperty(const QDateTime &v) {
- dateTimePropertyValue = v;
- }
-
- QPoint pointPropertyValue;
- QPoint pointProperty() const {
- return pointPropertyValue;
- }
- void setPointProperty(const QPoint &v) {
- pointPropertyValue = v;
- }
-
- QPointF pointFPropertyValue;
- QPointF pointFProperty() const {
- return pointFPropertyValue;
- }
- void setPointFProperty(const QPointF &v) {
- pointFPropertyValue = v;
- }
-
- QSize sizePropertyValue;
- QSize sizeProperty() const {
- return sizePropertyValue;
- }
- void setSizeProperty(const QSize &v) {
- sizePropertyValue = v;
- }
-
- QSizeF sizeFPropertyValue;
- QSizeF sizeFProperty() const {
- return sizeFPropertyValue;
- }
- void setSizeFProperty(const QSizeF &v) {
- sizeFPropertyValue = v;
- }
-
- QRect rectPropertyValue;
- QRect rectProperty() const {
- return rectPropertyValue;
- }
- void setRectProperty(const QRect &v) {
- rectPropertyValue = v;
- emit rectPropertyChanged();
- }
-
- QRect rectPropertyValue2;
- QRect rectProperty2() const {
- return rectPropertyValue2;
- }
- void setRectProperty2(const QRect &v) {
- rectPropertyValue2 = v;
- }
-
- QRectF rectFPropertyValue;
- QRectF rectFProperty() const {
- return rectFPropertyValue;
- }
- void setRectFProperty(const QRectF &v) {
- rectFPropertyValue = v;
- }
-
- bool boolPropertyValue;
- bool boolProperty() const {
- return boolPropertyValue;
- }
- void setBoolProperty(const bool &v) {
- boolPropertyValue = v;
- }
-
- QVariant variantPropertyValue;
- QVariant variantProperty() const {
- return variantPropertyValue;
- }
- void setVariantProperty(const QVariant &v) {
- variantPropertyValue = v;
- }
-
- QVector3D vectorPropertyValue;
- QVector3D vectorProperty() const {
- return vectorPropertyValue;
- }
- void setVectorProperty(const QVector3D &v) {
- vectorPropertyValue = v;
- }
-
- QUrl urlPropertyValue;
- QUrl urlProperty() const {
- return urlPropertyValue;
- }
- void setUrlProperty(const QUrl &v) {
- urlPropertyValue = v;
- }
-
- QmlScriptString scriptPropertyValue;
- QmlScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QmlScriptString &v) {
- scriptPropertyValue = v;
- }
-
- MyGroupedObject groupedValue;
- MyGroupedObject *grouped() { return &groupedValue; }
-
- MyGroupedObject *nullGrouped() { return 0; }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-QML_DECLARE_TYPE(MyTypeObject);
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<QObject> children READ children)
- Q_PROPERTY(QmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
- Q_CLASSINFO("DefaultProperty", "children");
-public:
- MyContainer() {}
-
- QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this, m_children); }
- QList<QObject *> *getChildren() { return &m_children; }
- QmlListProperty<MyInterface> qlistInterfaces() { return QmlListProperty<MyInterface>(this, m_interfaces); }
- QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
-
- QList<QObject*> m_children;
- QList<MyInterface *> m_interfaces;
-};
-
-QML_DECLARE_TYPE(MyContainer);
-
-
-class MyPropertyValueSource : public QObject, public QmlPropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QmlPropertyValueSource)
-public:
- MyPropertyValueSource()
- : QmlPropertyValueSource() {}
-
- QmlMetaProperty prop;
- virtual void setTarget(const QmlMetaProperty &p)
- {
- prop = p;
- }
-};
-QML_DECLARE_TYPE(MyPropertyValueSource);
-
-class MyDotPropertyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(MyQmlObject *obj READ obj)
- Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
-public:
- MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
- ~MyDotPropertyObject()
- {
- if (m_ownRWObj)
- delete m_rwobj;
- }
-
- MyQmlObject *obj() { return 0; }
-
- MyQmlObject *readWriteObj()
- {
- if (!m_rwobj) {
- m_rwobj = new MyQmlObject;
- m_ownRWObj = true;
- }
- return m_rwobj;
- }
-
- void setReadWriteObj(MyQmlObject *obj)
- {
- if (m_ownRWObj) {
- delete m_rwobj;
- m_ownRWObj = false;
- }
-
- m_rwobj = obj;
- }
-
-private:
- MyQmlObject *m_rwobj;
- bool m_ownRWObj;
-};
-
-QML_DECLARE_TYPE(MyDotPropertyObject);
-
-namespace MyNamespace {
- class MyNamespacedType : public QObject
- {
- Q_OBJECT
- };
-
- class MySecondNamespacedType : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<MyNamespace::MyNamespacedType> list READ list);
- public:
- QmlListProperty<MyNamespacedType> list() { return QmlListProperty<MyNamespacedType>(this, m_list); }
-
- private:
- QList<MyNamespacedType *> m_list;
- };
-}
-QML_DECLARE_TYPE(MyNamespace::MyNamespacedType);
-QML_DECLARE_TYPE(MyNamespace::MySecondNamespacedType);
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
deleted file mode 100644
index 4090e1d1a7..0000000000
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ /dev/null
@@ -1,1383 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-#include <private/qmlmetaproperty_p.h>
-#include "testtypes.h"
-
-#include "../../../shared/util.h"
-
-/*
-This test case covers QML language issues. This covers everything that does not
-involve evaluating ECMAScript expressions and bindings.
-
-Evaluation of expressions and bindings is covered in qmlecmascript
-*/
-class tst_qmllanguage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmllanguage() {
- QmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
- QFileInfo fileInfo(__FILE__);
- engine.addImportPath(fileInfo.absoluteDir().filePath(QLatin1String("data/lib")));
- }
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void errors_data();
- void errors();
-
- void simpleObject();
- void simpleContainer();
- void interfaceProperty();
- void interfaceQList();
- void assignObjectToSignal();
- void assignObjectToVariant();
- void assignLiteralSignalProperty();
- void assignQmlComponent();
- void assignBasicTypes();
- void assignTypeExtremes();
- void assignCompositeToType();
- void customParserTypes();
- void rootAsQmlComponent();
- void inlineQmlComponents();
- void idProperty();
- void assignSignal();
- void dynamicProperties();
- void dynamicPropertiesNested();
- void listProperties();
- void dynamicObjectProperties();
- void dynamicSignalsAndSlots();
- void simpleBindings();
- void autoComponentCreation();
- void propertyValueSource();
- void attachedProperties();
- void dynamicObjects();
- void customVariantTypes();
- void valueTypes();
- void cppnamespace();
- void aliasProperties();
- void componentCompositeType();
- void i18n();
- void i18n_data();
- void onCompleted();
- void scriptString();
- void defaultPropertyListOrder();
- void declaredPropertyValues();
-
- void importsBuiltin_data();
- void importsBuiltin();
- void importsLocal_data();
- void importsLocal();
- void importsRemote_data();
- void importsRemote();
- void importsInstalled_data();
- void importsInstalled();
- void importsOrder_data();
- void importsOrder();
-
- void qmlAttachedPropertiesObjectMethod();
-
- // regression tests for crashes
- void crash1();
- void crash2();
-
-private:
- QmlEngine engine;
- void testType(const QString& qml, const QString& type);
-};
-
-#define VERIFY_ERRORS(errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QmlError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QmlError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- if (qgetenv("DEBUG") != "" && expected != actual) \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- if (qgetenv("QMLLANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::WriteOnly)); \
- for (int ii = 0; ii < actual.count(); ++ii) { \
- file.write(actual.at(ii)); file.write("\n"); \
- } \
- file.close(); \
- } else { \
- QCOMPARE(expected, actual); \
- } \
- }
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-void tst_qmllanguage::initTestCase()
-{
- // Create locale-specific file
- // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
- // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
- // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
- QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
- QVERIFY(in.open(QIODevice::ReadOnly));
- QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
- QVERIFY(out.open(QIODevice::WriteOnly));
- out.write(in.readAll());
-}
-
-void tst_qmllanguage::cleanupTestCase()
-{
- QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
-}
-
-void tst_qmllanguage::errors_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("create");
-
- QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false;
- QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false;
- QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false;
- QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false;
- QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false;
- QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false;
-
- QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false;
- QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false;
- QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false;
-
- QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false;
- QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false;
- QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false;
- QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false;
- QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false;
- QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false;
- QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false;
- QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false;
- QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false;
- QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false;
- QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false;
- QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false;
-
- QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false;
- QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
- QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
-
- QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
- QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
-
- QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false;
- QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false;
- QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false;
- QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
- QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
- QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
-
- QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
- QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
- QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
- QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false;
- QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false;
- QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false;
- QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false;
- QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
- QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
- QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
- QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
-
- QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
-
- QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
- QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
- QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
- QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false;
-
- QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false;
- QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false;
- QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false;
-
- QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false;
- QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false;
- QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false;
- QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false;
- QTest::newRow("property.5") << "property.5.qml" << "property.5.errors.txt" << false;
-
- QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false;
- QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false;
- QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false;
- QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false;
- QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false;
- QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false;
- QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false;
- QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false;
- QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false;
- QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false;
- QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false;
- QTest::newRow("Script.12") << "script.12.qml" << "script.12.errors.txt" << false;
-
- QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
- QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
- QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
- QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
- QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
- QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
-
- QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false;
-
- QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
- QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
- QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
- QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
- QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
- QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
- QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
-}
-
-
-void tst_qmllanguage::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, create);
-
- if (file == "invalidID.6.qml")
- QSKIP("Test disabled until we strictly disallow ids from beginning with uppercase letters", SkipSingle);
-
- QmlComponent component(&engine, TEST_FILE(file));
-
- if(create) {
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-void tst_qmllanguage::simpleObject()
-{
- QmlComponent component(&engine, TEST_FILE("simpleObject.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qmllanguage::simpleContainer()
-{
- QmlComponent component(&engine, TEST_FILE("simpleContainer.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QCOMPARE(container->getChildren()->count(),2);
-}
-
-void tst_qmllanguage::interfaceProperty()
-{
- QmlComponent component(&engine, TEST_FILE("interfaceProperty.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->interface());
- QVERIFY(object->interface()->id == 913);
-}
-
-void tst_qmllanguage::interfaceQList()
-{
- QmlComponent component(&engine, TEST_FILE("interfaceQList.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QVERIFY(container->getQListInterfaces()->count() == 2);
- for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
-}
-
-void tst_qmllanguage::assignObjectToSignal()
-{
- QmlComponent component(&engine, TEST_FILE("assignObjectToSignal.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
- emit object->basicSignal();
-}
-
-void tst_qmllanguage::assignObjectToVariant()
-{
- QmlComponent component(&engine, TEST_FILE("assignObjectToVariant.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVariant v = object->property("a");
- QVERIFY(v.userType() == qMetaTypeId<QObject *>());
-}
-
-void tst_qmllanguage::assignLiteralSignalProperty()
-{
- QmlComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->onLiteralSignal(), 10);
-}
-
-// Test is an external component can be loaded and assigned (to a qlist)
-void tst_qmllanguage::assignQmlComponent()
-{
- QmlComponent component(&engine, TEST_FILE("assignQmlComponent.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->getChildren()->count() == 1);
- QObject *child = object->getChildren()->at(0);
- QCOMPARE(child->property("x"), QVariant(10));
- QCOMPARE(child->property("y"), QVariant(11));
-}
-
-// Test literal assignment to all the basic types
-void tst_qmllanguage::assignBasicTypes()
-{
- QmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.7));
- QCOMPARE((float)object->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF((float)-10.1, (float)12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF((float)0.1, (float)0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF((float)1000.1, (float)-10.9, (float)400, (float)90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- QVERIFY(object->objectProperty() != 0);
- MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
- QVERIFY(child != 0);
- QCOMPARE(child->intProperty(), 8);
-}
-
-// Test edge case type assignments
-void tst_qmllanguage::assignTypeExtremes()
-{
- QmlComponent component(&engine, TEST_FILE("assignTypeExtremes.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->uintProperty(), 0xEE6B2800);
- QCOMPARE(object->intProperty(), -0x77359400);
-}
-
-// Test that a composite type can assign to a property of its base type
-void tst_qmllanguage::assignCompositeToType()
-{
- QmlComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Tests that custom parser types can be instantiated
-void tst_qmllanguage::customParserTypes()
-{
- QmlComponent component(&engine, TEST_FILE("customParserTypes.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("count") == QVariant(2));
-}
-
-// Tests that the root item can be a custom component
-void tst_qmllanguage::rootAsQmlComponent()
-{
- QmlComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->property("x"), QVariant(11));
- QCOMPARE(object->getChildren()->count(), 2);
-}
-
-// Tests that components can be specified inline
-void tst_qmllanguage::inlineQmlComponents()
-{
- QmlComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- QmlComponent *comp = qobject_cast<QmlComponent *>(object->getChildren()->at(0));
- QVERIFY(comp != 0);
- MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
- QVERIFY(compObject != 0);
- QCOMPARE(compObject->value(), 11);
-}
-
-// Tests that types that have an id property have it set
-void tst_qmllanguage::idProperty()
-{
- QmlComponent component(&engine, TEST_FILE("idProperty.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- MyTypeObject *child =
- qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
- QVERIFY(child != 0);
- QCOMPARE(child->id(), QString("myObjectId"));
- QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
-}
-
-// Tests that signals can be assigned to
-void tst_qmllanguage::assignSignal()
-{
- QmlComponent component(&engine, TEST_FILE("assignSignal.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
- emit object->basicSignal();
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)");
- emit object->basicParameterizedSignal(9);
-}
-
-// Tests the creation and assignment of dynamic properties
-void tst_qmllanguage::dynamicProperties()
-{
- QmlComponent component(&engine, TEST_FILE("dynamicProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("intProperty"), QVariant(10));
- QCOMPARE(object->property("boolProperty"), QVariant(false));
- QCOMPARE(object->property("doubleProperty"), QVariant(-10.1));
- QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9));
- QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
- QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml")));
- QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
- QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
- QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
- QCOMPARE(object->property("variantProperty"), QVariant(12));
-}
-
-// Test that nested types can use dynamic properties
-void tst_qmllanguage::dynamicPropertiesNested()
-{
- QmlComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("super_a").toInt(), 11); // Overridden
- QCOMPARE(object->property("super_c").toInt(), 14); // Inherited
- QCOMPARE(object->property("a").toInt(), 13); // New
- QCOMPARE(object->property("b").toInt(), 12); // New
-
- delete object;
-}
-
-// Tests the creation and assignment to dynamic list properties
-void tst_qmllanguage::listProperties()
-{
- QmlComponent component(&engine, TEST_FILE("listProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 2);
-}
-
-// Tests the creation and assignment of dynamic object properties
-// ### Not complete
-void tst_qmllanguage::dynamicObjectProperties()
-{
- QmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0));
- QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0));
-}
-
-// Tests the declaration of dynamic signals and slots
-void tst_qmllanguage::dynamicSignalsAndSlots()
-{
- QTest::ignoreMessage(QtDebugMsg, "1921");
-
- QmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
-
- QCOMPARE(object->property("test").toInt(), 0);
- QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10)));
- QCOMPARE(object->property("test").toInt(), 10);
-}
-
-void tst_qmllanguage::simpleBindings()
-{
- QmlComponent component(&engine, TEST_FILE("simpleBindings.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value1"), QVariant(10));
- QCOMPARE(object->property("value2"), QVariant(10));
- QCOMPARE(object->property("value3"), QVariant(21));
- QCOMPARE(object->property("value4"), QVariant(10));
- QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
-}
-
-void tst_qmllanguage::autoComponentCreation()
-{
- QmlComponent component(&engine, TEST_FILE("autoComponentCreation.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->componentProperty() != 0);
- MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
- QVERIFY(child != 0);
- QCOMPARE(child->realProperty(), qreal(9));
-}
-
-void tst_qmllanguage::propertyValueSource()
-{
- {
- QmlComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QList<QObject *> valueSources;
- QObjectList allChildren = object->findChildren<QObject*>();
- foreach (QObject *child, allChildren) {
- if (qobject_cast<QmlPropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), object);
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("propertyValueSource.2.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QList<QObject *> valueSources;
- QObjectList allChildren = object->findChildren<QObject*>();
- foreach (QObject *child, allChildren) {
- if (qobject_cast<QmlPropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), object);
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-}
-
-void tst_qmllanguage::attachedProperties()
-{
- QmlComponent component(&engine, TEST_FILE("attachedProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
- QVERIFY(attached != 0);
- QCOMPARE(attached->property("value"), QVariant(10));
- QCOMPARE(attached->property("value2"), QVariant(13));
-}
-
-// Tests non-static object properties
-void tst_qmllanguage::dynamicObjects()
-{
- QmlComponent component(&engine, TEST_FILE("dynamicObject.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Tests the registration of custom variant string converters
-void tst_qmllanguage::customVariantTypes()
-{
- QmlComponent component(&engine, TEST_FILE("customVariantTypes.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->customType().a, 10);
-}
-
-void tst_qmllanguage::valueTypes()
-{
- QmlComponent component(&engine, TEST_FILE("valueTypes.qml"));
- VERIFY_ERRORS(0);
-
- QString message = QLatin1String("QML MyTypeObject (") + component.url().toString() +
- QLatin1String(":2:1) Binding loop detected for property \"rectProperty.width\"");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
-
-
- QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13));
- QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13));
- QCOMPARE(object->intProperty(), 10);
- object->doAction();
- QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13));
- QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13));
- QCOMPARE(object->intProperty(), 12);
-
- // ###
-#if 0
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(12));
- p.write(13);
- QCOMPARE(p.read(), QVariant(13));
-
- quint32 r = QmlMetaPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
- QmlMetaProperty p2;
- QmlMetaPropertyPrivate::restore(p2, r, object);
- QCOMPARE(p2.read(), QVariant(13));
-#endif
-}
-
-void tst_qmllanguage::cppnamespace()
-{
- {
- QmlComponent component(&engine, TEST_FILE("cppnamespace.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qmllanguage::aliasProperties()
-{
- // Simple "int" alias
- {
- QmlComponent component(&engine, TEST_FILE("alias.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("valueAlias").toInt(), 10);
- object->setProperty("value", QVariant(13));
- QCOMPARE(object->property("valueAlias").toInt(), 13);
-
- // Write throught alias
- object->setProperty("valueAlias", QVariant(19));
- QCOMPARE(object->property("valueAlias").toInt(), 19);
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
- }
-
- // Complex object alias
- {
- QmlComponent component(&engine, TEST_FILE("alias.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- MyQmlObject *v =
- qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
- QVERIFY(v != 0);
- QCOMPARE(v->value(), 10);
-
- // Write through alias
- MyQmlObject *v2 = new MyQmlObject();
- v2->setParent(object);
- object->setProperty("aliasObject", qVariantFromValue(v2));
- MyQmlObject *v3 =
- qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
- QVERIFY(v3 != 0);
- QCOMPARE(v3, v2);
-
- delete object;
- }
-
- // Nested aliases
- {
- QmlComponent component(&engine, TEST_FILE("alias.3.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 1892);
- QCOMPARE(object->property("value2").toInt(), 1892);
-
- object->setProperty("value", QVariant(1313));
- QCOMPARE(object->property("value").toInt(), 1313);
- QCOMPARE(object->property("value2").toInt(), 1313);
-
- object->setProperty("value2", QVariant(8080));
- QCOMPARE(object->property("value").toInt(), 8080);
- QCOMPARE(object->property("value2").toInt(), 8080);
-
- delete object;
- }
-
- // Enum aliases
- {
- QmlComponent component(&engine, TEST_FILE("alias.4.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("enumAlias").toInt(), 1);
-
- delete object;
- }
-
- // Id aliases
- {
- QmlComponent component(&engine, TEST_FILE("alias.5.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant v = object->property("otherAlias");
- QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
- MyQmlObject *o = qvariant_cast<MyQmlObject*>(v);
- QCOMPARE(o->value(), 10);
-
- delete o;
-
- v = object->property("otherAlias");
- QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
- o = qvariant_cast<MyQmlObject*>(v);
- QVERIFY(o == 0);
-
- delete object;
- }
-
- // Nested aliases - this used to cause a crash
- {
- QmlComponent component(&engine, TEST_FILE("alias.6.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 1923);
- }
-
- // Ptr Alias Cleanup - check that aliases to ptr types return 0
- // if the object aliased to is removed
- {
- QmlComponent component(&engine, TEST_FILE("alias.7.qml"));
- VERIFY_ERRORS(0);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *object1 = qvariant_cast<QObject *>(object->property("object"));
- QVERIFY(object1 != 0);
- QObject *object2 = qvariant_cast<QObject *>(object1->property("object"));
- QVERIFY(object2 != 0);
-
- QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject"));
- QVERIFY(alias == object2);
-
- delete object1;
-
- QObject *alias2 = object; // "Random" start value
- int status = -1;
- void *a[] = { &alias2, 0, &status };
- QMetaObject::metacall(object, QMetaObject::ReadProperty,
- object->metaObject()->indexOfProperty("aliasedObject"), a);
- QVERIFY(alias2 == 0);
- }
-
- // Simple composite type
- {
- QmlComponent component(&engine, TEST_FILE("alias.8.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 10);
-
- delete object;
- }
-
- // Complex composite type
- {
- QmlComponent component(&engine, TEST_FILE("alias.9.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 10);
-
- delete object;
- }
-}
-
-// Test that the root element in a composite type can be a Component
-void tst_qmllanguage::componentCompositeType()
-{
- QmlComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-class TestType : public QObject {
- Q_OBJECT
-public:
- TestType(QObject *p=0) : QObject(p) {}
-};
-
-class TestType2 : public QObject {
- Q_OBJECT
-public:
- TestType2(QObject *p=0) : QObject(p) {}
-};
-
-void tst_qmllanguage::i18n_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("stringProperty");
- QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
- QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
- QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
- QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
- QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
- QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
-}
-
-void tst_qmllanguage::i18n()
-{
- QFETCH(QString, file);
- QFETCH(QString, stringProperty);
- QmlComponent component(&engine, TEST_FILE(file));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), stringProperty);
-
- delete object;
-}
-
-// Check that the Component::onCompleted attached property works
-void tst_qmllanguage::onCompleted()
-{
- QmlComponent component(&engine, TEST_FILE("onCompleted.qml"));
- VERIFY_ERRORS(0);
- QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Check that assignments to QmlScriptString properties work
-void tst_qmllanguage::scriptString()
-{
- QmlComponent component(&engine, TEST_FILE("scriptString.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("foo + bar"));
- QCOMPARE(object->scriptProperty().scopeObject(), object);
- QCOMPARE(object->scriptProperty().context(), qmlContext(object));
-
- QVERIFY(object->grouped() != 0);
- QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)"));
- QCOMPARE(object->grouped()->script().scopeObject(), object);
- QCOMPARE(object->grouped()->script().context(), qmlContext(object));
-}
-
-// Check that default property assignments are correctly spliced into explicit
-// property assignments
-void tst_qmllanguage::defaultPropertyListOrder()
-{
- QmlComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
- VERIFY_ERRORS(0);
-
- MyContainer *container = qobject_cast<MyContainer *>(component.create());
- QVERIFY(container != 0);
-
- QCOMPARE(container->getChildren()->count(), 6);
- QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
- QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
- QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
- QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
- QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
- QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
-}
-
-void tst_qmllanguage::declaredPropertyValues()
-{
- QmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
- QEXPECT_FAIL("", "QTBUG-7860", Abort);
- VERIFY_ERRORS(0);
-}
-
-// Check that first child of qml is of given type. Empty type insists on error.
-void tst_qmllanguage::testType(const QString& qml, const QString& type)
-{
- QmlComponent component(&engine);
- component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
-
- QTRY_VERIFY(!component.isLoading());
-
- if (type.isEmpty()) {
- QVERIFY(component.isError());
- } else {
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(QString(object->metaObject()->className()), type);
- }
-}
-
-QML_DECLARE_TYPE(TestType)
-QML_DECLARE_TYPE(TestType2)
-
-QML_DEFINE_TYPE(com.nokia.Test, 0, 0, TestTP, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 0, Test, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 5, Test, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 8, Test, TestType2)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 9, OldTest, TestType)
-QML_DEFINE_TYPE(com.nokia.Test, 1, 12, Test, TestType2)
-
-// Import tests (QT-558)
-
-void tst_qmllanguage::importsBuiltin_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- // import built-ins
- QTest::newRow("missing import")
- << "Test {}"
- << "";
- QTest::newRow("not in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "Test {}"
- << "";
- QTest::newRow("in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "TestTP {}"
- << "TestType";
- QTest::newRow("qualified in version 0.0")
- << "import com.nokia.Test 0.0 as T\n"
- "T.TestTP {}"
- << "TestType";
- QTest::newRow("in version 1.0")
- << "import com.nokia.Test 1.0\n"
- "Test {}"
- << "TestType";
- QTest::newRow("qualified wrong")
- << "import com.nokia.Test 1.0 as T\n" // QT-610
- "Test {}"
- << "";
- QTest::newRow("qualified right")
- << "import com.nokia.Test 1.0 as T\n"
- "T.Test {}"
- << "TestType";
- QTest::newRow("qualified right but not in version 0.0")
- << "import com.nokia.Test 0.0 as T\n"
- "T.Test {}"
- << "";
- QTest::newRow("in version 1.1")
- << "import com.nokia.Test 1.1\n"
- "Test {}"
- << "TestType";
- QTest::newRow("in version 1.3")
- << "import com.nokia.Test 1.3\n"
- "Test {}"
- << "TestType";
- QTest::newRow("in version 1.5")
- << "import com.nokia.Test 1.5\n"
- "Test {}"
- << "TestType";
- QTest::newRow("changed in version 1.8")
- << "import com.nokia.Test 1.8\n"
- "Test {}"
- << "TestType2";
- QTest::newRow("in version 1.12")
- << "import com.nokia.Test 1.12\n"
- "Test {}"
- << "TestType2";
- QTest::newRow("old in version 1.9")
- << "import com.nokia.Test 1.9\n"
- "OldTest {}"
- << "TestType";
- QTest::newRow("old in version 1.11")
- << "import com.nokia.Test 1.11\n"
- "OldTest {}"
- << "TestType";
- QTest::newRow("multiversion 1")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "Test {}"
- << "TestType2";
- QTest::newRow("multiversion 2")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "OldTest {}"
- << "TestType";
- QTest::newRow("qualified multiversion 3")
- << "import com.nokia.Test 1.0 as T0\n"
- "import com.nokia.Test 1.8 as T8\n"
- "T0.Test {}"
- << "TestType";
- QTest::newRow("qualified multiversion 4")
- << "import com.nokia.Test 1.0 as T0\n"
- "import com.nokia.Test 1.8 as T8\n"
- "T8.Test {}"
- << "TestType2";
-}
-
-void tst_qmllanguage::importsBuiltin()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-void tst_qmllanguage::importsLocal_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- // import locals
- QTest::newRow("local import")
- << "import \"subdir\"\n" // QT-613
- "Test {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("local import second")
- << "import Qt 4.6\nimport \"subdir\"\n"
- "Test {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("local import subsubdir")
- << "import Qt 4.6\nimport \"subdir/subsubdir\"\n"
- "SubTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("local import QTBUG-7721 A")
- << "subdir.Test {}" // no longer allowed (QTBUG-7721)
- << "";
- QTest::newRow("local import QTBUG-7721 B")
- << "import \"subdir\" as X\n"
- "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
- << "";
- QTest::newRow("local import as")
- << "import \"subdir\" as T\n"
- "T.Test {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("wrong local import as")
- << "import \"subdir\" as T\n"
- "Test {}"
- << "";
- QTest::newRow("library precedence over local import")
- << "import \"subdir\"\n"
- "import com.nokia.Test 1.0\n"
- "Test {}"
- << "TestType";
-}
-
-void tst_qmllanguage::importsLocal()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-void tst_qmllanguage::importsRemote_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage";
-
- QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QmlGraphicsRectangle";
- QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QmlGraphicsText";
- QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QmlGraphicsImage";
-}
-
-#include "testhttpserver.h"
-
-void tst_qmllanguage::importsRemote()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
-
- TestHTTPServer server(14445);
- server.serveDirectory(SRCDIR);
-
- testType(qml,type);
-}
-
-void tst_qmllanguage::importsInstalled_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- // import installed
- QTest::newRow("installed import 0")
- << "import com.nokia.installedtest 0.0\n"
- "InstalledTestTP {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 0 as TP")
- << "import com.nokia.installedtest 0.0 as TP\n"
- "TP.InstalledTestTP {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 1")
- << "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 2")
- << "import com.nokia.installedtest 1.3\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import 3")
- << "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import 4")
- << "import com.nokia.installedtest 1.10\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import visibility") // QT-614
- << "import com.nokia.installedtest 1.4\n"
- "PrivateType {}"
- << "";
-}
-
-void tst_qmllanguage::importsInstalled()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-
-void tst_qmllanguage::importsOrder_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
-
- QTest::newRow("installed import overrides 1") <<
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import re-overrides 1") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QmlGraphicsText";
- QTest::newRow("installed import re-overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QmlGraphicsRectangle";
-
- QTest::newRow("installed import versus builtin 1") <<
- "import com.nokia.installedtest 1.5\n"
- "import Qt 4.6\n"
- "Rectangle {}"
- << "QmlGraphicsRectangle";
- QTest::newRow("installed import versus builtin 2") <<
- "import Qt 4.6\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << "QmlGraphicsText";
- QTest::newRow("namespaces cannot be overridden by types 1") <<
- "import Qt 4.6 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << "";
- QTest::newRow("namespaces cannot be overridden by types 2") <<
- "import Qt 4.6 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle.Image {}"
- << "QmlGraphicsImage";
-}
-
-void tst_qmllanguage::importsOrder()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- testType(qml,type);
-}
-
-void tst_qmllanguage::qmlAttachedPropertiesObjectMethod()
-{
- QObject object;
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
-
- {
- QmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0);
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0);
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
- }
-}
-
-void tst_qmllanguage::crash1()
-{
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nComponent {}", QUrl());
-}
-
-void tst_qmllanguage::crash2()
-{
- QmlComponent component(&engine, TEST_FILE("crash2.qml"));
-}
-
-QTEST_MAIN(tst_qmllanguage)
-
-#include "tst_qmllanguage.moc"
diff --git a/tests/auto/declarative/qmllist/qmllist.pro b/tests/auto/declarative/qmllist/qmllist.pro
deleted file mode 100644
index b2145ed9fd..0000000000
--- a/tests/auto/declarative/qmllist/qmllist.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllist.cpp
diff --git a/tests/auto/declarative/qmllist/tst_qmllist.cpp b/tests/auto/declarative/qmllist/tst_qmllist.cpp
deleted file mode 100644
index 76def1cea2..0000000000
--- a/tests/auto/declarative/qmllist/tst_qmllist.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QUrl>
-#include <QFileInfo>
-#include <QDir>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qmlprivate.h>
-#include <QDebug>
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath("data/" + filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-class tst_QmlList : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlList() {}
-
-private slots:
- void qmllistreference();
- void qmllistreference_invalid();
- void isValid();
- void object();
- void listElementType();
- void canAppend();
- void canAt();
- void canClear();
- void canCount();
- void append();
- void at();
- void clear();
- void count();
- void copy();
- void qmlmetaproperty();
- void engineTypes();
- void variantToList();
-};
-
-class TestType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<TestType> data READ dataProperty);
- Q_PROPERTY(int intProperty READ intProperty);
-
-public:
- TestType() : property(this, data) {}
- QmlListProperty<TestType> dataProperty() { return property; }
- int intProperty() const { return 10; }
-
- QList<TestType *> data;
- QmlListProperty<TestType> property;
-};
-QML_DECLARE_TYPE(TestType);
-QML_DEFINE_NOCREATE_TYPE(TestType);
-
-void tst_QmlList::qmllistreference()
-{
- TestType tt;
-
- QmlListReference r(&tt, "data");
- QVERIFY(r.isValid() == true);
- QCOMPARE(r.count(), 0);
-
- tt.data.append(&tt);
- QCOMPARE(r.count(), 1);
-}
-
-void tst_QmlList::qmllistreference_invalid()
-{
- TestType tt;
-
- // Invalid
- {
- QmlListReference r;
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-
- // Non-property
- {
- QmlListReference r(&tt, "blah");
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-
- // Non-list property
- {
- QmlListReference r(&tt, "intProperty");
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-}
-
-void tst_QmlList::isValid()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.isValid() == true);
- delete tt;
- QVERIFY(ref.isValid() == false);
- }
-}
-
-void tst_QmlList::object()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.object() == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.object() == 0);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.object() == tt);
- delete tt;
- QVERIFY(ref.object() == 0);
- }
-}
-
-void tst_QmlList::listElementType()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
- delete tt;
- QVERIFY(ref.listElementType() == 0);
- }
-}
-
-void tst_QmlList::canAppend()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canAppend() == true);
- delete tt;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canAppend() == false);
- }
-}
-
-void tst_QmlList::canAt()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canAt() == true);
- delete tt;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- TestType tt;
- tt.property.at = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canAt() == false);
- }
-}
-
-void tst_QmlList::canClear()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canClear() == true);
- delete tt;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canClear() == false);
- }
-}
-
-void tst_QmlList::canCount()
-{
- TestType *tt = new TestType;
-
- {
- QmlListReference ref;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.canCount() == true);
- delete tt;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- TestType tt;
- tt.property.count = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.canCount() == false);
- }
-}
-
-void tst_QmlList::append()
-{
- TestType *tt = new TestType;
- QObject object;
-
- {
- QmlListReference ref;
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.append(tt) == true);
- QVERIFY(tt->data.count() == 1);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(ref.append(&object) == false);
- QVERIFY(tt->data.count() == 1);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(ref.append(0) == true);
- QVERIFY(tt->data.count() == 2);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(tt->data.at(1) == 0);
- delete tt;
- QVERIFY(ref.append(0) == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.append(&tt) == false);
- }
-}
-
-void tst_QmlList::at()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QmlListReference ref;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.at(0) == tt);
- QVERIFY(ref.at(1) == 0);
- QVERIFY(ref.at(2) == tt);
- delete tt;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- TestType tt;
- tt.data.append(&tt);
- tt.property.at = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.at(0) == 0);
- }
-}
-
-void tst_QmlList::clear()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QmlListReference ref;
- QVERIFY(ref.clear() == false);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.clear() == false);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.clear() == true);
- QVERIFY(tt->data.count() == 0);
- delete tt;
- QVERIFY(ref.clear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.clear() == false);
- }
-}
-
-void tst_QmlList::count()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QmlListReference ref;
- QVERIFY(ref.count() == 0);
- }
-
- {
- QmlListReference ref(tt, "blah");
- QVERIFY(ref.count() == 0);
- }
-
- {
- QmlListReference ref(tt, "data");
- QVERIFY(ref.count() == 3);
- tt->data.removeAt(1);
- QVERIFY(ref.count() == 2);
- delete tt;
- QVERIFY(ref.count() == 0);
- }
-
- {
- TestType tt;
- tt.data.append(&tt);
- tt.property.count = 0;
- QmlListReference ref(&tt, "data");
- QVERIFY(ref.count() == 0);
- }
-}
-
-void tst_QmlList::copy()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QmlListReference *r1 = new QmlListReference(&tt, "data");
- QVERIFY(r1->count() == 3);
-
- QmlListReference r2(*r1);
- QmlListReference r3;
- r3 = *r1;
-
- QVERIFY(r2.count() == 3);
- QVERIFY(r3.count() == 3);
-
- delete r1;
-
- QVERIFY(r2.count() == 3);
- QVERIFY(r3.count() == 3);
-
- tt.data.removeAt(2);
-
- QVERIFY(r2.count() == 2);
- QVERIFY(r3.count() == 2);
-}
-
-void tst_QmlList::qmlmetaproperty()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QmlMetaProperty prop(&tt, QLatin1String("data"));
- QVariant v = prop.read();
- QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
- QmlListReference ref = qvariant_cast<QmlListReference>(v);
- QVERIFY(ref.count() == 3);
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
-}
-
-void tst_QmlList::engineTypes()
-{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("engineTypes.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QmlMetaProperty p1(o, QLatin1String("myList"));
- QVERIFY(p1.propertyCategory() == QmlMetaProperty::Normal);
-
- QmlMetaProperty p2(o, QLatin1String("myList"), engine.rootContext());
- QVERIFY(p2.propertyCategory() == QmlMetaProperty::List);
- QVariant v = p2.read();
- QVERIFY(v.userType() == qMetaTypeId<QmlListReference>());
- QmlListReference ref = qvariant_cast<QmlListReference>(v);
- QVERIFY(ref.count() == 2);
- QVERIFY(ref.listElementType());
- QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
-
- delete o;
-}
-
-void tst_QmlList::variantToList()
-{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("variantToList.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QVERIFY(o->property("value").userType() == qMetaTypeId<QmlListReference>());
- QCOMPARE(o->property("test").toInt(), 1);
-
- delete o;
-}
-
-QTEST_MAIN(tst_QmlList)
-
-#include "tst_qmllist.moc"
diff --git a/tests/auto/declarative/qmllistmodel/qmllistmodel.pro b/tests/auto/declarative/qmllistmodel/qmllistmodel.pro
deleted file mode 100644
index 60b0c4b2c6..0000000000
--- a/tests/auto/declarative/qmllistmodel/qmllistmodel.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += script
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmllistmodel.cpp
diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
deleted file mode 100644
index e70c7f1c39..0000000000
--- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
+++ /dev/null
@@ -1,338 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/private/qmllistmodel_p.h>
-#include <QtDeclarative/private/qmlexpression_p.h>
-#include <QmlComponent>
-#include <QDebug>
-
-class tst_QmlListModel : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlListModel() {}
-
-private slots:
- void static_types();
- void static_types_data();
- void static_i18n();
- void static_nestedElements();
- void static_nestedElements_data();
- void dynamic_data();
- void dynamic();
- void error_data();
- void error();
-};
-
-void tst_QmlListModel::static_i18n()
-{
- QString expect = QString::fromUtf8("na\303\257ve");
- QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }";
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
- QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
- QVERIFY(obj != 0);
- QString prop = obj->get(0).property(QLatin1String("prop1")).toString();
- QCOMPARE(prop,expect);
- delete obj;
-}
-
-void tst_QmlListModel::static_nestedElements()
-{
- QFETCH(int, elementCount);
-
- QStringList elements;
- for (int i=0; i<elementCount; i++)
- elements.append("ListElement { a: 1; b: 2 }");
- QString elementsStr = elements.join(",\n") + "\n";
-
- QString componentStr =
- "import Qt 4.6\n"
- "ListModel {\n"
- " ListElement {\n"
- " attributes: [\n";
- componentStr += elementsStr.toUtf8().constData();
- componentStr +=
- " ]\n"
- " }\n"
- "}";
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
-
- QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
- QVERIFY(obj != 0);
-
- QScriptValue prop = obj->get(0).property(QLatin1String("attributes")).property(QLatin1String("count"));
- QVERIFY(prop.isNumber());
- QCOMPARE(prop.toInt32(), qint32(elementCount));
-
- delete obj;
-}
-
-void tst_QmlListModel::static_nestedElements_data()
-{
- QTest::addColumn<int>("elementCount");
-
- QTest::newRow("0 items") << 0;
- QTest::newRow("1 item") << 1;
- QTest::newRow("2 items") << 2;
- QTest::newRow("many items") << 5;
-}
-
-void tst_QmlListModel::dynamic_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
-
- // Simple flat model
-
- QTest::newRow("count") << "count" << 0 << "";
-
- QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
- QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range";
-
- QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
- QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
- QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "";
- QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "";
- QTest::newRow("append4a") << "{append(123)}" << 0 << "QML ListModel (unknown location) append: value is not an object";
- QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML ListModel (unknown location) append: value is not an object";
-
- QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
-
- QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "";
- QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "";
- QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "";
- QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "";
- QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
- QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range";
- QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
- QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range";
- QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range";
-
- QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "";
- QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range";
- QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "";
- QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "";
- QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "";
- QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "";
- QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "";
- QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) insert: index -1 out of range";
- QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
- QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object";
-
- QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "";
- QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
- QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
- QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
- QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
- QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
- QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object";
- QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object";
- QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "";
-
- QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "";
- QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "";
- QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "";
- QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "";
- QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range";
- QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range";
- QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range";
- QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "";
-
- QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "";
- QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "";
- QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "";
- QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "";
- QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "";
- QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "";
- QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "";
- QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "";
- QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "";
- QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML ListModel (unknown location) move: out of range";
- QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
- QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML ListModel (unknown location) move: out of range";
- QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML ListModel (unknown location) move: out of range";
-
- // Structured model
-
- QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "";
- QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "";
- QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "";
-}
-
-void tst_QmlListModel::dynamic()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- QmlEngine engine;
- QmlListModel model;
- QmlEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->addDefaultObject(&model);
- QmlExpression e(engine.rootContext(), script, &model);
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- int actual = e.value().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
- QVERIFY(!e.hasError());
- QCOMPARE(actual,result);
-}
-
-void tst_QmlListModel::static_types_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
-
- QTest::newRow("string")
- << "ListElement { foo: \"bar\" }"
- << QVariant(QString("bar"));
-
- QTest::newRow("real")
- << "ListElement { foo: 10.5 }"
- << QVariant(10.5);
-
- QTest::newRow("real0")
- << "ListElement { foo: 0 }"
- << QVariant(double(0));
-
- QTest::newRow("bool")
- << "ListElement { foo: false }"
- << QVariant(false);
-
- QTest::newRow("bool")
- << "ListElement { foo: true }"
- << QVariant(true);
-}
-
-void tst_QmlListModel::static_types()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
-
- qml = "import Qt 4.6\nListModel { " + qml + " }";
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- QVERIFY(!component.isError());
-
- QmlListModel *obj = qobject_cast<QmlListModel*>(component.create());
- QVERIFY(obj != 0);
-
- QScriptValue actual = obj->get(0).property(QLatin1String("foo"));
-
- QCOMPARE(actual.isString(), value.type() == QVariant::String);
- QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool);
- QCOMPARE(actual.isNumber(), value.type() == QVariant::Double);
-
- QCOMPARE(actual.toString(), value.toString());
-
- delete obj;
-}
-
-void tst_QmlListModel::error_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("id not allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { id: fred } }"
- << "ListElement: cannot use reserved \"id\" property";
-
- QTest::newRow("id allowed in ListModel")
- << "import Qt 4.6\nListModel { id:model }"
- << "";
-
- QTest::newRow("random properties not allowed in ListModel")
- << "import Qt 4.6\nListModel { foo:123 }"
- << "ListModel: undefined property 'foo'";
-
- QTest::newRow("random properties allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { foo:123 } }"
- << "";
-
- QTest::newRow("bindings not allowed in ListElement")
- << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
- << "ListElement: cannot use script for property value";
-
- QTest::newRow("random object list properties allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
- << "";
-
- QTest::newRow("default properties not allowed in ListElement")
- << "import Qt 4.6\nListModel { ListElement { Item { } } }"
- << "QTBUG-6082 ListElement should not allow child objects";
-}
-
-void tst_QmlListModel::error()
-{
- QFETCH(QString, qml);
- QFETCH(QString, error);
-
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- if (error.isEmpty()) {
- QVERIFY(!component.isError());
- } else {
- if (error.startsWith(QLatin1String("QTBUG-")))
- QEXPECT_FAIL("",error.toLatin1(),Abort);
- QVERIFY(component.isError());
- QList<QmlError> errors = component.errors();
- QCOMPARE(errors.count(),1);
- QCOMPARE(errors.at(0).description(),error);
- }
-}
-
-QTEST_MAIN(tst_QmlListModel)
-
-#include "tst_qmllistmodel.moc"
diff --git a/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro b/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro
deleted file mode 100644
index 542c14e8e2..0000000000
--- a/tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlmetaproperty.cpp
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
deleted file mode 100644
index 050cd3f925..0000000000
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ /dev/null
@@ -1,1136 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlmetaproperty.h>
-#include <private/qguard_p.h>
-#include <QtDeclarative/qmlbinding.h>
-#include <QtGui/QLineEdit>
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
-public:
- MyQmlObject() {}
-};
-
-QML_DECLARE_TYPE(MyQmlObject);
-QML_DEFINE_TYPE(Test,1,0,MyQmlObject,MyQmlObject);
-
-class MyAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo)
-public:
- MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
-
- int foo() const { return m_foo; }
- void setFoo(int f) { m_foo = f; }
-
-private:
- int m_foo;
-};
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlListProperty<MyQmlObject> children READ children)
-public:
- MyContainer() {}
-
- QmlListProperty<MyQmlObject> children() { return QmlListProperty<MyQmlObject>(this, m_children); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-QML_DECLARE_TYPE(MyContainer);
-QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer);
-QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qmlmetaproperty : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmetaproperty() {}
-
-private slots:
-
- // Constructors
- void qmlmetaproperty();
- void qmlmetaproperty_object();
- void qmlmetaproperty_object_string();
- void qmlmetaproperty_object_context();
- void qmlmetaproperty_object_string_context();
-
- // Methods
- void name();
- void read();
- void write();
- void reset();
-
- // Functionality
- void writeObjectToList();
- void writeListToList();
-
- //writeToReadOnly();
-
- // Bugs
- void crashOnValueProperty();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlmetaproperty::qmlmetaproperty()
-{
- QmlMetaProperty prop;
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
-}
-
-class PropertyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int defaultProperty READ defaultProperty);
- Q_PROPERTY(QRect rectProperty READ rectProperty);
- Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty);
- Q_PROPERTY(QUrl url READ url WRITE setUrl);
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty);
-
- Q_CLASSINFO("DefaultProperty", "defaultProperty");
-public:
- PropertyObject() : m_resetProperty(9) {}
-
- int defaultProperty() { return 10; }
- QRect rectProperty() { return QRect(10, 10, 1, 209); }
-
- QRect wrectProperty() { return m_rect; }
- void setWRectProperty(const QRect &r) { m_rect = r; }
-
- QUrl url() { return m_url; }
- void setUrl(const QUrl &u) { m_url = u; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int r) { m_resetProperty = r; }
- void resetProperty() { m_resetProperty = 9; }
-
-signals:
- void clicked();
-
-private:
- int m_resetProperty;
- QRect m_rect;
- QUrl m_url;
-};
-
-QML_DECLARE_TYPE(PropertyObject);
-QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject);
-
-void tst_qmlmetaproperty::qmlmetaproperty_object()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QmlMetaProperty prop(&object);
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject);
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), (QmlMetaProperty::Type)(QmlMetaProperty::Property | QmlMetaProperty::Default));
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::qmlmetaproperty_object_string()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QmlMetaProperty prop(&object, QString("defaultProperty"));
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("defaultProperty"));
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("onClicked"));
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QmlMetaProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression != 0);
- QVERIFY(prop.signalExpression() == expression);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::qmlmetaproperty_object_context()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QmlMetaProperty prop(&object, engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), (QmlMetaProperty::Type)(QmlMetaProperty::Property | QmlMetaProperty::Default));
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::qmlmetaproperty_object_string_context()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QmlMetaProperty prop(&object, QString("defaultProperty"), engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), -1);
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), true);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QmlMetaProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(prop.binding() == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:-1: Unable to assign null to int");
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding != 0);
- QVERIFY(prop.binding() == binding);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-
- {
- QmlMetaProperty prop(&dobject, QString("onClicked"), engine.rootContext());
-
- QGuard<QmlBinding> binding(new QmlBinding(QString(), 0, 0));
- binding->setTarget(prop);
- QVERIFY(binding != 0);
- QGuard<QmlExpression> expression(new QmlExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasChangedNotifier(), false);
- QCOMPARE(prop.needsChangedNotifier(), false);
- QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifier(obj, 0), false);
- QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifier(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QmlMetaProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isDefault(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), &dobject);
- QCOMPARE(prop.propertyCategory(), QmlMetaProperty::InvalidProperty);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(prop.binding() == 0);
- QVERIFY(prop.setBinding(binding) == 0);
- QVERIFY(binding == 0);
- QVERIFY(prop.signalExpression() == 0);
- QVERIFY(prop.setSignalExpression(expression) == 0);
- QVERIFY(expression != 0);
- QVERIFY(prop.signalExpression() == expression);
- QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(prop.valueTypeCoreIndex(), -1);
-
- delete obj;
- }
-}
-
-void tst_qmlmetaproperty::name()
-{
- {
- QmlMetaProperty p;
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.name(), QString("defaultProperty"));
- }
-
- {
- QObject o;
- QmlMetaProperty p(&o, QString("objectName"));
- QCOMPARE(p.name(), QString("objectName"));
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString("onClicked"));
- }
-
- {
- QObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QObject o;
- QmlMetaProperty p(&o, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QmlMetaProperty p(0, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty");
- QCOMPARE(p.name(), QString("rectProperty"));
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.x");
- QCOMPARE(p.name(), QString("rectProperty.x"));
- }
-
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.foo");
- QCOMPARE(p.name(), QString());
- }
-}
-
-void tst_qmlmetaproperty::read()
-{
- // Invalid
- {
- QmlMetaProperty p;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Default prop
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid default prop
- {
- QObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.read(), QVariant());
- }
-
- // Value prop by name
- {
- QObject o;
-
- QmlMetaProperty p(&o, "objectName");
- QCOMPARE(p.read(), QVariant(QString()));
-
- o.setObjectName("myName");
-
- QCOMPARE(p.read(), QVariant("myName"));
- }
-
- // Value-type prop
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid value-type prop
- {
- PropertyObject o;
- QmlMetaProperty p = QmlMetaProperty::createProperty(&o, "rectProperty.foo");
- QCOMPARE(p.read(), QVariant());
- }
-
- // Signal property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.read(), QVariant());
-
- QVERIFY(0 == p.setSignalExpression(new QmlExpression()));
- QVERIFY(0 != p.signalExpression());
-
- QCOMPARE(p.read(), QVariant());
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QmlMetaProperty p = QmlMetaProperty::createProperty(o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- delete o;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Attached property
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(13));
- delete object;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "Foo.MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
-}
-
-void tst_qmlmetaproperty::write()
-{
- // Invalid
- {
- QmlMetaProperty p;
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Writable prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("objectName"));
- QCOMPARE(o.objectName(), QString());
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o.objectName(), QString("myName"));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QmlMetaProperty p(o, QString("objectName"));
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o->objectName(), QString("myName"));
-
- delete o;
-
- QCOMPARE(p.write(QVariant(QString("myName"))), false);
- }
-
- // Signal property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "onClicked");
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 == p.setSignalExpression(new QmlExpression()));
- QVERIFY(0 != p.signalExpression());
-
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 != p.signalExpression());
- }
-
- // Value-type property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "wrectProperty");
-
- QCOMPARE(o.wrectProperty(), QRect());
- QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
- QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
-
- QmlMetaProperty p2 = QmlMetaProperty::createProperty(&o, "wrectProperty.x");
- QCOMPARE(p2.read(), QVariant(1));
- QCOMPARE(p2.write(QVariant(6)), true);
- QCOMPARE(p2.read(), QVariant(6));
- QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
- }
-
- // URL-property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "url");
-
- QCOMPARE(p.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), QUrl("main.qml"));
-
- QmlMetaProperty p2(&o, "url", engine.rootContext());
-
- QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
- QVERIFY(result != QUrl("main.qml"));
-
- QCOMPARE(p2.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), result);
- }
-
- // Attached property
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
- {
- QmlComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(object, "Foo.MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
-}
-
-void tst_qmlmetaproperty::reset()
-{
- // Invalid
- {
- QmlMetaProperty p;
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QmlMetaProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Non-resettable-only prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Resettable prop by name
- {
- PropertyObject o;
- QmlMetaProperty p(&o, QString("resettableProperty"));
-
- QCOMPARE(p.read(), QVariant(9));
- QCOMPARE(p.write(QVariant(11)), true);
- QCOMPARE(p.read(), QVariant(11));
-
- QCOMPARE(p.isResettable(), true);
- QCOMPARE(p.reset(), true);
-
- QCOMPARE(p.read(), QVariant(9));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
-
- QmlMetaProperty p(o, QString("resettableProperty"));
-
- QCOMPARE(p.isResettable(), true);
- QCOMPARE(p.reset(), true);
-
- delete o;
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Signal property
- {
- PropertyObject o;
- QmlMetaProperty p(&o, "onClicked");
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-}
-
-void tst_qmlmetaproperty::writeObjectToList()
-{
- QmlComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QmlListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- MyQmlObject *object = new MyQmlObject;
- QmlMetaProperty prop(container, "children");
- prop.write(qVariantFromValue(object));
- QCOMPARE(list.count(), 1);
- QCOMPARE(list.at(0), object);
-}
-
-Q_DECLARE_METATYPE(QList<QObject *>);
-void tst_qmlmetaproperty::writeListToList()
-{
- QmlComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QmlListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- QList<QObject*> objList;
- objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
- QmlMetaProperty prop(container, "children");
- prop.write(qVariantFromValue(objList));
- QCOMPARE(list.count(), 4);
-
- //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
- /*QList<MyQmlObject*> typedObjList;
- typedObjList << new MyQmlObject();
- prop.write(qVariantFromValue(&typedObjList));
- QCOMPARE(container->children()->size(), 1);*/
-}
-
-void tst_qmlmetaproperty::crashOnValueProperty()
-{
- QmlEngine *engine = new QmlEngine;
- QmlComponent component(engine);
-
- component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
- PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
- QVERIFY(obj != 0);
-
- QmlMetaProperty p = QmlMetaProperty::createProperty(obj, "wrectProperty.x", qmlContext(obj));
- QCOMPARE(p.name(), QString("wrectProperty.x"));
-
- QCOMPARE(p.read(), QVariant(10));
-
- //don't crash once the engine is deleted
- delete engine;
- engine = 0;
-
- QCOMPARE(p.propertyTypeName(), "int");
- QCOMPARE(p.read(), QVariant(10));
- p.write(QVariant(20));
- QCOMPARE(p.read(), QVariant(20));
-}
-
-QTEST_MAIN(tst_qmlmetaproperty)
-
-#include "tst_qmlmetaproperty.moc"
diff --git a/tests/auto/declarative/qmlmetatype/qmlmetatype.pro b/tests/auto/declarative/qmlmetatype/qmlmetatype.pro
deleted file mode 100644
index 3a9a40088d..0000000000
--- a/tests/auto/declarative/qmlmetatype/qmlmetatype.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlmetatype.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
deleted file mode 100644
index 750ccf8589..0000000000
--- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlMetaType>
-#include <QLocale>
-#include <QPixmap>
-#include <QBitmap>
-#include <QPen>
-#include <QTextLength>
-#include <QMatrix4x4>
-#include <QVector2D>
-#include <QVector3D>
-#include <QVector4D>
-#include <QQuaternion>
-#include <qml.h>
-
-class tst_qmlmetatype : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmetatype() {}
-
-private slots:
- void copy();
-
- void qmlParserStatusCast();
- void qmlPropertyValueSourceCast();
- void qmlPropertyValueInterceptorCast();
-
- void isList();
-
- void defaultObject();
-};
-
-class TestType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo);
-
- Q_CLASSINFO("DefaultProperty", "foo");
-public:
- int foo() { return 0; }
-};
-QML_DECLARE_TYPE(TestType);
-QML_DEFINE_TYPE(Test, 1, 0, TestType, TestType);
-
-class ParserStatusTestType : public QObject, public QmlParserStatus
-{
- Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "foo"); // Missing default property
-};
-QML_DECLARE_TYPE(ParserStatusTestType);
-QML_DEFINE_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType);
-
-class ValueSourceTestType : public QObject, public QmlPropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QmlPropertyValueSource)
-public:
- virtual void setTarget(const QmlMetaProperty &) {}
-};
-QML_DECLARE_TYPE(ValueSourceTestType);
-QML_DEFINE_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType);
-
-class ValueInterceptorTestType : public QObject, public QmlPropertyValueInterceptor
-{
- Q_OBJECT
- Q_INTERFACES(QmlPropertyValueInterceptor)
-public:
- virtual void setTarget(const QmlMetaProperty &) {}
- virtual void write(const QVariant &) {}
-};
-QML_DECLARE_TYPE(ValueInterceptorTestType);
-QML_DEFINE_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType);
-
-
-#define COPY_TEST(cpptype, metatype, value, defaultvalue) \
-{ \
- cpptype v = (value); cpptype v2 = (value); \
- QVERIFY(QmlMetaType::copy(QMetaType:: metatype, &v, 0)); \
- QVERIFY(v == (defaultvalue)); \
- QVERIFY(QmlMetaType::copy(QMetaType:: metatype, &v, &v2)); \
- QVERIFY(v == (value)); \
-}
-
-#define QT_COPY_TEST(type, value) \
-{ \
- type v = (value); type v2 = (value); \
- QVERIFY(QmlMetaType::copy(QMetaType:: type, &v, 0)); \
- QVERIFY(v == (type ())); \
- QVERIFY(QmlMetaType::copy(QMetaType:: type, &v, &v2)); \
- QVERIFY(v == (value)); \
-}
-
-void tst_qmlmetatype::copy()
-{
- QVERIFY(QmlMetaType::copy(QMetaType::Void, 0, 0));
-
- COPY_TEST(bool, Bool, true, false);
- COPY_TEST(int, Int, 10, 0);
- COPY_TEST(unsigned int, UInt, 10, 0);
- COPY_TEST(long long, LongLong, 10, 0);
- COPY_TEST(unsigned long long, ULongLong, 10, 0);
- COPY_TEST(double, Double, 19.2, 0);
-
- QT_COPY_TEST(QChar, QChar('a'));
-
- QVariantMap variantMap;
- variantMap.insert("Hello World!", QVariant(10));
- QT_COPY_TEST(QVariantMap, variantMap);
-
- QT_COPY_TEST(QVariantList, QVariantList() << QVariant(19.2));
- QT_COPY_TEST(QString, QString("QML Rocks!"));
- QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks");
- QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD"));
- QT_COPY_TEST(QBitArray, QBitArray(102, true));
- QDate cd = QDate::currentDate();
- QT_COPY_TEST(QDate, cd);
- QTime ct = QTime::currentTime();
- QT_COPY_TEST(QTime, ct);
- QDateTime cdt = QDateTime::currentDateTime();
- QT_COPY_TEST(QDateTime, cdt);
- QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com"));
- QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia));
- QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99));
- QT_COPY_TEST(QRectF, QRectF(-10.2, 1.2, 102, 99.6));
- QT_COPY_TEST(QSize, QSize(100, 2));
- QT_COPY_TEST(QSizeF, QSizeF(20.2, -100234.2));
- QT_COPY_TEST(QLine, QLine(0, 0, 100, 100));
- QT_COPY_TEST(QLineF, QLineF(-10.2, 0, 103, 1));
- QT_COPY_TEST(QPoint, QPoint(-1912, 1613));
- QT_COPY_TEST(QPointF, QPointF(-908.1, 1612));
- QT_COPY_TEST(QRegExp, QRegExp("(\\d+)(?:\\s*)(cm|inch)"));
-
- QVariantHash variantHash;
- variantHash.insert("Hello World!", QVariant(19));
- QT_COPY_TEST(QVariantHash, variantHash);
-
-#ifdef QT3_SUPPORT
- QT_COPY_TEST(QColorGroup, QColorGroup(Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red, Qt::red));
-#endif
-
- QT_COPY_TEST(QFont, QFont("Helvetica", 1024));
-
- {
- QPixmap v = QPixmap(100, 100); QPixmap v2 = QPixmap(100, 100);
- QVERIFY(QmlMetaType::copy(QMetaType::QPixmap, &v, 0));
- QVERIFY(v.size() == QPixmap().size());
- QVERIFY(QmlMetaType::copy(QMetaType::QPixmap , &v, &v2));
- QVERIFY(v.size() == QPixmap(100,100).size());
- }
-
- QT_COPY_TEST(QBrush, QBrush(Qt::blue));
- QT_COPY_TEST(QColor, QColor("lightsteelblue"));
- QT_COPY_TEST(QPalette, QPalette(Qt::green));
-
- {
- QPixmap icon(100, 100);
-
- QIcon v = QIcon(icon); QIcon v2 = QIcon(icon);
- QVERIFY(QmlMetaType::copy(QMetaType::QIcon, &v, 0));
- QVERIFY(v.isNull() == QIcon().isNull());
- QVERIFY(QmlMetaType::copy(QMetaType::QIcon , &v, &v2));
- QVERIFY(v.isNull() == QIcon(icon).isNull());
- }
-
- {
- QImage v = QImage(100, 100, QImage::Format_RGB32);
- QImage v2 = QImage(100, 100, QImage::Format_RGB32);
- QVERIFY(QmlMetaType::copy(QMetaType::QImage, &v, 0));
- QVERIFY(v.size() == QImage().size());
- QVERIFY(QmlMetaType::copy(QMetaType::QImage , &v, &v2));
- QVERIFY(v.size() == QImage(100,100, QImage::Format_RGB32).size());
- }
-
- QT_COPY_TEST(QPolygon, QPolygon(QRect(100, 100, 200, 103)));
- QT_COPY_TEST(QRegion, QRegion(QRect(0, 10, 99, 87)));
-
- {
- QBitmap v = QBitmap(100, 100); QBitmap v2 = QBitmap(100, 100);
- QVERIFY(QmlMetaType::copy(QMetaType::QBitmap, &v, 0));
- QVERIFY(v.size() == QBitmap().size());
- QVERIFY(QmlMetaType::copy(QMetaType::QBitmap , &v, &v2));
- QVERIFY(v.size() == QBitmap(100,100).size());
- }
-
- {
- QCursor v = QCursor(Qt::SizeFDiagCursor); QCursor v2 = QCursor(Qt::SizeFDiagCursor);
- QVERIFY(QmlMetaType::copy(QMetaType::QCursor, &v, 0));
- QVERIFY(v.shape() == QCursor().shape());
- QVERIFY(QmlMetaType::copy(QMetaType::QCursor , &v, &v2));
- QVERIFY(v.shape() == QCursor(Qt::SizeFDiagCursor).shape());
- }
-
- QT_COPY_TEST(QSizePolicy, QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum));
- QT_COPY_TEST(QKeySequence, QKeySequence("Ctrl+O"));
- QT_COPY_TEST(QPen, QPen(Qt::red));
- QT_COPY_TEST(QTextLength, QTextLength(QTextLength::FixedLength, 10.2));
- QT_COPY_TEST(QTextFormat, QTextFormat(QTextFormat::ListFormat));
- QT_COPY_TEST(QMatrix, QMatrix().translate(10, 10));
- QT_COPY_TEST(QTransform, QTransform().translate(10, 10));
- QT_COPY_TEST(QMatrix4x4, QMatrix4x4(1,0,2,3,0,1,0,0,9,0,1,0,0,0,10,1));
- QT_COPY_TEST(QVector2D, QVector2D(10.2, 1));
- QT_COPY_TEST(QVector3D, QVector3D(10.2, 1, -2));
- QT_COPY_TEST(QVector4D, QVector4D(10.2, 1, -2, 1.2));
- QT_COPY_TEST(QQuaternion, QQuaternion(1.0, 10.2, 1, -2));
-
- int voidValue;
- COPY_TEST(void *, VoidStar, (void *)&voidValue, (void *)0);
- COPY_TEST(long, Long, 10, 0);
- COPY_TEST(short, Short, 10, 0);
- COPY_TEST(char, Char, 'a', 0);
- COPY_TEST(unsigned long, ULong, 10, 0);
- COPY_TEST(unsigned short, UShort, 10, 0);
- COPY_TEST(unsigned char, UChar, 'a', 0);
- COPY_TEST(float, Float, 10.5, 0);
-
- QObject objectValue;
- QWidget widgetValue;
- COPY_TEST(QObject *, QObjectStar, &objectValue, 0);
- COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0);
- COPY_TEST(qreal, QReal, 10.2, 0);
-
- {
- QVariant tv = QVariant::fromValue(QVariant(10));
- QVariant v(tv); QVariant v2(tv);
- QVERIFY(QmlMetaType::copy(qMetaTypeId<QVariant>(), &v, 0));
- QVERIFY(v == QVariant());
- QVERIFY(QmlMetaType::copy(qMetaTypeId<QVariant>(), &v, &v2));
- QVERIFY(v == tv);
- }
-
- {
- TestType t; QVariant tv = QVariant::fromValue(&t);
-
- QVariant v(tv); QVariant v2(tv);
- QVERIFY(QmlMetaType::copy(qMetaTypeId<TestType *>(), &v, 0));
- QVERIFY(v == QVariant::fromValue((TestType *)0));
- QVERIFY(QmlMetaType::copy(qMetaTypeId<TestType *>(), &v, &v2));
- QVERIFY(v == tv);
- }
-}
-
-void tst_qmlmetatype::qmlParserStatusCast()
-{
- QVERIFY(QmlMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
-
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- int cast = QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ParserStatusTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QmlParserStatus *)&t));
-
- QmlParserStatus *status = reinterpret_cast<QmlParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(status, &t);
-}
-
-void tst_qmlmetatype::qmlPropertyValueSourceCast()
-{
- QVERIFY(QmlMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
-
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- int cast = QmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueSourceTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QmlPropertyValueSource *)&t));
-
- QmlPropertyValueSource *source = reinterpret_cast<QmlPropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(source, &t);
-}
-
-void tst_qmlmetatype::qmlPropertyValueInterceptorCast()
-{
- QVERIFY(QmlMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
-
- QVERIFY(QmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
- int cast = QmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueInterceptorTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QmlPropertyValueInterceptor *)&t));
-
- QmlPropertyValueInterceptor *interceptor = reinterpret_cast<QmlPropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(interceptor, &t);
-}
-
-void tst_qmlmetatype::isList()
-{
- QCOMPARE(QmlMetaType::isList(QVariant::Invalid), false);
- QCOMPARE(QmlMetaType::isList(QVariant::Int), false);
-
- QmlListProperty<TestType> list;
-
- QCOMPARE(QmlMetaType::isList(qMetaTypeId<QmlListProperty<TestType> >()), true);
-}
-
-void tst_qmlmetatype::defaultObject()
-{
- QVERIFY(QmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
- QVERIFY(QmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
- QCOMPARE(QString(QmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
-
- QObject o;
- TestType t;
- ParserStatusTestType p;
-
- QVERIFY(QmlMetaType::defaultProperty((QObject *)0).name() == 0);
- QVERIFY(QmlMetaType::defaultProperty(&o).name() == 0);
- QVERIFY(QmlMetaType::defaultProperty(&p).name() == 0);
- QCOMPARE(QString(QmlMetaType::defaultProperty(&t).name()), QString("foo"));
-}
-
-QTEST_MAIN(tst_qmlmetatype)
-
-#include "tst_qmlmetatype.moc"
diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp
deleted file mode 100644
index 0d7f985a08..0000000000
--- a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtDeclarative/qmlmoduleplugin.h>
-#include <QtDeclarative/qml.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-QML_DECLARE_TYPE(MyPluginType);
-QML_DEFINE_TYPE(com.nokia.AutoTestQmlPluginType,1,0,MyPluginType,MyPluginType);
-
-
-class MyPlugin : public QmlModulePlugin
-{
- Q_OBJECT
-public:
- MyPlugin()
- {
- qWarning("plugin created");
- }
-
- QStringList keys() const
- {
- return QStringList() << QLatin1String("com.nokia.AutoTestQmlPluginType");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro
deleted file mode 100644
index 0625ea3f3c..0000000000
--- a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = qmlmodules
diff --git a/tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro b/tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro
deleted file mode 100644
index c60743dade..0000000000
--- a/tests/auto/declarative/qmlmoduleplugin/qmlmoduleplugin.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT = core
-TEMPLATE = subdirs
-SUBDIRS = plugin
-tst_qmlmoduleplugin_pro.depends += plugin
-SUBDIRS += tst_qmlmoduleplugin.pro
-
-
diff --git a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp b/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp
deleted file mode 100644
index 87125fca8b..0000000000
--- a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <qdir.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <QDebug>
-
-class tst_qmlmoduleplugin : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmoduleplugin() {
- QCoreApplication::addLibraryPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin"));
-qDebug() << QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin");
- }
-
-private slots:
- void importsPlugin();
-};
-
-#define VERIFY_ERRORS(errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QmlError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QmlError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- if (qgetenv("DEBUG") != "" && expected != actual) \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- if (qgetenv("QMLLANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::WriteOnly)); \
- for (int ii = 0; ii < actual.count(); ++ii) { \
- file.write(actual.at(ii)); file.write("\n"); \
- } \
- file.close(); \
- } else { \
- QCOMPARE(expected, actual); \
- } \
- }
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- QFileInfo fileInfo(__FILE__);
- return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename));
-}
-
-
-void tst_qmlmoduleplugin::importsPlugin()
-{
- QmlEngine engine;
- QTest::ignoreMessage(QtWarningMsg, "plugin created");
- QTest::ignoreMessage(QtWarningMsg, "import worked");
- QmlComponent component(&engine, TEST_FILE("plugin.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
-}
-
-QTEST_MAIN(tst_qmlmoduleplugin)
-
-#include "tst_qmlmoduleplugin.moc"
diff --git a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro b/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro
deleted file mode 100644
index 3c8a568f62..0000000000
--- a/tests/auto/declarative/qmlmoduleplugin/tst_qmlmoduleplugin.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-load(qttest_p4)
-SOURCES = tst_qmlmoduleplugin.cpp
-QT += declarative
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro b/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro
deleted file mode 100644
index 8113278643..0000000000
--- a/tests/auto/declarative/qmlnumberformatter/qmlnumberformatter.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlnumberformatter.cpp
diff --git a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
deleted file mode 100644
index 30f2feaa05..0000000000
--- a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qnumberformat_p.h>
-#include <private/qmlnumberformatter_p.h>
-
-class tst_qmlnumberformatter : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlnumberformatter();
-
- void init() {}
- void initTestCase() {}
-
- void cleanup() {}
- void cleanupTestCase() {}
-
-private slots:
- void text_data();
- void text();
-
-private:
- QStringList strings;
- QStringList formats;
- QStringList texts;
-};
-
-tst_qmlnumberformatter::tst_qmlnumberformatter()
-{
- strings << "100.0"
- << "12345"
- << "1234567"
- << "0.123"
- << "0.9999"
- << "0.989"
- << "1"
- << "1.0"
- << "1.01";
-
- formats << ""
- << "0000"
- << "0000.00"
- << "##"
- << "##.##"
- << "#0.00#"
- << "##,##0.##"
- << "(000) 000 - 000"
- << "00000,000.0000";
-
- //US locale only.
- texts << "100.000000"
- << "12345.000000"
- << "1234567.000000"
- << "0.123000"
- << "0.999900"
- << "0.989000"
- << "1.000000"
- << "1.000000"
- << "1.010000" //end ""
- << "0100"
- << "12345"
- << "1234567"
- << "0000"
- << "0001"
- << "0001"
- << "0001"
- << "0001"
- << "0001" // end "0000"
- << "0100.00"
- << "12345.00"
- << "1234567.00"
- << "0000.12"
- << "0001.00"
- << "0000.99"
- << "0001.00"
- << "0001.00"
- << "0001.01" // end "0000.00"
- << "100"
- << "12345"
- << "1234567"
- << "0"
- << "1"
- << "1"
- << "1"
- << "1"
- << "1" // end "##"
- << "100"//start "##.##"
- << "12345"
- << "1234567"
- << "0.12"
- << "1"
- << "0.99"
- << "1"
- << "1"
- << "1.01" // end "##.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
- << "100.00" //start "#0.00#"
- << "12345.00"
- << "1234567.00"
- << "0.123"
- << "1.00"
- << "0.989"
- << "1.00"
- << "1.00"
- << "1.01" //end "#0.00#"
- << "100" //start "##,##0.##"
- << "12,345"
- << "1,234,567"
- << "0.12"
- << "1"
- << "0.99"
- << "1"
- << "1"
- << "1.01" //end "##,##0.##" -- ### EXPECT FAIL ### QNumberFormat::formatDecimal() bug
- << "(000) 000 - 100" //start "(000) 000 - 000"
- << "(000) 012 - 345"
- << "(001) 234 - 567"
- << "(000) 000 - 000"
- << "(000) 000 - 001"
- << "(000) 000 - 001"
- << "(000) 000 - 001"
- << "(000) 000 - 001"
- << "(000) 000 - 001" // end "(000) 000 - 000"
- << "00,000,100.0000" // start "00000,000.0000"
- << "00,012,345.0000"
- << "01,234,567.0000"
- << "00,000,000.1230"
- << "00,000,000.9999"
- << "00,000,000.9890"
- << "00,000,001.0000"
- << "00,000,001.0000"
- << "00,000,001.0100"; // end
-
- qDebug() << "strings.size()" << strings.size()
- << "\nformats.size()" << formats.size()
- << "texts.size()" << texts.size();
-}
-
-void tst_qmlnumberformatter::text_data()
-{
- QTest::addColumn<QString>("string");
- QTest::addColumn<QString>("format");
- QTest::addColumn<QString>("text");
-
- for (int j=0; j < formats.size(); j++)
- {
- for (int i=0; i < strings.size(); i++)
- {
- QTest::newRow(QString("%1, %2").arg(strings.at(i)).arg(formats.at(j)).toAscii())
- << strings.at(i) << formats.at(j) << texts.at(j*formats.size()+i);
- }
- }
-
-}
-
-void tst_qmlnumberformatter::text()
-{
- QFETCH(QString, string);
- QFETCH(QString, format);
- QFETCH(QString, text);
-
- QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: ") + string + QString("; format: \"") + format + QString("\" }");
-
- QmlEngine engine;
- QmlComponent formatterComponent(&engine);
- formatterComponent.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
- if(formatterComponent.isError())
- qDebug() << formatterComponent.errors();
- QVERIFY(formatterComponent.isReady());
- QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
- QVERIFY(formatter != 0);
-
- QCOMPARE(formatter->format(), format);
- QCOMPARE(formatter->text(), text);
-
- delete formatter;
-}
-
-QTEST_MAIN(tst_qmlnumberformatter)
-
-#include "tst_qmlnumberformatter.moc"
diff --git a/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro b/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro
deleted file mode 100644
index 423fa2fafa..0000000000
--- a/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-QT += network
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlpixmapcache.cpp
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
diff --git a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp
deleted file mode 100644
index 019fc2ac3f..0000000000
--- a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp
+++ /dev/null
@@ -1,282 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtTest/QtTest>
-#include <private/qmlpixmapcache_p.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QNetworkReply>
-
-// These don't let normal people run tests!
-//#include "../network-settings.h"
-
-class tst_qmlpixmapcache : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlpixmapcache() :
- thisfile(QUrl::fromLocalFile(__FILE__))
- {
- }
-
-private slots:
- void single();
- void single_data();
- void parallel();
- void parallel_data();
-
-private:
- QmlEngine engine;
- QUrl thisfile;
-};
-
-
-static int slotters=0;
-
-class Slotter : public QObject
-{
- Q_OBJECT
-public:
- Slotter()
- {
- gotslot = false;
- slotters++;
- }
- bool gotslot;
-
-public slots:
- void got()
- {
- gotslot = true;
- --slotters;
- if (slotters==0)
- QTestEventLoop::instance().exitLoop();
- }
-};
-
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
-static const bool localfile_optimized = true;
-#else
-static const bool localfile_optimized = false;
-#endif
-
-void tst_qmlpixmapcache::single_data()
-{
- // Note, since QmlPixmapCache is shared, tests affect each other!
- // so use different files fore all test functions.
-
- QTest::addColumn<QUrl>("target");
- QTest::addColumn<bool>("incache");
- QTest::addColumn<bool>("exists");
- QTest::addColumn<bool>("neterror");
-
- // File URLs are optimized
- QTest::newRow("local") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false;
- QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false;
- QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false;
- QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true;
-}
-
-void tst_qmlpixmapcache::single()
-{
- QFETCH(QUrl, target);
- QFETCH(bool, incache);
- QFETCH(bool, exists);
- QFETCH(bool, neterror);
-
- if (neterror) {
- QString expected = "\"Error downloading " + target.toString() + " - server replied: Not Found\" ";
- QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
- } else if (!exists) {
- QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) ";
- QTest::ignoreMessage(QtWarningMsg, expected.toLatin1());
- }
-
- QPixmap pixmap;
- QVERIFY(pixmap.width() <= 0); // Check Qt assumption
- QmlPixmapReply::Status status = QmlPixmapCache::get(target, &pixmap);
-
- if (incache) {
- if (exists) {
- QVERIFY(status == QmlPixmapReply::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(status == QmlPixmapReply::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- } else {
- QmlPixmapReply *reply = QmlPixmapCache::request(&engine, target);
- QVERIFY(reply);
- QVERIFY(pixmap.width() <= 0);
-
- Slotter getter;
- connect(reply, SIGNAL(finished()), &getter, SLOT(got()));
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(getter.gotslot);
- if (exists) {
- QVERIFY(QmlPixmapCache::get(target, &pixmap) == QmlPixmapReply::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(QmlPixmapCache::get(target, &pixmap) == QmlPixmapReply::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- }
-
- QCOMPARE(QmlPixmapCache::pendingRequests(), 0);
-}
-
-void tst_qmlpixmapcache::parallel_data()
-{
- // Note, since QmlPixmapCache is shared, tests affect each other!
- // so use different files fore all test functions.
-
- QTest::addColumn<QUrl>("target1");
- QTest::addColumn<QUrl>("target2");
- QTest::addColumn<int>("incache");
- QTest::addColumn<int>("cancel"); // which one to cancel
- QTest::addColumn<int>("requests");
-
- QTest::newRow("local")
- << thisfile.resolved(QUrl("data/exists1.png"))
- << thisfile.resolved(QUrl("data/exists2.png"))
- << (localfile_optimized ? 2 : 0)
- << -1
- << (localfile_optimized ? 0 : 2)
- ;
-
- QTest::newRow("remote")
- << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
- << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
- << 0
- << -1
- << 2
- ;
-
- QTest::newRow("remoteagain")
- << QUrl("http://qt.nokia.com/images/template/checkbox-on.png")
- << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile")
- << 2
- << -1
- << 0
- ;
-
- QTest::newRow("remotecopy")
- << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
- << QUrl("http://qt.nokia.com/images/template/checkbox-off.png")
- << 0
- << -1
- << 1
- ;
-
- QTest::newRow("remotecopycancel")
- << QUrl("http://qt.nokia.com/rounded_block_bg.png")
- << QUrl("http://qt.nokia.com/rounded_block_bg.png")
- << 0
- << 0
- << 1
- ;
-}
-
-void tst_qmlpixmapcache::parallel()
-{
- QFETCH(QUrl, target1);
- QFETCH(QUrl, target2);
- QFETCH(int, incache);
- QFETCH(int, cancel);
- QFETCH(int, requests);
-
- QList<QUrl> targets;
- targets << target1 << target2;
-
- QList<QmlPixmapReply*> replies;
- QList<Slotter*> getters;
- for (int i=0; i<targets.count(); ++i) {
- QUrl target = targets.at(i);
- QPixmap pixmap;
- QmlPixmapReply::Status status = QmlPixmapCache::get(target, &pixmap);
- QmlPixmapReply *reply = 0;
- if (status != QmlPixmapReply::Error && status != QmlPixmapReply::Ready)
- reply = QmlPixmapCache::request(&engine, target);
- replies.append(reply);
- if (!reply) {
- QVERIFY(pixmap.width() > 0);
- getters.append(0);
- } else {
- QVERIFY(pixmap.width() <= 0);
- getters.append(new Slotter);
- connect(reply, SIGNAL(finished()), getters[i], SLOT(got()));
- }
- }
-
- QCOMPARE(incache+slotters, targets.count());
- QCOMPARE(QmlPixmapCache::pendingRequests(), requests);
-
- if (cancel >= 0) {
- QmlPixmapCache::cancel(targets.at(cancel), getters[cancel]);
- slotters--;
- }
-
- if (slotters) {
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- }
-
- for (int i=0; i<targets.count(); ++i) {
- QmlPixmapReply *reply = replies[i];
- if (reply) {
- if (i == cancel) {
- QVERIFY(!getters[i]->gotslot);
- } else {
- QVERIFY(getters[i]->gotslot);
- QPixmap pixmap;
- QVERIFY(QmlPixmapCache::get(targets[i], &pixmap) == QmlPixmapReply::Ready);
- QVERIFY(pixmap.width() > 0);
- }
- delete getters[i];
- }
- }
-
- QCOMPARE(QmlPixmapCache::pendingRequests(), 0);
-}
-
-QTEST_MAIN(tst_qmlpixmapcache)
-
-#include "tst_qmlpixmapcache.moc"
diff --git a/tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro b/tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro
deleted file mode 100644
index 967ab76726..0000000000
--- a/tests/auto/declarative/qmlpropertymap/qmlpropertymap.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlpropertymap.cpp
diff --git a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
deleted file mode 100644
index 26b89a6358..0000000000
--- a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp
+++ /dev/null
@@ -1,171 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlpropertymap.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstext_p.h>
-#include <QSignalSpy>
-
-class tst_QmlPropertyMap : public QObject
-{
- Q_OBJECT
-public:
- tst_QmlPropertyMap() {}
-
-private slots:
- void insert();
- void operatorInsert();
- void operatorValue();
- void clear();
- void changed();
- void count();
-};
-
-void tst_QmlPropertyMap::insert()
-{
- QmlPropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
-
- map.insert(QLatin1String("key1"),"Hello World");
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QmlPropertyMap::operatorInsert()
-{
- QmlPropertyMap map;
- map[QLatin1String("key1")] = 100;
- map[QLatin1String("key2")] = 200;
- QVERIFY(map.keys().count() == 2);
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
-
- map[QLatin1String("key1")] = "Hello World";
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QmlPropertyMap::operatorValue()
-{
- QmlPropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- const QmlPropertyMap &constMap = map;
-
- QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
- QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
- QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
-}
-
-void tst_QmlPropertyMap::clear()
-{
- QmlPropertyMap map;
- map.insert(QLatin1String("key1"),100);
- QVERIFY(map.keys().count() == 1);
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
-
- map.clear(QLatin1String("key1"));
- QVERIFY(map.keys().count() == 1);
- QVERIFY(map.contains(QLatin1String("key1")));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant());
-}
-
-void tst_QmlPropertyMap::changed()
-{
- QmlPropertyMap map;
- QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&)));
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QCOMPARE(spy.count(), 0);
-
- map.clear(QLatin1String("key1"));
- QCOMPARE(spy.count(), 0);
-
- //make changes in QML
- QmlEngine engine;
- QmlContext *ctxt = engine.rootContext();
- ctxt->setContextProperty(QLatin1String("testdata"), &map);
- QmlComponent component(&engine);
- component.setData("import Qt 4.6\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
- QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
- QmlGraphicsText *txt = qobject_cast<QmlGraphicsText*>(component.create());
- QVERIFY(txt);
- QCOMPARE(txt->text(), QString('X'));
- QCOMPARE(spy.count(), 1);
- QList<QVariant> arguments = spy.takeFirst();
- QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QmlPropertyMap::count()
-{
- QmlPropertyMap map;
- QCOMPARE(map.isEmpty(), true);
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QCOMPARE(map.count(), 2);
- QCOMPARE(map.isEmpty(), false);
-
- map.insert(QLatin1String("key3"),"Hello World");
- QCOMPARE(map.count(), 3);
-
- //clearing doesn't remove the key
- map.clear(QLatin1String("key3"));
- QCOMPARE(map.count(), 3);
- QCOMPARE(map.size(), map.count());
-}
-
-QTEST_MAIN(tst_QmlPropertyMap)
-
-#include "tst_qmlpropertymap.moc"
diff --git a/tests/auto/declarative/qmlqt/qmlqt.pro b/tests/auto/declarative/qmlqt/qmlqt.pro
deleted file mode 100644
index 5e79ea60d9..0000000000
--- a/tests/auto/declarative/qmlqt/qmlqt.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qmlqt.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
deleted file mode 100644
index c3c25210c6..0000000000
--- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
+++ /dev/null
@@ -1,369 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QDebug>
-#include <QmlEngine>
-#include <QFileInfo>
-#include <QmlComponent>
-#include <QDir>
-#include <QVector3D>
-#include <QCryptographicHash>
-#include <QmlGraphicsItem>
-
-class tst_qmlqt : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlqt() {}
-
-private slots:
- void enums();
- void rgba();
- void hsla();
- void rect();
- void point();
- void size();
- void vector();
- void lighter();
- void darker();
- void tint();
- void closestAngle();
- void playSound();
- void openUrlExternally();
- void md5();
- void createComponent();
- void createQmlObject();
- void consoleLog();
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_qmlqt::enums()
-{
- QmlComponent component(&engine, TEST_FILE("enums.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape);
- QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder);
- QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle);
- QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight);
-
- delete object;
-}
-
-void tst_qmlqt::rgba()
-{
- QmlComponent component(&engine, TEST_FILE("rgba.qml"));
-
- QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
- QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
- QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
- QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::hsla()
-{
- QmlComponent component(&engine, TEST_FILE("hsla.qml"));
-
- QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor";
- QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor";
- QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor";
- QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::rect()
-{
- QmlComponent component(&engine, TEST_FILE("rect.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109));
- QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6));
- QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF());
- QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF());
- QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF());
-
- delete object;
-}
-
-void tst_qmlqt::point()
-{
- QmlComponent component(&engine, TEST_FILE("point.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34));
- QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2));
- QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF());
- QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF());
-
- delete object;
-}
-
-void tst_qmlqt::size()
-{
- QmlComponent component(&engine, TEST_FILE("size.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF());
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF());
-
- delete object;
-}
-
-void tst_qmlqt::vector()
-{
- QmlComponent component(&engine, TEST_FILE("vector.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9));
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1));
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D());
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D());
-
- delete object;
-}
-
-void tst_qmlqt::lighter()
-{
- QmlComponent component(&engine, TEST_FILE("lighter.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::darker()
-{
- QmlComponent component(&engine, TEST_FILE("darker.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::tint()
-{
- QmlComponent component(&engine, TEST_FILE("tint.qml"));
-
- QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor";
- QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0));
- QEXPECT_FAIL("", "QT-2424",Continue);
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0, 0));
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
-
- delete object;
-}
-
-void tst_qmlqt::closestAngle()
-{
- QmlComponent component(&engine, TEST_FILE("closestangle.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0);
- QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11);
- QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11);
-
- delete object;
-}
-
-void tst_qmlqt::playSound()
-{
- QEXPECT_FAIL("", "How do we test this?", Abort);
- QVERIFY(false);
-}
-
-void tst_qmlqt::openUrlExternally()
-{
- QEXPECT_FAIL("", "How do we test this?", Abort);
- QVERIFY(false);
-}
-
-void tst_qmlqt::md5()
-{
- QmlComponent component(&engine, TEST_FILE("md5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex()));
- QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
-
- delete object;
-}
-
-void tst_qmlqt::createComponent()
-{
- QmlComponent component(&engine, TEST_FILE("createComponent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
- QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
- QCOMPARE(object->property("emptyArg").toBool(), true);
-
- QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
- QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString());
-
- delete object;
-}
-
-void tst_qmlqt::createQmlObject()
-{
- QmlComponent component(&engine, TEST_FILE("createQmlObject.qml"));
-
- QString warning1 = "QmlEngine::createQmlObject():";
- QString warning2 = " " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name";
- QString warning3 = "QmlEngine::createQmlObject(): Component is not ready";
- QString warning4 = "QmlEngine::createQmlObject():";
- QString warning5 = " " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method";
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("incorrectArgCount1").toBool(), true);
- QCOMPARE(object->property("incorrectArgCount2").toBool(), true);
- QCOMPARE(object->property("emptyArg").toBool(), true);
- QCOMPARE(object->property("errors").toBool(), true);
- QCOMPARE(object->property("noParent").toBool(), true);
- QCOMPARE(object->property("notReady").toBool(), true);
- QCOMPARE(object->property("runtimeError").toBool(), true);
- QCOMPARE(object->property("success").toBool(), true);
-
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(object);
- QVERIFY(item != 0);
- QVERIFY(item->childItems().count() == 1);
-
- delete object;
-}
-
-void tst_qmlqt::consoleLog()
-{
- QTest::ignoreMessage(QtDebugMsg, "completed ok");
- QTest::ignoreMessage(QtDebugMsg, "completed ok");
- QmlComponent component(&engine, TEST_FILE("consoleLog.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-QTEST_MAIN(tst_qmlqt)
-
-#include "tst_qmlqt.moc"
diff --git a/tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro b/tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro
deleted file mode 100644
index ffaa97f50d..0000000000
--- a/tests/auto/declarative/qmlspringfollow/qmlspringfollow.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlspringfollow.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp b/tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp
deleted file mode 100644
index 393b351f39..0000000000
--- a/tests/auto/declarative/qmlspringfollow/tst_qmlspringfollow.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlspringfollow_p.h>
-#include <private/qmlvaluetype_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlspringfollow : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlspringfollow();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlspringfollow::tst_qmlspringfollow()
-{
-}
-
-void tst_qmlspringfollow::defaultValues()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow1.qml"));
- QmlSpringFollow *obj = qobject_cast<QmlSpringFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 0.);
- QCOMPARE(obj->velocity(), 0.);
- QCOMPARE(obj->spring(), 0.);
- QCOMPARE(obj->damping(), 0.);
- QCOMPARE(obj->epsilon(), 0.01);
- QCOMPARE(obj->modulus(), 0.);
- QCOMPARE(obj->value(), 0.);
- QCOMPARE(obj->mass(), 1.);
- QCOMPARE(obj->enabled(), true);
- QCOMPARE(obj->inSync(), true);
-
- delete obj;
-}
-
-void tst_qmlspringfollow::values()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow2.qml"));
- QmlSpringFollow *obj = qobject_cast<QmlSpringFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->enabled(), true);
-
- QTRY_COMPARE(obj->value(), 1.44);
- QTRY_COMPARE(obj->inSync(), true);
-
- delete obj;
-}
-
-void tst_qmlspringfollow::disabled()
-{
- QmlEngine engine;
- QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springfollow3.qml"));
- QmlSpringFollow *obj = qobject_cast<QmlSpringFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->sourceValue(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->enabled(), false);
-
- QCOMPARE(obj->value(), 0.0);
- QCOMPARE(obj->inSync(), false);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlspringfollow)
-
-#include "tst_qmlspringfollow.moc"
diff --git a/tests/auto/declarative/qmlstates/qmlstates.pro b/tests/auto/declarative/qmlstates/qmlstates.pro
deleted file mode 100644
index 538734afa9..0000000000
--- a/tests/auto/declarative/qmlstates/qmlstates.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlstates.cpp
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
deleted file mode 100644
index b910c855a1..0000000000
--- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp
+++ /dev/null
@@ -1,911 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicsanchors_p_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
-#include <private/qmlpropertychanges_p.h>
-#include <private/qmlstategroup_p.h>
-
-class tst_qmlstates : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlstates() {}
-
-private:
- static QByteArray fullDataPath(const QString &path);
-
-private slots:
- void basicChanges();
- void basicExtension();
- void basicBinding();
- void signalOverride();
- void signalOverrideCrash();
- void parentChange();
- void parentChangeErrors();
- void anchorChanges();
- void anchorChanges2();
- void anchorChanges3();
- void anchorChanges4();
- void anchorChanges5();
- void script();
- void restoreEntryValues();
- void explicitChanges();
- void propertyErrors();
- void incorrectRestoreBug();
- void autoStateAtStartupRestoreBug();
- void deletingChange();
- void deletingState();
- void tempState();
- void illegalTempState();
- void nonExistantProperty();
-};
-
-QByteArray tst_qmlstates::fullDataPath(const QString &path)
-{
- return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8();
-}
-
-void tst_qmlstates::basicChanges()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
- //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- }
-}
-
-void tst_qmlstates::basicExtension()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rect->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2);
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-}
-
-void tst_qmlstates::basicBinding()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("red"));
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor2", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor2", QColor("green"));
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("purple"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("purple"));
-
- rect->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-}
-
-class MyRect : public QmlGraphicsRectangle
-{
- Q_OBJECT
-public:
- MyRect() {}
- void doSomething() { emit didSomething(); }
-Q_SIGNALS:
- void didSomething();
-};
-
-QML_DECLARE_TYPE(MyRect)
-QML_DEFINE_TYPE(Qt.test, 1, 0, MyRectangle,MyRect);
-
-void tst_qmlstates::signalOverride()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("white"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("extendedRect"));
-
- innerRect->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(innerRect->color(),QColor("green"));
- QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
- }
-}
-
-void tst_qmlstates::signalOverrideCrash()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- rect->setState("overridden");
- rect->doSomething();
-}
-
-void tst_qmlstates::parentChange()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlParentChange *pChange = qobject_cast<QmlParentChange*>(state->operationAt(0));
- QVERIFY(pChange != 0);
- QmlGraphicsItem *nParent = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("NewParent"));
- QVERIFY(nParent != 0);
-
- QCOMPARE(pChange->parent(), nParent);
-
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-133));
- QCOMPARE(innerRect->y(), qreal(-300));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(15));
- QCOMPARE(innerRect->scale(), qreal(.5));
- QEXPECT_FAIL("", "QTBUG-2919", Continue);
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(12.4148145657));
- QEXPECT_FAIL("", "QTBUG-2919", Continue);
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(10.6470476128));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(-37));
- QCOMPARE(innerRect->scale(), qreal(.25));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
-
- rect->setState("");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QEXPECT_FAIL("", "QTBUG-2919", Continue);
- QCOMPARE(innerRect->y(), qreal(0));
- }
-}
-
-void tst_qmlstates::parentChangeErrors()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange4.qml") + ":25:9) Unable to preserve appearance under non-uniform scale").constData());
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML ParentChange (" + fullDataPath("/data/parentChange5.qml") + ":25:9) Unable to preserve appearance under complex transform").constData());
- rect->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-}
-
-void tst_qmlstates::anchorChanges()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->reset(), QString("left"));
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->right().item, rect->right().item);
- QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
-
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges2()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rect->setState("right");
- QEXPECT_FAIL("", "QTBUG-5338", Continue);
- QCOMPARE(innerRect->x(), qreal(150));
-
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges3()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("reanchored");
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->left().item, leftGuideline->left().item);
- QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine);
- QCOMPARE(aChanges->right().item, rect->right().item);
- QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
- QCOMPARE(aChanges->top().item, rect->top().item);
- QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine);
- QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item);
- QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- QCOMPARE(innerRect->width(), qreal(190));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- QCOMPARE(innerRect->width(), qreal(150));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges4()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("reanchored");
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item);
- QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
-
- delete rect;
-}
-
-void tst_qmlstates::anchorChanges5()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rect->setState("reanchored");
- QCOMPARE(aChanges->object(), innerRect);
- QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item);
- QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine);
-
- delete rect;
-}
-
-void tst_qmlstates::script()
-{
- QmlEngine engine;
-
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/script.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
- }
-}
-
-void tst_qmlstates::restoreEntryValues()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("blue"));
-}
-
-void tst_qmlstates::explicitChanges()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/explicit.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlListReference list(rect, "states");
- QmlState *state = qobject_cast<QmlState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QmlPropertyChanges *changes = qobject_cast<QmlPropertyChanges*>(rect->findChild<QmlPropertyChanges*>("changes"));
- QVERIFY(changes != 0);
- QVERIFY(changes->isExplicit());
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
-}
-
-void tst_qmlstates::propertyErrors()
-{
- QmlEngine engine;
- QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to non-existent property \"colr\"").constData());
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/propertyErrors.qml") + ":8:9) Cannot assign to read-only property \"wantsFocus\"").constData());
- rect->setState("blue");
-}
-
-void tst_qmlstates::incorrectRestoreBug()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- // make sure if we change the base state value, we then restore to it correctly
- rect->setColor(QColor("green"));
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("green"));
-}
-
-void tst_qmlstates::autoStateAtStartupRestoreBug()
-{
- QmlEngine engine;
-
- QmlComponent component(&engine, SRCDIR "/data/autoStateAtStartupRestoreBug.qml");
- QObject *obj = component.create();
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 3);
-
- obj->setProperty("input", 2);
-
- QCOMPARE(obj->property("test").toInt(), 9);
-
- delete obj;
-}
-
-void tst_qmlstates::deletingChange()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/deleting.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->radius(),qreal(5));
-
- rect->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(0));
-
- QmlPropertyChanges *pc = rect->findChild<QmlPropertyChanges*>("pc1");
- QVERIFY(pc != 0);
- delete pc;
-
- QmlState *state = rect->findChild<QmlState*>();
- QVERIFY(state != 0);
- qmlExecuteDeferred(state);
- QCOMPARE(state->operationCount(), 1);
-
- rect->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(5));
-
- delete rect;
-}
-
-void tst_qmlstates::deletingState()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QmlStateGroup *sg = rect->findChild<QmlStateGroup*>();
- QVERIFY(sg != 0);
- QVERIFY(sg->findState("blue") != 0);
-
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- sg->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- QmlState *state = rect->findChild<QmlState*>();
- QVERIFY(state != 0);
- delete state;
-
- QVERIFY(sg->findState("blue") == 0);
-
- //### should we warn that state doesn't exist
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
-
- delete rect;
-}
-
-void tst_qmlstates::tempState()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QTest::ignoreMessage(QtDebugMsg, "entering placed");
- QTest::ignoreMessage(QtDebugMsg, "entering idle");
- rect->setState("placed");
- QCOMPARE(rect->state(), QLatin1String("idle"));
-}
-
-void tst_qmlstates::illegalTempState()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. ");
- rect->setState("placed");
- QCOMPARE(rect->state(), QLatin1String("placed"));
-}
-
-void tst_qmlstates::nonExistantProperty()
-{
- QmlEngine engine;
-
- QmlComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, QByteArray("QML PropertyChanges (" + fullDataPath("/data/nonExistantProp.qml") + ":9:9) Cannot assign to non-existent property \"colr\"").constData());
- rect->setState("blue");
- QCOMPARE(rect->state(), QLatin1String("blue"));
-}
-
-QTEST_MAIN(tst_qmlstates)
-
-#include "tst_qmlstates.moc"
diff --git a/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro b/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro
deleted file mode 100644
index 4d55b460b4..0000000000
--- a/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlsystempalette.cpp
diff --git a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp b/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp
deleted file mode 100644
index 06e4d1cded..0000000000
--- a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp
+++ /dev/null
@@ -1,187 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlsystempalette_p.h>
-#include <qpalette.h>
-#include "../../../shared/util.h"
-
-class tst_qmlsystempalette : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlsystempalette();
-
-private slots:
- void activePalette();
- void inactivePalette();
- void disabledPalette();
- void paletteChanged();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlsystempalette::tst_qmlsystempalette()
-{
-}
-
-void tst_qmlsystempalette::activePalette()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Active);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qmlsystempalette::inactivePalette()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Inactive }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QmlSystemPalette::Inactive);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Inactive);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qmlsystempalette::disabledPalette()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Disabled }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QmlSystemPalette::Disabled);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Disabled);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qmlsystempalette::paletteChanged()
-{
- QString componentStr = "import Qt 4.6\nSystemPalette { }";
- QmlComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette p;
- p.setCurrentColorGroup(QPalette::Active);
- p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
- p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
- p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
-
- qApp->setPalette(p);
-
- object->setColorGroup(QmlSystemPalette::Active);
- QTRY_COMPARE(QColor("red"), object->text());
- QTRY_COMPARE(QColor("green"), object->buttonText());
- QTRY_COMPARE(QColor("blue"), object->windowText());
-
- delete object;
-}
-
-QTEST_MAIN(tst_qmlsystempalette)
-
-#include "tst_qmlsystempalette.moc"
diff --git a/tests/auto/declarative/qmltimer/qmltimer.pro b/tests/auto/declarative/qmltimer/qmltimer.pro
deleted file mode 100644
index 2b244ed487..0000000000
--- a/tests/auto/declarative/qmltimer/qmltimer.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmltimer.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp
deleted file mode 100644
index b8b5e620f4..0000000000
--- a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp
+++ /dev/null
@@ -1,285 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmltimer_p.h>
-#include <QDebug>
-
-class tst_qmltimer : public QObject
-{
- Q_OBJECT
-public:
- tst_qmltimer();
-
-private slots:
- void notRepeating();
- void notRepeatingStart();
- void repeat();
- void noTriggerIfNotRunning();
- void triggeredOnStart();
- void triggeredOnStartRepeat();
- void changeDuration();
- void restart();
-};
-
-class TimerHelper : public QObject
-{
- Q_OBJECT
-public:
- TimerHelper() : QObject(), count(0)
- {
- }
-
- int count;
-
-public slots:
- void timeout() {
- ++count;
- }
-};
-
-#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
-// Increase wait as emulator startup can cause unexpected delays
-#define TIMEOUT_TIMEOUT 2000
-#else
-#define TIMEOUT_TIMEOUT 200
-#endif
-
-tst_qmltimer::tst_qmltimer()
-{
-}
-
-void tst_qmltimer::notRepeating()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->isRunning());
- QVERIFY(!timer->isRepeating());
- QCOMPARE(timer->interval(), 100);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-}
-
-void tst_qmltimer::notRepeatingStart()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(!timer->isRunning());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 0);
-
- timer->start();
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-
- delete timer;
-}
-
-void tst_qmltimer::repeat()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 0);
- int oldCount = helper.count;
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- oldCount = helper.count;
- timer->stop();
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count == oldCount);
- QVERIFY(timer->isRunning() == false);
-
- delete timer;
-}
-
-void tst_qmltimer::triggeredOnStart()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->triggeredOnStart());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning() == false);
-
- delete timer;
-}
-
-void tst_qmltimer::triggeredOnStartRepeat()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 1);
- int oldCount = helper.count;
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qmltimer::noTriggerIfNotRunning()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray(
- "import Qt 4.6\n"
- "Item { property bool ok: true\n"
- "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
- "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
- "}"
- ), QUrl::fromLocalFile(""));
- QObject *item = component.create();
- QVERIFY(item != 0);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(item->property("ok").toBool(), true);
-
- delete item;
-}
-
-void tst_qmltimer::changeDuration()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(500);
- QCOMPARE(helper.count, 2);
-
- timer->setInterval(500);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 3);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qmltimer::restart()
-{
- QmlEngine engine;
- QmlComponent component(&engine);
- component.setData(QByteArray("import Qt 4.6\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QmlTimer *timer = qobject_cast<QmlTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(300);
-
- timer->restart();
-
- QTest::qWait(700);
-
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-QTEST_MAIN(tst_qmltimer)
-
-#include "tst_qmltimer.moc"
diff --git a/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro b/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro
deleted file mode 100644
index 82d067ed82..0000000000
--- a/tests/auto/declarative/qmlvaluetypes/qmlvaluetypes.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-macx:CONFIG -= app_bundle
-
-HEADERS += testtypes.h
-
-SOURCES += tst_qmlvaluetypes.cpp \
- testtypes.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlvaluetypes/testtypes.cpp b/tests/auto/declarative/qmlvaluetypes/testtypes.cpp
deleted file mode 100644
index c51b7777d2..0000000000
--- a/tests/auto/declarative/qmlvaluetypes/testtypes.cpp
+++ /dev/null
@@ -1,45 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
-
-QML_DEFINE_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject);
-QML_DEFINE_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource);
-QML_DEFINE_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor);
diff --git a/tests/auto/declarative/qmlvaluetypes/testtypes.h b/tests/auto/declarative/qmlvaluetypes/testtypes.h
deleted file mode 100644
index b57fbff85d..0000000000
--- a/tests/auto/declarative/qmlvaluetypes/testtypes.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QObject>
-#include <QPoint>
-#include <QPointF>
-#include <QSize>
-#include <QSizeF>
-#include <QRect>
-#include <QRectF>
-#include <QVector3D>
-#include <QFont>
-#include <qml.h>
-#include <QmlPropertyValueSource>
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed);
- Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed);
- Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed);
- Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed);
- Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed);
- Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed);
- Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed);
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed);
-
-public:
- MyTypeObject() :
- m_point(10, 4),
- m_pointf(11.3, -10.9),
- m_size(1912, 1913),
- m_sizef(0.1, 100923.2),
- m_rect(2, 3, 109, 102),
- m_rectf(103.8, 99.2, 88.1, 77.6),
- m_vector(23.88, 3.1, 4.3)
- {
- m_font.setFamily("Arial");
- m_font.setBold(true);
- m_font.setWeight(QFont::DemiBold);
- m_font.setItalic(true);
- m_font.setUnderline(true);
- m_font.setOverline(true);
- m_font.setStrikeOut(true);
- m_font.setPointSize(29);
- m_font.setCapitalization(QFont::AllUppercase);
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
- m_font.setWordSpacing(19.7);
- }
-
- QPoint m_point;
- QPoint point() const { return m_point; }
- void setPoint(const QPoint &v) { m_point = v; emit changed(); }
-
- QPointF m_pointf;
- QPointF pointf() const { return m_pointf; }
- void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
-
- QSize m_size;
- QSize size() const { return m_size; }
- void setSize(const QSize &v) { m_size = v; emit changed(); }
-
- QSizeF m_sizef;
- QSizeF sizef() const { return m_sizef; }
- void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
-
- QRect m_rect;
- QRect rect() const { return m_rect; }
- void setRect(const QRect &v) { m_rect = v; emit changed(); }
-
- QRectF m_rectf;
- QRectF rectf() const { return m_rectf; }
- void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
-
- QVector3D m_vector;
- QVector3D vector() const { return m_vector; }
- void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
-
- QFont m_font;
- QFont font() const { return m_font; }
- void setFont(const QFont &v) { m_font = v; emit changed(); }
-
- void emitRunScript() { emit runScript(); }
-
-signals:
- void changed();
- void runScript();
-};
-QML_DECLARE_TYPE(MyTypeObject);
-
-class MyConstantValueSource : public QObject, public QmlPropertyValueSource
-{
- Q_OBJECT
-public:
- virtual void setTarget(const QmlMetaProperty &p) { p.write(3345); }
-};
-QML_DECLARE_TYPE(MyConstantValueSource);
-
-class MyOffsetValueInterceptor : public QObject, public QmlPropertyValueInterceptor
-{
- Q_OBJECT
-public:
- virtual void setTarget(const QmlMetaProperty &p) { prop = p; }
- virtual void write(const QVariant &value) { prop.write(value.toInt() + 13, QmlMetaProperty::BypassInterceptor); }
-
-private:
- QmlMetaProperty prop;
-};
-QML_DECLARE_TYPE(MyOffsetValueInterceptor);
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
deleted file mode 100644
index f99d3ce24e..0000000000
--- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp
+++ /dev/null
@@ -1,588 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QDebug>
-#include <private/qmlvaluetype_p.h>
-#include "testtypes.h"
-
-class tst_qmlvaluetypes : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlvaluetypes() {}
-
-private slots:
- void point();
- void pointf();
- void size();
- void sizef();
- void rect();
- void rectf();
- void vector3d();
- void font();
-
- void bindingAssignment();
- void bindingRead();
- void staticAssignment();
- void scriptAccess();
- void autoBindingRemoval();
- void valueSources();
- void valueInterceptors();
- void bindingConflict();
- void deletedObject();
- void bindingVariantCopy();
- void scriptVariantCopy();
- void cppClasses();
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-void tst_qmlvaluetypes::point()
-{
- {
- QmlComponent component(&engine, TEST_FILE("point_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("p_x").toInt(), 10);
- QCOMPARE(object->property("p_y").toInt(), 4);
- QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("point_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->point(), QPoint(11, 12));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::pointf()
-{
- {
- QmlComponent component(&engine, TEST_FILE("pointf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("p_x").toDouble(), 11.3);
- QCOMPARE(object->property("p_y").toDouble(), -10.9);
- QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("pointf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::size()
-{
- {
- QmlComponent component(&engine, TEST_FILE("size_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toInt(), 1912);
- QCOMPARE(object->property("s_height").toInt(), 1913);
- QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("size_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->size(), QSize(13, 88));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::sizef()
-{
- {
- QmlComponent component(&engine, TEST_FILE("sizef_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toDouble(), 0.1);
- QCOMPARE(object->property("s_height").toDouble(), 100923.2);
- QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("sizef_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::rect()
-{
- {
- QmlComponent component(&engine, TEST_FILE("rect_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("r_x").toInt(), 2);
- QCOMPARE(object->property("r_y").toInt(), 3);
- QCOMPARE(object->property("r_width").toInt(), 109);
- QCOMPARE(object->property("r_height").toInt(), 102);
- QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("rect_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::rectf()
-{
- {
- QmlComponent component(&engine, TEST_FILE("rectf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("r_x").toDouble(), 103.8);
- QCOMPARE(object->property("r_y").toDouble(), 99.2);
- QCOMPARE(object->property("r_width").toDouble(), 88.1);
- QCOMPARE(object->property("r_height").toDouble(), 77.6);
- QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("rectf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::vector3d()
-{
- {
- QmlComponent component(&engine, TEST_FILE("vector3d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
- QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("vector3d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
-
- delete object;
- }
-}
-
-void tst_qmlvaluetypes::font()
-{
- {
- QmlComponent component(&engine, TEST_FILE("font_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("f_family").toString(), object->font().family());
- QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
- QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
- QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
- QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
- QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
- QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
- QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
- QCOMPARE(object->property("f_pixelSize").toInt(), object->font().pixelSize());
- QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
- QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
- QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
-
- QCOMPARE(object->property("copy"), QVariant(object->font()));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("font_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QFont font;
- font.setFamily("Helvetica");
- font.setBold(false);
- font.setWeight(QFont::Normal);
- font.setItalic(false);
- font.setUnderline(false);
- font.setStrikeOut(false);
- font.setPointSize(15);
- font.setCapitalization(QFont::AllLowercase);
- font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
- font.setWordSpacing(11.2);
-
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->font(), font);
-
- delete object;
- }
-
- // Test pixelSize
- {
- QmlComponent component(&engine, TEST_FILE("font_write.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
-
- // Test pixelSize and pointSize
- {
- QmlComponent component(&engine, TEST_FILE("font_write.3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
-}
-
-// Test bindings can write to value types
-void tst_qmlvaluetypes::bindingAssignment()
-{
- QmlComponent component(&engine, TEST_FILE("bindingAssignment.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect().x(), 92);
-
- delete object;
-}
-
-// Test bindings can read from value types
-void tst_qmlvaluetypes::bindingRead()
-{
- QmlComponent component(&engine, TEST_FILE("bindingRead.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 2);
-
- object->setRect(QRect(19, 3, 88, 2));
-
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
-}
-
-// Test static values can assign to value types
-void tst_qmlvaluetypes::staticAssignment()
-{
- QmlComponent component(&engine, TEST_FILE("staticAssignment.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 9);
-
- delete object;
-}
-
-// Test scripts can read/write value types
-void tst_qmlvaluetypes::scriptAccess()
-{
- QmlComponent component(&engine, TEST_FILE("scriptAccess.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("valuePre").toInt(), 2);
- QCOMPARE(object->rect().x(), 19);
- QCOMPARE(object->property("valuePost").toInt(), 19);
-
- delete object;
-}
-
-// Test that assigning a constant from script removes any binding
-void tst_qmlvaluetypes::autoBindingRemoval()
-{
- {
- QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(13));
-
- QCOMPARE(object->rect().x(), 13);
-
- object->emitRunScript();
-
- QCOMPARE(object->rect().x(), 42);
-
- object->setProperty("value", QVariant(92));
-
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->rect().x(), 42);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(13));
-
- QCOMPARE(object->rect().x(), 13);
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.3.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
-
- QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
-
- QEXPECT_FAIL("", "QT-2920", Continue);
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- delete object;
- }
-
-}
-
-// Test that property value sources assign to value types
-void tst_qmlvaluetypes::valueSources()
-{
- QmlComponent component(&engine, TEST_FILE("valueSources.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 3345);
-
- delete object;
-}
-
-static void checkNoErrors(QmlComponent& component)
-{
- QList<QmlError> errors = component.errors();
- if (errors.isEmpty())
- return;
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QmlError &error = errors.at(ii);
- qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
- }
-}
-
-// Test that property value interceptors can be applied to value types
-void tst_qmlvaluetypes::valueInterceptors()
-{
- QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- checkNoErrors(component);
- QEXPECT_FAIL("", "QT-2920", Abort);
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 26);
-
- object->setProperty("value", 99);
-
- QCOMPARE(object->rect().x(), 112);
-
- delete object;
-}
-
-// Test that you can't assign a binding to the "root" value type, and a sub-property
-void tst_qmlvaluetypes::bindingConflict()
-{
- QmlComponent component(&engine, TEST_FILE("bindingConflict.qml"));
- QCOMPARE(component.isError(), true);
-}
-
-#define CPP_TEST(type, v) \
-{ \
- type *t = new type; \
- QVariant value(v); \
- t->setValue(value); \
- QCOMPARE(t->value(), value); \
- delete t; \
-}
-
-// Test that accessing a reference to a valuetype after the owning object is deleted
-// doesn't crash
-void tst_qmlvaluetypes::deletedObject()
-{
- QmlComponent component(&engine, TEST_FILE("deletedObject.qml"));
- QTest::ignoreMessage(QtDebugMsg, "Test: 2");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
- QVERIFY(dObject != 0);
- delete dObject;
-
- QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
- object->emitRunScript();
-
- delete object;
-}
-
-// Test that value types can be assigned to another value type property in a binding
-void tst_qmlvaluetypes::bindingVariantCopy()
-{
- QmlComponent component(&engine, TEST_FILE("bindingVariantCopy.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
-
- delete object;
-}
-
-// Test that value types can be assigned to another value type property in script
-void tst_qmlvaluetypes::scriptVariantCopy()
-{
- QmlComponent component(&engine, TEST_FILE("scriptVariantCopy.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
-
- delete object;
-}
-
-
-// Test that the value type classes can be used manually
-void tst_qmlvaluetypes::cppClasses()
-{
- CPP_TEST(QmlPointValueType, QPoint(19, 33));
- CPP_TEST(QmlPointFValueType, QPointF(33.6, -23));
- CPP_TEST(QmlSizeValueType, QSize(-100, 18));
- CPP_TEST(QmlSizeFValueType, QSizeF(-100.7, 18.2));
- CPP_TEST(QmlRectValueType, QRect(13, 39, 10928, 88));
- CPP_TEST(QmlRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
- CPP_TEST(QmlVector3DValueType, QVector3D(18.2, 19.7, 1002));
- CPP_TEST(QmlFontValueType, QFont("Helvetica"));
-
-}
-QTEST_MAIN(tst_qmlvaluetypes)
-
-#include "tst_qmlvaluetypes.moc"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro b/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro
deleted file mode 100644
index ed87b2aa11..0000000000
--- a/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative network
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../shared/
-HEADERS += ../shared/testhttpserver.h
-
-SOURCES += tst_qmlxmlhttprequest.cpp \
- ../shared/testhttpserver.cpp
-
-
-# Define SRCDIR equal to test's source directory
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
deleted file mode 100644
index e6755660df..0000000000
--- a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp
+++ /dev/null
@@ -1,1315 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QDebug>
-#include <QNetworkCookieJar>
-#include "testhttpserver.h"
-
-#define SERVER_PORT 14445
-
-class tst_qmlxmlhttprequest : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlxmlhttprequest() {}
-
-private slots:
- void initTestCase() {
- if (QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')) != QLatin1String("en-US")) {
- qWarning() << "Test will fail unless LANG is en_US";
- }
- }
-
- void domExceptionCodes();
- void callbackException();
- void callbackException_data();
- void staticStateValues();
- void instanceStateValues();
- void constructor();
- void defaultState();
- void open();
- void open_invalid_method();
- void open_sync();
- void open_arg_count();
- void setRequestHeader();
- void setRequestHeader_unsent();
- void setRequestHeader_illegalName_data();
- void setRequestHeader_illegalName();
- void setRequestHeader_sent();
- void setRequestHeader_args();
- void send_unsent();
- void send_alreadySent();
- void send_ignoreData();
- void send_withdata();
- void abort();
- void abort_unsent();
- void abort_opened();
- void getResponseHeader();
- void getResponseHeader_unsent();
- void getResponseHeader_sent();
- void getResponseHeader_args();
- void getAllResponseHeaders();
- void getAllResponseHeaders_unsent();
- void getAllResponseHeaders_sent();
- void getAllResponseHeaders_args();
- void status();
- void statusText();
- void responseText();
- void responseXML_invalid();
- void invalidMethodUsage();
- void redirects();
-
- // Attributes
- void document();
- void element();
- void attr();
- void text();
- void cdata();
-
- // Crashes
- // void outstanding_request_at_shutdown();
-
- // void network_errors()
- // void readyState()
-
-private:
- QmlEngine engine;
-};
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-// Test that the dom exception codes are correct
-void tst_qmlxmlhttprequest::domExceptionCodes()
-{
- QmlComponent component(&engine, TEST_FILE("domExceptionCodes.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("index_size_err").toInt(), 1);
- QCOMPARE(object->property("domstring_size_err").toInt(), 2);
- QCOMPARE(object->property("hierarchy_request_err").toInt(), 3);
- QCOMPARE(object->property("wrong_document_err").toInt(), 4);
- QCOMPARE(object->property("invalid_character_err").toInt(), 5);
- QCOMPARE(object->property("no_data_allowed_err").toInt(), 6);
- QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7);
- QCOMPARE(object->property("not_found_err").toInt(), 8);
- QCOMPARE(object->property("not_supported_err").toInt(), 9);
- QCOMPARE(object->property("inuse_attribute_err").toInt(), 10);
- QCOMPARE(object->property("invalid_state_err").toInt(), 11);
- QCOMPARE(object->property("syntax_err").toInt(), 12);
- QCOMPARE(object->property("invalid_modification_err").toInt(), 13);
- QCOMPARE(object->property("namespace_err").toInt(), 14);
- QCOMPARE(object->property("invalid_access_err").toInt(), 15);
- QCOMPARE(object->property("validation_err").toInt(), 16);
- QCOMPARE(object->property("type_mismatch_err").toInt(), 17);
-
- delete object;
-}
-
-#define TRY_WAIT(expr) \
- do { \
- for (int ii = 0; ii < 6; ++ii) { \
- if ((expr)) break; \
- QTest::qWait(50); \
- } \
- QVERIFY((expr)); \
- } while (false)
-
-
-void tst_qmlxmlhttprequest::callbackException_data()
-{
- QTest::addColumn<QString>("which");
- QTest::addColumn<int>("line");
-
- QTest::newRow("on-opened") << "1" << 15;
- QTest::newRow("on-loading") << "3" << 15;
- QTest::newRow("on-done") << "4" << 15;
-}
-
-void tst_qmlxmlhttprequest::callbackException()
-{
- // Test exception reporting for exceptions thrown at various points.
-
- QFETCH(QString, which);
- QFETCH(int, line);
-
- QString expect = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QmlComponent component(&engine, TEST_FILE("callbackException.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- object->setProperty("which", which);
- component.completeCreate();
-
- TRY_WAIT(object->property("threw").toBool() == true);
-
- delete object;
-}
-
-// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
-// ### WebKit does not do this, but it seems to fit the standard and QML better
-void tst_qmlxmlhttprequest::staticStateValues()
-{
- QmlComponent component(&engine, TEST_FILE("staticStateValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("unsent").toInt(), 0);
- QCOMPARE(object->property("opened").toInt(), 1);
- QCOMPARE(object->property("headers_received").toInt(), 2);
- QCOMPARE(object->property("loading").toInt(), 3);
- QCOMPARE(object->property("done").toInt(), 4);
-
- delete object;
-}
-
-// Test that the state value properties on instances have the correct values.
-void tst_qmlxmlhttprequest::instanceStateValues()
-{
- QmlComponent component(&engine, TEST_FILE("instanceStateValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("unsent").toInt(), 0);
- QCOMPARE(object->property("opened").toInt(), 1);
- QCOMPARE(object->property("headers_received").toInt(), 2);
- QCOMPARE(object->property("loading").toInt(), 3);
- QCOMPARE(object->property("done").toInt(), 4);
-
- delete object;
-}
-
-// Test calling constructor
-void tst_qmlxmlhttprequest::constructor()
-{
- QmlComponent component(&engine, TEST_FILE("constructor.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("calledAsConstructor").toBool(), true);
- QCOMPARE(object->property("calledAsFunction").toBool(), true);
-
- delete object;
-}
-
-// Test that all the properties are set correctly before any request is sent
-void tst_qmlxmlhttprequest::defaultState()
-{
- QmlComponent component(&engine, TEST_FILE("defaultState.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("readState").toInt(), 0);
- QCOMPARE(object->property("statusIsException").toBool(), true);
- QCOMPARE(object->property("statusTextIsException").toBool(), true);
- QCOMPARE(object->property("responseText").toString(), QString());
- QCOMPARE(object->property("responseXMLIsNull").toBool(), true);
-
- delete object;
-}
-
-// Test valid XMLHttpRequest.open() calls
-void tst_qmlxmlhttprequest::open()
-{
- // Relative url
- {
- QmlComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Absolute url
- {
- QmlComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", TEST_FILE("testdocument.html").toString());
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Absolute network url
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("open.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // User/pass
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("open_user.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- // ### Check that the username/password were sent to the server
-
- delete object;
- }
-}
-
-// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
-void tst_qmlxmlhttprequest::open_invalid_method()
-{
- QmlComponent component(&engine, TEST_FILE("open_invalid_method.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Test that calling XMLHttpRequest.open() with sync raises an exception
-void tst_qmlxmlhttprequest::open_sync()
-{
- QmlComponent component(&engine, TEST_FILE("open_sync.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Calling with incorrect arg count raises an exception
-void tst_qmlxmlhttprequest::open_arg_count()
-{
- {
- QmlComponent component(&engine, TEST_FILE("open_arg_count.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-
- {
- QmlComponent component(&engine, TEST_FILE("open_arg_count.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-}
-
-// Test valid setRequestHeader() calls
-void tst_qmlxmlhttprequest::setRequestHeader()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
- TEST_FILE("setRequestHeader.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("setRequestHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test setting headers before open() throws exception
-void tst_qmlxmlhttprequest::setRequestHeader_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::setRequestHeader_illegalName_data()
-{
- QTest::addColumn<QString>("name");
-
- QTest::newRow("Accept-Charset") << "AccePT-CHArset";
- QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding";
- QTest::newRow("Connection") << "ConnECtion";
- QTest::newRow("Content-Length") << "ContEnt-LenGth";
- QTest::newRow("Cookie") << "CookIe";
- QTest::newRow("Cookie2") << "CoOkie2";
- QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding";
- QTest::newRow("Date") << "DaTE";
- QTest::newRow("Expect") << "ExPect";
- QTest::newRow("Host") << "HoST";
- QTest::newRow("Keep-Alive") << "KEEP-aLive";
- QTest::newRow("Referer") << "ReferEr";
- QTest::newRow("TE") << "Te";
- QTest::newRow("Trailer") << "TraILEr";
- QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding";
- QTest::newRow("Upgrade") << "UpgrADe";
- QTest::newRow("User-Agent") << "uSEr-Agent";
- QTest::newRow("Via") << "vIa";
- QTest::newRow("Proxy-") << "ProXy-";
- QTest::newRow("Sec-") << "SeC-";
- QTest::newRow("Proxy-*") << "Proxy-BLAH";
- QTest::newRow("Sec-*") << "Sec-F";
-}
-
-// Tests that using illegal header names has no effect
-void tst_qmlxmlhttprequest::setRequestHeader_illegalName()
-{
- QFETCH(QString, name);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("setRequestHeader_illegalName.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("header", name);
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that attempting to set a header after a request is sent throws an exception
-void tst_qmlxmlhttprequest::setRequestHeader_sent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("setRequestHeader_sent.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("test").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qmlxmlhttprequest::setRequestHeader_args()
-{
- QmlComponent component(&engine, TEST_FILE("setRequestHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Test that calling send() in UNSENT state throws an exception
-void tst_qmlxmlhttprequest::send_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("send_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test attempting to resend a sent request throws an exception
-void tst_qmlxmlhttprequest::send_alreadySent()
-{
- QmlComponent component(&engine, TEST_FILE("send_alreadySent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that send for a GET or HEAD ignores data
-void tst_qmlxmlhttprequest::send_ignoreData()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"),
- TEST_FILE("send_ignoreData.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "GET");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_PUT.expect"),
- TEST_FILE("send_ignoreData.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "HEAD");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-}
-
-// Test that send()'ing data works
-void tst_qmlxmlhttprequest::send_withdata()
-{
- // No content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.1.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.2.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Incorrect content-type
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.3.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type - out of order
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.4.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Incorrect content-type - out of order
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.4.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.5.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // PUT
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.6.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.6.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- // Correct content-type - no charset
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_data.1.expect"),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("send_data.7.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-}
-
-// Test abort() has no effect in unsent state
-void tst_qmlxmlhttprequest::abort_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("abort_unsent.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() cancels an open (but unsent) request
-void tst_qmlxmlhttprequest::abort_opened()
-{
- QmlComponent component(&engine, TEST_FILE("abort_opened.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() aborts in progress send
-void tst_qmlxmlhttprequest::abort()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("abort.expect"),
- TEST_FILE("abort.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("abort.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("seenDone").toBool(), true);
- QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
- QCOMPARE(object->property("endStateUnsent").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::getResponseHeader()
-{
- QmlEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
-
-
- QmlComponent component(&engine, TEST_FILE("getResponseHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("headersReceivedState").toBool(), true);
- QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true);
-
- QCOMPARE(object->property("doneState").toBool(), true);
- QCOMPARE(object->property("doneNullHeader").toBool(), true);
- QCOMPARE(object->property("doneValidHeader").toBool(), true);
- QCOMPARE(object->property("doneMultiValidHeader").toBool(), true);
- QCOMPARE(object->property("doneCookieHeader").toBool(), true);
-
- delete object;
-}
-
-// Test getResponseHeader throws an exception in an invalid state
-void tst_qmlxmlhttprequest::getResponseHeader_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test getResponseHeader throws an exception in an invalid state
-void tst_qmlxmlhttprequest::getResponseHeader_sent()
-{
- QmlComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qmlxmlhttprequest::getResponseHeader_args()
-{
- QmlComponent component(&engine, TEST_FILE("getResponseHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::getAllResponseHeaders()
-{
- QmlEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("headersReceivedState").toBool(), true);
- QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
-
- QCOMPARE(object->property("doneState").toBool(), true);
- QCOMPARE(object->property("doneHeader").toBool(), true);
-
- delete object;
-}
-
-// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_qmlxmlhttprequest::getAllResponseHeaders_unsent()
-{
- QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_qmlxmlhttprequest::getAllResponseHeaders_sent()
-{
- QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qmlxmlhttprequest::getAllResponseHeaders_args()
-{
- QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qmlxmlhttprequest::status()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("status.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", 200);
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("status.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", 404);
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qmlxmlhttprequest::statusText()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("statusText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", "OK");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("statusText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", "Document not found");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qmlxmlhttprequest::responseText()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", "QML Rocks!\n");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.200.reply"),
- QUrl()));
-
- QmlComponent component(&engine, TEST_FILE("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
- TEST_FILE("status.404.reply"),
- TEST_FILE("testdocument.html")));
-
- QmlComponent component(&engine, TEST_FILE("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
-
- delete object;
- }
-}
-
-// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object
-// throws an exception
-void tst_qmlxmlhttprequest::invalidMethodUsage()
-{
- QmlComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("onreadystatechange").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QCOMPARE(object->property("open").toBool(), true);
- QCOMPARE(object->property("setRequestHeader").toBool(), true);
- QCOMPARE(object->property("send").toBool(), true);
- QCOMPARE(object->property("abort").toBool(), true);
- QCOMPARE(object->property("getResponseHeader").toBool(), true);
- QCOMPARE(object->property("getAllResponseHeaders").toBool(), true);
-
- delete object;
-}
-
-// Test that XMLHttpRequest transparently redirects
-void tst_qmlxmlhttprequest::redirects()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
- server.serveDirectory("data");
-
- QmlComponent component(&engine, TEST_FILE("redirects.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- TRY_WAIT(object->property("done").toBool() == true);
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
- server.serveDirectory("data");
-
- QmlComponent component(&engine, TEST_FILE("redirectError.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- TRY_WAIT(object->property("done").toBool() == true);
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
- server.serveDirectory("data");
-
- QmlComponent component(&engine, TEST_FILE("redirectRecur.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- for (int ii = 0; ii < 60; ++ii) {
- if (object->property("done").toBool()) break;
- QTest::qWait(50);
- }
- QVERIFY(object->property("done").toBool() == true);
-
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qmlxmlhttprequest::responseXML_invalid()
-{
- QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlNull").toBool(), true);
-
- delete object;
-}
-
-// Test the Document DOM element
-void tst_qmlxmlhttprequest::document()
-{
- QmlComponent component(&engine, TEST_FILE("document.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Element DOM element
-void tst_qmlxmlhttprequest::element()
-{
- QmlComponent component(&engine, TEST_FILE("element.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Attr DOM element
-void tst_qmlxmlhttprequest::attr()
-{
- QmlComponent component(&engine, TEST_FILE("attr.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Text DOM element
-void tst_qmlxmlhttprequest::text()
-{
- QmlComponent component(&engine, TEST_FILE("text.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the CDataSection DOM element
-void tst_qmlxmlhttprequest::cdata()
-{
- QmlComponent component(&engine, TEST_FILE("cdata.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- TRY_WAIT(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qmlxmlhttprequest)
-
-#include "tst_qmlxmlhttprequest.moc"
diff --git a/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro b/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro
deleted file mode 100644
index 8e58a329ec..0000000000
--- a/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-contains(QT_CONFIG,xmlpatterns) {
- QT += xmlpatterns
- DEFINES += QTEST_XMLPATTERNS
-}
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlxmllistmodel.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp
deleted file mode 100644
index df1931fdad..0000000000
--- a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp
+++ /dev/null
@@ -1,203 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-
-#ifdef QTEST_XMLPATTERNS
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlxmllistmodel_p.h>
-#include "../../../shared/util.h"
-
-class tst_qmlxmllistmodel : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qmlxmllistmodel() {}
-
-private slots:
- void buildModel();
- void missingFields();
- void cdata();
- void attributes();
- void roles();
- void roleErrors();
- void uniqueRoleNames();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlxmllistmodel::buildModel()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = listModel->data(3, roles);
- QVERIFY(data.count() == 4);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot"));
- QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog"));
- QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9);
- QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium"));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::missingFields()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model2.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3 << Qt::UserRole + 4;
- QHash<int, QVariant> data = listModel->data(5, roles);
- QVERIFY(data.count() == 5);
- QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String(""));
- QCOMPARE(data.value(Qt::UserRole+4).toString(), QLatin1String(""));
-
- data = listModel->data(7, roles);
- QVERIFY(data.count() == 5);
- QCOMPARE(data.value(Qt::UserRole+2).toString(), QLatin1String(""));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::cdata()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 5);
-
- QList<int> roles;
- roles << Qt::UserRole + 2;
- QHash<int, QVariant> data = listModel->data(2, roles);
- QVERIFY(data.count() == 1);
- QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::attributes()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 5);
-
- QList<int> roles;
- roles << Qt::UserRole;
- QHash<int, QVariant> data = listModel->data(2, roles);
- QVERIFY(data.count() == 1);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::roles()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles = listModel->roles();
- QCOMPARE(roles.count(), 4);
- QCOMPARE(listModel->toString(roles.at(0)), QLatin1String("name"));
- QCOMPARE(listModel->toString(roles.at(1)), QLatin1String("type"));
- QCOMPARE(listModel->toString(roles.at(2)), QLatin1String("age"));
- QCOMPARE(listModel->toString(roles.at(3)), QLatin1String("size"));
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::roleErrors()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml"));
- QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5) An XmlRole query must not start with '/'").toUtf8().constData());
- //### make sure we receive all expected warning messages.
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = listModel->data(3, roles);
- QVERIFY(data.count() == 4);
-
- //### should any of these return valid values?
- QCOMPARE(data.value(Qt::UserRole), QVariant());
- QCOMPARE(data.value(Qt::UserRole+1), QVariant());
- QCOMPARE(data.value(Qt::UserRole+2), QVariant());
-
- QEXPECT_FAIL("", "QT-2456", Continue);
- QCOMPARE(data.value(Qt::UserRole+3), QVariant());
-
- delete listModel;
-}
-
-void tst_qmlxmllistmodel::uniqueRoleNames()
-{
- QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml"));
- QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5) \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
- QmlXmlListModel *listModel = qobject_cast<QmlXmlListModel*>(component.create());
- QVERIFY(listModel != 0);
- QTRY_COMPARE(listModel->count(), 9);
-
- QList<int> roles = listModel->roles();
- QCOMPARE(roles.count(), 1);
-
- delete listModel;
-}
-
-QTEST_MAIN(tst_qmlxmllistmodel)
-
-#include "tst_qmlxmllistmodel.moc"
-
-#else
-QTEST_NOOP_MAIN
-#endif
diff --git a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
index 45947e3c40..2621d658be 100644
--- a/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
+++ b/tests/auto/declarative/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -117,7 +117,7 @@ void tst_QPacketProtocol::setMaximumPacketSize()
QByteArray b;
b.fill('a', size + 1);
out.send() << b.constData();
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(invalidPacket())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(invalidPacket())));
}
}
@@ -149,7 +149,7 @@ void tst_QPacketProtocol::send()
out.send(packet);
}
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
QPacket p = in.read();
p >> ba >> num;
@@ -178,7 +178,7 @@ void tst_QPacketProtocol::packetsAvailable()
for (int i=0; i<packetCount; i++)
out.send() << "Hello";
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
QCOMPARE(in.packetsAvailable(), qint64(packetCount));
}
@@ -198,7 +198,7 @@ void tst_QPacketProtocol::clear()
out.send() << 123;
out.send() << 456;
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
in.clear();
QVERIFY(in.read().isEmpty());
@@ -213,7 +213,7 @@ void tst_QPacketProtocol::read()
out.send() << 123;
out.send() << 456;
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
int num;
@@ -253,7 +253,7 @@ void tst_QPacketProtocol::tst_QPacket_clear()
QByteArray ba;
int num;
QPacketProtocol in(m_serverConn);
- QVERIFY(QmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
QPacket p1 = in.read();
p1 >> ba >> num;
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp
index 864bb631ec..66f04e5edf 100644
--- a/tests/auto/declarative/shared/debugutil.cpp
+++ b/tests/auto/declarative/shared/debugutil.cpp
@@ -42,14 +42,14 @@
#include <QEventLoop>
#include <QTimer>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
#include "debugutil_p.h"
#include <iostream>
-bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
+bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
@@ -60,17 +60,17 @@ bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int time
}
-QmlDebugTestData::QmlDebugTestData(QEventLoop *el)
+QDeclarativeDebugTestData::QDeclarativeDebugTestData(QEventLoop *el)
: exitCode(-1), loop(el)
{
}
-QmlDebugTestData::~QmlDebugTestData()
+QDeclarativeDebugTestData::~QDeclarativeDebugTestData()
{
qDeleteAll(items);
}
-void QmlDebugTestData::testsFinished(int code)
+void QDeclarativeDebugTestData::testsFinished(int code)
{
exitCode = code;
loop->quit();
@@ -78,56 +78,56 @@ void QmlDebugTestData::testsFinished(int code)
-QmlDebugTestService::QmlDebugTestService(const QString &s, QObject *parent)
- : QmlDebugService(s, parent), enabled(false)
+QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, QObject *parent)
+ : QDeclarativeDebugService(s, parent), enabled(false)
{
}
-void QmlDebugTestService::messageReceived(const QByteArray &ba)
+void QDeclarativeDebugTestService::messageReceived(const QByteArray &ba)
{
sendMessage(ba);
}
-void QmlDebugTestService::enabledChanged(bool e)
+void QDeclarativeDebugTestService::enabledChanged(bool e)
{
enabled = e;
emit enabledStateChanged();
}
-QmlDebugTestClient::QmlDebugTestClient(const QString &s, QmlDebugConnection *c)
- : QmlDebugClient(s, c)
+QDeclarativeDebugTestClient::QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c)
+ : QDeclarativeDebugClient(s, c)
{
}
-QByteArray QmlDebugTestClient::waitForResponse()
+QByteArray QDeclarativeDebugTestClient::waitForResponse()
{
lastMsg.clear();
- QmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
+ QDeclarativeDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
if (lastMsg.isEmpty()) {
- qWarning() << "tst_QmlDebugClient: no response from server!";
+ qWarning() << "tst_QDeclarativeDebugClient: no response from server!";
return QByteArray();
}
return lastMsg;
}
-void QmlDebugTestClient::messageReceived(const QByteArray &ba)
+void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba)
{
lastMsg = ba;
emit serverMessage(ba);
}
-tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
+tst_QDeclarativeDebug_Thread::tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory)
: m_data(data), m_factory(factory)
{
}
-void tst_QmlDebug_Thread::run()
+void tst_QDeclarativeDebug_Thread::run()
{
bool ok = false;
- QmlDebugConnection conn;
+ QDeclarativeDebugConnection conn;
conn.connectToHost("127.0.0.1", 3768);
ok = conn.waitForConnected();
Q_ASSERT(ok);
@@ -146,25 +146,25 @@ void tst_QmlDebug_Thread::run()
emit testsFinished(code);
}
-int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
+int QDeclarativeDebugTest::runTests(QDeclarativeTestFactory *factory, const QList<QByteArray> &qml)
{
qputenv("QML_DEBUG_SERVER_PORT", "3768");
QEventLoop loop;
- QmlDebugTestData data(&loop);
+ QDeclarativeDebugTestData data(&loop);
- tst_QmlDebug_Thread thread(&data, factory);
+ tst_QDeclarativeDebug_Thread thread(&data, factory);
QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
- QmlDebugService::notifyOnServerStart(&thread, "start");
+ QDeclarativeDebugService::notifyOnServerStart(&thread, "start");
- QmlEngine engine; // blocks until client connects
+ QDeclarativeEngine engine; // blocks until client connects
foreach (const QByteArray &code, qml) {
- QmlComponent c(&engine);
+ QDeclarativeComponent c(&engine);
c.setData(code, QUrl::fromLocalFile(""));
Q_ASSERT(c.isReady()); // fails if bad syntax
- data.items << qobject_cast<QmlGraphicsItem*>(c.create());
+ data.items << qobject_cast<QDeclarativeItem*>(c.create());
}
// start the test
diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h
index 6815b3c3db..c152b5a604 100644
--- a/tests/auto/declarative/shared/debugutil_p.h
+++ b/tests/auto/declarative/shared/debugutil_p.h
@@ -45,37 +45,37 @@
#include <QThread>
#include <QTest>
-#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qdeclarativeengine.h>
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-#include <private/qmlgraphicsitem_p.h>
+#include <private/qdeclarativedebugclient_p.h>
+#include <private/qdeclarativedebugservice_p.h>
+#include <private/qdeclarativeitem_p.h>
-class QmlTestFactory;
+class QDeclarativeTestFactory;
-class QmlDebugTest
+class QDeclarativeDebugTest
{
public:
static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
- static int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
+ static int runTests(QDeclarativeTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
};
-class QmlDebugTestData : public QObject
+class QDeclarativeDebugTestData : public QObject
{
Q_OBJECT
public:
- QmlDebugTestData(QEventLoop *el);
+ QDeclarativeDebugTestData(QEventLoop *el);
- ~QmlDebugTestData();
+ ~QDeclarativeDebugTestData();
- QmlDebugConnection *conn;
- QmlEngine *engine;
+ QDeclarativeDebugConnection *conn;
+ QDeclarativeEngine *engine;
int exitCode;
QEventLoop *loop;
- QList<QmlGraphicsItem *> items;
+ QList<QDeclarativeItem *> items;
signals:
void engineCreated();
@@ -84,24 +84,24 @@ public slots:
void testsFinished(int code);
private:
- friend class QmlDebugTest;
+ friend class QDeclarativeDebugTest;
};
-class QmlTestFactory
+class QDeclarativeTestFactory
{
public:
- QmlTestFactory() {}
- virtual ~QmlTestFactory() {}
+ QDeclarativeTestFactory() {}
+ virtual ~QDeclarativeTestFactory() {}
- virtual QObject *createTest(QmlDebugTestData *data) = 0;
+ virtual QObject *createTest(QDeclarativeDebugTestData *data) = 0;
};
-class QmlDebugTestService : public QmlDebugService
+class QDeclarativeDebugTestService : public QDeclarativeDebugService
{
Q_OBJECT
public:
- QmlDebugTestService(const QString &s, QObject *parent = 0);
+ QDeclarativeDebugTestService(const QString &s, QObject *parent = 0);
bool enabled;
signals:
@@ -113,11 +113,11 @@ protected:
virtual void enabledChanged(bool e);
};
-class QmlDebugTestClient : public QmlDebugClient
+class QDeclarativeDebugTestClient : public QDeclarativeDebugClient
{
Q_OBJECT
public:
- QmlDebugTestClient(const QString &s, QmlDebugConnection *c);
+ QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c);
QByteArray waitForResponse();
@@ -131,11 +131,11 @@ private:
QByteArray lastMsg;
};
-class tst_QmlDebug_Thread : public QThread
+class tst_QDeclarativeDebug_Thread : public QThread
{
Q_OBJECT
public:
- tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory);
+ tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory);
void run();
@@ -143,8 +143,8 @@ signals:
void testsFinished(int);
private:
- QmlDebugTestData *m_data;
- QmlTestFactory *m_factory;
+ QDeclarativeDebugTestData *m_data;
+ QDeclarativeTestFactory *m_factory;
};
diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp
index 238410187d..e8a5e0c9f5 100644
--- a/tests/auto/declarative/sql/tst_sql.cpp
+++ b/tests/auto/declarative/sql/tst_sql.cpp
@@ -40,10 +40,10 @@
****************************************************************************/
#include <qtest.h>
#include "../../../shared/util.h"
-#include <QtDeclarative/qmlengine.h>
-#include <QtDeclarative/qmlcomponent.h>
-#include <private/qmlgraphicstext_p.h>
-#include <private/qmlengine_p.h>
+#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
+#include <private/qdeclarativetext_p.h>
+#include <private/qdeclarativeengine_p.h>
#include <QtCore/qcryptographichash.h>
#include <QtWebKit/qwebpage.h>
#include <QtWebKit/qwebframe.h>
@@ -62,7 +62,7 @@ public:
qApp->setApplicationName("tst_sql");
qApp->setOrganizationName("Nokia");
qApp->setOrganizationDomain("nokia.com");
- engine = new QmlEngine;
+ engine = new QDeclarativeEngine;
}
~tst_sql()
@@ -85,7 +85,7 @@ private slots:
private:
QString dbDir() const;
- QmlEngine *engine;
+ QDeclarativeEngine *engine;
};
class QWebPageWithJavaScriptConsoleMessages : public QWebPage {
@@ -200,9 +200,9 @@ void tst_sql::testQml()
"Text { Script { source: \""+jsfile+"\" } text: test() }";
engine->setOfflineStoragePath(dbDir());
- QmlComponent component(engine);
+ QDeclarativeComponent component(engine);
component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports
- QmlGraphicsText *text = qobject_cast<QmlGraphicsText*>(component.create());
+ QDeclarativeText *text = qobject_cast<QDeclarativeText*>(component.create());
QVERIFY(text != 0);
QCOMPARE(text->text(),QString("passed"));
}
@@ -221,7 +221,7 @@ void tst_sql::testQml_cleanopen()
// making it more like the tests are running in new processes.
testQml();
- QmlEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases
+ QDeclarativeEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases
foreach (QString dbname, QSqlDatabase::connectionNames()) {
QSqlDatabase::removeDatabase(dbname);
}
diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml
index b577e45d26..cf3f9f764e 100644
--- a/tests/auto/declarative/visual/Package_Views/packageviews.qml
+++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml
@@ -64,7 +64,7 @@ Rectangle {
from: "*"; to: "*"
SequentialAnimation {
ParentAction{}
- NumberAnimation { properties: "x,y,width"; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "x,y,width"; easing.type: "InOutQuad" }
}
}
]
diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml
index 9c814eb3c2..4248d88887 100644
--- a/tests/auto/declarative/visual/animation/easing/easing.qml
+++ b/tests/auto/declarative/visual/animation/easing/easing.qml
@@ -9,127 +9,127 @@ Rectangle {
ListModel {
id: easingtypes
ListElement {
- type: "easeLinear"
+ type: "Linear"
}
ListElement {
- type: "easeInQuad"
+ type: "InQuad"
}
ListElement {
- type: "easeOutQuad"
+ type: "OutQuad"
}
ListElement {
- type: "easeInOutQuad"
+ type: "InOutQuad"
}
ListElement {
- type: "easeOutInQuad"
+ type: "OutInQuad"
}
ListElement {
- type: "easeInCubic"
+ type: "InCubic"
}
ListElement {
- type: "easeOutCubic"
+ type: "OutCubic"
}
ListElement {
- type: "easeInOutCubic"
+ type: "InOutCubic"
}
ListElement {
- type: "easeOutInCubic"
+ type: "OutInCubic"
}
ListElement {
- type: "easeInQuart"
+ type: "InQuart"
}
ListElement {
- type: "easeOutQuart"
+ type: "OutQuart"
}
ListElement {
- type: "easeInOutQuart"
+ type: "InOutQuart"
}
ListElement {
- type: "easeOutInQuart"
+ type: "OutInQuart"
}
ListElement {
- type: "easeInQuint"
+ type: "InQuint"
}
ListElement {
- type: "easeOutQuint"
+ type: "OutQuint"
}
ListElement {
- type: "easeInOutQuint"
+ type: "InOutQuint"
}
ListElement {
- type: "easeOutInQuint"
+ type: "OutInQuint"
}
ListElement {
- type: "easeInSine"
+ type: "InSine"
}
ListElement {
- type: "easeOutSine"
+ type: "OutSine"
}
ListElement {
- type: "easeInOutSine"
+ type: "InOutSine"
}
ListElement {
- type: "easeOutInSine"
+ type: "OutInSine"
}
ListElement {
- type: "easeInExpo"
+ type: "InExpo"
}
ListElement {
- type: "easeOutExpo"
+ type: "OutExpo"
}
ListElement {
- type: "easeInOutExpo"
+ type: "InOutExpo"
}
ListElement {
- type: "easeOutInExpo"
+ type: "OutInExpo"
}
ListElement {
- type: "easeInCirc"
+ type: "InCirc"
}
ListElement {
- type: "easeOutCirc"
+ type: "OutCirc"
}
ListElement {
- type: "easeInOutCirc"
+ type: "InOutCirc"
}
ListElement {
- type: "easeOutInCirc"
+ type: "OutInCirc"
}
ListElement {
- type: "easeInElastic"
+ type: "InElastic"
}
ListElement {
- type: "easeOutElastic"
+ type: "OutElastic"
}
ListElement {
- type: "easeInOutElastic"
+ type: "InOutElastic"
}
ListElement {
- type: "easeOutInElastic"
+ type: "OutInElastic"
}
ListElement {
- type: "easeInBack"
+ type: "InBack"
}
ListElement {
- type: "easeOutBack"
+ type: "OutBack"
}
ListElement {
- type: "easeInOutBack"
+ type: "InOutBack"
}
ListElement {
- type: "easeOutInBack"
+ type: "OutInBack"
}
ListElement {
- type: "easeOutBounce"
+ type: "OutBounce"
}
ListElement {
- type: "easeInBounce"
+ type: "InBounce"
}
ListElement {
- type: "easeInOutBounce"
+ type: "InOutBounce"
}
ListElement {
- type: "easeOutInBounce"
+ type: "OutInBounce"
}
}
]
@@ -177,7 +177,7 @@ Rectangle {
reversible: true
NumberAnimation {
properties: "x"
- easing: type
+ easing.type: type
duration: 1000
}
}
diff --git a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml
index f2e065d470..24ca76becb 100644
--- a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml
+++ b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml
@@ -14,11 +14,11 @@ Rectangle {
repeat: true
NumberAnimation {
to: 0; duration: 500
- easing: "easeInOutQuad"
+ easing.type: "InOutQuad"
}
NumberAnimation {
to: 200-img.height
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
duration: 2000
}
PauseAnimation {
diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
index 593f495a8e..e18e77030b 100644
--- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
+++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml
@@ -28,7 +28,7 @@ Rectangle {
SequentialAnimation {
ColorAnimation {}
PropertyAction { properties: "x" }
- NumberAnimation { properties: "y"; easing: "InOutQuad" }
+ NumberAnimation { properties: "y"; easing.type: "InOutQuad" }
}
}
}
diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
index 30d587a529..ef4ed76285 100644
--- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
+++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml
@@ -27,9 +27,9 @@ Rectangle {
transitions: Transition {
SequentialAnimation {
- NumberAnimation { properties: "x"; easing: "InOutQuad" }
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad" }
ScriptAction { stateChangeScriptName: "setColor" }
- NumberAnimation { properties: "y"; easing: "InOutQuad" }
+ NumberAnimation { properties: "y"; easing.type: "InOutQuad" }
}
}
}
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated-smooth.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/animated-smooth.qml
index 0ceaf49e6a..0ceaf49e6a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated-smooth.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/animated-smooth.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/animated.qml
index 29c02b3d56..29c02b3d56 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/animated.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/animated.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/borders.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/borders.qml
index 98794165f2..98794165f2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/borders.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/borders.qml
diff --git a/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml
new file mode 100644
index 0000000000..e268ce7490
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/MyBorderImage.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Item {
+ property alias horizontalMode: image.horizontalTileMode
+ property alias verticalMode: image.verticalTileMode
+ property alias source: image.source
+ property alias antialiased: image.smooth
+
+ property int minWidth
+ property int minHeight
+ property int maxWidth
+ property int maxHeight
+ property int margin
+
+ id: container
+ width: 240; height: 240
+
+ BorderImage {
+ id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2
+
+ width: SequentialAnimation {
+ repeat: true
+ NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" }
+ }
+
+ height: SequentialAnimation {
+ repeat: true
+ NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" }
+ }
+
+ border.top: container.margin
+ border.left: container.margin
+ border.bottom: container.margin
+ border.right: container.margin
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/bw.png b/tests/auto/declarative/visual/qdeclarativeborderimage/content/bw.png
index 486eaae96e..486eaae96e 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/bw.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/bw.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-round.sci b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-round.sci
index 506f6f5f99..506f6f5f99 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-round.sci
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-round.sci
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-stretch.sci b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-stretch.sci
index e4989a723c..e4989a723c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/colors-stretch.sci
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors-stretch.sci
diff --git a/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png
new file mode 100644
index 0000000000..dfb62f3d64
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/content/colors.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.0.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.0.png
index 9a6b079fdb..9a6b079fdb 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.1.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.1.png
index 1f960e5f9c..1f960e5f9c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.2.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.2.png
index 85a2729d2b..85a2729d2b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.3.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.3.png
index de6ff7c3f9..de6ff7c3f9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.4.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.4.png
index fe7d3dd1eb..fe7d3dd1eb 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.5.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.5.png
index e73bef53f3..e73bef53f3 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.6.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.6.png
index 0c75422191..0c75422191 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.qml
index 043f5e2a7a..043f5e2a7a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated-smooth.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated-smooth.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.0.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.0.png
index 99228f9908..99228f9908 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.1.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.1.png
index a2dcd00aaa..a2dcd00aaa 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.2.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.2.png
index 8a8002067c..8a8002067c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.3.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.3.png
index 02b57ef241..02b57ef241 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.4.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.4.png
index df0f6cc57c..df0f6cc57c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.5.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.5.png
index 0add64df61..0add64df61 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.6.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.6.png
index 08862076e2..08862076e2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.7.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.7.png
index bc1a7b0675..bc1a7b0675 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.7.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.qml
index 29e591a5d6..29e591a5d6 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/animated.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/animated.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.0.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.0.png
index 80cbd2628d..80cbd2628d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.1.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.1.png
index 80cbd2628d..80cbd2628d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.2.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.2.png
index 80cbd2628d..80cbd2628d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.3.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.3.png
index 80cbd2628d..80cbd2628d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.4.png b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.4.png
index 80cbd2628d..80cbd2628d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.qml b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.qml
index 16cd5e93b9..16cd5e93b9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/data/borders.qml
+++ b/tests/auto/declarative/visual/qdeclarativeborderimage/data/borders.qml
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.0.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.0.png
index 21b6afbed9..21b6afbed9 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.1.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.1.png
index bb8a02bc4c..bb8a02bc4c 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.2.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.2.png
index da60237b23..da60237b23 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.3.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.3.png
index 3e943e8819..3e943e8819 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.4.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.4.png
index 4fbaf2634c..4fbaf2634c 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.5.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.5.png
index c10d1966ab..c10d1966ab 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.6.png b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.6.png
index a672c064c4..a672c064c4 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.qml b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.qml
index 029a2fc022..029a2fc022 100644
--- a/tests/auto/declarative/visual/qmleasefollow/data/easefollow.qml
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/data/easefollow.qml
diff --git a/tests/auto/declarative/visual/qmleasefollow/easefollow.qml b/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml
index bd3270f701..bd3270f701 100644
--- a/tests/auto/declarative/visual/qmleasefollow/easefollow.qml
+++ b/tests/auto/declarative/visual/qdeclarativeeasefollow/easefollow.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.0.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.0.png
index 016902bdb0..016902bdb0 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.1.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.1.png
index a65493670f..a65493670f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.2.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.2.png
index cfd5517750..cfd5517750 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.3.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.3.png
index 016902bdb0..016902bdb0 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.qml b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.qml
index 46086f913c..46086f913c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-horizontal.qml
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-horizontal.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.0.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.0.png
index 18fef53434..18fef53434 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.1.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.1.png
index 18fef53434..18fef53434 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.10.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.10.png
index b352c68c1b..b352c68c1b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.10.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.11.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.11.png
index ce7ee68dac..ce7ee68dac 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.11.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.11.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.12.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.12.png
index d8cdacfa4c..d8cdacfa4c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.12.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.12.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.13.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.13.png
index 0c2fa7b064..0c2fa7b064 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.13.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.13.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.14.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.14.png
index e9b30282df..e9b30282df 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.14.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.14.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.15.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.15.png
index 2186a8b147..2186a8b147 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.15.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.15.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.16.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.16.png
index b4590af80b..b4590af80b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.16.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.16.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.17.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.17.png
index fe29f19702..fe29f19702 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.17.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.17.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.18.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.18.png
index fe29f19702..fe29f19702 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.18.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.18.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.19.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.19.png
index 4f8587fa9b..4f8587fa9b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.19.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.19.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.2.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.2.png
index 0a7cc039fa..0a7cc039fa 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.20.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.20.png
index 4f8587fa9b..4f8587fa9b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.20.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.20.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.21.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.21.png
index c0b0bdfae5..c0b0bdfae5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.21.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.21.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.22.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.22.png
index 4168c3b54f..4168c3b54f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.22.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.22.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.23.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.23.png
index 18fef53434..18fef53434 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.23.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.23.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.24.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.24.png
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.24.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.24.png
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.3.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.3.png
index fc6669d666..fc6669d666 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.4.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.4.png
index c0b0bdfae5..c0b0bdfae5 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.5.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.5.png
index 2ffa96e05b..2ffa96e05b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.6.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.6.png
index f550b89209..f550b89209 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.6.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.7.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.7.png
index f550b89209..f550b89209 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.7.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.8.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.8.png
index f550b89209..f550b89209 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.8.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.9.png b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.9.png
index f550b89209..f550b89209 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.9.png
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.qml
index db702983bf..db702983bf 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/data/flickable-vertical.qml
diff --git a/tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml
new file mode 100644
index 0000000000..50ba9ad962
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-horizontal.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+
+Rectangle {
+ color: "lightSteelBlue"
+ width: 600; height: 300
+
+ ListModel {
+ id: list
+ ListElement { dayColor: "steelblue" }
+ ListElement { dayColor: "blue" }
+ ListElement { dayColor: "yellow" }
+ ListElement { dayColor: "purple" }
+ ListElement { dayColor: "red" }
+ ListElement { dayColor: "green" }
+ ListElement { dayColor: "orange" }
+ }
+
+ Flickable {
+ id: flickable
+ anchors.fill: parent; contentWidth: row.width
+
+ Row {
+ id: row
+ Repeater {
+ model: list
+ Rectangle { width: 200; height: 300; color: dayColor }
+ }
+ }
+ }
+ Rectangle {
+ radius: 3
+ y: flickable.height-8
+ height: 8
+ x: flickable.visibleArea.xPosition * flickable.width
+ width: flickable.visibleArea.widthRatio * flickable.width
+ }
+}
diff --git a/tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml
new file mode 100644
index 0000000000..ebb963dc6a
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeflickable/flickable-vertical.qml
@@ -0,0 +1,91 @@
+import Qt 4.6
+
+Rectangle {
+ color: "lightSteelBlue"
+ width: 300; height: 600
+
+ ListModel {
+ id: list
+ ListElement { dayColor: "steelblue" }
+ ListElement { dayColor: "blue" }
+ ListElement { dayColor: "yellow" }
+ ListElement { dayColor: "purple" }
+ ListElement { dayColor: "red" }
+ ListElement { dayColor: "green" }
+ ListElement { dayColor: "orange" }
+ }
+
+ flickable {
+ id: flick
+ height: parent.height-50
+ width: parent.width; contentHeight: column.height
+
+ Column {
+ id: column
+ Repeater {
+ model: list
+ Rectangle { width: 300; height: 200; color: mr.pressed ? "black" : dayColor
+ MouseArea {
+ id: mr
+ anchors.fill: parent
+ }
+ }
+ }
+ }
+ clip: true
+ reportedVelocitySmoothing: 1000
+ }
+ Rectangle {
+ radius: 3
+ x: flick.width-8
+ width: 8
+ y: flick.visibleArea.yPosition * flick.height
+ height: flick.visibleArea.heightRatio * flick.height
+ }
+
+ // click to toggle interactive flag
+ Rectangle {
+ width: 64
+ height: 48
+ y: parent.height - 50
+ color: "red"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flick.interactive = flick.interactive ? false : true
+ }
+ }
+
+ // click to toggle click delay
+ Rectangle {
+ width: 64
+ height: 48
+ x: 66
+ y: parent.height - 50
+ color: "green"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flick.pressDelay = flick.pressDelay > 0 ? 0 : 500
+ }
+ }
+
+ // click to toggle overshoot
+ Rectangle {
+ width: 64
+ height: 48
+ x: 130
+ y: parent.height - 50
+ color: "yellow"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flick.overShoot = flick.overShoot > 0 ? 0 : 30
+ }
+ }
+
+ Rectangle {
+ width: Math.abs(flick.verticalVelocity)/100
+ height: 50
+ x: 200
+ y: parent.height - 50
+ color: blue
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.0.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.0.png
index 53a8b42a00..53a8b42a00 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.1.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.1.png
index b7efe8c3e2..b7efe8c3e2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.2.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.2.png
index aa6d14771a..aa6d14771a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.3.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.3.png
index 9d3971335e..9d3971335e 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.3.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.4.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.4.png
index 98e8817699..98e8817699 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.4.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.5.png b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.5.png
index a3f9d8f45b..a3f9d8f45b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.5.png
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.qml b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.qml
index 520d9a26db..520d9a26db 100644
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/data/test-flipable.qml
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/data/test-flipable.qml
diff --git a/tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml b/tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml
new file mode 100644
index 0000000000..a27aa6e9f8
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativeflipable/test-flipable.qml
@@ -0,0 +1,79 @@
+import Qt 4.6
+
+Rectangle {
+ width: 400; height: 240
+ color: "white"
+
+ Timer {
+ interval: 3000; running: true; repeat: true; triggeredOnStart: true
+ onTriggered: {
+ if (flipable.state == '') flipable.state = 'back'; else flipable.state = ''
+ if (flipable2.state == '') flipable2.state = 'back'; else flipable2.state = ''
+ }
+ }
+
+ Flipable {
+ id: flipable
+ width: 200; height: 200
+
+ transform: Rotation {
+ id: rotation; angle: 0
+ origin.x: 100; origin.y: 100
+ axis.x: 0; axis.y: 1; axis.z: 0
+ }
+
+ front: Rectangle {
+ color: "steelblue"; width: 200; height: 200
+ }
+
+ back: Rectangle {
+ color: "deeppink"; width: 200; height: 200
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: rotation; angle: 180 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 3000 }
+ }
+ }
+
+ Flipable {
+ id: flipable2
+ x: 200; width: 200; height: 200
+
+ transform: Rotation {
+ id: rotation2; angle: 0
+ origin.x: 100; origin.y: 100
+ axis.x: 1; axis.z: 0
+ }
+
+ front: Rectangle {
+ color: "deeppink"; width: 200; height: 200
+ }
+
+ back: Rectangle {
+ color: "steelblue"; width: 200; height: 200
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: rotation2; angle: 180 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 3000 }
+ }
+ }
+
+ Rectangle {
+ x: 25; width: 150; y: 210; height: 20; color: "black"
+ visible: flipable.side == Flipable.Front
+ }
+ Rectangle {
+ x: 225; width: 150; y: 210; height: 20; color: "black"
+ visible: flipable2.side == Flipable.Back
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.0.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.0.png
index 6c827779f1..6c827779f1 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.0.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.1.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.1.png
index 07b1f7c913..07b1f7c913 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.1.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.2.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.2.png
index f2f08c083a..f2f08c083a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.2.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.3.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.3.png
index 08649f959c..08649f959c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.3.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.4.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.4.png
index f9c2f17a6f..f9c2f17a6f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.4.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.5.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.5.png
index 52ec0bd132..52ec0bd132 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.5.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.6.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.6.png
index 3fe25befa1..3fe25befa1 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.6.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.7.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.7.png
index 4cc12a60d1..4cc12a60d1 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.7.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.8.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.8.png
index 2267f2326b..2267f2326b 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.8.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.9.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.9.png
index 6c827779f1..6c827779f1 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.9.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.qml b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.qml
index c7ac52d865..c7ac52d865 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.0.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.0.png
index 3021d5831d..3021d5831d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.1.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.1.png
index baeb1a60b4..baeb1a60b4 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.10.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.10.png
index b0486e5923..b0486e5923 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.10.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.2.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.2.png
index 2d0c7314f2..2d0c7314f2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.3.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.3.png
index af9ed05a63..af9ed05a63 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.4.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.4.png
index 0b0945d88d..0b0945d88d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.4.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.5.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.5.png
index 618ae0c8c9..618ae0c8c9 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.5.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.6.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.6.png
index fc31262bbd..fc31262bbd 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.6.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.7.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.7.png
index 22291ac94a..22291ac94a 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.7.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.8.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.8.png
index 3021d5831d..3021d5831d 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.8.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.9.png b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.9.png
index 2f2f5b9b6f..2f2f5b9b6f 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.9.png
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.qml b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.qml
index fb5f1fbaaa..fb5f1fbaaa 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/data/gridview2.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/data/gridview2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview.qml b/tests/auto/declarative/visual/qdeclarativegridview/gridview.qml
index f8782a5d02..f8782a5d02 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/gridview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview2.qml b/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml
index 81d06cf280..81d06cf280 100644
--- a/tests/auto/declarative/visual/qmlgraphicsgridview/gridview2.qml
+++ b/tests/auto/declarative/visual/qdeclarativegridview/gridview2.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.0.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.0.png
index cf36d605ed..cf36d605ed 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.0.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.1.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.1.png
index 6069df845d..6069df845d 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.1.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.2.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.2.png
index b8bd5f3180..b8bd5f3180 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.2.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.3.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.3.png
index cf36d605ed..cf36d605ed 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.3.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.4.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.4.png
index 831d6b4633..831d6b4633 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.4.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.5.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.5.png
index f7079dc16e..f7079dc16e 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.5.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.6.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.6.png
index a5f4451bbf..a5f4451bbf 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.6.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.7.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.7.png
index e1261d03b0..e1261d03b0 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.7.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.8.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.8.png
index 653905e2bb..653905e2bb 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.8.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/drag.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.qml
index 5a131e9ecb..5a131e9ecb 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/drag.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/drag.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.0.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.0.png
index c249c211d6..c249c211d6 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.0.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.1.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.1.png
index a96bf1ba7e..a96bf1ba7e 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.1.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.10.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.10.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.10.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.11.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.11.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.11.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.11.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.12.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.12.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.12.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.12.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.13.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.13.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.13.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.13.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.14.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.14.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.14.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.14.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.15.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.15.png
index e797cc9322..e797cc9322 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.15.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.15.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.16.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.16.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.16.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.16.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.17.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.17.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.17.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.17.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.18.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.18.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.18.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.18.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.19.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.19.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.19.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.19.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.2.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.2.png
index a96bf1ba7e..a96bf1ba7e 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.2.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.20.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.20.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.20.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.20.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.21.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.21.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.21.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.21.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.22.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.22.png
index 7951309c4f..7951309c4f 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.22.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.22.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.3.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.3.png
index a96bf1ba7e..a96bf1ba7e 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.3.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.4.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.4.png
index 1fe365a49c..1fe365a49c 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.4.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.5.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.5.png
index 1fe365a49c..1fe365a49c 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.5.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.6.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.6.png
index 1fe365a49c..1fe365a49c 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.6.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.7.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.7.png
index 1fe365a49c..1fe365a49c 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.7.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.8.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.8.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.8.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.9.png b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.9.png
index 7420ca7f83..7420ca7f83 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.9.png
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.qml
index cc374fd0b6..cc374fd0b6 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/data/mouseregion.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/data/mouseregion.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/drag.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/drag.qml
index dbb2a24b23..dbb2a24b23 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/drag.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/drag.qml
diff --git a/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml b/tests/auto/declarative/visual/qdeclarativemouseregion/mouseregion.qml
index 3c722d02f6..3c722d02f6 100644
--- a/tests/auto/declarative/visual/qmlmouseregion/mouseregion.qml
+++ b/tests/auto/declarative/visual/qdeclarativemouseregion/mouseregion.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.0.png b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.0.png
index 7321d95c9c..7321d95c9c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.0.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.1.png b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.1.png
index 49d2a5a7c2..49d2a5a7c2 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.1.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.2.png b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.2.png
index 6fe14b717c..6fe14b717c 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.2.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.qml b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.qml
index d766dc6c4e..d766dc6c4e 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/data/particles.qml
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/data/particles.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml b/tests/auto/declarative/visual/qdeclarativeparticles/particles.qml
index 2d481c96e0..2d481c96e0 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/particles.qml
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/particles.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsparticles/star.png b/tests/auto/declarative/visual/qdeclarativeparticles/star.png
index defbde53ca..defbde53ca 100644
--- a/tests/auto/declarative/visual/qmlgraphicsparticles/star.png
+++ b/tests/auto/declarative/visual/qdeclarativeparticles/star.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.0.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.0.png
index 18c8a9e6f0..18c8a9e6f0 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.1.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.1.png
index e86acb419d..e86acb419d 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.2.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.2.png
index 17990b706a..17990b706a 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.3.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.3.png
index 18c8a9e6f0..18c8a9e6f0 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.4.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.4.png
index 18c8a9e6f0..18c8a9e6f0 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.4.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.5.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.5.png
index 8636f8f9e2..8636f8f9e2 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.5.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.6.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.6.png
index fa7c4b622f..fa7c4b622f 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.6.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.qml b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.qml
index b8ff925f79..b8ff925f79 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview-2.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview-2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.0.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.0.png
index 442ba9f1a9..442ba9f1a9 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.1.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.1.png
index a9ff20fa4e..a9ff20fa4e 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.1.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.2.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.2.png
index 157bb991eb..157bb991eb 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.2.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.3.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.3.png
index 8c49acb576..8c49acb576 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.3.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.4.png b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.4.png
index eb2bf54803..eb2bf54803 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.4.png
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.qml b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.qml
index 8cff5c6285..8cff5c6285 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/data/test-pathview.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/data/test-pathview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview-2.qml b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview-2.qml
index c6d71d588a..c6d71d588a 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview-2.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview-2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview.qml
index 0adfa0217e..0adfa0217e 100644
--- a/tests/auto/declarative/visual/qmlgraphicspathview/test-pathview.qml
+++ b/tests/auto/declarative/visual/qdeclarativepathview/test-pathview.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.0.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.0.png
index f474afecdc..f474afecdc 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.1.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.1.png
index 8b7ae74b13..8b7ae74b13 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.1.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.2.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.2.png
index 9088bb4f48..9088bb4f48 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.2.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.3.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.3.png
index 18cd4298f9..18cd4298f9 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.3.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.4.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.4.png
index 739afc17ca..739afc17ca 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.4.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.5.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.5.png
index 93f0682397..93f0682397 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.5.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.qml b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.qml
index 7091bb3fae..7091bb3fae 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/dynamic.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/dynamic.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.0.png b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.0.png
index f7018fd9d2..f7018fd9d2 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.0.png
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.qml b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.qml
index 1eb115dacb..1eb115dacb 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/data/repeater.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/data/repeater.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml b/tests/auto/declarative/visual/qdeclarativepositioners/dynamic.qml
index f45e9a4d73..f45e9a4d73 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/dynamic.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/repeater.qml b/tests/auto/declarative/visual/qdeclarativepositioners/repeater.qml
index ff603650ec..ff603650ec 100644
--- a/tests/auto/declarative/visual/qmlgraphicspositioners/repeater.qml
+++ b/tests/auto/declarative/visual/qdeclarativepositioners/repeater.qml
diff --git a/tests/auto/declarative/visual/qmlspringfollow/clock.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml
index 04bbabc39c..04bbabc39c 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/clock.qml
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/clock.qml
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/background.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/background.png
index a885950862..a885950862 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/content/background.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/background.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/center.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/center.png
index 7fbd802a44..7fbd802a44 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/center.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/center.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/clock.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/clock.png
index 462edacc0e..462edacc0e 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/clock.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/clock.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/hour.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/hour.png
index f8061a1235..f8061a1235 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/hour.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/hour.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/minute.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/minute.png
index 1297ec7c2b..1297ec7c2b 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/minute.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/minute.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/content/second.png b/tests/auto/declarative/visual/qdeclarativespringfollow/content/second.png
index 4aa9fb5e8e..4aa9fb5e8e 100755
--- a/tests/auto/declarative/visual/qmlspringfollow/content/second.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/content/second.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.0.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.0.png
index baf1d45a21..baf1d45a21 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.0.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.1.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.1.png
index 932f63f4d7..932f63f4d7 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.1.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.2.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.2.png
index a5cb437fad..a5cb437fad 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.2.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.3.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.3.png
index 62e895c730..62e895c730 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.3.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/clock.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.qml
index ffc6a5e05e..ffc6a5e05e 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/clock.qml
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/clock.qml
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.0.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.0.png
index 3f42e75259..3f42e75259 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.0.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.1.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.1.png
index d661df6745..d661df6745 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.1.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.10.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.10.png
index e8c96e174c..e8c96e174c 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.10.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.10.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.2.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.2.png
index 35bfa4382c..35bfa4382c 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.2.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.3.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.3.png
index 74141cf876..74141cf876 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.3.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.4.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.4.png
index 9544054841..9544054841 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.4.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.5.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.5.png
index 4b02c797cf..4b02c797cf 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.5.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.6.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.6.png
index 8ea83459d1..8ea83459d1 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.6.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.7.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.7.png
index 76a73e8ae5..76a73e8ae5 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.7.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.8.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.8.png
index 88249403ee..88249403ee 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.8.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.9.png b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.9.png
index f954cc58ee..f954cc58ee 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.9.png
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.9.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlspringfollow/data/follow.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.qml
index fec5428c2e..fec5428c2e 100644
--- a/tests/auto/declarative/visual/qmlspringfollow/data/follow.qml
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/data/follow.qml
diff --git a/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml
new file mode 100644
index 0000000000..62503e495f
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativespringfollow/follow.qml
@@ -0,0 +1,71 @@
+import Qt 4.6
+
+Rectangle {
+ color: "#ffffff"
+ width: 320; height: 240
+ Rectangle {
+ id: rect
+ color: "#00ff00"
+ y: 200; width: 60; height: 20
+ y: SequentialAnimation {
+ repeat: true
+ NumberAnimation {
+ to: 20; duration: 500
+ easing.type: "InOutQuad"
+ }
+ NumberAnimation {
+ to: 200; duration: 2000
+ easing.type: "OutBounce"
+ }
+ PauseAnimation { duration: 1000 }
+ }
+ }
+
+ // Velocity
+ Rectangle {
+ color: "#ff0000"
+ x: rect.width; width: rect.width; height: 20
+ y: 200
+ y: SpringFollow { source: rect.y; velocity: 200 }
+ }
+
+ // Spring
+ Rectangle {
+ color: "#ff0000"
+ x: rect.width * 2; width: rect.width/2; height: 20
+ y: 200
+ y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2 }
+ }
+ Rectangle {
+ color: "#880000"
+ x: rect.width * 2.5; width: rect.width/2; height: 20
+ y: 200
+ y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ }
+
+ // Follow mouse
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: parent
+ Rectangle {
+ id: ball
+ width: 20; height: 20
+ radius: 10
+ color: "#0000ff"
+ x: SpringFollow { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ y: SpringFollow { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ states: [
+ State {
+ name: "following"
+ when: !f1.inSync || !f2.inSync
+ PropertyChanges { target: ball; color: "#ff0000" }
+ }
+ ]
+ transitions: [
+ Transition {
+ ColorAnimation { duration: 200 }
+ }
+ ]
+ }
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml b/tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml
index 56d616e618..56d616e618 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data-X11/parentanchor.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/baseline/data-X11/parentanchor.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml b/tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml
index 56d616e618..56d616e618 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/baseline/data/parentanchor.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/baseline/data/parentanchor.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml b/tests/auto/declarative/visual/qdeclarativetext/baseline/parentanchor.qml
index 80f0f03c37..80f0f03c37 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/baseline/parentanchor.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/baseline/parentanchor.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.0.png
index eea336298b..eea336298b 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.qml
index 1ccede4378..1ccede4378 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.0.png
index 3dfade5c72..3dfade5c72 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.1.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.1.png
index 1ee2076add..1ee2076add 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.2.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.2.png
index ae680bebbe..ae680bebbe 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.3.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.3.png
index c2859bef87..c2859bef87 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.qml
index 07ad23686b..07ad23686b 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/elide2.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/elide2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.0.png
index 80549b4609..80549b4609 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.qml
index c2fd0d80df..c2fd0d80df 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-MAC/multilength.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-MAC/multilength.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.0.png
index 5631a46d3a..5631a46d3a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.qml
index cfd832e481..cfd832e481 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.0.png
index 6e2b625daa..6e2b625daa 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.qml
index 0c061962f9..0c061962f9 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data-X11/multilength.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data-X11/multilength.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.0.png
index 1a8c89b870..1a8c89b870 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.qml
index 59f17f7578..59f17f7578 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.0.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.0.png
index 3dfade5c72..3dfade5c72 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.1.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.1.png
index 1ee2076add..1ee2076add 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.2.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.2.png
index ae680bebbe..ae680bebbe 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.3.png b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.3.png
index c2859bef87..c2859bef87 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.qml
index c592f182d6..c592f182d6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/data/elide2.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/data/elide2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/elide.qml
index fa6b5dacbf..fa6b5dacbf 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/elide.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide2.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/elide2.qml
index c163e051e1..c163e051e1 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/elide2.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/elide2.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/elide/multilength.qml b/tests/auto/declarative/visual/qdeclarativetext/elide/multilength.qml
index ca41eab2a5..ca41eab2a5 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/elide/multilength.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/elide/multilength.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.0.png
index 67b497f651..67b497f651 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.qml
index ab17eb1c20..ab17eb1c20 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/plaintext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.0.png
index 63799421c3..63799421c3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.qml
index 72499b93fd..72499b93fd 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/richtext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data-MAC/richtext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.0.png
index 50d56dc814..50d56dc814 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.qml
index f4cbcbd040..f4cbcbd040 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/plaintext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/plaintext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.0.png b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.0.png
index 2910670adb..2910670adb 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.qml
index 9f396c2e99..9f396c2e99 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/data/richtext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/data/richtext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/plaintext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/plaintext.qml
index a3aa929b1f..a3aa929b1f 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/plaintext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/plaintext.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/richtext.qml b/tests/auto/declarative/visual/qdeclarativetext/font/richtext.qml
index 35aa232089..35aa232089 100644
--- a/tests/auto/declarative/visual/qmlgraphicstext/font/richtext.qml
+++ b/tests/auto/declarative/visual/qdeclarativetext/font/richtext.qml
diff --git a/tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml
new file mode 100644
index 0000000000..176a5b8ab2
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/cursorDelegate.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+ Rectangle {
+ resources: [
+ Component { id: cursorA
+ Item { id: cPage;
+ x: Behavior { NumberAnimation { } }
+ y: Behavior { NumberAnimation { } }
+ height: Behavior { NumberAnimation { duration: 200 } }
+ Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
+ Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
+ Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
+ opacity: 1
+ opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
+ NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"}
+ NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"}
+ }
+ }
+ width: 1;
+ }
+ }
+ ]
+ width: 400
+ height: 200
+ color: "white"
+ TextEdit { id: mainText
+ text: "Hello World"
+ cursorDelegate: cursorA
+ focus: true
+ font.pixelSize: 28
+ selectionColor: "lightsteelblue"
+ selectedTextColor: "deeppink"
+ color: "forestgreen"
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.0.png
index 464a578bb4..464a578bb4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.1.png
index 9beb1ca4a7..9beb1ca4a7 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.2.png
index 001be30b98..001be30b98 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.3.png
index fc3e4b3dec..fc3e4b3dec 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.4.png
index 24f43e66e4..24f43e66e4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.5.png
index 001223b5b0..001223b5b0 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.6.png
index 7126e073dd..7126e073dd 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.7.png
index f0bea88417..f0bea88417 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.8.png
index 4381b8dfb8..4381b8dfb8 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.qml
index 8ee92d78e2..8ee92d78e2 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.0.png
index cc1774fdd6..cc1774fdd6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.1.png
index 60eba1686a..60eba1686a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.2.png
index d4663f731c..d4663f731c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.3.png
index dc1bb52f08..dc1bb52f08 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.qml
index 84c16e1918..84c16e1918 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-MAC/qt-669.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-MAC/qt-669.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.0.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.1.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.2.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.3.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.4.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.5.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.6.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.qml
index 4ff00f4a8a..4ff00f4a8a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data-X11/wrap.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data-X11/wrap.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.0.png
index 555996a21a..555996a21a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.1.png
index b705bad7b0..b705bad7b0 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.2.png
index 094cd2a6ec..094cd2a6ec 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.3.png
index 9c519c715c..9c519c715c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.4.png
index 3ec77b509d..3ec77b509d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.5.png
index 579a66e5b9..579a66e5b9 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.6.png
index 9e5ac90c18..9e5ac90c18 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.7.png
index 9f3acfcc25..9f3acfcc25 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.8.png
index f27518a1bb..f27518a1bb 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.qml
index 8578d48a85..8578d48a85 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.0.png
index 95a835aaec..95a835aaec 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.1.png
index 409192c6eb..409192c6eb 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.2.png
index cd2f11213e..cd2f11213e 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.3.png
index 7191c1ef69..7191c1ef69 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.qml
index 352c890388..352c890388 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/qt-669.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/qt-669.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.0.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.0.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.1.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.1.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.2.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.2.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.3.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.3.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.4.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.4.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.5.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.5.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.6.png b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.6.png
index ec65f494b6..ec65f494b6 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.qml b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.qml
index f96daa9cf8..f96daa9cf8 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/data/wrap.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/data/wrap.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml b/tests/auto/declarative/visual/qdeclarativetextedit/qt-669.qml
index b01ddf897d..b01ddf897d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/qt-669.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/qt-669.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/wrap.qml b/tests/auto/declarative/visual/qdeclarativetextedit/wrap.qml
index f9fe025fb9..f9fe025fb9 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/wrap.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextedit/wrap.qml
diff --git a/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml
new file mode 100644
index 0000000000..6a4e7fabad
--- /dev/null
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/cursorDelegate.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+ Rectangle {
+ resources: [
+ Component { id: cursorA
+ Item { id: cPage;
+ x: Behavior { NumberAnimation { } }
+ y: Behavior { NumberAnimation { } }
+ height: Behavior { NumberAnimation { duration: 200 } }
+ Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
+ Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
+ Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
+ opacity: 1
+ opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
+ NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"}
+ NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"}
+ }
+ }
+ width: 1;
+ }
+ }
+ ]
+ width: 400
+ height: 200
+ color: "white"
+ TextInput { id: mainText
+ text: "Hello World"
+ cursorDelegate: cursorA
+ focus: true
+ font.pixelSize: 28
+ selectionColor: "lightsteelblue"
+ selectedTextColor: "deeppink"
+ color: "forestgreen"
+ anchors.centerIn: parent
+ }
+}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.0.png
index 9d0bab2705..9d0bab2705 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.1.png
index db66ff79b3..db66ff79b3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.2.png
index cbcca68d43..cbcca68d43 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.3.png
index c22196b6bf..c22196b6bf 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.4.png
index a1d051e6bd..a1d051e6bd 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.5.png
index 9289dc028a..9289dc028a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.6.png
index 7331f89f0d..7331f89f0d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.7.png
index 968bdd2d3f..968bdd2d3f 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.8.png
index 9a3436a0d4..9a3436a0d4 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.qml
index 3b664b63da..3b664b63da 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-MAC/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-MAC/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.0.png
index 2b45a061da..2b45a061da 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.1.png
index 1f5bae01c3..1f5bae01c3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.2.png
index cb2b5a4aa3..cb2b5a4aa3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.3.png
index aa24805e0c..aa24805e0c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.4.png
index aa24805e0c..aa24805e0c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.qml
index dd7b291607..dd7b291607 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/echoMode.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/echoMode.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.0.png
index 87c2e07ec3..87c2e07ec3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.qml
index e29ac569cf..e29ac569cf 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data-X11/hAlign.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data-X11/hAlign.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.0.png
index f04f65ead0..f04f65ead0 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.1.png
index 46a703a194..46a703a194 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.2.png
index e4a38774ed..e4a38774ed 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.3.png
index 9ef842ae10..9ef842ae10 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.4.png
index 706e2b390d..706e2b390d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.5.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.5.png
index bcc86cc407..bcc86cc407 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.5.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.5.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.6.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.6.png
index 51ddd44f40..51ddd44f40 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.6.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.6.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.7.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.7.png
index 0a2fddafdc..0a2fddafdc 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.7.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.7.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.8.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.8.png
index 9c88bff24d..9c88bff24d 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.8.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.8.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.qml
index df2dd3894b..df2dd3894b 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/cursorDelegate.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/cursorDelegate.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.0.png
index 2b45a061da..2b45a061da 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.1.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.1.png
index 1f5bae01c3..1f5bae01c3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.1.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.1.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.2.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.2.png
index cb2b5a4aa3..cb2b5a4aa3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.2.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.2.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.3.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.3.png
index aa24805e0c..aa24805e0c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.3.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.3.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.4.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.4.png
index aa24805e0c..aa24805e0c 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.4.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.4.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.qml
index 873a86d63a..873a86d63a 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/echoMode.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/echoMode.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.0.png b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.0.png
index 87c2e07ec3..87c2e07ec3 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.0.png
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.0.png
Binary files differ
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.qml b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.qml
index e29ac569cf..e29ac569cf 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/data/hAlign.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/data/hAlign.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/echoMode.qml b/tests/auto/declarative/visual/qdeclarativetextinput/echoMode.qml
index b0b50e4420..b0b50e4420 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/echoMode.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/echoMode.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/hAlign.qml b/tests/auto/declarative/visual/qdeclarativetextinput/hAlign.qml
index 2d65adfe53..2d65adfe53 100644
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/hAlign.qml
+++ b/tests/auto/declarative/visual/qdeclarativetextinput/hAlign.qml
diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml b/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml
deleted file mode 100644
index eb1ec0010b..0000000000
--- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import Qt 4.6
-
-Item {
- property alias horizontalMode: image.horizontalTileMode
- property alias verticalMode: image.verticalTileMode
- property alias source: image.source
- property alias antialiased: image.smooth
-
- property int minWidth
- property int minHeight
- property int maxWidth
- property int maxHeight
- property int margin
-
- id: container
- width: 240; height: 240
-
- BorderImage {
- id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2
-
- width: SequentialAnimation {
- repeat: true
- NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing: "easeInOutQuad" }
- }
-
- height: SequentialAnimation {
- repeat: true
- NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" }
- }
-
- border.top: container.margin
- border.left: container.margin
- border.bottom: container.margin
- border.right: container.margin
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml
deleted file mode 100644
index 1a7366d341..0000000000
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-horizontal.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- color: "lightSteelBlue"
- width: 600; height: 300
-
- ListModel {
- id: list
- ListElement { dayColor: "steelblue" }
- ListElement { dayColor: "blue" }
- ListElement { dayColor: "yellow" }
- ListElement { dayColor: "purple" }
- ListElement { dayColor: "red" }
- ListElement { dayColor: "green" }
- ListElement { dayColor: "orange" }
- }
-
- Flickable {
- id: flickable
- anchors.fill: parent; viewportWidth: row.width
-
- Row {
- id: row
- Repeater {
- model: list
- Rectangle { width: 200; height: 300; color: dayColor }
- }
- }
- }
- Rectangle {
- radius: 3
- y: flickable.height-8
- height: 8
- x: flickable.visibleArea.xPosition * flickable.width
- width: flickable.visibleArea.widthRatio * flickable.width
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
deleted file mode 100644
index 6204aa9185..0000000000
--- a/tests/auto/declarative/visual/qmlgraphicsflickable/flickable-vertical.qml
+++ /dev/null
@@ -1,91 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- color: "lightSteelBlue"
- width: 300; height: 600
-
- ListModel {
- id: list
- ListElement { dayColor: "steelblue" }
- ListElement { dayColor: "blue" }
- ListElement { dayColor: "yellow" }
- ListElement { dayColor: "purple" }
- ListElement { dayColor: "red" }
- ListElement { dayColor: "green" }
- ListElement { dayColor: "orange" }
- }
-
- flickable {
- id: flick
- height: parent.height-50
- width: parent.width; viewportHeight: column.height
-
- Column {
- id: column
- Repeater {
- model: list
- Rectangle { width: 300; height: 200; color: mr.pressed ? "black" : dayColor
- MouseArea {
- id: mr
- anchors.fill: parent
- }
- }
- }
- }
- clip: true
- reportedVelocitySmoothing: 1000
- }
- Rectangle {
- radius: 3
- x: flick.width-8
- width: 8
- y: flick.visibleArea.yPosition * flick.height
- height: flick.visibleArea.heightRatio * flick.height
- }
-
- // click to toggle interactive flag
- Rectangle {
- width: 64
- height: 48
- y: parent.height - 50
- color: "red"
- MouseArea {
- anchors.fill: parent
- onClicked: flick.interactive = flick.interactive ? false : true
- }
- }
-
- // click to toggle click delay
- Rectangle {
- width: 64
- height: 48
- x: 66
- y: parent.height - 50
- color: "green"
- MouseArea {
- anchors.fill: parent
- onClicked: flick.pressDelay = flick.pressDelay > 0 ? 0 : 500
- }
- }
-
- // click to toggle overshoot
- Rectangle {
- width: 64
- height: 48
- x: 130
- y: parent.height - 50
- color: "yellow"
- MouseArea {
- anchors.fill: parent
- onClicked: flick.overShoot = flick.overShoot > 0 ? 0 : 30
- }
- }
-
- Rectangle {
- width: Math.abs(flick.verticalVelocity)/100
- height: 50
- x: 200
- y: parent.height - 50
- color: blue
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
deleted file mode 100644
index c33a3190b8..0000000000
--- a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml
+++ /dev/null
@@ -1,79 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- width: 400; height: 240
- color: "white"
-
- Timer {
- interval: 3000; running: true; repeat: true; triggeredOnStart: true
- onTriggered: {
- if (flipable.state == '') flipable.state = 'back'; else flipable.state = ''
- if (flipable2.state == '') flipable2.state = 'back'; else flipable2.state = ''
- }
- }
-
- Flipable {
- id: flipable
- width: 200; height: 200
-
- transform: Rotation {
- id: rotation; angle: 0
- origin.x: 100; origin.y: 100
- axis.x: 0; axis.y: 1; axis.z: 0
- }
-
- front: Rectangle {
- color: "steelblue"; width: 200; height: 200
- }
-
- back: Rectangle {
- color: "deeppink"; width: 200; height: 200
- }
-
- states: State {
- name: "back"
- PropertyChanges { target: rotation; angle: 180 }
- }
-
- transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 }
- }
- }
-
- Flipable {
- id: flipable2
- x: 200; width: 200; height: 200
-
- transform: Rotation {
- id: rotation2; angle: 0
- origin.x: 100; origin.y: 100
- axis.x: 1; axis.z: 0
- }
-
- front: Rectangle {
- color: "deeppink"; width: 200; height: 200
- }
-
- back: Rectangle {
- color: "steelblue"; width: 200; height: 200
- }
-
- states: State {
- name: "back"
- PropertyChanges { target: rotation2; angle: 180 }
- }
-
- transitions: Transition {
- NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 }
- }
- }
-
- Rectangle {
- x: 25; width: 150; y: 210; height: 20; color: "black"
- visible: flipable.side == Flipable.Front
- }
- Rectangle {
- x: 225; width: 150; y: 210; height: 20; color: "black"
- visible: flipable2.side == Flipable.Back
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
deleted file mode 100644
index e0c5db4bbf..0000000000
--- a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml
+++ /dev/null
@@ -1,35 +0,0 @@
-import Qt 4.6
- Rectangle {
- resources: [
- Component { id: cursorA
- Item { id: cPage;
- x: Behavior { NumberAnimation { } }
- y: Behavior { NumberAnimation { } }
- height: Behavior { NumberAnimation { duration: 200 } }
- Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
- Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
- Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
- opacity: 1
- opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
- NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
- NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
- }
- }
- width: 1;
- }
- }
- ]
- width: 400
- height: 200
- color: "white"
- TextEdit { id: mainText
- text: "Hello World"
- cursorDelegate: cursorA
- focus: true
- font.pixelSize: 28
- selectionColor: "lightsteelblue"
- selectedTextColor: "deeppink"
- color: "forestgreen"
- anchors.centerIn: parent
- }
-}
diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
deleted file mode 100644
index 0038664699..0000000000
--- a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml
+++ /dev/null
@@ -1,35 +0,0 @@
-import Qt 4.6
- Rectangle {
- resources: [
- Component { id: cursorA
- Item { id: cPage;
- x: Behavior { NumberAnimation { } }
- y: Behavior { NumberAnimation { } }
- height: Behavior { NumberAnimation { duration: 200 } }
- Rectangle { id: cRectangle; color: "black"; y: 1; width: 1; height: parent.height-2;
- Rectangle { id:top; color: "black"; width: 3; height: 1; x: -1; y:0}
- Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;}
- opacity: 1
- opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true;
- NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"}
- NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"}
- }
- }
- width: 1;
- }
- }
- ]
- width: 400
- height: 200
- color: "white"
- TextInput { id: mainText
- text: "Hello World"
- cursorDelegate: cursorA
- focus: true
- font.pixelSize: 28
- selectionColor: "lightsteelblue"
- selectedTextColor: "deeppink"
- color: "forestgreen"
- anchors.centerIn: parent
- }
-}
diff --git a/tests/auto/declarative/visual/qmlspringfollow/follow.qml b/tests/auto/declarative/visual/qmlspringfollow/follow.qml
deleted file mode 100644
index a85a7789e9..0000000000
--- a/tests/auto/declarative/visual/qmlspringfollow/follow.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- color: "#ffffff"
- width: 320; height: 240
- Rectangle {
- id: rect
- color: "#00ff00"
- y: 200; width: 60; height: 20
- y: SequentialAnimation {
- repeat: true
- NumberAnimation {
- to: 20; duration: 500
- easing: "easeInOutQuad"
- }
- NumberAnimation {
- to: 200; duration: 2000
- easing: "easeOutBounce"
- }
- PauseAnimation { duration: 1000 }
- }
- }
-
- // Velocity
- Rectangle {
- color: "#ff0000"
- x: rect.width; width: rect.width; height: 20
- y: 200
- y: SpringFollow { source: rect.y; velocity: 200 }
- }
-
- // Spring
- Rectangle {
- color: "#ff0000"
- x: rect.width * 2; width: rect.width/2; height: 20
- y: 200
- y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2 }
- }
- Rectangle {
- color: "#880000"
- x: rect.width * 2.5; width: rect.width/2; height: 20
- y: 200
- y: SpringFollow { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
- }
-
- // Follow mouse
- MouseArea {
- id: mouseRegion
- anchors.fill: parent
- Rectangle {
- id: ball
- width: 20; height: 20
- radius: 10
- color: "#0000ff"
- x: SpringFollow { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- y: SpringFollow { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- states: [
- State {
- name: "following"
- when: !f1.inSync || !f2.inSync
- PropertyChanges { target: ball; color: "#ff0000" }
- }
- ]
- transitions: [
- Transition {
- ColorAnimation { duration: 200 }
- }
- ]
- }
- }
-}
diff --git a/tests/auto/declarative/visual/tst_visual.cpp b/tests/auto/declarative/visual/tst_visual.cpp
index 8f41bef58d..cd88e87058 100644
--- a/tests/auto/declarative/visual/tst_visual.cpp
+++ b/tests/auto/declarative/visual/tst_visual.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
-#include <QmlView>
+#include <QDeclarativeView>
#include <QApplication>
#include <QLibraryInfo>
#include <QDir>
@@ -65,30 +65,30 @@ private slots:
void visual();
private:
- QString qmlviewer;
+ QString qmlruntime;
};
tst_visual::tst_visual()
{
- qmlviewer = viewer();
+ qmlruntime = viewer();
}
QString tst_visual::viewer()
{
QString binaries = QLibraryInfo::location(QLibraryInfo::BinariesPath);
- QString qmlviewer;
+ QString qmlruntime;
#if defined(Q_WS_MAC)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.app/Contents/MacOS/qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml");
#elif defined(Q_WS_WIN)
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer.exe");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml.exe");
#else
- qmlviewer = QDir(binaries).absoluteFilePath("qmlviewer");
+ qmlruntime = QDir(binaries).absoluteFilePath("qml");
#endif
- return qmlviewer;
+ return qmlruntime;
}
void tst_visual::visual_data()
@@ -118,7 +118,7 @@ void tst_visual::visual()
<< "-scriptopts" << "play,testimages,testerror,exitoncomplete,exitonfailure"
<< file;
QProcess p;
- p.start(qmlviewer, arguments);
+ p.start(qmlruntime, arguments);
QVERIFY(p.waitForFinished());
if (p.exitCode() != 0)
qDebug() << p.readAllStandardError();
@@ -211,7 +211,7 @@ void action(Mode mode, const QString &file)
QStringList arguments;
switch (mode) {
case Test:
- // Don't run qmlviewer
+ // Don't run qml
break;
case Record:
arguments << "-script" << testdata
diff --git a/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp
index 6d92d03a0d..88c2ef1a0d 100644
--- a/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp
+++ b/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp
@@ -80,6 +80,7 @@ private slots:
void setSourceModel();
void submit_data();
void submit();
+ void testRoleNames();
};
// Subclass that exposes the protected functions.
@@ -362,6 +363,87 @@ void tst_QAbstractProxyModel::submit()
QCOMPARE(model.submit(), submit);
}
+class StandardItemModelWithCustomRoleNames : public QStandardItemModel
+{
+public:
+ enum CustomRole {
+ CustomRole1 = Qt::UserRole,
+ CustomRole2
+ };
+
+ StandardItemModelWithCustomRoleNames() {
+ QHash<int, QByteArray> _roleNames = roleNames();
+ _roleNames.insert(CustomRole1, "custom1");
+ _roleNames.insert(CustomRole2, "custom2");
+ setRoleNames(_roleNames);
+ }
+};
+
+class AnotherStandardItemModelWithCustomRoleNames : public QStandardItemModel
+{
+ public:
+ enum CustomRole {
+ AnotherCustomRole1 = Qt::UserRole + 10, // Different to StandardItemModelWithCustomRoleNames::CustomRole1
+ AnotherCustomRole2
+ };
+
+ AnotherStandardItemModelWithCustomRoleNames() {
+ QHash<int, QByteArray> _roleNames = roleNames();
+ _roleNames.insert(AnotherCustomRole1, "another_custom1");
+ _roleNames.insert(AnotherCustomRole2, "another_custom2");
+ setRoleNames(_roleNames);
+ }
+};
+
+/**
+ Verifies that @p subSet is a subset of @p superSet. That is, all keys in @p subSet exist in @p superSet and have the same values.
+*/
+static void verifySubSetOf(const QHash<int, QByteArray> &superSet, const QHash<int, QByteArray> &subSet)
+{
+ QHash<int, QByteArray>::const_iterator it = subSet.constBegin();
+ const QHash<int, QByteArray>::const_iterator end = subSet.constEnd();
+ for ( ; it != end; ++it ) {
+ QVERIFY(superSet.contains(it.key()));
+ QVERIFY(it.value() == superSet.value(it.key()));
+ }
+}
+
+void tst_QAbstractProxyModel::testRoleNames()
+{
+ QStandardItemModel defaultModel;
+ StandardItemModelWithCustomRoleNames model;
+ QHash<int, QByteArray> rootModelRoleNames = model.roleNames();
+ QHash<int, QByteArray> defaultModelRoleNames = defaultModel.roleNames();
+
+ verifySubSetOf( rootModelRoleNames, defaultModelRoleNames);
+ QVERIFY( rootModelRoleNames.size() == defaultModelRoleNames.size() + 2 );
+ QVERIFY( rootModelRoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole1));
+ QVERIFY( rootModelRoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole2));
+ QVERIFY( rootModelRoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole1) == "custom1" );
+ QVERIFY( rootModelRoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole2) == "custom2" );
+
+ SubQAbstractProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ QHash<int, QByteArray> proxy1RoleNames = proxy1.roleNames();
+ verifySubSetOf( proxy1RoleNames, defaultModelRoleNames );
+ QVERIFY( proxy1RoleNames.size() == defaultModelRoleNames.size() + 2 );
+ QVERIFY( proxy1RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole1));
+ QVERIFY( proxy1RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole2));
+ QVERIFY( proxy1RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole1) == "custom1" );
+ QVERIFY( proxy1RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole2) == "custom2" );
+
+ SubQAbstractProxyModel proxy2;
+ proxy2.setSourceModel(&proxy1);
+ QHash<int, QByteArray> proxy2RoleNames = proxy2.roleNames();
+ verifySubSetOf( proxy2RoleNames, defaultModelRoleNames );
+ QVERIFY( proxy2RoleNames.size() == defaultModelRoleNames.size() + 2 );
+ QVERIFY( proxy2RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole1));
+ QVERIFY( proxy2RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole2));
+ QVERIFY( proxy2RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole1) == "custom1" );
+ QVERIFY( proxy2RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole2) == "custom2" );
+
+}
+
QTEST_MAIN(tst_QAbstractProxyModel)
#include "tst_qabstractproxymodel.moc"
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index c94ea7b29d..31e12fe27f 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -162,6 +162,9 @@ private slots:
void stream_QIcon_data();
void stream_QIcon();
+ void stream_QEasingCurve_data();
+ void stream_QEasingCurve();
+
void stream_atEnd_data();
void stream_atEnd();
@@ -243,6 +246,7 @@ private:
void writeqint64(QDataStream *s);
void writeQWMatrix(QDataStream *s);
void writeQIcon(QDataStream *s);
+ void writeQEasingCurve(QDataStream *s);
void readbool(QDataStream *s);
void readQBool(QDataStream *s);
@@ -272,6 +276,7 @@ private:
void readqint64(QDataStream *s);
void readQWMatrix(QDataStream *s);
void readQIcon(QDataStream *s);
+ void readQEasingCurve(QDataStream *s);
private:
QString svgFile;
@@ -687,6 +692,70 @@ void tst_QDataStream::readHash(QDataStream *s)
// ************************************
+static QEasingCurve QEasingCurveData(int index)
+{
+ QEasingCurve easing;
+
+ switch (index) {
+ case 0:
+ default:
+ break;
+ case 1:
+ easing.setType(QEasingCurve::Linear);
+ break;
+ case 2:
+ easing.setType(QEasingCurve::OutCubic);
+ break;
+ case 3:
+ easing.setType(QEasingCurve::InOutSine);
+ break;
+ case 4:
+ easing.setType(QEasingCurve::InOutElastic);
+ easing.setPeriod(1.5);
+ easing.setAmplitude(2.0);
+ break;
+ case 5:
+ easing.setType(QEasingCurve::OutInBack);
+ break;
+ case 6:
+ easing.setType(QEasingCurve::OutCurve);
+ break;
+ case 7:
+ easing.setType(QEasingCurve::InOutBack);
+ easing.setOvershoot(0.5);
+ break;
+ }
+ return easing;
+}
+#define MAX_EASING_DATA 8
+
+void tst_QDataStream::stream_QEasingCurve_data()
+{
+ stream_data(MAX_EASING_DATA);
+}
+
+void tst_QDataStream::stream_QEasingCurve()
+{
+ STREAM_IMPL(QEasingCurve);
+}
+
+void tst_QDataStream::writeQEasingCurve(QDataStream* s)
+{
+ QEasingCurve test(QEasingCurveData(dataIndex(QTest::currentDataTag())));
+ *s << test;
+}
+
+void tst_QDataStream::readQEasingCurve(QDataStream *s)
+{
+ QEasingCurve S;
+ QEasingCurve expected(QEasingCurveData(dataIndex(QTest::currentDataTag())));
+
+ *s >> S;
+ QCOMPARE(S, expected);
+}
+
+// ************************************
+
// contains some quint64 testing as well
#define MAX_qint64_DATA 4
diff --git a/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro
new file mode 100644
index 0000000000..13bf606e0f
--- /dev/null
+++ b/tests/auto/qdeclarativeaudio/qdeclarativeaudio.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qdeclarativeaudio.cpp
+
+QT += multimedia declarative
diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
new file mode 100644
index 0000000000..11439ceeb8
--- /dev/null
+++ b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
@@ -0,0 +1,1200 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+
+#include <QtMultimedia/private/qdeclarativeaudio_p.h>
+
+#include <QtGui/qapplication.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qmetadatacontrol.h>
+
+
+class tst_QmlAudio : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullPlayerControl();
+ void nullMetaDataControl();
+ void nullService();
+
+ void source();
+ void playing();
+ void paused();
+ void duration();
+ void position();
+ void volume();
+ void muted();
+ void bufferProgress();
+ void seekable();
+ void playbackRate();
+ void status();
+ void metaData_data();
+ void metaData();
+ void error();
+};
+
+Q_DECLARE_METATYPE(QtMultimedia::MetaData);
+Q_DECLARE_METATYPE(QDeclarativeAudio::Error);
+
+class QtTestMediaPlayerControl : public QMediaPlayerControl
+{
+ Q_OBJECT
+public:
+ QtTestMediaPlayerControl(QObject *parent = 0)
+ : QMediaPlayerControl(parent)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_mediaStatus(QMediaPlayer::NoMedia)
+ , m_duration(0)
+ , m_position(0)
+ , m_playbackRate(1.0)
+ , m_volume(50)
+ , m_bufferStatus(0)
+ , m_muted(false)
+ , m_audioAvailable(false)
+ , m_videoAvailable(false)
+ , m_seekable(false)
+ {
+ }
+
+ QMediaPlayer::State state() const { return m_state; }
+ void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
+
+ QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status) {
+ emit mediaStatusChanged(m_mediaStatus = status); }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
+ {
+ m_mediaStatus = status;
+ m_state = state;
+
+ emit mediaStatusChanged(m_mediaStatus);
+ emit stateChanged(m_state);
+ }
+
+ qint64 duration() const { return m_duration; }
+ void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
+
+ qint64 position() const { return m_position; }
+ void setPosition(qint64 position) { emit positionChanged(m_position = position); }
+
+ int volume() const { return m_volume; }
+ void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
+
+ bool isMuted() const { return m_muted; }
+ void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
+
+ int bufferStatus() const { return m_bufferStatus; }
+ void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
+
+ bool isAudioAvailable() const { return m_audioAvailable; }
+ void setAudioAvailable(bool available) {
+ emit audioAvailableChanged(m_audioAvailable = available); }
+ bool isVideoAvailable() const { return m_videoAvailable; }
+ void setVideoAvailable(bool available) {
+ emit videoAvailableChanged(m_videoAvailable = available); }
+
+ bool isSeekable() const { return m_seekable; }
+ void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
+
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+
+ qreal playbackRate() const { return m_playbackRate; }
+ void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
+
+ QMediaContent media() const { return m_media; }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &media, QIODevice *)
+ {
+ m_media = media;
+
+ m_mediaStatus = m_media.isNull()
+ ? QMediaPlayer::NoMedia
+ : QMediaPlayer::LoadingMedia;
+
+ emit mediaChanged(m_media);
+ emit mediaStatusChanged(m_mediaStatus);
+ }
+
+ void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
+ void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
+ void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
+
+ void emitError(QMediaPlayer::Error err, const QString &errorString) {
+ emit error(err, errorString); }
+
+private:
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_mediaStatus;
+ qint64 m_duration;
+ qint64 m_position;
+ qreal m_playbackRate;
+ int m_volume;
+ int m_bufferStatus;
+ bool m_muted;
+ bool m_audioAvailable;
+ bool m_videoAvailable;
+ bool m_seekable;
+ QMediaContent m_media;
+};
+
+class QtTestMetaDataControl : public QMetaDataControl
+{
+ Q_OBJECT
+public:
+ QtTestMetaDataControl(QObject *parent = 0)
+ : QMetaDataControl(parent)
+ {
+ }
+
+ bool isWritable() const { return true; }
+ bool isMetaDataAvailable() const { return true; }
+
+ QVariant metaData(QtMultimedia::MetaData key) const { return m_metaData.value(key); }
+ void setMetaData(QtMultimedia::MetaData key, const QVariant &value) {
+ m_metaData.insert(key, value); emit metaDataChanged(); }
+ void setMetaData(const QMap<QtMultimedia::MetaData, QVariant> &metaData) {
+ m_metaData = metaData; emit metaDataChanged(); }
+
+ QList<QtMultimedia::MetaData> availableMetaData() const { return m_metaData.keys(); }
+
+ QVariant extendedMetaData(const QString &) const { return QVariant(); }
+ void setExtendedMetaData(const QString &, const QVariant &) {}
+ QStringList availableExtendedMetaData() const { return QStringList(); }
+
+private:
+ QMap<QtMultimedia::MetaData, QVariant> m_metaData;
+};
+
+class QtTestMediaService : public QMediaService
+{
+ Q_OBJECT
+public:
+ QtTestMediaService(
+ QtTestMediaPlayerControl *playerControl,
+ QtTestMetaDataControl *metaDataControl,
+ QObject *parent)
+ : QMediaService(parent)
+ , playerControl(playerControl)
+ , metaDataControl(metaDataControl)
+ {
+ }
+
+ QMediaControl *control(const char *name) const
+ {
+ if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
+ return playerControl;
+ else if (qstrcmp(name, QMetaDataControl_iid) == 0)
+ return metaDataControl;
+ else
+ return 0;
+ }
+
+ QtTestMediaPlayerControl *playerControl;
+ QtTestMetaDataControl *metaDataControl;
+};
+
+class QtTestMediaServiceProvider : public QMediaServiceProvider
+{
+ Q_OBJECT
+public:
+ QtTestMediaServiceProvider()
+ : service(new QtTestMediaService(
+ new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(QtTestMediaService *service)
+ : service(service)
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(
+ QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl)
+ : service(new QtTestMediaService(playerControl, metaDataControl, this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ ~QtTestMediaServiceProvider()
+ {
+ setDefaultServiceProvider(0);
+ }
+
+ QMediaService *requestService(
+ const QByteArray &type,
+ const QMediaServiceProviderHint & = QMediaServiceProviderHint())
+ {
+ requestedService = type;
+
+ return service;
+ }
+
+ void releaseService(QMediaService *) {}
+
+ inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
+ inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; }
+
+ QtTestMediaService *service;
+ QByteArray requestedService;
+};
+
+
+void tst_QmlAudio::initTestCase()
+{
+ qRegisterMetaType<QDeclarativeAudio::Error>();
+}
+
+void tst_QmlAudio::nullPlayerControl()
+{
+ QtTestMetaDataControl metaDataControl;
+ QtTestMediaServiceProvider provider(0, &metaDataControl);
+
+ QDeclarativeAudio audio;
+
+ QCOMPARE(audio.source(), QUrl());
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.source(), QUrl());
+
+ QCOMPARE(audio.isPlaying(), false);
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), false);
+ audio.play();
+ QCOMPARE(audio.isPlaying(), false);
+
+ QCOMPARE(audio.isPaused(), false);
+ audio.pause();
+ QCOMPARE(audio.isPaused(), false);
+ audio.setPaused(true);
+ QCOMPARE(audio.isPaused(), true);
+
+ QCOMPARE(audio.duration(), 0);
+
+ QCOMPARE(audio.position(), 0);
+ audio.setPosition(10000);
+ QCOMPARE(audio.position(), 0);
+
+ QCOMPARE(audio.volume(), qreal(0));
+ audio.setVolume(50);
+ QCOMPARE(audio.volume(), qreal(0));
+
+ QCOMPARE(audio.isMuted(), false);
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), false);
+
+ QCOMPARE(audio.bufferProgress(), qreal(0));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing);
+}
+
+void tst_QmlAudio::nullMetaDataControl()
+{
+ QtTestMediaPlayerControl playerControl;
+ QtTestMediaServiceProvider provider(&playerControl, 0);
+
+ QDeclarativeAudio audio;
+
+ QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlAudio::nullService()
+{
+ QtTestMediaServiceProvider provider(0);
+
+ QDeclarativeAudio audio;
+
+ QCOMPARE(audio.source(), QUrl());
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.source(), QUrl());
+
+ QCOMPARE(audio.isPlaying(), false);
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), false);
+ audio.play();
+ QCOMPARE(audio.isPlaying(), false);
+
+ QCOMPARE(audio.isPaused(), false);
+ audio.pause();
+ QCOMPARE(audio.isPaused(), false);
+ audio.setPaused(true);
+ QCOMPARE(audio.isPaused(), true);
+
+ QCOMPARE(audio.duration(), 0);
+
+ QCOMPARE(audio.position(), 0);
+ audio.setPosition(10000);
+ QCOMPARE(audio.position(), 0);
+
+ QCOMPARE(audio.volume(), qreal(0));
+ audio.setVolume(50);
+ QCOMPARE(audio.volume(), qreal(0));
+
+ QCOMPARE(audio.isMuted(), false);
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), false);
+
+ QCOMPARE(audio.bufferProgress(), qreal(0));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing);
+
+ QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlAudio::source()
+{
+ const QUrl url1("http://example.com");
+ const QUrl url2("file:///local/path");
+ const QUrl url3;
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(sourceChanged()));
+
+ audio.setSource(url1);
+ QCOMPARE(audio.source(), url1);
+ QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1);
+ QCOMPARE(spy.count(), 1);
+
+ audio.setSource(url2);
+ QCOMPARE(audio.source(), url2);
+ QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2);
+ QCOMPARE(spy.count(), 2);
+
+ audio.setSource(url3);
+ QCOMPARE(audio.source(), url3);
+ QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::playing()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
+ QSignalSpy startedSpy(&audio, SIGNAL(started()));
+ QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int started = 0;
+ int stopped = 0;
+
+ QCOMPARE(audio.isPlaying(), false);
+
+ // setPlaying(true) when stopped.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when playing.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when playing.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // stop() when stopped.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when stopped.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when playing.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when playing.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlAudio::paused()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
+ QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged()));
+ QSignalSpy startedSpy(&audio, SIGNAL(started()));
+ QSignalSpy pausedSpy(&audio, SIGNAL(paused()));
+ QSignalSpy resumedSpy(&audio, SIGNAL(resumed()));
+ QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int pausedChanged = 0;
+ int started = 0;
+ int paused = 0;
+ int resumed = 0;
+ int stopped = 0;
+
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+
+ // setPlaying(true) when stopped.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when paused.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when paused.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when paused.
+ audio.setPaused(false);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when playing.
+ audio.setPaused(false);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when playing.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped and paused.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when stopped and paused.
+ audio.setPaused(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when stopped.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when stopped and paused.
+ audio.setPlaying(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when paused.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when paused.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped.
+ audio.setPaused(true);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when stopped and paused.
+ audio.stop();
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when stopped.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // pause() when stopped and paused.
+ audio.pause();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ audio.setPlaying(false);
+ QCOMPARE(audio.isPlaying(), false);
+ QCOMPARE(audio.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped and paused.
+ audio.play();
+ QCOMPARE(audio.isPlaying(), true);
+ QCOMPARE(audio.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlAudio::duration()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(durationChanged()));
+
+ QCOMPARE(audio.duration(), 0);
+
+ provider.playerControl()->setDuration(4040);
+ QCOMPARE(audio.duration(), 4040);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setDuration(-129);
+ QCOMPARE(audio.duration(), -129);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setDuration(0);
+ QCOMPARE(audio.duration(), 0);
+ QCOMPARE(spy.count(), 3);
+
+ // Unnecessary duration changed signals aren't filtered.
+ provider.playerControl()->setDuration(0);
+ QCOMPARE(audio.duration(), 0);
+ QCOMPARE(spy.count(), 4);
+}
+
+void tst_QmlAudio::position()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(positionChanged()));
+
+ QCOMPARE(audio.position(), 0);
+
+ // QDeclarativeAudio won't bound set positions to the duration. A media service may though.
+ QCOMPARE(audio.duration(), 0);
+
+ audio.setPosition(450);
+ QCOMPARE(audio.position(), 450);
+ QCOMPARE(provider.playerControl()->position(), qint64(450));
+ QCOMPARE(spy.count(), 1);
+
+ audio.setPosition(-5403);
+ QCOMPARE(audio.position(), -5403);
+ QCOMPARE(provider.playerControl()->position(), qint64(-5403));
+ QCOMPARE(spy.count(), 2);
+
+ audio.setPosition(-5403);
+ QCOMPARE(audio.position(), -5403);
+ QCOMPARE(provider.playerControl()->position(), qint64(-5403));
+ QCOMPARE(spy.count(), 3);
+
+ // Check the signal change signal is emitted if the change originates from the media service.
+ provider.playerControl()->setPosition(0);
+ QCOMPARE(audio.position(), 0);
+ QCOMPARE(spy.count(), 4);
+
+ connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ provider.playerControl()->updateState(QMediaPlayer::PlayingState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() > 4 && spy.count() < 7); // 5 or 6
+
+ provider.playerControl()->updateState(QMediaPlayer::PausedState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() < 7);
+}
+
+void tst_QmlAudio::volume()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(volumeChanged()));
+
+ QCOMPARE(audio.volume(), qreal(0.5));
+
+ audio.setVolume(0.7);
+ QCOMPARE(audio.volume(), qreal(0.7));
+ QCOMPARE(provider.playerControl()->volume(), 70);
+ QCOMPARE(spy.count(), 1);
+
+ audio.setVolume(0.7);
+ QCOMPARE(audio.volume(), qreal(0.7));
+ QCOMPARE(provider.playerControl()->volume(), 70);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setVolume(30);
+ QCOMPARE(audio.volume(), qreal(0.3));
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::muted()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(mutedChanged()));
+
+ QCOMPARE(audio.isMuted(), false);
+
+ audio.setMuted(true);
+ QCOMPARE(audio.isMuted(), true);
+ QCOMPARE(provider.playerControl()->isMuted(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setMuted(false);
+ QCOMPARE(audio.isMuted(), false);
+ QCOMPARE(spy.count(), 2);
+
+ audio.setMuted(false);
+ QCOMPARE(audio.isMuted(), false);
+ QCOMPARE(provider.playerControl()->isMuted(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::bufferProgress()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged()));
+
+ QCOMPARE(audio.bufferProgress(), qreal(0.0));
+
+ provider.playerControl()->setBufferStatus(20);
+ QCOMPARE(audio.bufferProgress(), qreal(0.2));
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setBufferStatus(20);
+ QCOMPARE(audio.bufferProgress(), qreal(0.2));
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setBufferStatus(40);
+ QCOMPARE(audio.bufferProgress(), qreal(0.4));
+ QCOMPARE(spy.count(), 3);
+
+ connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ provider.playerControl()->updateMediaStatus(
+ QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5
+
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(spy.count() < 6);
+}
+
+void tst_QmlAudio::seekable()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(seekableChanged()));
+
+ QCOMPARE(audio.isSeekable(), false);
+
+ provider.playerControl()->setSeekable(true);
+ QCOMPARE(audio.isSeekable(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setSeekable(true);
+ QCOMPARE(audio.isSeekable(), true);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setSeekable(false);
+ QCOMPARE(audio.isSeekable(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::playbackRate()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(playbackRateChanged()));
+
+ QCOMPARE(audio.playbackRate(), qreal(1.0));
+
+ audio.setPlaybackRate(0.5);
+ QCOMPARE(audio.playbackRate(), qreal(0.5));
+ QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5));
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setPlaybackRate(2.0);
+ QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
+ QCOMPARE(spy.count(), 2);
+
+ audio.setPlaybackRate(2.0);
+ QCOMPARE(audio.playbackRate(), qreal(2.0));
+ QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlAudio::status()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged()));
+ QSignalSpy loadedSpy(&audio, SIGNAL(loaded()));
+ QSignalSpy bufferingSpy(&audio, SIGNAL(buffering()));
+ QSignalSpy stalledSpy(&audio, SIGNAL(stalled()));
+ QSignalSpy bufferedSpy(&audio, SIGNAL(buffered()));
+ QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia()));
+
+ QCOMPARE(audio.status(), QDeclarativeAudio::NoMedia);
+
+ // Set media, start loading.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Loading);
+ QCOMPARE(statusChangedSpy.count(), 1);
+ QCOMPARE(loadedSpy.count(), 0);
+ QCOMPARE(bufferingSpy.count(), 0);
+ QCOMPARE(stalledSpy.count(), 0);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Finish loading.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Loaded);
+ QCOMPARE(statusChangedSpy.count(), 2);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 0);
+ QCOMPARE(stalledSpy.count(), 0);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Play, start buffering.
+ provider.playerControl()->updateMediaStatus(
+ QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Stalled);
+ QCOMPARE(statusChangedSpy.count(), 3);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 0);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Enough data buffered to proceed.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
+ QCOMPARE(statusChangedSpy.count(), 4);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 1);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Errant second buffering status changed.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
+ QCOMPARE(statusChangedSpy.count(), 4);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 1);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 0);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Buffer full.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffered);
+ QCOMPARE(statusChangedSpy.count(), 5);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 1);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 1);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Buffer getting low.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffering);
+ QCOMPARE(statusChangedSpy.count(), 6);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 2);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 1);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Buffer full.
+ provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
+ QCOMPARE(audio.status(), QDeclarativeAudio::Buffered);
+ QCOMPARE(statusChangedSpy.count(), 7);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 2);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 2);
+ QCOMPARE(endOfMediaSpy.count(), 0);
+
+ // Finished.
+ provider.playerControl()->updateMediaStatus(
+ QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
+ QCOMPARE(audio.status(), QDeclarativeAudio::EndOfMedia);
+ QCOMPARE(statusChangedSpy.count(), 8);
+ QCOMPARE(loadedSpy.count(), 1);
+ QCOMPARE(bufferingSpy.count(), 2);
+ QCOMPARE(stalledSpy.count(), 1);
+ QCOMPARE(bufferedSpy.count(), 2);
+ QCOMPARE(endOfMediaSpy.count(), 1);
+}
+
+void tst_QmlAudio::metaData_data()
+{
+ QTest::addColumn<QByteArray>("propertyName");
+ QTest::addColumn<QtMultimedia::MetaData>("propertyKey");
+ QTest::addColumn<QVariant>("value1");
+ QTest::addColumn<QVariant>("value2");
+
+ QTest::newRow("title")
+ << QByteArray("title")
+ << QtMultimedia::Title
+ << QVariant(QString::fromLatin1("This is a title"))
+ << QVariant(QString::fromLatin1("This is another title"));
+
+ QTest::newRow("genre")
+ << QByteArray("genre")
+ << QtMultimedia::Genre
+ << QVariant(QString::fromLatin1("rock"))
+ << QVariant(QString::fromLatin1("pop"));
+
+ QTest::newRow("trackNumber")
+ << QByteArray("trackNumber")
+ << QtMultimedia::TrackNumber
+ << QVariant(8)
+ << QVariant(12);
+}
+
+void tst_QmlAudio::metaData()
+{
+ QFETCH(QByteArray, propertyName);
+ QFETCH(QtMultimedia::MetaData, propertyKey);
+ QFETCH(QVariant, value1);
+ QFETCH(QVariant, value2);
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy spy(&audio, SIGNAL(__metaDataChanged()));
+
+ const int index = audio.metaObject()->indexOfProperty(propertyName.constData());
+ QVERIFY(index != -1);
+
+ QMetaProperty property = audio.metaObject()->property(index);
+ QCOMPARE(property.read(&audio), QVariant());
+
+ property.write(&audio, value1);
+ QCOMPARE(property.read(&audio), value1);
+ QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1);
+ QCOMPARE(spy.count(), 1);
+
+ provider.metaDataControl()->setMetaData(propertyKey, value2);
+ QCOMPARE(property.read(&audio), value2);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_QmlAudio::error()
+{
+ const QString errorString = QLatin1String("Failed to open device.");
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeAudio audio;
+
+ QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString)));
+ QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged()));
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+
+ provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
+
+ QCOMPARE(audio.error(), QDeclarativeAudio::ResourceError);
+ QCOMPARE(audio.errorString(), errorString);
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 1);
+
+ // Changing the source resets the error properties.
+ audio.setSource(QUrl("http://example.com"));
+ QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+
+ // But isn't noisy.
+ audio.setSource(QUrl("file:///file/path"));
+ QCOMPARE(audio.error(), QDeclarativeAudio::NoError);
+ QCOMPARE(audio.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+}
+
+
+QTEST_MAIN(tst_QmlAudio)
+
+#include "tst_qdeclarativeaudio.moc"
diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro
new file mode 100644
index 0000000000..d946bb049d
--- /dev/null
+++ b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qdeclarativevideo.cpp
+
+QT += multimedia declarative
diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp
new file mode 100644
index 0000000000..9fc1e70255
--- /dev/null
+++ b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp
@@ -0,0 +1,911 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
+
+#include <QtMultimedia/private/qdeclarativevideo_p.h>
+
+#include <QtGui/qapplication.h>
+#include <QtMultimedia/qabstractvideosurface.h>
+#include <QtMultimedia/qgraphicsvideoitem.h>
+#include <QtMultimedia/qmediaplayercontrol.h>
+#include <QtMultimedia/qmediaservice.h>
+#include <QtMultimedia/qvideooutputcontrol.h>
+#include <QtMultimedia/qvideorenderercontrol.h>
+#include <QtMultimedia/qvideosurfaceformat.h>
+
+
+class tst_QmlGraphicsVideo : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+
+private slots:
+ void nullPlayerControl();
+ void nullService();
+
+ void playing();
+ void paused();
+ void error();
+
+ void hasAudio();
+ void hasVideo();
+ void fillMode();
+ void geometry();
+};
+
+Q_DECLARE_METATYPE(QtMultimedia::MetaData);
+Q_DECLARE_METATYPE(QDeclarativeVideo::Error);
+
+class QtTestMediaPlayerControl : public QMediaPlayerControl
+{
+ Q_OBJECT
+public:
+ QtTestMediaPlayerControl(QObject *parent = 0)
+ : QMediaPlayerControl(parent)
+ , m_state(QMediaPlayer::StoppedState)
+ , m_mediaStatus(QMediaPlayer::NoMedia)
+ , m_duration(0)
+ , m_position(0)
+ , m_playbackRate(1.0)
+ , m_volume(50)
+ , m_bufferStatus(0)
+ , m_muted(false)
+ , m_audioAvailable(false)
+ , m_videoAvailable(false)
+ , m_seekable(false)
+ {
+ }
+
+ QMediaPlayer::State state() const { return m_state; }
+ void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
+
+ QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status) {
+ emit mediaStatusChanged(m_mediaStatus = status); }
+ void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
+ {
+ m_mediaStatus = status;
+ m_state = state;
+
+ emit mediaStatusChanged(m_mediaStatus);
+ emit stateChanged(m_state);
+ }
+
+ qint64 duration() const { return m_duration; }
+ void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
+
+ qint64 position() const { return m_position; }
+ void setPosition(qint64 position) { emit positionChanged(m_position = position); }
+
+ int volume() const { return m_volume; }
+ void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
+
+ bool isMuted() const { return m_muted; }
+ void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
+
+ int bufferStatus() const { return m_bufferStatus; }
+ void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
+
+ bool isAudioAvailable() const { return m_audioAvailable; }
+ void setAudioAvailable(bool available) {
+ emit audioAvailableChanged(m_audioAvailable = available); }
+ bool isVideoAvailable() const { return m_videoAvailable; }
+ void setVideoAvailable(bool available) {
+ emit videoAvailableChanged(m_videoAvailable = available); }
+
+ bool isSeekable() const { return m_seekable; }
+ void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
+
+ QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
+
+ qreal playbackRate() const { return m_playbackRate; }
+ void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
+
+ QMediaContent media() const { return m_media; }
+ const QIODevice *mediaStream() const { return 0; }
+ void setMedia(const QMediaContent &media, QIODevice *)
+ {
+ m_media = media;
+
+ m_mediaStatus = m_media.isNull()
+ ? QMediaPlayer::NoMedia
+ : QMediaPlayer::LoadingMedia;
+
+ emit mediaChanged(m_media);
+ emit mediaStatusChanged(m_mediaStatus);
+ }
+
+ void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
+ void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
+ void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
+
+ void emitError(QMediaPlayer::Error err, const QString &errorString) {
+ emit error(err, errorString); }
+
+private:
+ QMediaPlayer::State m_state;
+ QMediaPlayer::MediaStatus m_mediaStatus;
+ qint64 m_duration;
+ qint64 m_position;
+ qreal m_playbackRate;
+ int m_volume;
+ int m_bufferStatus;
+ bool m_muted;
+ bool m_audioAvailable;
+ bool m_videoAvailable;
+ bool m_seekable;
+ QMediaContent m_media;
+};
+
+class QtTestOutputControl : public QVideoOutputControl
+{
+public:
+ QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {}
+
+ QList<Output> availableOutputs() const { return m_outputs; }
+ void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; }
+
+ Output output() const { return m_output; }
+ virtual void setOutput(Output output) { m_output = output; }
+
+private:
+ Output m_output;
+ QList<Output> m_outputs;
+};
+
+class QtTestRendererControl : public QVideoRendererControl
+{
+public:
+ QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {}
+
+ QAbstractVideoSurface *surface() const { return m_surface; }
+ void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
+
+private:
+ QAbstractVideoSurface *m_surface;
+};
+
+class QtTestMediaService : public QMediaService
+{
+ Q_OBJECT
+public:
+ QtTestMediaService(
+ QtTestMediaPlayerControl *playerControl,
+ QtTestOutputControl *outputControl,
+ QtTestRendererControl *rendererControl,
+ QObject *parent)
+ : QMediaService(parent)
+ , playerControl(playerControl)
+ , outputControl(outputControl)
+ , rendererControl(rendererControl)
+ {
+ }
+
+ QMediaControl *control(const char *name) const
+ {
+ if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
+ return playerControl;
+ else if (qstrcmp(name, QVideoOutputControl_iid) == 0)
+ return outputControl;
+ else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
+ return rendererControl;
+ else
+ return 0;
+ }
+
+ QtTestMediaPlayerControl *playerControl;
+ QtTestOutputControl *outputControl;
+ QtTestRendererControl *rendererControl;
+};
+
+class QtTestMediaServiceProvider : public QMediaServiceProvider
+{
+ Q_OBJECT
+public:
+ QtTestMediaServiceProvider()
+ : service(new QtTestMediaService(
+ new QtTestMediaPlayerControl(this),
+ new QtTestOutputControl(this),
+ new QtTestRendererControl(this),
+ this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(QtTestMediaService *service)
+ : service(service)
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ QtTestMediaServiceProvider(
+ QtTestMediaPlayerControl *playerControl,
+ QtTestOutputControl *outputControl,
+ QtTestRendererControl *rendererControl)
+ : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this))
+ {
+ setDefaultServiceProvider(this);
+ }
+
+ ~QtTestMediaServiceProvider()
+ {
+ setDefaultServiceProvider(0);
+ }
+
+ QMediaService *requestService(
+ const QByteArray &type,
+ const QMediaServiceProviderHint & = QMediaServiceProviderHint())
+ {
+ requestedService = type;
+
+ return service;
+ }
+
+ void releaseService(QMediaService *) {}
+
+ inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
+ inline QtTestRendererControl *rendererControl() { return service->rendererControl; }
+
+ QtTestMediaService *service;
+ QByteArray requestedService;
+};
+
+
+void tst_QmlGraphicsVideo::initTestCase()
+{
+ qRegisterMetaType<QDeclarativeVideo::Error>();
+}
+
+void tst_QmlGraphicsVideo::nullPlayerControl()
+{
+ QtTestMediaServiceProvider provider(0, 0, 0);
+
+ QDeclarativeVideo video;
+
+ QCOMPARE(video.source(), QUrl());
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.source(), QUrl());
+
+ QCOMPARE(video.isPlaying(), false);
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), false);
+ video.play();
+ QCOMPARE(video.isPlaying(), false);
+
+ QCOMPARE(video.isPaused(), false);
+ video.pause();
+ QCOMPARE(video.isPaused(), false);
+ video.setPaused(true);
+ QCOMPARE(video.isPaused(), true);
+
+ QCOMPARE(video.duration(), 0);
+
+ QCOMPARE(video.position(), 0);
+ video.setPosition(10000);
+ QCOMPARE(video.position(), 0);
+
+ QCOMPARE(video.volume(), qreal(0));
+ video.setVolume(50);
+ QCOMPARE(video.volume(), qreal(0));
+
+ QCOMPARE(video.isMuted(), false);
+ video.setMuted(true);
+ QCOMPARE(video.isMuted(), false);
+
+ QCOMPARE(video.bufferProgress(), qreal(0));
+
+ QCOMPARE(video.isSeekable(), false);
+
+ QCOMPARE(video.playbackRate(), qreal(1.0));
+
+ QCOMPARE(video.hasAudio(), false);
+ QCOMPARE(video.hasVideo(), false);
+
+ QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
+
+ QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
+}
+
+void tst_QmlGraphicsVideo::nullService()
+{
+ QtTestMediaServiceProvider provider(0);
+
+ QDeclarativeVideo video;
+
+ QCOMPARE(video.source(), QUrl());
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.source(), QUrl());
+
+ QCOMPARE(video.isPlaying(), false);
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), false);
+ video.play();
+ QCOMPARE(video.isPlaying(), false);
+
+ QCOMPARE(video.isPaused(), false);
+ video.pause();
+ QCOMPARE(video.isPaused(), false);
+ video.setPaused(true);
+ QCOMPARE(video.isPaused(), true);
+
+ QCOMPARE(video.duration(), 0);
+
+ QCOMPARE(video.position(), 0);
+ video.setPosition(10000);
+ QCOMPARE(video.position(), 0);
+
+ QCOMPARE(video.volume(), qreal(0));
+ video.setVolume(50);
+ QCOMPARE(video.volume(), qreal(0));
+
+ QCOMPARE(video.isMuted(), false);
+ video.setMuted(true);
+ QCOMPARE(video.isMuted(), false);
+
+ QCOMPARE(video.bufferProgress(), qreal(0));
+
+ QCOMPARE(video.isSeekable(), false);
+
+ QCOMPARE(video.playbackRate(), qreal(1.0));
+
+ QCOMPARE(video.hasAudio(), false);
+ QCOMPARE(video.hasVideo(), false);
+
+ QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
+
+ QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
+
+ QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
+ QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
+ QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
+}
+
+void tst_QmlGraphicsVideo::playing()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
+ QSignalSpy startedSpy(&video, SIGNAL(started()));
+ QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int started = 0;
+ int stopped = 0;
+
+ QCOMPARE(video.isPlaying(), false);
+
+ // setPlaying(true) when stopped.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when playing.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when playing.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // stop() when stopped.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when stopped.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when playing.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when playing.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlGraphicsVideo::paused()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
+ QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged()));
+ QSignalSpy startedSpy(&video, SIGNAL(started()));
+ QSignalSpy pausedSpy(&video, SIGNAL(paused()));
+ QSignalSpy resumedSpy(&video, SIGNAL(resumed()));
+ QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
+
+ int playingChanged = 0;
+ int pausedChanged = 0;
+ int started = 0;
+ int paused = 0;
+ int resumed = 0;
+ int stopped = 0;
+
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+
+ // setPlaying(true) when stopped.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when paused.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when paused.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when paused.
+ video.setPaused(false);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when playing.
+ video.setPaused(false);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when playing.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped and paused.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(false) when stopped and paused.
+ video.setPaused(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when stopped.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(true) when stopped and paused.
+ video.setPlaying(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // play() when paused.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), ++resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPaused(true) when playing.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when paused.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // setPaused(true) when stopped.
+ video.setPaused(true);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // stop() when stopped and paused.
+ video.stop();
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // pause() when stopped.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // pause() when stopped and paused.
+ video.pause();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), ++paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+
+ // setPlaying(false) when paused.
+ video.setPlaying(false);
+ QCOMPARE(video.isPlaying(), false);
+ QCOMPARE(video.isPaused(), true);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), pausedChanged);
+ QCOMPARE(startedSpy.count(), started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), ++stopped);
+
+ // play() when stopped and paused.
+ video.play();
+ QCOMPARE(video.isPlaying(), true);
+ QCOMPARE(video.isPaused(), false);
+ QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
+ QCOMPARE(playingChangedSpy.count(), ++playingChanged);
+ QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
+ QCOMPARE(startedSpy.count(), ++started);
+ QCOMPARE(pausedSpy.count(), paused);
+ QCOMPARE(resumedSpy.count(), resumed);
+ QCOMPARE(stoppedSpy.count(), stopped);
+}
+
+void tst_QmlGraphicsVideo::error()
+{
+ const QString errorString = QLatin1String("Failed to open device.");
+
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString)));
+ QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
+
+ QCOMPARE(video.error(), QDeclarativeVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+
+ provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
+
+ QCOMPARE(video.error(), QDeclarativeVideo::ResourceError);
+ QCOMPARE(video.errorString(), errorString);
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 1);
+
+ // Changing the source resets the error properties.
+ video.setSource(QUrl("http://example.com"));
+ QCOMPARE(video.error(), QDeclarativeVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+
+ // But isn't noisy.
+ video.setSource(QUrl("file:///file/path"));
+ QCOMPARE(video.error(), QDeclarativeVideo::NoError);
+ QCOMPARE(video.errorString(), QString());
+ QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorChangedSpy.count(), 2);
+}
+
+
+void tst_QmlGraphicsVideo::hasAudio()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy spy(&video, SIGNAL(hasAudioChanged()));
+
+ QCOMPARE(video.hasAudio(), false);
+
+ provider.playerControl()->setAudioAvailable(true);
+ QCOMPARE(video.hasAudio(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setAudioAvailable(true);
+ QCOMPARE(video.hasAudio(), true);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setAudioAvailable(false);
+ QCOMPARE(video.hasAudio(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlGraphicsVideo::hasVideo()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QSignalSpy spy(&video, SIGNAL(hasVideoChanged()));
+
+ QCOMPARE(video.hasVideo(), false);
+
+ provider.playerControl()->setVideoAvailable(true);
+ QCOMPARE(video.hasVideo(), true);
+ QCOMPARE(spy.count(), 1);
+
+ provider.playerControl()->setVideoAvailable(true);
+ QCOMPARE(video.hasVideo(), true);
+ QCOMPARE(spy.count(), 2);
+
+ provider.playerControl()->setVideoAvailable(false);
+ QCOMPARE(video.hasVideo(), false);
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_QmlGraphicsVideo::fillMode()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QList<QGraphicsItem *> children = video.childItems();
+ QCOMPARE(children.count(), 1);
+ QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
+ QVERIFY(videoItem != 0);
+
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
+
+ video.setFillMode(QDeclarativeVideo::PreserveAspectCrop);
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
+
+ video.setFillMode(QDeclarativeVideo::Stretch);
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
+
+ video.setFillMode(QDeclarativeVideo::PreserveAspectFit);
+ QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
+ QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
+}
+
+void tst_QmlGraphicsVideo::geometry()
+{
+ QtTestMediaServiceProvider provider;
+ QDeclarativeVideo video;
+
+ QAbstractVideoSurface *surface = provider.rendererControl()->surface();
+ QVERIFY(surface != 0);
+
+ QList<QGraphicsItem *> children = video.childItems();
+ QCOMPARE(children.count(), 1);
+ QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
+ QVERIFY(videoItem != 0);
+
+ QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32);
+
+ QVERIFY(surface->start(format));
+
+ QCOMPARE(video.implicitWidth(), qreal(640));
+ QCOMPARE(video.implicitHeight(), qreal(480));
+
+ video.setWidth(560);
+ video.setHeight(328);
+
+ QCOMPARE(videoItem->size().width(), qreal(560));
+ QCOMPARE(videoItem->size().height(), qreal(328));
+}
+
+QTEST_MAIN(tst_QmlGraphicsVideo)
+
+#include "tst_qdeclarativevideo.moc"
diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
index 12ddff1be9..124f900ff1 100644
--- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
@@ -69,6 +69,8 @@ private slots:
void valueForProgress();
void setCustomType();
void operators();
+ void properties();
+ void metaTypes();
protected:
};
@@ -505,6 +507,65 @@ void tst_QEasingCurve::operators()
QVERIFY(curve2 == curve);
}
+class tst_QEasingProperties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing)
+public:
+ tst_QEasingProperties(QObject *parent = 0) : QObject(parent) {}
+
+ QEasingCurve easing() const { return e; }
+ void setEasing(const QEasingCurve& value) { e = value; }
+
+private:
+ QEasingCurve e;
+};
+
+// Test getting and setting easing properties via the metaobject system.
+void tst_QEasingCurve::properties()
+{
+ tst_QEasingProperties obj;
+
+ QEasingCurve inOutBack(QEasingCurve::InOutBack);
+ qreal overshoot = 1.5f;
+ inOutBack.setOvershoot(overshoot);
+ qreal amplitude = inOutBack.amplitude();
+ qreal period = inOutBack.period();
+
+ obj.setEasing(inOutBack);
+
+ QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QCOMPARE(easing.type(), QEasingCurve::InOutBack);
+ QCOMPARE(easing.overshoot(), overshoot);
+ QCOMPARE(easing.amplitude(), amplitude);
+ QCOMPARE(easing.period(), period);
+
+ QEasingCurve linear(QEasingCurve::Linear);
+ overshoot = linear.overshoot();
+ amplitude = linear.amplitude();
+ period = linear.period();
+
+ obj.setProperty("easing",
+ qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));
+
+ easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QCOMPARE(easing.type(), QEasingCurve::Linear);
+ QCOMPARE(easing.overshoot(), overshoot);
+ QCOMPARE(easing.amplitude(), amplitude);
+ QCOMPARE(easing.period(), period);
+}
+
+void tst_QEasingCurve::metaTypes()
+{
+ QVERIFY(QMetaType::type("QEasingCurve") == QMetaType::QEasingCurve);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QEasingCurve)),
+ QByteArray("QEasingCurve"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QEasingCurve));
+
+ QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve);
+}
QTEST_MAIN(tst_QEasingCurve)
#include "tst_qeasingcurve.moc"
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 2ef0419473..d37ff768b1 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -245,6 +245,7 @@ private slots:
#endif
void render_data();
void render();
+ void renderItemsWithNegativeWidthOrHeight();
void contextMenuEvent();
void contextMenuEvent_ItemIgnoresTransformations();
void update();
@@ -2751,6 +2752,41 @@ void tst_QGraphicsScene::render()
}
}
+void tst_QGraphicsScene::renderItemsWithNegativeWidthOrHeight()
+{
+ QGraphicsScene scene(0, 0, 150, 150);
+
+ // Add item with negative width.
+ QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, -150, 50);
+ item1->setBrush(Qt::red);
+ item1->setPos(150, 50);
+ scene.addItem(item1);
+
+ // Add item with negative height.
+ QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 50, -150);
+ item2->setBrush(Qt::blue);
+ item2->setPos(50, 150);
+ scene.addItem(item2);
+
+ QGraphicsView view(&scene);
+ view.setFrameStyle(QFrame::NoFrame);
+ view.resize(150, 150);
+ view.show();
+ QCOMPARE(view.viewport()->size(), QSize(150, 150));
+
+ QImage expected(view.viewport()->size(), QImage::Format_RGB32);
+ view.viewport()->render(&expected);
+
+ // Make sure the scene background is the same as the viewport background.
+ scene.setBackgroundBrush(view.viewport()->palette().brush(view.viewport()->backgroundRole()));
+ QImage actual(150, 150, QImage::Format_RGB32);
+ QPainter painter(&actual);
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(actual, expected);
+}
+
void tst_QGraphicsScene::contextMenuEvent()
{
QGraphicsScene scene;
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 59bffeb67c..c77f76da57 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -218,6 +218,7 @@ private slots:
void update();
void inputMethodSensitivity();
void inputContextReset();
+ void indirectPainting();
// task specific tests below me
void task172231_untransformableItems();
@@ -3799,6 +3800,31 @@ void tst_QGraphicsView::inputContextReset()
QCOMPARE(inputContext.resets, 0);
}
+void tst_QGraphicsView::indirectPainting()
+{
+ class MyScene : public QGraphicsScene
+ { public:
+ MyScene() : QGraphicsScene(), drawCount(0) {}
+ void drawItems(QPainter *, int, QGraphicsItem **, const QStyleOptionGraphicsItem *, QWidget *)
+ { ++drawCount; }
+ int drawCount;
+ };
+
+ MyScene scene;
+ QGraphicsItem *item = scene.addRect(0, 0, 50, 50);
+
+ QGraphicsView view(&scene);
+ view.setOptimizationFlag(QGraphicsView::IndirectPainting);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(100);
+
+ scene.drawCount = 0;
+ item->setPos(20, 20);
+ QApplication::processEvents();
+ QTRY_VERIFY(scene.drawCount > 0);
+}
+
void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
{
QGraphicsView view;
diff --git a/tests/auto/qmlaudio/qmlaudio.pro b/tests/auto/qmlaudio/qmlaudio.pro
deleted file mode 100644
index fe18761b9a..0000000000
--- a/tests/auto/qmlaudio/qmlaudio.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_qmlaudio.cpp
-
-QT += multimedia declarative
-requires(contains(QT_CONFIG, multimedia))
-requires(contains(QT_CONFIG, declarative))
diff --git a/tests/auto/qmlaudio/tst_qmlaudio.cpp b/tests/auto/qmlaudio/tst_qmlaudio.cpp
deleted file mode 100644
index 068317fff3..0000000000
--- a/tests/auto/qmlaudio/tst_qmlaudio.cpp
+++ /dev/null
@@ -1,1200 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-
-#include <QtMultimedia/private/qmlaudio_p.h>
-
-#include <QtGui/qapplication.h>
-#include <QtMultimedia/qmediaplayercontrol.h>
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/qmetadatacontrol.h>
-
-
-class tst_QmlAudio : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullPlayerControl();
- void nullMetaDataControl();
- void nullService();
-
- void source();
- void playing();
- void paused();
- void duration();
- void position();
- void volume();
- void muted();
- void bufferProgress();
- void seekable();
- void playbackRate();
- void status();
- void metaData_data();
- void metaData();
- void error();
-};
-
-Q_DECLARE_METATYPE(QtMultimedia::MetaData);
-Q_DECLARE_METATYPE(QmlAudio::Error);
-
-class QtTestMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- QtTestMediaPlayerControl(QObject *parent = 0)
- : QMediaPlayerControl(parent)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_duration(0)
- , m_position(0)
- , m_playbackRate(1.0)
- , m_volume(50)
- , m_bufferStatus(0)
- , m_muted(false)
- , m_audioAvailable(false)
- , m_videoAvailable(false)
- , m_seekable(false)
- {
- }
-
- QMediaPlayer::State state() const { return m_state; }
- void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
-
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
- void updateMediaStatus(QMediaPlayer::MediaStatus status) {
- emit mediaStatusChanged(m_mediaStatus = status); }
- void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
- {
- m_mediaStatus = status;
- m_state = state;
-
- emit mediaStatusChanged(m_mediaStatus);
- emit stateChanged(m_state);
- }
-
- qint64 duration() const { return m_duration; }
- void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
-
- qint64 position() const { return m_position; }
- void setPosition(qint64 position) { emit positionChanged(m_position = position); }
-
- int volume() const { return m_volume; }
- void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
-
- bool isMuted() const { return m_muted; }
- void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
-
- int bufferStatus() const { return m_bufferStatus; }
- void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
-
- bool isAudioAvailable() const { return m_audioAvailable; }
- void setAudioAvailable(bool available) {
- emit audioAvailableChanged(m_audioAvailable = available); }
- bool isVideoAvailable() const { return m_videoAvailable; }
- void setVideoAvailable(bool available) {
- emit videoAvailableChanged(m_videoAvailable = available); }
-
- bool isSeekable() const { return m_seekable; }
- void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
-
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
-
- qreal playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
-
- QMediaContent media() const { return m_media; }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &media, QIODevice *)
- {
- m_media = media;
-
- m_mediaStatus = m_media.isNull()
- ? QMediaPlayer::NoMedia
- : QMediaPlayer::LoadingMedia;
-
- emit mediaChanged(m_media);
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
- void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
- void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
-
- void emitError(QMediaPlayer::Error err, const QString &errorString) {
- emit error(err, errorString); }
-
-private:
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- qint64 m_duration;
- qint64 m_position;
- qreal m_playbackRate;
- int m_volume;
- int m_bufferStatus;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
- QMediaContent m_media;
-};
-
-class QtTestMetaDataControl : public QMetaDataControl
-{
- Q_OBJECT
-public:
- QtTestMetaDataControl(QObject *parent = 0)
- : QMetaDataControl(parent)
- {
- }
-
- bool isWritable() const { return true; }
- bool isMetaDataAvailable() const { return true; }
-
- QVariant metaData(QtMultimedia::MetaData key) const { return m_metaData.value(key); }
- void setMetaData(QtMultimedia::MetaData key, const QVariant &value) {
- m_metaData.insert(key, value); emit metaDataChanged(); }
- void setMetaData(const QMap<QtMultimedia::MetaData, QVariant> &metaData) {
- m_metaData = metaData; emit metaDataChanged(); }
-
- QList<QtMultimedia::MetaData> availableMetaData() const { return m_metaData.keys(); }
-
- QVariant extendedMetaData(const QString &) const { return QVariant(); }
- void setExtendedMetaData(const QString &, const QVariant &) {}
- QStringList availableExtendedMetaData() const { return QStringList(); }
-
-private:
- QMap<QtMultimedia::MetaData, QVariant> m_metaData;
-};
-
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaService(
- QtTestMediaPlayerControl *playerControl,
- QtTestMetaDataControl *metaDataControl,
- QObject *parent)
- : QMediaService(parent)
- , playerControl(playerControl)
- , metaDataControl(metaDataControl)
- {
- }
-
- QMediaControl *control(const char *name) const
- {
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return playerControl;
- else if (qstrcmp(name, QMetaDataControl_iid) == 0)
- return metaDataControl;
- else
- return 0;
- }
-
- QtTestMediaPlayerControl *playerControl;
- QtTestMetaDataControl *metaDataControl;
-};
-
-class QtTestMediaServiceProvider : public QMediaServiceProvider
-{
- Q_OBJECT
-public:
- QtTestMediaServiceProvider()
- : service(new QtTestMediaService(
- new QtTestMediaPlayerControl(this), new QtTestMetaDataControl(this), this))
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(QtTestMediaService *service)
- : service(service)
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(
- QtTestMediaPlayerControl *playerControl, QtTestMetaDataControl *metaDataControl)
- : service(new QtTestMediaService(playerControl, metaDataControl, this))
- {
- setDefaultServiceProvider(this);
- }
-
- ~QtTestMediaServiceProvider()
- {
- setDefaultServiceProvider(0);
- }
-
- QMediaService *requestService(
- const QByteArray &type,
- const QMediaServiceProviderHint & = QMediaServiceProviderHint())
- {
- requestedService = type;
-
- return service;
- }
-
- void releaseService(QMediaService *) {}
-
- inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
- inline QtTestMetaDataControl *metaDataControl() { return service->metaDataControl; }
-
- QtTestMediaService *service;
- QByteArray requestedService;
-};
-
-
-void tst_QmlAudio::initTestCase()
-{
- qRegisterMetaType<QmlAudio::Error>();
-}
-
-void tst_QmlAudio::nullPlayerControl()
-{
- QtTestMetaDataControl metaDataControl;
- QtTestMediaServiceProvider provider(0, &metaDataControl);
-
- QmlAudio audio;
-
- QCOMPARE(audio.source(), QUrl());
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl());
-
- QCOMPARE(audio.isPlaying(), false);
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), false);
- audio.play();
- QCOMPARE(audio.isPlaying(), false);
-
- QCOMPARE(audio.isPaused(), false);
- audio.pause();
- QCOMPARE(audio.isPaused(), false);
- audio.setPaused(true);
- QCOMPARE(audio.isPaused(), true);
-
- QCOMPARE(audio.duration(), 0);
-
- QCOMPARE(audio.position(), 0);
- audio.setPosition(10000);
- QCOMPARE(audio.position(), 0);
-
- QCOMPARE(audio.volume(), qreal(0));
- audio.setVolume(50);
- QCOMPARE(audio.volume(), qreal(0));
-
- QCOMPARE(audio.isMuted(), false);
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), false);
-
- QCOMPARE(audio.bufferProgress(), qreal(0));
-
- QCOMPARE(audio.isSeekable(), false);
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- QCOMPARE(audio.status(), QmlAudio::NoMedia);
-
- QCOMPARE(audio.error(), QmlAudio::ServiceMissing);
-}
-
-void tst_QmlAudio::nullMetaDataControl()
-{
- QtTestMediaPlayerControl playerControl;
- QtTestMediaServiceProvider provider(&playerControl, 0);
-
- QmlAudio audio;
-
- QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QmlAudio::nullService()
-{
- QtTestMediaServiceProvider provider(0);
-
- QmlAudio audio;
-
- QCOMPARE(audio.source(), QUrl());
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.source(), QUrl());
-
- QCOMPARE(audio.isPlaying(), false);
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), false);
- audio.play();
- QCOMPARE(audio.isPlaying(), false);
-
- QCOMPARE(audio.isPaused(), false);
- audio.pause();
- QCOMPARE(audio.isPaused(), false);
- audio.setPaused(true);
- QCOMPARE(audio.isPaused(), true);
-
- QCOMPARE(audio.duration(), 0);
-
- QCOMPARE(audio.position(), 0);
- audio.setPosition(10000);
- QCOMPARE(audio.position(), 0);
-
- QCOMPARE(audio.volume(), qreal(0));
- audio.setVolume(50);
- QCOMPARE(audio.volume(), qreal(0));
-
- QCOMPARE(audio.isMuted(), false);
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), false);
-
- QCOMPARE(audio.bufferProgress(), qreal(0));
-
- QCOMPARE(audio.isSeekable(), false);
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- QCOMPARE(audio.status(), QmlAudio::NoMedia);
-
- QCOMPARE(audio.error(), QmlAudio::ServiceMissing);
-
- QCOMPARE(audio.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QmlAudio::source()
-{
- const QUrl url1("http://example.com");
- const QUrl url2("file:///local/path");
- const QUrl url3;
-
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(sourceChanged()));
-
- audio.setSource(url1);
- QCOMPARE(audio.source(), url1);
- QCOMPARE(provider.playerControl()->media().canonicalUrl(), url1);
- QCOMPARE(spy.count(), 1);
-
- audio.setSource(url2);
- QCOMPARE(audio.source(), url2);
- QCOMPARE(provider.playerControl()->media().canonicalUrl(), url2);
- QCOMPARE(spy.count(), 2);
-
- audio.setSource(url3);
- QCOMPARE(audio.source(), url3);
- QCOMPARE(provider.playerControl()->media().canonicalUrl(), url3);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::playing()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
- QSignalSpy startedSpy(&audio, SIGNAL(started()));
- QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int started = 0;
- int stopped = 0;
-
- QCOMPARE(audio.isPlaying(), false);
-
- // setPlaying(true) when stopped.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when playing.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when playing.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // stop() when stopped.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when stopped.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when playing.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when playing.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlAudio::paused()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy playingChangedSpy(&audio, SIGNAL(playingChanged()));
- QSignalSpy pausedChangedSpy(&audio, SIGNAL(pausedChanged()));
- QSignalSpy startedSpy(&audio, SIGNAL(started()));
- QSignalSpy pausedSpy(&audio, SIGNAL(paused()));
- QSignalSpy resumedSpy(&audio, SIGNAL(resumed()));
- QSignalSpy stoppedSpy(&audio, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int pausedChanged = 0;
- int started = 0;
- int paused = 0;
- int resumed = 0;
- int stopped = 0;
-
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
-
- // setPlaying(true) when stopped.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when paused.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when paused.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when paused.
- audio.setPaused(false);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when playing.
- audio.setPaused(false);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when playing.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped and paused.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when stopped and paused.
- audio.setPaused(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when stopped.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when stopped and paused.
- audio.setPlaying(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when paused.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when paused.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped.
- audio.setPaused(true);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when stopped and paused.
- audio.stop();
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when stopped.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // pause() when stopped and paused.
- audio.pause();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- audio.setPlaying(false);
- QCOMPARE(audio.isPlaying(), false);
- QCOMPARE(audio.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped and paused.
- audio.play();
- QCOMPARE(audio.isPlaying(), true);
- QCOMPARE(audio.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlAudio::duration()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(durationChanged()));
-
- QCOMPARE(audio.duration(), 0);
-
- provider.playerControl()->setDuration(4040);
- QCOMPARE(audio.duration(), 4040);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setDuration(-129);
- QCOMPARE(audio.duration(), -129);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setDuration(0);
- QCOMPARE(audio.duration(), 0);
- QCOMPARE(spy.count(), 3);
-
- // Unnecessary duration changed signals aren't filtered.
- provider.playerControl()->setDuration(0);
- QCOMPARE(audio.duration(), 0);
- QCOMPARE(spy.count(), 4);
-}
-
-void tst_QmlAudio::position()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(positionChanged()));
-
- QCOMPARE(audio.position(), 0);
-
- // QmlAudio won't bound set positions to the duration. A media service may though.
- QCOMPARE(audio.duration(), 0);
-
- audio.setPosition(450);
- QCOMPARE(audio.position(), 450);
- QCOMPARE(provider.playerControl()->position(), qint64(450));
- QCOMPARE(spy.count(), 1);
-
- audio.setPosition(-5403);
- QCOMPARE(audio.position(), -5403);
- QCOMPARE(provider.playerControl()->position(), qint64(-5403));
- QCOMPARE(spy.count(), 2);
-
- audio.setPosition(-5403);
- QCOMPARE(audio.position(), -5403);
- QCOMPARE(provider.playerControl()->position(), qint64(-5403));
- QCOMPARE(spy.count(), 3);
-
- // Check the signal change signal is emitted if the change originates from the media service.
- provider.playerControl()->setPosition(0);
- QCOMPARE(audio.position(), 0);
- QCOMPARE(spy.count(), 4);
-
- connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- provider.playerControl()->updateState(QMediaPlayer::PlayingState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() > 4 && spy.count() < 7); // 5 or 6
-
- provider.playerControl()->updateState(QMediaPlayer::PausedState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() < 7);
-}
-
-void tst_QmlAudio::volume()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(volumeChanged()));
-
- QCOMPARE(audio.volume(), qreal(0.5));
-
- audio.setVolume(0.7);
- QCOMPARE(audio.volume(), qreal(0.7));
- QCOMPARE(provider.playerControl()->volume(), 70);
- QCOMPARE(spy.count(), 1);
-
- audio.setVolume(0.7);
- QCOMPARE(audio.volume(), qreal(0.7));
- QCOMPARE(provider.playerControl()->volume(), 70);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setVolume(30);
- QCOMPARE(audio.volume(), qreal(0.3));
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::muted()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(mutedChanged()));
-
- QCOMPARE(audio.isMuted(), false);
-
- audio.setMuted(true);
- QCOMPARE(audio.isMuted(), true);
- QCOMPARE(provider.playerControl()->isMuted(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setMuted(false);
- QCOMPARE(audio.isMuted(), false);
- QCOMPARE(spy.count(), 2);
-
- audio.setMuted(false);
- QCOMPARE(audio.isMuted(), false);
- QCOMPARE(provider.playerControl()->isMuted(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::bufferProgress()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged()));
-
- QCOMPARE(audio.bufferProgress(), qreal(0.0));
-
- provider.playerControl()->setBufferStatus(20);
- QCOMPARE(audio.bufferProgress(), qreal(0.2));
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setBufferStatus(20);
- QCOMPARE(audio.bufferProgress(), qreal(0.2));
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setBufferStatus(40);
- QCOMPARE(audio.bufferProgress(), qreal(0.4));
- QCOMPARE(spy.count(), 3);
-
- connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop()));
-
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::BufferingMedia, QMediaPlayer::PlayingState);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5
-
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(spy.count() < 6);
-}
-
-void tst_QmlAudio::seekable()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(seekableChanged()));
-
- QCOMPARE(audio.isSeekable(), false);
-
- provider.playerControl()->setSeekable(true);
- QCOMPARE(audio.isSeekable(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setSeekable(true);
- QCOMPARE(audio.isSeekable(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setSeekable(false);
- QCOMPARE(audio.isSeekable(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::playbackRate()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(playbackRateChanged()));
-
- QCOMPARE(audio.playbackRate(), qreal(1.0));
-
- audio.setPlaybackRate(0.5);
- QCOMPARE(audio.playbackRate(), qreal(0.5));
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(0.5));
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setPlaybackRate(2.0);
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
- QCOMPARE(spy.count(), 2);
-
- audio.setPlaybackRate(2.0);
- QCOMPARE(audio.playbackRate(), qreal(2.0));
- QCOMPARE(provider.playerControl()->playbackRate(), qreal(2.0));
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlAudio::status()
-{
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged()));
- QSignalSpy loadedSpy(&audio, SIGNAL(loaded()));
- QSignalSpy bufferingSpy(&audio, SIGNAL(buffering()));
- QSignalSpy stalledSpy(&audio, SIGNAL(stalled()));
- QSignalSpy bufferedSpy(&audio, SIGNAL(buffered()));
- QSignalSpy endOfMediaSpy(&audio, SIGNAL(endOfMedia()));
-
- QCOMPARE(audio.status(), QmlAudio::NoMedia);
-
- // Set media, start loading.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadingMedia);
- QCOMPARE(audio.status(), QmlAudio::Loading);
- QCOMPARE(statusChangedSpy.count(), 1);
- QCOMPARE(loadedSpy.count(), 0);
- QCOMPARE(bufferingSpy.count(), 0);
- QCOMPARE(stalledSpy.count(), 0);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Finish loading.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::LoadedMedia);
- QCOMPARE(audio.status(), QmlAudio::Loaded);
- QCOMPARE(statusChangedSpy.count(), 2);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 0);
- QCOMPARE(stalledSpy.count(), 0);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Play, start buffering.
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::StalledMedia, QMediaPlayer::PlayingState);
- QCOMPARE(audio.status(), QmlAudio::Stalled);
- QCOMPARE(statusChangedSpy.count(), 3);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 0);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Enough data buffered to proceed.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 4);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 1);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Errant second buffering status changed.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 4);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 1);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 0);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Buffer full.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffered);
- QCOMPARE(statusChangedSpy.count(), 5);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 1);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 1);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Buffer getting low.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferingMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffering);
- QCOMPARE(statusChangedSpy.count(), 6);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 2);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 1);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Buffer full.
- provider.playerControl()->updateMediaStatus(QMediaPlayer::BufferedMedia);
- QCOMPARE(audio.status(), QmlAudio::Buffered);
- QCOMPARE(statusChangedSpy.count(), 7);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 2);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 2);
- QCOMPARE(endOfMediaSpy.count(), 0);
-
- // Finished.
- provider.playerControl()->updateMediaStatus(
- QMediaPlayer::EndOfMedia, QMediaPlayer::StoppedState);
- QCOMPARE(audio.status(), QmlAudio::EndOfMedia);
- QCOMPARE(statusChangedSpy.count(), 8);
- QCOMPARE(loadedSpy.count(), 1);
- QCOMPARE(bufferingSpy.count(), 2);
- QCOMPARE(stalledSpy.count(), 1);
- QCOMPARE(bufferedSpy.count(), 2);
- QCOMPARE(endOfMediaSpy.count(), 1);
-}
-
-void tst_QmlAudio::metaData_data()
-{
- QTest::addColumn<QByteArray>("propertyName");
- QTest::addColumn<QtMultimedia::MetaData>("propertyKey");
- QTest::addColumn<QVariant>("value1");
- QTest::addColumn<QVariant>("value2");
-
- QTest::newRow("title")
- << QByteArray("title")
- << QtMultimedia::Title
- << QVariant(QString::fromLatin1("This is a title"))
- << QVariant(QString::fromLatin1("This is another title"));
-
- QTest::newRow("genre")
- << QByteArray("genre")
- << QtMultimedia::Genre
- << QVariant(QString::fromLatin1("rock"))
- << QVariant(QString::fromLatin1("pop"));
-
- QTest::newRow("trackNumber")
- << QByteArray("trackNumber")
- << QtMultimedia::TrackNumber
- << QVariant(8)
- << QVariant(12);
-}
-
-void tst_QmlAudio::metaData()
-{
- QFETCH(QByteArray, propertyName);
- QFETCH(QtMultimedia::MetaData, propertyKey);
- QFETCH(QVariant, value1);
- QFETCH(QVariant, value2);
-
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy spy(&audio, SIGNAL(__metaDataChanged()));
-
- const int index = audio.metaObject()->indexOfProperty(propertyName.constData());
- QVERIFY(index != -1);
-
- QMetaProperty property = audio.metaObject()->property(index);
- QCOMPARE(property.read(&audio), QVariant());
-
- property.write(&audio, value1);
- QCOMPARE(property.read(&audio), value1);
- QCOMPARE(provider.metaDataControl()->metaData(propertyKey), value1);
- QCOMPARE(spy.count(), 1);
-
- provider.metaDataControl()->setMetaData(propertyKey, value2);
- QCOMPARE(property.read(&audio), value2);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_QmlAudio::error()
-{
- const QString errorString = QLatin1String("Failed to open device.");
-
- QtTestMediaServiceProvider provider;
- QmlAudio audio;
-
- QSignalSpy errorSpy(&audio, SIGNAL(error(QmlAudio::Error,QString)));
- QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged()));
-
- QCOMPARE(audio.error(), QmlAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
-
- provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
-
- QCOMPARE(audio.error(), QmlAudio::ResourceError);
- QCOMPARE(audio.errorString(), errorString);
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 1);
-
- // Changing the source resets the error properties.
- audio.setSource(QUrl("http://example.com"));
- QCOMPARE(audio.error(), QmlAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-
- // But isn't noisy.
- audio.setSource(QUrl("file:///file/path"));
- QCOMPARE(audio.error(), QmlAudio::NoError);
- QCOMPARE(audio.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-}
-
-
-QTEST_MAIN(tst_QmlAudio)
-
-#include "tst_qmlaudio.moc"
diff --git a/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro b/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro
deleted file mode 100644
index 0a83124ed5..0000000000
--- a/tests/auto/qmlgraphicsvideo/qmlgraphicsvideo.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_qmlgraphicsvideo.cpp
-
-QT += multimedia declarative
-requires(contains(QT_CONFIG, multimedia))
-requires(contains(QT_CONFIG, declarative))
diff --git a/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp b/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp
deleted file mode 100644
index 0da094d543..0000000000
--- a/tests/auto/qmlgraphicsvideo/tst_qmlgraphicsvideo.cpp
+++ /dev/null
@@ -1,911 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QtTest>
-
-#include <QtMultimedia/private/qmlgraphicsvideo_p.h>
-
-#include <QtGui/qapplication.h>
-#include <QtMultimedia/qabstractvideosurface.h>
-#include <QtMultimedia/qgraphicsvideoitem.h>
-#include <QtMultimedia/qmediaplayercontrol.h>
-#include <QtMultimedia/qmediaservice.h>
-#include <QtMultimedia/qvideooutputcontrol.h>
-#include <QtMultimedia/qvideorenderercontrol.h>
-#include <QtMultimedia/qvideosurfaceformat.h>
-
-
-class tst_QmlGraphicsVideo : public QObject
-{
- Q_OBJECT
-public slots:
- void initTestCase();
-
-private slots:
- void nullPlayerControl();
- void nullService();
-
- void playing();
- void paused();
- void error();
-
- void hasAudio();
- void hasVideo();
- void fillMode();
- void geometry();
-};
-
-Q_DECLARE_METATYPE(QtMultimedia::MetaData);
-Q_DECLARE_METATYPE(QmlGraphicsVideo::Error);
-
-class QtTestMediaPlayerControl : public QMediaPlayerControl
-{
- Q_OBJECT
-public:
- QtTestMediaPlayerControl(QObject *parent = 0)
- : QMediaPlayerControl(parent)
- , m_state(QMediaPlayer::StoppedState)
- , m_mediaStatus(QMediaPlayer::NoMedia)
- , m_duration(0)
- , m_position(0)
- , m_playbackRate(1.0)
- , m_volume(50)
- , m_bufferStatus(0)
- , m_muted(false)
- , m_audioAvailable(false)
- , m_videoAvailable(false)
- , m_seekable(false)
- {
- }
-
- QMediaPlayer::State state() const { return m_state; }
- void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
-
- QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
- void updateMediaStatus(QMediaPlayer::MediaStatus status) {
- emit mediaStatusChanged(m_mediaStatus = status); }
- void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
- {
- m_mediaStatus = status;
- m_state = state;
-
- emit mediaStatusChanged(m_mediaStatus);
- emit stateChanged(m_state);
- }
-
- qint64 duration() const { return m_duration; }
- void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
-
- qint64 position() const { return m_position; }
- void setPosition(qint64 position) { emit positionChanged(m_position = position); }
-
- int volume() const { return m_volume; }
- void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
-
- bool isMuted() const { return m_muted; }
- void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
-
- int bufferStatus() const { return m_bufferStatus; }
- void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
-
- bool isAudioAvailable() const { return m_audioAvailable; }
- void setAudioAvailable(bool available) {
- emit audioAvailableChanged(m_audioAvailable = available); }
- bool isVideoAvailable() const { return m_videoAvailable; }
- void setVideoAvailable(bool available) {
- emit videoAvailableChanged(m_videoAvailable = available); }
-
- bool isSeekable() const { return m_seekable; }
- void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
-
- QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
-
- qreal playbackRate() const { return m_playbackRate; }
- void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
-
- QMediaContent media() const { return m_media; }
- const QIODevice *mediaStream() const { return 0; }
- void setMedia(const QMediaContent &media, QIODevice *)
- {
- m_media = media;
-
- m_mediaStatus = m_media.isNull()
- ? QMediaPlayer::NoMedia
- : QMediaPlayer::LoadingMedia;
-
- emit mediaChanged(m_media);
- emit mediaStatusChanged(m_mediaStatus);
- }
-
- void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
- void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
- void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
-
- void emitError(QMediaPlayer::Error err, const QString &errorString) {
- emit error(err, errorString); }
-
-private:
- QMediaPlayer::State m_state;
- QMediaPlayer::MediaStatus m_mediaStatus;
- qint64 m_duration;
- qint64 m_position;
- qreal m_playbackRate;
- int m_volume;
- int m_bufferStatus;
- bool m_muted;
- bool m_audioAvailable;
- bool m_videoAvailable;
- bool m_seekable;
- QMediaContent m_media;
-};
-
-class QtTestOutputControl : public QVideoOutputControl
-{
-public:
- QtTestOutputControl(QObject *parent) : QVideoOutputControl(parent), m_output(NoOutput) {}
-
- QList<Output> availableOutputs() const { return m_outputs; }
- void setAvailableOutputs(const QList<Output> outputs) { m_outputs = outputs; }
-
- Output output() const { return m_output; }
- virtual void setOutput(Output output) { m_output = output; }
-
-private:
- Output m_output;
- QList<Output> m_outputs;
-};
-
-class QtTestRendererControl : public QVideoRendererControl
-{
-public:
- QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {}
-
- QAbstractVideoSurface *surface() const { return m_surface; }
- void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
-
-private:
- QAbstractVideoSurface *m_surface;
-};
-
-class QtTestMediaService : public QMediaService
-{
- Q_OBJECT
-public:
- QtTestMediaService(
- QtTestMediaPlayerControl *playerControl,
- QtTestOutputControl *outputControl,
- QtTestRendererControl *rendererControl,
- QObject *parent)
- : QMediaService(parent)
- , playerControl(playerControl)
- , outputControl(outputControl)
- , rendererControl(rendererControl)
- {
- }
-
- QMediaControl *control(const char *name) const
- {
- if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
- return playerControl;
- else if (qstrcmp(name, QVideoOutputControl_iid) == 0)
- return outputControl;
- else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
- return rendererControl;
- else
- return 0;
- }
-
- QtTestMediaPlayerControl *playerControl;
- QtTestOutputControl *outputControl;
- QtTestRendererControl *rendererControl;
-};
-
-class QtTestMediaServiceProvider : public QMediaServiceProvider
-{
- Q_OBJECT
-public:
- QtTestMediaServiceProvider()
- : service(new QtTestMediaService(
- new QtTestMediaPlayerControl(this),
- new QtTestOutputControl(this),
- new QtTestRendererControl(this),
- this))
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(QtTestMediaService *service)
- : service(service)
- {
- setDefaultServiceProvider(this);
- }
-
- QtTestMediaServiceProvider(
- QtTestMediaPlayerControl *playerControl,
- QtTestOutputControl *outputControl,
- QtTestRendererControl *rendererControl)
- : service(new QtTestMediaService(playerControl, outputControl, rendererControl, this))
- {
- setDefaultServiceProvider(this);
- }
-
- ~QtTestMediaServiceProvider()
- {
- setDefaultServiceProvider(0);
- }
-
- QMediaService *requestService(
- const QByteArray &type,
- const QMediaServiceProviderHint & = QMediaServiceProviderHint())
- {
- requestedService = type;
-
- return service;
- }
-
- void releaseService(QMediaService *) {}
-
- inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
- inline QtTestRendererControl *rendererControl() { return service->rendererControl; }
-
- QtTestMediaService *service;
- QByteArray requestedService;
-};
-
-
-void tst_QmlGraphicsVideo::initTestCase()
-{
- qRegisterMetaType<QmlGraphicsVideo::Error>();
-}
-
-void tst_QmlGraphicsVideo::nullPlayerControl()
-{
- QtTestMediaServiceProvider provider(0, 0, 0);
-
- QmlGraphicsVideo video;
-
- QCOMPARE(video.source(), QUrl());
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.source(), QUrl());
-
- QCOMPARE(video.isPlaying(), false);
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), false);
- video.play();
- QCOMPARE(video.isPlaying(), false);
-
- QCOMPARE(video.isPaused(), false);
- video.pause();
- QCOMPARE(video.isPaused(), false);
- video.setPaused(true);
- QCOMPARE(video.isPaused(), true);
-
- QCOMPARE(video.duration(), 0);
-
- QCOMPARE(video.position(), 0);
- video.setPosition(10000);
- QCOMPARE(video.position(), 0);
-
- QCOMPARE(video.volume(), qreal(0));
- video.setVolume(50);
- QCOMPARE(video.volume(), qreal(0));
-
- QCOMPARE(video.isMuted(), false);
- video.setMuted(true);
- QCOMPARE(video.isMuted(), false);
-
- QCOMPARE(video.bufferProgress(), qreal(0));
-
- QCOMPARE(video.isSeekable(), false);
-
- QCOMPARE(video.playbackRate(), qreal(1.0));
-
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(video.hasVideo(), false);
-
- QCOMPARE(video.status(), QmlGraphicsVideo::NoMedia);
-
- QCOMPARE(video.error(), QmlGraphicsVideo::ServiceMissing);
-}
-
-void tst_QmlGraphicsVideo::nullService()
-{
- QtTestMediaServiceProvider provider(0);
-
- QmlGraphicsVideo video;
-
- QCOMPARE(video.source(), QUrl());
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.source(), QUrl());
-
- QCOMPARE(video.isPlaying(), false);
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), false);
- video.play();
- QCOMPARE(video.isPlaying(), false);
-
- QCOMPARE(video.isPaused(), false);
- video.pause();
- QCOMPARE(video.isPaused(), false);
- video.setPaused(true);
- QCOMPARE(video.isPaused(), true);
-
- QCOMPARE(video.duration(), 0);
-
- QCOMPARE(video.position(), 0);
- video.setPosition(10000);
- QCOMPARE(video.position(), 0);
-
- QCOMPARE(video.volume(), qreal(0));
- video.setVolume(50);
- QCOMPARE(video.volume(), qreal(0));
-
- QCOMPARE(video.isMuted(), false);
- video.setMuted(true);
- QCOMPARE(video.isMuted(), false);
-
- QCOMPARE(video.bufferProgress(), qreal(0));
-
- QCOMPARE(video.isSeekable(), false);
-
- QCOMPARE(video.playbackRate(), qreal(1.0));
-
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(video.hasVideo(), false);
-
- QCOMPARE(video.status(), QmlGraphicsVideo::NoMedia);
-
- QCOMPARE(video.error(), QmlGraphicsVideo::ServiceMissing);
-
- QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
- QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
- QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
-}
-
-void tst_QmlGraphicsVideo::playing()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
- QSignalSpy startedSpy(&video, SIGNAL(started()));
- QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int started = 0;
- int stopped = 0;
-
- QCOMPARE(video.isPlaying(), false);
-
- // setPlaying(true) when stopped.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when playing.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when playing.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // stop() when stopped.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when stopped.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when playing.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when playing.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlGraphicsVideo::paused()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
- QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged()));
- QSignalSpy startedSpy(&video, SIGNAL(started()));
- QSignalSpy pausedSpy(&video, SIGNAL(paused()));
- QSignalSpy resumedSpy(&video, SIGNAL(resumed()));
- QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
-
- int playingChanged = 0;
- int pausedChanged = 0;
- int started = 0;
- int paused = 0;
- int resumed = 0;
- int stopped = 0;
-
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
-
- // setPlaying(true) when stopped.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when paused.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when paused.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when paused.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when playing.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when playing.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped and paused.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(false) when stopped and paused.
- video.setPaused(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when stopped.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(true) when stopped and paused.
- video.setPlaying(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // play() when paused.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), ++resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPaused(true) when playing.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when paused.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // setPaused(true) when stopped.
- video.setPaused(true);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // stop() when stopped and paused.
- video.stop();
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // pause() when stopped.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // pause() when stopped and paused.
- video.pause();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), ++paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-
- // setPlaying(false) when paused.
- video.setPlaying(false);
- QCOMPARE(video.isPlaying(), false);
- QCOMPARE(video.isPaused(), true);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), pausedChanged);
- QCOMPARE(startedSpy.count(), started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), ++stopped);
-
- // play() when stopped and paused.
- video.play();
- QCOMPARE(video.isPlaying(), true);
- QCOMPARE(video.isPaused(), false);
- QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
- QCOMPARE(playingChangedSpy.count(), ++playingChanged);
- QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
- QCOMPARE(startedSpy.count(), ++started);
- QCOMPARE(pausedSpy.count(), paused);
- QCOMPARE(resumedSpy.count(), resumed);
- QCOMPARE(stoppedSpy.count(), stopped);
-}
-
-void tst_QmlGraphicsVideo::error()
-{
- const QString errorString = QLatin1String("Failed to open device.");
-
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy errorSpy(&video, SIGNAL(error(QmlGraphicsVideo::Error,QString)));
- QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
-
- QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
- QCOMPARE(video.errorString(), QString());
-
- provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
-
- QCOMPARE(video.error(), QmlGraphicsVideo::ResourceError);
- QCOMPARE(video.errorString(), errorString);
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 1);
-
- // Changing the source resets the error properties.
- video.setSource(QUrl("http://example.com"));
- QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
- QCOMPARE(video.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-
- // But isn't noisy.
- video.setSource(QUrl("file:///file/path"));
- QCOMPARE(video.error(), QmlGraphicsVideo::NoError);
- QCOMPARE(video.errorString(), QString());
- QCOMPARE(errorSpy.count(), 1);
- QCOMPARE(errorChangedSpy.count(), 2);
-}
-
-
-void tst_QmlGraphicsVideo::hasAudio()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy spy(&video, SIGNAL(hasAudioChanged()));
-
- QCOMPARE(video.hasAudio(), false);
-
- provider.playerControl()->setAudioAvailable(true);
- QCOMPARE(video.hasAudio(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setAudioAvailable(true);
- QCOMPARE(video.hasAudio(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setAudioAvailable(false);
- QCOMPARE(video.hasAudio(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlGraphicsVideo::hasVideo()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QSignalSpy spy(&video, SIGNAL(hasVideoChanged()));
-
- QCOMPARE(video.hasVideo(), false);
-
- provider.playerControl()->setVideoAvailable(true);
- QCOMPARE(video.hasVideo(), true);
- QCOMPARE(spy.count(), 1);
-
- provider.playerControl()->setVideoAvailable(true);
- QCOMPARE(video.hasVideo(), true);
- QCOMPARE(spy.count(), 2);
-
- provider.playerControl()->setVideoAvailable(false);
- QCOMPARE(video.hasVideo(), false);
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_QmlGraphicsVideo::fillMode()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QList<QGraphicsItem *> children = video.childItems();
- QCOMPARE(children.count(), 1);
- QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
- QVERIFY(videoItem != 0);
-
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectFit);
-
- video.setFillMode(QmlGraphicsVideo::PreserveAspectCrop);
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectCrop);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
-
- video.setFillMode(QmlGraphicsVideo::Stretch);
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::Stretch);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
-
- video.setFillMode(QmlGraphicsVideo::PreserveAspectFit);
- QCOMPARE(video.fillMode(), QmlGraphicsVideo::PreserveAspectFit);
- QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
-}
-
-void tst_QmlGraphicsVideo::geometry()
-{
- QtTestMediaServiceProvider provider;
- QmlGraphicsVideo video;
-
- QAbstractVideoSurface *surface = provider.rendererControl()->surface();
- QVERIFY(surface != 0);
-
- QList<QGraphicsItem *> children = video.childItems();
- QCOMPARE(children.count(), 1);
- QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
- QVERIFY(videoItem != 0);
-
- QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32);
-
- QVERIFY(surface->start(format));
-
- QCOMPARE(video.implicitWidth(), qreal(640));
- QCOMPARE(video.implicitHeight(), qreal(480));
-
- video.setWidth(560);
- video.setHeight(328);
-
- QCOMPARE(videoItem->size().width(), qreal(560));
- QCOMPARE(videoItem->size().height(), qreal(328));
-}
-
-QTEST_MAIN(tst_QmlGraphicsVideo)
-
-#include "tst_qmlgraphicsvideo.moc"
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 66cfeb7fcd..849b8b2b2e 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include "../../shared/util.h"
#include <QtCore/qpropertyanimation.h>
#include <QtCore/qvariantanimation.h>
@@ -288,7 +289,7 @@ void tst_QPropertyAnimation::statesAndSignals()
anim->start();
QTest::qWait(1000);
- QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QTRY_COMPARE(anim->state(), QAnimationGroup::Stopped);
QCOMPARE(runningSpy.count(), 2); //started and stopped again
runningSpy.clear();
QCOMPARE(finishedSpy.count(), 1);
@@ -340,7 +341,7 @@ void tst_QPropertyAnimation::deletion1()
QCOMPARE(anim->state(), QAnimationGroup::Running);
QTest::qWait(150);
QVERIFY(anim); //The animation should not have been deleted
- QCOMPARE(anim->state(), QAnimationGroup::Stopped);
+ QTRY_COMPARE(anim->state(), QAnimationGroup::Stopped);
QCOMPARE(runningSpy.count(), 2);
QCOMPARE(finishedSpy.count(), 1);
@@ -351,9 +352,9 @@ void tst_QPropertyAnimation::deletion1()
QVERIFY(anim);
QCOMPARE(anim->state(), QAnimationGroup::Running);
QTest::qWait(150);
- QVERIFY(!anim); //The animation must have been deleted
- QCOMPARE(runningSpy.count(), 4);
+ QTRY_COMPARE(runningSpy.count(), 4);
QCOMPARE(finishedSpy.count(), 2);
+ QVERIFY(!anim); //The animation must have been deleted
delete object;
}
@@ -459,7 +460,7 @@ void tst_QPropertyAnimation::noStartValue()
QTest::qWait(300);
- QCOMPARE(o.values.first(), 42);
+ QTRY_COMPARE(o.values.first(), 42);
QCOMPARE(o.values.last(), 420);
}
@@ -497,7 +498,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
anim->start(QVariantAnimation::DeleteWhenStopped);
QTest::qWait(anim->duration() + 100);
- QCOMPARE(runningSpy.count(), 2); //started and then stopped
+ QTRY_COMPARE(runningSpy.count(), 2); //started and then stopped
QVERIFY(!anim);
}
@@ -518,7 +519,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning()
QVERIFY(!anim); //anim should have been deleted
QVERIFY(anim2);
QTest::qWait(anim2->duration());
- QVERIFY(!anim2); //anim2 is finished: it should have been deleted by now
+ QTRY_VERIFY(!anim2); //anim2 is finished: it should have been deleted by now
QVERIFY(!anim);
}
@@ -591,7 +592,7 @@ void tst_QPropertyAnimation::startWithoutStartValue()
QVERIFY(current < 100);
QTest::qWait(200);
- QCOMPARE(anim.state(), QVariantAnimation::Stopped);
+ QTRY_COMPARE(anim.state(), QVariantAnimation::Stopped);
current = anim.currentValue().toInt();
QCOMPARE(current, 100);
QCOMPARE(o.property("ole").toInt(), current);
@@ -631,7 +632,7 @@ void tst_QPropertyAnimation::startBackwardWithoutEndValue()
QVERIFY(current < 100);
QTest::qWait(200);
- QCOMPARE(anim.state(), QVariantAnimation::Stopped);
+ QTRY_COMPARE(anim.state(), QVariantAnimation::Stopped);
current = anim.currentValue().toInt();
QCOMPARE(current, 100);
QCOMPARE(o.property("ole").toInt(), current);
@@ -661,7 +662,7 @@ void tst_QPropertyAnimation::playForwardBackward()
anim.setEndValue(100);
anim.start();
QTest::qWait(anim.duration() + 100);
- QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), anim.duration());
//the animation is at the end
@@ -669,7 +670,7 @@ void tst_QPropertyAnimation::playForwardBackward()
anim.start();
QCOMPARE(anim.state(), QAbstractAnimation::Running);
QTest::qWait(anim.duration() + 100);
- QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), 0);
//the direction is backward
@@ -678,7 +679,7 @@ void tst_QPropertyAnimation::playForwardBackward()
QCOMPARE(anim.state(), QAbstractAnimation::Running);
QCOMPARE(anim.currentTime(), anim.duration());
QTest::qWait(anim.duration() + 100);
- QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(anim.currentTime(), 0);
}
@@ -1146,7 +1147,7 @@ void tst_QPropertyAnimation::twoAnimations()
o2.anim.start();
QTest::qWait(o1.anim.duration() + 100);
- QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped);
+ QTRY_COMPARE(o1.anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped);
QCOMPARE(o1.ole(), 1000);
@@ -1197,7 +1198,7 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime()
QCOMPARE(composedAnimation.state(), QAbstractAnimation::Running);
QTest::qWait(composedAnimation.duration() + 100);
- QCOMPARE(composedAnimation.state(), QAbstractAnimation::Stopped);
+ QTRY_COMPARE(composedAnimation.state(), QAbstractAnimation::Stopped);
QCOMPARE(o.value(), 1000);
}
diff --git a/tests/auto/qscriptstring/tst_qscriptstring.cpp b/tests/auto/qscriptstring/tst_qscriptstring.cpp
index 808b6439e9..ea4a92b707 100644
--- a/tests/auto/qscriptstring/tst_qscriptstring.cpp
+++ b/tests/auto/qscriptstring/tst_qscriptstring.cpp
@@ -177,6 +177,12 @@ void tst_QScriptString::toArrayIndex_data()
QTest::newRow("101a") << QString::fromLatin1("101a") << false << quint32(0xffffffff);
QTest::newRow("4294967294") << QString::fromLatin1("4294967294") << true << quint32(0xfffffffe);
QTest::newRow("4294967295") << QString::fromLatin1("4294967295") << false << quint32(0xffffffff);
+ QTest::newRow("0.0") << QString::fromLatin1("0.0") << false << quint32(0xffffffff);
+ QTest::newRow("1.0") << QString::fromLatin1("1.0") << false << quint32(0xffffffff);
+ QTest::newRow("1.5") << QString::fromLatin1("1.5") << false << quint32(0xffffffff);
+ QTest::newRow("1.") << QString::fromLatin1("1.") << false << quint32(0xffffffff);
+ QTest::newRow(".1") << QString::fromLatin1(".1") << false << quint32(0xffffffff);
+ QTest::newRow("1e0") << QString::fromLatin1("1e0") << false << quint32(0xffffffff);
}
void tst_QScriptString::toArrayIndex()
diff --git a/tests/auto/qscriptvalue/qscriptvalue.pro b/tests/auto/qscriptvalue/qscriptvalue.pro
index 1588cc5729..191cd4a73a 100644
--- a/tests/auto/qscriptvalue/qscriptvalue.pro
+++ b/tests/auto/qscriptvalue/qscriptvalue.pro
@@ -5,3 +5,10 @@ HEADERS += tst_qscriptvalue.h
# Generated by testgen
SOURCES += tst_qscriptvalue_generated.cpp
+
+
+win32-msvc* {
+ # With -O2, MSVC takes up to 24 minutes to compile this test!
+ QMAKE_CXXFLAGS_RELEASE -= -O1 -O2
+ QMAKE_CXXFLAGS_RELEASE += -Od
+}
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 68daf1a113..e154528ea2 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -934,8 +934,8 @@ void tst_QSequentialAnimationGroup::startDelay()
QTest::qWait(500);
+ QTRY_COMPARE(group.state(), QAnimationGroup::Stopped);
QVERIFY(group.currentLoopTime() == 375);
- QCOMPARE(group.state(), QAnimationGroup::Stopped);
}
void tst_QSequentialAnimationGroup::clearGroup()
@@ -1029,7 +1029,7 @@ void tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations()
QTest::qWait(500);
- QCOMPARE(o.property("myProperty").toInt(), 44);
+ QTRY_COMPARE(o.property("myProperty").toInt(), 44);
QCOMPARE(o2.property("myProperty").toInt(), 42);
QCOMPARE(o2.property("myOtherProperty").toInt(), 31);
QCOMPARE(a1->state(), QAnimationGroup::Stopped);
@@ -1171,7 +1171,7 @@ void tst_QSequentialAnimationGroup::deleteChildrenWithRunningGroup()
QCOMPARE(anim1->state(), QAnimationGroup::Running);
QTest::qWait(100);
- QVERIFY(group.currentLoopTime() > 0);
+ QTRY_VERIFY(group.currentLoopTime() > 0);
delete anim1;
QCOMPARE(group.animationCount(), 0);
@@ -1430,7 +1430,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
QCOMPARE(notTimeDriven.currentLoopTime(), 0);
QTest::qWait(300); //wait for the end of notTimeDriven
- QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
const int actualDuration = notTimeDriven.currentLoopTime();
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(group.currentLoopTime(), actualDuration);
@@ -1459,14 +1459,14 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation()
QCOMPARE(animStateChangedSpy.count(), 0);
QTest::qWait(300); //wait for the end of notTimeDriven
- QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
+ QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim.state(), QAnimationGroup::Running);
QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim));
QCOMPARE(animStateChangedSpy.count(), 1);
QTest::qWait(300); //wait for the end of anim
- QCOMPARE(anim.state(), QAnimationGroup::Stopped);
+ QTRY_COMPARE(anim.state(), QAnimationGroup::Stopped);
QCOMPARE(anim.currentLoopTime(), anim.duration());
//we should simply be at the end
@@ -1621,7 +1621,7 @@ void tst_QSequentialAnimationGroup::clear()
group.start();
QTest::qWait(anim1->duration() + 100);
- QCOMPARE(group.animationCount(), 0);
+ QTRY_COMPARE(group.animationCount(), 0);
QCOMPARE(group.state(), QAbstractAnimation::Stopped);
QCOMPARE(group.currentLoopTime(), 0);
@@ -1629,8 +1629,8 @@ void tst_QSequentialAnimationGroup::clear()
group.connect(anim1, SIGNAL(finished()), SLOT(refill()));
group.start();
QTest::qWait(anim1->duration() + 100);
+ QTRY_COMPARE(group.state(), QAbstractAnimation::Running);
QVERIFY(anim1 == 0); //anim1 should have been deleted
- QCOMPARE(group.state(), QAbstractAnimation::Running);
}
void tst_QSequentialAnimationGroup::pauseResume()
@@ -1645,7 +1645,7 @@ void tst_QSequentialAnimationGroup::pauseResume()
QCOMPARE(group.duration(), 250);
group.start();
QTest::qWait(100);
- QCOMPARE(group.state(), QAnimationGroup::Running);
+ QTRY_COMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(spy.count(), 1);
spy.clear();
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 72ce3934ed..83109b5cea 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -2513,13 +2513,9 @@ void tst_QUrl::schemeValidator()
void tst_QUrl::invalidSchemeValidator()
{
- // enable that test when QUrl is fixed
- return;
-
// test that if scheme does not start with an ALPHA, QUrl::isValid() returns false
{
QUrl url("1http://qt.nokia.com", QUrl::StrictMode);
- qDebug() << url;
QCOMPARE(url.isValid(), false);
}
{
diff --git a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
index b325250f6e..1238804d99 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
+++ b/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
@@ -156,6 +156,7 @@ private slots:
}
void sizeSpeedWithoutFilterLowLevel() {
+ QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
#ifdef Q_OS_WIN
const wchar_t *dirpath = (wchar_t*)testdir.absolutePath().utf16();
wchar_t appendedPath[MAX_PATH];
@@ -173,7 +174,6 @@ private slots:
}
FindClose(hSearch);
#else
- QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
DIR *dir = opendir(qPrintable(testdir.absolutePath()));
QVERIFY(dir);
diff --git a/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt b/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt
new file mode 100644
index 0000000000..b915320e9e
--- /dev/null
+++ b/tests/benchmarks/corelib/io/qdir/tree/4.6.0-list.txt
@@ -0,0 +1,11963 @@
+0 src/
+0 3rdparty/
+0 ce-compat/
+0 ce_time.c
+ ce_time.h
+2 clucene/
+0 APACHE.license
+ AUTHORS
+ ChangeLog
+ COPYING
+ LGPL.license
+ README
+ src/
+0 CLucene/
+0 analysis/
+0 AnalysisHeader.cpp
+ AnalysisHeader.h
+ Analyzers.cpp
+ Analyzers.h
+ standard/
+0 StandardAnalyzer.cpp
+ StandardAnalyzer.h
+ StandardFilter.cpp
+ StandardFilter.h
+ StandardTokenizerConstants.h
+ StandardTokenizer.cpp
+ StandardTokenizer.h
+3 CLBackwards.h
+ CLConfig.h
+ CLMonolithic.cpp
+ config/
+0 CompilerAcc.h
+ CompilerBcb.h
+ CompilerGcc.h
+ compiler.h
+ CompilerMsvc.h
+ define_std.h
+ gunichartables.cpp
+ gunichartables.h
+ PlatformMac.h
+ PlatformUnix.h
+ PlatformWin32.h
+ repl_lltot.cpp
+ repl_tchar.h
+ repl_tcscasecmp.cpp
+ repl_tcslwr.cpp
+ repl_tcstod.cpp
+ repl_tcstoll.cpp
+ repl_tprintf.cpp
+ repl_wchar.h
+ threadCSection.h
+ threadPthread.h
+ threads.cpp
+ utf8.cpp
+2 debug/
+0 condition.cpp
+ condition.h
+ error.cpp
+ error.h
+ lucenebase.h
+ mem.h
+ memtracking.cpp
+2 document/
+0 DateField.cpp
+ DateField.h
+ Document.cpp
+ Document.h
+ Field.cpp
+ Field.h
+3 CLucene.h
+ CLucene/index/
+0 CompoundFile.cpp
+ CompoundFile.h
+ DocumentWriter.cpp
+ DocumentWriter.h
+ FieldInfo.h
+ FieldInfos.cpp
+ FieldInfos.h
+ FieldsReader.cpp
+ FieldsReader.h
+ FieldsWriter.cpp
+ FieldsWriter.h
+ IndexModifier.cpp
+ IndexModifier.h
+ IndexReader.cpp
+ IndexReader.h
+ IndexWriter.cpp
+ IndexWriter.h
+ MultiReader.cpp
+ MultiReader.h
+ SegmentHeader.h
+ SegmentInfos.cpp
+ SegmentInfos.h
+ SegmentMergeInfo.cpp
+ SegmentMergeInfo.h
+ SegmentMergeQueue.cpp
+ SegmentMergeQueue.h
+ SegmentMerger.cpp
+ SegmentMerger.h
+ SegmentReader.cpp
+ SegmentTermDocs.cpp
+ SegmentTermEnum.cpp
+ SegmentTermEnum.h
+ SegmentTermPositions.cpp
+ SegmentTermVector.cpp
+ Term.cpp
+ Term.h
+ TermInfo.cpp
+ TermInfo.h
+ TermInfosReader.cpp
+ TermInfosReader.h
+ TermInfosWriter.cpp
+ TermInfosWriter.h
+ Terms.h
+ TermVector.h
+ TermVectorReader.cpp
+ TermVectorWriter.cpp
+2 CLucene/LuceneThreads.h
+ CLucene/queryParser/
+0 Lexer.cpp
+ Lexer.h
+ MultiFieldQueryParser.cpp
+ MultiFieldQueryParser.h
+ QueryParserBase.cpp
+ QueryParserBase.h
+ QueryParser.cpp
+ QueryParser.h
+ QueryToken.cpp
+ QueryToken.h
+ TokenList.cpp
+ TokenList.h
+2 CLucene/search/
+0 BooleanClause.h
+ BooleanQuery.cpp
+ BooleanQuery.h
+ BooleanScorer.cpp
+ BooleanScorer.h
+ CachingWrapperFilter.cpp
+ CachingWrapperFilter.h
+ ChainedFilter.cpp
+ ChainedFilter.h
+ Compare.h
+ ConjunctionScorer.cpp
+ ConjunctionScorer.h
+ DateFilter.cpp
+ DateFilter.h
+ ExactPhraseScorer.cpp
+ ExactPhraseScorer.h
+ Explanation.cpp
+ Explanation.h
+ FieldCache.cpp
+ FieldCache.h
+ FieldCacheImpl.cpp
+ FieldCacheImpl.h
+ FieldDoc.h
+ FieldDocSortedHitQueue.cpp
+ FieldDocSortedHitQueue.h
+ FieldSortedHitQueue.cpp
+ FieldSortedHitQueue.h
+ FilteredTermEnum.cpp
+ FilteredTermEnum.h
+ Filter.h
+ FuzzyQuery.cpp
+ FuzzyQuery.h
+ HitQueue.cpp
+ HitQueue.h
+ Hits.cpp
+ IndexSearcher.cpp
+ IndexSearcher.h
+ MultiSearcher.cpp
+ MultiSearcher.h
+ MultiTermQuery.cpp
+ MultiTermQuery.h
+ PhrasePositions.cpp
+ PhrasePositions.h
+ PhraseQuery.cpp
+ PhraseQuery.h
+ PhraseQueue.h
+ PhraseScorer.cpp
+ PhraseScorer.h
+ PrefixQuery.cpp
+ PrefixQuery.h
+ QueryFilter.cpp
+ QueryFilter.h
+ RangeFilter.cpp
+ RangeFilter.h
+ RangeQuery.cpp
+ RangeQuery.h
+ Scorer.h
+ SearchHeader.cpp
+ SearchHeader.h
+ Similarity.cpp
+ Similarity.h
+ SloppyPhraseScorer.cpp
+ SloppyPhraseScorer.h
+ Sort.cpp
+ Sort.h
+ TermQuery.cpp
+ TermQuery.h
+ TermScorer.cpp
+ TermScorer.h
+ WildcardQuery.cpp
+ WildcardQuery.h
+ WildcardTermEnum.cpp
+ WildcardTermEnum.h
+2 CLucene/StdHeader.cpp
+ CLucene/StdHeader.h
+ CLucene/store/
+0 Directory.h
+ FSDirectory.cpp
+ FSDirectory.h
+ IndexInput.cpp
+ IndexInput.h
+ IndexOutput.cpp
+ IndexOutput.h
+ InputStream.h
+ Lock.cpp
+ Lock.h
+ MMapInput.cpp
+ OutputStream.h
+ RAMDirectory.cpp
+ RAMDirectory.h
+ TransactionalRAMDirectory.cpp
+ TransactionalRAMDirectory.h
+2 CLucene/util/
+0 Arrays.h
+ BitSet.cpp
+ BitSet.h
+ bufferedstream.h
+ dirent.cpp
+ dirent.h
+ Equators.cpp
+ Equators.h
+ FastCharStream.cpp
+ FastCharStream.h
+ fileinputstream.cpp
+ fileinputstream.h
+ inputstreambuffer.h
+ jstreamsconfig.h
+ Misc.cpp
+ Misc.h
+ PriorityQueue.h
+ Reader.cpp
+ Reader.h
+ streambase.h
+ StringBuffer.cpp
+ StringBuffer.h
+ StringIntern.cpp
+ StringIntern.h
+ stringreader.h
+ subinputstream.h
+ ThreadLocal.cpp
+ ThreadLocal.h
+ VoidList.h
+ VoidMap.h
+4 des/
+0 des.cpp
+2 easing/
+0 easing.cpp
+ legal.qdoc
+2 fonts/
+0 5x7.bdf
+ 6x13.bdf
+ COPYING.Cursor
+ COPYING.Helvetica
+ COPYING.Utopia
+ COPYRIGHT.BH
+ COPYRIGHT.Charter
+ COPYRIGHT.Courier
+ COPYRIGHT.DejaVu
+ COPYRIGHT.IBM
+ COPYRIGHT.Unifont
+ COPYRIGHT.Vera
+ helvB08.bdf
+ helvB10.bdf
+ helvB12.bdf
+ helvB14.bdf
+ helvB18.bdf
+ helvB24.bdf
+ helvBO08.bdf
+ helvBO10.bdf
+ helvBO12.bdf
+ helvBO14.bdf
+ helvBO18.bdf
+ helvBO24.bdf
+ helvO08.bdf
+ helvO10.bdf
+ helvO12.bdf
+ helvO14.bdf
+ helvO18.bdf
+ helvO24.bdf
+ helvR08.bdf
+ helvR10.bdf
+ helvR12.bdf
+ helvR14.bdf
+ helvR18.bdf
+ helvR24.bdf
+ micro.bdf
+ README.DejaVu
+ unifont.bdf
+2 freetype/
+0 autogen.sh
+ builds/
+0 amiga/
+0 include/
+0 freetype/
+0 config/
+0 ftconfig.h
+ ftmodule.h
+4 makefile
+0 .os4
+2 README
+ smakefile
+ src/
+0 base/
+0 ftdebug.c
+ ftsystem.c
+4 ansi/
+0 ansi-def.mk
+ ansi.mk
+2 atari/
+0 ATARI.H
+ FNames.SIC
+ FREETYPE.PRJ
+ README.TXT
+2 beos/
+0 beos-def.mk
+ beos.mk
+ detect.mk
+2 compiler/
+0 ansi-cc.mk
+ bcc-dev.mk
+ bcc.mk
+ emx.mk
+ gcc-dev.mk
+ gcc.mk
+ intelc.mk
+ unix-lcc.mk
+ visualage.mk
+ visualc.mk
+ watcom.mk
+ win-lcc.mk
+2 detect.mk
+ dos/
+0 detect.mk
+ dos-def.mk
+ dos-emx.mk
+ dos-gcc.mk
+ dos-wat.mk
+2 exports.mk
+ freetype.mk
+ link_dos.mk
+ link_std.mk
+ mac/
+0 ascii2mpw.py
+ FreeType.m68k_cfm.make.txt
+ FreeType.m68k_far.make.txt
+ FreeType.ppc_carbon.make.txt
+ FreeType.ppc_classic.make.txt
+ ftlib.prj.xml
+ ftmac.c
+ README
+2 modules.mk
+ newline
+ os2/
+0 detect.mk
+ os2-def.mk
+ os2-dev.mk
+ os2-gcc.mk
+2 symbian/
+0 bld.inf
+ freetype.mmp
+2 toplevel.mk
+ unix/
+0 aclocal.m4
+ config.guess
+ config.sub
+ configure
+0 .ac
+ .raw
+2 detect.mk
+ freetype2.in
+ freetype2.m4
+ freetype-config.in
+ ft2unix.h
+ ftconfig.h
+ ftconfig.in
+ ft-munmap.m4
+ ftsystem.c
+ install.mk
+ install-sh
+ ltmain.sh
+ mkinstalldirs
+ unix-cc.in
+ unixddef.mk
+ unix-def.in
+ unix-dev.mk
+ unix-lcc.mk
+ unix.mk
+2 vms/
+0 ftconfig.h
+ ftsystem.c
+2 win32/
+0 detect.mk
+ ftdebug.c
+ vc2005/
+0 freetype.sln
+ freetype.vcproj
+ index.html
+2 vc2008/
+0 freetype.sln
+ freetype.vcproj
+ index.html
+2 visualc/
+0 freetype.dsp
+ freetype.dsw
+ index.html
+2 w32-bccd.mk
+ w32-bcc.mk
+ w32-dev.mk
+ w32-gcc.mk
+ w32-icc.mk
+ w32-intl.mk
+ w32-lcc.mk
+ w32-mingw32.mk
+ w32-vcc.mk
+ w32-wat.mk
+ win32-def.mk
+2 wince/
+0 ftdebug.c
+ vc2005-ce/
+0 freetype.sln
+ freetype.vcproj
+ index.html
+2 vc2008-ce/
+0 freetype.sln
+ freetype.vcproj
+ index.html
+4 ChangeLog
+0 .20
+ .21
+ .22
+2 configure
+ devel/
+0 ft2build.h
+ ftoption.h
+2 docs/
+0 CHANGES
+ CUSTOMIZE
+ DEBUG
+ formats.txt
+ FTL.TXT
+ GPL.TXT
+ INSTALL
+0 .ANY
+ .CROSS
+ .GNU
+ .MAC
+ .UNIX
+ .VMS
+2 LICENSE.TXT
+ MAKEPP
+ PATENTS
+ PROBLEMS
+ raster.txt
+ reference/
+0 ft2-base_interface.html
+ ft2-basic_types.html
+ ft2-bdf_fonts.html
+ ft2-bitmap_handling.html
+ ft2-cache_subsystem.html
+ ft2-cid_fonts.html
+ ft2-computations.html
+ ft2-font_formats.html
+ ft2-gasp_table.html
+ ft2-glyph_management.html
+ ft2-glyph_stroker.html
+ ft2-glyph_variants.html
+ ft2-gx_validation.html
+ ft2-gzip.html
+ ft2-header_file_macros.html
+ ft2-incremental.html
+ ft2-index.html
+ ft2-lcd_filtering.html
+ ft2-list_processing.html
+ ft2-lzw.html
+ ft2-mac_specific.html
+ ft2-module_management.html
+ ft2-multiple_masters.html
+ ft2-ot_validation.html
+ ft2-outline_processing.html
+ ft2-pfr_fonts.html
+ ft2-quick_advance.html
+ ft2-raster.html
+ ft2-sfnt_names.html
+ ft2-sizes_management.html
+ ft2-system_interface.html
+ ft2-toc.html
+ ft2-truetype_engine.html
+ ft2-truetype_tables.html
+ ft2-type1_tables.html
+ ft2-user_allocation.html
+ ft2-version.html
+ ft2-winfnt_fonts.html
+ README
+2 release
+ TODO
+ TRUETYPE
+ UPGRADE.UNIX
+ VERSION.DLL
+2 include/
+0 freetype/
+0 config/
+0 ftconfig.h
+ ftheader.h
+ ftmodule.h
+ ftoption.h
+ ftstdlib.h
+2 freetype.h
+ ftadvanc.h
+ ftbbox.h
+ ftbdf.h
+ ftbitmap.h
+ ftcache.h
+ ftchapters.h
+ ftcid.h
+ fterrdef.h
+ fterrors.h
+ ftgasp.h
+ ftglyph.h
+ ftgxval.h
+ ftgzip.h
+ ftimage.h
+ ftincrem.h
+ ftlcdfil.h
+ ftlist.h
+ ftlzw.h
+ ftmac.h
+ ftmm.h
+ ftmodapi.h
+ ftmoderr.h
+ ftotval.h
+ ftoutln.h
+ ftpfr.h
+ ftrender.h
+ ftsizes.h
+ ftsnames.h
+ ftstroke.h
+ ftsynth.h
+ ftsystem.h
+ fttrigon.h
+ fttypes.h
+ ftwinfnt.h
+ ftxf86.h
+ internal/
+0 autohint.h
+ ftcalc.h
+ ftdebug.h
+ ftdriver.h
+ ftgloadr.h
+ ftmemory.h
+ ftobjs.h
+ ftrfork.h
+ ftserv.h
+ ftstream.h
+ fttrace.h
+ ftvalid.h
+ internal.h
+ pcftypes.h
+ psaux.h
+ pshints.h
+ services/
+0 svbdf.h
+ svcid.h
+ svgldict.h
+ svgxval.h
+ svkern.h
+ svmm.h
+ svotval.h
+ svpfr.h
+ svpostnm.h
+ svpscmap.h
+ svpsinfo.h
+ svsfnt.h
+ svttcmap.h
+ svtteng.h
+ svttglyf.h
+ svwinfnt.h
+ svxf86nm.h
+2 sfnt.h
+ t1types.h
+ tttypes.h
+2 t1tables.h
+ ttnameid.h
+ tttables.h
+ tttags.h
+ ttunpat.h
+2 ft2build.h
+2 Jamfile
+ Jamrules
+ Makefile
+ modules.cfg
+ objs/
+0 README
+2 README
+0 .CVS
+2 src/
+0 autofit/
+0 afangles.c
+ afangles.h
+ afcjk.c
+ afcjk.h
+ afdummy.c
+ afdummy.h
+ aferrors.h
+ afglobal.c
+ afglobal.h
+ afhints.c
+ afhints.h
+ afindic.c
+ afindic.h
+ aflatin2.c
+ aflatin2.h
+ aflatin.c
+ aflatin.h
+ afloader.c
+ afloader.h
+ afmodule.c
+ afmodule.h
+ aftypes.h
+ afwarp.c
+ afwarp.h
+ autofit.c
+ Jamfile
+ module.mk
+ rules.mk
+2 base/
+0 ftadvanc.c
+ ftapi.c
+ ftbase.c
+ ftbase.h
+ ftbbox.c
+ ftbdf.c
+ ftbitmap.c
+ ftcalc.c
+ ftcid.c
+ ftdbgmem.c
+ ftdebug.c
+ ftfstype.c
+ ftgasp.c
+ ftgloadr.c
+ ftglyph.c
+ ftgxval.c
+ ftinit.c
+ ftlcdfil.c
+ ftmac.c
+ ftmm.c
+ ftnames.c
+ ftobjs.c
+ ftotval.c
+ ftoutln.c
+ ftpatent.c
+ ftpfr.c
+ ftrfork.c
+ ftstream.c
+ ftstroke.c
+ ftsynth.c
+ ftsystem.c
+ fttrigon.c
+ fttype1.c
+ ftutil.c
+ ftwinfnt.c
+ ftxf86.c
+ Jamfile
+ rules.mk
+2 bdf/
+0 bdf.c
+ bdfdrivr.c
+ bdfdrivr.h
+ bdferror.h
+ bdf.h
+ bdflib.c
+ Jamfile
+ module.mk
+ README
+ rules.mk
+2 cache/
+0 ftcache.c
+ ftcbasic.c
+ ftccache.c
+ ftccache.h
+ ftccback.h
+ ftccmap.c
+ ftcerror.h
+ ftcglyph.c
+ ftcglyph.h
+ ftcimage.c
+ ftcimage.h
+ ftcmanag.c
+ ftcmanag.h
+ ftcmru.c
+ ftcmru.h
+ ftcsbits.c
+ ftcsbits.h
+ Jamfile
+ rules.mk
+2 cff/
+0 cff.c
+ cffcmap.c
+ cffcmap.h
+ cffdrivr.c
+ cffdrivr.h
+ cfferrs.h
+ cffgload.c
+ cffgload.h
+ cffload.c
+ cffload.h
+ cffobjs.c
+ cffobjs.h
+ cffparse.c
+ cffparse.h
+ cfftoken.h
+ cfftypes.h
+ Jamfile
+ module.mk
+ rules.mk
+2 cid/
+0 ciderrs.h
+ cidgload.c
+ cidgload.h
+ cidload.c
+ cidload.h
+ cidobjs.c
+ cidobjs.h
+ cidparse.c
+ cidparse.h
+ cidriver.c
+ cidriver.h
+ cidtoken.h
+ Jamfile
+ module.mk
+ rules.mk
+ type1cid.c
+2 gxvalid/
+0 gxvalid.c
+ gxvalid.h
+ gxvbsln.c
+ gxvcommn.c
+ gxvcommn.h
+ gxverror.h
+ gxvfeat.c
+ gxvfeat.h
+ gxvfgen.c
+ gxvjust.c
+ gxvkern.c
+ gxvlcar.c
+ gxvmod.c
+ gxvmod.h
+ gxvmort0.c
+ gxvmort1.c
+ gxvmort2.c
+ gxvmort4.c
+ gxvmort5.c
+ gxvmort.c
+ gxvmort.h
+ gxvmorx0.c
+ gxvmorx1.c
+ gxvmorx2.c
+ gxvmorx4.c
+ gxvmorx5.c
+ gxvmorx.c
+ gxvmorx.h
+ gxvopbd.c
+ gxvprop.c
+ gxvtrak.c
+ Jamfile
+ module.mk
+ README
+ rules.mk
+2 gzip/
+0 adler32.c
+ ftgzip.c
+ infblock.c
+ infblock.h
+ infcodes.c
+ infcodes.h
+ inffixed.h
+ inflate.c
+ inftrees.c
+ inftrees.h
+ infutil.c
+ infutil.h
+ Jamfile
+ rules.mk
+ zconf.h
+ zlib.h
+ zutil.c
+ zutil.h
+2 Jamfile
+ lzw/
+0 ftlzw.c
+ ftzopen.c
+ ftzopen.h
+ Jamfile
+ rules.mk
+2 otvalid/
+0 Jamfile
+ module.mk
+ otvalid.c
+ otvalid.h
+ otvbase.c
+ otvcommn.c
+ otvcommn.h
+ otverror.h
+ otvgdef.c
+ otvgpos.c
+ otvgpos.h
+ otvgsub.c
+ otvjstf.c
+ otvmath.c
+ otvmod.c
+ otvmod.h
+ rules.mk
+2 pcf/
+0 Jamfile
+ module.mk
+ pcf.c
+ pcfdrivr.c
+ pcfdrivr.h
+ pcferror.h
+ pcf.h
+ pcfread.c
+ pcfread.h
+ pcfutil.c
+ pcfutil.h
+ README
+ rules.mk
+2 pfr/
+0 Jamfile
+ module.mk
+ pfr.c
+ pfrcmap.c
+ pfrcmap.h
+ pfrdrivr.c
+ pfrdrivr.h
+ pfrerror.h
+ pfrgload.c
+ pfrgload.h
+ pfrload.c
+ pfrload.h
+ pfrobjs.c
+ pfrobjs.h
+ pfrsbit.c
+ pfrsbit.h
+ pfrtypes.h
+ rules.mk
+2 psaux/
+0 afmparse.c
+ afmparse.h
+ Jamfile
+ module.mk
+ psaux.c
+ psauxerr.h
+ psauxmod.c
+ psauxmod.h
+ psconv.c
+ psconv.h
+ psobjs.c
+ psobjs.h
+ rules.mk
+ t1cmap.c
+ t1cmap.h
+ t1decode.c
+ t1decode.h
+2 pshinter/
+0 Jamfile
+ module.mk
+ pshalgo.c
+ pshalgo.h
+ pshglob.c
+ pshglob.h
+ pshinter.c
+ pshmod.c
+ pshmod.h
+ pshnterr.h
+ pshrec.c
+ pshrec.h
+ rules.mk
+2 psnames/
+0 Jamfile
+ module.mk
+ psmodule.c
+ psmodule.h
+ psnamerr.h
+ psnames.c
+ pstables.h
+ rules.mk
+2 raster/
+0 ftmisc.h
+ ftraster.c
+ ftraster.h
+ ftrend1.c
+ ftrend1.h
+ Jamfile
+ module.mk
+ raster.c
+ rasterrs.h
+ rules.mk
+2 sfnt/
+0 Jamfile
+ module.mk
+ rules.mk
+ sfdriver.c
+ sfdriver.h
+ sferrors.h
+ sfnt.c
+ sfobjs.c
+ sfobjs.h
+ ttbdf.c
+ ttbdf.h
+ ttcmap.c
+ ttcmap.h
+ ttkern.c
+ ttkern.h
+ ttload.c
+ ttload.h
+ ttmtx.c
+ ttmtx.h
+ ttpost.c
+ ttpost.h
+ ttsbit0.c
+ ttsbit.c
+ ttsbit.h
+2 smooth/
+0 ftgrays.c
+ ftgrays.h
+ ftsmerrs.h
+ ftsmooth.c
+ ftsmooth.h
+ Jamfile
+ module.mk
+ rules.mk
+ smooth.c
+2 tools/
+0 apinames.c
+ cordic.py
+ docmaker/
+0 content.py
+ docbeauty.py
+ docmaker.py
+ formatter.py
+ sources.py
+ tohtml.py
+ utils.py
+2 ftrandom/
+0 ftrandom.c
+ Makefile
+ README
+2 glnames.py
+ Jamfile
+ test_afm.c
+ test_bbox.c
+ test_trig.c
+2 truetype/
+0 Jamfile
+ module.mk
+ rules.mk
+ truetype.c
+ ttdriver.c
+ ttdriver.h
+ tterrors.h
+ ttgload.c
+ ttgload.h
+ ttgxvar.c
+ ttgxvar.h
+ ttinterp.c
+ ttinterp.h
+ ttobjs.c
+ ttobjs.h
+ ttpload.c
+ ttpload.h
+2 type1/
+0 Jamfile
+ module.mk
+ rules.mk
+ t1afm.c
+ t1afm.h
+ t1driver.c
+ t1driver.h
+ t1errors.h
+ t1gload.c
+ t1gload.h
+ t1load.c
+ t1load.h
+ t1objs.c
+ t1objs.h
+ t1parse.c
+ t1parse.h
+ t1tokens.h
+ type1.c
+2 type42/
+0 Jamfile
+ module.mk
+ rules.mk
+ t42drivr.c
+ t42drivr.h
+ t42error.h
+ t42objs.c
+ t42objs.h
+ t42parse.c
+ t42parse.h
+ t42types.h
+ type42.c
+2 winfonts/
+0 fnterrs.h
+ Jamfile
+ module.mk
+ rules.mk
+ winfnt.c
+ winfnt.h
+3 version.sed
+ vms_make.com
+2 .gitattributes
+ harfbuzz/
+0 AUTHORS
+ autogen.sh
+ ChangeLog
+ configure.ac
+ COPYING
+ .gitignore
+ Makefile.am
+ NEWS
+ README
+ src/
+0 .gitignore
+ harfbuzz-arabic.c
+ harfbuzz-buffer.c
+ harfbuzz-buffer.h
+ harfbuzz-buffer-private.h
+ harfbuzz.c
+ harfbuzz-dump.c
+ harfbuzz-dump.h
+ harfbuzz-dump-main.c
+ harfbuzz-external.h
+ harfbuzz-gdef.c
+ harfbuzz-gdef.h
+ harfbuzz-gdef-private.h
+ harfbuzz-global.h
+ harfbuzz-gpos.c
+ harfbuzz-gpos.h
+ harfbuzz-gpos-private.h
+ harfbuzz-gsub.c
+ harfbuzz-gsub.h
+ harfbuzz-gsub-private.h
+ harfbuzz.h
+ harfbuzz-hangul.c
+ harfbuzz-hebrew.c
+ harfbuzz-impl.c
+ harfbuzz-impl.h
+ harfbuzz-indic.cpp
+ harfbuzz-khmer.c
+ harfbuzz-myanmar.c
+ harfbuzz-open.c
+ harfbuzz-open.h
+ harfbuzz-open-private.h
+ harfbuzz-shape.h
+ harfbuzz-shaper-all.cpp
+ harfbuzz-shaper.cpp
+ harfbuzz-shaper.h
+ harfbuzz-shaper-private.h
+ harfbuzz-stream.c
+ harfbuzz-stream.h
+ harfbuzz-stream-private.h
+ harfbuzz-thai.c
+ harfbuzz-tibetan.c
+ Makefile.am
+2 tests/
+0 linebreaking/
+0 .gitignore
+ harfbuzz-qt.cpp
+ main.cpp
+ Makefile.am
+2 Makefile.am
+ shaping/
+0 .gitignore
+ main.cpp
+ Makefile.am
+ README
+4 javascriptcore/
+0 JavaScriptCore/
+0 API/
+0 APICast.h
+ JavaScriptCore.h
+ JavaScript.h
+ JSBase.cpp
+ JSBase.h
+ JSBasePrivate.h
+ JSCallbackConstructor.cpp
+ JSCallbackConstructor.h
+ JSCallbackFunction.cpp
+ JSCallbackFunction.h
+ JSCallbackObject.cpp
+ JSCallbackObjectFunctions.h
+ JSCallbackObject.h
+ JSClassRef.cpp
+ JSClassRef.h
+ JSContextRef.cpp
+ JSContextRef.h
+ JSObjectRef.cpp
+ JSObjectRef.h
+ JSProfilerPrivate.cpp
+ JSProfilerPrivate.h
+ JSRetainPtr.h
+ JSStringRefBSTR.cpp
+ JSStringRefBSTR.h
+ JSStringRefCF.cpp
+ JSStringRefCF.h
+ JSStringRef.cpp
+ JSStringRef.h
+ JSValueRef.cpp
+ JSValueRef.h
+ OpaqueJSString.cpp
+ OpaqueJSString.h
+ WebKitAvailability.h
+2 assembler/
+0 AbstractMacroAssembler.h
+ ARMAssembler.cpp
+ ARMAssembler.h
+ ARMv7Assembler.h
+ AssemblerBuffer.h
+ AssemblerBufferWithConstantPool.h
+ CodeLocation.h
+ LinkBuffer.h
+ MacroAssemblerARM.cpp
+ MacroAssemblerARM.h
+ MacroAssemblerARMv7.h
+ MacroAssemblerCodeRef.h
+ MacroAssembler.h
+ MacroAssemblerX86_64.h
+ MacroAssemblerX86Common.h
+ MacroAssemblerX86.h
+ RepatchBuffer.h
+ X86Assembler.h
+2 AUTHORS
+ bytecode/
+0 CodeBlock.cpp
+ CodeBlock.h
+ EvalCodeCache.h
+ Instruction.h
+ JumpTable.cpp
+ JumpTable.h
+ Opcode.cpp
+ Opcode.h
+ SamplingTool.cpp
+ SamplingTool.h
+ StructureStubInfo.cpp
+ StructureStubInfo.h
+2 bytecompiler/
+0 BytecodeGenerator.cpp
+ BytecodeGenerator.h
+ Label.h
+ LabelScope.h
+ RegisterID.h
+2 ChangeLog
+0 -2002-12-03
+ -2003-10-25
+ -2007-10-14
+ -2008-08-10
+ -2009-06-16
+2 config.h
+ COPYING.LIB
+ create_hash_table
+ debugger/
+0 DebuggerActivation.cpp
+ DebuggerActivation.h
+ DebuggerCallFrame.cpp
+ DebuggerCallFrame.h
+ Debugger.cpp
+ Debugger.h
+2 DerivedSources.make
+ docs/
+0 make-bytecode-docs.pl
+2 ForwardingHeaders/
+0 JavaScriptCore/
+0 APICast.h
+ JavaScriptCore.h
+ JavaScript.h
+ JSBase.h
+ JSContextRef.h
+ JSObjectRef.h
+ JSRetainPtr.h
+ JSStringRefCF.h
+ JSStringRef.h
+ JSValueRef.h
+ OpaqueJSString.h
+ WebKitAvailability.h
+3 generated/
+0 ArrayPrototype.lut.h
+ chartables.c
+ DatePrototype.lut.h
+ Grammar.cpp
+ Grammar.h
+ JSONObject.lut.h
+ Lexer.lut.h
+ MathObject.lut.h
+ NumberConstructor.lut.h
+ RegExpConstructor.lut.h
+ RegExpObject.lut.h
+ StringPrototype.lut.h
+2 headers.pri
+ Info.plist
+ interpreter/
+0 CachedCall.h
+ CallFrameClosure.h
+ CallFrame.cpp
+ CallFrame.h
+ Interpreter.cpp
+ Interpreter.h
+ RegisterFile.cpp
+ RegisterFile.h
+ Register.h
+2 JavaScriptCore.gypi
+ JavaScriptCore.order
+ JavaScriptCorePrefix.h
+ JavaScriptCore.pri
+ jit/
+0 ExecutableAllocator.cpp
+ ExecutableAllocatorFixedVMPool.cpp
+ ExecutableAllocator.h
+ ExecutableAllocatorPosix.cpp
+ ExecutableAllocatorWin.cpp
+ JITArithmetic.cpp
+ JITCall.cpp
+ JITCode.h
+ JIT.cpp
+ JIT.h
+ JITInlineMethods.h
+ JITOpcodes.cpp
+ JITPropertyAccess.cpp
+ JITStubCall.h
+ JITStubs.cpp
+ JITStubs.h
+2 jsc.cpp
+ make-generated-sources.sh
+ os-win32/
+0 stdbool.h
+ stdint.h
+2 parser/
+0 Grammar.y
+ Keywords.table
+ Lexer.cpp
+ Lexer.h
+ NodeConstructors.h
+ NodeInfo.h
+ Nodes.cpp
+ Nodes.h
+ ParserArena.cpp
+ ParserArena.h
+ Parser.cpp
+ Parser.h
+ ResultType.h
+ SourceCode.h
+ SourceProvider.h
+2 pcre/
+0 AUTHORS
+ COPYING
+ dftables
+ pcre_compile.cpp
+ pcre_exec.cpp
+ pcre.h
+ pcre_internal.h
+ pcre.pri
+ pcre_tables.cpp
+ pcre_ucp_searchfuncs.cpp
+ pcre_xclass.cpp
+ ucpinternal.h
+ ucptable.cpp
+2 profiler/
+0 CallIdentifier.h
+ HeavyProfile.cpp
+ HeavyProfile.h
+ Profile.cpp
+ ProfileGenerator.cpp
+ ProfileGenerator.h
+ Profile.h
+ ProfileNode.cpp
+ ProfileNode.h
+ Profiler.cpp
+ Profiler.h
+ ProfilerServer.h
+ ProfilerServer.mm
+ TreeProfile.cpp
+ TreeProfile.h
+2 runtime/
+0 ArgList.cpp
+ ArgList.h
+ Arguments.cpp
+ Arguments.h
+ ArrayConstructor.cpp
+ ArrayConstructor.h
+ ArrayPrototype.cpp
+ ArrayPrototype.h
+ BatchedTransitionOptimizer.h
+ BooleanConstructor.cpp
+ BooleanConstructor.h
+ BooleanObject.cpp
+ BooleanObject.h
+ BooleanPrototype.cpp
+ BooleanPrototype.h
+ CallData.cpp
+ CallData.h
+ ClassInfo.h
+ Collector.cpp
+ Collector.h
+ CollectorHeapIterator.h
+ CommonIdentifiers.cpp
+ CommonIdentifiers.h
+ Completion.cpp
+ Completion.h
+ ConstructData.cpp
+ ConstructData.h
+ DateConstructor.cpp
+ DateConstructor.h
+ DateConversion.cpp
+ DateConversion.h
+ DateInstance.cpp
+ DateInstance.h
+ DatePrototype.cpp
+ DatePrototype.h
+ ErrorConstructor.cpp
+ ErrorConstructor.h
+ Error.cpp
+ Error.h
+ ErrorInstance.cpp
+ ErrorInstance.h
+ ErrorPrototype.cpp
+ ErrorPrototype.h
+ ExceptionHelpers.cpp
+ ExceptionHelpers.h
+ Executable.cpp
+ Executable.h
+ FunctionConstructor.cpp
+ FunctionConstructor.h
+ FunctionPrototype.cpp
+ FunctionPrototype.h
+ GetterSetter.cpp
+ GetterSetter.h
+ GlobalEvalFunction.cpp
+ GlobalEvalFunction.h
+ Identifier.cpp
+ Identifier.h
+ InitializeThreading.cpp
+ InitializeThreading.h
+ InternalFunction.cpp
+ InternalFunction.h
+ JSActivation.cpp
+ JSActivation.h
+ JSAPIValueWrapper.cpp
+ JSAPIValueWrapper.h
+ JSArray.cpp
+ JSArray.h
+ JSByteArray.cpp
+ JSByteArray.h
+ JSCell.cpp
+ JSCell.h
+ JSFunction.cpp
+ JSFunction.h
+ JSGlobalData.cpp
+ JSGlobalData.h
+ JSGlobalObject.cpp
+ JSGlobalObjectFunctions.cpp
+ JSGlobalObjectFunctions.h
+ JSGlobalObject.h
+ JSImmediate.cpp
+ JSImmediate.h
+ JSLock.cpp
+ JSLock.h
+ JSNotAnObject.cpp
+ JSNotAnObject.h
+ JSNumberCell.cpp
+ JSNumberCell.h
+ JSObject.cpp
+ JSObject.h
+ JSONObject.cpp
+ JSONObject.h
+ JSPropertyNameIterator.cpp
+ JSPropertyNameIterator.h
+ JSStaticScopeObject.cpp
+ JSStaticScopeObject.h
+ JSString.cpp
+ JSString.h
+ JSType.h
+ JSTypeInfo.h
+ JSValue.cpp
+ JSValue.h
+ JSVariableObject.cpp
+ JSVariableObject.h
+ JSWrapperObject.cpp
+ JSWrapperObject.h
+ LiteralParser.cpp
+ LiteralParser.h
+ Lookup.cpp
+ Lookup.h
+ MarkStack.cpp
+ MarkStack.h
+ MarkStackPosix.cpp
+ MarkStackWin.cpp
+ MathObject.cpp
+ MathObject.h
+ NativeErrorConstructor.cpp
+ NativeErrorConstructor.h
+ NativeErrorPrototype.cpp
+ NativeErrorPrototype.h
+ NativeFunctionWrapper.h
+ NumberConstructor.cpp
+ NumberConstructor.h
+ NumberObject.cpp
+ NumberObject.h
+ NumberPrototype.cpp
+ NumberPrototype.h
+ NumericStrings.h
+ ObjectConstructor.cpp
+ ObjectConstructor.h
+ ObjectPrototype.cpp
+ ObjectPrototype.h
+ Operations.cpp
+ Operations.h
+ PropertyDescriptor.cpp
+ PropertyDescriptor.h
+ PropertyMapHashTable.h
+ PropertyNameArray.cpp
+ PropertyNameArray.h
+ PropertySlot.cpp
+ PropertySlot.h
+ Protect.h
+ PrototypeFunction.cpp
+ PrototypeFunction.h
+ PutPropertySlot.h
+ RegExpConstructor.cpp
+ RegExpConstructor.h
+ RegExp.cpp
+ RegExp.h
+ RegExpMatchesArray.h
+ RegExpObject.cpp
+ RegExpObject.h
+ RegExpPrototype.cpp
+ RegExpPrototype.h
+ ScopeChain.cpp
+ ScopeChain.h
+ ScopeChainMark.h
+ SmallStrings.cpp
+ SmallStrings.h
+ StringConstructor.cpp
+ StringConstructor.h
+ StringObject.cpp
+ StringObject.h
+ StringObjectThatMasqueradesAsUndefined.h
+ StringPrototype.cpp
+ StringPrototype.h
+ StructureChain.cpp
+ StructureChain.h
+ Structure.cpp
+ Structure.h
+ StructureTransitionTable.h
+ SymbolTable.h
+ TimeoutChecker.cpp
+ TimeoutChecker.h
+ Tracing.h
+ UString.cpp
+ UString.h
+2 THANKS
+ wrec/
+0 CharacterClassConstructor.cpp
+ CharacterClassConstructor.h
+ CharacterClass.cpp
+ CharacterClass.h
+ Escapes.h
+ Quantifier.h
+ WREC.cpp
+ WRECFunctors.cpp
+ WRECFunctors.h
+ WRECGenerator.cpp
+ WRECGenerator.h
+ WREC.h
+ WRECParser.cpp
+ WRECParser.h
+2 wscript
+ wtf/
+0 AlwaysInline.h
+ ASCIICType.h
+ Assertions.cpp
+ Assertions.h
+ AVLTree.h
+ ByteArray.cpp
+ ByteArray.h
+ CONTRIBUTORS.pthreads-win32
+ CrossThreadRefCounted.h
+ CurrentTime.cpp
+ CurrentTime.h
+ DateMath.cpp
+ DateMath.h
+ Deque.h
+ DisallowCType.h
+ dtoa.cpp
+ dtoa.h
+ FastAllocBase.h
+ FastMalloc.cpp
+ FastMalloc.h
+ Forward.h
+ GetPtr.h
+ GOwnPtr.cpp
+ GOwnPtr.h
+ HashCountedSet.h
+ HashFunctions.h
+ HashIterators.h
+ HashMap.h
+ HashSet.h
+ HashTable.cpp
+ HashTable.h
+ HashTraits.h
+ ListHashSet.h
+ ListRefPtr.h
+ Locker.h
+ MainThread.cpp
+ MainThread.h
+ MallocZoneSupport.h
+ MathExtras.h
+ MessageQueue.h
+ Noncopyable.h
+ NotFound.h
+ OwnArrayPtr.h
+ OwnFastMallocPtr.h
+ OwnPtrCommon.h
+ OwnPtr.h
+ OwnPtrWin.cpp
+ PassOwnPtr.h
+ PassRefPtr.h
+ Platform.h
+ PossiblyNull.h
+ PtrAndFlags.h
+ qt/
+0 MainThreadQt.cpp
+ ThreadingQt.cpp
+2 RandomNumber.cpp
+ RandomNumber.h
+ RandomNumberSeed.h
+ RefCounted.h
+ RefCountedLeakCounter.cpp
+ RefCountedLeakCounter.h
+ RefPtr.h
+ RefPtrHashMap.h
+ RetainPtr.h
+ SegmentedVector.h
+ StdLibExtras.h
+ StringExtras.h
+ TCPackedCache.h
+ TCPageMap.h
+ TCSpinLock.h
+ TCSystemAlloc.cpp
+ TCSystemAlloc.h
+ Threading.cpp
+ Threading.h
+ ThreadingNone.cpp
+ ThreadingPthreads.cpp
+ ThreadingWin.cpp
+ ThreadSpecific.h
+ ThreadSpecificWin.cpp
+ TypeTraits.cpp
+ TypeTraits.h
+ unicode/
+0 CollatorDefault.cpp
+ Collator.h
+ glib/
+0 UnicodeGLib.cpp
+ UnicodeGLib.h
+ UnicodeMacrosFromICU.h
+2 icu/
+0 CollatorICU.cpp
+ UnicodeIcu.h
+2 qt4/
+0 UnicodeQt4.h
+2 Unicode.h
+ UTF8.cpp
+ UTF8.h
+ wince/
+0 UnicodeWince.cpp
+ UnicodeWince.h
+3 UnusedParam.h
+ Vector.h
+ VectorTraits.h
+ VMTags.h
+ wince/
+0 FastMallocWince.h
+ MemoryManager.cpp
+ MemoryManager.h
+ mt19937ar.c
+3 yarr/
+0 RegexCompiler.cpp
+ RegexCompiler.h
+ RegexInterpreter.cpp
+ RegexInterpreter.h
+ RegexJIT.cpp
+ RegexJIT.h
+ RegexParser.h
+ RegexPattern.h
+3 VERSION
+ WebKit.pri
+2 libjpeg/
+0 change.log
+ coderules.doc
+ filelist.doc
+ install.doc
+ jcapimin.c
+ jcapistd.c
+ jccoefct.c
+ jccolor.c
+ jcdctmgr.c
+ jchuff.c
+ jchuff.h
+ jcinit.c
+ jcmainct.c
+ jcmarker.c
+ jcmaster.c
+ jcomapi.c
+ jconfig.bcc
+ jconfig.cfg
+ jconfig.dj
+ jconfig.doc
+ jconfig.h
+ jconfig.mac
+ jconfig.manx
+ jconfig.mc6
+ jconfig.sas
+ jconfig.st
+ jconfig.vc
+ jconfig.vms
+ jconfig.wat
+ jcparam.c
+ jcphuff.c
+ jcprepct.c
+ jcsample.c
+ jctrans.c
+ jdapimin.c
+ jdapistd.c
+ jdatadst.c
+ jdatasrc.c
+ jdcoefct.c
+ jdcolor.c
+ jdct.h
+ jddctmgr.c
+ jdhuff.c
+ jdhuff.h
+ jdinput.c
+ jdmainct.c
+ jdmarker.c
+ jdmaster.c
+ jdmerge.c
+ jdphuff.c
+ jdpostct.c
+ jdsample.c
+ jdtrans.c
+ jerror.c
+ jerror.h
+ jfdctflt.c
+ jfdctfst.c
+ jfdctint.c
+ jidctflt.c
+ jidctfst.c
+ jidctint.c
+ jidctred.c
+ jinclude.h
+ jmemmgr.c
+ jmemnobs.c
+ jmemsys.h
+ jmorecfg.h
+ jpegint.h
+ jpeglib.h
+ jquant1.c
+ jquant2.c
+ jutils.c
+ jversion.h
+ libjpeg.doc
+ makefile.ansi
+ makefile.bcc
+ makefile.cfg
+ makefile.dj
+ makefile.manx
+ makefile.mc6
+ makefile.mms
+ makefile.sas
+ makefile.unix
+ makefile.vc
+ makefile.vms
+ makefile.wat
+ README
+ structure.doc
+ usage.doc
+ wizard.doc
+2 libmng/
+0 CHANGES
+ doc/
+0 doc.readme
+ libmng.txt
+ man/
+0 jng.5
+ libmng.3
+ mng.5
+2 misc/
+0 magic.dif
+2 Plan1.png
+ Plan2.png
+ rpm/
+0 libmng-1.0.10-rhconf.patch
+ libmng.spec
+3 libmng_callback_xs.c
+ libmng_chunk_descr.c
+ libmng_chunk_descr.h
+ libmng_chunk_io.c
+ libmng_chunk_io.h
+ libmng_chunk_prc.c
+ libmng_chunk_prc.h
+ libmng_chunks.h
+ libmng_chunk_xs.c
+ libmng_cms.c
+ libmng_cms.h
+ libmng_conf.h
+ libmng_data.h
+ libmng_display.c
+ libmng_display.h
+ libmng_dither.c
+ libmng_dither.h
+ libmng_error.c
+ libmng_error.h
+ libmng_filter.c
+ libmng_filter.h
+ libmng.h
+ libmng_hlapi.c
+ libmng_jpeg.c
+ libmng_jpeg.h
+ libmng_memory.h
+ libmng_object_prc.c
+ libmng_object_prc.h
+ libmng_objects.h
+ libmng_pixels.c
+ libmng_pixels.h
+ libmng_prop_xs.c
+ libmng_read.c
+ libmng_read.h
+ libmng_trace.c
+ libmng_trace.h
+ libmng_types.h
+ libmng_write.c
+ libmng_write.h
+ libmng_zlib.c
+ libmng_zlib.h
+ LICENSE
+ makefiles/
+0 configure.in
+ Makefile.am
+ makefile.bcb3
+ makefile.dj
+ makefile.linux
+ makefile.mingw
+0 dll
+2 makefile.qnx
+ makefile.unix
+ makefile.vcwin32
+ README
+2 README
+0 .autoconf
+ .config
+ .contrib
+ .dll
+ .examples
+ .footprint
+ .packaging
+2 unmaintained/
+0 autogen.sh
+3 libpng/
+0 ANNOUNCE
+ CHANGES
+ configure
+ example.c
+ INSTALL
+ KNOWNBUG
+ libpng-1.2.40.txt
+ libpng.3
+ libpngpf.3
+ LICENSE
+ png.5
+ pngbar.jpg
+ pngbar.png
+ png.c
+ pngconf.h
+ pngerror.c
+ pnggccrd.c
+ pngget.c
+ png.h
+ pngmem.c
+ pngnow.png
+ pngpread.c
+ pngread.c
+ pngrio.c
+ pngrtran.c
+ pngrutil.c
+ pngset.c
+ pngtest.c
+ pngtest.png
+ pngtrans.c
+ pngvcrd.c
+ pngwio.c
+ pngwrite.c
+ pngwtran.c
+ pngwutil.c
+ projects/
+0 beos/
+0 x86-shared.proj
+ x86-shared.txt
+ x86-static.proj
+ x86-static.txt
+2 cbuilder5/
+0 libpng.bpf
+ libpng.bpg
+ libpng.bpr
+ libpng.cpp
+ libpng.readme.txt
+ libpngstat.bpf
+ libpngstat.bpr
+ zlib.readme.txt
+2 netware.txt
+ visualc6/
+0 libpng.dsp
+ libpng.dsw
+ pngtest.dsp
+ README.txt
+2 visualc71/
+0 libpng.sln
+ libpng.vcproj
+ pngtest.vcproj
+ PRJ0041.mak
+ README.txt
+ README_zlib.txt
+ zlib.vcproj
+2 wince.txt
+2 README
+ scripts/
+0 CMakeLists.txt
+ descrip.mms
+ libpng-config-body.in
+ libpng-config-head.in
+ libpng-config.in
+ libpng.icc
+ libpng.pc-configure.in
+ libpng.pc.in
+ makefile.32sunu
+ makefile.64sunu
+ makefile.acorn
+ makefile.aix
+ makefile.amiga
+ makefile.atari
+ makefile.bc32
+ makefile.beos
+ makefile.bor
+ makefile.cygwin
+ makefile.darwin
+ makefile.dec
+ makefile.dj2
+ makefile.elf
+ makefile.freebsd
+ makefile.gcc
+ makefile.gcmmx
+ makefile.hp64
+ makefile.hpgcc
+ makefile.hpux
+ makefile.ibmc
+ makefile.intel
+ makefile.knr
+ makefile.linux
+ makefile.mingw
+ makefile.mips
+ makefile.msc
+ makefile.ne12bsd
+ makefile.netbsd
+ makefile.nommx
+ makefile.openbsd
+ makefile.os2
+ makefile.sco
+ makefile.sggcc
+ makefile.sgi
+ makefile.so9
+ makefile.solaris
+0 -x86
+2 makefile.std
+ makefile.sunos
+ makefile.tc3
+ makefile.vcawin32
+ makefile.vcwin32
+ makefile.watcom
+ makevms.com
+ pngos2.def
+ pngw32.def
+ pngw32.rc
+ SCOPTIONS.ppc
+ smakefile.ppc
+2 TODO
+ Y2KINFO
+2 libtiff/
+0 aclocal.m4
+ autogen.sh
+ ChangeLog
+ config/
+0 compile
+ config.guess
+ config.sub
+ depcomp
+ install-sh
+ ltmain.sh
+ missing
+ mkinstalldirs
+2 configure
+0 .ac
+2 COPYRIGHT
+ HOWTO-RELEASE
+ html/
+0 addingtags.html
+ bugs.html
+ build.html
+ contrib.html
+ document.html
+ images/
+0 back.gif
+ bali.jpg
+ cat.gif
+ cover.jpg
+ cramps.gif
+ dave.gif
+2 images.html
+ images/info.gif
+ images/jello.jpg
+ images/jim.gif
+ images/Makefile.am
+ images/Makefile.in
+ images/note.gif
+ images/oxford.gif
+ images/quad.jpg
+ images/ring.gif
+ images/smallliz.jpg
+ images/strike.gif
+ images/warning.gif
+ index.html
+ internals.html
+ intro.html
+ libtiff.html
+ Makefile.am
+ Makefile.in
+ man/
+0 fax2ps.1.html
+ fax2tiff.1.html
+ gif2tiff.1.html
+ index.html
+ libtiff.3tiff.html
+ Makefile.am
+ Makefile.in
+ pal2rgb.1.html
+ ppm2tiff.1.html
+ ras2tiff.1.html
+ raw2tiff.1.html
+ rgb2ycbcr.1.html
+ sgi2tiff.1.html
+ thumbnail.1.html
+ tiff2bw.1.html
+ tiff2pdf.1.html
+ tiff2ps.1.html
+ tiff2rgba.1.html
+ TIFFbuffer.3tiff.html
+ TIFFClose.3tiff.html
+ tiffcmp.1.html
+ TIFFcodec.3tiff.html
+ TIFFcolor.3tiff.html
+ tiffcp.1.html
+ TIFFDataWidth.3tiff.html
+ tiffdither.1.html
+ tiffdump.1.html
+ TIFFError.3tiff.html
+ TIFFFlush.3tiff.html
+ TIFFGetField.3tiff.html
+ tiffgt.1.html
+ tiffinfo.1.html
+ tiffmedian.1.html
+ TIFFmemory.3tiff.html
+ TIFFOpen.3tiff.html
+ TIFFPrintDirectory.3tiff.html
+ TIFFquery.3tiff.html
+ TIFFReadDirectory.3tiff.html
+ TIFFReadEncodedStrip.3tiff.html
+ TIFFReadEncodedTile.3tiff.html
+ TIFFReadRawStrip.3tiff.html
+ TIFFReadRawTile.3tiff.html
+ TIFFReadRGBAImage.3tiff.html
+ TIFFReadRGBAStrip.3tiff.html
+ TIFFReadRGBATile.3tiff.html
+ TIFFReadScanline.3tiff.html
+ TIFFReadTile.3tiff.html
+ TIFFRGBAImage.3tiff.html
+ tiffset.1.html
+ TIFFSetDirectory.3tiff.html
+ TIFFSetField.3tiff.html
+ TIFFsize.3tiff.html
+ tiffsplit.1.html
+ TIFFstrip.3tiff.html
+ tiffsv.1.html
+ TIFFswab.3tiff.html
+ TIFFtile.3tiff.html
+ TIFFWarning.3tiff.html
+ TIFFWriteDirectory.3tiff.html
+ TIFFWriteEncodedStrip.3tiff.html
+ TIFFWriteEncodedTile.3tiff.html
+ TIFFWriteRawStrip.3tiff.html
+ TIFFWriteRawTile.3tiff.html
+ TIFFWriteScanline.3tiff.html
+ TIFFWriteTile.3tiff.html
+2 misc.html
+ support.html
+ TIFFTechNote2.html
+ tools.html
+ v3.4beta007.html
+ v3.4beta016.html
+ v3.4beta018.html
+ v3.4beta024.html
+ v3.4beta028.html
+ v3.4beta029.html
+ v3.4beta031.html
+ v3.4beta032.html
+ v3.4beta033.html
+ v3.4beta034.html
+ v3.4beta035.html
+ v3.4beta036.html
+ v3.5.1.html
+ v3.5.2.html
+ v3.5.3.html
+ v3.5.4.html
+ v3.5.5.html
+ v3.5.6-beta.html
+ v3.5.7.html
+ v3.6.0.html
+ v3.6.1.html
+ v3.7.0alpha.html
+ v3.7.0beta2.html
+ v3.7.0beta.html
+ v3.7.0.html
+ v3.7.1.html
+ v3.7.2.html
+ v3.7.3.html
+ v3.7.4.html
+ v3.8.0.html
+ v3.8.1.html
+ v3.8.2.html
+2 libtiff/
+0 libtiff.def
+ Makefile.am
+ Makefile.in
+ Makefile.vc
+ mkg3states.c
+ SConstruct
+ t4.h
+ tif_acorn.c
+ tif_apple.c
+ tif_atari.c
+ tif_aux.c
+ tif_close.c
+ tif_codec.c
+ tif_color.c
+ tif_compress.c
+ tif_config.h
+0 .in
+ .vc
+2 tif_dir.c
+ tif_dir.h
+ tif_dirinfo.c
+ tif_dirread.c
+ tif_dirwrite.c
+ tif_dumpmode.c
+ tif_error.c
+ tif_extension.c
+ tif_fax3.c
+ tif_fax3.h
+ tif_fax3sm.c
+ tiffconf.h
+0 .in
+ .vc
+2 tiff.h
+ tiffio.h
+0 xx
+2 tiffiop.h
+ tif_flush.c
+ tiffvers.h
+ tif_getimage.c
+ tif_jpeg.c
+ tif_luv.c
+ tif_lzw.c
+ tif_msdos.c
+ tif_next.c
+ tif_ojpeg.c
+ tif_open.c
+ tif_packbits.c
+ tif_pixarlog.c
+ tif_predict.c
+ tif_predict.h
+ tif_print.c
+ tif_read.c
+ tif_stream.cxx
+ tif_strip.c
+ tif_swab.c
+ tif_thunder.c
+ tif_tile.c
+ tif_unix.c
+ tif_version.c
+ tif_warning.c
+ tif_win32.c
+ tif_win3.c
+ tif_write.c
+ tif_zip.c
+ uvcode.h
+2 m4/
+0 acinclude.m4
+ libtool.m4
+ ltoptions.m4
+ ltsugar.m4
+ ltversion.m4
+2 Makefile.am
+ Makefile.in
+ Makefile.vc
+ nmake.opt
+ port/
+0 dummy.c
+ getopt.c
+ lfind.c
+ Makefile.am
+ Makefile.in
+ Makefile.vc
+ strcasecmp.c
+ strtoul.c
+2 README
+ RELEASE-DATE
+ SConstruct
+ test/
+0 ascii_tag.c
+ check_tag.c
+ long_tag.c
+ Makefile.am
+ Makefile.in
+ short_tag.c
+ strip.c
+ strip_rw.c
+ test_arrays.c
+ test_arrays.h
+2 TODO
+ VERSION
+2 Makefile
+ md4/
+0 md4.cpp
+ md4.h
+2 md5/
+0 md5.cpp
+ md5.h
+2 patches/
+0 freetype-2.3.5-config.patch
+ freetype-2.3.6-ascii.patch
+ freetype-2.3.6-vxworks.patch
+ libjpeg-6b-config.patch
+ libjpeg-6b-vxworks.patch
+ libmng-1.0.10-endless-loop.patch
+ libpng-1.2.20-elf-visibility.patch
+ libpng-1.2.20-vxworks.patch
+ libtiff-3.8.2-config.patch
+ libtiff-3.8.2-vxworks.patch
+ sqlite-3.5.6-config.patch
+ sqlite-3.5.6-vxworks.patch
+ sqlite-3.5.6-wince.patch
+ zlib-1.2.3-elf-visibility.patch
+2 phonon/
+0 CMakeLists.txt
+ COPYING.LIB
+ ds9/
+0 abstractvideorenderer.cpp
+ abstractvideorenderer.h
+ audiooutput.cpp
+ audiooutput.h
+ backend.cpp
+ backend.h
+ backendnode.cpp
+ backendnode.h
+ CMakeLists.txt
+ compointer.h
+ ConfigureChecks.cmake
+ ds9.desktop
+ effect.cpp
+ effect.h
+ fakesource.cpp
+ fakesource.h
+ iodevicereader.cpp
+ iodevicereader.h
+ lgpl-2.1.txt
+ lgpl-3.txt
+ mediagraph.cpp
+ mediagraph.h
+ mediaobject.cpp
+ mediaobject.h
+ phononds9_namespace.h
+ qasyncreader.cpp
+ qasyncreader.h
+ qaudiocdreader.cpp
+ qaudiocdreader.h
+ qbasefilter.cpp
+ qbasefilter.h
+ qmeminputpin.cpp
+ qmeminputpin.h
+ qpin.cpp
+ qpin.h
+ videorenderer_soft.cpp
+ videorenderer_soft.h
+ videorenderer_vmr9.cpp
+ videorenderer_vmr9.h
+ videowidget.cpp
+ videowidget.h
+ volumeeffect.cpp
+ volumeeffect.h
+2 gstreamer/
+0 abstractrenderer.cpp
+ abstractrenderer.h
+ alsasink2.c
+ alsasink2.h
+ artssink.cpp
+ artssink.h
+ audioeffect.cpp
+ audioeffect.h
+ audiooutput.cpp
+ audiooutput.h
+ backend.cpp
+ backend.h
+ CMakeLists.txt
+ common.h
+ ConfigureChecks.cmake
+ devicemanager.cpp
+ devicemanager.h
+ effect.cpp
+ effect.h
+ effectmanager.cpp
+ effectmanager.h
+ glrenderer.cpp
+ glrenderer.h
+ gsthelper.cpp
+ gsthelper.h
+ gstreamer.desktop
+ lgpl-2.1.txt
+ lgpl-3.txt
+ medianode.cpp
+ medianodeevent.cpp
+ medianodeevent.h
+ medianode.h
+ mediaobject.cpp
+ mediaobject.h
+ message.cpp
+ message.h
+ Messages.sh
+ phononsrc.cpp
+ phononsrc.h
+ qwidgetvideosink.cpp
+ qwidgetvideosink.h
+ streamreader.cpp
+ streamreader.h
+ videowidget.cpp
+ videowidget.h
+ volumefadereffect.cpp
+ volumefadereffect.h
+ widgetrenderer.cpp
+ widgetrenderer.h
+ x11renderer.cpp
+ x11renderer.h
+2 includes/
+0 CMakeLists.txt
+ Phonon/
+0 AbstractAudioOutput
+ AbstractMediaStream
+ AbstractVideoOutput
+ AddonInterface
+ AudioDevice
+0 Enumerator
+2 AudioOutput
+0 Device
+0 Model
+2 Interface
+2 BackendCapabilities
+ BackendInterface
+ Effect
+0 Description
+0 Model
+2 Interface
+ Parameter
+ Widget
+2 Experimental/
+0 AbstractVideoDataOutput
+ AudioDataOutput
+ SnapshotInterface
+ VideoDataOutput
+0 Interface
+2 VideoFrame
+0 2
+2 Visualization
+2 Global
+ MediaController
+ MediaNode
+ MediaObject
+0 Interface
+2 MediaSource
+ ObjectDescription
+0 Model
+2 Path
+ PlatformPlugin
+ SeekSlider
+ StreamInterface
+ VideoPlayer
+ VideoWidget
+0 Interface
+2 VolumeFaderEffect
+ VolumeFaderInterface
+ VolumeSlider
+3 mmf/
+0 abstractaudioeffect.cpp
+ abstractaudioeffect.h
+ abstractmediaplayer.cpp
+ abstractmediaplayer.h
+ abstractplayer.cpp
+ abstractplayer.h
+ ancestormovemonitor.cpp
+ ancestormovemonitor.h
+ audioequalizer.cpp
+ audioequalizer.h
+ audiooutput.cpp
+ audiooutput.h
+ audioplayer.cpp
+ audioplayer.h
+ backend.cpp
+ backend.h
+ bassboost.cpp
+ bassboost.h
+ defs.h
+ dummyplayer.cpp
+ dummyplayer.h
+ effectfactory.cpp
+ effectfactory.h
+ mediaobject.cpp
+ mediaobject.h
+ mmf_medianode.cpp
+ mmf_medianode.h
+ mmf_videoplayer.cpp
+ mmf_videoplayer.h
+ objectdump.cpp
+ objectdump.h
+ objectdump_symbian.cpp
+ objectdump_symbian.h
+ objecttree.cpp
+ objecttree.h
+ utils.cpp
+ utils.h
+ videooutput.cpp
+ videooutput.h
+ videooutputobserver.h
+ videowidget.cpp
+ videowidget.h
+ volumeobserver.h
+2 phonon/
+0 abstractaudiooutput.cpp
+ abstractaudiooutput.h
+ abstractaudiooutput_p.cpp
+ abstractaudiooutput_p.h
+ abstractmediastream.cpp
+ abstractmediastream.h
+ abstractmediastream_p.h
+ abstractvideooutput.cpp
+ abstractvideooutput.h
+ abstractvideooutput_p.cpp
+ abstractvideooutput_p.h
+ addoninterface.h
+ audiooutputadaptor.cpp
+ audiooutputadaptor_p.h
+ audiooutput.cpp
+ audiooutput.h
+ audiooutputinterface.cpp
+ audiooutputinterface.h
+ audiooutput_p.h
+ backendcapabilities.cpp
+ backendcapabilities.h
+ backendcapabilities_p.h
+ backend.dox
+ backendinterface.h
+ BUGS
+ CMakeLists.txt
+ effect.cpp
+ effect.h
+ effectinterface.h
+ effectparameter.cpp
+ effectparameter.h
+ effectparameter_p.h
+ effect_p.h
+ effectwidget.cpp
+ effectwidget.h
+ effectwidget_p.h
+ extractmethodcalls.rb
+ factory.cpp
+ factory_p.h
+ frontendinterface_p.h
+ globalconfig.cpp
+ globalconfig_p.h
+ globalstatic_p.h
+ IDEAS
+ iodevicestream.cpp
+ iodevicestream_p.h
+ .krazy
+ mediacontroller.cpp
+ mediacontroller.h
+ medianode.cpp
+ medianodedestructionhandler_p.h
+ medianode.h
+ medianode_p.h
+ mediaobject.cpp
+ mediaobject.dox
+ mediaobject.h
+ mediaobjectinterface.h
+ mediaobject_p.h
+ mediasource.cpp
+ mediasource.h
+ mediasource_p.h
+ Messages.sh
+ objectdescription.cpp
+ objectdescription.h
+ objectdescriptionmodel.cpp
+ objectdescriptionmodel.h
+ objectdescriptionmodel_p.h
+ objectdescription_p.h
+ org.kde.Phonon.AudioOutput.xml
+ path.cpp
+ path.h
+ path_p.h
+2 phonon.pc.cmake
+ phonon/phonondefs.h
+ phonon/phonondefs_p.h
+ phonon/phonon_export.h
+ phonon/phononnamespace.cpp
+ phonon/phononnamespace.h
+0 .in
+2 phonon/phononnamespace_p.h
+ phonon/platform.cpp
+ phonon/platform_p.h
+ phonon/platformplugin.h
+ phonon/preprocessandextract.sh
+ phonon/qsettingsgroup_p.h
+ phonon/seekslider.cpp
+ phonon/seekslider.h
+ phonon/seekslider_p.h
+ phonon/streaminterface.cpp
+ phonon/streaminterface.h
+ phonon/streaminterface_p.h
+ phonon/stream-thoughts
+ phonon/TODO
+ phonon/videoplayer.cpp
+ phonon/videoplayer.h
+ phonon/videowidget.cpp
+ phonon/videowidget.h
+ phonon/videowidgetinterface.h
+ phonon/videowidget_p.h
+ phonon/volumefadereffect.cpp
+ phonon/volumefadereffect.h
+ phonon/volumefadereffect_p.h
+ phonon/volumefaderinterface.h
+ phonon/volumeslider.cpp
+ phonon/volumeslider.h
+ phonon/volumeslider_p.h
+ qt7/
+0 audioconnection.h
+ audioconnection.mm
+ audiodevice.h
+ audiodevice.mm
+ audioeffects.h
+ audioeffects.mm
+ audiograph.h
+ audiograph.mm
+ audiomixer.h
+ audiomixer.mm
+ audionode.h
+ audionode.mm
+ audiooutput.h
+ audiooutput.mm
+ audiopartoutput.h
+ audiopartoutput.mm
+ audiosplitter.h
+ audiosplitter.mm
+ backend.h
+ backendheader.h
+ backendheader.mm
+ backendinfo.h
+ backendinfo.mm
+ backend.mm
+ CMakeLists.txt
+ ConfigureChecks.cmake
+ lgpl-2.1.txt
+ lgpl-3.txt
+ medianodeevent.h
+ medianodeevent.mm
+ medianode.h
+ medianode.mm
+ medianodevideopart.h
+ medianodevideopart.mm
+ mediaobjectaudionode.h
+ mediaobjectaudionode.mm
+ mediaobject.h
+ mediaobject.mm
+ quicktimeaudioplayer.h
+ quicktimeaudioplayer.mm
+ quicktimemetadata.h
+ quicktimemetadata.mm
+ quicktimestreamreader.h
+ quicktimestreamreader.mm
+ quicktimevideoplayer.h
+ quicktimevideoplayer.mm
+ videoeffect.h
+ videoeffect.mm
+ videoframe.h
+ videoframe.mm
+ videowidget.h
+ videowidget.mm
+2 waveout/
+0 audiooutput.cpp
+ audiooutput.h
+ backend.cpp
+ backend.h
+ mediaobject.cpp
+ mediaobject.h
+3 powervr/
+0 pvr2d.h
+ wsegl.h
+2 ptmalloc/
+0 ChangeLog
+ COPYRIGHT
+ lran2.h
+ Makefile
+ malloc-2.8.3.h
+ malloc.c
+ malloc-private.h
+ ptmalloc3.c
+ README
+ sysdeps/
+0 generic/
+0 atomic.h
+ malloc-machine.h
+ thread-st.h
+2 pthread/
+0 malloc-machine.h
+ thread-st.h
+2 solaris/
+0 malloc-machine.h
+ thread-st.h
+2 sproc/
+0 malloc-machine.h
+ thread-st.h
+4 README
+ sha1/
+0 sha1.cpp
+2 sqlite/
+0 shell.c
+ sqlite3.c
+ sqlite3.h
+2 webkit/
+0 ChangeLog
+ .gitignore
+ JavaScriptCore/
+0 API/
+0 APICast.h
+ JavaScriptCore.h
+ JavaScript.h
+ JSBase.cpp
+ JSBase.h
+ JSBasePrivate.h
+ JSCallbackConstructor.cpp
+ JSCallbackConstructor.h
+ JSCallbackFunction.cpp
+ JSCallbackFunction.h
+ JSCallbackObject.cpp
+ JSCallbackObjectFunctions.h
+ JSCallbackObject.h
+ JSClassRef.cpp
+ JSClassRef.h
+ JSContextRef.cpp
+ JSContextRef.h
+ JSContextRefPrivate.h
+ JSObjectRef.cpp
+ JSObjectRef.h
+ JSProfilerPrivate.cpp
+ JSProfilerPrivate.h
+ JSRetainPtr.h
+ JSStringRefBSTR.cpp
+ JSStringRefBSTR.h
+ JSStringRefCF.cpp
+ JSStringRefCF.h
+ JSStringRef.cpp
+ JSStringRef.h
+ JSValueRef.cpp
+ JSValueRef.h
+ OpaqueJSString.cpp
+ OpaqueJSString.h
+ WebKitAvailability.h
+2 assembler/
+0 AbstractMacroAssembler.h
+ ARMAssembler.cpp
+ ARMAssembler.h
+ ARMv7Assembler.h
+ AssemblerBuffer.h
+ AssemblerBufferWithConstantPool.h
+ CodeLocation.h
+ LinkBuffer.h
+ MacroAssemblerARM.cpp
+ MacroAssemblerARM.h
+ MacroAssemblerARMv7.h
+ MacroAssemblerCodeRef.h
+ MacroAssembler.h
+ MacroAssemblerX86_64.h
+ MacroAssemblerX86Common.h
+ MacroAssemblerX86.h
+ RepatchBuffer.h
+ X86Assembler.h
+2 AUTHORS
+ bytecode/
+0 CodeBlock.cpp
+ CodeBlock.h
+ EvalCodeCache.h
+ Instruction.h
+ JumpTable.cpp
+ JumpTable.h
+ Opcode.cpp
+ Opcode.h
+ SamplingTool.cpp
+ SamplingTool.h
+ StructureStubInfo.cpp
+ StructureStubInfo.h
+2 bytecompiler/
+0 BytecodeGenerator.cpp
+ BytecodeGenerator.h
+ Label.h
+ LabelScope.h
+ RegisterID.h
+2 ChangeLog
+0 -2002-12-03
+ -2003-10-25
+ -2007-10-14
+ -2008-08-10
+ -2009-06-16
+2 config.h
+ COPYING.LIB
+ create_hash_table
+ debugger/
+0 DebuggerActivation.cpp
+ DebuggerActivation.h
+ DebuggerCallFrame.cpp
+ DebuggerCallFrame.h
+ Debugger.cpp
+ Debugger.h
+2 DerivedSources.make
+ docs/
+0 make-bytecode-docs.pl
+2 ForwardingHeaders/
+0 JavaScriptCore/
+0 APICast.h
+ JavaScriptCore.h
+ JavaScript.h
+ JSBase.h
+ JSContextRef.h
+ JSObjectRef.h
+ JSRetainPtr.h
+ JSStringRefCF.h
+ JSStringRef.h
+ JSValueRef.h
+ OpaqueJSString.h
+ WebKitAvailability.h
+3 generated/
+0 ArrayPrototype.lut.h
+ chartables.c
+ DatePrototype.lut.h
+ Grammar.cpp
+ Grammar.h
+ JSONObject.lut.h
+ Lexer.lut.h
+ MathObject.lut.h
+ NumberConstructor.lut.h
+ RegExpConstructor.lut.h
+ RegExpObject.lut.h
+ StringPrototype.lut.h
+2 headers.pri
+ Info.plist
+ interpreter/
+0 CachedCall.h
+ CallFrameClosure.h
+ CallFrame.cpp
+ CallFrame.h
+ Interpreter.cpp
+ Interpreter.h
+ RegisterFile.cpp
+ RegisterFile.h
+ Register.h
+2 JavaScriptCore.gypi
+ JavaScriptCore.order
+ JavaScriptCorePrefix.h
+ JavaScriptCore.pri
+ JavaScriptCore.pro
+ jit/
+0 ExecutableAllocator.cpp
+ ExecutableAllocatorFixedVMPool.cpp
+ ExecutableAllocator.h
+ ExecutableAllocatorPosix.cpp
+ ExecutableAllocatorSymbian.cpp
+ ExecutableAllocatorWin.cpp
+ JITArithmetic.cpp
+ JITCall.cpp
+ JITCode.h
+ JIT.cpp
+ JIT.h
+ JITInlineMethods.h
+ JITOpcodes.cpp
+ JITPropertyAccess.cpp
+ JITStubCall.h
+ JITStubs.cpp
+ JITStubs.h
+2 jsc.cpp
+ make-generated-sources.sh
+ os-win32/
+0 stdbool.h
+ stdint.h
+2 parser/
+0 Grammar.y
+ Keywords.table
+ Lexer.cpp
+ Lexer.h
+ NodeConstructors.h
+ NodeInfo.h
+ Nodes.cpp
+ Nodes.h
+ ParserArena.cpp
+ ParserArena.h
+ Parser.cpp
+ Parser.h
+ ResultType.h
+ SourceCode.h
+ SourceProvider.h
+2 pcre/
+0 AUTHORS
+ COPYING
+ dftables
+ pcre_compile.cpp
+ pcre_exec.cpp
+ pcre.h
+ pcre_internal.h
+ pcre.pri
+ pcre_tables.cpp
+ pcre_ucp_searchfuncs.cpp
+ pcre_xclass.cpp
+ ucpinternal.h
+ ucptable.cpp
+2 profiler/
+0 CallIdentifier.h
+ HeavyProfile.cpp
+ HeavyProfile.h
+ Profile.cpp
+ ProfileGenerator.cpp
+ ProfileGenerator.h
+ Profile.h
+ ProfileNode.cpp
+ ProfileNode.h
+ Profiler.cpp
+ Profiler.h
+ ProfilerServer.h
+ ProfilerServer.mm
+ TreeProfile.cpp
+ TreeProfile.h
+2 runtime/
+0 ArgList.cpp
+ ArgList.h
+ Arguments.cpp
+ Arguments.h
+ ArrayConstructor.cpp
+ ArrayConstructor.h
+ ArrayPrototype.cpp
+ ArrayPrototype.h
+ BatchedTransitionOptimizer.h
+ BooleanConstructor.cpp
+ BooleanConstructor.h
+ BooleanObject.cpp
+ BooleanObject.h
+ BooleanPrototype.cpp
+ BooleanPrototype.h
+ CallData.cpp
+ CallData.h
+ ClassInfo.h
+ Collector.cpp
+ Collector.h
+ CollectorHeapIterator.h
+ CommonIdentifiers.cpp
+ CommonIdentifiers.h
+ Completion.cpp
+ Completion.h
+ ConstructData.cpp
+ ConstructData.h
+ DateConstructor.cpp
+ DateConstructor.h
+ DateConversion.cpp
+ DateConversion.h
+ DateInstanceCache.h
+ DateInstance.cpp
+ DateInstance.h
+ DatePrototype.cpp
+ DatePrototype.h
+ ErrorConstructor.cpp
+ ErrorConstructor.h
+ Error.cpp
+ Error.h
+ ErrorInstance.cpp
+ ErrorInstance.h
+ ErrorPrototype.cpp
+ ErrorPrototype.h
+ ExceptionHelpers.cpp
+ ExceptionHelpers.h
+ Executable.cpp
+ Executable.h
+ FunctionConstructor.cpp
+ FunctionConstructor.h
+ FunctionPrototype.cpp
+ FunctionPrototype.h
+ GetterSetter.cpp
+ GetterSetter.h
+ GlobalEvalFunction.cpp
+ GlobalEvalFunction.h
+ Identifier.cpp
+ Identifier.h
+ InitializeThreading.cpp
+ InitializeThreading.h
+ InternalFunction.cpp
+ InternalFunction.h
+ JSActivation.cpp
+ JSActivation.h
+ JSAPIValueWrapper.cpp
+ JSAPIValueWrapper.h
+ JSArray.cpp
+ JSArray.h
+ JSByteArray.cpp
+ JSByteArray.h
+ JSCell.cpp
+ JSCell.h
+ JSFunction.cpp
+ JSFunction.h
+ JSGlobalData.cpp
+ JSGlobalData.h
+ JSGlobalObject.cpp
+ JSGlobalObjectFunctions.cpp
+ JSGlobalObjectFunctions.h
+ JSGlobalObject.h
+ JSImmediate.cpp
+ JSImmediate.h
+ JSLock.cpp
+ JSLock.h
+ JSNotAnObject.cpp
+ JSNotAnObject.h
+ JSNumberCell.cpp
+ JSNumberCell.h
+ JSObject.cpp
+ JSObject.h
+ JSONObject.cpp
+ JSONObject.h
+ JSPropertyNameIterator.cpp
+ JSPropertyNameIterator.h
+ JSStaticScopeObject.cpp
+ JSStaticScopeObject.h
+ JSString.cpp
+ JSString.h
+ JSType.h
+ JSTypeInfo.h
+ JSValue.cpp
+ JSValue.h
+ JSVariableObject.cpp
+ JSVariableObject.h
+ JSWrapperObject.cpp
+ JSWrapperObject.h
+ LiteralParser.cpp
+ LiteralParser.h
+ Lookup.cpp
+ Lookup.h
+ MarkStack.cpp
+ MarkStack.h
+ MarkStackPosix.cpp
+ MarkStackSymbian.cpp
+ MarkStackWin.cpp
+ MathObject.cpp
+ MathObject.h
+ NativeErrorConstructor.cpp
+ NativeErrorConstructor.h
+ NativeErrorPrototype.cpp
+ NativeErrorPrototype.h
+ NativeFunctionWrapper.h
+ NumberConstructor.cpp
+ NumberConstructor.h
+ NumberObject.cpp
+ NumberObject.h
+ NumberPrototype.cpp
+ NumberPrototype.h
+ NumericStrings.h
+ ObjectConstructor.cpp
+ ObjectConstructor.h
+ ObjectPrototype.cpp
+ ObjectPrototype.h
+ Operations.cpp
+ Operations.h
+ PropertyDescriptor.cpp
+ PropertyDescriptor.h
+ PropertyMapHashTable.h
+ PropertyNameArray.cpp
+ PropertyNameArray.h
+ PropertySlot.cpp
+ PropertySlot.h
+ Protect.h
+ PrototypeFunction.cpp
+ PrototypeFunction.h
+ PutPropertySlot.h
+ RegExpConstructor.cpp
+ RegExpConstructor.h
+ RegExp.cpp
+ RegExp.h
+ RegExpMatchesArray.h
+ RegExpObject.cpp
+ RegExpObject.h
+ RegExpPrototype.cpp
+ RegExpPrototype.h
+ ScopeChain.cpp
+ ScopeChain.h
+ ScopeChainMark.h
+ SmallStrings.cpp
+ SmallStrings.h
+ StringConstructor.cpp
+ StringConstructor.h
+ StringObject.cpp
+ StringObject.h
+ StringObjectThatMasqueradesAsUndefined.h
+ StringPrototype.cpp
+ StringPrototype.h
+ StructureChain.cpp
+ StructureChain.h
+ Structure.cpp
+ Structure.h
+ StructureTransitionTable.h
+ SymbolTable.h
+ TimeoutChecker.cpp
+ TimeoutChecker.h
+ Tracing.h
+ UString.cpp
+ UString.h
+2 THANKS
+ wrec/
+0 CharacterClassConstructor.cpp
+ CharacterClassConstructor.h
+ CharacterClass.cpp
+ CharacterClass.h
+ Escapes.h
+ Quantifier.h
+ WREC.cpp
+ WRECFunctors.cpp
+ WRECFunctors.h
+ WRECGenerator.cpp
+ WRECGenerator.h
+ WREC.h
+ WRECParser.cpp
+ WRECParser.h
+2 wscript
+ wtf/
+0 AlwaysInline.h
+ ASCIICType.h
+ Assertions.cpp
+ Assertions.h
+ AVLTree.h
+ ByteArray.cpp
+ ByteArray.h
+ CONTRIBUTORS.pthreads-win32
+ CrossThreadRefCounted.h
+ CurrentTime.cpp
+ CurrentTime.h
+ DateMath.cpp
+ DateMath.h
+ Deque.h
+ DisallowCType.h
+ dtoa.cpp
+ dtoa.h
+ FastAllocBase.h
+ FastMalloc.cpp
+ FastMalloc.h
+ Forward.h
+ GetPtr.h
+ GOwnPtr.cpp
+ GOwnPtr.h
+ HashCountedSet.h
+ HashFunctions.h
+ HashIterators.h
+ HashMap.h
+ HashSet.h
+ HashTable.cpp
+ HashTable.h
+ HashTraits.h
+ ListHashSet.h
+ ListRefPtr.h
+ Locker.h
+ MainThread.cpp
+ MainThread.h
+ MallocZoneSupport.h
+ MathExtras.h
+ MessageQueue.h
+ Noncopyable.h
+ NotFound.h
+ OwnArrayPtr.h
+ OwnFastMallocPtr.h
+ OwnPtrCommon.h
+ OwnPtr.h
+ OwnPtrWin.cpp
+ PassOwnPtr.h
+ PassRefPtr.h
+ Platform.h
+ PossiblyNull.h
+ PtrAndFlags.h
+ qt/
+0 MainThreadQt.cpp
+ ThreadingQt.cpp
+2 RandomNumber.cpp
+ RandomNumber.h
+ RandomNumberSeed.h
+ RefCounted.h
+ RefCountedLeakCounter.cpp
+ RefCountedLeakCounter.h
+ RefPtr.h
+ RefPtrHashMap.h
+ RetainPtr.h
+ SegmentedVector.h
+ StdLibExtras.h
+ StringExtras.h
+ TCPackedCache.h
+ TCPageMap.h
+ TCSpinLock.h
+ TCSystemAlloc.cpp
+ TCSystemAlloc.h
+ Threading.cpp
+ Threading.h
+ ThreadingNone.cpp
+ ThreadingPthreads.cpp
+ ThreadingWin.cpp
+ ThreadSpecific.h
+ ThreadSpecificWin.cpp
+ TypeTraits.cpp
+ TypeTraits.h
+ unicode/
+0 CollatorDefault.cpp
+ Collator.h
+ glib/
+0 UnicodeGLib.cpp
+ UnicodeGLib.h
+ UnicodeMacrosFromICU.h
+2 icu/
+0 CollatorICU.cpp
+ UnicodeIcu.h
+2 qt4/
+0 UnicodeQt4.h
+2 Unicode.h
+ UTF8.cpp
+ UTF8.h
+ wince/
+0 UnicodeWince.cpp
+ UnicodeWince.h
+3 UnusedParam.h
+ Vector.h
+ VectorTraits.h
+ VMTags.h
+ wince/
+0 FastMallocWince.h
+ MemoryManager.cpp
+ MemoryManager.h
+ mt19937ar.c
+3 yarr/
+0 RegexCompiler.cpp
+ RegexCompiler.h
+ RegexInterpreter.cpp
+ RegexInterpreter.h
+ RegexJIT.cpp
+ RegexJIT.h
+ RegexParser.h
+ RegexPattern.h
+3 VERSION
+ WebCore/
+0 accessibility/
+0 AccessibilityAllInOne.cpp
+ AccessibilityARIAGridCell.cpp
+ AccessibilityARIAGridCell.h
+ AccessibilityARIAGrid.cpp
+ AccessibilityARIAGrid.h
+ AccessibilityARIAGridRow.cpp
+ AccessibilityARIAGridRow.h
+ AccessibilityImageMapLink.cpp
+ AccessibilityImageMapLink.h
+ AccessibilityListBox.cpp
+ AccessibilityListBox.h
+ AccessibilityListBoxOption.cpp
+ AccessibilityListBoxOption.h
+ AccessibilityList.cpp
+ AccessibilityList.h
+ AccessibilityMediaControls.cpp
+ AccessibilityMediaControls.h
+ AccessibilityObject.cpp
+ AccessibilityObject.h
+ AccessibilityRenderObject.cpp
+ AccessibilityRenderObject.h
+ AccessibilitySlider.cpp
+ AccessibilitySlider.h
+ AccessibilityTableCell.cpp
+ AccessibilityTableCell.h
+ AccessibilityTableColumn.cpp
+ AccessibilityTableColumn.h
+ AccessibilityTable.cpp
+ AccessibilityTable.h
+ AccessibilityTableHeaderContainer.cpp
+ AccessibilityTableHeaderContainer.h
+ AccessibilityTableRow.cpp
+ AccessibilityTableRow.h
+ AXObjectCache.cpp
+ AXObjectCache.h
+ qt/
+0 AccessibilityObjectQt.cpp
+3 bindings/
+0 js/
+0 CachedScriptSourceProvider.h
+ DOMObjectWithSVGContext.h
+ GCController.cpp
+ GCController.h
+ JSAbstractWorkerCustom.cpp
+ JSAttrCustom.cpp
+ JSAudioConstructor.cpp
+ JSAudioConstructor.h
+ JSBindingsAllInOne.cpp
+ JSCallbackData.cpp
+ JSCallbackData.h
+ JSCanvasArrayBufferConstructor.cpp
+ JSCanvasArrayBufferConstructor.h
+ JSCanvasArrayCustom.cpp
+ JSCanvasByteArrayConstructor.cpp
+ JSCanvasByteArrayConstructor.h
+ JSCanvasByteArrayCustom.cpp
+ JSCanvasFloatArrayConstructor.cpp
+ JSCanvasFloatArrayConstructor.h
+ JSCanvasFloatArrayCustom.cpp
+ JSCanvasIntArrayConstructor.cpp
+ JSCanvasIntArrayConstructor.h
+ JSCanvasIntArrayCustom.cpp
+ JSCanvasNumberArrayCustom.cpp
+ JSCanvasRenderingContext2DCustom.cpp
+ JSCanvasRenderingContext3DCustom.cpp
+ JSCanvasRenderingContextCustom.cpp
+ JSCanvasShortArrayConstructor.cpp
+ JSCanvasShortArrayConstructor.h
+ JSCanvasShortArrayCustom.cpp
+ JSCanvasUnsignedByteArrayConstructor.cpp
+ JSCanvasUnsignedByteArrayConstructor.h
+ JSCanvasUnsignedByteArrayCustom.cpp
+ JSCanvasUnsignedIntArrayConstructor.cpp
+ JSCanvasUnsignedIntArrayConstructor.h
+ JSCanvasUnsignedIntArrayCustom.cpp
+ JSCanvasUnsignedShortArrayConstructor.cpp
+ JSCanvasUnsignedShortArrayConstructor.h
+ JSCanvasUnsignedShortArrayCustom.cpp
+ JSCDATASectionCustom.cpp
+ JSClipboardCustom.cpp
+ JSConsoleCustom.cpp
+ JSCoordinatesCustom.cpp
+ JSCSSRuleCustom.cpp
+ JSCSSRuleListCustom.cpp
+ JSCSSStyleDeclarationCustom.cpp
+ JSCSSStyleDeclarationCustom.h
+ JSCSSValueCustom.cpp
+ JSCustomPositionCallback.cpp
+ JSCustomPositionCallback.h
+ JSCustomPositionErrorCallback.cpp
+ JSCustomPositionErrorCallback.h
+ JSCustomSQLStatementCallback.cpp
+ JSCustomSQLStatementCallback.h
+ JSCustomSQLStatementErrorCallback.cpp
+ JSCustomSQLStatementErrorCallback.h
+ JSCustomSQLTransactionCallback.cpp
+ JSCustomSQLTransactionCallback.h
+ JSCustomSQLTransactionErrorCallback.cpp
+ JSCustomSQLTransactionErrorCallback.h
+ JSCustomVoidCallback.cpp
+ JSCustomVoidCallback.h
+ JSCustomXPathNSResolver.cpp
+ JSCustomXPathNSResolver.h
+ JSDatabaseCustom.cpp
+ JSDataGridColumnListCustom.cpp
+ JSDataGridDataSource.cpp
+ JSDataGridDataSource.h
+ JSDedicatedWorkerContextCustom.cpp
+ JSDesktopNotificationsCustom.cpp
+ JSDocumentCustom.cpp
+ JSDocumentFragmentCustom.cpp
+ JSDOMApplicationCacheCustom.cpp
+ JSDOMBinding.cpp
+ JSDOMBinding.h
+ JSDOMGlobalObject.cpp
+ JSDOMGlobalObject.h
+ JSDOMWindowBase.cpp
+ JSDOMWindowBase.h
+ JSDOMWindowCustom.cpp
+ JSDOMWindowCustom.h
+ JSDOMWindowShell.cpp
+ JSDOMWindowShell.h
+ JSElementCustom.cpp
+ JSEventCustom.cpp
+ JSEventListener.cpp
+ JSEventListener.h
+ JSEventSourceConstructor.cpp
+ JSEventSourceConstructor.h
+ JSEventSourceCustom.cpp
+ JSEventTarget.cpp
+ JSEventTarget.h
+ JSExceptionBase.cpp
+ JSExceptionBase.h
+ JSGeolocationCustom.cpp
+ JSHistoryCustom.cpp
+ JSHistoryCustom.h
+ JSHTMLAllCollectionCustom.cpp
+ JSHTMLAppletElementCustom.cpp
+ JSHTMLAppletElementCustom.h
+ JSHTMLCanvasElementCustom.cpp
+ JSHTMLCollectionCustom.cpp
+ JSHTMLDataGridElementCustom.cpp
+ JSHTMLDocumentCustom.cpp
+ JSHTMLElementCustom.cpp
+ JSHTMLEmbedElementCustom.cpp
+ JSHTMLEmbedElementCustom.h
+ JSHTMLFormElementCustom.cpp
+ JSHTMLFrameElementCustom.cpp
+ JSHTMLFrameSetElementCustom.cpp
+ JSHTMLIFrameElementCustom.cpp
+ JSHTMLInputElementCustom.cpp
+ JSHTMLInputElementCustom.h
+ JSHTMLObjectElementCustom.cpp
+ JSHTMLObjectElementCustom.h
+ JSHTMLOptionsCollectionCustom.cpp
+ JSHTMLSelectElementCustom.cpp
+ JSHTMLSelectElementCustom.h
+ JSImageConstructor.cpp
+ JSImageConstructor.h
+ JSImageDataCustom.cpp
+ JSInspectedObjectWrapper.cpp
+ JSInspectedObjectWrapper.h
+ JSInspectorBackendCustom.cpp
+ JSInspectorCallbackWrapper.cpp
+ JSInspectorCallbackWrapper.h
+ JSJavaScriptCallFrameCustom.cpp
+ JSLazyEventListener.cpp
+ JSLazyEventListener.h
+ JSLocationCustom.cpp
+ JSLocationCustom.h
+ JSMessageChannelConstructor.cpp
+ JSMessageChannelConstructor.h
+ JSMessageChannelCustom.cpp
+ JSMessageEventCustom.cpp
+ JSMessagePortCustom.cpp
+ JSMessagePortCustom.h
+ JSMimeTypeArrayCustom.cpp
+ JSNamedNodeMapCustom.cpp
+ JSNavigatorCustom.cpp
+ JSNodeCustom.cpp
+ JSNodeFilterCondition.cpp
+ JSNodeFilterCondition.h
+ JSNodeFilterCustom.cpp
+ JSNodeIteratorCustom.cpp
+ JSNodeListCustom.cpp
+ JSOptionConstructor.cpp
+ JSOptionConstructor.h
+ JSPluginArrayCustom.cpp
+ JSPluginCustom.cpp
+ JSPluginElementFunctions.cpp
+ JSPluginElementFunctions.h
+ JSQuarantinedObjectWrapper.cpp
+ JSQuarantinedObjectWrapper.h
+ JSSharedWorkerConstructor.cpp
+ JSSharedWorkerConstructor.h
+ JSSharedWorkerCustom.cpp
+ JSSQLResultSetRowListCustom.cpp
+ JSSQLTransactionCustom.cpp
+ JSStorageCustom.cpp
+ JSStorageCustom.h
+ JSStyleSheetCustom.cpp
+ JSStyleSheetListCustom.cpp
+ JSSVGElementInstanceCustom.cpp
+ JSSVGLengthCustom.cpp
+ JSSVGMatrixCustom.cpp
+ JSSVGPathSegCustom.cpp
+ JSSVGPathSegListCustom.cpp
+ JSSVGPODTypeWrapper.h
+ JSSVGPointListCustom.cpp
+ JSSVGTransformListCustom.cpp
+ JSTextCustom.cpp
+ JSTreeWalkerCustom.cpp
+ JSWebKitCSSMatrixConstructor.cpp
+ JSWebKitCSSMatrixConstructor.h
+ JSWebKitPointConstructor.cpp
+ JSWebKitPointConstructor.h
+ JSWebSocketConstructor.cpp
+ JSWebSocketConstructor.h
+ JSWebSocketCustom.cpp
+ JSWorkerConstructor.cpp
+ JSWorkerConstructor.h
+ JSWorkerContextBase.cpp
+ JSWorkerContextBase.h
+ JSWorkerContextCustom.cpp
+ JSWorkerCustom.cpp
+ JSXMLHttpRequestConstructor.cpp
+ JSXMLHttpRequestConstructor.h
+ JSXMLHttpRequestCustom.cpp
+ JSXMLHttpRequestUploadCustom.cpp
+ JSXSLTProcessorConstructor.cpp
+ JSXSLTProcessorConstructor.h
+ JSXSLTProcessorCustom.cpp
+ ScheduledAction.cpp
+ ScheduledAction.h
+ ScriptArray.cpp
+ ScriptArray.h
+ ScriptCachedFrameData.cpp
+ ScriptCachedFrameData.h
+ ScriptCallFrame.cpp
+ ScriptCallFrame.h
+ ScriptCallStack.cpp
+ ScriptCallStack.h
+ ScriptController.cpp
+ ScriptControllerGtk.cpp
+ ScriptController.h
+ ScriptControllerHaiku.cpp
+ ScriptControllerMac.mm
+ ScriptControllerQt.cpp
+ ScriptControllerWin.cpp
+ ScriptControllerWx.cpp
+ ScriptEventListener.cpp
+ ScriptEventListener.h
+ ScriptFunctionCall.cpp
+ ScriptFunctionCall.h
+ ScriptInstance.h
+ ScriptObject.cpp
+ ScriptObject.h
+ ScriptObjectQuarantine.cpp
+ ScriptObjectQuarantine.h
+ ScriptSourceCode.h
+ ScriptSourceProvider.h
+ ScriptState.cpp
+ ScriptState.h
+ ScriptString.h
+ ScriptValue.cpp
+ ScriptValue.h
+ SerializedScriptValue.cpp
+ SerializedScriptValue.h
+ StringSourceProvider.h
+ WorkerScriptController.cpp
+ WorkerScriptController.h
+2 ScriptControllerBase.cpp
+ scripts/
+0 CodeGeneratorCOM.pm
+ CodeGeneratorJS.pm
+ CodeGeneratorObjC.pm
+ CodeGenerator.pm
+ CodeGeneratorV8.pm
+ generate-bindings.pl
+ IDLParser.pm
+ IDLStructure.pm
+ InFilesParser.pm
+3 bridge/
+0 c/
+0 c_class.cpp
+ c_class.h
+ c_instance.cpp
+ c_instance.h
+ c_runtime.cpp
+ c_runtime.h
+ c_utility.cpp
+ c_utility.h
+2 IdentifierRep.cpp
+ IdentifierRep.h
+ jni/
+0 jni_class.cpp
+ jni_class.h
+ jni_instance.cpp
+ jni_instance.h
+ jni_jsobject.h
+ jni_jsobject.mm
+ jni_objc.mm
+ jni_runtime.cpp
+ jni_runtime.h
+ jni_utility.cpp
+ jni_utility.h
+2 make_testbindings
+ npapi.h
+ NP_jsobject.cpp
+ NP_jsobject.h
+ npruntime.cpp
+ npruntime.h
+ npruntime_impl.h
+ npruntime_internal.h
+ npruntime_priv.h
+ qt/
+0 qt_class.cpp
+ qt_class.h
+ qt_instance.cpp
+ qt_instance.h
+ qt_runtime.cpp
+ qt_runtime.h
+2 runtime_array.cpp
+ runtime_array.h
+ runtime.cpp
+ runtime.h
+ runtime_method.cpp
+ runtime_method.h
+ runtime_object.cpp
+ runtime_object.h
+ runtime_root.cpp
+ runtime_root.h
+ testbindings.cpp
+ testbindings.mm
+ testC.js
+ test.js
+ testM.js
+ testqtbindings.cpp
+2 ChangeLog
+0 -2002-12-03
+ -2003-10-25
+ -2005-08-23
+ -2005-12-19
+ -2006-05-10
+ -2006-12-31
+ -2007-10-14
+ -2008-08-10
+ -2009-06-16
+2 combine-javascript-resources
+ config.h
+ css/
+0 Counter.h
+ Counter.idl
+ CSSBorderImageValue.cpp
+ CSSBorderImageValue.h
+ CSSCanvasValue.cpp
+ CSSCanvasValue.h
+ CSSCharsetRule.cpp
+ CSSCharsetRule.h
+ CSSCharsetRule.idl
+ CSSComputedStyleDeclaration.cpp
+ CSSComputedStyleDeclaration.h
+ CSSCursorImageValue.cpp
+ CSSCursorImageValue.h
+ CSSFontFace.cpp
+ CSSFontFace.h
+ CSSFontFaceRule.cpp
+ CSSFontFaceRule.h
+ CSSFontFaceRule.idl
+ CSSFontFaceSource.cpp
+ CSSFontFaceSource.h
+ CSSFontFaceSrcValue.cpp
+ CSSFontFaceSrcValue.h
+ CSSFontSelector.cpp
+ CSSFontSelector.h
+ CSSFunctionValue.cpp
+ CSSFunctionValue.h
+ CSSGradientValue.cpp
+ CSSGradientValue.h
+ CSSGrammar.y
+ CSSHelper.cpp
+ CSSHelper.h
+ CSSImageGeneratorValue.cpp
+ CSSImageGeneratorValue.h
+ CSSImageValue.cpp
+ CSSImageValue.h
+ CSSImportRule.cpp
+ CSSImportRule.h
+ CSSImportRule.idl
+ CSSInheritedValue.cpp
+ CSSInheritedValue.h
+ CSSInitialValue.cpp
+ CSSInitialValue.h
+ CSSMediaRule.cpp
+ CSSMediaRule.h
+ CSSMediaRule.idl
+ CSSMutableStyleDeclaration.cpp
+ CSSMutableStyleDeclaration.h
+ CSSNamespace.h
+ CSSPageRule.cpp
+ CSSPageRule.h
+ CSSPageRule.idl
+ CSSParser.cpp
+ CSSParser.h
+ CSSParserValues.cpp
+ CSSParserValues.h
+ CSSPrimitiveValue.cpp
+ CSSPrimitiveValue.h
+ CSSPrimitiveValue.idl
+ CSSPrimitiveValueMappings.h
+ CSSProperty.cpp
+ CSSProperty.h
+ CSSPropertyLonghand.cpp
+ CSSPropertyLonghand.h
+ CSSPropertyNames.in
+ CSSQuirkPrimitiveValue.h
+ CSSReflectionDirection.h
+ CSSReflectValue.cpp
+ CSSReflectValue.h
+ CSSRule.cpp
+ CSSRule.h
+ CSSRule.idl
+ CSSRuleList.cpp
+ CSSRuleList.h
+ CSSRuleList.idl
+ CSSSegmentedFontFace.cpp
+ CSSSegmentedFontFace.h
+ CSSSelector.cpp
+ CSSSelector.h
+ CSSSelectorList.cpp
+ CSSSelectorList.h
+ CSSStyleDeclaration.cpp
+ CSSStyleDeclaration.h
+ CSSStyleDeclaration.idl
+ CSSStyleRule.cpp
+ CSSStyleRule.h
+ CSSStyleRule.idl
+ CSSStyleSelector.cpp
+ CSSStyleSelector.h
+ CSSStyleSheet.cpp
+ CSSStyleSheet.h
+ CSSStyleSheet.idl
+ CSSTimingFunctionValue.cpp
+ CSSTimingFunctionValue.h
+ CSSUnicodeRangeValue.cpp
+ CSSUnicodeRangeValue.h
+ CSSUnknownRule.h
+ CSSUnknownRule.idl
+ CSSValue.h
+ CSSValue.idl
+ CSSValueKeywords.in
+ CSSValueList.cpp
+ CSSValueList.h
+ CSSValueList.idl
+ CSSVariableDependentValue.cpp
+ CSSVariableDependentValue.h
+ CSSVariablesDeclaration.cpp
+ CSSVariablesDeclaration.h
+ CSSVariablesDeclaration.idl
+ CSSVariablesRule.cpp
+ CSSVariablesRule.h
+ CSSVariablesRule.idl
+ DashboardRegion.h
+ DashboardSupportCSSPropertyNames.in
+ FontFamilyValue.cpp
+ FontFamilyValue.h
+ FontValue.cpp
+ FontValue.h
+ html.css
+ make-css-file-arrays.pl
+ makegrammar.pl
+ makeprop.pl
+ maketokenizer
+ makevalues.pl
+ mathml.css
+ mediaControlsChromium.css
+ mediaControls.css
+ mediaControlsQt.css
+ mediaControlsQuickTime.css
+ Media.cpp
+ MediaFeatureNames.cpp
+ MediaFeatureNames.h
+ Media.h
+ Media.idl
+ MediaList.cpp
+ MediaList.h
+ MediaList.idl
+ MediaQuery.cpp
+ MediaQueryEvaluator.cpp
+ MediaQueryEvaluator.h
+ MediaQueryExp.cpp
+ MediaQueryExp.h
+ MediaQuery.h
+ Pair.h
+ quirks.css
+ Rect.h
+ Rect.idl
+ RGBColor.cpp
+ RGBColor.h
+ RGBColor.idl
+ ShadowValue.cpp
+ ShadowValue.h
+ StyleBase.cpp
+ StyleBase.h
+ StyleList.cpp
+ StyleList.h
+ StyleSheet.cpp
+ StyleSheet.h
+ StyleSheet.idl
+ StyleSheetList.cpp
+ StyleSheetList.h
+ StyleSheetList.idl
+ svg.css
+ SVGCSSComputedStyleDeclaration.cpp
+ SVGCSSParser.cpp
+ SVGCSSPropertyNames.in
+ SVGCSSStyleSelector.cpp
+ SVGCSSValueKeywords.in
+ themeChromiumLinux.css
+ themeWin.css
+ themeWinQuirks.css
+ tokenizer.flex
+ view-source.css
+ WCSSPropertyNames.in
+ WCSSValueKeywords.in
+ WebKitCSSKeyframeRule.cpp
+ WebKitCSSKeyframeRule.h
+ WebKitCSSKeyframeRule.idl
+ WebKitCSSKeyframesRule.cpp
+ WebKitCSSKeyframesRule.h
+ WebKitCSSKeyframesRule.idl
+ WebKitCSSMatrix.cpp
+ WebKitCSSMatrix.h
+ WebKitCSSMatrix.idl
+ WebKitCSSTransformValue.cpp
+ WebKitCSSTransformValue.h
+ WebKitCSSTransformValue.idl
+ wml.css
+2 DerivedSources.cpp
+ dom/
+0 ActiveDOMObject.cpp
+ ActiveDOMObject.h
+ Attr.cpp
+ Attr.h
+ Attribute.cpp
+ Attribute.h
+ Attr.idl
+ BeforeLoadEvent.h
+ BeforeLoadEvent.idl
+ BeforeTextInsertedEvent.cpp
+ BeforeTextInsertedEvent.h
+ BeforeUnloadEvent.cpp
+ BeforeUnloadEvent.h
+ CDATASection.cpp
+ CDATASection.h
+ CDATASection.idl
+ CharacterData.cpp
+ CharacterData.h
+ CharacterData.idl
+ CheckedRadioButtons.cpp
+ CheckedRadioButtons.h
+ ChildNodeList.cpp
+ ChildNodeList.h
+ ClassNames.cpp
+ ClassNames.h
+ ClassNodeList.cpp
+ ClassNodeList.h
+ ClientRect.cpp
+ ClientRect.h
+ ClientRect.idl
+ ClientRectList.cpp
+ ClientRectList.h
+ ClientRectList.idl
+ ClipboardAccessPolicy.h
+ Clipboard.cpp
+ ClipboardEvent.cpp
+ ClipboardEvent.h
+ Clipboard.h
+ Clipboard.idl
+ Comment.cpp
+ Comment.h
+ Comment.idl
+ ContainerNodeAlgorithms.h
+ ContainerNode.cpp
+ ContainerNode.h
+ CSSMappedAttributeDeclaration.cpp
+ CSSMappedAttributeDeclaration.h
+ default/
+0 PlatformMessagePortChannel.cpp
+ PlatformMessagePortChannel.h
+2 Document.cpp
+ DocumentFragment.cpp
+ DocumentFragment.h
+ DocumentFragment.idl
+ Document.h
+ Document.idl
+ DocumentMarker.h
+ DocumentType.cpp
+ DocumentType.h
+ DocumentType.idl
+ DOMCoreException.h
+ DOMCoreException.idl
+ DOMImplementation.cpp
+ DOMImplementation.h
+ DOMImplementation.idl
+ DynamicNodeList.cpp
+ DynamicNodeList.h
+ EditingText.cpp
+ EditingText.h
+ Element.cpp
+ Element.h
+ Element.idl
+ ElementRareData.h
+ Entity.cpp
+ Entity.h
+ Entity.idl
+ EntityReference.cpp
+ EntityReference.h
+ EntityReference.idl
+ ErrorEvent.cpp
+ ErrorEvent.h
+ ErrorEvent.idl
+ Event.cpp
+ EventException.h
+ EventException.idl
+ Event.h
+ Event.idl
+ EventListener.h
+ EventListener.idl
+ EventNames.cpp
+ EventNames.h
+ EventTarget.cpp
+ EventTarget.h
+ EventTarget.idl
+ ExceptionBase.cpp
+ ExceptionBase.h
+ ExceptionCode.cpp
+ ExceptionCode.h
+ InputElement.cpp
+ InputElement.h
+ KeyboardEvent.cpp
+ KeyboardEvent.h
+ KeyboardEvent.idl
+ make_names.pl
+ MappedAttribute.cpp
+ MappedAttributeEntry.h
+ MappedAttribute.h
+ MessageChannel.cpp
+ MessageChannel.h
+ MessageChannel.idl
+ MessageEvent.cpp
+ MessageEvent.h
+ MessageEvent.idl
+ MessagePortChannel.cpp
+ MessagePortChannel.h
+ MessagePort.cpp
+ MessagePort.h
+ MessagePort.idl
+ MouseEvent.cpp
+ MouseEvent.h
+ MouseEvent.idl
+ MouseRelatedEvent.cpp
+ MouseRelatedEvent.h
+ MutationEvent.cpp
+ MutationEvent.h
+ MutationEvent.idl
+ NamedAttrMap.cpp
+ NamedAttrMap.h
+ NamedMappedAttrMap.cpp
+ NamedMappedAttrMap.h
+ NamedNodeMap.h
+ NamedNodeMap.idl
+ NameNodeList.cpp
+ NameNodeList.h
+ Node.cpp
+ NodeFilterCondition.cpp
+ NodeFilterCondition.h
+ NodeFilter.cpp
+ NodeFilter.h
+ NodeFilter.idl
+ Node.h
+ Node.idl
+ NodeIterator.cpp
+ NodeIterator.h
+ NodeIterator.idl
+ NodeList.h
+ NodeList.idl
+ NodeRareData.h
+ NodeRenderStyle.h
+ NodeWithIndex.h
+ Notation.cpp
+ Notation.h
+ Notation.idl
+ OptionElement.cpp
+ OptionElement.h
+ OptionGroupElement.cpp
+ OptionGroupElement.h
+ OverflowEvent.cpp
+ OverflowEvent.h
+ OverflowEvent.idl
+ PageTransitionEvent.cpp
+ PageTransitionEvent.h
+ PageTransitionEvent.idl
+ Position.cpp
+ PositionCreationFunctions.h
+ Position.h
+ PositionIterator.cpp
+ PositionIterator.h
+ ProcessingInstruction.cpp
+ ProcessingInstruction.h
+ ProcessingInstruction.idl
+ ProgressEvent.cpp
+ ProgressEvent.h
+ ProgressEvent.idl
+ QualifiedName.cpp
+ QualifiedName.h
+ RangeBoundaryPoint.h
+ Range.cpp
+ RangeException.h
+ RangeException.idl
+ Range.h
+ Range.idl
+ RegisteredEventListener.cpp
+ RegisteredEventListener.h
+ ScriptElement.cpp
+ ScriptElement.h
+ ScriptExecutionContext.cpp
+ ScriptExecutionContext.h
+ SelectElement.cpp
+ SelectElement.h
+ SelectorNodeList.cpp
+ SelectorNodeList.h
+ StaticNodeList.cpp
+ StaticNodeList.h
+ StyledElement.cpp
+ StyledElement.h
+ StyleElement.cpp
+ StyleElement.h
+ TagNodeList.cpp
+ TagNodeList.h
+ Text.cpp
+ TextEvent.cpp
+ TextEvent.h
+ TextEvent.idl
+ Text.h
+ Text.idl
+ Tokenizer.h
+ TransformSource.h
+ TransformSourceLibxslt.cpp
+ TransformSourceQt.cpp
+ Traversal.cpp
+ Traversal.h
+ TreeWalker.cpp
+ TreeWalker.h
+ TreeWalker.idl
+ UIEvent.cpp
+ UIEvent.h
+ UIEvent.idl
+ UIEventWithKeyState.cpp
+ UIEventWithKeyState.h
+ WebKitAnimationEvent.cpp
+ WebKitAnimationEvent.h
+ WebKitAnimationEvent.idl
+ WebKitTransitionEvent.cpp
+ WebKitTransitionEvent.h
+ WebKitTransitionEvent.idl
+ WheelEvent.cpp
+ WheelEvent.h
+ WheelEvent.idl
+ XMLTokenizer.cpp
+ XMLTokenizer.h
+ XMLTokenizerLibxml2.cpp
+ XMLTokenizerQt.cpp
+ XMLTokenizerScope.cpp
+ XMLTokenizerScope.h
+2 editing/
+0 android/
+0 EditorAndroid.cpp
+2 AppendNodeCommand.cpp
+ AppendNodeCommand.h
+ ApplyStyleCommand.cpp
+ ApplyStyleCommand.h
+ BreakBlockquoteCommand.cpp
+ BreakBlockquoteCommand.h
+ chromium/
+0 EditorChromium.cpp
+2 CompositeEditCommand.cpp
+ CompositeEditCommand.h
+ CreateLinkCommand.cpp
+ CreateLinkCommand.h
+ DeleteButtonController.cpp
+ DeleteButtonController.h
+ DeleteButton.cpp
+ DeleteButton.h
+ DeleteFromTextNodeCommand.cpp
+ DeleteFromTextNodeCommand.h
+ DeleteSelectionCommand.cpp
+ DeleteSelectionCommand.h
+ EditAction.h
+ EditCommand.cpp
+ EditCommand.h
+ EditorCommand.cpp
+ Editor.cpp
+ EditorDeleteAction.h
+ Editor.h
+ EditorInsertAction.h
+ FormatBlockCommand.cpp
+ FormatBlockCommand.h
+ gtk/
+0 SelectionControllerGtk.cpp
+2 htmlediting.cpp
+ htmlediting.h
+ HTMLInterchange.cpp
+ HTMLInterchange.h
+ IndentOutdentCommand.cpp
+ IndentOutdentCommand.h
+ InsertIntoTextNodeCommand.cpp
+ InsertIntoTextNodeCommand.h
+ InsertLineBreakCommand.cpp
+ InsertLineBreakCommand.h
+ InsertListCommand.cpp
+ InsertListCommand.h
+ InsertNodeBeforeCommand.cpp
+ InsertNodeBeforeCommand.h
+ InsertParagraphSeparatorCommand.cpp
+ InsertParagraphSeparatorCommand.h
+ InsertTextCommand.cpp
+ InsertTextCommand.h
+ JoinTextNodesCommand.cpp
+ JoinTextNodesCommand.h
+ markup.cpp
+ markup.h
+ MergeIdenticalElementsCommand.cpp
+ MergeIdenticalElementsCommand.h
+ ModifySelectionListLevel.cpp
+ ModifySelectionListLevel.h
+ MoveSelectionCommand.cpp
+ MoveSelectionCommand.h
+ qt/
+0 EditorQt.cpp
+2 RemoveCSSPropertyCommand.cpp
+ RemoveCSSPropertyCommand.h
+ RemoveFormatCommand.cpp
+ RemoveFormatCommand.h
+ RemoveNodeCommand.cpp
+ RemoveNodeCommand.h
+ RemoveNodePreservingChildrenCommand.cpp
+ RemoveNodePreservingChildrenCommand.h
+ ReplaceNodeWithSpanCommand.cpp
+ ReplaceNodeWithSpanCommand.h
+ ReplaceSelectionCommand.cpp
+ ReplaceSelectionCommand.h
+ SelectionController.cpp
+ SelectionController.h
+ SetNodeAttributeCommand.cpp
+ SetNodeAttributeCommand.h
+ SmartReplaceCF.cpp
+ SmartReplace.cpp
+ SmartReplace.h
+ SmartReplaceICU.cpp
+ SplitElementCommand.cpp
+ SplitElementCommand.h
+ SplitTextNodeCommand.cpp
+ SplitTextNodeCommand.h
+ SplitTextNodeContainingElementCommand.cpp
+ SplitTextNodeContainingElementCommand.h
+ TextAffinity.h
+ TextGranularity.h
+ TextIterator.cpp
+ TextIterator.h
+ TypingCommand.cpp
+ TypingCommand.h
+ UnlinkCommand.cpp
+ UnlinkCommand.h
+ VisiblePosition.cpp
+ VisiblePosition.h
+ VisibleSelection.cpp
+ VisibleSelection.h
+ visible_units.cpp
+ visible_units.h
+ WrapContentsInDummySpanCommand.cpp
+ WrapContentsInDummySpanCommand.h
+2 ForwardingHeaders/
+0 debugger/
+0 DebuggerActivation.h
+ DebuggerCallFrame.h
+ Debugger.h
+2 interpreter/
+0 CallFrame.h
+ Interpreter.h
+2 jit/
+0 JITCode.h
+2 masm/
+0 X86Assembler.h
+2 parser/
+0 SourceCode.h
+ SourceProvider.h
+2 pcre/
+0 pcre.h
+2 profiler/
+0 Profile.h
+ ProfileNode.h
+ Profiler.h
+2 runtime/
+0 ArgList.h
+ ArrayPrototype.h
+ BooleanObject.h
+ CallData.h
+ Collector.h
+ Completion.h
+ ConstructData.h
+ DateInstance.h
+ Error.h
+ ExceptionHelpers.h
+ FunctionConstructor.h
+ FunctionPrototype.h
+ Identifier.h
+ InitializeThreading.h
+ InternalFunction.h
+ JSAPIValueWrapper.h
+ JSArray.h
+ JSByteArray.h
+ JSCell.h
+ JSFunction.h
+ JSGlobalData.h
+ JSGlobalObject.h
+ JSLock.h
+ JSNumberCell.h
+ JSObject.h
+ JSString.h
+ JSValue.h
+ Lookup.h
+ ObjectPrototype.h
+ Operations.h
+ PropertyMap.h
+ PropertyNameArray.h
+ Protect.h
+ PrototypeFunction.h
+ StringObject.h
+ StringObjectThatMasqueradesAsUndefined.h
+ StringPrototype.h
+ StructureChain.h
+ Structure.h
+ SymbolTable.h
+ UString.h
+2 wrec/
+0 WREC.h
+2 wtf/
+0 AlwaysInline.h
+ ASCIICType.h
+ Assertions.h
+ ByteArray.h
+ CrossThreadRefCounted.h
+ CurrentTime.h
+ DateInstanceCache.h
+ DateMath.h
+ Deque.h
+ DisallowCType.h
+ dtoa.h
+ FastAllocBase.h
+ FastMalloc.h
+ Forward.h
+ GetPtr.h
+ HashCountedSet.h
+ HashFunctions.h
+ HashMap.h
+ HashSet.h
+ HashTable.h
+ HashTraits.h
+ ListHashSet.h
+ ListRefPtr.h
+ Locker.h
+ MainThread.h
+ MathExtras.h
+ MessageQueue.h
+ Noncopyable.h
+ NotFound.h
+ OwnArrayPtr.h
+ OwnFastMallocPtr.h
+ OwnPtrCommon.h
+ OwnPtr.h
+ PassOwnPtr.h
+ PassRefPtr.h
+ Platform.h
+ PossiblyNull.h
+ PtrAndFlags.h
+ RandomNumber.h
+ RefCounted.h
+ RefCountedLeakCounter.h
+ RefPtr.h
+ RetainPtr.h
+ StdLibExtras.h
+ StringExtras.h
+ Threading.h
+ ThreadSpecific.h
+ TypeTraits.h
+ unicode/
+0 Collator.h
+ icu/
+0 UnicodeIcu.h
+2 Unicode.h
+ UTF8.h
+2 UnusedParam.h
+ Vector.h
+ VectorTraits.h
+ VMTags.h
+3 generated/
+0 ArrayPrototype.lut.h
+ chartables.c
+ ColorData.c
+ CSSGrammar.cpp
+ CSSGrammar.h
+ CSSPropertyNames.cpp
+ CSSPropertyNames.h
+ CSSValueKeywords.c
+ CSSValueKeywords.h
+ DatePrototype.lut.h
+ DocTypeStrings.cpp
+ Grammar.cpp
+ Grammar.h
+ HTMLElementFactory.cpp
+ HTMLElementFactory.h
+ HTMLEntityNames.c
+ HTMLNames.cpp
+ HTMLNames.h
+ JSAbstractWorker.cpp
+ JSAbstractWorker.h
+ JSAttr.cpp
+ JSAttr.h
+ JSBarInfo.cpp
+ JSBarInfo.h
+ JSBeforeLoadEvent.cpp
+ JSBeforeLoadEvent.h
+ JSCanvasArrayBuffer.cpp
+ JSCanvasArrayBuffer.h
+ JSCanvasArray.cpp
+ JSCanvasArray.h
+ JSCanvasByteArray.cpp
+ JSCanvasByteArray.h
+ JSCanvasFloatArray.cpp
+ JSCanvasFloatArray.h
+ JSCanvasGradient.cpp
+ JSCanvasGradient.h
+ JSCanvasIntArray.cpp
+ JSCanvasIntArray.h
+ JSCanvasPattern.cpp
+ JSCanvasPattern.h
+ JSCanvasRenderingContext2D.cpp
+ JSCanvasRenderingContext2D.h
+ JSCanvasRenderingContext3D.cpp
+ JSCanvasRenderingContext3D.h
+ JSCanvasRenderingContext.cpp
+ JSCanvasRenderingContext.h
+ JSCanvasShortArray.cpp
+ JSCanvasShortArray.h
+ JSCanvasUnsignedByteArray.cpp
+ JSCanvasUnsignedByteArray.h
+ JSCanvasUnsignedIntArray.cpp
+ JSCanvasUnsignedIntArray.h
+ JSCanvasUnsignedShortArray.cpp
+ JSCanvasUnsignedShortArray.h
+ JSCDATASection.cpp
+ JSCDATASection.h
+ JSCharacterData.cpp
+ JSCharacterData.h
+ JSClientRect.cpp
+ JSClientRect.h
+ JSClientRectList.cpp
+ JSClientRectList.h
+ JSClipboard.cpp
+ JSClipboard.h
+ JSComment.cpp
+ JSComment.h
+ JSConsole.cpp
+ JSConsole.h
+ JSCoordinates.cpp
+ JSCoordinates.h
+ JSCounter.cpp
+ JSCounter.h
+ JSCSSCharsetRule.cpp
+ JSCSSCharsetRule.h
+ JSCSSFontFaceRule.cpp
+ JSCSSFontFaceRule.h
+ JSCSSImportRule.cpp
+ JSCSSImportRule.h
+ JSCSSMediaRule.cpp
+ JSCSSMediaRule.h
+ JSCSSPageRule.cpp
+ JSCSSPageRule.h
+ JSCSSPrimitiveValue.cpp
+ JSCSSPrimitiveValue.h
+ JSCSSRule.cpp
+ JSCSSRule.h
+ JSCSSRuleList.cpp
+ JSCSSRuleList.h
+ JSCSSStyleDeclaration.cpp
+ JSCSSStyleDeclaration.h
+ JSCSSStyleRule.cpp
+ JSCSSStyleRule.h
+ JSCSSStyleSheet.cpp
+ JSCSSStyleSheet.h
+ JSCSSValue.cpp
+ JSCSSValue.h
+ JSCSSValueList.cpp
+ JSCSSValueList.h
+ JSCSSVariablesDeclaration.cpp
+ JSCSSVariablesDeclaration.h
+ JSCSSVariablesRule.cpp
+ JSCSSVariablesRule.h
+ JSDatabase.cpp
+ JSDatabase.h
+ JSDataGridColumn.cpp
+ JSDataGridColumn.h
+ JSDataGridColumnList.cpp
+ JSDataGridColumnList.h
+ JSDedicatedWorkerContext.cpp
+ JSDedicatedWorkerContext.h
+ JSDocument.cpp
+ JSDocumentFragment.cpp
+ JSDocumentFragment.h
+ JSDocument.h
+ JSDocumentType.cpp
+ JSDocumentType.h
+ JSDOMApplicationCache.cpp
+ JSDOMApplicationCache.h
+ JSDOMCoreException.cpp
+ JSDOMCoreException.h
+ JSDOMImplementation.cpp
+ JSDOMImplementation.h
+ JSDOMParser.cpp
+ JSDOMParser.h
+ JSDOMSelection.cpp
+ JSDOMSelection.h
+ JSDOMWindowBase.lut.h
+ JSDOMWindow.cpp
+ JSDOMWindow.h
+ JSElement.cpp
+ JSElement.h
+ JSEntity.cpp
+ JSEntity.h
+ JSEntityReference.cpp
+ JSEntityReference.h
+ JSErrorEvent.cpp
+ JSErrorEvent.h
+ JSEvent.cpp
+ JSEventException.cpp
+ JSEventException.h
+ JSEvent.h
+ JSEventSource.cpp
+ JSEventSource.h
+ JSFile.cpp
+ JSFile.h
+ JSFileList.cpp
+ JSFileList.h
+ JSGeolocation.cpp
+ JSGeolocation.h
+ JSGeoposition.cpp
+ JSGeoposition.h
+ JSHistory.cpp
+ JSHistory.h
+ JSHTMLAllCollection.cpp
+ JSHTMLAllCollection.h
+ JSHTMLAnchorElement.cpp
+ JSHTMLAnchorElement.h
+ JSHTMLAppletElement.cpp
+ JSHTMLAppletElement.h
+ JSHTMLAreaElement.cpp
+ JSHTMLAreaElement.h
+ JSHTMLAudioElement.cpp
+ JSHTMLAudioElement.h
+ JSHTMLBaseElement.cpp
+ JSHTMLBaseElement.h
+ JSHTMLBaseFontElement.cpp
+ JSHTMLBaseFontElement.h
+ JSHTMLBlockquoteElement.cpp
+ JSHTMLBlockquoteElement.h
+ JSHTMLBodyElement.cpp
+ JSHTMLBodyElement.h
+ JSHTMLBRElement.cpp
+ JSHTMLBRElement.h
+ JSHTMLButtonElement.cpp
+ JSHTMLButtonElement.h
+ JSHTMLCanvasElement.cpp
+ JSHTMLCanvasElement.h
+ JSHTMLCollection.cpp
+ JSHTMLCollection.h
+ JSHTMLDataGridCellElement.cpp
+ JSHTMLDataGridCellElement.h
+ JSHTMLDataGridColElement.cpp
+ JSHTMLDataGridColElement.h
+ JSHTMLDataGridElement.cpp
+ JSHTMLDataGridElement.h
+ JSHTMLDataGridRowElement.cpp
+ JSHTMLDataGridRowElement.h
+ JSHTMLDataListElement.cpp
+ JSHTMLDataListElement.h
+ JSHTMLDirectoryElement.cpp
+ JSHTMLDirectoryElement.h
+ JSHTMLDivElement.cpp
+ JSHTMLDivElement.h
+ JSHTMLDListElement.cpp
+ JSHTMLDListElement.h
+ JSHTMLDocument.cpp
+ JSHTMLDocument.h
+ JSHTMLElement.cpp
+ JSHTMLElement.h
+ JSHTMLElementWrapperFactory.cpp
+ JSHTMLElementWrapperFactory.h
+ JSHTMLEmbedElement.cpp
+ JSHTMLEmbedElement.h
+ JSHTMLFieldSetElement.cpp
+ JSHTMLFieldSetElement.h
+ JSHTMLFontElement.cpp
+ JSHTMLFontElement.h
+ JSHTMLFormElement.cpp
+ JSHTMLFormElement.h
+ JSHTMLFrameElement.cpp
+ JSHTMLFrameElement.h
+ JSHTMLFrameSetElement.cpp
+ JSHTMLFrameSetElement.h
+ JSHTMLHeadElement.cpp
+ JSHTMLHeadElement.h
+ JSHTMLHeadingElement.cpp
+ JSHTMLHeadingElement.h
+ JSHTMLHRElement.cpp
+ JSHTMLHRElement.h
+ JSHTMLHtmlElement.cpp
+ JSHTMLHtmlElement.h
+ JSHTMLIFrameElement.cpp
+ JSHTMLIFrameElement.h
+ JSHTMLImageElement.cpp
+ JSHTMLImageElement.h
+ JSHTMLInputElement.cpp
+ JSHTMLInputElement.h
+ JSHTMLIsIndexElement.cpp
+ JSHTMLIsIndexElement.h
+ JSHTMLLabelElement.cpp
+ JSHTMLLabelElement.h
+ JSHTMLLegendElement.cpp
+ JSHTMLLegendElement.h
+ JSHTMLLIElement.cpp
+ JSHTMLLIElement.h
+ JSHTMLLinkElement.cpp
+ JSHTMLLinkElement.h
+ JSHTMLMapElement.cpp
+ JSHTMLMapElement.h
+ JSHTMLMarqueeElement.cpp
+ JSHTMLMarqueeElement.h
+ JSHTMLMediaElement.cpp
+ JSHTMLMediaElement.h
+ JSHTMLMenuElement.cpp
+ JSHTMLMenuElement.h
+ JSHTMLMetaElement.cpp
+ JSHTMLMetaElement.h
+ JSHTMLModElement.cpp
+ JSHTMLModElement.h
+ JSHTMLObjectElement.cpp
+ JSHTMLObjectElement.h
+ JSHTMLOListElement.cpp
+ JSHTMLOListElement.h
+ JSHTMLOptGroupElement.cpp
+ JSHTMLOptGroupElement.h
+ JSHTMLOptionElement.cpp
+ JSHTMLOptionElement.h
+ JSHTMLOptionsCollection.cpp
+ JSHTMLOptionsCollection.h
+ JSHTMLParagraphElement.cpp
+ JSHTMLParagraphElement.h
+ JSHTMLParamElement.cpp
+ JSHTMLParamElement.h
+ JSHTMLPreElement.cpp
+ JSHTMLPreElement.h
+ JSHTMLQuoteElement.cpp
+ JSHTMLQuoteElement.h
+ JSHTMLScriptElement.cpp
+ JSHTMLScriptElement.h
+ JSHTMLSelectElement.cpp
+ JSHTMLSelectElement.h
+ JSHTMLSourceElement.cpp
+ JSHTMLSourceElement.h
+ JSHTMLStyleElement.cpp
+ JSHTMLStyleElement.h
+ JSHTMLTableCaptionElement.cpp
+ JSHTMLTableCaptionElement.h
+ JSHTMLTableCellElement.cpp
+ JSHTMLTableCellElement.h
+ JSHTMLTableColElement.cpp
+ JSHTMLTableColElement.h
+ JSHTMLTableElement.cpp
+ JSHTMLTableElement.h
+ JSHTMLTableRowElement.cpp
+ JSHTMLTableRowElement.h
+ JSHTMLTableSectionElement.cpp
+ JSHTMLTableSectionElement.h
+ JSHTMLTextAreaElement.cpp
+ JSHTMLTextAreaElement.h
+ JSHTMLTitleElement.cpp
+ JSHTMLTitleElement.h
+ JSHTMLUListElement.cpp
+ JSHTMLUListElement.h
+ JSHTMLVideoElement.cpp
+ JSHTMLVideoElement.h
+ JSImageData.cpp
+ JSImageData.h
+ JSInspectorBackend.cpp
+ JSInspectorBackend.h
+ JSJavaScriptCallFrame.cpp
+ JSJavaScriptCallFrame.h
+ JSKeyboardEvent.cpp
+ JSKeyboardEvent.h
+ JSLocation.cpp
+ JSLocation.h
+ JSMedia.cpp
+ JSMediaError.cpp
+ JSMediaError.h
+ JSMedia.h
+ JSMediaList.cpp
+ JSMediaList.h
+ JSMessageChannel.cpp
+ JSMessageChannel.h
+ JSMessageEvent.cpp
+ JSMessageEvent.h
+ JSMessagePort.cpp
+ JSMessagePort.h
+ JSMimeTypeArray.cpp
+ JSMimeTypeArray.h
+ JSMimeType.cpp
+ JSMimeType.h
+ JSMouseEvent.cpp
+ JSMouseEvent.h
+ JSMutationEvent.cpp
+ JSMutationEvent.h
+ JSNamedNodeMap.cpp
+ JSNamedNodeMap.h
+ JSNavigator.cpp
+ JSNavigator.h
+ JSNode.cpp
+ JSNodeFilter.cpp
+ JSNodeFilter.h
+ JSNode.h
+ JSNodeIterator.cpp
+ JSNodeIterator.h
+ JSNodeList.cpp
+ JSNodeList.h
+ JSNotation.cpp
+ JSNotation.h
+ JSONObject.lut.h
+ JSOverflowEvent.cpp
+ JSOverflowEvent.h
+ JSPageTransitionEvent.cpp
+ JSPageTransitionEvent.h
+ JSPluginArray.cpp
+ JSPluginArray.h
+ JSPlugin.cpp
+ JSPlugin.h
+ JSPositionError.cpp
+ JSPositionError.h
+ JSProcessingInstruction.cpp
+ JSProcessingInstruction.h
+ JSProgressEvent.cpp
+ JSProgressEvent.h
+ JSRange.cpp
+ JSRangeException.cpp
+ JSRangeException.h
+ JSRange.h
+ JSRect.cpp
+ JSRect.h
+ JSRGBColor.cpp
+ JSRGBColor.h
+ JSScreen.cpp
+ JSScreen.h
+ JSSharedWorkerContext.cpp
+ JSSharedWorkerContext.h
+ JSSharedWorker.cpp
+ JSSharedWorker.h
+ JSSQLError.cpp
+ JSSQLError.h
+ JSSQLResultSet.cpp
+ JSSQLResultSet.h
+ JSSQLResultSetRowList.cpp
+ JSSQLResultSetRowList.h
+ JSSQLTransaction.cpp
+ JSSQLTransaction.h
+ JSStorage.cpp
+ JSStorageEvent.cpp
+ JSStorageEvent.h
+ JSStorage.h
+ JSStyleSheet.cpp
+ JSStyleSheet.h
+ JSStyleSheetList.cpp
+ JSStyleSheetList.h
+ JSSVGAElement.cpp
+ JSSVGAElement.h
+ JSSVGAltGlyphElement.cpp
+ JSSVGAltGlyphElement.h
+ JSSVGAngle.cpp
+ JSSVGAngle.h
+ JSSVGAnimateColorElement.cpp
+ JSSVGAnimateColorElement.h
+ JSSVGAnimatedAngle.cpp
+ JSSVGAnimatedAngle.h
+ JSSVGAnimatedBoolean.cpp
+ JSSVGAnimatedBoolean.h
+ JSSVGAnimatedEnumeration.cpp
+ JSSVGAnimatedEnumeration.h
+ JSSVGAnimatedInteger.cpp
+ JSSVGAnimatedInteger.h
+ JSSVGAnimatedLength.cpp
+ JSSVGAnimatedLength.h
+ JSSVGAnimatedLengthList.cpp
+ JSSVGAnimatedLengthList.h
+ JSSVGAnimatedNumber.cpp
+ JSSVGAnimatedNumber.h
+ JSSVGAnimatedNumberList.cpp
+ JSSVGAnimatedNumberList.h
+ JSSVGAnimatedPreserveAspectRatio.cpp
+ JSSVGAnimatedPreserveAspectRatio.h
+ JSSVGAnimatedRect.cpp
+ JSSVGAnimatedRect.h
+ JSSVGAnimatedString.cpp
+ JSSVGAnimatedString.h
+ JSSVGAnimatedTransformList.cpp
+ JSSVGAnimatedTransformList.h
+ JSSVGAnimateElement.cpp
+ JSSVGAnimateElement.h
+ JSSVGAnimateTransformElement.cpp
+ JSSVGAnimateTransformElement.h
+ JSSVGAnimationElement.cpp
+ JSSVGAnimationElement.h
+ JSSVGCircleElement.cpp
+ JSSVGCircleElement.h
+ JSSVGClipPathElement.cpp
+ JSSVGClipPathElement.h
+ JSSVGColor.cpp
+ JSSVGColor.h
+ JSSVGComponentTransferFunctionElement.cpp
+ JSSVGComponentTransferFunctionElement.h
+ JSSVGCursorElement.cpp
+ JSSVGCursorElement.h
+ JSSVGDefsElement.cpp
+ JSSVGDefsElement.h
+ JSSVGDescElement.cpp
+ JSSVGDescElement.h
+ JSSVGDocument.cpp
+ JSSVGDocument.h
+ JSSVGElement.cpp
+ JSSVGElement.h
+ JSSVGElementInstance.cpp
+ JSSVGElementInstance.h
+ JSSVGElementInstanceList.cpp
+ JSSVGElementInstanceList.h
+ JSSVGElementWrapperFactory.cpp
+ JSSVGElementWrapperFactory.h
+ JSSVGEllipseElement.cpp
+ JSSVGEllipseElement.h
+ JSSVGException.cpp
+ JSSVGException.h
+ JSSVGFEBlendElement.cpp
+ JSSVGFEBlendElement.h
+ JSSVGFEColorMatrixElement.cpp
+ JSSVGFEColorMatrixElement.h
+ JSSVGFEComponentTransferElement.cpp
+ JSSVGFEComponentTransferElement.h
+ JSSVGFECompositeElement.cpp
+ JSSVGFECompositeElement.h
+ JSSVGFEDiffuseLightingElement.cpp
+ JSSVGFEDiffuseLightingElement.h
+ JSSVGFEDisplacementMapElement.cpp
+ JSSVGFEDisplacementMapElement.h
+ JSSVGFEDistantLightElement.cpp
+ JSSVGFEDistantLightElement.h
+ JSSVGFEFloodElement.cpp
+ JSSVGFEFloodElement.h
+ JSSVGFEFuncAElement.cpp
+ JSSVGFEFuncAElement.h
+ JSSVGFEFuncBElement.cpp
+ JSSVGFEFuncBElement.h
+ JSSVGFEFuncGElement.cpp
+ JSSVGFEFuncGElement.h
+ JSSVGFEFuncRElement.cpp
+ JSSVGFEFuncRElement.h
+ JSSVGFEGaussianBlurElement.cpp
+ JSSVGFEGaussianBlurElement.h
+ JSSVGFEImageElement.cpp
+ JSSVGFEImageElement.h
+ JSSVGFEMergeElement.cpp
+ JSSVGFEMergeElement.h
+ JSSVGFEMergeNodeElement.cpp
+ JSSVGFEMergeNodeElement.h
+ JSSVGFEMorphologyElement.cpp
+ JSSVGFEMorphologyElement.h
+ JSSVGFEOffsetElement.cpp
+ JSSVGFEOffsetElement.h
+ JSSVGFEPointLightElement.cpp
+ JSSVGFEPointLightElement.h
+ JSSVGFESpecularLightingElement.cpp
+ JSSVGFESpecularLightingElement.h
+ JSSVGFESpotLightElement.cpp
+ JSSVGFESpotLightElement.h
+ JSSVGFETileElement.cpp
+ JSSVGFETileElement.h
+ JSSVGFETurbulenceElement.cpp
+ JSSVGFETurbulenceElement.h
+ JSSVGFilterElement.cpp
+ JSSVGFilterElement.h
+ JSSVGFontElement.cpp
+ JSSVGFontElement.h
+ JSSVGFontFaceElement.cpp
+ JSSVGFontFaceElement.h
+ JSSVGFontFaceFormatElement.cpp
+ JSSVGFontFaceFormatElement.h
+ JSSVGFontFaceNameElement.cpp
+ JSSVGFontFaceNameElement.h
+ JSSVGFontFaceSrcElement.cpp
+ JSSVGFontFaceSrcElement.h
+ JSSVGFontFaceUriElement.cpp
+ JSSVGFontFaceUriElement.h
+ JSSVGForeignObjectElement.cpp
+ JSSVGForeignObjectElement.h
+ JSSVGGElement.cpp
+ JSSVGGElement.h
+ JSSVGGlyphElement.cpp
+ JSSVGGlyphElement.h
+ JSSVGGradientElement.cpp
+ JSSVGGradientElement.h
+ JSSVGHKernElement.cpp
+ JSSVGHKernElement.h
+ JSSVGImageElement.cpp
+ JSSVGImageElement.h
+ JSSVGLength.cpp
+ JSSVGLength.h
+ JSSVGLengthList.cpp
+ JSSVGLengthList.h
+ JSSVGLinearGradientElement.cpp
+ JSSVGLinearGradientElement.h
+ JSSVGLineElement.cpp
+ JSSVGLineElement.h
+ JSSVGMarkerElement.cpp
+ JSSVGMarkerElement.h
+ JSSVGMaskElement.cpp
+ JSSVGMaskElement.h
+ JSSVGMatrix.cpp
+ JSSVGMatrix.h
+ JSSVGMetadataElement.cpp
+ JSSVGMetadataElement.h
+ JSSVGMissingGlyphElement.cpp
+ JSSVGMissingGlyphElement.h
+ JSSVGNumber.cpp
+ JSSVGNumber.h
+ JSSVGNumberList.cpp
+ JSSVGNumberList.h
+ JSSVGPaint.cpp
+ JSSVGPaint.h
+ JSSVGPathElement.cpp
+ JSSVGPathElement.h
+ JSSVGPathSegArcAbs.cpp
+ JSSVGPathSegArcAbs.h
+ JSSVGPathSegArcRel.cpp
+ JSSVGPathSegArcRel.h
+ JSSVGPathSegClosePath.cpp
+ JSSVGPathSegClosePath.h
+ JSSVGPathSeg.cpp
+ JSSVGPathSegCurvetoCubicAbs.cpp
+ JSSVGPathSegCurvetoCubicAbs.h
+ JSSVGPathSegCurvetoCubicRel.cpp
+ JSSVGPathSegCurvetoCubicRel.h
+ JSSVGPathSegCurvetoCubicSmoothAbs.cpp
+ JSSVGPathSegCurvetoCubicSmoothAbs.h
+ JSSVGPathSegCurvetoCubicSmoothRel.cpp
+ JSSVGPathSegCurvetoCubicSmoothRel.h
+ JSSVGPathSegCurvetoQuadraticAbs.cpp
+ JSSVGPathSegCurvetoQuadraticAbs.h
+ JSSVGPathSegCurvetoQuadraticRel.cpp
+ JSSVGPathSegCurvetoQuadraticRel.h
+ JSSVGPathSegCurvetoQuadraticSmoothAbs.cpp
+ JSSVGPathSegCurvetoQuadraticSmoothAbs.h
+ JSSVGPathSegCurvetoQuadraticSmoothRel.cpp
+ JSSVGPathSegCurvetoQuadraticSmoothRel.h
+ JSSVGPathSeg.h
+ JSSVGPathSegLinetoAbs.cpp
+ JSSVGPathSegLinetoAbs.h
+ JSSVGPathSegLinetoHorizontalAbs.cpp
+ JSSVGPathSegLinetoHorizontalAbs.h
+ JSSVGPathSegLinetoHorizontalRel.cpp
+ JSSVGPathSegLinetoHorizontalRel.h
+ JSSVGPathSegLinetoRel.cpp
+ JSSVGPathSegLinetoRel.h
+ JSSVGPathSegLinetoVerticalAbs.cpp
+ JSSVGPathSegLinetoVerticalAbs.h
+ JSSVGPathSegLinetoVerticalRel.cpp
+ JSSVGPathSegLinetoVerticalRel.h
+ JSSVGPathSegList.cpp
+ JSSVGPathSegList.h
+ JSSVGPathSegMovetoAbs.cpp
+ JSSVGPathSegMovetoAbs.h
+ JSSVGPathSegMovetoRel.cpp
+ JSSVGPathSegMovetoRel.h
+ JSSVGPatternElement.cpp
+ JSSVGPatternElement.h
+ JSSVGPoint.cpp
+ JSSVGPoint.h
+ JSSVGPointList.cpp
+ JSSVGPointList.h
+ JSSVGPolygonElement.cpp
+ JSSVGPolygonElement.h
+ JSSVGPolylineElement.cpp
+ JSSVGPolylineElement.h
+ JSSVGPreserveAspectRatio.cpp
+ JSSVGPreserveAspectRatio.h
+ JSSVGRadialGradientElement.cpp
+ JSSVGRadialGradientElement.h
+ JSSVGRect.cpp
+ JSSVGRectElement.cpp
+ JSSVGRectElement.h
+ JSSVGRect.h
+ JSSVGRenderingIntent.cpp
+ JSSVGRenderingIntent.h
+ JSSVGScriptElement.cpp
+ JSSVGScriptElement.h
+ JSSVGSetElement.cpp
+ JSSVGSetElement.h
+ JSSVGStopElement.cpp
+ JSSVGStopElement.h
+ JSSVGStringList.cpp
+ JSSVGStringList.h
+ JSSVGStyleElement.cpp
+ JSSVGStyleElement.h
+ JSSVGSVGElement.cpp
+ JSSVGSVGElement.h
+ JSSVGSwitchElement.cpp
+ JSSVGSwitchElement.h
+ JSSVGSymbolElement.cpp
+ JSSVGSymbolElement.h
+ JSSVGTextContentElement.cpp
+ JSSVGTextContentElement.h
+ JSSVGTextElement.cpp
+ JSSVGTextElement.h
+ JSSVGTextPathElement.cpp
+ JSSVGTextPathElement.h
+ JSSVGTextPositioningElement.cpp
+ JSSVGTextPositioningElement.h
+ JSSVGTitleElement.cpp
+ JSSVGTitleElement.h
+ JSSVGTransform.cpp
+ JSSVGTransform.h
+ JSSVGTransformList.cpp
+ JSSVGTransformList.h
+ JSSVGTRefElement.cpp
+ JSSVGTRefElement.h
+ JSSVGTSpanElement.cpp
+ JSSVGTSpanElement.h
+ JSSVGUnitTypes.cpp
+ JSSVGUnitTypes.h
+ JSSVGUseElement.cpp
+ JSSVGUseElement.h
+ JSSVGViewElement.cpp
+ JSSVGViewElement.h
+ JSSVGZoomEvent.cpp
+ JSSVGZoomEvent.h
+ JSText.cpp
+ JSTextEvent.cpp
+ JSTextEvent.h
+ JSText.h
+ JSTextMetrics.cpp
+ JSTextMetrics.h
+ JSTimeRanges.cpp
+ JSTimeRanges.h
+ JSTreeWalker.cpp
+ JSTreeWalker.h
+ JSUIEvent.cpp
+ JSUIEvent.h
+ JSValidityState.cpp
+ JSValidityState.h
+ JSVoidCallback.cpp
+ JSVoidCallback.h
+ JSWebKitAnimationEvent.cpp
+ JSWebKitAnimationEvent.h
+ JSWebKitCSSKeyframeRule.cpp
+ JSWebKitCSSKeyframeRule.h
+ JSWebKitCSSKeyframesRule.cpp
+ JSWebKitCSSKeyframesRule.h
+ JSWebKitCSSMatrix.cpp
+ JSWebKitCSSMatrix.h
+ JSWebKitCSSTransformValue.cpp
+ JSWebKitCSSTransformValue.h
+ JSWebKitPoint.cpp
+ JSWebKitPoint.h
+ JSWebKitTransitionEvent.cpp
+ JSWebKitTransitionEvent.h
+ JSWebSocket.cpp
+ JSWebSocket.h
+ JSWheelEvent.cpp
+ JSWheelEvent.h
+ JSWorkerContextBase.lut.h
+ JSWorkerContext.cpp
+ JSWorkerContext.h
+ JSWorker.cpp
+ JSWorker.h
+ JSWorkerLocation.cpp
+ JSWorkerLocation.h
+ JSWorkerNavigator.cpp
+ JSWorkerNavigator.h
+ JSXMLHttpRequest.cpp
+ JSXMLHttpRequestException.cpp
+ JSXMLHttpRequestException.h
+ JSXMLHttpRequest.h
+ JSXMLHttpRequestProgressEvent.cpp
+ JSXMLHttpRequestProgressEvent.h
+ JSXMLHttpRequestUpload.cpp
+ JSXMLHttpRequestUpload.h
+ JSXMLSerializer.cpp
+ JSXMLSerializer.h
+ JSXPathEvaluator.cpp
+ JSXPathEvaluator.h
+ JSXPathException.cpp
+ JSXPathException.h
+ JSXPathExpression.cpp
+ JSXPathExpression.h
+ JSXPathNSResolver.cpp
+ JSXPathNSResolver.h
+ JSXPathResult.cpp
+ JSXPathResult.h
+ JSXSLTProcessor.cpp
+ JSXSLTProcessor.h
+ Lexer.lut.h
+ MathObject.lut.h
+ NumberConstructor.lut.h
+ RegExpConstructor.lut.h
+ RegExpObject.lut.h
+ StringPrototype.lut.h
+ SVGElementFactory.cpp
+ SVGElementFactory.h
+ SVGNames.cpp
+ SVGNames.h
+ tokenizer.cpp
+ UserAgentStyleSheetsData.cpp
+ UserAgentStyleSheets.h
+ WebKitVersion.h
+ XLinkNames.cpp
+ XLinkNames.h
+ XMLNames.cpp
+ XMLNames.h
+ XPathGrammar.cpp
+ XPathGrammar.h
+2 history/
+0 BackForwardListChromium.cpp
+ BackForwardList.cpp
+ BackForwardList.h
+ CachedFrame.cpp
+ CachedFrame.h
+ CachedFramePlatformData.h
+ CachedPage.cpp
+ CachedPage.h
+ cf/
+0 HistoryPropertyList.cpp
+ HistoryPropertyList.h
+2 HistoryItem.cpp
+ HistoryItem.h
+ PageCache.cpp
+ PageCache.h
+ qt/
+0 HistoryItemQt.cpp
+3 html/
+0 canvas/
+0 CanvasActiveInfo.h
+ CanvasActiveInfo.idl
+ CanvasArrayBuffer.cpp
+ CanvasArrayBuffer.h
+ CanvasArrayBuffer.idl
+ CanvasArray.cpp
+ CanvasArray.h
+ CanvasArray.idl
+ CanvasBuffer.cpp
+ CanvasBuffer.h
+ CanvasBuffer.idl
+ CanvasByteArray.cpp
+ CanvasByteArray.h
+ CanvasByteArray.idl
+ CanvasFloatArray.cpp
+ CanvasFloatArray.h
+ CanvasFloatArray.idl
+ CanvasFramebuffer.cpp
+ CanvasFramebuffer.h
+ CanvasFramebuffer.idl
+ CanvasGradient.cpp
+ CanvasGradient.h
+ CanvasGradient.idl
+ CanvasIntArray.cpp
+ CanvasIntArray.h
+ CanvasIntArray.idl
+ CanvasNumberArray.cpp
+ CanvasNumberArray.h
+ CanvasNumberArray.idl
+ CanvasObject.cpp
+ CanvasObject.h
+ CanvasPattern.cpp
+ CanvasPattern.h
+ CanvasPattern.idl
+ CanvasPixelArray.cpp
+ CanvasPixelArray.h
+ CanvasPixelArray.idl
+ CanvasProgram.cpp
+ CanvasProgram.h
+ CanvasProgram.idl
+ CanvasRenderbuffer.cpp
+ CanvasRenderbuffer.h
+ CanvasRenderbuffer.idl
+ CanvasRenderingContext2D.cpp
+ CanvasRenderingContext2D.h
+ CanvasRenderingContext2D.idl
+ CanvasRenderingContext3D.cpp
+ CanvasRenderingContext3D.h
+ CanvasRenderingContext3D.idl
+ CanvasRenderingContext.cpp
+ CanvasRenderingContext.h
+ CanvasRenderingContext.idl
+ CanvasShader.cpp
+ CanvasShader.h
+ CanvasShader.idl
+ CanvasShortArray.cpp
+ CanvasShortArray.h
+ CanvasShortArray.idl
+ CanvasStyle.cpp
+ CanvasStyle.h
+ CanvasTexture.cpp
+ CanvasTexture.h
+ CanvasTexture.idl
+ CanvasUnsignedByteArray.cpp
+ CanvasUnsignedByteArray.h
+ CanvasUnsignedByteArray.idl
+ CanvasUnsignedIntArray.cpp
+ CanvasUnsignedIntArray.h
+ CanvasUnsignedIntArray.idl
+ CanvasUnsignedShortArray.cpp
+ CanvasUnsignedShortArray.h
+ CanvasUnsignedShortArray.idl
+2 CollectionCache.cpp
+ CollectionCache.h
+ CollectionType.h
+ DataGridColumn.cpp
+ DataGridColumn.h
+ DataGridColumn.idl
+ DataGridColumnList.cpp
+ DataGridColumnList.h
+ DataGridColumnList.idl
+ DataGridDataSource.h
+ DocTypeStrings.gperf
+ DOMDataGridDataSource.cpp
+ DOMDataGridDataSource.h
+ File.cpp
+ File.h
+ File.idl
+ FileList.cpp
+ FileList.h
+ FileList.idl
+ FormDataList.cpp
+ FormDataList.h
+ HTMLAllCollection.cpp
+ HTMLAllCollection.h
+ HTMLAllCollection.idl
+ HTMLAnchorElement.cpp
+ HTMLAnchorElement.h
+ HTMLAnchorElement.idl
+ HTMLAppletElement.cpp
+ HTMLAppletElement.h
+ HTMLAppletElement.idl
+ HTMLAreaElement.cpp
+ HTMLAreaElement.h
+ HTMLAreaElement.idl
+ HTMLAttributeNames.in
+ HTMLAudioElement.cpp
+ HTMLAudioElement.h
+ HTMLAudioElement.idl
+ HTMLBaseElement.cpp
+ HTMLBaseElement.h
+ HTMLBaseElement.idl
+ HTMLBaseFontElement.cpp
+ HTMLBaseFontElement.h
+ HTMLBaseFontElement.idl
+ HTMLBlockquoteElement.cpp
+ HTMLBlockquoteElement.h
+ HTMLBlockquoteElement.idl
+ HTMLBodyElement.cpp
+ HTMLBodyElement.h
+ HTMLBodyElement.idl
+ HTMLBRElement.cpp
+ HTMLBRElement.h
+ HTMLBRElement.idl
+ HTMLButtonElement.cpp
+ HTMLButtonElement.h
+ HTMLButtonElement.idl
+ HTMLCanvasElement.cpp
+ HTMLCanvasElement.h
+ HTMLCanvasElement.idl
+ HTMLCollection.cpp
+ HTMLCollection.h
+ HTMLCollection.idl
+ HTMLDataGridCellElement.cpp
+ HTMLDataGridCellElement.h
+ HTMLDataGridCellElement.idl
+ HTMLDataGridColElement.cpp
+ HTMLDataGridColElement.h
+ HTMLDataGridColElement.idl
+ HTMLDataGridElement.cpp
+ HTMLDataGridElement.h
+ HTMLDataGridElement.idl
+ HTMLDataGridRowElement.cpp
+ HTMLDataGridRowElement.h
+ HTMLDataGridRowElement.idl
+ HTMLDataListElement.cpp
+ HTMLDataListElement.h
+ HTMLDataListElement.idl
+ HTMLDirectoryElement.cpp
+ HTMLDirectoryElement.h
+ HTMLDirectoryElement.idl
+ HTMLDivElement.cpp
+ HTMLDivElement.h
+ HTMLDivElement.idl
+ HTMLDListElement.cpp
+ HTMLDListElement.h
+ HTMLDListElement.idl
+ HTMLDocument.cpp
+ HTMLDocument.h
+ HTMLDocument.idl
+ HTMLElement.cpp
+ HTMLElement.h
+ HTMLElement.idl
+ HTMLElementsAllInOne.cpp
+ HTMLEmbedElement.cpp
+ HTMLEmbedElement.h
+ HTMLEmbedElement.idl
+ HTMLEntityNames.gperf
+ HTMLFieldSetElement.cpp
+ HTMLFieldSetElement.h
+ HTMLFieldSetElement.idl
+ HTMLFontElement.cpp
+ HTMLFontElement.h
+ HTMLFontElement.idl
+ HTMLFormCollection.cpp
+ HTMLFormCollection.h
+ HTMLFormControlElement.cpp
+ HTMLFormControlElement.h
+ HTMLFormElement.cpp
+ HTMLFormElement.h
+ HTMLFormElement.idl
+ HTMLFrameElementBase.cpp
+ HTMLFrameElementBase.h
+ HTMLFrameElement.cpp
+ HTMLFrameElement.h
+ HTMLFrameElement.idl
+ HTMLFrameOwnerElement.cpp
+ HTMLFrameOwnerElement.h
+ HTMLFrameSetElement.cpp
+ HTMLFrameSetElement.h
+ HTMLFrameSetElement.idl
+ HTMLHeadElement.cpp
+ HTMLHeadElement.h
+ HTMLHeadElement.idl
+ HTMLHeadingElement.cpp
+ HTMLHeadingElement.h
+ HTMLHeadingElement.idl
+ HTMLHRElement.cpp
+ HTMLHRElement.h
+ HTMLHRElement.idl
+ HTMLHtmlElement.cpp
+ HTMLHtmlElement.h
+ HTMLHtmlElement.idl
+ HTMLIFrameElement.cpp
+ HTMLIFrameElement.h
+ HTMLIFrameElement.idl
+ HTMLImageElement.cpp
+ HTMLImageElement.h
+ HTMLImageElement.idl
+ HTMLImageLoader.cpp
+ HTMLImageLoader.h
+ HTMLInputElement.cpp
+ HTMLInputElement.h
+ HTMLInputElement.idl
+ HTMLIsIndexElement.cpp
+ HTMLIsIndexElement.h
+ HTMLIsIndexElement.idl
+ HTMLKeygenElement.cpp
+ HTMLKeygenElement.h
+ HTMLLabelElement.cpp
+ HTMLLabelElement.h
+ HTMLLabelElement.idl
+ HTMLLegendElement.cpp
+ HTMLLegendElement.h
+ HTMLLegendElement.idl
+ HTMLLIElement.cpp
+ HTMLLIElement.h
+ HTMLLIElement.idl
+ HTMLLinkElement.cpp
+ HTMLLinkElement.h
+ HTMLLinkElement.idl
+ HTMLMapElement.cpp
+ HTMLMapElement.h
+ HTMLMapElement.idl
+ HTMLMarqueeElement.cpp
+ HTMLMarqueeElement.h
+ HTMLMarqueeElement.idl
+ HTMLMediaElement.cpp
+ HTMLMediaElement.h
+ HTMLMediaElement.idl
+ HTMLMenuElement.cpp
+ HTMLMenuElement.h
+ HTMLMenuElement.idl
+ HTMLMetaElement.cpp
+ HTMLMetaElement.h
+ HTMLMetaElement.idl
+ HTMLModElement.cpp
+ HTMLModElement.h
+ HTMLModElement.idl
+ HTMLNameCollection.cpp
+ HTMLNameCollection.h
+ HTMLNoScriptElement.cpp
+ HTMLNoScriptElement.h
+ HTMLObjectElement.cpp
+ HTMLObjectElement.h
+ HTMLObjectElement.idl
+ HTMLOListElement.cpp
+ HTMLOListElement.h
+ HTMLOListElement.idl
+ HTMLOptGroupElement.cpp
+ HTMLOptGroupElement.h
+ HTMLOptGroupElement.idl
+ HTMLOptionElement.cpp
+ HTMLOptionElement.h
+ HTMLOptionElement.idl
+ HTMLOptionsCollection.cpp
+ HTMLOptionsCollection.h
+ HTMLOptionsCollection.idl
+ HTMLParagraphElement.cpp
+ HTMLParagraphElement.h
+ HTMLParagraphElement.idl
+ HTMLParamElement.cpp
+ HTMLParamElement.h
+ HTMLParamElement.idl
+ HTMLParser.cpp
+ HTMLParserErrorCodes.cpp
+ HTMLParserErrorCodes.h
+ HTMLParser.h
+ HTMLParserQuirks.h
+ HTMLPlugInElement.cpp
+ HTMLPlugInElement.h
+ HTMLPlugInImageElement.cpp
+ HTMLPlugInImageElement.h
+ HTMLPreElement.cpp
+ HTMLPreElement.h
+ HTMLPreElement.idl
+ HTMLQuoteElement.cpp
+ HTMLQuoteElement.h
+ HTMLQuoteElement.idl
+ HTMLScriptElement.cpp
+ HTMLScriptElement.h
+ HTMLScriptElement.idl
+ HTMLSelectElement.cpp
+ HTMLSelectElement.h
+ HTMLSelectElement.idl
+ HTMLSourceElement.cpp
+ HTMLSourceElement.h
+ HTMLSourceElement.idl
+ HTMLStyleElement.cpp
+ HTMLStyleElement.h
+ HTMLStyleElement.idl
+ HTMLTableCaptionElement.cpp
+ HTMLTableCaptionElement.h
+ HTMLTableCaptionElement.idl
+ HTMLTableCellElement.cpp
+ HTMLTableCellElement.h
+ HTMLTableCellElement.idl
+ HTMLTableColElement.cpp
+ HTMLTableColElement.h
+ HTMLTableColElement.idl
+ HTMLTableElement.cpp
+ HTMLTableElement.h
+ HTMLTableElement.idl
+ HTMLTablePartElement.cpp
+ HTMLTablePartElement.h
+ HTMLTableRowElement.cpp
+ HTMLTableRowElement.h
+ HTMLTableRowElement.idl
+ HTMLTableRowsCollection.cpp
+ HTMLTableRowsCollection.h
+ HTMLTableSectionElement.cpp
+ HTMLTableSectionElement.h
+ HTMLTableSectionElement.idl
+ HTMLTagNames.in
+ HTMLTextAreaElement.cpp
+ HTMLTextAreaElement.h
+ HTMLTextAreaElement.idl
+ HTMLTitleElement.cpp
+ HTMLTitleElement.h
+ HTMLTitleElement.idl
+ HTMLTokenizer.cpp
+ HTMLTokenizer.h
+ HTMLUListElement.cpp
+ HTMLUListElement.h
+ HTMLUListElement.idl
+ HTMLVideoElement.cpp
+ HTMLVideoElement.h
+ HTMLVideoElement.idl
+ HTMLViewSourceDocument.cpp
+ HTMLViewSourceDocument.h
+ ImageData.cpp
+ ImageData.h
+ ImageData.idl
+ MediaError.h
+ MediaError.idl
+ PreloadScanner.cpp
+ PreloadScanner.h
+ TextMetrics.h
+ TextMetrics.idl
+ TimeRanges.cpp
+ TimeRanges.h
+ TimeRanges.idl
+ ValidityState.cpp
+ ValidityState.h
+ ValidityState.idl
+ VoidCallback.h
+ VoidCallback.idl
+2 Info.plist
+ inspector/
+0 ConsoleMessage.cpp
+ ConsoleMessage.h
+ front-end/
+0 AbstractTimelinePanel.js
+ BottomUpProfileDataGridTree.js
+ Breakpoint.js
+ BreakpointsSidebarPane.js
+ Callback.js
+ CallStackSidebarPane.js
+ ChangesView.js
+ Color.js
+ ConsoleView.js
+ CookieItemsView.js
+ Database.js
+ DatabaseQueryView.js
+ DatabaseTableView.js
+ DataGrid.js
+ DOMAgent.js
+ DOMStorageDataGrid.js
+ DOMStorageItemsView.js
+ DOMStorage.js
+ Drawer.js
+ ElementsPanel.js
+ ElementsTreeOutline.js
+ EventListenersSidebarPane.js
+ FontView.js
+ Images/
+0 back.png
+ checker.png
+ clearConsoleButtonGlyph.png
+ closeButtons.png
+ consoleButtonGlyph.png
+ cookie.png
+ database.png
+ databaseTable.png
+ debuggerContinue.png
+ debuggerPause.png
+ debuggerStepInto.png
+ debuggerStepOut.png
+ debuggerStepOver.png
+ disclosureTriangleSmallDownBlack.png
+ disclosureTriangleSmallDown.png
+ disclosureTriangleSmallDownWhite.png
+ disclosureTriangleSmallRightBlack.png
+ disclosureTriangleSmallRightDownBlack.png
+ disclosureTriangleSmallRightDown.png
+ disclosureTriangleSmallRightDownWhite.png
+ disclosureTriangleSmallRight.png
+ disclosureTriangleSmallRightWhite.png
+ dockButtonGlyph.png
+ elementsIcon.png
+ enableOutlineButtonGlyph.png
+ enableSolidButtonGlyph.png
+ errorIcon.png
+ errorMediumIcon.png
+ errorRedDot.png
+ excludeButtonGlyph.png
+ focusButtonGlyph.png
+ forward.png
+ glossyHeader.png
+ glossyHeaderPressed.png
+ glossyHeaderSelected.png
+ glossyHeaderSelectedPressed.png
+ goArrow.png
+ graphLabelCalloutLeft.png
+ graphLabelCalloutRight.png
+ grayConnectorPoint.png
+ largerResourcesButtonGlyph.png
+ localStorage.png
+ nodeSearchButtonGlyph.png
+ paneBottomGrowActive.png
+ paneBottomGrow.png
+ paneGrowHandleLine.png
+ paneSettingsButtons.png
+ pauseOnExceptionButtonGlyph.png
+ percentButtonGlyph.png
+ profileGroupIcon.png
+ profileIcon.png
+ profilesIcon.png
+ profileSmallIcon.png
+ profilesSilhouette.png
+ radioDot.png
+ recordButtonGlyph.png
+ recordToggledButtonGlyph.png
+ reloadButtonGlyph.png
+ resourceCSSIcon.png
+ resourceDocumentIcon.png
+ resourceDocumentIconSmall.png
+ resourceJSIcon.png
+ resourcePlainIcon.png
+ resourcePlainIconSmall.png
+ resourcesIcon.png
+ resourcesSilhouette.png
+ resourcesSizeGraphIcon.png
+ resourcesTimeGraphIcon.png
+ scriptsIcon.png
+ scriptsSilhouette.png
+ searchSmallBlue.png
+ searchSmallBrightBlue.png
+ searchSmallGray.png
+ searchSmallWhite.png
+ segmentEnd.png
+ segmentHoverEnd.png
+ segmentHover.png
+ segment.png
+ segmentSelectedEnd.png
+ segmentSelected.png
+ sessionStorage.png
+ splitviewDimple.png
+ splitviewDividerBackground.png
+ statusbarBackground.png
+ statusbarBottomBackground.png
+ statusbarButtons.png
+ statusbarMenuButton.png
+ statusbarMenuButtonSelected.png
+ statusbarResizerHorizontal.png
+ statusbarResizerVertical.png
+ storageIcon.png
+ successGreenDot.png
+ timelineBarBlue.png
+ timelineBarGray.png
+ timelineBarGreen.png
+ timelineBarOrange.png
+ timelineBarPurple.png
+ timelineBarRed.png
+ timelineBarYellow.png
+ timelineCheckmarks.png
+ timelineDots.png
+ timelineHollowPillBlue.png
+ timelineHollowPillGray.png
+ timelineHollowPillGreen.png
+ timelineHollowPillOrange.png
+ timelineHollowPillPurple.png
+ timelineHollowPillRed.png
+ timelineHollowPillYellow.png
+ timelineIcon.png
+ timelinePillBlue.png
+ timelinePillGray.png
+ timelinePillGreen.png
+ timelinePillOrange.png
+ timelinePillPurple.png
+ timelinePillRed.png
+ timelinePillYellow.png
+ tipBalloonBottom.png
+ tipBalloon.png
+ tipIcon.png
+ tipIconPressed.png
+ toolbarItemSelected.png
+ treeDownTriangleBlack.png
+ treeDownTriangleWhite.png
+ treeRightTriangleBlack.png
+ treeRightTriangleWhite.png
+ treeUpTriangleBlack.png
+ treeUpTriangleWhite.png
+ undockButtonGlyph.png
+ userInputIcon.png
+ userInputPreviousIcon.png
+ userInputResultIcon.png
+ warningIcon.png
+ warningMediumIcon.png
+ warningOrangeDot.png
+ warningsErrors.png
+ whiteConnectorPoint.png
+2 ImageView.js
+ InjectedScriptAccess.js
+ InjectedScript.js
+ InspectorControllerStub.js
+ inspector.css
+ inspector.html
+ inspector.js
+ inspectorSyntaxHighlight.css
+ KeyboardShortcut.js
+ MetricsSidebarPane.js
+ Object.js
+ ObjectPropertiesSection.js
+ ObjectProxy.js
+ PanelEnablerView.js
+ Panel.js
+ Placard.js
+ Popup.js
+ ProfileDataGridTree.js
+ ProfilesPanel.js
+ ProfileView.js
+ PropertiesSection.js
+ PropertiesSidebarPane.js
+ ResourceCategory.js
+ Resource.js
+ ResourcesPanel.js
+ ResourceView.js
+ ScopeChainSidebarPane.js
+ Script.js
+ ScriptsPanel.js
+ ScriptView.js
+ SidebarPane.js
+ SidebarTreeElement.js
+ SourceFrame.js
+ SourceView.js
+ StatusBarButton.js
+ StoragePanel.js
+ StylesSidebarPane.js
+ SummaryBar.js
+ TestController.js
+ TextPrompt.js
+ TimelineAgent.js
+ TimelinePanel.js
+ TopDownProfileDataGridTree.js
+ treeoutline.js
+ utilities.js
+ View.js
+ WatchExpressionsSidebarPane.js
+ WebKit.qrc
+2 InspectorBackend.cpp
+ InspectorBackend.h
+ InspectorBackend.idl
+ InspectorClient.h
+ InspectorController.cpp
+ InspectorController.h
+ InspectorDatabaseResource.cpp
+ InspectorDatabaseResource.h
+ InspectorDOMAgent.cpp
+ InspectorDOMAgent.h
+ InspectorDOMStorageResource.cpp
+ InspectorDOMStorageResource.h
+ InspectorFrontend.cpp
+ InspectorFrontend.h
+ InspectorResource.cpp
+ InspectorResource.h
+ InspectorTimelineAgent.cpp
+ InspectorTimelineAgent.h
+ JavaScriptCallFrame.cpp
+ JavaScriptCallFrame.h
+ JavaScriptCallFrame.idl
+ JavaScriptDebugListener.h
+ JavaScriptDebugServer.cpp
+ JavaScriptDebugServer.h
+ JavaScriptProfile.cpp
+ JavaScriptProfile.h
+ JavaScriptProfileNode.cpp
+ JavaScriptProfileNode.h
+ TimelineRecordFactory.cpp
+ TimelineRecordFactory.h
+2 LICENSE-APPLE
+ LICENSE-LGPL-2
+0 .1
+2 loader/
+0 appcache/
+0 ApplicationCache.cpp
+ ApplicationCacheGroup.cpp
+ ApplicationCacheGroup.h
+ ApplicationCache.h
+ ApplicationCacheHost.cpp
+ ApplicationCacheHost.h
+ ApplicationCacheResource.cpp
+ ApplicationCacheResource.h
+ ApplicationCacheStorage.cpp
+ ApplicationCacheStorage.h
+ DOMApplicationCache.cpp
+ DOMApplicationCache.h
+ DOMApplicationCache.idl
+ ManifestParser.cpp
+ ManifestParser.h
+2 archive/
+0 ArchiveFactory.cpp
+ ArchiveFactory.h
+ Archive.h
+ ArchiveResourceCollection.cpp
+ ArchiveResourceCollection.h
+ ArchiveResource.cpp
+ ArchiveResource.h
+ cf/
+0 LegacyWebArchive.cpp
+ LegacyWebArchive.h
+ LegacyWebArchiveMac.mm
+3 Cache.cpp
+ CachedCSSStyleSheet.cpp
+ CachedCSSStyleSheet.h
+ CachedFont.cpp
+ CachedFont.h
+ CachedImage.cpp
+ CachedImage.h
+ CachedResourceClient.h
+ CachedResourceClientWalker.cpp
+ CachedResourceClientWalker.h
+ CachedResource.cpp
+ CachedResource.h
+ CachedResourceHandle.cpp
+ CachedResourceHandle.h
+ CachedScript.cpp
+ CachedScript.h
+ CachedXBLDocument.cpp
+ CachedXBLDocument.h
+ CachedXSLStyleSheet.cpp
+ CachedXSLStyleSheet.h
+ Cache.h
+ CachePolicy.h
+ cf/
+0 ResourceLoaderCFNet.cpp
+2 CrossOriginAccessControl.cpp
+ CrossOriginAccessControl.h
+ CrossOriginPreflightResultCache.cpp
+ CrossOriginPreflightResultCache.h
+ DocLoader.cpp
+ DocLoader.h
+ DocumentLoader.cpp
+ DocumentLoader.h
+ DocumentThreadableLoader.cpp
+ DocumentThreadableLoader.h
+ EmptyClients.h
+ FormState.cpp
+ FormState.h
+ FrameLoaderClient.h
+ FrameLoader.cpp
+ FrameLoader.h
+ FrameLoaderTypes.h
+ FTPDirectoryDocument.cpp
+ FTPDirectoryDocument.h
+ FTPDirectoryParser.cpp
+ FTPDirectoryParser.h
+ HistoryController.cpp
+ HistoryController.h
+ icon/
+0 IconDatabaseClient.h
+ IconDatabase.cpp
+ IconDatabase.h
+ IconDatabaseNone.cpp
+ IconFetcher.cpp
+ IconFetcher.h
+ IconLoader.cpp
+ IconLoader.h
+ IconRecord.cpp
+ IconRecord.h
+ PageURLRecord.cpp
+ PageURLRecord.h
+2 ImageDocument.cpp
+ ImageDocument.h
+ ImageLoader.cpp
+ ImageLoader.h
+ loader.cpp
+ loader.h
+ MainResourceLoader.cpp
+ MainResourceLoader.h
+ MediaDocument.cpp
+ MediaDocument.h
+ NavigationAction.cpp
+ NavigationAction.h
+ NetscapePlugInStreamLoader.cpp
+ NetscapePlugInStreamLoader.h
+ PlaceholderDocument.cpp
+ PlaceholderDocument.h
+ PluginDocument.cpp
+ PluginDocument.h
+ PolicyCallback.cpp
+ PolicyCallback.h
+ PolicyChecker.cpp
+ PolicyChecker.h
+ ProgressTracker.cpp
+ ProgressTracker.h
+ RedirectScheduler.cpp
+ RedirectScheduler.h
+ Request.cpp
+ Request.h
+ ResourceLoader.cpp
+ ResourceLoader.h
+ ResourceLoadNotifier.cpp
+ ResourceLoadNotifier.h
+ SubresourceLoaderClient.h
+ SubresourceLoader.cpp
+ SubresourceLoader.h
+ SubstituteData.h
+ SubstituteResource.h
+ TextDocument.cpp
+ TextDocument.h
+ TextResourceDecoder.cpp
+ TextResourceDecoder.h
+ ThreadableLoaderClient.h
+ ThreadableLoaderClientWrapper.h
+ ThreadableLoader.cpp
+ ThreadableLoader.h
+ WorkerThreadableLoader.cpp
+ WorkerThreadableLoader.h
+2 make-generated-sources.sh
+ mathml/
+0 MathMLElement.cpp
+ MathMLElement.h
+ MathMLInlineContainerElement.cpp
+ MathMLInlineContainerElement.h
+ MathMLMathElement.cpp
+ MathMLMathElement.h
+ mathtags.in
+2 move-js-headers.sh
+ notifications/
+0 NotificationCenter.cpp
+ NotificationCenter.h
+ NotificationCenter.idl
+ NotificationContents.h
+ Notification.cpp
+ Notification.h
+ Notification.idl
+ NotificationPresenter.h
+2 page/
+0 AbstractView.idl
+ android/
+0 DragControllerAndroid.cpp
+ EventHandlerAndroid.cpp
+ InspectorControllerAndroid.cpp
+2 animation/
+0 AnimationBase.cpp
+ AnimationBase.h
+ AnimationController.cpp
+ AnimationController.h
+ AnimationControllerPrivate.h
+ CompositeAnimation.cpp
+ CompositeAnimation.h
+ ImplicitAnimation.cpp
+ ImplicitAnimation.h
+ KeyframeAnimation.cpp
+ KeyframeAnimation.h
+2 BarInfo.cpp
+ BarInfo.h
+ BarInfo.idl
+ ChromeClient.h
+ Chrome.cpp
+ Chrome.h
+ Console.cpp
+ Console.h
+ Console.idl
+ ContextMenuClient.h
+ ContextMenuController.cpp
+ ContextMenuController.h
+ Coordinates.h
+ Coordinates.idl
+ DOMSelection.cpp
+ DOMSelection.h
+ DOMSelection.idl
+ DOMTimer.cpp
+ DOMTimer.h
+ DOMWindow.cpp
+ DOMWindow.h
+ DOMWindow.idl
+ DragActions.h
+ DragClient.h
+ DragController.cpp
+ DragController.h
+ EditorClient.h
+ EventHandler.cpp
+ EventHandler.h
+ EventSource.cpp
+ EventSource.h
+ EventSource.idl
+ FocusController.cpp
+ FocusController.h
+ FocusDirection.h
+ Frame.cpp
+ Frame.h
+ FrameLoadRequest.h
+ FrameTree.cpp
+ FrameTree.h
+ FrameView.cpp
+ FrameView.h
+ Geolocation.cpp
+ Geolocation.h
+ Geolocation.idl
+ Geoposition.h
+ Geoposition.idl
+ HaltablePlugin.h
+ History.cpp
+ History.h
+ History.idl
+ Location.cpp
+ Location.h
+ Location.idl
+ MouseEventWithHitTestResults.cpp
+ MouseEventWithHitTestResults.h
+ NavigatorBase.cpp
+ NavigatorBase.h
+ Navigator.cpp
+ Navigator.h
+ Navigator.idl
+ OriginAccessEntry.cpp
+ OriginAccessEntry.h
+ Page.cpp
+ PageGroup.cpp
+ PageGroup.h
+ PageGroupLoadDeferrer.cpp
+ PageGroupLoadDeferrer.h
+ Page.h
+ PluginHalterClient.h
+ PluginHalter.cpp
+ PluginHalter.h
+ PositionCallback.h
+ PositionErrorCallback.h
+ PositionError.h
+ PositionError.idl
+ PositionOptions.h
+ PrintContext.cpp
+ PrintContext.h
+ qt/
+0 DragControllerQt.cpp
+ EventHandlerQt.cpp
+ FrameQt.cpp
+2 Screen.cpp
+ Screen.h
+ Screen.idl
+ SecurityOrigin.cpp
+ SecurityOrigin.h
+ SecurityOriginHash.h
+ Settings.cpp
+ Settings.h
+ UserContentURLPattern.cpp
+ UserContentURLPattern.h
+ UserScript.h
+ UserScriptTypes.h
+ UserStyleSheet.h
+ UserStyleSheetTypes.h
+ WebKitPoint.h
+ WebKitPoint.idl
+ win/
+ WindowFeatures.cpp
+ WindowFeatures.h
+ win/DragControllerWin.cpp
+ win/EventHandlerWin.cpp
+ win/FrameCairoWin.cpp
+ win/FrameCGWin.cpp
+ win/FrameWin.cpp
+ win/FrameWin.h
+ win/PageWin.cpp
+ WorkerNavigator.cpp
+ WorkerNavigator.h
+ WorkerNavigator.idl
+ XSSAuditor.cpp
+ XSSAuditor.h
+2 platform/
+0 android/
+0 ClipboardAndroid.cpp
+ ClipboardAndroid.h
+ CursorAndroid.cpp
+ DragDataAndroid.cpp
+ EventLoopAndroid.cpp
+ FileChooserAndroid.cpp
+ FileSystemAndroid.cpp
+ KeyboardCodes.h
+ KeyEventAndroid.cpp
+ LocalizedStringsAndroid.cpp
+ PopupMenuAndroid.cpp
+ RenderThemeAndroid.cpp
+ RenderThemeAndroid.h
+ ScreenAndroid.cpp
+ ScrollViewAndroid.cpp
+ SearchPopupMenuAndroid.cpp
+ SystemTimeAndroid.cpp
+ TemporaryLinkStubs.cpp
+ WidgetAndroid.cpp
+2 animation/
+0 Animation.cpp
+ Animation.h
+ AnimationList.cpp
+ AnimationList.h
+ TimingFunction.h
+2 Arena.cpp
+ Arena.h
+ AutodrainedPool.h
+ ColorData.gperf
+ ContentType.cpp
+ ContentType.h
+ ContextMenu.cpp
+ ContextMenu.h
+ ContextMenuItem.h
+ Cookie.h
+ CookieJar.h
+ CrossThreadCopier.cpp
+ CrossThreadCopier.h
+ Cursor.h
+ DeprecatedPtrList.h
+ DeprecatedPtrListImpl.cpp
+ DeprecatedPtrListImpl.h
+ DragData.cpp
+ DragData.h
+ DragImage.cpp
+ DragImage.h
+ EventLoop.h
+ FileChooser.cpp
+ FileChooser.h
+ FileSystem.h
+ FloatConversion.h
+ GeolocationService.cpp
+ GeolocationService.h
+ graphics/
+0 BitmapImage.cpp
+ BitmapImage.h
+ Color.cpp
+ Color.h
+ DashArray.h
+ filters/
+0 FEBlend.cpp
+ FEBlend.h
+ FEColorMatrix.cpp
+ FEColorMatrix.h
+ FEComponentTransfer.cpp
+ FEComponentTransfer.h
+ FEComposite.cpp
+ FEComposite.h
+ FEGaussianBlur.cpp
+ FEGaussianBlur.h
+ FilterEffect.cpp
+ FilterEffect.h
+ Filter.h
+ SourceAlpha.cpp
+ SourceAlpha.h
+ SourceGraphic.cpp
+ SourceGraphic.h
+2 FloatPoint3D.cpp
+ FloatPoint3D.h
+ FloatPoint.cpp
+ FloatPoint.h
+ FloatQuad.cpp
+ FloatQuad.h
+ FloatRect.cpp
+ FloatRect.h
+ FloatSize.cpp
+ FloatSize.h
+ FontCache.cpp
+ FontCache.h
+ Font.cpp
+ FontData.cpp
+ FontData.h
+ FontDescription.cpp
+ FontDescription.h
+ FontFallbackList.cpp
+ FontFallbackList.h
+ FontFamily.cpp
+ FontFamily.h
+ FontFastPath.cpp
+ Font.h
+ FontRenderingMode.h
+ FontSelector.h
+ FontSmoothingMode.h
+ FontTraitsMask.h
+ GeneratedImage.cpp
+ GeneratedImage.h
+ Generator.h
+ GlyphBuffer.h
+ GlyphPageTreeNode.cpp
+ GlyphPageTreeNode.h
+ GlyphWidthMap.cpp
+ GlyphWidthMap.h
+ Gradient.cpp
+ Gradient.h
+ GraphicsContext3D.h
+ GraphicsContext.cpp
+ GraphicsContext.h
+ GraphicsContextPrivate.h
+ GraphicsLayerClient.h
+ GraphicsLayer.cpp
+ GraphicsLayer.h
+ GraphicsTypes.cpp
+ GraphicsTypes.h
+ Icon.h
+ ImageBuffer.cpp
+ ImageBuffer.h
+ Image.cpp
+ Image.h
+ ImageObserver.h
+ ImageSource.cpp
+ ImageSource.h
+ IntPoint.h
+ IntRect.cpp
+ IntRect.h
+ IntSize.h
+ IntSizeHash.h
+ MediaPlayer.cpp
+ MediaPlayer.h
+ MediaPlayerPrivate.h
+ opentype/
+0 OpenTypeUtilities.cpp
+ OpenTypeUtilities.h
+2 Path.cpp
+ Path.h
+ PathTraversalState.cpp
+ PathTraversalState.h
+ Pattern.cpp
+ Pattern.h
+ Pen.cpp
+ Pen.h
+ qt/
+0 ColorQt.cpp
+ FloatPointQt.cpp
+ FloatRectQt.cpp
+ FontCacheQt.cpp
+ FontCustomPlatformData.cpp
+ FontCustomPlatformData.h
+ FontFallbackListQt.cpp
+ FontPlatformData.h
+ FontPlatformDataQt.cpp
+ FontQt43.cpp
+ FontQt.cpp
+ GlyphPageTreeNodeQt.cpp
+ GradientQt.cpp
+ GraphicsContextQt.cpp
+ IconQt.cpp
+ ImageBufferData.h
+ ImageBufferQt.cpp
+ ImageDecoderQt.cpp
+ ImageDecoderQt.h
+ ImageQt.cpp
+ IntPointQt.cpp
+ IntRectQt.cpp
+ IntSizeQt.cpp
+ MediaPlayerPrivatePhonon.cpp
+ MediaPlayerPrivatePhonon.h
+ PathQt.cpp
+ PatternQt.cpp
+ SimpleFontDataQt.cpp
+ StillImageQt.cpp
+ StillImageQt.h
+ TransformationMatrixQt.cpp
+2 SegmentedFontData.cpp
+ SegmentedFontData.h
+ SimpleFontData.cpp
+ SimpleFontData.h
+ StringTruncator.cpp
+ StringTruncator.h
+ StrokeStyleApplier.h
+ TextRenderingMode.h
+ TextRun.h
+ transforms/
+0 IdentityTransformOperation.h
+ Matrix3DTransformOperation.cpp
+ Matrix3DTransformOperation.h
+ MatrixTransformOperation.cpp
+ MatrixTransformOperation.h
+ PerspectiveTransformOperation.cpp
+ PerspectiveTransformOperation.h
+ RotateTransformOperation.cpp
+ RotateTransformOperation.h
+ ScaleTransformOperation.cpp
+ ScaleTransformOperation.h
+ SkewTransformOperation.cpp
+ SkewTransformOperation.h
+ TransformationMatrix.cpp
+ TransformationMatrix.h
+ TransformOperation.h
+ TransformOperations.cpp
+ TransformOperations.h
+ TranslateTransformOperation.cpp
+ TranslateTransformOperation.h
+2 UnitBezier.h
+ WidthIterator.cpp
+ WidthIterator.h
+2 HostWindow.h
+ image-decoders/
+0 cairo/
+0 ImageDecoderCairo.cpp
+2 ImageDecoder.cpp
+ ImageDecoder.h
+ qt/
+0 RGBA32BufferQt.cpp
+2 wx/
+0 ImageDecoderWx.cpp
+3 KeyboardCodes.h
+ KURL.cpp
+ KURLGoogle.cpp
+ KURLGooglePrivate.h
+ KURL.h
+ KURLHash.h
+ Language.h
+ LengthBox.h
+ Length.cpp
+ Length.h
+ LengthSize.h
+ LinkHash.cpp
+ LinkHash.h
+ LocalizedStrings.h
+ Logging.cpp
+ Logging.h
+ mac/
+0 AutodrainedPool.mm
+ BlockExceptions.h
+ BlockExceptions.mm
+ ClipboardMac.h
+ ClipboardMac.mm
+ ContextMenuItemMac.mm
+ ContextMenuMac.mm
+ CookieJar.mm
+ CursorMac.mm
+ DragDataMac.mm
+ DragImageMac.mm
+ EventLoopMac.mm
+ FileChooserMac.mm
+ FileSystemMac.mm
+ FoundationExtras.h
+ GeolocationServiceMac.h
+ GeolocationServiceMac.mm
+ KeyEventMac.mm
+ KURLMac.mm
+ Language.mm
+ LocalCurrentGraphicsContext.h
+ LocalCurrentGraphicsContext.mm
+ LocalizedStringsMac.mm
+ LoggingMac.mm
+ MIMETypeRegistryMac.mm
+ PasteboardHelper.h
+ PasteboardMac.mm
+ PlatformMouseEventMac.mm
+ PlatformScreenMac.mm
+ PopupMenuMac.mm
+ PurgeableBufferMac.cpp
+ RuntimeApplicationChecks.h
+ RuntimeApplicationChecks.mm
+ SchedulePairMac.mm
+ ScrollbarThemeMac.h
+ ScrollbarThemeMac.mm
+ ScrollViewMac.mm
+ SearchPopupMenuMac.mm
+ SharedBufferMac.mm
+ SharedTimerMac.mm
+ SoftLinking.h
+ SoundMac.mm
+ SSLKeyGeneratorMac.mm
+ SuddenTermination.mm
+ SystemTimeMac.cpp
+ ThemeMac.h
+ ThemeMac.mm
+ ThreadCheck.mm
+ WebCoreKeyGenerator.h
+ WebCoreKeyGenerator.m
+ WebCoreNSStringExtras.h
+ WebCoreNSStringExtras.mm
+ WebCoreObjCExtras.h
+ WebCoreObjCExtras.mm
+ WebCoreSystemInterface.h
+ WebCoreSystemInterface.mm
+ WebCoreView.h
+ WebCoreView.m
+ WebFontCache.h
+ WebFontCache.mm
+ WheelEventMac.mm
+ WidgetMac.mm
+2 MIMETypeRegistry.cpp
+ MIMETypeRegistry.h
+ mock/
+0 GeolocationServiceMock.cpp
+ GeolocationServiceMock.h
+2 network/
+0 AuthenticationChallengeBase.cpp
+ AuthenticationChallengeBase.h
+ Credential.cpp
+ Credential.h
+ CredentialStorage.cpp
+ CredentialStorage.h
+ DNS.h
+ FormDataBuilder.cpp
+ FormDataBuilder.h
+ FormData.cpp
+ FormData.h
+ HTTPHeaderMap.cpp
+ HTTPHeaderMap.h
+ HTTPParsers.cpp
+ HTTPParsers.h
+ NetworkStateNotifier.cpp
+ NetworkStateNotifier.h
+ ProtectionSpace.cpp
+ ProtectionSpace.h
+ ProtectionSpaceHash.h
+ qt/
+0 AuthenticationChallenge.h
+ DnsPrefetchHelper.cpp
+ DnsPrefetchHelper.h
+ QNetworkReplyHandler.cpp
+ QNetworkReplyHandler.h
+ ResourceError.h
+ ResourceHandleQt.cpp
+ ResourceRequest.h
+ ResourceRequestQt.cpp
+ ResourceResponse.h
+ SocketStreamError.h
+ SocketStreamHandle.h
+ SocketStreamHandleSoup.cpp
+2 ResourceErrorBase.cpp
+ ResourceErrorBase.h
+ ResourceHandleClient.h
+ ResourceHandle.cpp
+ ResourceHandle.h
+ ResourceHandleInternal.h
+ ResourceRequestBase.cpp
+ ResourceRequestBase.h
+ ResourceResponseBase.cpp
+ ResourceResponseBase.h
+ SocketStreamErrorBase.cpp
+ SocketStreamErrorBase.h
+ SocketStreamHandleBase.cpp
+ SocketStreamHandleBase.h
+ SocketStreamHandleClient.h
+2 NotImplemented.h
+ Pasteboard.h
+ PlatformKeyboardEvent.h
+ PlatformMenuDescription.h
+ PlatformMouseEvent.h
+ PlatformScreen.h
+ PlatformWheelEvent.h
+ PopupMenuClient.h
+ PopupMenu.h
+ PopupMenuStyle.h
+ posix/
+0 FileSystemPOSIX.cpp
+2 PurgeableBuffer.h
+ qt/
+0 ClipboardQt.cpp
+ ClipboardQt.h
+ ContextMenuItemQt.cpp
+ ContextMenuQt.cpp
+ CookieJarQt.cpp
+ CursorQt.cpp
+ DragDataQt.cpp
+ DragImageQt.cpp
+ EventLoopQt.cpp
+ FileChooserQt.cpp
+ FileSystemQt.cpp
+ KURLQt.cpp
+ Localizations.cpp
+ LoggingQt.cpp
+ MIMETypeRegistryQt.cpp
+ PasteboardQt.cpp
+ PlatformKeyboardEventQt.cpp
+ PlatformMouseEventQt.cpp
+ PlatformScreenQt.cpp
+ PopupMenuQt.cpp
+ QWebPageClient.h
+ QWebPopup.cpp
+ QWebPopup.h
+ RenderThemeQt.cpp
+ RenderThemeQt.h
+ ScreenQt.cpp
+ ScrollbarQt.cpp
+ ScrollbarThemeQt.cpp
+ ScrollbarThemeQt.h
+ ScrollViewQt.cpp
+ SearchPopupMenuQt.cpp
+ SharedBufferQt.cpp
+ SharedTimerQt.cpp
+ SoundQt.cpp
+ TemporaryLinkStubs.cpp
+ WheelEventQt.cpp
+ WidgetQt.cpp
+2 RunLoopTimer.h
+ ScrollbarClient.h
+ Scrollbar.cpp
+ Scrollbar.h
+ ScrollbarThemeComposite.cpp
+ ScrollbarThemeComposite.h
+ ScrollbarTheme.h
+ ScrollTypes.h
+ ScrollView.cpp
+ ScrollView.h
+ SearchPopupMenu.h
+ SharedBuffer.cpp
+ SharedBuffer.h
+ SharedTimer.h
+ Sound.h
+ sql/
+0 SQLiteAuthorizer.cpp
+ SQLiteDatabase.cpp
+ SQLiteDatabase.h
+ SQLiteFileSystem.cpp
+ SQLiteFileSystem.h
+ SQLiteStatement.cpp
+ SQLiteStatement.h
+ SQLiteTransaction.cpp
+ SQLiteTransaction.h
+ SQLValue.cpp
+ SQLValue.h
+2 SSLKeyGenerator.h
+ StaticConstructors.h
+ SuddenTermination.h
+ SystemTime.h
+ text/
+0 android/
+0 TextBreakIteratorInternalICU.cpp
+2 AtomicString.cpp
+ AtomicString.h
+ AtomicStringHash.h
+ AtomicStringImpl.h
+ Base64.cpp
+ Base64.h
+ BidiContext.cpp
+ BidiContext.h
+ BidiResolver.h
+ cf/
+0 StringCF.cpp
+ StringImplCF.cpp
+2 CharacterNames.h
+ CString.cpp
+ CString.h
+ mac/
+0 character-sets.txt
+ CharsetData.h
+ mac-encodings.txt
+ make-charset-table.pl
+ ShapeArabic.c
+ ShapeArabic.h
+ StringImplMac.mm
+ StringMac.mm
+ TextBoundaries.mm
+ TextBreakIteratorInternalICUMac.mm
+ TextCodecMac.cpp
+ TextCodecMac.h
+2 ParserUtilities.h
+ PlatformString.h
+ qt/
+0 StringQt.cpp
+ TextBoundaries.cpp
+ TextBreakIteratorQt.cpp
+ TextCodecQt.cpp
+ TextCodecQt.h
+2 RegularExpression.cpp
+ RegularExpression.h
+ SegmentedString.cpp
+ SegmentedString.h
+ StringBuffer.h
+ StringBuilder.cpp
+ StringBuilder.h
+ String.cpp
+ StringHash.h
+ StringImpl.cpp
+ StringImpl.h
+ TextBoundaries.h
+ TextBoundariesICU.cpp
+ TextBreakIterator.h
+ TextBreakIteratorICU.cpp
+ TextBreakIteratorInternalICU.h
+ TextCodec.cpp
+ TextCodec.h
+ TextCodecICU.cpp
+ TextCodecICU.h
+ TextCodecLatin1.cpp
+ TextCodecLatin1.h
+ TextCodecUserDefined.cpp
+ TextCodecUserDefined.h
+ TextCodecUTF16.cpp
+ TextCodecUTF16.h
+ TextDirection.h
+ TextEncoding.cpp
+ TextEncodingDetector.h
+ TextEncodingDetectorICU.cpp
+ TextEncodingDetectorNone.cpp
+ TextEncoding.h
+ TextEncodingRegistry.cpp
+ TextEncodingRegistry.h
+ TextStream.cpp
+ TextStream.h
+ UnicodeRange.cpp
+ UnicodeRange.h
+ win/
+0 TextBreakIteratorInternalICUWin.cpp
+3 Theme.cpp
+ Theme.h
+ ThemeTypes.h
+ ThreadCheck.h
+ ThreadGlobalData.cpp
+ ThreadGlobalData.h
+ ThreadTimers.cpp
+ ThreadTimers.h
+ Timer.cpp
+ Timer.h
+ TreeShared.h
+ Widget.cpp
+ Widget.h
+ win/
+0 BitmapInfo.cpp
+ BitmapInfo.h
+ SystemTimeWin.cpp
+3 plugins/
+0 mac/
+0 PluginDataMac.mm
+ PluginPackageMac.cpp
+ PluginViewMac.cpp
+2 MimeTypeArray.cpp
+ MimeTypeArray.h
+ MimeTypeArray.idl
+ MimeType.cpp
+ MimeType.h
+ MimeType.idl
+ npapi.cpp
+ npfunctions.h
+ PluginArray.cpp
+ PluginArray.h
+ PluginArray.idl
+ Plugin.cpp
+ PluginDatabaseClient.h
+ PluginDatabase.cpp
+ PluginDatabase.h
+ PluginData.cpp
+ PluginData.h
+ PluginDataNone.cpp
+ PluginDebug.cpp
+ PluginDebug.h
+ Plugin.h
+ Plugin.idl
+ PluginInfoStore.cpp
+ PluginInfoStore.h
+ PluginMainThreadScheduler.cpp
+ PluginMainThreadScheduler.h
+ PluginPackage.cpp
+ PluginPackage.h
+ PluginPackageNone.cpp
+ PluginQuirkSet.h
+ PluginStream.cpp
+ PluginStream.h
+ PluginView.cpp
+ PluginView.h
+ PluginViewNone.cpp
+ qt/
+0 PluginContainerQt.cpp
+ PluginContainerQt.h
+ PluginDataQt.cpp
+ PluginPackageQt.cpp
+ PluginViewQt.cpp
+2 symbian/
+0 npinterface.h
+ PluginContainerSymbian.cpp
+ PluginContainerSymbian.h
+ PluginDatabaseSymbian.cpp
+ PluginPackageSymbian.cpp
+ PluginViewSymbian.cpp
+2 win/
+0 PaintHooks.asm
+ PluginDatabaseWin.cpp
+ PluginDataWin.cpp
+ PluginMessageThrottlerWin.cpp
+ PluginMessageThrottlerWin.h
+ PluginPackageWin.cpp
+ PluginViewWin.cpp
+3 rendering/
+0 AutoTableLayout.cpp
+ AutoTableLayout.h
+ break_lines.cpp
+ break_lines.h
+ CounterNode.cpp
+ CounterNode.h
+ EllipsisBox.cpp
+ EllipsisBox.h
+ FixedTableLayout.cpp
+ FixedTableLayout.h
+ GapRects.h
+ HitTestRequest.h
+ HitTestResult.cpp
+ HitTestResult.h
+ InlineBox.cpp
+ InlineBox.h
+ InlineFlowBox.cpp
+ InlineFlowBox.h
+ InlineRunBox.h
+ InlineTextBox.cpp
+ InlineTextBox.h
+ LayoutState.cpp
+ LayoutState.h
+ MediaControlElements.cpp
+ MediaControlElements.h
+ OverlapTestRequestClient.h
+ PointerEventsHitRules.cpp
+ PointerEventsHitRules.h
+ RenderApplet.cpp
+ RenderApplet.h
+ RenderArena.cpp
+ RenderArena.h
+ RenderBlock.cpp
+ RenderBlock.h
+ RenderBlockLineLayout.cpp
+ RenderBox.cpp
+ RenderBox.h
+ RenderBoxModelObject.cpp
+ RenderBoxModelObject.h
+ RenderBR.cpp
+ RenderBR.h
+ RenderButton.cpp
+ RenderButton.h
+ RenderCounter.cpp
+ RenderCounter.h
+ RenderDataGrid.cpp
+ RenderDataGrid.h
+ RenderFieldset.cpp
+ RenderFieldset.h
+ RenderFileUploadControl.cpp
+ RenderFileUploadControl.h
+ RenderFlexibleBox.cpp
+ RenderFlexibleBox.h
+ RenderForeignObject.cpp
+ RenderForeignObject.h
+ RenderFrame.cpp
+ RenderFrame.h
+ RenderFrameSet.cpp
+ RenderFrameSet.h
+ RenderHTMLCanvas.cpp
+ RenderHTMLCanvas.h
+ RenderImage.cpp
+ RenderImageGeneratedContent.cpp
+ RenderImageGeneratedContent.h
+ RenderImage.h
+ RenderInline.cpp
+ RenderInline.h
+ RenderLayerBacking.cpp
+ RenderLayerBacking.h
+ RenderLayerCompositor.cpp
+ RenderLayerCompositor.h
+ RenderLayer.cpp
+ RenderLayer.h
+ RenderLineBoxList.cpp
+ RenderLineBoxList.h
+ RenderListBox.cpp
+ RenderListBox.h
+ RenderListItem.cpp
+ RenderListItem.h
+ RenderListMarker.cpp
+ RenderListMarker.h
+ RenderMarquee.cpp
+ RenderMarquee.h
+ RenderMediaControlsChromium.cpp
+ RenderMediaControlsChromium.h
+ RenderMediaControls.cpp
+ RenderMediaControls.h
+ RenderMedia.cpp
+ RenderMedia.h
+ RenderMenuList.cpp
+ RenderMenuList.h
+ RenderObjectChildList.cpp
+ RenderObjectChildList.h
+ RenderObject.cpp
+ RenderObject.h
+ RenderOverflow.h
+ RenderPart.cpp
+ RenderPart.h
+ RenderPartObject.cpp
+ RenderPartObject.h
+ RenderPath.cpp
+ RenderPath.h
+ RenderReplaced.cpp
+ RenderReplaced.h
+ RenderReplica.cpp
+ RenderReplica.h
+ RenderScrollbar.cpp
+ RenderScrollbar.h
+ RenderScrollbarPart.cpp
+ RenderScrollbarPart.h
+ RenderScrollbarTheme.cpp
+ RenderScrollbarTheme.h
+ RenderSelectionInfo.h
+ RenderSlider.cpp
+ RenderSlider.h
+ RenderSVGBlock.cpp
+ RenderSVGBlock.h
+ RenderSVGContainer.cpp
+ RenderSVGContainer.h
+ RenderSVGGradientStop.cpp
+ RenderSVGGradientStop.h
+ RenderSVGHiddenContainer.cpp
+ RenderSVGHiddenContainer.h
+ RenderSVGImage.cpp
+ RenderSVGImage.h
+ RenderSVGInline.cpp
+ RenderSVGInline.h
+ RenderSVGInlineText.cpp
+ RenderSVGInlineText.h
+ RenderSVGModelObject.cpp
+ RenderSVGModelObject.h
+ RenderSVGRoot.cpp
+ RenderSVGRoot.h
+ RenderSVGText.cpp
+ RenderSVGText.h
+ RenderSVGTextPath.cpp
+ RenderSVGTextPath.h
+ RenderSVGTransformableContainer.cpp
+ RenderSVGTransformableContainer.h
+ RenderSVGTSpan.cpp
+ RenderSVGTSpan.h
+ RenderSVGViewportContainer.cpp
+ RenderSVGViewportContainer.h
+ RenderTableCell.cpp
+ RenderTableCell.h
+ RenderTableCol.cpp
+ RenderTableCol.h
+ RenderTable.cpp
+ RenderTable.h
+ RenderTableRow.cpp
+ RenderTableRow.h
+ RenderTableSection.cpp
+ RenderTableSection.h
+ RenderTextControl.cpp
+ RenderTextControl.h
+ RenderTextControlMultiLine.cpp
+ RenderTextControlMultiLine.h
+ RenderTextControlSingleLine.cpp
+ RenderTextControlSingleLine.h
+ RenderText.cpp
+ RenderTextFragment.cpp
+ RenderTextFragment.h
+ RenderText.h
+ RenderThemeChromiumLinux.cpp
+ RenderThemeChromiumLinux.h
+ RenderThemeChromiumMac.h
+ RenderThemeChromiumMac.mm
+ RenderThemeChromiumSkia.cpp
+ RenderThemeChromiumSkia.h
+ RenderThemeChromiumWin.cpp
+ RenderThemeChromiumWin.h
+ RenderTheme.cpp
+ RenderTheme.h
+ RenderThemeMac.h
+ RenderThemeSafari.cpp
+ RenderThemeSafari.h
+ RenderThemeWince.cpp
+ RenderThemeWince.h
+ RenderThemeWin.cpp
+ RenderThemeWin.h
+ RenderTreeAsText.cpp
+ RenderTreeAsText.h
+ RenderVideo.cpp
+ RenderVideo.h
+ RenderView.cpp
+ RenderView.h
+ RenderWidget.cpp
+ RenderWidget.h
+ RenderWidgetProtector.h
+ RenderWordBreak.cpp
+ RenderWordBreak.h
+ RootInlineBox.cpp
+ RootInlineBox.h
+ ScrollBehavior.cpp
+ ScrollBehavior.h
+ style/
+0 BindingURI.cpp
+ BindingURI.h
+ BorderData.h
+ BorderValue.h
+ CollapsedBorderValue.h
+ ContentData.cpp
+ ContentData.h
+ CounterContent.h
+ CounterDirectives.cpp
+ CounterDirectives.h
+ CursorData.h
+ CursorList.h
+ DataRef.h
+ FillLayer.cpp
+ FillLayer.h
+ KeyframeList.cpp
+ KeyframeList.h
+ NinePieceImage.cpp
+ NinePieceImage.h
+ OutlineValue.h
+ RenderStyleConstants.h
+ RenderStyle.cpp
+ RenderStyle.h
+ ShadowData.cpp
+ ShadowData.h
+ StyleBackgroundData.cpp
+ StyleBackgroundData.h
+ StyleBoxData.cpp
+ StyleBoxData.h
+ StyleCachedImage.cpp
+ StyleCachedImage.h
+ StyleDashboardRegion.h
+ StyleFlexibleBoxData.cpp
+ StyleFlexibleBoxData.h
+ StyleGeneratedImage.cpp
+ StyleGeneratedImage.h
+ StyleImage.h
+ StyleInheritedData.cpp
+ StyleInheritedData.h
+ StyleMarqueeData.cpp
+ StyleMarqueeData.h
+ StyleMultiColData.cpp
+ StyleMultiColData.h
+ StyleRareInheritedData.cpp
+ StyleRareInheritedData.h
+ StyleRareNonInheritedData.cpp
+ StyleRareNonInheritedData.h
+ StyleReflection.h
+ StyleSurroundData.cpp
+ StyleSurroundData.h
+ StyleTransformData.cpp
+ StyleTransformData.h
+ StyleVisualData.cpp
+ StyleVisualData.h
+ SVGRenderStyle.cpp
+ SVGRenderStyleDefs.cpp
+ SVGRenderStyleDefs.h
+ SVGRenderStyle.h
+2 SVGCharacterLayoutInfo.cpp
+ SVGCharacterLayoutInfo.h
+ SVGInlineFlowBox.cpp
+ SVGInlineFlowBox.h
+ SVGInlineTextBox.cpp
+ SVGInlineTextBox.h
+ SVGRenderSupport.cpp
+ SVGRenderSupport.h
+ SVGRenderTreeAsText.cpp
+ SVGRenderTreeAsText.h
+ SVGRootInlineBox.cpp
+ SVGRootInlineBox.h
+ TableLayout.h
+ TextControlInnerElements.cpp
+ TextControlInnerElements.h
+ TransformState.cpp
+ TransformState.h
+2 Resources/
+0 aliasCursor.png
+ cellCursor.png
+ contextMenuCursor.png
+ copyCursor.png
+ crossHairCursor.png
+ deleteButton.png
+ deleteButtonPressed.png
+ deleteButtonPressed.tiff
+ deleteButton.tiff
+ eastResizeCursor.png
+ eastWestResizeCursor.png
+ helpCursor.png
+ linkCursor.png
+ missingImage.png
+ missingImage.tiff
+ moveCursor.png
+ noDropCursor.png
+ noneCursor.png
+ northEastResizeCursor.png
+ northEastSouthWestResizeCursor.png
+ northResizeCursor.png
+ northSouthResizeCursor.png
+ northWestResizeCursor.png
+ northWestSouthEastResizeCursor.png
+ notAllowedCursor.png
+ nullPlugin.png
+ panIcon.png
+ progressCursor.png
+ southEastResizeCursor.png
+ southResizeCursor.png
+ southWestResizeCursor.png
+ textAreaResizeCorner.png
+ textAreaResizeCorner.tiff
+ urlIcon.png
+ verticalTextCursor.png
+ waitCursor.png
+ westResizeCursor.png
+ zoomInCursor.png
+ zoomOutCursor.png
+2 storage/
+0 ChangeVersionWrapper.cpp
+ ChangeVersionWrapper.h
+ DatabaseAuthorizer.cpp
+ DatabaseAuthorizer.h
+ Database.cpp
+ DatabaseDetails.h
+ Database.h
+ Database.idl
+ DatabaseTask.cpp
+ DatabaseTask.h
+ DatabaseThread.cpp
+ DatabaseThread.h
+ DatabaseTrackerClient.h
+ DatabaseTracker.cpp
+ DatabaseTracker.h
+ LocalStorageTask.cpp
+ LocalStorageTask.h
+ LocalStorageThread.cpp
+ LocalStorageThread.h
+ OriginQuotaManager.cpp
+ OriginQuotaManager.h
+ OriginUsageRecord.cpp
+ OriginUsageRecord.h
+ SQLError.h
+ SQLError.idl
+ SQLResultSet.cpp
+ SQLResultSet.h
+ SQLResultSet.idl
+ SQLResultSetRowList.cpp
+ SQLResultSetRowList.h
+ SQLResultSetRowList.idl
+ SQLStatementCallback.h
+ SQLStatement.cpp
+ SQLStatementErrorCallback.h
+ SQLStatement.h
+ SQLTransactionCallback.h
+ SQLTransactionClient.cpp
+ SQLTransactionClient.h
+ SQLTransactionCoordinator.cpp
+ SQLTransactionCoordinator.h
+ SQLTransaction.cpp
+ SQLTransactionErrorCallback.h
+ SQLTransaction.h
+ SQLTransaction.idl
+ StorageArea.h
+ StorageAreaImpl.cpp
+ StorageAreaImpl.h
+ StorageAreaSync.cpp
+ StorageAreaSync.h
+ Storage.cpp
+ StorageEvent.cpp
+ StorageEventDispatcher.cpp
+ StorageEventDispatcher.h
+ StorageEvent.h
+ StorageEvent.idl
+ Storage.h
+ Storage.idl
+ StorageMap.cpp
+ StorageMap.h
+ StorageNamespace.cpp
+ StorageNamespace.h
+ StorageNamespaceImpl.cpp
+ StorageNamespaceImpl.h
+ StorageSyncManager.cpp
+ StorageSyncManager.h
+2 svg/
+0 animation/
+0 SMILTimeContainer.cpp
+ SMILTimeContainer.h
+ SMILTime.cpp
+ SMILTime.h
+ SVGSMILElement.cpp
+ SVGSMILElement.h
+2 ColorDistance.cpp
+ ColorDistance.h
+ ElementTimeControl.h
+ ElementTimeControl.idl
+ GradientAttributes.h
+ graphics/
+0 filters/
+0 SVGDistantLightSource.h
+ SVGFEConvolveMatrix.cpp
+ SVGFEConvolveMatrix.h
+ SVGFEDiffuseLighting.cpp
+ SVGFEDiffuseLighting.h
+ SVGFEDisplacementMap.cpp
+ SVGFEDisplacementMap.h
+ SVGFEFlood.cpp
+ SVGFEFlood.h
+ SVGFEImage.cpp
+ SVGFEImage.h
+ SVGFEMerge.cpp
+ SVGFEMerge.h
+ SVGFEMorphology.cpp
+ SVGFEMorphology.h
+ SVGFEOffset.cpp
+ SVGFEOffset.h
+ SVGFESpecularLighting.cpp
+ SVGFESpecularLighting.h
+ SVGFETile.cpp
+ SVGFETile.h
+ SVGFETurbulence.cpp
+ SVGFETurbulence.h
+ SVGFilterBuilder.cpp
+ SVGFilterBuilder.h
+ SVGFilter.cpp
+ SVGFilter.h
+ SVGLightSource.cpp
+ SVGLightSource.h
+ SVGPointLightSource.h
+ SVGSpotLightSource.h
+2 SVGImage.cpp
+ SVGImage.h
+ SVGPaintServer.cpp
+ SVGPaintServerGradient.cpp
+ SVGPaintServerGradient.h
+ SVGPaintServer.h
+ SVGPaintServerLinearGradient.cpp
+ SVGPaintServerLinearGradient.h
+ SVGPaintServerPattern.cpp
+ SVGPaintServerPattern.h
+ SVGPaintServerRadialGradient.cpp
+ SVGPaintServerRadialGradient.h
+ SVGPaintServerSolid.cpp
+ SVGPaintServerSolid.h
+ SVGResourceClipper.cpp
+ SVGResourceClipper.h
+ SVGResource.cpp
+ SVGResourceFilter.cpp
+ SVGResourceFilter.h
+ SVGResource.h
+ SVGResourceListener.h
+ SVGResourceMarker.cpp
+ SVGResourceMarker.h
+ SVGResourceMasker.cpp
+ SVGResourceMasker.h
+2 LinearGradientAttributes.h
+ PatternAttributes.h
+ RadialGradientAttributes.h
+ SVGAElement.cpp
+ SVGAElement.h
+ SVGAElement.idl
+ SVGAllInOne.cpp
+ SVGAltGlyphElement.cpp
+ SVGAltGlyphElement.h
+ SVGAltGlyphElement.idl
+ SVGAngle.cpp
+ SVGAngle.h
+ SVGAngle.idl
+ SVGAnimateColorElement.cpp
+ SVGAnimateColorElement.h
+ SVGAnimateColorElement.idl
+ SVGAnimatedAngle.idl
+ SVGAnimatedBoolean.idl
+ SVGAnimatedEnumeration.idl
+ SVGAnimatedInteger.idl
+ SVGAnimatedLength.idl
+ SVGAnimatedLengthList.idl
+ SVGAnimatedNumber.idl
+ SVGAnimatedNumberList.idl
+ SVGAnimatedPathData.cpp
+ SVGAnimatedPathData.h
+ SVGAnimatedPathData.idl
+ SVGAnimatedPoints.cpp
+ SVGAnimatedPoints.h
+ SVGAnimatedPoints.idl
+ SVGAnimatedPreserveAspectRatio.idl
+ SVGAnimatedProperty.h
+ SVGAnimatedRect.idl
+ SVGAnimatedString.idl
+ SVGAnimatedTemplate.h
+ SVGAnimatedTransformList.idl
+ SVGAnimateElement.cpp
+ SVGAnimateElement.h
+ SVGAnimateElement.idl
+ SVGAnimateMotionElement.cpp
+ SVGAnimateMotionElement.h
+ SVGAnimateTransformElement.cpp
+ SVGAnimateTransformElement.h
+ SVGAnimateTransformElement.idl
+ SVGAnimationElement.cpp
+ SVGAnimationElement.h
+ SVGAnimationElement.idl
+ svgattrs.in
+ SVGCircleElement.cpp
+ SVGCircleElement.h
+ SVGCircleElement.idl
+ SVGClipPathElement.cpp
+ SVGClipPathElement.h
+ SVGClipPathElement.idl
+ SVGColor.cpp
+ SVGColor.h
+ SVGColor.idl
+ SVGComponentTransferFunctionElement.cpp
+ SVGComponentTransferFunctionElement.h
+ SVGComponentTransferFunctionElement.idl
+ SVGCursorElement.cpp
+ SVGCursorElement.h
+ SVGCursorElement.idl
+ SVGDefsElement.cpp
+ SVGDefsElement.h
+ SVGDefsElement.idl
+ SVGDescElement.cpp
+ SVGDescElement.h
+ SVGDescElement.idl
+ SVGDocument.cpp
+ SVGDocumentExtensions.cpp
+ SVGDocumentExtensions.h
+ SVGDocument.h
+ SVGDocument.idl
+ SVGElement.cpp
+ SVGElement.h
+ SVGElement.idl
+ SVGElementInstance.cpp
+ SVGElementInstance.h
+ SVGElementInstance.idl
+ SVGElementInstanceList.cpp
+ SVGElementInstanceList.h
+ SVGElementInstanceList.idl
+ SVGEllipseElement.cpp
+ SVGEllipseElement.h
+ SVGEllipseElement.idl
+ SVGException.h
+ SVGException.idl
+ SVGExternalResourcesRequired.cpp
+ SVGExternalResourcesRequired.h
+ SVGExternalResourcesRequired.idl
+ SVGFEBlendElement.cpp
+ SVGFEBlendElement.h
+ SVGFEBlendElement.idl
+ SVGFEColorMatrixElement.cpp
+ SVGFEColorMatrixElement.h
+ SVGFEColorMatrixElement.idl
+ SVGFEComponentTransferElement.cpp
+ SVGFEComponentTransferElement.h
+ SVGFEComponentTransferElement.idl
+ SVGFECompositeElement.cpp
+ SVGFECompositeElement.h
+ SVGFECompositeElement.idl
+ SVGFEDiffuseLightingElement.cpp
+ SVGFEDiffuseLightingElement.h
+ SVGFEDiffuseLightingElement.idl
+ SVGFEDisplacementMapElement.cpp
+ SVGFEDisplacementMapElement.h
+ SVGFEDisplacementMapElement.idl
+ SVGFEDistantLightElement.cpp
+ SVGFEDistantLightElement.h
+ SVGFEDistantLightElement.idl
+ SVGFEFloodElement.cpp
+ SVGFEFloodElement.h
+ SVGFEFloodElement.idl
+ SVGFEFuncAElement.cpp
+ SVGFEFuncAElement.h
+ SVGFEFuncAElement.idl
+ SVGFEFuncBElement.cpp
+ SVGFEFuncBElement.h
+ SVGFEFuncBElement.idl
+ SVGFEFuncGElement.cpp
+ SVGFEFuncGElement.h
+ SVGFEFuncGElement.idl
+ SVGFEFuncRElement.cpp
+ SVGFEFuncRElement.h
+ SVGFEFuncRElement.idl
+ SVGFEGaussianBlurElement.cpp
+ SVGFEGaussianBlurElement.h
+ SVGFEGaussianBlurElement.idl
+ SVGFEImageElement.cpp
+ SVGFEImageElement.h
+ SVGFEImageElement.idl
+ SVGFELightElement.cpp
+ SVGFELightElement.h
+ SVGFEMergeElement.cpp
+ SVGFEMergeElement.h
+ SVGFEMergeElement.idl
+ SVGFEMergeNodeElement.cpp
+ SVGFEMergeNodeElement.h
+ SVGFEMergeNodeElement.idl
+ SVGFEMorphologyElement.cpp
+ SVGFEMorphologyElement.h
+ SVGFEMorphologyElement.idl
+ SVGFEOffsetElement.cpp
+ SVGFEOffsetElement.h
+ SVGFEOffsetElement.idl
+ SVGFEPointLightElement.cpp
+ SVGFEPointLightElement.h
+ SVGFEPointLightElement.idl
+ SVGFESpecularLightingElement.cpp
+ SVGFESpecularLightingElement.h
+ SVGFESpecularLightingElement.idl
+ SVGFESpotLightElement.cpp
+ SVGFESpotLightElement.h
+ SVGFESpotLightElement.idl
+ SVGFETileElement.cpp
+ SVGFETileElement.h
+ SVGFETileElement.idl
+ SVGFETurbulenceElement.cpp
+ SVGFETurbulenceElement.h
+ SVGFETurbulenceElement.idl
+ SVGFilterElement.cpp
+ SVGFilterElement.h
+ SVGFilterElement.idl
+ SVGFilterPrimitiveStandardAttributes.cpp
+ SVGFilterPrimitiveStandardAttributes.h
+ SVGFilterPrimitiveStandardAttributes.idl
+ SVGFitToViewBox.cpp
+ SVGFitToViewBox.h
+ SVGFitToViewBox.idl
+ SVGFont.cpp
+ SVGFontData.cpp
+ SVGFontData.h
+ SVGFontElement.cpp
+ SVGFontElement.h
+ SVGFontElement.idl
+ SVGFontFaceElement.cpp
+ SVGFontFaceElement.h
+ SVGFontFaceElement.idl
+ SVGFontFaceFormatElement.cpp
+ SVGFontFaceFormatElement.h
+ SVGFontFaceFormatElement.idl
+ SVGFontFaceNameElement.cpp
+ SVGFontFaceNameElement.h
+ SVGFontFaceNameElement.idl
+ SVGFontFaceSrcElement.cpp
+ SVGFontFaceSrcElement.h
+ SVGFontFaceSrcElement.idl
+ SVGFontFaceUriElement.cpp
+ SVGFontFaceUriElement.h
+ SVGFontFaceUriElement.idl
+ SVGForeignObjectElement.cpp
+ SVGForeignObjectElement.h
+ SVGForeignObjectElement.idl
+ SVGGElement.cpp
+ SVGGElement.h
+ SVGGElement.idl
+ SVGGlyphElement.cpp
+ SVGGlyphElement.h
+ SVGGlyphElement.idl
+ SVGGlyphMap.h
+ SVGGradientElement.cpp
+ SVGGradientElement.h
+ SVGGradientElement.idl
+ SVGHKernElement.cpp
+ SVGHKernElement.h
+ SVGHKernElement.idl
+ SVGImageElement.cpp
+ SVGImageElement.h
+ SVGImageElement.idl
+ SVGImageLoader.cpp
+ SVGImageLoader.h
+ SVGLangSpace.cpp
+ SVGLangSpace.h
+ SVGLangSpace.idl
+ SVGLength.cpp
+ SVGLength.h
+ SVGLength.idl
+ SVGLengthList.cpp
+ SVGLengthList.h
+ SVGLengthList.idl
+ SVGLinearGradientElement.cpp
+ SVGLinearGradientElement.h
+ SVGLinearGradientElement.idl
+ SVGLineElement.cpp
+ SVGLineElement.h
+ SVGLineElement.idl
+ SVGList.h
+ SVGListTraits.h
+ SVGLocatable.cpp
+ SVGLocatable.h
+ SVGLocatable.idl
+ SVGMarkerElement.cpp
+ SVGMarkerElement.h
+ SVGMarkerElement.idl
+ SVGMaskElement.cpp
+ SVGMaskElement.h
+ SVGMaskElement.idl
+ SVGMatrix.idl
+ SVGMetadataElement.cpp
+ SVGMetadataElement.h
+ SVGMetadataElement.idl
+ SVGMissingGlyphElement.cpp
+ SVGMissingGlyphElement.h
+ SVGMissingGlyphElement.idl
+ SVGMPathElement.cpp
+ SVGMPathElement.h
+ SVGNumber.idl
+ SVGNumberList.cpp
+ SVGNumberList.h
+ SVGNumberList.idl
+ SVGPaint.cpp
+ SVGPaint.h
+ SVGPaint.idl
+ SVGParserUtilities.cpp
+ SVGParserUtilities.h
+ SVGPathElement.cpp
+ SVGPathElement.h
+ SVGPathElement.idl
+ SVGPathSegArcAbs.idl
+ SVGPathSegArc.cpp
+ SVGPathSegArc.h
+ SVGPathSegArcRel.idl
+ SVGPathSegClosePath.cpp
+ SVGPathSegClosePath.h
+ SVGPathSegClosePath.idl
+ SVGPathSegCurvetoCubicAbs.idl
+ SVGPathSegCurvetoCubic.cpp
+ SVGPathSegCurvetoCubic.h
+ SVGPathSegCurvetoCubicRel.idl
+ SVGPathSegCurvetoCubicSmoothAbs.idl
+ SVGPathSegCurvetoCubicSmooth.cpp
+ SVGPathSegCurvetoCubicSmooth.h
+ SVGPathSegCurvetoCubicSmoothRel.idl
+ SVGPathSegCurvetoQuadraticAbs.idl
+ SVGPathSegCurvetoQuadratic.cpp
+ SVGPathSegCurvetoQuadratic.h
+ SVGPathSegCurvetoQuadraticRel.idl
+ SVGPathSegCurvetoQuadraticSmoothAbs.idl
+ SVGPathSegCurvetoQuadraticSmooth.cpp
+ SVGPathSegCurvetoQuadraticSmooth.h
+ SVGPathSegCurvetoQuadraticSmoothRel.idl
+ SVGPathSeg.h
+ SVGPathSeg.idl
+ SVGPathSegLinetoAbs.idl
+ SVGPathSegLineto.cpp
+ SVGPathSegLineto.h
+ SVGPathSegLinetoHorizontalAbs.idl
+ SVGPathSegLinetoHorizontal.cpp
+ SVGPathSegLinetoHorizontal.h
+ SVGPathSegLinetoHorizontalRel.idl
+ SVGPathSegLinetoRel.idl
+ SVGPathSegLinetoVerticalAbs.idl
+ SVGPathSegLinetoVertical.cpp
+ SVGPathSegLinetoVertical.h
+ SVGPathSegLinetoVerticalRel.idl
+ SVGPathSegList.cpp
+ SVGPathSegList.h
+ SVGPathSegList.idl
+ SVGPathSegMovetoAbs.idl
+ SVGPathSegMoveto.cpp
+ SVGPathSegMoveto.h
+ SVGPathSegMovetoRel.idl
+ SVGPatternElement.cpp
+ SVGPatternElement.h
+ SVGPatternElement.idl
+ SVGPoint.idl
+ SVGPointList.cpp
+ SVGPointList.h
+ SVGPointList.idl
+ SVGPolyElement.cpp
+ SVGPolyElement.h
+ SVGPolygonElement.cpp
+ SVGPolygonElement.h
+ SVGPolygonElement.idl
+ SVGPolylineElement.cpp
+ SVGPolylineElement.h
+ SVGPolylineElement.idl
+ SVGPreserveAspectRatio.cpp
+ SVGPreserveAspectRatio.h
+ SVGPreserveAspectRatio.idl
+ SVGRadialGradientElement.cpp
+ SVGRadialGradientElement.h
+ SVGRadialGradientElement.idl
+ SVGRectElement.cpp
+ SVGRectElement.h
+ SVGRectElement.idl
+ SVGRect.idl
+ SVGRenderingIntent.h
+ SVGRenderingIntent.idl
+ SVGScriptElement.cpp
+ SVGScriptElement.h
+ SVGScriptElement.idl
+ SVGSetElement.cpp
+ SVGSetElement.h
+ SVGSetElement.idl
+ SVGStopElement.cpp
+ SVGStopElement.h
+ SVGStopElement.idl
+ SVGStringList.cpp
+ SVGStringList.h
+ SVGStringList.idl
+ SVGStylable.cpp
+ SVGStylable.h
+ SVGStylable.idl
+ SVGStyledElement.cpp
+ SVGStyledElement.h
+ SVGStyledLocatableElement.cpp
+ SVGStyledLocatableElement.h
+ SVGStyledTransformableElement.cpp
+ SVGStyledTransformableElement.h
+ SVGStyleElement.cpp
+ SVGStyleElement.h
+ SVGStyleElement.idl
+ SVGSVGElement.cpp
+ SVGSVGElement.h
+ SVGSVGElement.idl
+ SVGSwitchElement.cpp
+ SVGSwitchElement.h
+ SVGSwitchElement.idl
+ SVGSymbolElement.cpp
+ SVGSymbolElement.h
+ SVGSymbolElement.idl
+ svgtags.in
+ SVGTests.cpp
+ SVGTests.h
+ SVGTests.idl
+ SVGTextContentElement.cpp
+ SVGTextContentElement.h
+ SVGTextContentElement.idl
+ SVGTextElement.cpp
+ SVGTextElement.h
+ SVGTextElement.idl
+ SVGTextPathElement.cpp
+ SVGTextPathElement.h
+ SVGTextPathElement.idl
+ SVGTextPositioningElement.cpp
+ SVGTextPositioningElement.h
+ SVGTextPositioningElement.idl
+ SVGTitleElement.cpp
+ SVGTitleElement.h
+ SVGTitleElement.idl
+ SVGTransformable.cpp
+ SVGTransformable.h
+ SVGTransformable.idl
+ SVGTransform.cpp
+ SVGTransformDistance.cpp
+ SVGTransformDistance.h
+ SVGTransform.h
+ SVGTransform.idl
+ SVGTransformList.cpp
+ SVGTransformList.h
+ SVGTransformList.idl
+ SVGTRefElement.cpp
+ SVGTRefElement.h
+ SVGTRefElement.idl
+ SVGTSpanElement.cpp
+ SVGTSpanElement.h
+ SVGTSpanElement.idl
+ SVGUnitTypes.h
+ SVGUnitTypes.idl
+ SVGURIReference.cpp
+ SVGURIReference.h
+ SVGURIReference.idl
+ SVGUseElement.cpp
+ SVGUseElement.h
+ SVGUseElement.idl
+ SVGViewElement.cpp
+ SVGViewElement.h
+ SVGViewElement.idl
+ SVGViewSpec.cpp
+ SVGViewSpec.h
+ SVGViewSpec.idl
+ SVGZoomAndPan.cpp
+ SVGZoomAndPan.h
+ SVGZoomAndPan.idl
+ SVGZoomEvent.cpp
+ SVGZoomEvent.h
+ SVGZoomEvent.idl
+ SynchronizablePropertyController.cpp
+ SynchronizablePropertyController.h
+ SynchronizableTypeWrapper.h
+ xlinkattrs.in
+2 WebCore.3DRendering.exp
+ WebCore.DashboardSupport.exp
+ WebCore.gypi
+ WebCore.JNI.exp
+ WebCore.NPAPI.exp
+ WebCore.order
+ WebCorePrefix.cpp
+ WebCorePrefix.h
+ WebCore.pro
+ WebCore.qrc
+ WebCore.SVG.Animation.exp
+ WebCore.SVG.exp
+ WebCore.SVG.Filters.exp
+ WebCore.SVG.ForeignObject.exp
+ WebCore.Tiger.exp
+ WebCore.Video.exp
+ WebCore.VideoProxy.exp
+ websockets/
+0 WebSocketChannelClient.h
+ WebSocketChannel.cpp
+ WebSocketChannel.h
+ WebSocket.cpp
+ WebSocket.h
+ WebSocketHandshake.cpp
+ WebSocketHandshake.h
+ WebSocket.idl
+2 wml/
+0 WMLAccessElement.cpp
+ WMLAccessElement.h
+ WMLAElement.cpp
+ WMLAElement.h
+ WMLAnchorElement.cpp
+ WMLAnchorElement.h
+ WMLAttributeNames.in
+ WMLBRElement.cpp
+ WMLBRElement.h
+ WMLCardElement.cpp
+ WMLCardElement.h
+ WMLDocument.cpp
+ WMLDocument.h
+ WMLDoElement.cpp
+ WMLDoElement.h
+ WMLElement.cpp
+ WMLElement.h
+ WMLErrorHandling.cpp
+ WMLErrorHandling.h
+ WMLEventHandlingElement.cpp
+ WMLEventHandlingElement.h
+ WMLFieldSetElement.cpp
+ WMLFieldSetElement.h
+ WMLFormControlElement.cpp
+ WMLFormControlElement.h
+ WMLGoElement.cpp
+ WMLGoElement.h
+ WMLImageElement.cpp
+ WMLImageElement.h
+ WMLImageLoader.cpp
+ WMLImageLoader.h
+ WMLInputElement.cpp
+ WMLInputElement.h
+ WMLInsertedLegendElement.cpp
+ WMLInsertedLegendElement.h
+ WMLIntrinsicEvent.cpp
+ WMLIntrinsicEvent.h
+ WMLIntrinsicEventHandler.cpp
+ WMLIntrinsicEventHandler.h
+ WMLMetaElement.cpp
+ WMLMetaElement.h
+ WMLNoopElement.cpp
+ WMLNoopElement.h
+ WMLOnEventElement.cpp
+ WMLOnEventElement.h
+ WMLOptGroupElement.cpp
+ WMLOptGroupElement.h
+ WMLOptionElement.cpp
+ WMLOptionElement.h
+ WMLPageState.cpp
+ WMLPageState.h
+ WMLPElement.cpp
+ WMLPElement.h
+ WMLPostfieldElement.cpp
+ WMLPostfieldElement.h
+ WMLPrevElement.cpp
+ WMLPrevElement.h
+ WMLRefreshElement.cpp
+ WMLRefreshElement.h
+ WMLSelectElement.cpp
+ WMLSelectElement.h
+ WMLSetvarElement.cpp
+ WMLSetvarElement.h
+ WMLTableElement.cpp
+ WMLTableElement.h
+ WMLTagNames.in
+ WMLTaskElement.cpp
+ WMLTaskElement.h
+ WMLTemplateElement.cpp
+ WMLTemplateElement.h
+ WMLTimerElement.cpp
+ WMLTimerElement.h
+ WMLVariables.cpp
+ WMLVariables.h
+2 workers/
+0 AbstractWorker.cpp
+ AbstractWorker.h
+ AbstractWorker.idl
+ DedicatedWorkerContext.cpp
+ DedicatedWorkerContext.h
+ DedicatedWorkerContext.idl
+ DedicatedWorkerThread.cpp
+ DedicatedWorkerThread.h
+ DefaultSharedWorkerRepository.cpp
+ DefaultSharedWorkerRepository.h
+ GenericWorkerTask.h
+ SharedWorkerContext.cpp
+ SharedWorkerContext.h
+ SharedWorkerContext.idl
+ SharedWorker.cpp
+ SharedWorker.h
+ SharedWorker.idl
+ SharedWorkerRepository.h
+ SharedWorkerThread.cpp
+ SharedWorkerThread.h
+ WorkerContext.cpp
+ WorkerContext.h
+ WorkerContext.idl
+ WorkerContextProxy.h
+ Worker.cpp
+ Worker.h
+ Worker.idl
+ WorkerLoaderProxy.h
+ WorkerLocation.cpp
+ WorkerLocation.h
+ WorkerLocation.idl
+ WorkerMessagingProxy.cpp
+ WorkerMessagingProxy.h
+ WorkerObjectProxy.h
+ WorkerReportingProxy.h
+ WorkerRunLoop.cpp
+ WorkerRunLoop.h
+ WorkerScriptLoaderClient.h
+ WorkerScriptLoader.cpp
+ WorkerScriptLoader.h
+ WorkerThread.cpp
+ WorkerThread.h
+2 xml/
+0 DOMParser.cpp
+ DOMParser.h
+ DOMParser.idl
+ NativeXPathNSResolver.cpp
+ NativeXPathNSResolver.h
+ xmlattrs.in
+ XMLHttpRequest.cpp
+ XMLHttpRequestException.h
+ XMLHttpRequestException.idl
+ XMLHttpRequest.h
+ XMLHttpRequest.idl
+ XMLHttpRequestProgressEvent.h
+ XMLHttpRequestProgressEvent.idl
+ XMLHttpRequestUpload.cpp
+ XMLHttpRequestUpload.h
+ XMLHttpRequestUpload.idl
+ XMLSerializer.cpp
+ XMLSerializer.h
+ XMLSerializer.idl
+ XPathEvaluator.cpp
+ XPathEvaluator.h
+ XPathEvaluator.idl
+ XPathException.h
+ XPathException.idl
+ XPathExpression.cpp
+ XPathExpression.h
+ XPathExpression.idl
+ XPathExpressionNode.cpp
+ XPathExpressionNode.h
+ XPathFunctions.cpp
+ XPathFunctions.h
+ XPathGrammar.y
+ XPathNamespace.cpp
+ XPathNamespace.h
+ XPathNodeSet.cpp
+ XPathNodeSet.h
+ XPathNSResolver.cpp
+ XPathNSResolver.h
+ XPathNSResolver.idl
+ XPathParser.cpp
+ XPathParser.h
+ XPathPath.cpp
+ XPathPath.h
+ XPathPredicate.cpp
+ XPathPredicate.h
+ XPathResult.cpp
+ XPathResult.h
+ XPathResult.idl
+ XPathStep.cpp
+ XPathStep.h
+ XPathUtil.cpp
+ XPathUtil.h
+ XPathValue.cpp
+ XPathValue.h
+ XPathVariableReference.cpp
+ XPathVariableReference.h
+ XSLImportRule.cpp
+ XSLImportRule.h
+ XSLStyleSheet.h
+ XSLStyleSheetLibxslt.cpp
+ XSLStyleSheetQt.cpp
+ XSLTExtensions.cpp
+ XSLTExtensions.h
+ XSLTProcessor.cpp
+ XSLTProcessor.h
+ XSLTProcessor.idl
+ XSLTProcessorLibxslt.cpp
+ XSLTProcessorQt.cpp
+ XSLTUnicodeSort.cpp
+ XSLTUnicodeSort.h
+3 WebKit/
+0 ChangeLog
+ LICENSE
+ mac/
+0 Configurations/
+0 Version.xcconfig
+2 Workers/
+0 WebWorkersPrivate.h
+ WebWorkersPrivate.mm
+4 WebKit.pri
+ WebKit/qt/
+0 Api/
+0 headers.pri
+ qgraphicswebview.cpp
+ qgraphicswebview.h
+ qwebdatabase.cpp
+ qwebdatabase.h
+ qwebdatabase_p.h
+ qwebelement.cpp
+ qwebelement.h
+ qwebframe.cpp
+ qwebframe.h
+ qwebframe_p.h
+ qwebhistory.cpp
+ qwebhistory.h
+ qwebhistoryinterface.cpp
+ qwebhistoryinterface.h
+ qwebhistory_p.h
+ qwebinspector.cpp
+ qwebinspector.h
+ qwebinspector_p.h
+ qwebkitglobal.h
+ qwebkitversion.cpp
+ qwebkitversion.h
+ qwebpage.cpp
+ qwebpage.h
+ qwebpage_p.h
+ qwebplugindatabase.cpp
+ qwebplugindatabase_p.h
+ qwebpluginfactory.cpp
+ qwebpluginfactory.h
+ qwebsecurityorigin.cpp
+ qwebsecurityorigin.h
+ qwebsecurityorigin_p.h
+ qwebsettings.cpp
+ qwebsettings.h
+ qwebview.cpp
+ qwebview.h
+2 ChangeLog
+ docs/
+0 docs.pri
+ qtwebkit.qdoc
+0 conf
+2 qwebview-diagram.png
+ webkitsnippets/
+0 qtwebkit_build_snippet.qdoc
+ qtwebkit_qwebinspector_snippet.cpp
+ qtwebkit_qwebview_snippet.cpp
+ simple/
+0 main.cpp
+ simple.pro
+2 webelement/
+0 main.cpp
+ webelement.pro
+2 webpage/
+0 main.cpp
+ webpage.pro
+4 tests/
+0 benchmarks/
+0 loading/
+0 tst_loading.cpp
+ tst_loading.pro
+2 painting/
+0 tst_painting.cpp
+ tst_painting.pro
+3 qgraphicswebview/
+0 qgraphicswebview.pro
+ tst_qgraphicswebview.cpp
+2 qwebelement/
+0 image.png
+ qwebelement.pro
+ qwebelement.qrc
+ style2.css
+ style.css
+ tst_qwebelement.cpp
+2 qwebframe/
+0 image.png
+ qwebframe.pro
+ qwebframe.qrc
+ resources/
+0 image2.png
+2 style.css
+ test1.html
+ test2.html
+ tst_qwebframe.cpp
+2 qwebhistory/
+0 data/
+0 page1.html
+ page2.html
+ page3.html
+ page4.html
+ page5.html
+ page6.html
+3 qwebhistoryinterface/
+0 qwebhistoryinterface.pro
+ tst_qwebhistoryinterface.cpp
+2 qwebhistory/qwebhistory.pro
+ qwebhistory/tst_qwebhistory.cpp
+ qwebhistory/tst_qwebhistory.qrc
+ qwebpage/
+0 frametest/
+0 frame_a.html
+ iframe2.html
+ iframe3.html
+ iframe.html
+ index.html
+2 qwebpage.pro
+ tst_qwebpage.cpp
+ tst_qwebpage.qrc
+2 qwebplugindatabase/
+0 qwebplugindatabase.pro
+ tst_qwebplugindatabase.cpp
+2 qwebview/
+0 data/
+0 frame_a.html
+ index.html
+2 .gitignore
+ qwebview.pro
+ tst_qwebview.cpp
+ tst_qwebview.qrc
+2 resources/
+0 test.swf
+2 tests.pro
+ util.h
+2 WebCoreSupport/
+0 ChromeClientQt.cpp
+ ChromeClientQt.h
+ ContextMenuClientQt.cpp
+ ContextMenuClientQt.h
+ DragClientQt.cpp
+ DragClientQt.h
+ EditCommandQt.cpp
+ EditCommandQt.h
+ EditorClientQt.cpp
+ EditorClientQt.h
+ FrameLoaderClientQt.cpp
+ FrameLoaderClientQt.h
+ InspectorClientQt.cpp
+ InspectorClientQt.h
+2 WebKit_pch.h
+2 WebKit/scripts/
+0 generate-webkitversion.pl
+2 WebKit/StringsNotToBeLocalized.txt
+2 wintab/
+0 pktdef.h
+ wintab.h
+2 xorg/
+0 wacomcfg.h
+2 zlib/
+0 adler32.c
+ algorithm.txt
+ ChangeLog
+ compress.c
+ configure
+ crc32.c
+ crc32.h
+ deflate.c
+ deflate.h
+ example.c
+ examples/
+0 fitblk.c
+ gun.c
+ gzappend.c
+ gzjoin.c
+ gzlog.c
+ gzlog.h
+ README.examples
+ zlib_how.html
+ zpipe.c
+ zran.c
+2 FAQ
+ gzio.c
+ INDEX
+ infback.c
+ inffast.c
+ inffast.h
+ inffixed.h
+ inflate.c
+ inflate.h
+ inftrees.c
+ inftrees.h
+ Makefile
+0 .in
+2 make_vms.com
+ minigzip.c
+ projects/
+0 README.projects
+ visualc6/
+0 example.dsp
+ minigzip.dsp
+ README.txt
+ zlib.dsp
+ zlib.dsw
+3 README
+ trees.c
+ trees.h
+ uncompr.c
+ win32/
+0 DLL_FAQ.txt
+ Makefile.bor
+ Makefile.emx
+ Makefile.gcc
+ Makefile.msc
+ VisualC.txt
+ zlib1.rc
+ zlib.def
+2 zconf.h
+ zconf.in.h
+ zlib.3
+ zlib.h
+ zutil.c
+ zutil.h
+3 activeqt/
+0 activeqt.pro
+ container/
+0 container.pro
+ qaxbase.cpp
+ qaxbase.h
+ qaxdump.cpp
+ qaxobject.cpp
+ qaxobject.h
+ qaxscript.cpp
+ qaxscript.h
+ qaxscriptwrapper.cpp
+ qaxselect.cpp
+ qaxselect.h
+ qaxselect.ui
+ qaxwidget.cpp
+ qaxwidget.h
+2 control/
+0 control.pro
+ qaxaggregated.h
+ qaxbindable.cpp
+ qaxbindable.h
+ qaxfactory.cpp
+ qaxfactory.h
+ qaxmain.cpp
+ qaxserverbase.cpp
+ qaxserver.cpp
+ qaxserver.def
+ qaxserverdll.cpp
+ qaxserver.ico
+ qaxservermain.cpp
+ qaxserver.rc
+2 shared/
+0 qaxtypes.cpp
+ qaxtypes.h
+3 corelib/
+0 animation/
+0 animation.pri
+ qabstractanimation.cpp
+ qabstractanimation.h
+ qabstractanimation_p.h
+ qanimationgroup.cpp
+ qanimationgroup.h
+ qanimationgroup_p.h
+ qparallelanimationgroup.cpp
+ qparallelanimationgroup.h
+ qparallelanimationgroup_p.h
+ qpauseanimation.cpp
+ qpauseanimation.h
+ qpropertyanimation.cpp
+ qpropertyanimation.h
+ qpropertyanimation_p.h
+ qsequentialanimationgroup.cpp
+ qsequentialanimationgroup.h
+ qsequentialanimationgroup_p.h
+ qvariantanimation.cpp
+ qvariantanimation.h
+ qvariantanimation_p.h
+2 arch/
+0 alpha/
+0 arch.pri
+ qatomic_alpha.s
+2 arch.pri
+ arm/
+0 arch.pri
+ qatomic_arm.cpp
+2 armv6/
+0 arch.pri
+ qatomic_generic_armv6.cpp
+2 avr32/
+0 arch.pri
+2 bfin/
+0 arch.pri
+2 generic/
+0 arch.pri
+ qatomic_generic_unix.cpp
+ qatomic_generic_windows.cpp
+2 i386/
+0 arch.pri
+ qatomic_i386.s
+2 ia64/
+0 arch.pri
+ qatomic_ia64.s
+2 macosx/
+0 arch.pri
+ qatomic32_ppc.s
+2 mips/
+0 arch.pri
+ qatomic_mips32.s
+ qatomic_mips64.s
+2 parisc/
+0 arch.pri
+ qatomic_parisc.cpp
+ q_ldcw.s
+2 powerpc/
+0 arch.pri
+ qatomic32.s
+ qatomic64.s
+2 qatomic_alpha.h
+ qatomic_arch.h
+ qatomic_arm.h
+ qatomic_armv6.h
+ qatomic_avr32.h
+ qatomic_bfin.h
+ qatomic_bootstrap.h
+ qatomic_generic.h
+ qatomic_i386.h
+ qatomic_ia64.h
+ qatomic_macosx.h
+ qatomic_mips.h
+ qatomic_parisc.h
+ qatomic_powerpc.h
+ qatomic_s390.h
+ qatomic_sh4a.h
+ qatomic_sh.h
+ qatomic_sparc.h
+ qatomic_symbian.h
+ qatomic_vxworks.h
+ qatomic_windowsce.h
+ qatomic_windows.h
+ qatomic_x86_64.h
+ s390/
+0 arch.pri
+2 sh/
+ sh4a/
+0 arch.pri
+2 sh/arch.pri
+ sh/qatomic_sh.cpp
+ sparc/
+0 arch.pri
+ qatomic32.s
+ qatomic64.s
+ qatomic_sparc.cpp
+2 symbian/
+0 arch.pri
+ qatomic_symbian.cpp
+2 vxworks/
+0 arch.pri
+ qatomic_ppc.s
+2 windows/
+0 arch.pri
+2 x86_64/
+0 arch.pri
+ qatomic_sun.s
+3 codecs/
+0 codecs.pri
+ codecs.qdoc
+ qfontlaocodec.cpp
+ qfontlaocodec_p.h
+ qiconvcodec.cpp
+ qiconvcodec_p.h
+ qisciicodec.cpp
+ qisciicodec_p.h
+ qlatincodec.cpp
+ qlatincodec_p.h
+ qsimplecodec.cpp
+ qsimplecodec_p.h
+ qtextcodec.cpp
+ qtextcodec.h
+ qtextcodec_p.h
+ qtextcodecplugin.cpp
+ qtextcodecplugin.h
+ qtsciicodec.cpp
+ qtsciicodec_p.h
+ qutfcodec.cpp
+ qutfcodec_p.h
+2 concurrent/
+0 concurrent.pri
+ qfuture.cpp
+ qfuture.h
+ qfutureinterface.cpp
+ qfutureinterface.h
+ qfutureinterface_p.h
+ qfuturesynchronizer.cpp
+ qfuturesynchronizer.h
+ qfuturewatcher.cpp
+ qfuturewatcher.h
+ qfuturewatcher_p.h
+ qrunnable.cpp
+ qrunnable.h
+ qtconcurrentcompilertest.h
+ qtconcurrentexception.cpp
+ qtconcurrentexception.h
+ qtconcurrentfilter.cpp
+ qtconcurrentfilter.h
+ qtconcurrentfilterkernel.h
+ qtconcurrentfunctionwrappers.h
+ qtconcurrentiteratekernel.cpp
+ qtconcurrentiteratekernel.h
+ qtconcurrentmap.cpp
+ qtconcurrentmap.h
+ qtconcurrentmapkernel.h
+ qtconcurrentmedian.h
+ qtconcurrentreducekernel.h
+ qtconcurrentresultstore.cpp
+ qtconcurrentresultstore.h
+ qtconcurrentrunbase.h
+ qtconcurrentrun.cpp
+ qtconcurrentrun.h
+ qtconcurrentstoredfunctioncall.h
+ qtconcurrentthreadengine.cpp
+ qtconcurrentthreadengine.h
+ qthreadpool.cpp
+ qthreadpool.h
+ qthreadpool_p.h
+2 corelib.pro
+ eval.pri
+ global/
+0 global.pri
+ qconfig-dist.h
+ qconfig-large.h
+ qconfig-medium.h
+ qconfig-minimal.h
+ qconfig-small.h
+ qendian.h
+ qendian.qdoc
+ qfeatures.h
+ qfeatures.txt
+ qglobal.cpp
+ qglobal.h
+ qlibraryinfo.cpp
+ qlibraryinfo.h
+ qmalloc.cpp
+ qnamespace.h
+ qnamespace.qdoc
+ qnumeric.cpp
+ qnumeric.h
+ qnumeric_p.h
+ qt_pch.h
+ qt_windows.h
+2 io/
+0 io.pri
+ qabstractfileengine.cpp
+ qabstractfileengine.h
+ qabstractfileengine_p.h
+ qbuffer.cpp
+ qbuffer.h
+ qdatastream.cpp
+ qdatastream.h
+ qdatastream_p.h
+ qdebug.cpp
+ qdebug.h
+ qdir.cpp
+ qdir.h
+ qdiriterator.cpp
+ qdiriterator.h
+ qfile.cpp
+ qfile.h
+ qfileinfo.cpp
+ qfileinfo.h
+ qfileinfo_p.h
+ qfile_p.h
+ qfilesystemwatcher.cpp
+ qfilesystemwatcher_dnotify.cpp
+ qfilesystemwatcher_dnotify_p.h
+ qfilesystemwatcher_fsevents.cpp
+ qfilesystemwatcher_fsevents_p.h
+ qfilesystemwatcher.h
+ qfilesystemwatcher_inotify.cpp
+ qfilesystemwatcher_inotify_p.h
+ qfilesystemwatcher_kqueue.cpp
+ qfilesystemwatcher_kqueue_p.h
+ qfilesystemwatcher_p.h
+ qfilesystemwatcher_symbian.cpp
+ qfilesystemwatcher_symbian_p.h
+ qfilesystemwatcher_win.cpp
+ qfilesystemwatcher_win_p.h
+ qfsfileengine.cpp
+ qfsfileengine.h
+ qfsfileengine_iterator.cpp
+ qfsfileengine_iterator_p.h
+ qfsfileengine_iterator_unix.cpp
+ qfsfileengine_iterator_win.cpp
+ qfsfileengine_p.h
+ qfsfileengine_unix.cpp
+ qfsfileengine_win.cpp
+ qiodevice.cpp
+ qiodevice.h
+ qiodevice_p.h
+ qnoncontiguousbytedevice.cpp
+ qnoncontiguousbytedevice_p.h
+ qprocess.cpp
+ qprocess.h
+ qprocess_p.h
+ qprocess_symbian.cpp
+ qprocess_unix.cpp
+ qprocess_win.cpp
+ qresource.cpp
+ qresource.h
+ qresource_iterator.cpp
+ qresource_iterator_p.h
+ qresource_p.h
+ qsettings.cpp
+ qsettings.h
+ qsettings_mac.cpp
+ qsettings_p.h
+ qsettings_win.cpp
+ qtemporaryfile.cpp
+ qtemporaryfile.h
+ qtextstream.cpp
+ qtextstream.h
+ qurl.cpp
+ qurl.h
+ qwindowspipewriter.cpp
+ qwindowspipewriter_p.h
+2 kernel/
+0 kernel.pri
+ qabstracteventdispatcher.cpp
+ qabstracteventdispatcher.h
+ qabstracteventdispatcher_p.h
+ qabstractitemmodel.cpp
+ qabstractitemmodel.h
+ qabstractitemmodel_p.h
+ qbasictimer.cpp
+ qbasictimer.h
+ qcoreapplication.cpp
+ qcoreapplication.h
+ qcoreapplication_mac.cpp
+ qcoreapplication_p.h
+ qcoreapplication_win.cpp
+ qcorecmdlineargs_p.h
+ qcoreevent.cpp
+ qcoreevent.h
+ qcoreglobaldata.cpp
+ qcoreglobaldata_p.h
+ qcore_mac.cpp
+ qcore_mac_p.h
+ qcore_symbian_p.cpp
+ qcore_symbian_p.h
+ qcore_unix.cpp
+ qcore_unix_p.h
+ qcrashhandler.cpp
+ qcrashhandler_p.h
+ qeventdispatcher_glib.cpp
+ qeventdispatcher_glib_p.h
+ qeventdispatcher_symbian.cpp
+ qeventdispatcher_symbian_p.h
+ qeventdispatcher_unix.cpp
+ qeventdispatcher_unix_p.h
+ qeventdispatcher_win.cpp
+ qeventdispatcher_win_p.h
+ qeventloop.cpp
+ qeventloop.h
+ qfunctions_p.h
+ qfunctions_vxworks.cpp
+ qfunctions_vxworks.h
+ qfunctions_wince.cpp
+ qfunctions_wince.h
+ qguard_p.h
+ qmath.cpp
+ qmath.h
+ qmetaobject.cpp
+ qmetaobject.h
+ qmetaobject_p.h
+ qmetatype.cpp
+ qmetatype.h
+ qmimedata.cpp
+ qmimedata.h
+ qobjectcleanuphandler.cpp
+ qobjectcleanuphandler.h
+ qobject.cpp
+ qobjectdefs.h
+ qobject.h
+ qobject_p.h
+ qpointer.cpp
+ qpointer.h
+ qsharedmemory.cpp
+ qsharedmemory.h
+ qsharedmemory_p.h
+ qsharedmemory_symbian.cpp
+ qsharedmemory_unix.cpp
+ qsharedmemory_win.cpp
+ qsignalmapper.cpp
+ qsignalmapper.h
+ qsocketnotifier.cpp
+ qsocketnotifier.h
+ qsystemsemaphore.cpp
+ qsystemsemaphore.h
+ qsystemsemaphore_p.h
+ qsystemsemaphore_symbian.cpp
+ qsystemsemaphore_unix.cpp
+ qsystemsemaphore_win.cpp
+ qtcore_eval.cpp
+ qtimer.cpp
+ qtimer.h
+ qtranslator.cpp
+ qtranslator.h
+ qtranslator_p.h
+ qvariant.cpp
+ qvariant.h
+ qvariant_p.h
+ qwineventnotifier_p.cpp
+ qwineventnotifier_p.h
+2 plugin/
+0 plugin.pri
+ qfactoryinterface.h
+ qfactoryloader.cpp
+ qfactoryloader_p.h
+ qlibrary.cpp
+ qlibrary.h
+ qlibrary_p.h
+ qlibrary_unix.cpp
+ qlibrary_win.cpp
+ qplugin.h
+ qpluginloader.cpp
+ qpluginloader.h
+ qplugin.qdoc
+ quuid.cpp
+ quuid.h
+2 QtCore.dynlist
+ statemachine/
+0 qabstractstate.cpp
+ qabstractstate.h
+ qabstractstate_p.h
+ qabstracttransition.cpp
+ qabstracttransition.h
+ qabstracttransition_p.h
+ qeventtransition.cpp
+ qeventtransition.h
+ qeventtransition_p.h
+ qfinalstate.cpp
+ qfinalstate.h
+ qhistorystate.cpp
+ qhistorystate.h
+ qhistorystate_p.h
+ qsignaleventgenerator_p.h
+ qsignaltransition.cpp
+ qsignaltransition.h
+ qsignaltransition_p.h
+ qstate.cpp
+ qstate.h
+ qstatemachine.cpp
+ qstatemachine.h
+ qstatemachine_p.h
+ qstate_p.h
+ statemachine.pri
+2 thread/
+0 qatomic.cpp
+ qatomic.h
+ qbasicatomic.h
+ qmutex.cpp
+ qmutex.h
+ qmutex_p.h
+ qmutexpool.cpp
+ qmutexpool_p.h
+ qmutex_unix.cpp
+ qmutex_win.cpp
+ qorderedmutexlocker_p.h
+ qreadwritelock.cpp
+ qreadwritelock.h
+ qreadwritelock_p.h
+ qsemaphore.cpp
+ qsemaphore.h
+ qthread.cpp
+ qthread.h
+ qthread_p.h
+ qthreadstorage.cpp
+ qthreadstorage.h
+ qthread_unix.cpp
+ qthread_win.cpp
+ qwaitcondition.h
+ qwaitcondition.qdoc
+ qwaitcondition_unix.cpp
+ qwaitcondition_win.cpp
+ thread.pri
+2 tools/
+0 qalgorithms.h
+ qalgorithms.qdoc
+ qbitarray.cpp
+ qbitarray.h
+ qbytearray.cpp
+ qbytearray.h
+ qbytearraymatcher.cpp
+ qbytearraymatcher.h
+ qbytedata_p.h
+ qcache.h
+ qcache.qdoc
+ qchar.cpp
+ qchar.h
+ qcontainerfwd.h
+ qcontiguouscache.cpp
+ qcontiguouscache.h
+ qcryptographichash.cpp
+ qcryptographichash.h
+ qdatetime.cpp
+ qdatetime.h
+ qdatetime_p.h
+ qeasingcurve.cpp
+ qeasingcurve.h
+ qharfbuzz.cpp
+ qharfbuzz_p.h
+ qhash.cpp
+ qhash.h
+ qiterator.h
+ qiterator.qdoc
+ qline.cpp
+ qline.h
+ qlinkedlist.cpp
+ qlinkedlist.h
+ qlist.cpp
+ qlist.h
+ qlocale.cpp
+ qlocale_data_p.h
+ qlocale.h
+ qlocale_p.h
+ qlocale_symbian.cpp
+ qmap.cpp
+ qmap.h
+ qmargins.cpp
+ qmargins.h
+ qpair.h
+ qpair.qdoc
+ qpodlist_p.h
+ qpoint.cpp
+ qpoint.h
+ qqueue.cpp
+ qqueue.h
+ qrect.cpp
+ qrect.h
+ qregexp.cpp
+ qregexp.h
+ qringbuffer_p.h
+ qscopedpointer.cpp
+ qscopedpointer.h
+ qscopedpointer_p.h
+ qset.h
+ qset.qdoc
+ qshareddata.cpp
+ qshareddata.h
+ qsharedpointer.cpp
+ qsharedpointer.h
+ qsharedpointer_impl.h
+ qsize.cpp
+ qsize.h
+ qstack.cpp
+ qstack.h
+ qstringbuilder.cpp
+ qstringbuilder.h
+ qstring.cpp
+ qstring.h
+ qstringlist.cpp
+ qstringlist.h
+ qstringmatcher.cpp
+ qstringmatcher.h
+ qtextboundaryfinder.cpp
+ qtextboundaryfinder.h
+ qtimeline.cpp
+ qtimeline.h
+ qtools_p.h
+ qunicodetables.cpp
+ qunicodetables_p.h
+ qvarlengtharray.h
+ qvarlengtharray.qdoc
+ qvector.cpp
+ qvector.h
+ qvsnprintf.cpp
+ tools.pri
+2 xml/
+0 .gitignore
+ make-parser.sh
+ qxmlstream.cpp
+ qxmlstream.g
+ qxmlstream.h
+ qxmlstream_p.h
+ qxmlutils.cpp
+ qxmlutils_p.h
+ xml.pri
+3 dbus/
+0 dbus.pro
+ qdbusabstractadaptor.cpp
+ qdbusabstractadaptor.h
+ qdbusabstractadaptor_p.h
+ qdbusabstractinterface.cpp
+ qdbusabstractinterface.h
+ qdbusabstractinterface_p.h
+ qdbusargument.cpp
+ qdbusargument.h
+ qdbusargument_p.h
+ qdbusconnection.cpp
+ qdbusconnection.h
+ qdbusconnectioninterface.cpp
+ qdbusconnectioninterface.h
+ qdbusconnection_p.h
+ qdbuscontext.cpp
+ qdbuscontext.h
+ qdbuscontext_p.h
+ qdbusdemarshaller.cpp
+ qdbuserror.cpp
+ qdbuserror.h
+ qdbusextratypes.cpp
+ qdbusextratypes.h
+ qdbusintegrator.cpp
+ qdbusintegrator_p.h
+ qdbusinterface.cpp
+ qdbusinterface.h
+ qdbusinterface_p.h
+ qdbusinternalfilters.cpp
+ qdbusintrospection.cpp
+ qdbusintrospection_p.h
+ qdbusmacros.h
+ qdbusmarshaller.cpp
+ qdbusmessage.cpp
+ qdbusmessage.h
+ qdbusmessage_p.h
+ qdbusmetaobject.cpp
+ qdbusmetaobject_p.h
+ qdbusmetatype.cpp
+ qdbusmetatype.h
+ qdbusmetatype_p.h
+ qdbusmisc.cpp
+ qdbuspendingcall.cpp
+ qdbuspendingcall.h
+ qdbuspendingcall_p.h
+ qdbuspendingreply.cpp
+ qdbuspendingreply.h
+ qdbusreply.cpp
+ qdbusreply.h
+ qdbusserver.cpp
+ qdbusserver.h
+ qdbusservicewatcher.cpp
+ qdbusservicewatcher.h
+ qdbus_symbols.cpp
+ qdbus_symbols_p.h
+ qdbusthreaddebug_p.h
+ qdbusutil.cpp
+ qdbusutil_p.h
+ qdbusxmlgenerator.cpp
+ qdbusxmlparser.cpp
+ qdbusxmlparser_p.h
+2 gui/
+0 accessible/
+0 accessible.pri
+ qaccessible2.cpp
+ qaccessible2.h
+ qaccessiblebridge.cpp
+ qaccessiblebridge.h
+ qaccessible.cpp
+ qaccessible.h
+ qaccessible_mac_carbon.cpp
+ qaccessible_mac_cocoa.mm
+ qaccessible_mac.mm
+ qaccessible_mac_p.h
+ qaccessibleobject.cpp
+ qaccessibleobject.h
+ qaccessibleplugin.cpp
+ qaccessibleplugin.h
+ qaccessible_unix.cpp
+ qaccessiblewidget.cpp
+ qaccessiblewidget.h
+ qaccessible_win.cpp
+2 animation/
+0 animation.pri
+ qguivariantanimation.cpp
+2 dialogs/
+0 dialogs.pri
+ images/
+0 fit-page-24.png
+ fit-page-32.png
+ fit-width-24.png
+ fit-width-32.png
+ go-first-24.png
+ go-first-32.png
+ go-last-24.png
+ go-last-32.png
+ go-next-24.png
+ go-next-32.png
+ go-previous-24.png
+ go-previous-32.png
+ layout-landscape-24.png
+ layout-landscape-32.png
+ layout-portrait-24.png
+ layout-portrait-32.png
+ page-setup-24.png
+ page-setup-32.png
+ print-24.png
+ print-32.png
+ qtlogo-64.png
+ status-color.png
+ status-gray-scale.png
+ view-page-multi-24.png
+ view-page-multi-32.png
+ view-page-one-24.png
+ view-page-one-32.png
+ view-page-sided-24.png
+ view-page-sided-32.png
+ zoom-in-24.png
+ zoom-in-32.png
+ zoom-out-24.png
+ zoom-out-32.png
+2 qabstractpagesetupdialog.cpp
+ qabstractpagesetupdialog.h
+ qabstractpagesetupdialog_p.h
+ qabstractprintdialog.cpp
+ qabstractprintdialog.h
+ qabstractprintdialog_p.h
+ qcolordialog.cpp
+ qcolordialog.h
+ qcolordialog_mac.mm
+ qcolordialog_p.h
+ qdialog.cpp
+ qdialog.h
+ qdialog_p.h
+ qdialogsbinarycompat_win.cpp
+ qerrormessage.cpp
+ qerrormessage.h
+ qfiledialog.cpp
+ qfiledialog_embedded.ui
+ qfiledialog.h
+ qfiledialog_mac.mm
+ qfiledialog_p.h
+ qfiledialog.ui
+ qfiledialog_win.cpp
+ qfileinfogatherer.cpp
+ qfileinfogatherer_p.h
+ qfilesystemmodel.cpp
+ qfilesystemmodel.h
+ qfilesystemmodel_p.h
+ qfontdialog.cpp
+ qfontdialog.h
+ qfontdialog_mac.mm
+ qfontdialog_p.h
+ qfscompleter_p.h
+ qinputdialog.cpp
+ qinputdialog.h
+ qmessagebox.cpp
+ qmessagebox.h
+ qmessagebox.qrc
+ qnspanelproxy_mac.mm
+ qpagesetupdialog.cpp
+ qpagesetupdialog.h
+ qpagesetupdialog_mac.mm
+ qpagesetupdialog_unix.cpp
+ qpagesetupdialog_unix_p.h
+ qpagesetupdialog_win.cpp
+ qpagesetupwidget.ui
+ qprintdialog.h
+ qprintdialog_mac.mm
+ qprintdialog.qdoc
+ qprintdialog.qrc
+ qprintdialog_qws.cpp
+ qprintdialog_unix.cpp
+ qprintdialog_win.cpp
+ qprintpreviewdialog.cpp
+ qprintpreviewdialog.h
+ qprintpropertieswidget.ui
+ qprintsettingsoutput.ui
+ qprintwidget.ui
+ qprogressdialog.cpp
+ qprogressdialog.h
+ qsidebar.cpp
+ qsidebar_p.h
+ qwizard.cpp
+ qwizard.h
+ qwizard_win.cpp
+ qwizard_win_p.h
+2 effects/
+0 effects.pri
+ qgraphicseffect.cpp
+ qgraphicseffect.h
+ qgraphicseffect_p.h
+2 egl/
+0 egl.pri
+ qegl.cpp
+ qegl_p.h
+ qeglproperties.cpp
+ qeglproperties_p.h
+ qegl_qws.cpp
+ qegl_symbian.cpp
+ qegl_wince.cpp
+ qegl_x11.cpp
+2 embedded/
+0 directfb.pri
+ embedded.pri
+ qcopchannel_qws.cpp
+ qcopchannel_qws.h
+ qdecorationdefault_qws.cpp
+ qdecorationdefault_qws.h
+ qdecorationfactory_qws.cpp
+ qdecorationfactory_qws.h
+ qdecorationplugin_qws.cpp
+ qdecorationplugin_qws.h
+ qdecoration_qws.cpp
+ qdecoration_qws.h
+ qdecorationstyled_qws.cpp
+ qdecorationstyled_qws.h
+ qdecorationwindows_qws.cpp
+ qdecorationwindows_qws.h
+ qdirectpainter_qws.cpp
+ qdirectpainter_qws.h
+ qkbd_defaultmap_qws_p.h
+ qkbddriverfactory_qws.cpp
+ qkbddriverfactory_qws.h
+ qkbddriverplugin_qws.cpp
+ qkbddriverplugin_qws.h
+ qkbdlinuxinput_qws.cpp
+ qkbdlinuxinput_qws.h
+ qkbdqnx_qws.cpp
+ qkbdqnx_qws.h
+ qkbd_qws.cpp
+ qkbd_qws.h
+ qkbd_qws_p.h
+ qkbdtty_qws.cpp
+ qkbdtty_qws.h
+ qkbdum_qws.cpp
+ qkbdum_qws.h
+ qkbdvfb_qws.cpp
+ qkbdvfb_qws.h
+ qlock.cpp
+ qlock_p.h
+ qmousedriverfactory_qws.cpp
+ qmousedriverfactory_qws.h
+ qmousedriverplugin_qws.cpp
+ qmousedriverplugin_qws.h
+ qmouselinuxinput_qws.cpp
+ qmouselinuxinput_qws.h
+ qmouselinuxtp_qws.cpp
+ qmouselinuxtp_qws.h
+ qmousepc_qws.cpp
+ qmousepc_qws.h
+ qmouseqnx_qws.cpp
+ qmouseqnx_qws.h
+ qmouse_qws.cpp
+ qmouse_qws.h
+ qmousetslib_qws.cpp
+ qmousetslib_qws.h
+ qmousevfb_qws.cpp
+ qmousevfb_qws.h
+ qscreendriverfactory_qws.cpp
+ qscreendriverfactory_qws.h
+ qscreendriverplugin_qws.cpp
+ qscreendriverplugin_qws.h
+ qscreenlinuxfb_qws.cpp
+ qscreenlinuxfb_qws.h
+ qscreenmulti_qws.cpp
+ qscreenmulti_qws_p.h
+ qscreenproxy_qws.cpp
+ qscreenproxy_qws.h
+ qscreenqnx_qws.cpp
+ qscreenqnx_qws.h
+ qscreen_qws.cpp
+ qscreen_qws.h
+ qscreentransformed_qws.cpp
+ qscreentransformed_qws.h
+ qscreenvfb_qws.cpp
+ qscreenvfb_qws.h
+ qsoundqss_qws.cpp
+ qsoundqss_qws.h
+ qtransportauthdefs_qws.h
+ qtransportauth_qws.cpp
+ qtransportauth_qws.h
+ qtransportauth_qws_p.h
+ qunixsocket.cpp
+ qunixsocket_p.h
+ qunixsocketserver.cpp
+ qunixsocketserver_p.h
+ qvfbhdr.h
+ qwindowsystem_p.h
+ qwindowsystem_qws.cpp
+ qwindowsystem_qws.h
+ qwscommand_qws.cpp
+ qwscommand_qws_p.h
+ qwscursor_qws.cpp
+ qwscursor_qws.h
+ qwsdisplay_qws.h
+ qwsdisplay_qws_p.h
+ qwsembedwidget.cpp
+ qwsembedwidget.h
+ qwsevent_qws.cpp
+ qwsevent_qws.h
+ qwslock.cpp
+ qwslock_p.h
+ qwsmanager_p.h
+ qwsmanager_qws.cpp
+ qwsmanager_qws.h
+ qwsproperty_qws.cpp
+ qwsproperty_qws.h
+ qwsprotocolitem_qws.h
+ qwssharedmemory.cpp
+ qwssharedmemory_p.h
+ qwssignalhandler.cpp
+ qwssignalhandler_p.h
+ qwssocket_qws.cpp
+ qwssocket_qws.h
+ qwsutils_qws.h
+2 graphicsview/
+0 graphicsview.pri
+ qgraphicsanchorlayout.cpp
+ qgraphicsanchorlayout.h
+ qgraphicsanchorlayout_p.cpp
+ qgraphicsanchorlayout_p.h
+ qgraphicsgridlayout.cpp
+ qgraphicsgridlayout.h
+ qgraphicsitemanimation.cpp
+ qgraphicsitemanimation.h
+ qgraphicsitem.cpp
+ qgraphicsitem.h
+ qgraphicsitem_p.h
+ qgraphicslayout.cpp
+ qgraphicslayout.h
+ qgraphicslayoutitem.cpp
+ qgraphicslayoutitem.h
+ qgraphicslayoutitem_p.h
+ qgraphicslayout_p.cpp
+ qgraphicslayout_p.h
+ qgraphicslinearlayout.cpp
+ qgraphicslinearlayout.h
+ qgraphicsproxywidget.cpp
+ qgraphicsproxywidget.h
+ qgraphicsproxywidget_p.h
+ qgraphicsscene_bsp.cpp
+ qgraphicsscene_bsp_p.h
+ qgraphicsscenebsptreeindex.cpp
+ qgraphicsscenebsptreeindex_p.h
+ qgraphicsscene.cpp
+ qgraphicssceneevent.cpp
+ qgraphicssceneevent.h
+ qgraphicsscene.h
+ qgraphicssceneindex.cpp
+ qgraphicssceneindex_p.h
+ qgraphicsscenelinearindex.cpp
+ qgraphicsscenelinearindex_p.h
+ qgraphicsscene_p.h
+ qgraphicstransform.cpp
+ qgraphicstransform.h
+ qgraphicstransform_p.h
+ qgraphicsview.cpp
+ qgraphicsview.h
+ qgraphicsview_p.h
+ qgraphicswidget.cpp
+ qgraphicswidget.h
+ qgraphicswidget_p.cpp
+ qgraphicswidget_p.h
+ qgraph_p.h
+ qgridlayoutengine.cpp
+ qgridlayoutengine_p.h
+ qsimplex_p.cpp
+ qsimplex_p.h
+2 gui.pro
+ image/
+0 image.pri
+ qbitmap.cpp
+ qbitmap.h
+ qbmphandler.cpp
+ qbmphandler_p.h
+ qicon.cpp
+ qiconengine.cpp
+ qiconengine.h
+ qiconengineplugin.cpp
+ qiconengineplugin.h
+ qicon.h
+ qiconloader.cpp
+ qiconloader_p.h
+ qicon_p.h
+ qimage.cpp
+ qimage.h
+ qimageiohandler.cpp
+ qimageiohandler.h
+ qimage_p.h
+ qimagepixmapcleanuphooks.cpp
+ qimagepixmapcleanuphooks_p.h
+ qimagereader.cpp
+ qimagereader.h
+ qimagewriter.cpp
+ qimagewriter.h
+ qmovie.cpp
+ qmovie.h
+ qnativeimage.cpp
+ qnativeimage_p.h
+ qpaintengine_pic.cpp
+ qpaintengine_pic_p.h
+ qpicture.cpp
+ qpictureformatplugin.cpp
+ qpictureformatplugin.h
+ qpicture.h
+ qpicture_p.h
+ qpixmapcache.cpp
+ qpixmapcache.h
+ qpixmapcache_p.h
+ qpixmap.cpp
+ qpixmapdata.cpp
+ qpixmapdatafactory.cpp
+ qpixmapdatafactory_p.h
+ qpixmapdata_p.h
+ qpixmapfilter.cpp
+ qpixmapfilter_p.h
+ qpixmap.h
+ qpixmap_mac.cpp
+ qpixmap_mac_p.h
+ qpixmap_qws.cpp
+ qpixmap_raster.cpp
+ qpixmap_raster_p.h
+ qpixmap_s60.cpp
+ qpixmap_s60_p.h
+ qpixmap_win.cpp
+ qpixmap_x11.cpp
+ qpixmap_x11_p.h
+ qpnghandler.cpp
+ qpnghandler_p.h
+ qppmhandler.cpp
+ qppmhandler_p.h
+ qxbmhandler.cpp
+ qxbmhandler_p.h
+ qxpmhandler.cpp
+ qxpmhandler_p.h
+2 inputmethod/
+0 inputmethod.pri
+ qcoefepinputcontext_p.h
+ qcoefepinputcontext_s60.cpp
+ qinputcontext.cpp
+ qinputcontextfactory.cpp
+ qinputcontextfactory.h
+ qinputcontext.h
+ qinputcontext_p.h
+ qinputcontextplugin.cpp
+ qinputcontextplugin.h
+ qmacinputcontext_mac.cpp
+ qmacinputcontext_p.h
+ qwininputcontext_p.h
+ qwininputcontext_win.cpp
+ qwsinputcontext_p.h
+ qwsinputcontext_qws.cpp
+ qximinputcontext_p.h
+ qximinputcontext_x11.cpp
+2 itemviews/
+0 itemviews.pri
+ qabstractitemdelegate.cpp
+ qabstractitemdelegate.h
+ qabstractitemview.cpp
+ qabstractitemview.h
+ qabstractitemview_p.h
+ qabstractproxymodel.cpp
+ qabstractproxymodel.h
+ qabstractproxymodel_p.h
+ qbsptree.cpp
+ qbsptree_p.h
+ qcolumnview.cpp
+ qcolumnviewgrip.cpp
+ qcolumnviewgrip_p.h
+ qcolumnview.h
+ qcolumnview_p.h
+ qdatawidgetmapper.cpp
+ qdatawidgetmapper.h
+ qdirmodel.cpp
+ qdirmodel.h
+ qfileiconprovider.cpp
+ qfileiconprovider.h
+ qheaderview.cpp
+ qheaderview.h
+ qheaderview_p.h
+ qitemdelegate.cpp
+ qitemdelegate.h
+ qitemeditorfactory.cpp
+ qitemeditorfactory.h
+ qitemeditorfactory_p.h
+ qitemselectionmodel.cpp
+ qitemselectionmodel.h
+ qitemselectionmodel_p.h
+ qlistview.cpp
+ qlistview.h
+ qlistview_p.h
+ qlistwidget.cpp
+ qlistwidget.h
+ qlistwidget_p.h
+ qproxymodel.cpp
+ qproxymodel.h
+ qproxymodel_p.h
+ qsortfilterproxymodel.cpp
+ qsortfilterproxymodel.h
+ qstandarditemmodel.cpp
+ qstandarditemmodel.h
+ qstandarditemmodel_p.h
+ qstringlistmodel.cpp
+ qstringlistmodel.h
+ qstyleditemdelegate.cpp
+ qstyleditemdelegate.h
+ qtableview.cpp
+ qtableview.h
+ qtableview_p.h
+ qtablewidget.cpp
+ qtablewidget.h
+ qtablewidget_p.h
+ qtreeview.cpp
+ qtreeview.h
+ qtreeview_p.h
+ qtreewidget.cpp
+ qtreewidget.h
+ qtreewidgetitemiterator.cpp
+ qtreewidgetitemiterator.h
+ qtreewidgetitemiterator_p.h
+ qtreewidget_p.h
+ qwidgetitemdata_p.h
+2 kernel/
+0 kernel.pri
+ mac.pri
+ qaction.cpp
+ qactiongroup.cpp
+ qactiongroup.h
+ qaction.h
+ qaction_p.h
+ qapplication.cpp
+ qapplication.h
+ qapplication_mac.mm
+ qapplication_p.h
+ qapplication_qws.cpp
+ qapplication_s60.cpp
+ qapplication_win.cpp
+ qapplication_x11.cpp
+ qboxlayout.cpp
+ qboxlayout.h
+ qclipboard.cpp
+ qclipboard.h
+ qclipboard_mac.cpp
+ qclipboard_p.h
+ qclipboard_qws.cpp
+ qclipboard_s60.cpp
+ qclipboard_win.cpp
+ qclipboard_x11.cpp
+ qcocoaapplicationdelegate_mac.mm
+ qcocoaapplicationdelegate_mac_p.h
+ qcocoaapplication_mac.mm
+ qcocoaapplication_mac_p.h
+ qcocoamenuloader_mac.mm
+ qcocoamenuloader_mac_p.h
+ qcocoapanel_mac.mm
+ qcocoapanel_mac_p.h
+ qcocoaview_mac.mm
+ qcocoaview_mac_p.h
+ qcocoawindowcustomthemeframe_mac.mm
+ qcocoawindowcustomthemeframe_mac_p.h
+ qcocoawindowdelegate_mac.mm
+ qcocoawindowdelegate_mac_p.h
+ qcocoawindow_mac.mm
+ qcocoawindow_mac_p.h
+ qcursor.cpp
+ qcursor.h
+ qcursor_mac.mm
+ qcursor_p.h
+ qcursor_qws.cpp
+ qcursor_s60.cpp
+ qcursor_win.cpp
+ qcursor_x11.cpp
+ qdesktopwidget.cpp
+ qdesktopwidget.h
+ qdesktopwidget_mac.mm
+ qdesktopwidget_mac_p.h
+ qdesktopwidget.qdoc
+ qdesktopwidget_qws.cpp
+ qdesktopwidget_s60.cpp
+ qdesktopwidget_win.cpp
+ qdesktopwidget_x11.cpp
+ qdnd.cpp
+ qdnd_mac.mm
+ qdnd_p.h
+ qdnd_qws.cpp
+ qdnd_s60.cpp
+ qdnd_win.cpp
+ qdnd_x11.cpp
+ qdrag.cpp
+ qdrag.h
+ qevent.cpp
+ qeventdispatcher_glib_qws.cpp
+ qeventdispatcher_glib_qws_p.h
+ qeventdispatcher_mac.mm
+ qeventdispatcher_mac_p.h
+ qeventdispatcher_qws.cpp
+ qeventdispatcher_qws_p.h
+ qeventdispatcher_s60.cpp
+ qeventdispatcher_s60_p.h
+ qeventdispatcher_x11.cpp
+ qeventdispatcher_x11_p.h
+ qevent.h
+ qevent_p.h
+ qformlayout.cpp
+ qformlayout.h
+ qgesture.cpp
+ qgesture.h
+ qgesturemanager.cpp
+ qgesturemanager_p.h
+ qgesture_p.h
+ qgesturerecognizer.cpp
+ qgesturerecognizer.h
+ qgridlayout.cpp
+ qgridlayout.h
+ qguieventdispatcher_glib.cpp
+ qguieventdispatcher_glib_p.h
+ qguifunctions_wince.cpp
+ qguifunctions_wince.h
+ qguiplatformplugin.cpp
+ qguiplatformplugin_p.h
+ qguivariant.cpp
+ qkde.cpp
+ qkde_p.h
+ qkeymapper.cpp
+ qkeymapper_mac.cpp
+ qkeymapper_p.h
+ qkeymapper_qws.cpp
+ qkeymapper_s60.cpp
+ qkeymapper_win.cpp
+ qkeymapper_x11.cpp
+ qkeymapper_x11_p.cpp
+ qkeysequence.cpp
+ qkeysequence.h
+ qkeysequence_p.h
+ qlayout.cpp
+ qlayoutengine.cpp
+ qlayoutengine_p.h
+ qlayout.h
+ qlayoutitem.cpp
+ qlayoutitem.h
+ qlayout_p.h
+ qmacdefines_mac.h
+ qmacgesturerecognizer_mac.mm
+ qmacgesturerecognizer_mac_p.h
+ qmime.cpp
+ qmime.h
+ qmime_mac.cpp
+ qmime_win.cpp
+ qmotifdnd_x11.cpp
+ qmultitouch_mac.mm
+ qmultitouch_mac_p.h
+ qnsframeview_mac_p.h
+ qnsthemeframe_mac_p.h
+ qnstitledframe_mac_p.h
+ qole_win.cpp
+ qpalette.cpp
+ qpalette.h
+ qsessionmanager.h
+ qsessionmanager_qws.cpp
+ qshortcut.cpp
+ qshortcut.h
+ qshortcutmap.cpp
+ qshortcutmap_p.h
+ qsizepolicy.h
+ qsizepolicy.qdoc
+ qsoftkeymanager.cpp
+ qsoftkeymanager_p.h
+ qsound.cpp
+ qsound.h
+ qsound_mac.mm
+ qsound_p.h
+ qsound_qws.cpp
+ qsound_s60.cpp
+ qsound_win.cpp
+ qsound_x11.cpp
+ qstackedlayout.cpp
+ qstackedlayout.h
+ qstandardgestures.cpp
+ qstandardgestures_p.h
+ qt_cocoa_helpers_mac.mm
+ qt_cocoa_helpers_mac_p.h
+ qt_gui_pch.h
+ qt_mac.cpp
+ qt_mac_p.h
+ qtooltip.cpp
+ qtooltip.h
+ qt_s60_p.h
+ qt_x11_p.h
+ qwhatsthis.cpp
+ qwhatsthis.h
+ qwidgetaction.cpp
+ qwidgetaction.h
+ qwidgetaction_p.h
+ qwidget.cpp
+ qwidgetcreate_x11.cpp
+ qwidget.h
+ qwidget_mac.mm
+ qwidget_p.h
+ qwidget_qws.cpp
+ qwidget_s60.cpp
+ qwidget_wince.cpp
+ qwidget_win.cpp
+ qwidget_x11.cpp
+ qwindowdefs.h
+ qwindowdefs_win.h
+ qwinnativepangesturerecognizer_win.cpp
+ qwinnativepangesturerecognizer_win_p.h
+ qx11embed_x11.cpp
+ qx11embed_x11.h
+ qx11info_x11.cpp
+ qx11info_x11.h
+ symbian.pri
+ win.pri
+ x11.pri
+2 mac/
+0 images/
+0 copyarrowcursor.png
+ forbiddencursor.png
+ leopard-unified-toolbar-on.png
+ pluscursor.png
+ spincursor.png
+ waitcursor.png
+2 macresources.qrc
+ qt_menu.nib/
+0 classes.nib
+ info.nib
+ keyedobjects.nib
+3 math3d/
+0 math3d.pri
+ qgenericmatrix.cpp
+ qgenericmatrix.h
+ qmatrix4x4.cpp
+ qmatrix4x4.h
+ qquaternion.cpp
+ qquaternion.h
+ qvector2d.cpp
+ qvector2d.h
+ qvector3d.cpp
+ qvector3d.h
+ qvector4d.cpp
+ qvector4d.h
+2 painting/
+0 makepsheader.pl
+ painting.pri
+ qbackingstore.cpp
+ qbackingstore_p.h
+ qbezier.cpp
+ qbezier_p.h
+ qblendfunctions_armv6_rvct.s
+ qblendfunctions.cpp
+ qbrush.cpp
+ qbrush.h
+ qcolor.cpp
+ qcolor.h
+ qcolormap.h
+ qcolormap_mac.cpp
+ qcolormap.qdoc
+ qcolormap_qws.cpp
+ qcolormap_s60.cpp
+ qcolormap_win.cpp
+ qcolormap_x11.cpp
+ qcolor_p.cpp
+ qcolor_p.h
+ qcssutil.cpp
+ qcssutil_p.h
+ qcups.cpp
+ qcups_p.h
+ qdatabuffer_p.h
+ qdrawhelper_armv6_p.h
+ qdrawhelper_armv6_rvct.inc
+ qdrawhelper_armv6_rvct.s
+ qdrawhelper.cpp
+ qdrawhelper_iwmmxt.cpp
+ qdrawhelper_mmx3dnow.cpp
+ qdrawhelper_mmx.cpp
+ qdrawhelper_mmx_p.h
+ qdrawhelper_p.h
+ qdrawhelper_sse2.cpp
+ qdrawhelper_sse3dnow.cpp
+ qdrawhelper_sse.cpp
+ qdrawhelper_sse_p.h
+ qdrawhelper_x86_p.h
+ qdrawutil.cpp
+ qdrawutil.h
+ qemulationpaintengine.cpp
+ qemulationpaintengine_p.h
+ qfixed_p.h
+ qgraphicssystem.cpp
+ qgraphicssystemfactory.cpp
+ qgraphicssystemfactory_p.h
+ qgraphicssystem_mac.cpp
+ qgraphicssystem_mac_p.h
+ qgraphicssystem_p.h
+ qgraphicssystemplugin.cpp
+ qgraphicssystemplugin_p.h
+ qgraphicssystem_qws.cpp
+ qgraphicssystem_qws_p.h
+ qgraphicssystem_raster.cpp
+ qgraphicssystem_raster_p.h
+ qgrayraster.c
+ qgrayraster_p.h
+ qimagescale.cpp
+ qimagescale_p.h
+ qmath_p.h
+ qmatrix.cpp
+ qmatrix.h
+ qmemrotate.cpp
+ qmemrotate_p.h
+ qoutlinemapper.cpp
+ qoutlinemapper_p.h
+ qpaintbuffer.cpp
+ qpaintbuffer_p.h
+ qpaintdevice.cpp
+ qpaintdevice.h
+ qpaintdevice_mac.cpp
+ qpaintdevice.qdoc
+ qpaintdevice_qws.cpp
+ qpaintdevice_win.cpp
+ qpaintdevice_x11.cpp
+ qpaintengine_alpha.cpp
+ qpaintengine_alpha_p.h
+ qpaintengine.cpp
+ qpaintengineex.cpp
+ qpaintengineex_p.h
+ qpaintengine.h
+ qpaintengine_mac.cpp
+ qpaintengine_mac_p.h
+ qpaintengine_p.h
+ qpaintengine_preview.cpp
+ qpaintengine_preview_p.h
+ qpaintengine_raster.cpp
+ qpaintengine_raster_p.h
+ qpaintengine_s60.cpp
+ qpaintengine_s60_p.h
+ qpaintengine_x11.cpp
+ qpaintengine_x11_p.h
+ qpainter.cpp
+ qpainter.h
+ qpainterpath.cpp
+ qpainterpath.h
+ qpainterpath_p.h
+ qpainter_p.h
+ qpathclipper.cpp
+ qpathclipper_p.h
+ qpdf.cpp
+ qpdf_p.h
+ qpen.cpp
+ qpen.h
+ qpen_p.h
+ qpolygonclipper_p.h
+ qpolygon.cpp
+ qpolygon.h
+ qprintengine.h
+ qprintengine_mac.mm
+ qprintengine_mac_p.h
+ qprintengine_pdf.cpp
+ qprintengine_pdf_p.h
+ qprintengine_ps.cpp
+ qprintengine_ps_p.h
+ qprintengine_qws.cpp
+ qprintengine_qws_p.h
+ qprintengine_win.cpp
+ qprintengine_win_p.h
+ qprinter.cpp
+ qprinter.h
+ qprinterinfo.h
+ qprinterinfo_mac.cpp
+ qprinterinfo.qdoc
+ qprinterinfo_unix.cpp
+ qprinterinfo_unix_p.h
+ qprinterinfo_win.cpp
+ qprinter_p.h
+ qpsprinter.agl
+ qpsprinter.ps
+ qrasterdefs_p.h
+ qrasterizer.cpp
+ qrasterizer_p.h
+ qregion.cpp
+ qregion.h
+ qregion_mac.cpp
+ qregion_qws.cpp
+ qregion_s60.cpp
+ qregion_win.cpp
+ qregion_x11.cpp
+ qrgb.h
+ qstroker.cpp
+ qstroker_p.h
+ qstylepainter.cpp
+ qstylepainter.h
+ qtessellator.cpp
+ qtessellator_p.h
+ qtextureglyphcache.cpp
+ qtextureglyphcache_p.h
+ qtransform.cpp
+ qtransform.h
+ qvectorpath_p.h
+ qwindowsurface.cpp
+ qwindowsurface_mac.cpp
+ qwindowsurface_mac_p.h
+ qwindowsurface_p.h
+ qwindowsurface_qws.cpp
+ qwindowsurface_qws_p.h
+ qwindowsurface_raster.cpp
+ qwindowsurface_raster_p.h
+ qwindowsurface_s60.cpp
+ qwindowsurface_s60_p.h
+ qwindowsurface_x11.cpp
+ qwindowsurface_x11_p.h
+ qwmatrix.h
+2 QtGui.dynlist
+ s60framework/
+0 qs60mainapplication.cpp
+ qs60mainapplication.h
+ qs60mainapplication_p.h
+ qs60mainappui.cpp
+ qs60mainappui.h
+ qs60maindocument.cpp
+ qs60maindocument.h
+ s60framework.pri
+ s60main.rss
+2 statemachine/
+0 qbasickeyeventtransition.cpp
+ qbasickeyeventtransition_p.h
+ qbasicmouseeventtransition.cpp
+ qbasicmouseeventtransition_p.h
+ qguistatemachine.cpp
+ qkeyeventtransition.cpp
+ qkeyeventtransition.h
+ qmouseeventtransition.cpp
+ qmouseeventtransition.h
+ statemachine.pri
+2 styles/
+0 images/
+0 cdr-128.png
+ cdr-16.png
+ cdr-32.png
+ closedock-16.png
+ closedock-down-16.png
+ computer-16.png
+ computer-32.png
+ defaults60theme.blob
+ desktop-16.png
+ desktop-32.png
+ dirclosed-128.png
+ dirclosed-16.png
+ dirclosed-32.png
+ dirlink-128.png
+ dirlink-16.png
+ dirlink-32.png
+ diropen-128.png
+ diropen-16.png
+ diropen-32.png
+ dockdock-16.png
+ dockdock-down-16.png
+ down-128.png
+ down-16.png
+ down-32.png
+ dvd-128.png
+ dvd-16.png
+ dvd-32.png
+ file-128.png
+ file-16.png
+ file-32.png
+ filecontents-128.png
+ filecontents-16.png
+ filecontents-32.png
+ fileinfo-128.png
+ fileinfo-16.png
+ fileinfo-32.png
+ filelink-128.png
+ filelink-16.png
+ filelink-32.png
+ floppy-128.png
+ floppy-16.png
+ floppy-32.png
+ fontbitmap-16.png
+ fonttruetype-16.png
+ harddrive-128.png
+ harddrive-16.png
+ harddrive-32.png
+ left-128.png
+ left-16.png
+ left-32.png
+ media-pause-16.png
+ media-pause-32.png
+ media-play-16.png
+ media-play-32.png
+ media-seek-backward-16.png
+ media-seek-backward-32.png
+ media-seek-forward-16.png
+ media-seek-forward-32.png
+ media-skip-backward-16.png
+ media-skip-backward-32.png
+ media-skip-forward-16.png
+ media-skip-forward-32.png
+ media-stop-16.png
+ media-stop-32.png
+ media-volume-16.png
+ media-volume-muted-16.png
+ networkdrive-128.png
+ networkdrive-16.png
+ networkdrive-32.png
+ newdirectory-128.png
+ newdirectory-16.png
+ newdirectory-32.png
+ parentdir-128.png
+ parentdir-16.png
+ parentdir-32.png
+ refresh-24.png
+ refresh-32.png
+ right-128.png
+ right-16.png
+ right-32.png
+ standardbutton-apply-128.png
+ standardbutton-apply-16.png
+ standardbutton-apply-32.png
+ standardbutton-cancel-128.png
+ standardbutton-cancel-16.png
+ standardbutton-cancel-32.png
+ standardbutton-clear-128.png
+ standardbutton-clear-16.png
+ standardbutton-clear-32.png
+ standardbutton-close-128.png
+ standardbutton-close-16.png
+ standardbutton-close-32.png
+ standardbutton-closetab-16.png
+ standardbutton-closetab-down-16.png
+ standardbutton-closetab-hover-16.png
+ standardbutton-delete-128.png
+ standardbutton-delete-16.png
+ standardbutton-delete-32.png
+ standardbutton-help-128.png
+ standardbutton-help-16.png
+ standardbutton-help-32.png
+ standardbutton-no-128.png
+ standardbutton-no-16.png
+ standardbutton-no-32.png
+ standardbutton-ok-128.png
+ standardbutton-ok-16.png
+ standardbutton-ok-32.png
+ standardbutton-open-128.png
+ standardbutton-open-16.png
+ standardbutton-open-32.png
+ standardbutton-save-128.png
+ standardbutton-save-16.png
+ standardbutton-save-32.png
+ standardbutton-yes-128.png
+ standardbutton-yes-16.png
+ standardbutton-yes-32.png
+ stop-24.png
+ stop-32.png
+ trash-128.png
+ trash-16.png
+ trash-32.png
+ up-128.png
+ up-16.png
+ up-32.png
+ viewdetailed-128.png
+ viewdetailed-16.png
+ viewdetailed-32.png
+ viewlist-128.png
+ viewlist-16.png
+ viewlist-32.png
+2 qcdestyle.cpp
+ qcdestyle.h
+ qcleanlooksstyle.cpp
+ qcleanlooksstyle.h
+ qcleanlooksstyle_p.h
+ qcommonstyle.cpp
+ qcommonstyle.h
+ qcommonstyle_p.h
+ qcommonstylepixmaps_p.h
+ qgtkpainter.cpp
+ qgtkpainter_p.h
+ qgtkstyle.cpp
+ qgtkstyle.h
+ qgtkstyle_p.cpp
+ qgtkstyle_p.h
+ qmacstyle_mac.h
+ qmacstyle_mac.mm
+ qmacstylepixmaps_mac_p.h
+ qmacstyle.qdoc
+ qmotifstyle.cpp
+ qmotifstyle.h
+ qmotifstyle_p.h
+ qplastiquestyle.cpp
+ qplastiquestyle.h
+ qproxystyle.cpp
+ qproxystyle.h
+ qproxystyle_p.h
+ qs60style.cpp
+ qs60style.h
+ qs60style_p.h
+ qs60style_s60.cpp
+ qs60style_simulated.cpp
+ qstyle.cpp
+ qstylefactory.cpp
+ qstylefactory.h
+ qstyle.h
+ qstylehelper.cpp
+ qstylehelper_p.h
+ qstyleoption.cpp
+ qstyleoption.h
+ qstyle_p.h
+ qstyleplugin.cpp
+ qstyleplugin.h
+ qstyle.qrc
+ qstyle_s60_simulated.qrc
+ qstylesheetstyle.cpp
+ qstylesheetstyle_default.cpp
+ qstylesheetstyle_p.h
+ qstyle_wince.qrc
+ qwindowscestyle.cpp
+ qwindowscestyle.h
+ qwindowscestyle_p.h
+ qwindowsmobilestyle.cpp
+ qwindowsmobilestyle.h
+ qwindowsmobilestyle_p.h
+ qwindowsstyle.cpp
+ qwindowsstyle.h
+ qwindowsstyle_p.h
+ qwindowsvistastyle.cpp
+ qwindowsvistastyle.h
+ qwindowsvistastyle_p.h
+ qwindowsxpstyle.cpp
+ qwindowsxpstyle.h
+ qwindowsxpstyle_p.h
+ styles.pri
+2 symbian/
+0 images/
+0 blank.png
+ busy12.png
+ busy3.png
+ busy6.png
+ busy9.png
+ closehand.png
+ cross.png
+ forbidden.png
+ handpoint.png
+ ibeam.png
+ openhand.png
+ pointer.png
+ sizeall.png
+ sizebdiag.png
+ sizefdiag.png
+ sizehor.png
+ sizever.png
+ splith.png
+ splitv.png
+ uparrow.png
+ wait10.png
+ wait11.png
+ wait12.png
+ wait1.png
+ wait2.png
+ wait3.png
+ wait4.png
+ wait5.png
+ wait6.png
+ wait7.png
+ wait8.png
+ wait9.png
+ whatsthis.png
+2 qsymbianevent.cpp
+ qsymbianevent.h
+ symbianresources.qrc
+2 text/
+0 qabstractfontengine_p.h
+ qabstractfontengine_qws.cpp
+ qabstractfontengine_qws.h
+ qabstracttextdocumentlayout.cpp
+ qabstracttextdocumentlayout.h
+ qabstracttextdocumentlayout_p.h
+ qcssparser.cpp
+ qcssparser_p.h
+ qcssscanner.cpp
+ qfont.cpp
+ qfontdatabase.cpp
+ qfontdatabase.h
+ qfontdatabase_mac.cpp
+ qfontdatabase_qws.cpp
+ qfontdatabase_s60.cpp
+ qfontdatabase_win.cpp
+ qfontdatabase_x11.cpp
+ qfontengine.cpp
+ qfontengine_ft.cpp
+ qfontengine_ft_p.h
+ qfontengineglyphcache_p.h
+ qfontengine_mac.mm
+ qfontengine_p.h
+ qfontengine_qpf.cpp
+ qfontengine_qpf_p.h
+ qfontengine_qws.cpp
+ qfontengine_s60.cpp
+ qfontengine_s60_p.h
+ qfontengine_win.cpp
+ qfontengine_win_p.h
+ qfontengine_x11.cpp
+ qfontengine_x11_p.h
+ qfont.h
+ qfontinfo.h
+ qfont_mac.cpp
+ qfontmetrics.cpp
+ qfontmetrics.h
+ qfont_p.h
+ qfont_qws.cpp
+ qfont_s60.cpp
+ qfontsubset.cpp
+ qfontsubset_p.h
+ qfont_win.cpp
+ qfont_x11.cpp
+ qfragmentmap.cpp
+ qfragmentmap_p.h
+ qpfutil.cpp
+ qsyntaxhighlighter.cpp
+ qsyntaxhighlighter.h
+ qtextcontrol.cpp
+ qtextcontrol_p.h
+ qtextcontrol_p_p.h
+ qtextcursor.cpp
+ qtextcursor.h
+ qtextcursor_p.h
+ qtextdocument.cpp
+ qtextdocumentfragment.cpp
+ qtextdocumentfragment.h
+ qtextdocumentfragment_p.h
+ qtextdocument.h
+ qtextdocumentlayout.cpp
+ qtextdocumentlayout_p.h
+ qtextdocument_p.cpp
+ qtextdocument_p.h
+ qtextdocumentwriter.cpp
+ qtextdocumentwriter.h
+ qtextengine.cpp
+ qtextengine_mac.cpp
+ qtextengine_p.h
+ qtextformat.cpp
+ qtextformat.h
+ qtextformat_p.h
+ qtexthtmlparser.cpp
+ qtexthtmlparser_p.h
+ qtextimagehandler.cpp
+ qtextimagehandler_p.h
+ qtextlayout.cpp
+ qtextlayout.h
+ qtextlist.cpp
+ qtextlist.h
+ qtextobject.cpp
+ qtextobject.h
+ qtextobject_p.h
+ qtextodfwriter.cpp
+ qtextodfwriter_p.h
+ qtextoption.cpp
+ qtextoption.h
+ qtexttable.cpp
+ qtexttable.h
+ qtexttable_p.h
+ qzip.cpp
+ qzipreader_p.h
+ qzipwriter_p.h
+ text.pri
+2 util/
+0 qcompleter.cpp
+ qcompleter.h
+ qcompleter_p.h
+ qdesktopservices.cpp
+ qdesktopservices.h
+ qdesktopservices_mac.cpp
+ qdesktopservices_qws.cpp
+ qdesktopservices_s60.cpp
+ qdesktopservices_win.cpp
+ qdesktopservices_x11.cpp
+ qsystemtrayicon.cpp
+ qsystemtrayicon.h
+ qsystemtrayicon_mac.mm
+ qsystemtrayicon_p.h
+ qsystemtrayicon_qws.cpp
+ qsystemtrayicon_win.cpp
+ qsystemtrayicon_x11.cpp
+ qundogroup.cpp
+ qundogroup.h
+ qundostack.cpp
+ qundostack.h
+ qundostack_p.h
+ qundoview.cpp
+ qundoview.h
+ util.pri
+2 widgets/
+0 qabstractbutton.cpp
+ qabstractbutton.h
+ qabstractbutton_p.h
+ qabstractscrollarea.cpp
+ qabstractscrollarea.h
+ qabstractscrollarea_p.h
+ qabstractslider.cpp
+ qabstractslider.h
+ qabstractslider_p.h
+ qabstractspinbox.cpp
+ qabstractspinbox.h
+ qabstractspinbox_p.h
+ qbuttongroup.cpp
+ qbuttongroup.h
+ qcalendartextnavigator_p.h
+ qcalendarwidget.cpp
+ qcalendarwidget.h
+ qcheckbox.cpp
+ qcheckbox.h
+ qcocoamenu_mac.mm
+ qcocoamenu_mac_p.h
+ qcocoatoolbardelegate_mac.mm
+ qcocoatoolbardelegate_mac_p.h
+ qcombobox.cpp
+ qcombobox.h
+ qcombobox_p.h
+ qcommandlinkbutton.cpp
+ qcommandlinkbutton.h
+ qdatetimeedit.cpp
+ qdatetimeedit.h
+ qdatetimeedit_p.h
+ qdial.cpp
+ qdial.h
+ qdialogbuttonbox.cpp
+ qdialogbuttonbox.h
+ qdockarealayout.cpp
+ qdockarealayout_p.h
+ qdockwidget.cpp
+ qdockwidget.h
+ qdockwidget_p.h
+ qeffects.cpp
+ qeffects_p.h
+ qfocusframe.cpp
+ qfocusframe.h
+ qfontcombobox.cpp
+ qfontcombobox.h
+ qframe.cpp
+ qframe.h
+ qframe_p.h
+ qgroupbox.cpp
+ qgroupbox.h
+ qlabel.cpp
+ qlabel.h
+ qlabel_p.h
+ qlcdnumber.cpp
+ qlcdnumber.h
+ qlinecontrol.cpp
+ qlinecontrol_p.h
+ qlineedit.cpp
+ qlineedit.h
+ qlineedit_p.cpp
+ qlineedit_p.h
+ qmaccocoaviewcontainer_mac.h
+ qmaccocoaviewcontainer_mac.mm
+ qmacnativewidget_mac.h
+ qmacnativewidget_mac.mm
+ qmainwindow.cpp
+ qmainwindow.h
+ qmainwindowlayout.cpp
+ qmainwindowlayout_mac.mm
+ qmainwindowlayout_p.h
+ qmdiarea.cpp
+ qmdiarea.h
+ qmdiarea_p.h
+ qmdisubwindow.cpp
+ qmdisubwindow.h
+ qmdisubwindow_p.h
+ qmenubar.cpp
+ qmenubar.h
+ qmenubar_p.h
+ qmenu.cpp
+ qmenudata.cpp
+ qmenudata.h
+ qmenu.h
+ qmenu_mac.mm
+ qmenu_p.h
+ qmenu_symbian.cpp
+ qmenu_wince.cpp
+ qmenu_wince.rc
+ qmenu_wince_resource_p.h
+ qplaintextedit.cpp
+ qplaintextedit.h
+ qplaintextedit_p.h
+ qprintpreviewwidget.cpp
+ qprintpreviewwidget.h
+ qprogressbar.cpp
+ qprogressbar.h
+ qpushbutton.cpp
+ qpushbutton.h
+ qpushbutton_p.h
+ qradiobutton.cpp
+ qradiobutton.h
+ qrubberband.cpp
+ qrubberband.h
+ qscrollarea.cpp
+ qscrollarea.h
+ qscrollarea_p.h
+ qscrollbar.cpp
+ qscrollbar.h
+ qsizegrip.cpp
+ qsizegrip.h
+ qslider.cpp
+ qslider.h
+ qspinbox.cpp
+ qspinbox.h
+ qsplashscreen.cpp
+ qsplashscreen.h
+ qsplitter.cpp
+ qsplitter.h
+ qsplitter_p.h
+ qstackedwidget.cpp
+ qstackedwidget.h
+ qstatusbar.cpp
+ qstatusbar.h
+ qtabbar.cpp
+ qtabbar.h
+ qtabbar_p.h
+ qtabwidget.cpp
+ qtabwidget.h
+ qtextbrowser.cpp
+ qtextbrowser.h
+ qtextedit.cpp
+ qtextedit.h
+ qtextedit_p.h
+ qtoolbararealayout.cpp
+ qtoolbararealayout_p.h
+ qtoolbar.cpp
+ qtoolbarextension.cpp
+ qtoolbarextension_p.h
+ qtoolbar.h
+ qtoolbarlayout.cpp
+ qtoolbarlayout_p.h
+ qtoolbar_p.h
+ qtoolbarseparator.cpp
+ qtoolbarseparator_p.h
+ qtoolbox.cpp
+ qtoolbox.h
+ qtoolbutton.cpp
+ qtoolbutton.h
+ qvalidator.cpp
+ qvalidator.h
+ qwidgetanimator.cpp
+ qwidgetanimator_p.h
+ qwidgetresizehandler.cpp
+ qwidgetresizehandler_p.h
+ qworkspace.cpp
+ qworkspace.h
+ widgets.pri
+3 multimedia/
+0 audio/
+0 audio.pri
+ qaudio.cpp
+ qaudiodevicefactory.cpp
+ qaudiodevicefactory_p.h
+ qaudiodeviceinfo_alsa_p.cpp
+ qaudiodeviceinfo_alsa_p.h
+ qaudiodeviceinfo.cpp
+ qaudiodeviceinfo.h
+ qaudiodeviceinfo_mac_p.cpp
+ qaudiodeviceinfo_mac_p.h
+ qaudiodeviceinfo_win32_p.cpp
+ qaudiodeviceinfo_win32_p.h
+ qaudioengine.cpp
+ qaudioengine.h
+ qaudioengineplugin.cpp
+ qaudioengineplugin.h
+ qaudioformat.cpp
+ qaudioformat.h
+ qaudio.h
+ qaudioinput_alsa_p.cpp
+ qaudioinput_alsa_p.h
+ qaudioinput.cpp
+ qaudioinput.h
+ qaudioinput_mac_p.cpp
+ qaudioinput_mac_p.h
+ qaudioinput_win32_p.cpp
+ qaudioinput_win32_p.h
+ qaudio_mac.cpp
+ qaudio_mac_p.h
+ qaudiooutput_alsa_p.cpp
+ qaudiooutput_alsa_p.h
+ qaudiooutput.cpp
+ qaudiooutput.h
+ qaudiooutput_mac_p.cpp
+ qaudiooutput_mac_p.h
+ qaudiooutput_win32_p.cpp
+ qaudiooutput_win32_p.h
+2 multimedia.pro
+ video/
+0 qabstractvideobuffer.cpp
+ qabstractvideobuffer.h
+ qabstractvideobuffer_p.h
+ qabstractvideosurface.cpp
+ qabstractvideosurface.h
+ qabstractvideosurface_p.h
+ qimagevideobuffer.cpp
+ qimagevideobuffer_p.h
+ qmemoryvideobuffer.cpp
+ qmemoryvideobuffer_p.h
+ qvideoframe.cpp
+ qvideoframe.h
+ qvideosurfaceformat.cpp
+ qvideosurfaceformat.h
+ video.pri
+3 network/
+0 access/
+0 access.pri
+ qabstractnetworkcache.cpp
+ qabstractnetworkcache.h
+ qabstractnetworkcache_p.h
+ qftp.cpp
+ qftp.h
+ qhttp.cpp
+ qhttp.h
+ qhttpnetworkconnectionchannel.cpp
+ qhttpnetworkconnectionchannel_p.h
+ qhttpnetworkconnection.cpp
+ qhttpnetworkconnection_p.h
+ qhttpnetworkheader.cpp
+ qhttpnetworkheader_p.h
+ qhttpnetworkreply.cpp
+ qhttpnetworkreply_p.h
+ qhttpnetworkrequest.cpp
+ qhttpnetworkrequest_p.h
+ qnetworkaccessbackend.cpp
+ qnetworkaccessbackend_p.h
+ qnetworkaccesscachebackend.cpp
+ qnetworkaccesscachebackend_p.h
+ qnetworkaccesscache.cpp
+ qnetworkaccesscache_p.h
+ qnetworkaccessdatabackend.cpp
+ qnetworkaccessdatabackend_p.h
+ qnetworkaccessdebugpipebackend.cpp
+ qnetworkaccessdebugpipebackend_p.h
+ qnetworkaccessfilebackend.cpp
+ qnetworkaccessfilebackend_p.h
+ qnetworkaccessftpbackend.cpp
+ qnetworkaccessftpbackend_p.h
+ qnetworkaccesshttpbackend.cpp
+ qnetworkaccesshttpbackend_p.h
+ qnetworkaccessmanager.cpp
+ qnetworkaccessmanager.h
+ qnetworkaccessmanager_p.h
+ qnetworkcookie.cpp
+ qnetworkcookie.h
+ qnetworkcookiejar.cpp
+ qnetworkcookiejar.h
+ qnetworkcookiejar_p.h
+ qnetworkcookie_p.h
+ qnetworkdiskcache.cpp
+ qnetworkdiskcache.h
+ qnetworkdiskcache_p.h
+ qnetworkreply.cpp
+ qnetworkreply.h
+ qnetworkreplyimpl.cpp
+ qnetworkreplyimpl_p.h
+ qnetworkreply_p.h
+ qnetworkrequest.cpp
+ qnetworkrequest.h
+ qnetworkrequest_p.h
+2 kernel/
+0 kernel.pri
+ qauthenticator.cpp
+ qauthenticator.h
+ qauthenticator_p.h
+ qhostaddress.cpp
+ qhostaddress.h
+ qhostaddress_p.h
+ qhostinfo.cpp
+ qhostinfo.h
+ qhostinfo_p.h
+ qhostinfo_unix.cpp
+ qhostinfo_win.cpp
+ qnetworkinterface.cpp
+ qnetworkinterface.h
+ qnetworkinterface_p.h
+ qnetworkinterface_symbian.cpp
+ qnetworkinterface_unix.cpp
+ qnetworkinterface_win.cpp
+ qnetworkinterface_win_p.h
+ qnetworkproxy.cpp
+ qnetworkproxy_generic.cpp
+ qnetworkproxy.h
+ qnetworkproxy_mac.cpp
+ qnetworkproxy_p.h
+ qnetworkproxy_win.cpp
+ qurlinfo.cpp
+ qurlinfo.h
+2 network.pro
+ network.qrc
+ socket/
+0 qabstractsocket.cpp
+ qabstractsocketengine.cpp
+ qabstractsocketengine_p.h
+ qabstractsocket.h
+ qabstractsocket_p.h
+ qhttpsocketengine.cpp
+ qhttpsocketengine_p.h
+ qlocalserver.cpp
+ qlocalserver.h
+ qlocalserver_p.h
+ qlocalserver_tcp.cpp
+ qlocalserver_unix.cpp
+ qlocalserver_win.cpp
+ qlocalsocket.cpp
+ qlocalsocket.h
+ qlocalsocket_p.h
+ qlocalsocket_tcp.cpp
+ qlocalsocket_unix.cpp
+ qlocalsocket_win.cpp
+ qnativesocketengine.cpp
+ qnativesocketengine_p.h
+ qnativesocketengine_unix.cpp
+ qnativesocketengine_win.cpp
+ qnet_unix_p.h
+ qsocks5socketengine.cpp
+ qsocks5socketengine_p.h
+ qtcpserver.cpp
+ qtcpserver.h
+ qtcpsocket.cpp
+ qtcpsocket.h
+ qtcpsocket_p.h
+ qudpsocket.cpp
+ qudpsocket.h
+ socket.pri
+2 ssl/
+0 qsslcertificate.cpp
+ qsslcertificate.h
+ qsslcertificate_p.h
+ qsslcipher.cpp
+ qsslcipher.h
+ qsslcipher_p.h
+ qsslconfiguration.cpp
+ qsslconfiguration.h
+ qsslconfiguration_p.h
+ qssl.cpp
+ qsslerror.cpp
+ qsslerror.h
+ qssl.h
+ qsslkey.cpp
+ qsslkey.h
+ qsslkey_p.h
+ qsslsocket.cpp
+ qsslsocket.h
+ qsslsocket_openssl.cpp
+ qsslsocket_openssl_p.h
+ qsslsocket_openssl_symbols.cpp
+ qsslsocket_openssl_symbols_p.h
+ qsslsocket_p.h
+ qt-ca-bundle.crt
+ ssl.pri
+3 opengl/
+0 gl2paintengineex/
+0 qgl2pexvertexarray.cpp
+ qgl2pexvertexarray_p.h
+ qglcustomshaderstage.cpp
+ qglcustomshaderstage_p.h
+ qglengineshadermanager.cpp
+ qglengineshadermanager_p.h
+ qglengineshadersource_p.h
+ qglgradientcache.cpp
+ qglgradientcache_p.h
+ qpaintengineex_opengl2.cpp
+ qpaintengineex_opengl2_p.h
+ qtriangulatingstroker.cpp
+ qtriangulatingstroker_p.h
+2 opengl.pro
+ qgl_cl_p.h
+ qglcolormap.cpp
+ qglcolormap.h
+ qgl.cpp
+ qgl_egl.cpp
+ qgl_egl_p.h
+ qglextensions.cpp
+ qglextensions_p.h
+ qglframebufferobject.cpp
+ qglframebufferobject.h
+ qglframebufferobject_p.h
+ qgl.h
+ qgl_mac.mm
+ qglpaintdevice.cpp
+ qglpaintdevice_p.h
+ qgl_p.h
+ qglpixelbuffer.cpp
+ qglpixelbuffer_egl.cpp
+ qglpixelbuffer.h
+ qglpixelbuffer_mac.mm
+ qglpixelbuffer_p.h
+ qglpixelbuffer_win.cpp
+ qglpixelbuffer_x11.cpp
+ qglpixmapfilter.cpp
+ qglpixmapfilter_p.h
+ qgl_qws.cpp
+ qglscreen_qws.cpp
+ qglscreen_qws.h
+ qglshaderprogram.cpp
+ qglshaderprogram.h
+ qgl_wince.cpp
+ qgl_win.cpp
+ qglwindowsurface_qws.cpp
+ qglwindowsurface_qws_p.h
+ qgl_x11.cpp
+ qgl_x11egl.cpp
+ qgraphicsshadereffect.cpp
+ qgraphicsshadereffect_p.h
+ qgraphicssystem_gl.cpp
+ qgraphicssystem_gl_p.h
+ qpaintengine_opengl.cpp
+ qpaintengine_opengl_p.h
+ qpixmapdata_gl.cpp
+ qpixmapdata_gl_p.h
+ qpixmapdata_x11gl_egl.cpp
+ qpixmapdata_x11gl_p.h
+ qwindowsurface_gl.cpp
+ qwindowsurface_gl_p.h
+ qwindowsurface_x11gl.cpp
+ qwindowsurface_x11gl_p.h
+ util/
+0 brushes.conf
+ brush_painter.glsl
+ composition_mode_colorburn.glsl
+ composition_mode_colordodge.glsl
+ composition_mode_darken.glsl
+ composition_mode_difference.glsl
+ composition_mode_exclusion.glsl
+ composition_mode_hardlight.glsl
+ composition_mode_lighten.glsl
+ composition_mode_multiply.glsl
+ composition_mode_overlay.glsl
+ composition_modes.conf
+ composition_mode_screen.glsl
+ composition_mode_softlight.glsl
+ conical_brush.glsl
+ ellipse_aa.glsl
+ fast_painter.glsl
+ fragmentprograms_p.h
+ generator.cpp
+ generator.pro
+ glsl_to_include.sh
+ linear_brush.glsl
+ masks.conf
+ painter.glsl
+ painter_nomask.glsl
+ pattern_brush.glsl
+ radial_brush.glsl
+ README-GLSL
+ simple_porter_duff.glsl
+ solid_brush.glsl
+ texture_brush.glsl
+ trap_exact_aa.glsl
+3 openvg/
+0 openvg.pro
+ qpaintengine_vg.cpp
+ qpaintengine_vg_p.h
+ qpixmapdata_vg.cpp
+ qpixmapdata_vg_p.h
+ qpixmapfilter_vg.cpp
+ qpixmapfilter_vg_p.h
+ qvgcompositionhelper_p.h
+ qvg.h
+ qvg_p.h
+ qwindowsurface_vg.cpp
+ qwindowsurface_vgegl.cpp
+ qwindowsurface_vgegl_p.h
+ qwindowsurface_vg_p.h
+2 phonon/
+0 phonon.pro
+2 plugins/
+0 accessible/
+0 accessible.pro
+ compat/
+0 compat.pro
+ main.cpp
+ q3complexwidgets.cpp
+ q3complexwidgets.h
+ q3simplewidgets.cpp
+ q3simplewidgets.h
+ qaccessiblecompat.cpp
+ qaccessiblecompat.h
+2 qaccessiblebase.pri
+ widgets/
+0 complexwidgets.cpp
+ complexwidgets.h
+ main.cpp
+ qaccessiblemenu.cpp
+ qaccessiblemenu.h
+ qaccessiblewidgets.cpp
+ qaccessiblewidgets.h
+ rangecontrols.cpp
+ rangecontrols.h
+ simplewidgets.cpp
+ simplewidgets.h
+ widgets.pro
+3 audio/
+0 audio.pro
+2 codecs/
+0 cn/
+0 cn.pro
+ main.cpp
+ qgb18030codec.cpp
+ qgb18030codec.h
+2 codecs.pro
+ jp/
+0 jp.pro
+ main.cpp
+ qeucjpcodec.cpp
+ qeucjpcodec.h
+ qfontjpcodec.cpp
+ qfontjpcodec.h
+ qjiscodec.cpp
+ qjiscodec.h
+ qjpunicode.cpp
+ qjpunicode.h
+ qsjiscodec.cpp
+ qsjiscodec.h
+2 kr/
+0 cp949codetbl.h
+ kr.pro
+ main.cpp
+ qeuckrcodec.cpp
+ qeuckrcodec.h
+2 tw/
+0 main.cpp
+ qbig5codec.cpp
+ qbig5codec.h
+ tw.pro
+3 decorations/
+0 decorations.pro
+ default/
+0 default.pro
+ main.cpp
+2 styled/
+0 main.cpp
+ styled.pro
+2 windows/
+0 main.cpp
+ windows.pro
+3 gfxdrivers/
+0 ahi/
+0 ahi.pro
+ qscreenahiplugin.cpp
+ qscreenahi_qws.cpp
+ qscreenahi_qws.h
+2 directfb/
+0 directfb.pro
+ qdirectfbkeyboard.cpp
+ qdirectfbkeyboard.h
+ qdirectfbmouse.cpp
+ qdirectfbmouse.h
+ qdirectfbpaintdevice.cpp
+ qdirectfbpaintdevice.h
+ qdirectfbpaintengine.cpp
+ qdirectfbpaintengine.h
+ qdirectfbpixmap.cpp
+ qdirectfbpixmap.h
+ qdirectfbscreen.cpp
+ qdirectfbscreen.h
+ qdirectfbscreenplugin.cpp
+ qdirectfbwindowsurface.cpp
+ qdirectfbwindowsurface.h
+2 gfxdrivers.pro
+ linuxfb/
+0 linuxfb.pro
+ main.cpp
+2 powervr/
+0 powervr.pri
+ powervr.pro
+ pvreglscreen/
+0 pvreglscreen.cpp
+ pvreglscreen.h
+ pvreglscreenplugin.cpp
+ pvreglscreen.pro
+ pvreglwindowsurface.cpp
+ pvreglwindowsurface.h
+2 QWSWSEGL/
+0 pvrqwsdrawable.c
+ pvrqwsdrawable.h
+ pvrqwsdrawable_p.h
+ pvrqwswsegl.c
+ QWSWSEGL.pro
+2 README
+2 qvfb/
+0 main.cpp
+ qvfb.pro
+2 transformed/
+0 main.cpp
+ transformed.pro
+2 vnc/
+0 main.cpp
+ qscreenvnc_p.h
+ qscreenvnc_qws.cpp
+ qscreenvnc_qws.h
+ vnc.pro
+3 graphicssystems/
+0 graphicssystems.pro
+ opengl/
+0 main.cpp
+ opengl.pro
+2 openvg/
+0 main.cpp
+ openvg.pro
+ qgraphicssystem_vg.cpp
+ qgraphicssystem_vg_p.h
+2 shivavg/
+0 main.cpp
+ README
+ shivavggraphicssystem.cpp
+ shivavggraphicssystem.h
+ shivavg.pro
+ shivavgwindowsurface.cpp
+ shivavgwindowsurface.h
+2 trace/
+0 main.cpp
+ qgraphicssystem_trace.cpp
+ qgraphicssystem_trace_p.h
+ trace.pro
+3 iconengines/
+0 iconengines.pro
+ svgiconengine/
+0 main.cpp
+ qsvgiconengine.cpp
+ qsvgiconengine.h
+ svgiconengine.pro
+3 imageformats/
+0 gif/
+0 gif.pro
+ main.cpp
+ qgifhandler.cpp
+ qgifhandler.h
+2 ico/
+0 ico.pro
+ main.cpp
+ qicohandler.cpp
+ qicohandler.h
+2 imageformats.pro
+ jpeg/
+0 jpeg.pro
+ main.cpp
+ qjpeghandler.cpp
+ qjpeghandler.h
+2 mng/
+0 main.cpp
+ mng.pro
+ qmnghandler.cpp
+ qmnghandler.h
+2 svg/
+0 main.cpp
+ qsvgiohandler.cpp
+ qsvgiohandler.h
+ svg.pro
+2 tiff/
+0 main.cpp
+ qtiffhandler.cpp
+ qtiffhandler.h
+ tiff.pro
+3 inputmethods/
+0 imsw-multi/
+0 imsw-multi.pro
+ qmultiinputcontext.cpp
+ qmultiinputcontext.h
+ qmultiinputcontextplugin.cpp
+ qmultiinputcontextplugin.h
+2 inputmethods.pro
+2 kbddrivers/
+0 kbddrivers.pro
+ linuxinput/
+0 linuxinput.pro
+ main.cpp
+3 mousedrivers/
+0 linuxtp/
+0 linuxtp.pro
+ main.cpp
+2 mousedrivers.pro
+ pc/
+0 main.cpp
+ pc.pro
+2 tslib/
+0 main.cpp
+ tslib.pro
+3 phonon/
+0 ds9/
+0 ds9.pro
+2 gstreamer/
+0 gstreamer.pro
+2 mmf/
+0 mmf.pro
+2 phonon.pro
+ qt7/
+0 qt7.pro
+2 waveout/
+0 waveout.pro
+3 plugins.pro
+ qpluginbase.pri
+ s60/
+0 3_1/
+0 3_1.pro
+2 3_2/
+0 3_2.pro
+2 5_0/
+0 5_0.pro
+2 bwins/
+0 qts60pluginu.def
+2 eabi/
+0 qts60pluginu.def
+2 s60pluginbase.pri
+ s60.pro
+ src/
+0 qcoreapplication_3_1.cpp
+ qcoreapplication_3_2.cpp
+ qdesktopservices_3_1.cpp
+ qdesktopservices_3_2.cpp
+ qlocale_3_1.cpp
+ qlocale_3_2.cpp
+3 script/
+0 qtdbus/
+0 main.cpp
+ main.h
+ qtdbus.pro
+2 script.pro
+2 sqldrivers/
+0 db2/
+0 db2.pro
+ main.cpp
+ README
+2 ibase/
+0 ibase.pro
+ main.cpp
+2 mysql/
+0 main.cpp
+ mysql.pro
+ README
+2 oci/
+0 main.cpp
+ oci.pro
+ README
+2 odbc/
+0 main.cpp
+ odbc.pro
+ README
+2 psql/
+0 main.cpp
+ psql.pro
+ README
+2 qsqldriverbase.pri
+ README
+ sqldrivers.pro
+ sqlite/
+ sqlite2/
+0 README
+ smain.cpp
+ sqlite2.pro
+2 sqlite/README
+ sqlite/smain.cpp
+ sqlite/sqlite.pro
+ sqlite_symbian/
+0 SQLite3_v9.2.zip
+ sqlite_symbian.pro
+2 tds/
+0 main.cpp
+ README
+ tds.pro
+4 qbase.pri
+ qt3support/
+0 canvas/
+0 canvas.pri
+ q3canvas.cpp
+ q3canvas.h
+2 dialogs/
+0 dialogs.pri
+ q3filedialog.cpp
+ q3filedialog.h
+ q3filedialog_mac.cpp
+ q3filedialog_win.cpp
+ q3progressdialog.cpp
+ q3progressdialog.h
+ q3tabdialog.cpp
+ q3tabdialog.h
+ q3wizard.cpp
+ q3wizard.h
+2 itemviews/
+0 itemviews.pri
+ q3iconview.cpp
+ q3iconview.h
+ q3listbox.cpp
+ q3listbox.h
+ q3listview.cpp
+ q3listview.h
+ q3table.cpp
+ q3table.h
+2 network/
+0 network.pri
+ q3dns.cpp
+ q3dns.h
+ q3ftp.cpp
+ q3ftp.h
+ q3http.cpp
+ q3http.h
+ q3localfs.cpp
+ q3localfs.h
+ q3network.cpp
+ q3network.h
+ q3networkprotocol.cpp
+ q3networkprotocol.h
+ q3serversocket.cpp
+ q3serversocket.h
+ q3socket.cpp
+ q3socketdevice.cpp
+ q3socketdevice.h
+ q3socketdevice_unix.cpp
+ q3socketdevice_win.cpp
+ q3socket.h
+ q3url.cpp
+ q3url.h
+ q3urloperator.cpp
+ q3urloperator.h
+2 other/
+0 other.pri
+ q3accel.cpp
+ q3accel.h
+ q3boxlayout.cpp
+ q3boxlayout.h
+ q3dragobject.cpp
+ q3dragobject.h
+ q3dropsite.cpp
+ q3dropsite.h
+ q3gridlayout.h
+ q3membuf.cpp
+ q3membuf_p.h
+ q3mimefactory.cpp
+ q3mimefactory.h
+ q3polygonscanner.cpp
+ q3polygonscanner.h
+ q3process.cpp
+ q3process.h
+ q3process_unix.cpp
+ q3process_win.cpp
+ qiconset.h
+ qt_compat_pch.h
+2 painting/
+0 painting.pri
+ q3paintdevicemetrics.cpp
+ q3paintdevicemetrics.h
+ q3paintengine_svg.cpp
+ q3paintengine_svg_p.h
+ q3painter.cpp
+ q3painter.h
+ q3picture.cpp
+ q3picture.h
+ q3pointarray.cpp
+ q3pointarray.h
+2 qt3support.pro
+ sql/
+0 q3databrowser.cpp
+ q3databrowser.h
+ q3datatable.cpp
+ q3datatable.h
+ q3dataview.cpp
+ q3dataview.h
+ q3editorfactory.cpp
+ q3editorfactory.h
+ q3sqlcursor.cpp
+ q3sqlcursor.h
+ q3sqleditorfactory.cpp
+ q3sqleditorfactory.h
+ q3sqlfieldinfo.h
+ q3sqlfieldinfo.qdoc
+ q3sqlform.cpp
+ q3sqlform.h
+ q3sqlmanager_p.cpp
+ q3sqlmanager_p.h
+ q3sqlpropertymap.cpp
+ q3sqlpropertymap.h
+ q3sqlrecordinfo.h
+ q3sqlrecordinfo.qdoc
+ q3sqlselectcursor.cpp
+ q3sqlselectcursor.h
+ sql.pri
+2 text/
+0 q3multilineedit.cpp
+ q3multilineedit.h
+ q3richtext.cpp
+ q3richtext_p.cpp
+ q3richtext_p.h
+ q3simplerichtext.cpp
+ q3simplerichtext.h
+ q3stylesheet.cpp
+ q3stylesheet.h
+ q3syntaxhighlighter.cpp
+ q3syntaxhighlighter.h
+ q3syntaxhighlighter_p.h
+ q3textbrowser.cpp
+ q3textbrowser.h
+ q3textedit.cpp
+ q3textedit.h
+ q3textstream.cpp
+ q3textstream.h
+ q3textview.cpp
+ q3textview.h
+ text.pri
+2 tools/
+0 q3asciicache.h
+ q3asciicache.qdoc
+ q3asciidict.h
+ q3asciidict.qdoc
+ q3cache.h
+ q3cache.qdoc
+ q3cleanuphandler.h
+ q3cstring.cpp
+ q3cstring.h
+ q3deepcopy.cpp
+ q3deepcopy.h
+ q3dict.h
+ q3dict.qdoc
+ q3garray.cpp
+ q3garray.h
+ q3gcache.cpp
+ q3gcache.h
+ q3gdict.cpp
+ q3gdict.h
+ q3glist.cpp
+ q3glist.h
+ q3gvector.cpp
+ q3gvector.h
+ q3intcache.h
+ q3intcache.qdoc
+ q3intdict.h
+ q3intdict.qdoc
+ q3memarray.h
+ q3memarray.qdoc
+ q3objectdict.h
+ q3ptrcollection.cpp
+ q3ptrcollection.h
+ q3ptrdict.h
+ q3ptrdict.qdoc
+ q3ptrlist.h
+ q3ptrlist.qdoc
+ q3ptrqueue.h
+ q3ptrqueue.qdoc
+ q3ptrstack.h
+ q3ptrstack.qdoc
+ q3ptrvector.h
+ q3ptrvector.qdoc
+ q3semaphore.cpp
+ q3semaphore.h
+ q3shared.cpp
+ q3shared.h
+ q3signal.cpp
+ q3signal.h
+ q3sortedlist.h
+ q3strlist.h
+ q3strvec.h
+ q3tl.h
+ q3valuelist.h
+ q3valuelist.qdoc
+ q3valuestack.h
+ q3valuestack.qdoc
+ q3valuevector.h
+ q3valuevector.qdoc
+ tools.pri
+2 widgets/
+0 q3action.cpp
+ q3action.h
+ q3button.cpp
+ q3buttongroup.cpp
+ q3buttongroup.h
+ q3button.h
+ q3combobox.cpp
+ q3combobox.h
+ q3datetimeedit.cpp
+ q3datetimeedit.h
+ q3dockarea.cpp
+ q3dockarea.h
+ q3dockwindow.cpp
+ q3dockwindow.h
+ q3frame.cpp
+ q3frame.h
+ q3grid.cpp
+ q3grid.h
+ q3gridview.cpp
+ q3gridview.h
+ q3groupbox.cpp
+ q3groupbox.h
+ q3hbox.cpp
+ q3hbox.h
+ q3header.cpp
+ q3header.h
+ q3hgroupbox.cpp
+ q3hgroupbox.h
+ q3mainwindow.cpp
+ q3mainwindow.h
+ q3mainwindow_p.h
+ q3popupmenu.cpp
+ q3popupmenu.h
+ q3progressbar.cpp
+ q3progressbar.h
+ q3rangecontrol.cpp
+ q3rangecontrol.h
+ q3scrollview.cpp
+ q3scrollview.h
+ q3spinwidget.cpp
+ q3titlebar.cpp
+ q3titlebar_p.h
+ q3toolbar.cpp
+ q3toolbar.h
+ q3vbox.cpp
+ q3vbox.h
+ q3vgroupbox.cpp
+ q3vgroupbox.h
+ q3whatsthis.cpp
+ q3whatsthis.h
+ q3widgetstack.cpp
+ q3widgetstack.h
+ widgets.pri
+3 qt_install.pri
+ qt_targets.pri
+ s60installs/
+0 bwins/
+0 phononu.def
+ QtCoreu.def
+ QtGuiu.def
+ QtMultimediau.def
+ QtNetworku.def
+ QtScriptu.def
+ QtSqlu.def
+ QtSvgu.def
+ QtTestu.def
+ QtWebKitu.def
+ QtXmlPatternsu.def
+ QtXmlu.def
+2 eabi/
+0 phononu.def
+ QtCoreu.def
+ QtGuiu.def
+ QtMultimediau.def
+ QtNetworku.def
+ QtOpenVGu.def
+ QtScriptu.def
+ QtSqlu.def
+ QtSvgu.def
+ QtTestu.def
+ QtWebKitu.def
+ QtXmlPatternsu.def
+ QtXmlu.def
+2 .gitignore
+ qtdemoapps.iby
+ qt.iby
+ qt.svg
+ s60installs.pro
+ selfsigned.cer
+ selfsigned.key
+2 s60main/
+0 qts60main.cpp
+ qts60main_mcrt0.cpp
+ s60main.pro
+2 script/
+0 api/
+0 api.pri
+ qscriptable.cpp
+ qscriptable.h
+ qscriptable_p.h
+ qscriptclass.cpp
+ qscriptclass.h
+ qscriptclasspropertyiterator.cpp
+ qscriptclasspropertyiterator.h
+ qscriptcontext.cpp
+ qscriptcontext.h
+ qscriptcontextinfo.cpp
+ qscriptcontextinfo.h
+ qscriptcontext_p.h
+ qscriptengineagent.cpp
+ qscriptengineagent.h
+ qscriptengineagent_p.h
+ qscriptengine.cpp
+ qscriptengine.h
+ qscriptengine_p.h
+ qscriptextensioninterface.h
+ qscriptextensionplugin.cpp
+ qscriptextensionplugin.h
+ qscriptprogram.cpp
+ qscriptprogram.h
+ qscriptprogram_p.h
+ qscriptstring.cpp
+ qscriptstring.h
+ qscriptstring_p.h
+ qscriptvalue.cpp
+ qscriptvalue.h
+ qscriptvalueiterator.cpp
+ qscriptvalueiterator.h
+ qscriptvalue_p.h
+2 bridge/
+0 bridge.pri
+ qscriptactivationobject.cpp
+ qscriptactivationobject_p.h
+ qscriptclassobject.cpp
+ qscriptclassobject_p.h
+ qscriptdeclarativeclass.cpp
+ qscriptdeclarativeclass_p.h
+ qscriptdeclarativeobject.cpp
+ qscriptdeclarativeobject_p.h
+ qscriptfunction.cpp
+ qscriptfunction_p.h
+ qscriptglobalobject.cpp
+ qscriptglobalobject_p.h
+ qscriptobject.cpp
+ qscriptobject_p.h
+ qscriptqobject.cpp
+ qscriptqobject_p.h
+ qscriptvariant.cpp
+ qscriptvariant_p.h
+2 parser/
+0 parser.pri
+ qscriptast.cpp
+ qscriptastfwd_p.h
+ qscriptast_p.h
+ qscriptastvisitor.cpp
+ qscriptastvisitor_p.h
+ qscript.g
+ qscriptgrammar.cpp
+ qscriptgrammar_p.h
+ qscriptlexer.cpp
+ qscriptlexer_p.h
+ qscriptparser.cpp
+ qscriptparser_p.h
+ qscriptsyntaxchecker.cpp
+ qscriptsyntaxchecker_p.h
+2 script.pri
+ script.pro
+2 scripttools/
+0 debugging/
+0 debugging.pri
+ images/
+0 breakpoint.png
+ breakpoint.svg
+ d_breakpoint.png
+ d_breakpoint.svg
+ delete.png
+ d_interrupt.png
+ d_play.png
+ find.png
+ interrupt.png
+ location.png
+ location.svg
+ mac/
+0 closetab.png
+ next.png
+ plus.png
+ previous.png
+2 new.png
+ play.png
+ reload.png
+ return.png
+ runtocursor.png
+ runtonewscript.png
+ stepinto.png
+ stepout.png
+ stepover.png
+ win/
+0 closetab.png
+ next.png
+ plus.png
+ previous.png
+2 wrap.png
+2 qscriptbreakpointdata.cpp
+ qscriptbreakpointdata_p.h
+ qscriptbreakpointsmodel.cpp
+ qscriptbreakpointsmodel_p.h
+ qscriptbreakpointswidget.cpp
+ qscriptbreakpointswidgetinterface.cpp
+ qscriptbreakpointswidgetinterface_p.h
+ qscriptbreakpointswidgetinterface_p_p.h
+ qscriptbreakpointswidget_p.h
+ qscriptcompletionproviderinterface_p.h
+ qscriptcompletiontask.cpp
+ qscriptcompletiontaskinterface.cpp
+ qscriptcompletiontaskinterface_p.h
+ qscriptcompletiontaskinterface_p_p.h
+ qscriptcompletiontask_p.h
+ qscriptdebuggeragent.cpp
+ qscriptdebuggeragent_p.h
+ qscriptdebuggeragent_p_p.h
+ qscriptdebuggerbackend.cpp
+ qscriptdebuggerbackend_p.h
+ qscriptdebuggerbackend_p_p.h
+ qscriptdebuggercodefinderwidget.cpp
+ qscriptdebuggercodefinderwidgetinterface.cpp
+ qscriptdebuggercodefinderwidgetinterface_p.h
+ qscriptdebuggercodefinderwidgetinterface_p_p.h
+ qscriptdebuggercodefinderwidget_p.h
+ qscriptdebuggercodeview.cpp
+ qscriptdebuggercodeviewinterface.cpp
+ qscriptdebuggercodeviewinterface_p.h
+ qscriptdebuggercodeviewinterface_p_p.h
+ qscriptdebuggercodeview_p.h
+ qscriptdebuggercodewidget.cpp
+ qscriptdebuggercodewidgetinterface.cpp
+ qscriptdebuggercodewidgetinterface_p.h
+ qscriptdebuggercodewidgetinterface_p_p.h
+ qscriptdebuggercodewidget_p.h
+ qscriptdebuggercommand.cpp
+ qscriptdebuggercommandexecutor.cpp
+ qscriptdebuggercommandexecutor_p.h
+ qscriptdebuggercommand_p.h
+ qscriptdebuggercommandschedulerfrontend.cpp
+ qscriptdebuggercommandschedulerfrontend_p.h
+ qscriptdebuggercommandschedulerinterface_p.h
+ qscriptdebuggercommandschedulerjob.cpp
+ qscriptdebuggercommandschedulerjob_p.h
+ qscriptdebuggercommandschedulerjob_p_p.h
+ qscriptdebuggerconsolecommand.cpp
+ qscriptdebuggerconsolecommandgroupdata.cpp
+ qscriptdebuggerconsolecommandgroupdata_p.h
+ qscriptdebuggerconsolecommandjob.cpp
+ qscriptdebuggerconsolecommandjob_p.h
+ qscriptdebuggerconsolecommandjob_p_p.h
+ qscriptdebuggerconsolecommandmanager.cpp
+ qscriptdebuggerconsolecommandmanager_p.h
+ qscriptdebuggerconsolecommand_p.h
+ qscriptdebuggerconsolecommand_p_p.h
+ qscriptdebuggerconsole.cpp
+ qscriptdebuggerconsoleglobalobject.cpp
+ qscriptdebuggerconsoleglobalobject_p.h
+ qscriptdebuggerconsolehistorianinterface_p.h
+ qscriptdebuggerconsole_p.h
+ qscriptdebuggerconsolewidget.cpp
+ qscriptdebuggerconsolewidgetinterface.cpp
+ qscriptdebuggerconsolewidgetinterface_p.h
+ qscriptdebuggerconsolewidgetinterface_p_p.h
+ qscriptdebuggerconsolewidget_p.h
+ qscriptdebugger.cpp
+ qscriptdebuggerevent.cpp
+ qscriptdebuggereventhandlerinterface_p.h
+ qscriptdebuggerevent_p.h
+ qscriptdebuggerfrontend.cpp
+ qscriptdebuggerfrontend_p.h
+ qscriptdebuggerfrontend_p_p.h
+ qscriptdebuggerjob.cpp
+ qscriptdebuggerjob_p.h
+ qscriptdebuggerjob_p_p.h
+ qscriptdebuggerjobschedulerinterface_p.h
+ qscriptdebuggerlocalsmodel.cpp
+ qscriptdebuggerlocalsmodel_p.h
+ qscriptdebuggerlocalswidget.cpp
+ qscriptdebuggerlocalswidgetinterface.cpp
+ qscriptdebuggerlocalswidgetinterface_p.h
+ qscriptdebuggerlocalswidgetinterface_p_p.h
+ qscriptdebuggerlocalswidget_p.h
+ qscriptdebuggerobjectsnapshotdelta_p.h
+ qscriptdebugger_p.h
+ qscriptdebuggerresponse.cpp
+ qscriptdebuggerresponsehandlerinterface_p.h
+ qscriptdebuggerresponse_p.h
+ qscriptdebuggerscriptedconsolecommand.cpp
+ qscriptdebuggerscriptedconsolecommand_p.h
+ qscriptdebuggerscriptsmodel.cpp
+ qscriptdebuggerscriptsmodel_p.h
+ qscriptdebuggerscriptswidget.cpp
+ qscriptdebuggerscriptswidgetinterface.cpp
+ qscriptdebuggerscriptswidgetinterface_p.h
+ qscriptdebuggerscriptswidgetinterface_p_p.h
+ qscriptdebuggerscriptswidget_p.h
+ qscriptdebuggerstackmodel.cpp
+ qscriptdebuggerstackmodel_p.h
+ qscriptdebuggerstackwidget.cpp
+ qscriptdebuggerstackwidgetinterface.cpp
+ qscriptdebuggerstackwidgetinterface_p.h
+ qscriptdebuggerstackwidgetinterface_p_p.h
+ qscriptdebuggerstackwidget_p.h
+ qscriptdebuggerstandardwidgetfactory.cpp
+ qscriptdebuggerstandardwidgetfactory_p.h
+ qscriptdebuggervalue.cpp
+ qscriptdebuggervalue_p.h
+ qscriptdebuggervalueproperty.cpp
+ qscriptdebuggervalueproperty_p.h
+ qscriptdebuggerwidgetfactoryinterface_p.h
+ qscriptdebugoutputwidget.cpp
+ qscriptdebugoutputwidgetinterface.cpp
+ qscriptdebugoutputwidgetinterface_p.h
+ qscriptdebugoutputwidgetinterface_p_p.h
+ qscriptdebugoutputwidget_p.h
+ qscriptedit.cpp
+ qscriptedit_p.h
+ qscriptenginedebugger.cpp
+ qscriptenginedebuggerfrontend.cpp
+ qscriptenginedebuggerfrontend_p.h
+ qscriptenginedebugger.h
+ qscripterrorlogwidget.cpp
+ qscripterrorlogwidgetinterface.cpp
+ qscripterrorlogwidgetinterface_p.h
+ qscripterrorlogwidgetinterface_p_p.h
+ qscripterrorlogwidget_p.h
+ qscriptmessagehandlerinterface_p.h
+ qscriptobjectsnapshot.cpp
+ qscriptobjectsnapshot_p.h
+ qscriptscriptdata.cpp
+ qscriptscriptdata_p.h
+ qscriptstdmessagehandler.cpp
+ qscriptstdmessagehandler_p.h
+ qscriptsyntaxhighlighter.cpp
+ qscriptsyntaxhighlighter_p.h
+ qscripttooltipproviderinterface_p.h
+ qscriptvalueproperty.cpp
+ qscriptvalueproperty_p.h
+ qscriptxmlparser.cpp
+ qscriptxmlparser_p.h
+ scripts/
+0 commands/
+0 advance.qs
+ backtrace.qs
+ break.qs
+ clear.qs
+ complete.qs
+ condition.qs
+ continue.qs
+ delete.qs
+ disable.qs
+ down.qs
+ enable.qs
+ eval.qs
+ finish.qs
+ frame.qs
+ help.qs
+ ignore.qs
+ info.qs
+ interrupt.qs
+ list.qs
+ next.qs
+ print.qs
+ return.qs
+ step.qs
+ tbreak.qs
+ up.qs
+3 scripttools_debugging.qrc
+2 scripttools.pro
+2 script/utils/
+0 qscriptdate.cpp
+ qscriptdate_p.h
+ utils.pri
+2 sql/
+0 drivers/
+0 db2/
+0 qsql_db2.cpp
+ qsql_db2.h
+2 drivers.pri
+ ibase/
+0 qsql_ibase.cpp
+ qsql_ibase.h
+2 mysql/
+0 qsql_mysql.cpp
+ qsql_mysql.h
+2 oci/
+0 qsql_oci.cpp
+ qsql_oci.h
+2 odbc/
+0 qsql_odbc.cpp
+ qsql_odbc.h
+2 psql/
+0 qsql_psql.cpp
+ qsql_psql.h
+2 sqlite/
+ sqlite2/
+0 qsql_sqlite2.cpp
+ qsql_sqlite2.h
+2 sqlite/qsql_sqlite.cpp
+ sqlite/qsql_sqlite.h
+ tds/
+0 qsql_tds.cpp
+ qsql_tds.h
+3 kernel/
+0 kernel.pri
+ qsqlcachedresult.cpp
+ qsqlcachedresult_p.h
+ qsqldatabase.cpp
+ qsqldatabase.h
+ qsqldriver.cpp
+ qsqldriver.h
+ qsqldriverplugin.cpp
+ qsqldriverplugin.h
+ qsqlerror.cpp
+ qsqlerror.h
+ qsqlfield.cpp
+ qsqlfield.h
+ qsql.h
+ qsqlindex.cpp
+ qsqlindex.h
+ qsqlnulldriver_p.h
+ qsql.qdoc
+ qsqlquery.cpp
+ qsqlquery.h
+ qsqlrecord.cpp
+ qsqlrecord.h
+ qsqlresult.cpp
+ qsqlresult.h
+2 models/
+0 models.pri
+ qsqlquerymodel.cpp
+ qsqlquerymodel.h
+ qsqlquerymodel_p.h
+ qsqlrelationaldelegate.cpp
+ qsqlrelationaldelegate.h
+ qsqlrelationaltablemodel.cpp
+ qsqlrelationaltablemodel.h
+ qsqltablemodel.cpp
+ qsqltablemodel.h
+ qsqltablemodel_p.h
+2 README.module
+ sql.pro
+2 src.pro
+ svg/
+0 qgraphicssvgitem.cpp
+ qgraphicssvgitem.h
+ qsvgfont.cpp
+ qsvgfont_p.h
+ qsvggenerator.cpp
+ qsvggenerator.h
+ qsvggraphics.cpp
+ qsvggraphics_p.h
+ qsvghandler.cpp
+ qsvghandler_p.h
+ qsvgnode.cpp
+ qsvgnode_p.h
+ qsvgrenderer.cpp
+ qsvgrenderer.h
+ qsvgstructure.cpp
+ qsvgstructure_p.h
+ qsvgstyle.cpp
+ qsvgstyle_p.h
+ qsvgtinydocument.cpp
+ qsvgtinydocument_p.h
+ qsvgwidget.cpp
+ qsvgwidget.h
+ svg.pro
+2 testlib/
+0 3rdparty/
+0 callgrind_p.h
+ cycle_p.h
+ valgrind_p.h
+2 qabstracttestlogger.cpp
+ qabstracttestlogger_p.h
+ qasciikey.cpp
+ qbenchmark.cpp
+ qbenchmarkevent.cpp
+ qbenchmarkevent_p.h
+ qbenchmark.h
+ qbenchmarkmeasurement.cpp
+ qbenchmarkmeasurement_p.h
+ qbenchmark_p.h
+ qbenchmarkvalgrind.cpp
+ qbenchmarkvalgrind_p.h
+ qplaintestlogger.cpp
+ qplaintestlogger_p.h
+ qsignaldumper.cpp
+ qsignaldumper_p.h
+ qsignalspy.h
+ qsignalspy.qdoc
+ qtestaccessible.h
+ qtestassert.h
+ qtestbasicstreamer.cpp
+ qtestbasicstreamer.h
+ qtestcase.cpp
+ qtestcase.h
+ qtestcoreelement.h
+ qtestcorelist.h
+ qtestdata.cpp
+ qtestdata.h
+ qtestelementattribute.cpp
+ qtestelementattribute.h
+ qtestelement.cpp
+ qtestelement.h
+ qtestevent.h
+ qtesteventloop.h
+ qtestevent.qdoc
+ qtestfilelogger.cpp
+ qtestfilelogger.h
+ qtest_global.h
+ qtest_gui.h
+ qtest.h
+ qtestkeyboard.h
+ qtestlightxmlstreamer.cpp
+ qtestlightxmlstreamer.h
+ qtestlog.cpp
+ qtestlogger.cpp
+ qtestlogger_p.h
+ qtestlog_p.h
+ qtestmouse.h
+ qtestresult.cpp
+ qtestresult_p.h
+ qtestspontaneevent.h
+ qtestsystem.h
+ qtesttable.cpp
+ qtesttable_p.h
+ qtesttouch.h
+ qtestxmlstreamer.cpp
+ qtestxmlstreamer.h
+ qtestxunitstreamer.cpp
+ qtestxunitstreamer.h
+ qxmltestlogger.cpp
+ qxmltestlogger_p.h
+ testlib.pro
+2 tools/
+0 bootstrap/
+0 bootstrap.pri
+ bootstrap.pro
+2 idc/
+0 idc.pro
+ main.cpp
+2 moc/
+0 generator.cpp
+ generator.h
+ keywords.cpp
+ main.cpp
+ moc.cpp
+ moc.h
+ moc.pri
+ moc.pro
+ mwerks_mac.cpp
+ mwerks_mac.h
+ outputrevision.h
+ parser.cpp
+ parser.h
+ ppkeywords.cpp
+ preprocessor.cpp
+ preprocessor.h
+ symbols.h
+ token.cpp
+ token.h
+ util/
+0 generate_keywords.cpp
+ generate_keywords.pro
+ generate.sh
+ licenseheader.txt
+2 utils.h
+2 rcc/
+0 main.cpp
+ rcc.cpp
+ rcc.h
+ rcc.pri
+ rcc.pro
+2 tools.pro
+ uic/
+ uic3/
+0 converter.cpp
+ deps.cpp
+ domtool.cpp
+ domtool.h
+ embed.cpp
+ form.cpp
+ main.cpp
+ object.cpp
+ parser.cpp
+ parser.h
+ qt3to4.cpp
+ qt3to4.h
+ subclassing.cpp
+ ui3reader.cpp
+ ui3reader.h
+ uic3.pro
+ uic.cpp
+ uic.h
+ widgetinfo.cpp
+ widgetinfo.h
+2 uic/cpp/
+0 cppextractimages.cpp
+ cppextractimages.h
+ cpp.pri
+ cppwritedeclaration.cpp
+ cppwritedeclaration.h
+ cppwriteicondata.cpp
+ cppwriteicondata.h
+ cppwriteicondeclaration.cpp
+ cppwriteicondeclaration.h
+ cppwriteiconinitialization.cpp
+ cppwriteiconinitialization.h
+ cppwriteincludes.cpp
+ cppwriteincludes.h
+ cppwriteinitialization.cpp
+ cppwriteinitialization.h
+2 uic/customwidgetsinfo.cpp
+ uic/customwidgetsinfo.h
+ uic/databaseinfo.cpp
+ uic/databaseinfo.h
+ uic/driver.cpp
+ uic/driver.h
+ uic/globaldefs.h
+ uic/main.cpp
+ uic/option.h
+ uic/treewalker.cpp
+ uic/treewalker.h
+ uic/ui4.cpp
+ uic/ui4.h
+ uic/uic.cpp
+ uic/uic.h
+ uic/uic.pri
+ uic/uic.pro
+ uic/utils.h
+ uic/validator.cpp
+ uic/validator.h
+2 winmain/
+0 qtmain_win.cpp
+ winmain.pro
+2 xml/
+0 dom/
+0 dom.pri
+ qdom.cpp
+ qdom.h
+3 xmlpatterns/
+0 acceltree/
+0 acceltree.pri
+ qacceliterators.cpp
+ qacceliterators_p.h
+ qacceltreebuilder.cpp
+ qacceltreebuilder_p.h
+ qacceltree.cpp
+ qacceltree_p.h
+ qacceltreeresourceloader.cpp
+ qacceltreeresourceloader_p.h
+ qcompressedwhitespace.cpp
+ qcompressedwhitespace_p.h
+2 api/
+0 api.pri
+ qabstractmessagehandler.cpp
+ qabstractmessagehandler.h
+ qabstracturiresolver.cpp
+ qabstracturiresolver.h
+ qabstractxmlforwarditerator.cpp
+ qabstractxmlforwarditerator_p.h
+ qabstractxmlnodemodel.cpp
+ qabstractxmlnodemodel.h
+ qabstractxmlnodemodel_p.h
+ qabstractxmlpullprovider.cpp
+ qabstractxmlpullprovider_p.h
+ qabstractxmlreceiver.cpp
+ qabstractxmlreceiver.h
+ qabstractxmlreceiver_p.h
+ qdeviceresourceloader_p.h
+ qiodevicedelegate.cpp
+ qiodevicedelegate_p.h
+ qnetworkaccessdelegator.cpp
+ qnetworkaccessdelegator_p.h
+ qpullbridge.cpp
+ qpullbridge_p.h
+ qreferencecountedvalue_p.h
+ qresourcedelegator.cpp
+ qresourcedelegator_p.h
+ qsimplexmlnodemodel.cpp
+ qsimplexmlnodemodel.h
+ qsourcelocation.cpp
+ qsourcelocation.h
+ quriloader.cpp
+ quriloader_p.h
+ qvariableloader.cpp
+ qvariableloader_p.h
+ qxmlformatter.cpp
+ qxmlformatter.h
+ qxmlname.cpp
+ qxmlname.h
+ qxmlnamepool.cpp
+ qxmlnamepool.h
+ qxmlquery.cpp
+ qxmlquery.h
+ qxmlquery_p.h
+ qxmlresultitems.cpp
+ qxmlresultitems.h
+ qxmlresultitems_p.h
+ qxmlschema.cpp
+ qxmlschema.h
+ qxmlschema_p.cpp
+ qxmlschema_p.h
+ qxmlschemavalidator.cpp
+ qxmlschemavalidator.h
+ qxmlschemavalidator_p.h
+ qxmlserializer.cpp
+ qxmlserializer.h
+ qxmlserializer_p.h
+2 common.pri
+ data/
+0 data.pri
+ qabstractdatetime.cpp
+ qabstractdatetime_p.h
+ qabstractduration.cpp
+ qabstractduration_p.h
+ qabstractfloatcasters.cpp
+ qabstractfloatcasters_p.h
+ qabstractfloat.cpp
+ qabstractfloatmathematician.cpp
+ qabstractfloatmathematician_p.h
+ qabstractfloat_p.h
+ qanyuri.cpp
+ qanyuri_p.h
+ qatomiccaster.cpp
+ qatomiccaster_p.h
+ qatomiccasters.cpp
+ qatomiccasters_p.h
+ qatomiccomparator.cpp
+ qatomiccomparator_p.h
+ qatomiccomparators.cpp
+ qatomiccomparators_p.h
+ qatomicmathematician.cpp
+ qatomicmathematician_p.h
+ qatomicmathematicians.cpp
+ qatomicmathematicians_p.h
+ qatomicstring.cpp
+ qatomicstring_p.h
+ qatomicvalue.cpp
+ qbase64binary.cpp
+ qbase64binary_p.h
+ qboolean.cpp
+ qboolean_p.h
+ qcommonvalues.cpp
+ qcommonvalues_p.h
+ qcomparisonfactory.cpp
+ qcomparisonfactory_p.h
+ qdate.cpp
+ qdate_p.h
+ qdaytimeduration.cpp
+ qdaytimeduration_p.h
+ qdecimal.cpp
+ qdecimal_p.h
+ qderivedinteger_p.h
+ qderivedstring_p.h
+ qduration.cpp
+ qduration_p.h
+ qgday.cpp
+ qgday_p.h
+ qgmonth.cpp
+ qgmonthday.cpp
+ qgmonthday_p.h
+ qgmonth_p.h
+ qgyear.cpp
+ qgyearmonth.cpp
+ qgyearmonth_p.h
+ qgyear_p.h
+ qhexbinary.cpp
+ qhexbinary_p.h
+ qinteger.cpp
+ qinteger_p.h
+ qitem.cpp
+ qitem_p.h
+ qnodebuilder.cpp
+ qnodebuilder_p.h
+ qnodemodel.cpp
+ qqnamevalue.cpp
+ qqnamevalue_p.h
+ qresourceloader.cpp
+ qresourceloader_p.h
+ qschemadatetime.cpp
+ qschemadatetime_p.h
+ qschemanumeric.cpp
+ qschemanumeric_p.h
+ qschematime.cpp
+ qschematime_p.h
+ qsequencereceiver.cpp
+ qsequencereceiver_p.h
+ qsorttuple.cpp
+ qsorttuple_p.h
+ quntypedatomic.cpp
+ quntypedatomic_p.h
+ qvalidationerror.cpp
+ qvalidationerror_p.h
+ qvaluefactory.cpp
+ qvaluefactory_p.h
+ qyearmonthduration.cpp
+ qyearmonthduration_p.h
+2 documentationGroups.dox
+ Doxyfile
+ environment/
+0 createReportContext.sh
+ createReportContext.xsl
+ environment.pri
+ qcurrentitemcontext.cpp
+ qcurrentitemcontext_p.h
+ qdelegatingdynamiccontext.cpp
+ qdelegatingdynamiccontext_p.h
+ qdelegatingstaticcontext.cpp
+ qdelegatingstaticcontext_p.h
+ qdynamiccontext.cpp
+ qdynamiccontext_p.h
+ qfocus.cpp
+ qfocus_p.h
+ qgenericdynamiccontext.cpp
+ qgenericdynamiccontext_p.h
+ qgenericstaticcontext.cpp
+ qgenericstaticcontext_p.h
+ qreceiverdynamiccontext.cpp
+ qreceiverdynamiccontext_p.h
+ qreportcontext.cpp
+ qreportcontext_p.h
+ qstackcontextbase.cpp
+ qstackcontextbase_p.h
+ qstaticbaseuricontext.cpp
+ qstaticbaseuricontext_p.h
+ qstaticcompatibilitycontext.cpp
+ qstaticcompatibilitycontext_p.h
+ qstaticcontext.cpp
+ qstaticcontext_p.h
+ qstaticcurrentcontext.cpp
+ qstaticcurrentcontext_p.h
+ qstaticfocuscontext.cpp
+ qstaticfocuscontext_p.h
+ qstaticnamespacecontext.cpp
+ qstaticnamespacecontext_p.h
+2 expr/
+0 expr.pri
+ qandexpression.cpp
+ qandexpression_p.h
+ qapplytemplate.cpp
+ qapplytemplate_p.h
+ qargumentreference.cpp
+ qargumentreference_p.h
+ qarithmeticexpression.cpp
+ qarithmeticexpression_p.h
+ qattributeconstructor.cpp
+ qattributeconstructor_p.h
+ qattributenamevalidator.cpp
+ qattributenamevalidator_p.h
+ qaxisstep.cpp
+ qaxisstep_p.h
+ qcachecells_p.h
+ qcallsite.cpp
+ qcallsite_p.h
+ qcalltargetdescription.cpp
+ qcalltargetdescription_p.h
+ qcalltemplate.cpp
+ qcalltemplate_p.h
+ qcastableas.cpp
+ qcastableas_p.h
+ qcastas.cpp
+ qcastas_p.h
+ qcastingplatform.cpp
+ qcastingplatform_p.h
+ qcollationchecker.cpp
+ qcollationchecker_p.h
+ qcombinenodes.cpp
+ qcombinenodes_p.h
+ qcommentconstructor.cpp
+ qcommentconstructor_p.h
+ qcomparisonplatform.cpp
+ qcomparisonplatform_p.h
+ qcomputednamespaceconstructor.cpp
+ qcomputednamespaceconstructor_p.h
+ qcontextitem.cpp
+ qcontextitem_p.h
+ qcopyof.cpp
+ qcopyof_p.h
+ qcurrentitemstore.cpp
+ qcurrentitemstore_p.h
+ qdocumentconstructor.cpp
+ qdocumentconstructor_p.h
+ qdocumentcontentvalidator.cpp
+ qdocumentcontentvalidator_p.h
+ qdynamiccontextstore.cpp
+ qdynamiccontextstore_p.h
+ qelementconstructor.cpp
+ qelementconstructor_p.h
+ qemptycontainer.cpp
+ qemptycontainer_p.h
+ qemptysequence.cpp
+ qemptysequence_p.h
+ qevaluationcache.cpp
+ qevaluationcache_p.h
+ qexpression.cpp
+ qexpressiondispatch_p.h
+ qexpressionfactory.cpp
+ qexpressionfactory_p.h
+ qexpression_p.h
+ qexpressionsequence.cpp
+ qexpressionsequence_p.h
+ qexpressionvariablereference.cpp
+ qexpressionvariablereference_p.h
+ qexternalvariableloader.cpp
+ qexternalvariableloader_p.h
+ qexternalvariablereference.cpp
+ qexternalvariablereference_p.h
+ qfirstitempredicate.cpp
+ qfirstitempredicate_p.h
+ qforclause.cpp
+ qforclause_p.h
+ qgeneralcomparison.cpp
+ qgeneralcomparison_p.h
+ qgenericpredicate.cpp
+ qgenericpredicate_p.h
+ qifthenclause.cpp
+ qifthenclause_p.h
+ qinstanceof.cpp
+ qinstanceof_p.h
+ qletclause.cpp
+ qletclause_p.h
+ qliteral.cpp
+ qliteral_p.h
+ qliteralsequence.cpp
+ qliteralsequence_p.h
+ qnamespaceconstructor.cpp
+ qnamespaceconstructor_p.h
+ qncnameconstructor.cpp
+ qncnameconstructor_p.h
+ qnodecomparison.cpp
+ qnodecomparison_p.h
+ qnodesort.cpp
+ qnodesort_p.h
+ qoperandsiterator_p.h
+ qoptimizationpasses.cpp
+ qoptimizationpasses_p.h
+ qoptimizerblocks.cpp
+ qoptimizerblocks_p.h
+ qoptimizerframework.cpp
+ qoptimizerframework_p.h
+ qorderby.cpp
+ qorderby_p.h
+ qorexpression.cpp
+ qorexpression_p.h
+ qpaircontainer.cpp
+ qpaircontainer_p.h
+ qparentnodeaxis.cpp
+ qparentnodeaxis_p.h
+ qpath.cpp
+ qpath_p.h
+ qpositionalvariablereference.cpp
+ qpositionalvariablereference_p.h
+ qprocessinginstructionconstructor.cpp
+ qprocessinginstructionconstructor_p.h
+ qqnameconstructor.cpp
+ qqnameconstructor_p.h
+ qquantifiedexpression.cpp
+ qquantifiedexpression_p.h
+ qrangeexpression.cpp
+ qrangeexpression_p.h
+ qrangevariablereference.cpp
+ qrangevariablereference_p.h
+ qreturnorderby.cpp
+ qreturnorderby_p.h
+ qsimplecontentconstructor.cpp
+ qsimplecontentconstructor_p.h
+ qsinglecontainer.cpp
+ qsinglecontainer_p.h
+ qsourcelocationreflection.cpp
+ qsourcelocationreflection_p.h
+ qstaticbaseuristore.cpp
+ qstaticbaseuristore_p.h
+ qstaticcompatibilitystore.cpp
+ qstaticcompatibilitystore_p.h
+ qtemplate.cpp
+ qtemplateinvoker.cpp
+ qtemplateinvoker_p.h
+ qtemplatemode.cpp
+ qtemplatemode_p.h
+ qtemplateparameterreference.cpp
+ qtemplateparameterreference_p.h
+ qtemplatepattern_p.h
+ qtemplate_p.h
+ qtextnodeconstructor.cpp
+ qtextnodeconstructor_p.h
+ qtreatas.cpp
+ qtreatas_p.h
+ qtriplecontainer.cpp
+ qtriplecontainer_p.h
+ qtruthpredicate.cpp
+ qtruthpredicate_p.h
+ qunaryexpression.cpp
+ qunaryexpression_p.h
+ qunlimitedcontainer.cpp
+ qunlimitedcontainer_p.h
+ qunresolvedvariablereference.cpp
+ qunresolvedvariablereference_p.h
+ quserfunctioncallsite.cpp
+ quserfunctioncallsite_p.h
+ quserfunction.cpp
+ quserfunction_p.h
+ qvalidate.cpp
+ qvalidate_p.h
+ qvaluecomparison.cpp
+ qvaluecomparison_p.h
+ qvariabledeclaration.cpp
+ qvariabledeclaration_p.h
+ qvariablereference.cpp
+ qvariablereference_p.h
+ qwithparam_p.h
+ qxsltsimplecontentconstructor.cpp
+ qxsltsimplecontentconstructor_p.h
+2 functions/
+0 functions.pri
+ qabstractfunctionfactory.cpp
+ qabstractfunctionfactory_p.h
+ qaccessorfns.cpp
+ qaccessorfns_p.h
+ qaggregatefns.cpp
+ qaggregatefns_p.h
+ qaggregator.cpp
+ qaggregator_p.h
+ qassemblestringfns.cpp
+ qassemblestringfns_p.h
+ qbooleanfns.cpp
+ qbooleanfns_p.h
+ qcomparescaseaware.cpp
+ qcomparescaseaware_p.h
+ qcomparestringfns.cpp
+ qcomparestringfns_p.h
+ qcomparingaggregator.cpp
+ qcomparingaggregator_p.h
+ qconstructorfunctionsfactory.cpp
+ qconstructorfunctionsfactory_p.h
+ qcontextfns.cpp
+ qcontextfns_p.h
+ qcontextnodechecker.cpp
+ qcontextnodechecker_p.h
+ qcurrentfn.cpp
+ qcurrentfn_p.h
+ qdatetimefn.cpp
+ qdatetimefn_p.h
+ qdatetimefns.cpp
+ qdatetimefns_p.h
+ qdeepequalfn.cpp
+ qdeepequalfn_p.h
+ qdocumentfn.cpp
+ qdocumentfn_p.h
+ qelementavailablefn.cpp
+ qelementavailablefn_p.h
+ qerrorfn.cpp
+ qerrorfn_p.h
+ qfunctionargument.cpp
+ qfunctionargument_p.h
+ qfunctionavailablefn.cpp
+ qfunctionavailablefn_p.h
+ qfunctioncall.cpp
+ qfunctioncall_p.h
+ qfunctionfactorycollection.cpp
+ qfunctionfactorycollection_p.h
+ qfunctionfactory.cpp
+ qfunctionfactory_p.h
+ qfunctionsignature.cpp
+ qfunctionsignature_p.h
+ qgenerateidfn.cpp
+ qgenerateidfn_p.h
+ qnodefns.cpp
+ qnodefns_p.h
+ qnumericfns.cpp
+ qnumericfns_p.h
+ qpatternmatchingfns.cpp
+ qpatternmatchingfns_p.h
+ qpatternplatform.cpp
+ qpatternplatform_p.h
+ qqnamefns.cpp
+ qqnamefns_p.h
+ qresolveurifn.cpp
+ qresolveurifn_p.h
+ qsequencefns.cpp
+ qsequencefns_p.h
+ qsequencegeneratingfns.cpp
+ qsequencegeneratingfns_p.h
+ qstaticbaseuricontainer_p.h
+ qstaticnamespacescontainer.cpp
+ qstaticnamespacescontainer_p.h
+ qstringvaluefns.cpp
+ qstringvaluefns_p.h
+ qsubstringfns.cpp
+ qsubstringfns_p.h
+ qsystempropertyfn.cpp
+ qsystempropertyfn_p.h
+ qtimezonefns.cpp
+ qtimezonefns_p.h
+ qtracefn.cpp
+ qtracefn_p.h
+ qtypeavailablefn.cpp
+ qtypeavailablefn_p.h
+ qunparsedentitypublicidfn.cpp
+ qunparsedentitypublicidfn_p.h
+ qunparsedentityurifn.cpp
+ qunparsedentityurifn_p.h
+ qunparsedtextavailablefn.cpp
+ qunparsedtextavailablefn_p.h
+ qunparsedtextfn.cpp
+ qunparsedtextfn_p.h
+ qxpath10corefunctions.cpp
+ qxpath10corefunctions_p.h
+ qxpath20corefunctions.cpp
+ qxpath20corefunctions_p.h
+ qxslt20corefunctions.cpp
+ qxslt20corefunctions_p.h
+2 .gitignore
+ iterators/
+0 iterators.pri
+ qcachingiterator.cpp
+ qcachingiterator_p.h
+ qdeduplicateiterator.cpp
+ qdeduplicateiterator_p.h
+ qdistinctiterator.cpp
+ qdistinctiterator_p.h
+ qemptyiterator_p.h
+ qexceptiterator.cpp
+ qexceptiterator_p.h
+ qindexofiterator.cpp
+ qindexofiterator_p.h
+ qinsertioniterator.cpp
+ qinsertioniterator_p.h
+ qintersectiterator.cpp
+ qintersectiterator_p.h
+ qitemmappingiterator_p.h
+ qrangeiterator.cpp
+ qrangeiterator_p.h
+ qremovaliterator.cpp
+ qremovaliterator_p.h
+ qsequencemappingiterator_p.h
+ qsingletoniterator_p.h
+ qsubsequenceiterator.cpp
+ qsubsequenceiterator_p.h
+ qtocodepointsiterator.cpp
+ qtocodepointsiterator_p.h
+ qunioniterator.cpp
+ qunioniterator_p.h
+2 janitors/
+0 janitors.pri
+ qargumentconverter.cpp
+ qargumentconverter_p.h
+ qatomizer.cpp
+ qatomizer_p.h
+ qcardinalityverifier.cpp
+ qcardinalityverifier_p.h
+ qebvextractor.cpp
+ qebvextractor_p.h
+ qitemverifier.cpp
+ qitemverifier_p.h
+ quntypedatomicconverter.cpp
+ quntypedatomicconverter_p.h
+2 Mainpage.dox
+ parser/
+0 createParser.sh
+ createTokenLookup.sh
+ createXSLTTokenLookup.sh
+ .gitattributes
+ .gitignore
+ parser.pri
+ qmaintainingreader.cpp
+ qmaintainingreader_p.h
+ qparsercontext.cpp
+ qparsercontext_p.h
+ qquerytransformparser.cpp
+ qquerytransformparser_p.h
+ qtokenizer_p.h
+ qtokenlookup.cpp
+ qtokenrevealer.cpp
+ qtokenrevealer_p.h
+ qtokensource.cpp
+ qtokensource_p.h
+ querytransformparser.ypp
+ qxquerytokenizer.cpp
+ qxquerytokenizer_p.h
+ qxslttokenizer.cpp
+ qxslttokenizer_p.h
+ qxslttokenlookup.cpp
+ qxslttokenlookup_p.h
+ qxslttokenlookup.xml
+ TokenLookup.gperf
+ trolltechHeader.txt
+ winCEWorkaround.sed
+2 projection/
+0 projection.pri
+ qdocumentprojector.cpp
+ qdocumentprojector_p.h
+ qprojectedexpression_p.h
+2 qtokenautomaton/
+0 exampleFile.xml
+ qautomaton2cpp.xsl
+ qtokenautomaton.xsd
+ README
+2 query.pri
+ schema/
+0 builtinschemas.qrc
+ doc/
+0 All_diagram.dot
+ Alternative_diagram.dot
+ Annotation_diagram.dot
+ AnyAttribute_diagram.dot
+ Any_diagram.dot
+ Assert_diagram.dot
+ Choice_diagram.dot
+ ComplexContent_diagram.dot
+ ComplexContentExtension_diagram.dot
+ ComplexContentRestriction_diagram.dot
+ DefaultOpenContent_diagram.dot
+ EnumerationFacet_diagram.dot
+ Field_diagram.dot
+ FractionDigitsFacet_diagram.dot
+ GlobalAttribute_diagram.dot
+ GlobalComplexType_diagram.dot
+ GlobalElement_diagram.dot
+ GlobalSimpleType_diagram.dot
+ Import_diagram.dot
+ Include_diagram.dot
+ Key_diagram.dot
+ KeyRef_diagram.dot
+ legend.dot
+ LengthFacet_diagram.dot
+ List_diagram.dot
+ LocalAll_diagram.dot
+ LocalAttribute_diagram.dot
+ LocalChoice_diagram.dot
+ LocalComplexType_diagram.dot
+ LocalElement_diagram.dot
+ LocalSequence_diagram.dot
+ LocalSimpleType_diagram.dot
+ MaxExclusiveFacet_diagram.dot
+ MaxInclusiveFacet_diagram.dot
+ MaxLengthFacet_diagram.dot
+ MinExclusiveFacet_diagram.dot
+ MinInclusiveFacet_diagram.dot
+ MinLengthFacet_diagram.dot
+ NamedAttributeGroup_diagram.dot
+ NamedGroup_diagram.dot
+ Notation_diagram.dot
+ Override_diagram.dot
+ PatternFacet_diagram.dot
+ Redefine_diagram.dot
+ ReferredAttributeGroup_diagram.dot
+ ReferredGroup_diagram.dot
+ Schema_diagram.dot
+ Selector_diagram.dot
+ Sequence_diagram.dot
+ SimpleContent_diagram.dot
+ SimpleContentExtension_diagram.dot
+ SimpleContentRestriction_diagram.dot
+ SimpleRestriction_diagram.dot
+ TotalDigitsFacet_diagram.dot
+ Union_diagram.dot
+ Unique_diagram.dot
+ WhiteSpaceFacet_diagram.dot
+2 .gitignore
+ qnamespacesupport.cpp
+ qnamespacesupport_p.h
+ qxsdalternative.cpp
+ qxsdalternative_p.h
+ qxsdannotated.cpp
+ qxsdannotated_p.h
+ qxsdannotation.cpp
+ qxsdannotation_p.h
+ qxsdapplicationinformation.cpp
+ qxsdapplicationinformation_p.h
+ qxsdassertion.cpp
+ qxsdassertion_p.h
+ qxsdattribute.cpp
+ qxsdattributegroup.cpp
+ qxsdattributegroup_p.h
+ qxsdattribute_p.h
+ qxsdattributereference.cpp
+ qxsdattributereference_p.h
+ qxsdattributeterm.cpp
+ qxsdattributeterm_p.h
+ qxsdattributeuse.cpp
+ qxsdattributeuse_p.h
+ qxsdcomplextype.cpp
+ qxsdcomplextype_p.h
+ qxsddocumentation.cpp
+ qxsddocumentation_p.h
+ qxsdelement.cpp
+ qxsdelement_p.h
+ qxsdfacet.cpp
+ qxsdfacet_p.h
+ qxsdidcache.cpp
+ qxsdidcache_p.h
+ qxsdidchelper.cpp
+ qxsdidchelper_p.h
+ qxsdidentityconstraint.cpp
+ qxsdidentityconstraint_p.h
+ qxsdinstancereader.cpp
+ qxsdinstancereader_p.h
+ qxsdmodelgroup.cpp
+ qxsdmodelgroup_p.h
+ qxsdnotation.cpp
+ qxsdnotation_p.h
+ qxsdparticlechecker.cpp
+ qxsdparticlechecker_p.h
+ qxsdparticle.cpp
+ qxsdparticle_p.h
+ qxsdreference.cpp
+ qxsdreference_p.h
+ qxsdschemachecker.cpp
+ qxsdschemachecker_helper.cpp
+ qxsdschemachecker_p.h
+ qxsdschemachecker_setup.cpp
+ qxsdschemacontext.cpp
+ qxsdschemacontext_p.h
+ qxsdschema.cpp
+ qxsdschemadebugger.cpp
+ qxsdschemadebugger_p.h
+ qxsdschemahelper.cpp
+ qxsdschemahelper_p.h
+ qxsdschemamerger.cpp
+ qxsdschemamerger_p.h
+ qxsdschemaparsercontext.cpp
+ qxsdschemaparsercontext_p.h
+ qxsdschemaparser.cpp
+ qxsdschemaparser_p.h
+ qxsdschemaparser_setup.cpp
+ qxsdschema_p.h
+ qxsdschemaresolver.cpp
+ qxsdschemaresolver_p.h
+ qxsdschematoken.cpp
+ qxsdschematoken_p.h
+ qxsdschematypesfactory.cpp
+ qxsdschematypesfactory_p.h
+ qxsdsimpletype.cpp
+ qxsdsimpletype_p.h
+ qxsdstatemachinebuilder.cpp
+ qxsdstatemachinebuilder_p.h
+ qxsdstatemachine.cpp
+ qxsdstatemachine_p.h
+ qxsdterm.cpp
+ qxsdterm_p.h
+ qxsdtypechecker.cpp
+ qxsdtypechecker_p.h
+ qxsduserschematype.cpp
+ qxsduserschematype_p.h
+ qxsdvalidatedxmlnodemodel.cpp
+ qxsdvalidatedxmlnodemodel_p.h
+ qxsdvalidatinginstancereader.cpp
+ qxsdvalidatinginstancereader_p.h
+ qxsdwildcard.cpp
+ qxsdwildcard_p.h
+ qxsdxpathexpression.cpp
+ qxsdxpathexpression_p.h
+ schema.pri
+ schemas/
+0 xml.xsd
+0 -LICENSE
+3 tokens.xml
+2 type/
+0 qabstractnodetest.cpp
+ qabstractnodetest_p.h
+ qanyitemtype.cpp
+ qanyitemtype_p.h
+ qanynodetype.cpp
+ qanynodetype_p.h
+ qanysimpletype.cpp
+ qanysimpletype_p.h
+ qanytype.cpp
+ qanytype_p.h
+ qatomiccasterlocator.cpp
+ qatomiccasterlocator_p.h
+ qatomiccasterlocators.cpp
+ qatomiccasterlocators_p.h
+ qatomiccomparatorlocator.cpp
+ qatomiccomparatorlocator_p.h
+ qatomiccomparatorlocators.cpp
+ qatomiccomparatorlocators_p.h
+ qatomicmathematicianlocator.cpp
+ qatomicmathematicianlocator_p.h
+ qatomicmathematicianlocators.cpp
+ qatomicmathematicianlocators_p.h
+ qatomictype.cpp
+ qatomictypedispatch_p.h
+ qatomictype_p.h
+ qbasictypesfactory.cpp
+ qbasictypesfactory_p.h
+ qbuiltinatomictype.cpp
+ qbuiltinatomictype_p.h
+ qbuiltinatomictypes.cpp
+ qbuiltinatomictypes_p.h
+ qbuiltinnodetype.cpp
+ qbuiltinnodetype_p.h
+ qbuiltintypes.cpp
+ qbuiltintypes_p.h
+ qcardinality.cpp
+ qcardinality_p.h
+ qcommonsequencetypes.cpp
+ qcommonsequencetypes_p.h
+ qebvtype.cpp
+ qebvtype_p.h
+ qemptysequencetype.cpp
+ qemptysequencetype_p.h
+ qgenericsequencetype.cpp
+ qgenericsequencetype_p.h
+ qitemtype.cpp
+ qitemtype_p.h
+ qlocalnametest.cpp
+ qlocalnametest_p.h
+ qmultiitemtype.cpp
+ qmultiitemtype_p.h
+ qnamedschemacomponent.cpp
+ qnamedschemacomponent_p.h
+ qnamespacenametest.cpp
+ qnamespacenametest_p.h
+ qnonetype.cpp
+ qnonetype_p.h
+ qnumerictype.cpp
+ qnumerictype_p.h
+ qprimitives_p.h
+ qqnametest.cpp
+ qqnametest_p.h
+ qschemacomponent.cpp
+ qschemacomponent_p.h
+ qschematype.cpp
+ qschematypefactory.cpp
+ qschematypefactory_p.h
+ qschematype_p.h
+ qsequencetype.cpp
+ qsequencetype_p.h
+ qtypechecker.cpp
+ qtypechecker_p.h
+ quntyped.cpp
+ quntyped_p.h
+ qxsltnodetest.cpp
+ qxsltnodetest_p.h
+ type.pri
+2 utils/
+0 qautoptr.cpp
+ qautoptr_p.h
+ qcommonnamespaces_p.h
+ qcppcastinghelper_p.h
+ qdebug_p.h
+ qdelegatingnamespaceresolver.cpp
+ qdelegatingnamespaceresolver_p.h
+ qgenericnamespaceresolver.cpp
+ qgenericnamespaceresolver_p.h
+ qnamepool.cpp
+ qnamepool_p.h
+ qnamespacebinding_p.h
+ qnamespaceresolver.cpp
+ qnamespaceresolver_p.h
+ qnodenamespaceresolver.cpp
+ qnodenamespaceresolver_p.h
+ qoutputvalidator.cpp
+ qoutputvalidator_p.h
+ qpatternistlocale.cpp
+ qpatternistlocale_p.h
+ qxpathhelper.cpp
+ qxpathhelper_p.h
+ utils.pri
+2 xmlpatterns.pro
+2 xml/sax/
+0 qxml.cpp
+ qxml.h
+ sax.pri
+2 xml/stream/
+0 qxmlstream.h
+ stream.pri
+2 xml/xml.pro
diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp
new file mode 100644
index 0000000000..ad5ae9882e
--- /dev/null
+++ b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp
@@ -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 test suite module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <QtTest/QTest>
+
+#include <QDirIterator>
+#include <QFile>
+#include <QString>
+#include <QStack>
+
+#include "../../../../../shared/filesystem.h"
+
+class bench_QDir_tree
+ : public QObject
+{
+ Q_OBJECT
+
+public:
+ bench_QDir_tree()
+ : prefix("./test-tree/")
+ {
+ }
+
+private:
+ QByteArray prefix;
+
+private slots:
+ void initTestCase()
+ {
+ QFile list(":/4.6.0-list.txt");
+ QVERIFY(list.open(QIODevice::ReadOnly | QIODevice::Text));
+
+ QVERIFY(fs.createDirectory(prefix));
+
+ QStack<QByteArray> stack;
+ QByteArray line;
+ Q_FOREVER {
+ char ch;
+ if (!list.getChar(&ch))
+ break;
+ if (ch != ' ') {
+ line.append(ch);
+ continue;
+ }
+
+ int pop = 1;
+ if (!line.isEmpty())
+ pop = line.toInt();
+
+ while (pop) {
+ stack.pop();
+ --pop;
+ }
+
+ line = list.readLine();
+ line.chop(1);
+ stack.push(line);
+
+ line = prefix;
+ Q_FOREACH(const QByteArray &pathElement, stack)
+ line += pathElement;
+
+ if (line.endsWith('/'))
+ QVERIFY(fs.createDirectory(line));
+ else
+ QVERIFY(fs.createFile(line));
+
+ line.clear();
+ }
+ }
+
+ void fileSearch_data() const
+ {
+ QTest::addColumn<QStringList>("nameFilters");
+ QTest::addColumn<int>("filter");
+ QTest::addColumn<int>("entryCount");
+
+ QTest::newRow("*.cpp") << QStringList("*.cpp")
+ << int(QDir::Files)
+ << 3813;
+
+ QTest::newRow("executables") << QStringList("*")
+ << int(QDir::Executable | QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot)
+ << 543;
+ }
+
+ void fileSearch() const
+ {
+ QFETCH(QStringList, nameFilters);
+ QFETCH(int, filter);
+ QFETCH(int, entryCount);
+
+ int count = 0;
+ QBENCHMARK {
+ // Recursive directory iteration
+ QDirIterator iterator(prefix, nameFilters, QDir::Filter(filter),
+ QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+
+ count = 0;
+ while (iterator.hasNext()) {
+ iterator.next();
+ ++count;
+ }
+
+ QCOMPARE(count, entryCount);
+ }
+
+ QCOMPARE(count, entryCount);
+ }
+
+ void traverseDirectory() const
+ {
+ int count = 0;
+ QBENCHMARK {
+ QDirIterator iterator(prefix,
+ QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System,
+ QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+
+ while (iterator.hasNext()) {
+ iterator.next();
+ ++count;
+ }
+
+ QCOMPARE(count, 11963);
+ }
+
+ QCOMPARE(count, 11963);
+ }
+
+private:
+ FileSystem fs;
+};
+
+QTEST_MAIN(bench_QDir_tree)
+#include "bench_qdir_tree.moc"
diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc
new file mode 100644
index 0000000000..d57cb6c368
--- /dev/null
+++ b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>4.6.0-list.txt</file>
+</qresource>
+</RCC>
diff --git a/tests/benchmarks/corelib/io/qdir/tree/tree.pro b/tests/benchmarks/corelib/io/qdir/tree/tree.pro
new file mode 100644
index 0000000000..773f0f7ccd
--- /dev/null
+++ b/tests/benchmarks/corelib/io/qdir/tree/tree.pro
@@ -0,0 +1,11 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = bench_qdir_tree
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += bench_qdir_tree.cpp
+RESOURCES += bench_qdir_tree.qrc
+
+QT -= gui
diff --git a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro
index 295cb502ab..eca619fb37 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro
+++ b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro
@@ -1,6 +1,6 @@
load(qttest_p4)
TEMPLATE = app
-TARGET = qfileinfo
+TARGET = tst_qfileinfo
DEPENDPATH += .
INCLUDEPATH += .
diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro
index e25f186fbb..aa4cc41277 100644
--- a/tests/benchmarks/declarative/binding/binding.pro
+++ b/tests/benchmarks/declarative/binding/binding.pro
@@ -7,3 +7,9 @@ macx:CONFIG -= app_bundle
SOURCES += tst_binding.cpp testtypes.cpp
HEADERS += testtypes.h
+symbian* {
+ data.sources = data/*
+ data.path = data
+ DEPLOYMENT = data
+}
+
diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/declarative/binding/testtypes.cpp
index 3a9f59b394..043c8ab945 100644
--- a/tests/benchmarks/declarative/binding/testtypes.cpp
+++ b/tests/benchmarks/declarative/binding/testtypes.cpp
@@ -40,4 +40,7 @@
****************************************************************************/
#include "testtypes.h"
-QML_DEFINE_TYPE(Test, 1, 0, MyQmlObject, MyQmlObject);
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Test, 1, 0, MyQmlObject, MyQmlObject);
+}
diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h
index d4e0a1a935..4b103ceb25 100644
--- a/tests/benchmarks/declarative/binding/testtypes.h
+++ b/tests/benchmarks/declarative/binding/testtypes.h
@@ -42,7 +42,7 @@
#define TESTTYPES_H
#include <QtCore/qobject.h>
-#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qdeclarative.h>
class MyQmlObject : public QObject
{
@@ -50,7 +50,7 @@ class MyQmlObject : public QObject
Q_PROPERTY(int result READ result WRITE setResult);
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged);
Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged);
- Q_PROPERTY(QmlList<QObject *> *data READ data);
+ Q_PROPERTY(QDeclarativeList<QObject *> *data READ data);
Q_CLASSINFO("DefaultProperty", "data");
public:
MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
@@ -61,7 +61,7 @@ public:
int value() const { return m_value; }
void setValue(int v) { m_value = v; emit valueChanged(); }
- QmlList<QObject *> *data() { return &m_data; }
+ QDeclarativeList<QObject *> *data() { return &m_data; }
MyQmlObject *object() const { return m_object; }
void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
@@ -71,11 +71,13 @@ signals:
void objectChanged();
private:
- QmlConcreteList<QObject *> m_data;
+ QDeclarativeConcreteList<QObject *> m_data;
int m_result;
int m_value;
MyQmlObject *m_object;
};
QML_DECLARE_TYPE(MyQmlObject);
+void registerTypes();
+
#endif // TESTTYPES_H
diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp
index 74a340711e..ee529a7a2e 100644
--- a/tests/benchmarks/declarative/binding/tst_binding.cpp
+++ b/tests/benchmarks/declarative/binding/tst_binding.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QFile>
#include <QDebug>
#include "testtypes.h"
@@ -57,8 +57,8 @@ public:
virtual ~tst_binding();
public slots:
- void init();
- void cleanup();
+ void initTestCase();
+ void cleanupTestCase();
private slots:
void objectproperty_data();
@@ -67,7 +67,7 @@ private slots:
void basicproperty();
private:
- QmlEngine engine;
+ QDeclarativeEngine engine;
};
tst_binding::tst_binding()
@@ -78,16 +78,17 @@ tst_binding::~tst_binding()
{
}
-void tst_binding::init()
+void tst_binding::initTestCase()
{
+ registerTypes();
}
-void tst_binding::cleanup()
+void tst_binding::cleanupTestCase()
{
}
#define COMPONENT(filename, binding) \
- QmlComponent c(&engine); \
+ QDeclarativeComponent c(&engine); \
{ \
QFile f(filename); \
QVERIFY(f.open(QIODevice::ReadOnly)); \
diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro
index fcc2987c94..3e0caf6988 100644
--- a/tests/benchmarks/declarative/creation/creation.pro
+++ b/tests/benchmarks/declarative/creation/creation.pro
@@ -6,5 +6,10 @@ macx:CONFIG -= app_bundle
SOURCES += tst_creation.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
+symbian* {
+ data.sources = data/*
+ data.path = data
+ DEPLOYMENT += addFiles
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+} \ No newline at end of file
diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp
index 23c820cdf7..9c0fd27d08 100644
--- a/tests/benchmarks/declarative/creation/tst_creation.cpp
+++ b/tests/benchmarks/declarative/creation/tst_creation.cpp
@@ -40,15 +40,21 @@
****************************************************************************/
#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QmlMetaType>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDeclarativeMetaType>
#include <QDebug>
#include <QGraphicsScene>
#include <QGraphicsItem>
-#include <QmlGraphicsItem>
+#include <QDeclarativeItem>
#include <private/qobject_p.h>
+#ifdef Q_OS_SYMBIAN
+// In Symbian OS test data is located in applications private dir
+// Application private dir is default serach path for files, so SRCDIR can be set to empty
+#define SRCDIR ""
+#endif
+
class tst_creation : public QObject
{
Q_OBJECT
@@ -77,7 +83,7 @@ private slots:
void itemtree_scene_cpp();
private:
- QmlEngine engine;
+ QDeclarativeEngine engine;
};
inline QUrl TEST_FILE(const QString &filename)
@@ -95,7 +101,7 @@ void tst_creation::qobject_cpp()
void tst_creation::qobject_qml()
{
- QmlComponent component(&engine, TEST_FILE("qobject.qml"));
+ QDeclarativeComponent component(&engine, TEST_FILE("qobject.qml"));
QObject *obj = component.create();
delete obj;
@@ -107,7 +113,7 @@ void tst_creation::qobject_qml()
void tst_creation::qobject_qmltype()
{
- QmlType *t = QmlMetaType::qmlType("Qt/QtObject", 4, 6);
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6);
QBENCHMARK {
QObject *obj = t->create();
@@ -148,7 +154,7 @@ void tst_creation::objects_qmltype_data()
{
QTest::addColumn<QByteArray>("type");
- QList<QByteArray> types = QmlMetaType::qmlTypeNames();
+ QList<QByteArray> types = QDeclarativeMetaType::qmlTypeNames();
foreach (QByteArray type, types)
QTest::newRow(type.constData()) << type;
}
@@ -156,7 +162,7 @@ void tst_creation::objects_qmltype_data()
void tst_creation::objects_qmltype()
{
QFETCH(QByteArray, type);
- QmlType *t = QmlMetaType::qmlType(type, 4, 6);
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6);
QBENCHMARK {
QObject *obj = t->create();
@@ -275,7 +281,7 @@ void tst_creation::qgraphicsitem_tree14()
}
}
-struct QmlGraphics_DerivedObject : public QObject
+struct QDeclarativeGraphics_DerivedObject : public QObject
{
void setParent_noEvent(QObject *parent) {
bool sce = d_ptr->sendChildEvents;
@@ -285,17 +291,17 @@ struct QmlGraphics_DerivedObject : public QObject
}
};
-inline void QmlGraphics_setParent_noEvent(QObject *object, QObject *parent)
+inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent)
{
- static_cast<QmlGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
+ static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
}
void tst_creation::itemtree_notree_cpp()
{
QBENCHMARK {
- QmlGraphicsItem *item = new QmlGraphicsItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
for (int i = 0; i < 30; ++i) {
- QmlGraphicsItem *child = new QmlGraphicsItem;
+ QDeclarativeItem *child = new QDeclarativeItem;
}
delete item;
}
@@ -304,10 +310,10 @@ void tst_creation::itemtree_notree_cpp()
void tst_creation::itemtree_objtree_cpp()
{
QBENCHMARK {
- QmlGraphicsItem *item = new QmlGraphicsItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
for (int i = 0; i < 30; ++i) {
- QmlGraphicsItem *child = new QmlGraphicsItem;
- QmlGraphics_setParent_noEvent(child,item);
+ QDeclarativeItem *child = new QDeclarativeItem;
+ QDeclarativeGraphics_setParent_noEvent(child,item);
}
delete item;
}
@@ -316,10 +322,10 @@ void tst_creation::itemtree_objtree_cpp()
void tst_creation::itemtree_cpp()
{
QBENCHMARK {
- QmlGraphicsItem *item = new QmlGraphicsItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
for (int i = 0; i < 30; ++i) {
- QmlGraphicsItem *child = new QmlGraphicsItem;
- QmlGraphics_setParent_noEvent(child,item);
+ QDeclarativeItem *child = new QDeclarativeItem;
+ QDeclarativeGraphics_setParent_noEvent(child,item);
child->setParentItem(item);
}
delete item;
@@ -329,10 +335,10 @@ void tst_creation::itemtree_cpp()
void tst_creation::itemtree_data_cpp()
{
QBENCHMARK {
- QmlGraphicsItem *item = new QmlGraphicsItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
for (int i = 0; i < 30; ++i) {
- QmlGraphicsItem *child = new QmlGraphicsItem;
- QmlGraphics_setParent_noEvent(child,item);
+ QDeclarativeItem *child = new QDeclarativeItem;
+ QDeclarativeGraphics_setParent_noEvent(child,item);
item->data()->append(child);
}
delete item;
@@ -341,7 +347,7 @@ void tst_creation::itemtree_data_cpp()
void tst_creation::itemtree_qml()
{
- QmlComponent component(&engine, TEST_FILE("item.qml"));
+ QDeclarativeComponent component(&engine, TEST_FILE("item.qml"));
QObject *obj = component.create();
delete obj;
@@ -354,13 +360,13 @@ void tst_creation::itemtree_qml()
void tst_creation::itemtree_scene_cpp()
{
QGraphicsScene scene;
- QmlGraphicsItem *root = new QmlGraphicsItem;
+ QDeclarativeItem *root = new QDeclarativeItem;
scene.addItem(root);
QBENCHMARK {
- QmlGraphicsItem *item = new QmlGraphicsItem;
+ QDeclarativeItem *item = new QDeclarativeItem;
for (int i = 0; i < 30; ++i) {
- QmlGraphicsItem *child = new QmlGraphicsItem;
- QmlGraphics_setParent_noEvent(child,item);
+ QDeclarativeItem *child = new QDeclarativeItem;
+ QDeclarativeGraphics_setParent_noEvent(child,item);
child->setParentItem(item);
}
item->setParentItem(root);
diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro
index 8433de5b9b..8c0ed4210b 100644
--- a/tests/benchmarks/declarative/declarative.pro
+++ b/tests/benchmarks/declarative/declarative.pro
@@ -3,8 +3,8 @@ SUBDIRS += \
binding \
creation \
pointers \
- qmlcomponent \
- qmlgraphicsimage \
- qmlmetaproperty \
+ qdeclarativecomponent \
+ qdeclarativeimage \
+ qdeclarativemetaproperty \
script \
-# qmltime
+# qdeclarativetime
diff --git a/tests/benchmarks/declarative/pointers/tst_pointers.cpp b/tests/benchmarks/declarative/pointers/tst_pointers.cpp
index 4fead9a3f9..7257bee118 100644
--- a/tests/benchmarks/declarative/pointers/tst_pointers.cpp
+++ b/tests/benchmarks/declarative/pointers/tst_pointers.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <qtest.h>
-#include "private/qmlguard_p.h"
+#include "private/qdeclarativeguard_p.h"
#include <QWeakPointer>
class tst_pointers : public QObject
@@ -59,7 +59,7 @@ void tst_pointers::qmlguard()
{
QObject *obj = new QObject;
QBENCHMARK {
- QmlGuard<QObject> guardedObject;
+ QDeclarativeGuard<QObject> guardedObject;
guardedObject = obj;
}
}
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/myqmlobject.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml
index 9c3f7f8281..9c3f7f8281 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/myqmlobject.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/myqmlobject_binding.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml
index e6cc4cf473..e6cc4cf473 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/myqmlobject_binding.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/object.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml
index 0d2d49b75c..0d2d49b75c 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/object.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/object_id.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml
index 69114afd47..69114afd47 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/object_id.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
index 723e62aa38..723e62aa38 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/BoomBlock.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/blueStar.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStar.png
index ff9588f80a..ff9588f80a 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/blueStar.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStar.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/blueStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png
index bf342e0362..bf342e0362 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/blueStone.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/greenStar.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStar.png
index cd06854719..cd06854719 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/greenStar.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStar.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/greenStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png
index 5ac14a5a81..5ac14a5a81 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/greenStone.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/redStar.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStar.png
index 0a4dffe583..0a4dffe583 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/redStar.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStar.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/redStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png
index b099f6007a..b099f6007a 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/redStone.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/yellowStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png
index c56124a895..c56124a895 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/samegame/pics/yellowStone.png
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/synthesized_properties.2.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml
index 27c5646f63..27c5646f63 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/synthesized_properties.2.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml
diff --git a/tests/benchmarks/declarative/qmlcomponent/data/synthesized_properties.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml
index d08f35bb54..d08f35bb54 100644
--- a/tests/benchmarks/declarative/qmlcomponent/data/synthesized_properties.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
new file mode 100644
index 0000000000..12fa9f4482
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
@@ -0,0 +1,19 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qdeclarativecomponent
+QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp
+HEADERS += testtypes.h
+
+symbian* {
+ data.sources = data/*
+ data.path = data
+ samegame.sources = data/samegame/*
+ samegame.path = data/samegame
+ samegame_pics.sources = data/samegame/pics/*
+ samegame_pics.path = data/samegame/pics
+ DEPLOYMENT += data samegame samegame_pics
+}
+
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp
new file mode 100644
index 0000000000..acdc395f5f
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
+
+void registerTypes()
+{
+ QML_REGISTER_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject);
+}
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h
new file mode 100644
index 0000000000..4b103ceb25
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtDeclarative/qdeclarative.h>
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int result READ result WRITE setResult);
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged);
+ Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged);
+ Q_PROPERTY(QDeclarativeList<QObject *> *data READ data);
+ Q_CLASSINFO("DefaultProperty", "data");
+public:
+ MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
+
+ int result() const { return m_result; }
+ void setResult(int r) { m_result = r; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; emit valueChanged(); }
+
+ QDeclarativeList<QObject *> *data() { return &m_data; }
+
+ MyQmlObject *object() const { return m_object; }
+ void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
+
+signals:
+ void valueChanged();
+ void objectChanged();
+
+private:
+ QDeclarativeConcreteList<QObject *> m_data;
+ int m_result;
+ int m_value;
+ MyQmlObject *m_object;
+};
+QML_DECLARE_TYPE(MyQmlObject);
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
new file mode 100644
index 0000000000..706530386c
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QFile>
+#include <QDebug>
+#include "testtypes.h"
+
+//TESTED_FILES=
+
+
+class tst_qmlcomponent : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qmlcomponent();
+ virtual ~tst_qmlcomponent();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private slots:
+ void creation_data();
+ void creation();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qmlcomponent::tst_qmlcomponent()
+{
+}
+
+tst_qmlcomponent::~tst_qmlcomponent()
+{
+}
+
+void tst_qmlcomponent::initTestCase()
+{
+ registerTypes();
+}
+
+void tst_qmlcomponent::cleanupTestCase()
+{
+}
+
+void tst_qmlcomponent::creation_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("Object") << "data/object.qml";
+ QTest::newRow("Object - Id") << "data/object_id.qml";
+ QTest::newRow("MyQmlObject") << "data/myqmlobject.qml";
+ QTest::newRow("MyQmlObject: basic binding") << "data/myqmlobject_binding.qml";
+ QTest::newRow("Synthesized properties") << "data/synthesized_properties.qml";
+ QTest::newRow("Synthesized properties.2") << "data/synthesized_properties.2.qml";
+ QTest::newRow("SameGame - BoomBlock") << "data/samegame/BoomBlock.qml";
+}
+
+void tst_qmlcomponent::creation()
+{
+ QFETCH(QString, file);
+
+ QDeclarativeComponent c(&engine, file);
+ QVERIFY(c.isReady());
+
+ QObject *obj = c.create();
+ delete obj;
+
+ QBENCHMARK {
+ QObject *obj = c.create();
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_qmlcomponent)
+#include "tst_qdeclarativecomponent.moc"
diff --git a/tests/benchmarks/declarative/qmlgraphicsimage/image.png b/tests/benchmarks/declarative/qdeclarativeimage/image.png
index 623d36233d..623d36233d 100644
--- a/tests/benchmarks/declarative/qmlgraphicsimage/image.png
+++ b/tests/benchmarks/declarative/qdeclarativeimage/image.png
Binary files differ
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
new file mode 100644
index 0000000000..bbe4e8d012
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qdeclarativeimage
+QT += declarative
+macx:CONFIG -= app_bundle
+CONFIG += release
+
+SOURCES += tst_qdeclarativeimage.cpp
+
+symbian* {
+ data.sources = image.png
+ data.path = .
+ DEPLOYMENT += data
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
new file mode 100644
index 0000000000..4bba022659
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <private/qdeclarativeimage_p.h>
+
+#ifdef Q_OS_SYMBIAN
+// In Symbian OS test data is located in applications private dir
+// Application private dir is default serach path for files, so SRCDIR can be set to empty
+#define SRCDIR ""
+#endif
+
+class tst_qmlgraphicsimage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlgraphicsimage() {}
+
+private slots:
+ void qmlgraphicsimage();
+ void qmlgraphicsimage_file();
+ void qmlgraphicsimage_url();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+void tst_qmlgraphicsimage::qmlgraphicsimage()
+{
+ int x = 0;
+ QUrl url("image.png");
+ QBENCHMARK {
+ QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
+ QDeclarativeImage *image = new QDeclarativeImage;
+ QDeclarativeEngine::setContextForObject(image, engine.rootContext());
+ delete image;
+ }
+}
+
+void tst_qmlgraphicsimage::qmlgraphicsimage_file()
+{
+ int x = 0;
+ QUrl url("image.png");
+ QBENCHMARK {
+ QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
+ QDeclarativeImage *image = new QDeclarativeImage;
+ QDeclarativeEngine::setContextForObject(image, engine.rootContext());
+ image->setSource(url);
+ delete image;
+ }
+}
+
+void tst_qmlgraphicsimage::qmlgraphicsimage_url()
+{
+ int x = 0;
+ QUrl url("image.png");
+ QBENCHMARK {
+ QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
+ QDeclarativeImage *image = new QDeclarativeImage;
+ QDeclarativeEngine::setContextForObject(image, engine.rootContext());
+ image->setSource(url2);
+ delete image;
+ }
+}
+
+QTEST_MAIN(tst_qmlgraphicsimage)
+
+#include "tst_qdeclarativeimage.moc"
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/data/object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml
index 11b95e1a06..11b95e1a06 100644
--- a/tests/benchmarks/declarative/qmlmetaproperty/data/object.qml
+++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/data/synthesized_object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml
index a923a0af4d..a923a0af4d 100644
--- a/tests/benchmarks/declarative/qmlmetaproperty/data/synthesized_object.qml
+++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
new file mode 100644
index 0000000000..80707680e6
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qdeclarativemetaproperty
+QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativemetaproperty.cpp
+
diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp
new file mode 100644
index 0000000000..dae175120e
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp
@@ -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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDeclarativeMetaProperty>
+#include <QFile>
+#include <QDebug>
+
+//TESTED_FILES=
+
+
+class tst_qmlmetaproperty : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qmlmetaproperty();
+ virtual ~tst_qmlmetaproperty();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void lookup_data();
+ void lookup();
+
+private:
+ QDeclarativeEngine engine;
+};
+
+tst_qmlmetaproperty::tst_qmlmetaproperty()
+{
+}
+
+tst_qmlmetaproperty::~tst_qmlmetaproperty()
+{
+}
+
+void tst_qmlmetaproperty::init()
+{
+}
+
+void tst_qmlmetaproperty::cleanup()
+{
+}
+
+void tst_qmlmetaproperty::lookup_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("Simple Object") << "data/object.qml";
+ QTest::newRow("Synthesized Object") << "data/synthesized_object.qml";
+}
+
+void tst_qmlmetaproperty::lookup()
+{
+ QFETCH(QString, file);
+
+ QDeclarativeComponent c(&engine, file);
+ QVERIFY(c.isReady());
+
+ QObject *obj = c.create();
+
+ QBENCHMARK {
+ QDeclarativeMetaProperty p(obj, "x");
+ }
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qmlmetaproperty)
+#include "tst_qdeclarativemetaproperty.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativetime/example.qml b/tests/benchmarks/declarative/qdeclarativetime/example.qml
new file mode 100644
index 0000000000..dd6185d8b8
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/example.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ property string name: "Bob Smith"
+
+ QDeclarativeTime.Timer {
+ component: Item {
+ Text { text: name }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp
new file mode 100644
index 0000000000..a9243373c4
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include <QApplication>
+#include <QTime>
+#include <QDeclarativeContext>
+#include <QGraphicsScene>
+#include <QGraphicsRectItem>
+
+class Timer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent);
+
+public:
+ Timer();
+
+ QDeclarativeComponent *component() const;
+ void setComponent(QDeclarativeComponent *);
+
+ static Timer *timerInstance();
+
+ void run(uint);
+
+ bool willParent() const;
+ void setWillParent(bool p);
+
+private:
+ void runTest(QDeclarativeContext *, uint);
+
+ QDeclarativeComponent *m_component;
+ static Timer *m_timer;
+
+ bool m_willparent;
+ QGraphicsScene m_scene;
+ QGraphicsRectItem m_item;
+};
+QML_DECLARE_TYPE(Timer);
+
+Timer *Timer::m_timer = 0;
+
+Timer::Timer()
+: m_component(0), m_willparent(false)
+{
+ if (m_timer)
+ qWarning("Timer: Timer already registered");
+ m_timer = this;
+
+ m_scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ m_scene.addItem(&m_item);
+}
+
+QDeclarativeComponent *Timer::component() const
+{
+ return m_component;
+}
+
+void Timer::setComponent(QDeclarativeComponent *c)
+{
+ m_component = c;
+}
+
+Timer *Timer::timerInstance()
+{
+ return m_timer;
+}
+
+void Timer::run(uint iterations)
+{
+ QDeclarativeContext context(qmlContext(this));
+
+ QObject *o = m_component->create(&context);
+ QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
+ if (m_willparent && go)
+ go->setParentItem(&m_item);
+ delete o;
+
+ runTest(&context, iterations);
+}
+
+bool Timer::willParent() const
+{
+ return m_willparent;
+}
+
+void Timer::setWillParent(bool p)
+{
+ m_willparent = p;
+}
+
+void Timer::runTest(QDeclarativeContext *context, uint iterations)
+{
+ QTime t;
+ t.start();
+ for (uint ii = 0; ii < iterations; ++ii) {
+ QObject *o = m_component->create(context);
+ QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
+ if (m_willparent && go)
+ go->setParentItem(&m_item);
+ delete o;
+ }
+
+ int e = t.elapsed();
+
+ qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms";
+
+}
+
+void usage(const char *name)
+{
+ qWarning("Usage: %s [-iterations <count>] [-parent] <qml file>", name);
+ exit(-1);
+}
+
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ QML_REGISTER_TYPE(QDeclarativeTime, 1, 0, Timer, Timer);
+
+ uint iterations = 1024;
+ QString filename;
+ bool willParent = false;
+
+ for (int ii = 1; ii < argc; ++ii) {
+ QByteArray arg(argv[ii]);
+
+ if (arg == "-iterations") {
+ if (ii + 1 < argc) {
+ ++ii;
+ QByteArray its(argv[ii]);
+ bool ok = false;
+ iterations = its.toUInt(&ok);
+ if (!ok)
+ usage(argv[0]);
+ } else {
+ usage(argv[0]);
+ }
+ } else if (arg == "-parent") {
+ willParent = true;
+ } else {
+ filename = QLatin1String(argv[ii]);
+ }
+ }
+
+ if (filename.isEmpty())
+#ifdef Q_OS_SYMBIAN
+ filename = QLatin1String("./tests/item_creation/data.qml");
+#else
+ usage(argv[0]);
+#endif
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, filename);
+ if (component.isError()) {
+ qWarning() << component.errors();
+ return -1;
+ }
+
+ QObject *obj = component.create();
+ if (!obj) {
+ qWarning() << component.errors();
+ return -1;
+ }
+
+ Timer *timer = Timer::timerInstance();
+ if (!timer) {
+ qWarning() << "A Tester.Timer instance is required.";
+ return -1;
+ }
+
+#ifdef Q_OS_SYMBIAN
+ willParent = true;
+#endif
+ timer->setWillParent(willParent);
+
+ if (!timer->component()) {
+ qWarning() << "The timer has no component";
+ return -1;
+ }
+
+#ifdef Q_OS_SYMBIAN
+ iterations = 1024;
+#endif
+
+ timer->run(iterations);
+
+ return 0;
+}
+
+#include "qdeclarativetime.moc"
diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro
new file mode 100644
index 0000000000..7902ee1d8c
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.pro
@@ -0,0 +1,23 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = qdeclarativetime
+QT += declarative
+macx:CONFIG -= app_bundle
+
+SOURCES += qdeclarativetime.cpp
+
+symbian* {
+ TARGET.CAPABILITY = "All -TCB"
+ example.sources = example.qml
+ esample.path = .
+ tests.sources = tests/*
+ tests.path = tests
+ anshors.sources = tests/anchors/*
+ anchors.path = tests/anchors
+ item_creation.sources = tests/item_creation/*
+ item_creation.path = tests/item_creation
+ positioner_creation.sources = tests/positioner_creation/*
+ positioner_creation.path = tests/positioner_creation
+ DEPLOYMENT += example tests anchors item_creation positioner_creation
+}
+
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml
new file mode 100644
index 0000000000..8d93594989
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/empty.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.leftMargin: 0
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml
new file mode 100644
index 0000000000..918c48ae80
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/fill.qml
@@ -0,0 +1,41 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ Item {
+ anchors.fill: parent
+ anchors.leftMargin: 0
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml
new file mode 100644
index 0000000000..bb845382ef
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/anchors/null.qml
@@ -0,0 +1,27 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ Item {
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml
new file mode 100644
index 0000000000..3387a32833
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/children.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ children: [
+ Rectangle { },
+ Rectangle { },
+ Item { },
+ Image { },
+ Text { },
+ Item { },
+ Item { },
+ Image { },
+ Image { },
+ Row { },
+ Image { },
+ Image { },
+ Column { },
+ Row { },
+ Text { },
+ Text { },
+ Text { },
+ MouseArea { }
+ ]
+
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml
new file mode 100644
index 0000000000..a8b653cfa9
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/data.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ data: [
+ Rectangle { },
+ Rectangle { },
+ Item { },
+ Image { },
+ Text { },
+ Item { },
+ Item { },
+ Image { },
+ Image { },
+ Row { },
+ Image { },
+ Image { },
+ Column { },
+ Row { },
+ Text { },
+ Text { },
+ Text { },
+ MouseArea { }
+ ]
+
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml
new file mode 100644
index 0000000000..0a507d4413
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/no_creation.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml
new file mode 100644
index 0000000000..227d8ad594
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/item_creation/resources.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ resources: [
+ Rectangle { },
+ Rectangle { },
+ Item { },
+ Image { },
+ Text { },
+ Item { },
+ Item { },
+ Image { },
+ Image { },
+ Row { },
+ Image { },
+ Image { },
+ Column { },
+ Row { },
+ Text { },
+ Text { },
+ Text { },
+ MouseArea { }
+ ]
+
+ }
+ }
+ }
+
+}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml
new file mode 100644
index 0000000000..c1f54a41e7
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/no_positioner.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ Rectangle { }
+ Rectangle { }
+ Item {
+ Image { }
+ Text { }
+ }
+
+ Item {
+ Item {
+ Image { }
+ Image { }
+ Item {
+ Image { }
+ Image { }
+ }
+ }
+
+ Item {
+ Item {
+ Text { }
+ Text { }
+ }
+ Text { }
+ }
+ }
+ MouseArea { }
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml
new file mode 100644
index 0000000000..d49ff78024
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/null_positioner.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ Rectangle { }
+ Rectangle { }
+ Item {
+ Image { }
+ Text { }
+ }
+
+ Item {
+ Item {
+ Image { }
+ Image { }
+ Row { }
+ Image { }
+ Image { }
+ }
+
+ Column { }
+ Row { }
+ Text { }
+ Text { }
+ Text { }
+ }
+ MouseArea { }
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml
new file mode 100644
index 0000000000..05ca8044de
--- /dev/null
+++ b/tests/benchmarks/declarative/qdeclarativetime/tests/positioner_creation/positioner.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+import QDeclarativeTime 1.0 as QDeclarativeTime
+
+Item {
+ QDeclarativeTime.Timer {
+ component: Component {
+ Item {
+ Rectangle { }
+ Rectangle { }
+ Item {
+ Image { }
+ Text { }
+ }
+
+ Item {
+ Item {
+ Image { }
+ Image { }
+ Row {
+ Image { }
+ Image { }
+ }
+ }
+
+ Column {
+ Row {
+ Text { }
+ Text { }
+ }
+ Text { }
+ }
+ }
+ MouseArea { }
+ }
+ }
+ }
+}
diff --git a/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro b/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro
deleted file mode 100644
index 6a86f58331..0000000000
--- a/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-load(qttest_p4)
-TEMPLATE = app
-TARGET = tst_qmlcomponent
-QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlcomponent.cpp testtypes.cpp
-HEADERS += testtypes.h
-
diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp
deleted file mode 100644
index f0bc1f9809..0000000000
--- a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp
+++ /dev/null
@@ -1,43 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "testtypes.h"
-
-QML_DEFINE_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject);
diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.h b/tests/benchmarks/declarative/qmlcomponent/testtypes.h
deleted file mode 100644
index d4e0a1a935..0000000000
--- a/tests/benchmarks/declarative/qmlcomponent/testtypes.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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qml.h>
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int result READ result WRITE setResult);
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged);
- Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged);
- Q_PROPERTY(QmlList<QObject *> *data READ data);
- Q_CLASSINFO("DefaultProperty", "data");
-public:
- MyQmlObject() : m_result(0), m_value(0), m_object(0) {}
-
- int result() const { return m_result; }
- void setResult(int r) { m_result = r; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; emit valueChanged(); }
-
- QmlList<QObject *> *data() { return &m_data; }
-
- MyQmlObject *object() const { return m_object; }
- void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); }
-
-signals:
- void valueChanged();
- void objectChanged();
-
-private:
- QmlConcreteList<QObject *> m_data;
- int m_result;
- int m_value;
- MyQmlObject *m_object;
-};
-QML_DECLARE_TYPE(MyQmlObject);
-
-#endif // TESTTYPES_H
diff --git a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp
deleted file mode 100644
index 647edbf057..0000000000
--- a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp
+++ /dev/null
@@ -1,118 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QFile>
-#include <QDebug>
-#include "testtypes.h"
-
-//TESTED_FILES=
-
-
-class tst_qmlcomponent : public QObject
-{
- Q_OBJECT
-
-public:
- tst_qmlcomponent();
- virtual ~tst_qmlcomponent();
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void creation_data();
- void creation();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlcomponent::tst_qmlcomponent()
-{
-}
-
-tst_qmlcomponent::~tst_qmlcomponent()
-{
-}
-
-void tst_qmlcomponent::init()
-{
-}
-
-void tst_qmlcomponent::cleanup()
-{
-}
-
-void tst_qmlcomponent::creation_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("Object") << "data/object.qml";
- QTest::newRow("Object - Id") << "data/object_id.qml";
- QTest::newRow("MyQmlObject") << "data/myqmlobject.qml";
- QTest::newRow("MyQmlObject: basic binding") << "data/myqmlobject_binding.qml";
- QTest::newRow("Synthesized properties") << "data/synthesized_properties.qml";
- QTest::newRow("Synthesized properties.2") << "data/synthesized_properties.2.qml";
- QTest::newRow("SameGame - BoomBlock") << "data/samegame/BoomBlock.qml";
-}
-
-void tst_qmlcomponent::creation()
-{
- QFETCH(QString, file);
-
- QmlComponent c(&engine, file);
- QVERIFY(c.isReady());
-
- QObject *obj = c.create();
- delete obj;
-
- QBENCHMARK {
- QObject *obj = c.create();
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_qmlcomponent)
-#include "tst_qmlcomponent.moc"
diff --git a/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro b/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro
deleted file mode 100644
index 449d87420f..0000000000
--- a/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-load(qttest_p4)
-TEMPLATE = app
-TARGET = tst_qmlgraphicsimage
-QT += declarative
-macx:CONFIG -= app_bundle
-CONFIG += release
-
-SOURCES += tst_qmlgraphicsimage.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
diff --git a/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
deleted file mode 100644
index 7d7d24e940..0000000000
--- a/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <private/qmlgraphicsimage_p.h>
-
-class tst_qmlgraphicsimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsimage() {}
-
-private slots:
- void qmlgraphicsimage();
- void qmlgraphicsimage_file();
- void qmlgraphicsimage_url();
-
-private:
- QmlEngine engine;
-};
-
-void tst_qmlgraphicsimage::qmlgraphicsimage()
-{
- int x = 0;
- QUrl url("image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QmlGraphicsImage *image = new QmlGraphicsImage;
- QmlEngine::setContextForObject(image, engine.rootContext());
- delete image;
- }
-}
-
-void tst_qmlgraphicsimage::qmlgraphicsimage_file()
-{
- int x = 0;
- QUrl url("image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QmlGraphicsImage *image = new QmlGraphicsImage;
- QmlEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url);
- delete image;
- }
-}
-
-void tst_qmlgraphicsimage::qmlgraphicsimage_url()
-{
- int x = 0;
- QUrl url("image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QmlGraphicsImage *image = new QmlGraphicsImage;
- QmlEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url2);
- delete image;
- }
-}
-
-QTEST_MAIN(tst_qmlgraphicsimage)
-
-#include "tst_qmlgraphicsimage.moc"
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro b/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro
deleted file mode 100644
index c18a56b006..0000000000
--- a/tests/benchmarks/declarative/qmlmetaproperty/qmlmetaproperty.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-TEMPLATE = app
-TARGET = tst_qmlmetaproperty
-QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlmetaproperty.cpp
-
diff --git a/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
deleted file mode 100644
index 4c002f856a..0000000000
--- a/tests/benchmarks/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ /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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <QmlMetaProperty>
-#include <QFile>
-#include <QDebug>
-
-//TESTED_FILES=
-
-
-class tst_qmlmetaproperty : public QObject
-{
- Q_OBJECT
-
-public:
- tst_qmlmetaproperty();
- virtual ~tst_qmlmetaproperty();
-
-public slots:
- void init();
- void cleanup();
-
-private slots:
- void lookup_data();
- void lookup();
-
-private:
- QmlEngine engine;
-};
-
-tst_qmlmetaproperty::tst_qmlmetaproperty()
-{
-}
-
-tst_qmlmetaproperty::~tst_qmlmetaproperty()
-{
-}
-
-void tst_qmlmetaproperty::init()
-{
-}
-
-void tst_qmlmetaproperty::cleanup()
-{
-}
-
-void tst_qmlmetaproperty::lookup_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("Simple Object") << "data/object.qml";
- QTest::newRow("Synthesized Object") << "data/synthesized_object.qml";
-}
-
-void tst_qmlmetaproperty::lookup()
-{
- QFETCH(QString, file);
-
- QmlComponent c(&engine, file);
- QVERIFY(c.isReady());
-
- QObject *obj = c.create();
-
- QBENCHMARK {
- QmlMetaProperty p(obj, "x");
- }
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qmlmetaproperty)
-#include "tst_qmlmetaproperty.moc"
diff --git a/tests/benchmarks/declarative/qmltime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml
deleted file mode 100644
index 68889f0819..0000000000
--- a/tests/benchmarks/declarative/qmltime/example.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- property string name: "Bob Smith"
-
- QmlTime.Timer {
- component: Item {
- Text { text: name }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp
deleted file mode 100644
index 2cc5d0de9c..0000000000
--- a/tests/benchmarks/declarative/qmltime/qmltime.cpp
+++ /dev/null
@@ -1,219 +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 test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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>
-#include <QmlComponent>
-#include <QDebug>
-#include <QApplication>
-#include <QTime>
-#include <QmlContext>
-#include <QGraphicsScene>
-#include <QGraphicsRectItem>
-
-class Timer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QmlComponent *component READ component WRITE setComponent);
-
-public:
- Timer();
-
- QmlComponent *component() const;
- void setComponent(QmlComponent *);
-
- static Timer *timerInstance();
-
- void run(uint);
-
- bool willParent() const;
- void setWillParent(bool p);
-
-private:
- void runTest(QmlContext *, uint);
-
- QmlComponent *m_component;
- static Timer *m_timer;
-
- bool m_willparent;
- QGraphicsScene m_scene;
- QGraphicsRectItem m_item;
-};
-QML_DECLARE_TYPE(Timer);
-QML_DEFINE_TYPE(QmlTime, 1, 0, Timer, Timer);
-
-Timer *Timer::m_timer = 0;
-
-Timer::Timer()
-: m_component(0), m_willparent(false)
-{
- if (m_timer)
- qWarning("Timer: Timer already registered");
- m_timer = this;
-
- m_scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- m_scene.addItem(&m_item);
-}
-
-QmlComponent *Timer::component() const
-{
- return m_component;
-}
-
-void Timer::setComponent(QmlComponent *c)
-{
- m_component = c;
-}
-
-Timer *Timer::timerInstance()
-{
- return m_timer;
-}
-
-void Timer::run(uint iterations)
-{
- QmlContext context(qmlContext(this));
-
- QObject *o = m_component->create(&context);
- QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
- if (m_willparent && go)
- go->setParentItem(&m_item);
- delete o;
-
- runTest(&context, iterations);
-}
-
-bool Timer::willParent() const
-{
- return m_willparent;
-}
-
-void Timer::setWillParent(bool p)
-{
- m_willparent = p;
-}
-
-void Timer::runTest(QmlContext *context, uint iterations)
-{
- QTime t;
- t.start();
- for (uint ii = 0; ii < iterations; ++ii) {
- QObject *o = m_component->create(context);
- QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o);
- if (m_willparent && go)
- go->setParentItem(&m_item);
- delete o;
- }
-
- int e = t.elapsed();
-
- qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms";
-
-}
-
-void usage(const char *name)
-{
- qWarning("Usage: %s [-iterations <count>] [-parent] <qml file>", name);
- exit(-1);
-}
-
-int main(int argc, char ** argv)
-{
- QApplication app(argc, argv);
-
- uint iterations = 1024;
- QString filename;
- bool willParent = false;
-
- for (int ii = 1; ii < argc; ++ii) {
- QByteArray arg(argv[ii]);
-
- if (arg == "-iterations") {
- if (ii + 1 < argc) {
- ++ii;
- QByteArray its(argv[ii]);
- bool ok = false;
- iterations = its.toUInt(&ok);
- if (!ok)
- usage(argv[0]);
- } else {
- usage(argv[0]);
- }
- } else if (arg == "-parent") {
- willParent = true;
- } else {
- filename = QLatin1String(argv[ii]);
- }
- }
-
- if (filename.isEmpty())
- usage(argv[0]);
-
- QmlEngine engine;
- QmlComponent component(&engine, filename);
- if (component.isError()) {
- qWarning() << component.errors();
- return -1;
- }
-
- QObject *obj = component.create();
- if (!obj) {
- qWarning() << component.errors();
- return -1;
- }
-
- Timer *timer = Timer::timerInstance();
- if (!timer) {
- qWarning() << "A Tester.Timer instance is required.";
- return -1;
- }
-
- timer->setWillParent(willParent);
-
- if (!timer->component()) {
- qWarning() << "The timer has no component";
- return -1;
- }
-
- timer->run(iterations);
-
- return 0;
-}
-
-#include "qmltime.moc"
diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro
deleted file mode 100644
index b077d1a38a..0000000000
--- a/tests/benchmarks/declarative/qmltime/qmltime.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-load(qttest_p4)
-TEMPLATE = app
-TARGET = qmltime
-QT += declarative
-macx:CONFIG -= app_bundle
-
-SOURCES += qmltime.cpp
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml
deleted file mode 100644
index 31c879bfa5..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- Item {
- anchors.leftMargin: 0
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml
deleted file mode 100644
index 23fe78e29f..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- Item {
- anchors.fill: parent
- anchors.leftMargin: 0
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml
deleted file mode 100644
index bc447efedf..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- Item {
- }
- }
- }
- }
-}
-
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
deleted file mode 100644
index 996602cfb7..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- children: [
- Rectangle { },
- Rectangle { },
- Item { },
- Image { },
- Text { },
- Item { },
- Item { },
- Image { },
- Image { },
- Row { },
- Image { },
- Image { },
- Column { },
- Row { },
- Text { },
- Text { },
- Text { },
- MouseArea { }
- ]
-
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
deleted file mode 100644
index 9f79c347bf..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- data: [
- Rectangle { },
- Rectangle { },
- Item { },
- Image { },
- Text { },
- Item { },
- Item { },
- Image { },
- Image { },
- Row { },
- Image { },
- Image { },
- Column { },
- Row { },
- Text { },
- Text { },
- Text { },
- MouseArea { }
- ]
-
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml
deleted file mode 100644
index f228c2af00..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
deleted file mode 100644
index 335aeb873d..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
-
- QmlTime.Timer {
- component: Component {
- Item {
- resources: [
- Rectangle { },
- Rectangle { },
- Item { },
- Image { },
- Text { },
- Item { },
- Item { },
- Image { },
- Image { },
- Row { },
- Image { },
- Image { },
- Column { },
- Row { },
- Text { },
- Text { },
- Text { },
- MouseArea { }
- ]
-
- }
- }
- }
-
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
deleted file mode 100644
index 97bad47f92..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
- QmlTime.Timer {
- component: Component {
- Item {
- Rectangle { }
- Rectangle { }
- Item {
- Image { }
- Text { }
- }
-
- Item {
- Item {
- Image { }
- Image { }
- Item {
- Image { }
- Image { }
- }
- }
-
- Item {
- Item {
- Text { }
- Text { }
- }
- Text { }
- }
- }
- MouseArea { }
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
deleted file mode 100644
index 36dda15539..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
- QmlTime.Timer {
- component: Component {
- Item {
- Rectangle { }
- Rectangle { }
- Item {
- Image { }
- Text { }
- }
-
- Item {
- Item {
- Image { }
- Image { }
- Row { }
- Image { }
- Image { }
- }
-
- Column { }
- Row { }
- Text { }
- Text { }
- Text { }
- }
- MouseArea { }
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
deleted file mode 100644
index 396e27dd83..0000000000
--- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import Qt 4.6
-import QmlTime 1.0 as QmlTime
-
-Item {
- QmlTime.Timer {
- component: Component {
- Item {
- Rectangle { }
- Rectangle { }
- Item {
- Image { }
- Text { }
- }
-
- Item {
- Item {
- Image { }
- Image { }
- Row {
- Image { }
- Image { }
- }
- }
-
- Column {
- Row {
- Text { }
- Text { }
- }
- Text { }
- }
- }
- MouseArea { }
- }
- }
- }
-}
diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro
index 48fea81b73..6255acc27e 100644
--- a/tests/benchmarks/declarative/script/script.pro
+++ b/tests/benchmarks/declarative/script/script.pro
@@ -7,5 +7,14 @@ CONFIG += release
SOURCES += tst_script.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
+symbian* {
+ data.sources = data/*
+ data.path = data
+ DEPLOYMENT += data
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
+
+
+
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index dd21997836..61f5fc8457 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -40,14 +40,20 @@
****************************************************************************/
#include <qtest.h>
-#include <QmlEngine>
-#include <QmlComponent>
-#include <private/qmlengine_p.h>
-#include <private/qmlobjectscriptclass_p.h>
-#include <private/qmlgraphicsrectangle_p.h>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <private/qdeclarativeengine_p.h>
+#include <private/qdeclarativeobjectscriptclass_p.h>
+#include <private/qdeclarativerectangle_p.h>
#include <QScriptEngine>
#include <QScriptValue>
+#ifdef Q_OS_SYMBIAN
+// In Symbian OS test data is located in applications private dir
+// Application private dir is default serach path for files, so SRCDIR can be set to empty
+#define SRCDIR "."
+#endif
+
class tst_script : public QObject
{
Q_OBJECT
@@ -55,6 +61,8 @@ public:
tst_script() {}
private slots:
+ void initTestCase();
+
void property_js();
void property_getter();
void property_getter_js();
@@ -88,6 +96,11 @@ private slots:
private:
};
+void tst_script::initTestCase()
+{
+ QML_REGISTER_TYPE(Qt.test, 1, 0, TestObject, TestObject);
+}
+
inline QUrl TEST_FILE(const QString &filename)
{
return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
@@ -123,7 +136,6 @@ private:
int m_x;
};
QML_DECLARE_TYPE(TestObject);
-QML_DEFINE_TYPE(Qt.test, 1, 0, TestObject, TestObject);
TestObject::TestObject(QObject *parent)
: QObject(parent), m_x(0)
@@ -289,12 +301,12 @@ void tst_script::property_qobject()
void tst_script::property_qmlobject()
{
- QmlEngine qmlengine;
+ QDeclarativeEngine qmlengine;
- QScriptEngine *engine = QmlEnginePrivate::getScriptEngine(&qmlengine);
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
- QScriptValue v = QmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+ QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
QScriptValueList args;
args << v;
@@ -373,12 +385,12 @@ void tst_script::function_qobject()
void tst_script::function_qmlobject()
{
- QmlEngine qmlengine;
+ QDeclarativeEngine qmlengine;
- QScriptEngine *engine = QmlEnginePrivate::getScriptEngine(&qmlengine);
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
- QScriptValue v = QmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+ QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
QScriptValueList args;
args << v;
@@ -457,12 +469,12 @@ void tst_script::function_args_qobject()
void tst_script::function_args_qmlobject()
{
- QmlEngine qmlengine;
+ QDeclarativeEngine qmlengine;
- QScriptEngine *engine = QmlEnginePrivate::getScriptEngine(&qmlengine);
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
- QScriptValue v = QmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+ QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
QScriptValueList args;
args << v;
@@ -476,8 +488,8 @@ void tst_script::function_args_qmlobject()
void tst_script::signal_unconnected()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("signal_unconnected.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("signal_unconnected.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -490,8 +502,8 @@ void tst_script::signal_unconnected()
void tst_script::signal_qml()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("signal_qml.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("signal_qml.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -504,8 +516,8 @@ void tst_script::signal_qml()
void tst_script::signal_args()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("signal_args.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("signal_args.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -518,8 +530,8 @@ void tst_script::signal_args()
void tst_script::signal_unusedArgs()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("signal_unusedArgs.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("signal_unusedArgs.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -532,8 +544,8 @@ void tst_script::signal_unusedArgs()
void tst_script::slot_simple()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("slot_simple.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("slot_simple.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -546,8 +558,8 @@ void tst_script::slot_simple()
void tst_script::slot_simple_js()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("slot_simple_js.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("slot_simple_js.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -560,8 +572,8 @@ void tst_script::slot_simple_js()
void tst_script::slot_complex()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("slot_complex.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("slot_complex.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -574,8 +586,8 @@ void tst_script::slot_complex()
void tst_script::slot_complex_js()
{
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("slot_complex_js.qml"));
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("slot_complex_js.qml"));
TestObject *object = qobject_cast<TestObject *>(component.create());
QVERIFY(object != 0);
@@ -597,9 +609,9 @@ void tst_script::block_data()
void tst_script::block()
{
QFETCH(QString, methodName);
- QmlEngine engine;
- QmlComponent component(&engine, TEST_FILE("block.qml"));
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle *>(component.create());
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("block.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create());
QVERIFY(rect != 0);
int index = rect->metaObject()->indexOfMethod(methodName.toUtf8());
diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp
index b904f407f3..2c1274c5e8 100644
--- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp
+++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/main.cpp
@@ -751,7 +751,7 @@ int main(int argc, char *argv[])
aargv[aargc++] = argv[i];
}
- QApplication app(argc, argv);
+ QApplication app(aargc, aargv);
int returnValue = 0;
if (settings.options() & Settings::ManualTest) {
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
index 1028f42d6a..6c4ca08295 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
@@ -42,7 +42,14 @@
#include "view.h"
#include <QtGui>
+
+#ifdef Q_WS_WIN
+#define CALLGRIND_START_INSTRUMENTATION {}
+#define CALLGRIND_STOP_INSTRUMENTATION {}
+#else
#include "valgrind/callgrind.h"
+#endif
+
#ifndef QT_NO_OPENGL
#include <QtOpenGL>
#endif
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
index 527713f5e6..63b0da956c 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
@@ -39,7 +39,13 @@
**
****************************************************************************/
#include <QtGui>
+
+#ifdef Q_WS_WIN
+#define CALLGRIND_START_INSTRUMENTATION {}
+#define CALLGRIND_STOP_INSTRUMENTATION {}
+#else
#include "valgrind/callgrind.h"
+#endif
#ifdef Q_WS_X11
extern void qt_x11_wait_for_window_manager(QWidget *);
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
index 7419206c5a..3f303938a4 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
@@ -39,7 +39,13 @@
**
****************************************************************************/
#include <QtGui>
+
+#ifdef Q_WS_WIN
+#define CALLGRIND_START_INSTRUMENTATION {}
+#define CALLGRIND_STOP_INSTRUMENTATION {}
+#else
#include "valgrind/callgrind.h"
+#endif
class ItemMover : public QObject
{
diff --git a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
index f21bd44222..8c30be4294 100644
--- a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
@@ -42,33 +42,35 @@
#include <qtest.h>
#include <QtGui>
-class tst_QWidget : public QObject
+static void processEvents()
{
- Q_OBJECT
-
-
-private slots:
- void update_data();
- void updateOpaque_data();
- void updateOpaque();
- void updateTransparent_data();
- void updateTransparent();
- void updatePartial_data();
- void updatePartial();
- void updateComplex_data();
- void updateComplex();
-
- void complexToplevelResize();
-};
+ QApplication::flush();
+ QApplication::processEvents();
+ QApplication::processEvents();
+}
class UpdateWidget : public QWidget
{
public:
- UpdateWidget(int rows, int columns) : QWidget(0)
+ UpdateWidget(int rows, int columns)
+ : QWidget(0), rowCount(0), columnCount(0), opaqueChildren(false)
{
+ fill(rows, columns);
+ }
+
+ UpdateWidget(QWidget *parent = 0)
+ : QWidget(parent), rowCount(0), columnCount(0), opaqueChildren(false) {}
+
+ void fill(int rows, int columns)
+ {
+ if (rows == rowCount && columns == columnCount)
+ return;
+ delete layout();
QGridLayout *layout = new QGridLayout;
- for (int row = 0; row < rows; ++row) {
- for (int column = 0; column < columns; ++column) {
+ rowCount = rows;
+ columnCount = columns;
+ for (int row = 0; row < rowCount; ++row) {
+ for (int column = 0; column < columnCount; ++column) {
UpdateWidget *widget = new UpdateWidget;
widget->setFixedSize(20, 20);
layout->addWidget(widget, row, column);
@@ -76,9 +78,20 @@ public:
}
}
setLayout(layout);
+ adjustSize();
+ QTest::qWait(250);
+ processEvents();
}
- UpdateWidget(QWidget *parent = 0) : QWidget(parent) {}
+ void setOpaqueChildren(bool enable)
+ {
+ if (opaqueChildren != enable) {
+ foreach (QWidget *w, children)
+ w->setAttribute(Qt::WA_OpaquePaintEvent, enable);
+ opaqueChildren = enable;
+ processEvents();
+ }
+ }
void paintEvent(QPaintEvent *)
{
@@ -93,75 +106,86 @@ public:
QRegion updateRegion;
QList<UpdateWidget*> children;
+ int rowCount;
+ int columnCount;
+ bool opaqueChildren;
};
-void tst_QWidget::update_data()
+class tst_QWidget : public QObject
{
- QTest::addColumn<int>("rows");
- QTest::addColumn<int>("columns");
- QTest::addColumn<int>("numUpdates");
-
- QTest::newRow("10x10x1") << 10 << 10 << 1;
- QTest::newRow("10x10x10") << 10 << 10 << 10;
- QTest::newRow("25x25x1") << 25 << 25 << 1;
- QTest::newRow("25x25x10") << 25 << 25 << 10;
- QTest::newRow("25x25x100") << 25 << 25 << 100;
-}
+ Q_OBJECT
-void tst_QWidget::updateOpaque_data()
-{
- update_data();
-}
+public slots:
+ void initTestCase();
+ void init();
-void tst_QWidget::updateOpaque()
-{
- QFETCH(int, rows);
- QFETCH(int, columns);
- QFETCH(int, numUpdates);
+private slots:
+ void update_data();
+ void update();
+ void updatePartial_data();
+ void updatePartial();
+ void updateComplex_data();
+ void updateComplex();
- UpdateWidget widget(rows, columns);
- foreach (QWidget *w, widget.children) {
- w->setAttribute(Qt::WA_OpaquePaintEvent);
- }
+private:
+ UpdateWidget widget;
+};
+void tst_QWidget::initTestCase()
+{
widget.show();
- QApplication::processEvents();
+ QTest::qWaitForWindowShown(&widget);
+ QTest::qWait(300);
+ processEvents();
+}
- int i = 0;
- const int n = widget.children.size();
- QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
- widget.children[i]->update();
- QApplication::processEvents();
- i = (i + 1) % n;
- }
- }
+void tst_QWidget::init()
+{
+ QVERIFY(widget.isVisible());
+ for (int i = 0; i < 3; ++i)
+ processEvents();
}
-void tst_QWidget::updateTransparent_data()
+void tst_QWidget::update_data()
{
- update_data();
+ QTest::addColumn<int>("rows");
+ QTest::addColumn<int>("columns");
+ QTest::addColumn<int>("numUpdates");
+ QTest::addColumn<bool>("opaque");
+
+ QTest::newRow("10x10x1 transparent") << 10 << 10 << 1 << false;
+ QTest::newRow("10x10x10 transparent") << 10 << 10 << 10 << false;
+ QTest::newRow("10x10x100 transparent") << 10 << 10 << 100 << false;
+ QTest::newRow("10x10x1 opaque") << 10 << 10 << 1 << true;
+ QTest::newRow("10x10x10 opaque") << 10 << 10 << 10 << true;
+ QTest::newRow("10x10x100 opaque") << 10 << 10 << 100 << true;
+ QTest::newRow("25x25x1 transparent ") << 25 << 25 << 1 << false;
+ QTest::newRow("25x25x10 transparent") << 25 << 25 << 10 << false;
+ QTest::newRow("25x25x100 transparent") << 25 << 25 << 100 << false;
+ QTest::newRow("25x25x1 opaque") << 25 << 25 << 1 << true;
+ QTest::newRow("25x25x10 opaque") << 25 << 25 << 10 << true;
+ QTest::newRow("25x25x100 opaque") << 25 << 25 << 100 << true;
}
-void tst_QWidget::updateTransparent()
+void tst_QWidget::update()
{
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, numUpdates);
+ QFETCH(bool, opaque);
- UpdateWidget widget(rows, columns);
- widget.show();
- QApplication::processEvents();
+ widget.fill(rows, columns);
+ widget.setOpaqueChildren(opaque);
- int i = 0;
- const int n = widget.children.size();
QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
- widget.children[i]->update();
+ for (int i = 0; i < widget.children.size(); ++i) {
+ for (int j = 0; j < numUpdates; ++j)
+ widget.children.at(i)->update();
QApplication::processEvents();
- i = (i + 1) % n;
}
}
+
+ QApplication::flush();
}
void tst_QWidget::updatePartial_data()
@@ -174,24 +198,23 @@ void tst_QWidget::updatePartial()
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, numUpdates);
+ QFETCH(bool, opaque);
- UpdateWidget widget(rows, columns);
- widget.show();
- QApplication::processEvents();
+ widget.fill(rows, columns);
+ widget.setOpaqueChildren(opaque);
- int i = 0;
- const int n = widget.children.size();
QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
+ for (int i = 0; i < widget.children.size(); ++i) {
QWidget *w = widget.children[i];
const int x = w->width() / 2;
const int y = w->height() / 2;
- w->update(0, 0, x, y);
- w->update(x, 0, x, y);
- w->update(0, y, x, y);
- w->update(x, y, x, y);
+ for (int j = 0; j < numUpdates; ++j) {
+ w->update(0, 0, x, y);
+ w->update(x, 0, x, y);
+ w->update(0, y, x, y);
+ w->update(x, y, x, y);
+ }
QApplication::processEvents();
- i = (i + 1) % n;
}
}
}
@@ -206,127 +229,27 @@ void tst_QWidget::updateComplex()
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, numUpdates);
+ QFETCH(bool, opaque);
- UpdateWidget widget(rows, columns);
- widget.show();
- QApplication::processEvents();
+ widget.fill(rows, columns);
+ widget.setOpaqueChildren(opaque);
- int i = 0;
- const int n = widget.children.size();
QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
+ for (int i = 0; i < widget.children.size(); ++i) {
QWidget *w = widget.children[i];
const int x = w->width() / 2;
const int y = w->height() / 2;
- w->update(QRegion(0, 0, x, y, QRegion::Ellipse));
- w->update(QRegion(x, y, x, y, QRegion::Ellipse));
+ QRegion r1(0, 0, x, y, QRegion::Ellipse);
+ QRegion r2(x, y, x, y, QRegion::Ellipse);
+ for (int j = 0; j < numUpdates; ++j) {
+ w->update(r1);
+ w->update(r2);
+ }
QApplication::processEvents();
- i = (i + 1) % n;
}
}
}
-class ResizeWidget : public QWidget
-{
-public:
- ResizeWidget();
-};
-
-ResizeWidget::ResizeWidget() : QWidget(0)
-{
- QBoxLayout *topLayout = new QVBoxLayout;
-
- QMenuBar *menubar = new QMenuBar;
- QMenu* popup = menubar->addMenu("&File");
- popup->addAction("&Quit", qApp, SLOT(quit()));
- topLayout->setMenuBar(menubar);
-
- QBoxLayout *buttons = new QHBoxLayout;
- buttons->setMargin(5);
- buttons->addStretch(10);
- for (int i = 1; i <= 4; i++ ) {
- QPushButton* button = new QPushButton;
- button->setText(QString("Button %1").arg(i));
- buttons->addWidget(button);
- }
- topLayout->addLayout(buttons);
-
- buttons = new QHBoxLayout;
- buttons->addStretch(10);
- for (int i = 11; i <= 16; i++) {
- QPushButton* button = new QPushButton;
- button->setText(QString("Button %1").arg(i));
- buttons->addWidget(button);
- }
- topLayout->addLayout(buttons);
-
- QBoxLayout *buttons2 = new QHBoxLayout;
- buttons2->addStretch(10);
- topLayout->addLayout(buttons2);
-
- QPushButton *button = new QPushButton;
- button->setText("Button five");
- buttons2->addWidget(button);
-
- button = new QPushButton;
- button->setText("Button 6");
- buttons2->addWidget(button);
-
- QTextEdit *bigWidget = new QTextEdit;
- bigWidget->setText("This widget will get all the remaining space");
- bigWidget->setFrameStyle(QFrame::Panel | QFrame::Plain);
- topLayout->addWidget(bigWidget);
-
- const int numRows = 6;
- const int labelCol = 0;
- const int linedCol = 1;
- const int multiCol = 2;
-
- QGridLayout *grid = new QGridLayout;
- for (int row = 0; row < numRows; row++) {
- QLineEdit *lineEdit = new QLineEdit;
- grid->addWidget(lineEdit, row, linedCol);
- QLabel *label = new QLabel(QString("Line &%1").arg(row + 1));
- grid->addWidget(label, row, labelCol);
- }
- topLayout->addLayout(grid);
-
- QTextEdit *multiLineEdit = new QTextEdit;
- grid->addWidget(multiLineEdit, 0, labelCol + 1, multiCol, multiCol);
-
- grid->setColumnStretch(linedCol, 10);
- grid->setColumnStretch(multiCol, 20);
-
- QLabel* statusBar = new QLabel;
- statusBar->setText("Let's pretend this is a status bar");
- statusBar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
- statusBar->setFixedHeight(statusBar->sizeHint().height());
- statusBar->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
- topLayout->addWidget(statusBar);
-
- topLayout->activate();
- setLayout(topLayout);
-}
-
-void tst_QWidget::complexToplevelResize()
-{
- ResizeWidget w;
- w.show();
-
- QApplication::processEvents();
-
- const int minSize = 100;
- const int maxSize = 800;
- int size = minSize;
-
- QBENCHMARK {
- w.resize(size, size);
- size = qMax(minSize, (size + 10) % maxSize);
- QApplication::processEvents();
- QApplication::processEvents();
- }
-}
-
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
index 39b2244eaf..d570bb3aa8 100644
--- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp
@@ -1395,7 +1395,7 @@ void tst_QPainter::drawTransformedImageRoundedRect()
}
}
-//code from QmlGraphicsRectangle for drawing rounded rects
+//code from QDeclarativeRectangle for drawing rounded rects
void tst_QPainter::drawBorderPixmapRoundedRect()
{
//setup image
@@ -1446,7 +1446,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect_data()
// QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB8565_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB8565_Premultiplied;
}
-//code from QmlGraphicsRectangle for drawing rounded rects
+//code from QDeclarativeRectangle for drawing rounded rects
void tst_QPainter::drawScaledBorderPixmapRoundedRect()
{
QFETCH(float, scale);
@@ -1502,7 +1502,7 @@ void tst_QPainter::drawTransformedBorderPixmapRoundedRect_data()
}
-//code from QmlGraphicsRectangle for drawing rounded rects
+//code from QDeclarativeRectangle for drawing rounded rects
void tst_QPainter::drawTransformedBorderPixmapRoundedRect()
{
QFETCH(QTransform, transform);
diff --git a/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp b/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp
index 226b6615ff..d051b12989 100644
--- a/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp
+++ b/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp
@@ -82,6 +82,7 @@ void tst_qstylesheetstyle::empty()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet("/*" + QString::number(i) + "*/");
@@ -94,6 +95,7 @@ void tst_qstylesheetstyle::empty_events()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet("/*" + QString::number(i) + "*/");
@@ -112,6 +114,7 @@ void tst_qstylesheetstyle::simple()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet(QString(simple_css) + "/*" + QString::number(i) + "*/");
@@ -124,6 +127,7 @@ void tst_qstylesheetstyle::simple_events()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet(QString(simple_css) + "/*" + QString::number(i) + "*/");
@@ -175,8 +179,13 @@ void tst_qstylesheetstyle::grid()
w->setStyleSheet("/* */");
if(show) {
w->show();
+ QTest::qWaitForWindowShown(w);
+ QApplication::flush();
+ QApplication::processEvents();
QTest::qWait(30);
+ QApplication::processEvents();
}
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet(stylesheet + "/*" + QString::number(i) + "*/");
diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro
index 99d1935921..89f5d317f0 100644
--- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro
+++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro
@@ -1,6 +1,6 @@
load(qttest_p4)
TEMPLATE = app
-TARGET = qfile_vs_qnetworkaccessmanager
+TARGET = tst_qfile_vs_qnetworkaccessmanager
DEPENDPATH += .
INCLUDEPATH += .
diff --git a/tests/benchmarks/script/qscriptvalue/tst_qscriptvalue.cpp b/tests/benchmarks/script/qscriptvalue/tst_qscriptvalue.cpp
index 3bfc21c775..d7bb04bb10 100644
--- a/tests/benchmarks/script/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/benchmarks/script/qscriptvalue/tst_qscriptvalue.cpp
@@ -69,6 +69,8 @@ private slots:
void property();
void setProperty();
void propertyFlags();
+ void readMetaProperty();
+ void writeMetaProperty();
};
tst_QScriptValue::tst_QScriptValue()
@@ -201,5 +203,28 @@ void tst_QScriptValue::propertyFlags()
}
}
+void tst_QScriptValue::readMetaProperty()
+{
+ QScriptEngine engine;
+ QScriptValue object = engine.newQObject(QCoreApplication::instance());
+ QScriptString propertyName = engine.toStringHandle("objectName");
+ QBENCHMARK {
+ for (int i = 0; i < 10000; ++i)
+ object.property(propertyName);
+ }
+}
+
+void tst_QScriptValue::writeMetaProperty()
+{
+ QScriptEngine engine;
+ QScriptValue object = engine.newQObject(QCoreApplication::instance());
+ QScriptString propertyName = engine.toStringHandle("objectName");
+ QScriptValue value(&engine, "foo");
+ QBENCHMARK {
+ for (int i = 0; i < 10000; ++i)
+ object.setProperty(propertyName, value);
+ }
+}
+
QTEST_MAIN(tst_QScriptValue)
#include "tst_qscriptvalue.moc"
diff --git a/tools/assistant/lib/qhelpsearchresultwidget.cpp b/tools/assistant/lib/qhelpsearchresultwidget.cpp
index 8e476d5e4f..2f5489b37c 100644
--- a/tools/assistant/lib/qhelpsearchresultwidget.cpp
+++ b/tools/assistant/lib/qhelpsearchresultwidget.cpp
@@ -304,7 +304,7 @@ private:
last = resultLastToShow > count ? count : resultLastToShow;
}
}
- hitsLabel->setText(QHelpSearchResultWidget::tr("%1 - %2 of %3 Hits").arg(first).arg(last).arg(count));
+ hitsLabel->setText(QHelpSearchResultWidget::tr("%1 - %2 of %n Hits", 0, count).arg(first).arg(last));
}
private:
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 70f562e1a0..b9a1b0e1c1 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -148,7 +148,7 @@ void BookmarkManager::takeBookmarksMenu(QMenu* menu)
void BookmarkManager::addBookmark(const QString &title, const QString &url)
{
TRACE_OBJ
- showBookmarkDialog(title.isEmpty() ? tr("Untiled") : title,
+ showBookmarkDialog(title.isEmpty() ? tr("Untitled") : title,
url.isEmpty() ? QLatin1String("about:blank") : url);
}
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index bbc0c37df7..b6c0beba0f 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -167,10 +167,10 @@ void CmdLineParser::handleCollectionFileOption()
const QString &fileName = nextArg();
m_collectionFile = getFileName(fileName);
if (m_collectionFile.isEmpty())
- m_error = tr("The collection file '%1' does not exist!").
+ m_error = tr("The collection file '%1' does not exist.").
arg(fileName);
} else {
- m_error = tr("Missing collection file!");
+ m_error = tr("Missing collection file.");
}
}
@@ -183,9 +183,9 @@ void CmdLineParser::handleShowUrlOption()
if (url.isValid()) {
m_url = url;
} else
- m_error = tr("Invalid URL '%1'!").arg(urlString);
+ m_error = tr("Invalid URL '%1'.").arg(urlString);
} else {
- m_error = tr("Missing URL!");
+ m_error = tr("Missing URL.");
}
}
@@ -223,7 +223,7 @@ void CmdLineParser::handleShowOrHideOrActivateOption(ShowState state)
else
m_error = tr("Unknown widget: %1").arg(widget);
} else {
- m_error = tr("Missing widget!");
+ m_error = tr("Missing widget.");
}
}
@@ -246,11 +246,11 @@ void CmdLineParser::handleRegisterOrUnregisterOption(RegisterState state)
const QString &fileName = nextArg();
m_helpFile = getFileName(fileName);
if (m_helpFile.isEmpty())
- m_error = tr("The Qt help file '%1' does not exist!").arg(fileName);
+ m_error = tr("The Qt help file '%1' does not exist.").arg(fileName);
else
m_register = state;
} else {
- m_error = tr("Missing help file!");
+ m_error = tr("Missing help file.");
}
}
@@ -260,7 +260,7 @@ void CmdLineParser::handleSetCurrentFilterOption()
if (hasMoreArgs())
m_currentFilter = nextArg();
else
- m_error = tr("Missing filter argument!");
+ m_error = tr("Missing filter argument.");
}
QString CmdLineParser::getFileName(const QString &fileName)
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index 0bfe9042c5..9e8f5f45f0 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -53,7 +53,7 @@ class AbstractHelpViewer
{
public:
AbstractHelpViewer();
- ~AbstractHelpViewer();
+ virtual ~AbstractHelpViewer();
virtual QFont viewerFont() const = 0;
virtual void setViewerFont(const QFont &font) = 0;
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 172dcd48b1..c0a29ca86f 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1070,6 +1070,12 @@ void Configure::parseCmdLine()
dictionary[ "QT_INSTALL_PLUGINS" ] = configCmdLine.at(i);
}
+ else if( configCmdLine.at(i) == "-importdir" ) {
+ ++i;
+ if(i==argCount)
+ break;
+ dictionary[ "QT_INSTALL_IMPORTS" ] = configCmdLine.at(i);
+ }
else if( configCmdLine.at(i) == "-datadir" ) {
++i;
if(i==argCount)
@@ -1487,6 +1493,7 @@ void Configure::applySpecSpecifics()
dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ];
dictionary[ "QT_INSTALL_PREFIX" ] = "";
dictionary[ "QT_INSTALL_PLUGINS" ] = "\\resource\\qt\\plugins";
+ dictionary[ "QT_INSTALL_IMPORTS" ] = "\\resource\\qt\\imports";
dictionary[ "ARM_FPU_TYPE" ] = "softvfp";
dictionary[ "SQL_SQLITE" ] = "yes";
dictionary[ "SQL_SQLITE_LIB" ] = "system";
@@ -1563,7 +1570,7 @@ bool Configure::displayHelp()
desc("Usage: configure [-buildkey <key>]\n"
// desc("Usage: configure [-prefix dir] [-bindir <dir>] [-libdir <dir>]\n"
// "[-docdir <dir>] [-headerdir <dir>] [-plugindir <dir>]\n"
-// "[-datadir <dir>] [-translationdir <dir>]\n"
+// "[-importdir <dir>] [-datadir <dir>] [-translationdir <dir>]\n"
// "[-examplesdir <dir>] [-demosdir <dir>][-buildkey <key>]\n"
"[-release] [-debug] [-debug-and-release] [-shared] [-static]\n"
"[-no-fast] [-fast] [-no-exceptions] [-exceptions]\n"
@@ -1603,6 +1610,7 @@ bool Configure::displayHelp()
desc( "-docdir <dir>", "Documentation will be installed to dir\n(default PREFIX/doc)");
desc( "-headerdir <dir>", "Headers will be installed to dir\n(default PREFIX/include)");
desc( "-plugindir <dir>", "Plugins will be installed to dir\n(default PREFIX/plugins)");
+ desc( "-importdir <dir>", "Imports for QML will be installed to dir\n(default PREFIX/imports)");
desc( "-datadir <dir>", "Data used by Qt programs will be installed to dir\n(default PREFIX)");
desc( "-translationdir <dir>","Translations of Qt programs will be installed to dir\n(default PREFIX/translations)\n");
desc( "-examplesdir <dir>", "Examples will be installed to dir\n(default PREFIX/examples)");
@@ -2074,7 +2082,7 @@ bool Configure::checkAvailability(const QString &part)
} else if (part == "WEBKIT") {
available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-g++");
} else if (part == "DECLARATIVE") {
- available = QFile::exists(sourcePath + "/src/declarative/qml/qmlcomponent.h");
+ available = QFile::exists(sourcePath + "/src/declarative/qml/qdeclarativecomponent.h");
} else if (part == "AUDIO_BACKEND") {
available = true;
if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
@@ -2657,6 +2665,8 @@ void Configure::generateOutputVars()
dictionary[ "QT_INSTALL_BINS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/bin" );
if( !dictionary[ "QT_INSTALL_PLUGINS" ].size() )
dictionary[ "QT_INSTALL_PLUGINS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/plugins" );
+ if( !dictionary[ "QT_INSTALL_IMPORTS" ].size() )
+ dictionary[ "QT_INSTALL_IMPORTS" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] + "/imports" );
if( !dictionary[ "QT_INSTALL_DATA" ].size() )
dictionary[ "QT_INSTALL_DATA" ] = qipempty ? "" : fixSeparators( dictionary[ "QT_INSTALL_PREFIX" ] );
if( !dictionary[ "QT_INSTALL_TRANSLATIONS" ].size() )
@@ -3161,6 +3171,7 @@ void Configure::generateConfigfiles()
<< "static const char qt_configure_libraries_path_str [512 + 12] = \"qt_libspath=" << QString(dictionary["QT_INSTALL_LIBS"]).replace( "\\", "\\\\" ) << "\";" << endl
<< "static const char qt_configure_binaries_path_str [512 + 12] = \"qt_binspath=" << QString(dictionary["QT_INSTALL_BINS"]).replace( "\\", "\\\\" ) << "\";" << endl
<< "static const char qt_configure_plugins_path_str [512 + 12] = \"qt_plugpath=" << QString(dictionary["QT_INSTALL_PLUGINS"]).replace( "\\", "\\\\" ) << "\";" << endl
+ << "static const char qt_configure_imports_path_str [512 + 12] = \"qt_impspath=" << QString(dictionary["QT_INSTALL_IMPORTS"]).replace( "\\", "\\\\" ) << "\";" << endl
<< "static const char qt_configure_data_path_str [512 + 12] = \"qt_datapath=" << QString(dictionary["QT_INSTALL_DATA"]).replace( "\\", "\\\\" ) << "\";" << endl
<< "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << QString(dictionary["QT_INSTALL_TRANSLATIONS"]).replace( "\\", "\\\\" ) << "\";" << endl
<< "static const char qt_configure_examples_path_str [512 + 12] = \"qt_xmplpath=" << QString(dictionary["QT_INSTALL_EXAMPLES"]).replace( "\\", "\\\\" ) << "\";" << endl
@@ -3175,6 +3186,7 @@ void Configure::generateConfigfiles()
<< "static const char qt_configure_libraries_path_str [512 + 12] = \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib").replace( "\\", "\\\\" ) <<"\";" << endl
<< "static const char qt_configure_binaries_path_str [512 + 12] = \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin").replace( "\\", "\\\\" ) <<"\";" << endl
<< "static const char qt_configure_plugins_path_str [512 + 12] = \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins").replace( "\\", "\\\\" ) <<"\";" << endl
+ << "static const char qt_configure_imports_path_str [512 + 12] = \"qt_impspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/imports").replace( "\\", "\\\\" ) <<"\";" << endl
<< "static const char qt_configure_data_path_str [512 + 12] = \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ]).replace( "\\", "\\\\" ) <<"\";" << endl
<< "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations").replace( "\\", "\\\\" ) <<"\";" << endl
<< "static const char qt_configure_examples_path_str [512 + 12] = \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example").replace( "\\", "\\\\" ) <<"\";" << endl
@@ -3190,6 +3202,7 @@ void Configure::generateConfigfiles()
<< "#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;" << endl
<< "#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;" << endl
<< "#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12;" << endl
<< "#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;" << endl
<< "#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;" << endl
<< "#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12;" << endl
@@ -3336,6 +3349,7 @@ void Configure::displayConfig()
cout << "Headers installed to........" << dictionary[ "QT_INSTALL_HEADERS" ] << endl;
cout << "Libraries installed to......" << dictionary[ "QT_INSTALL_LIBS" ] << endl;
cout << "Plugins installed to........" << dictionary[ "QT_INSTALL_PLUGINS" ] << endl;
+ cout << "Imports installed to........" << dictionary[ "QT_INSTALL_IMPORTS" ] << endl;
cout << "Binaries installed to......." << dictionary[ "QT_INSTALL_BINS" ] << endl;
cout << "Docs installed to..........." << dictionary[ "QT_INSTALL_DOCS" ] << endl;
cout << "Data installed to..........." << dictionary[ "QT_INSTALL_DATA" ] << endl;
@@ -3709,7 +3723,7 @@ void Configure::generateMakefiles()
QTextStream txt(&file);
txt << "all:\n";
txt << "\t" << args.join(" ") << "\n";
- txt << "\t" << dictionary[ "MAKE" ] << " -f " << it->target << "\n";
+ txt << "\t\"$(MAKE)\" -$(MAKEFLAGS) -f " << it->target << "\n";
txt << "first: all\n";
txt << "qmake:\n";
txt << "\t" << args.join(" ") << "\n";
diff --git a/tools/linguist/lupdate/lupdate.pro b/tools/linguist/lupdate/lupdate.pro
index 283d69f1d1..1f8893139e 100644
--- a/tools/linguist/lupdate/lupdate.pro
+++ b/tools/linguist/lupdate/lupdate.pro
@@ -26,7 +26,7 @@ SOURCES += \
cpp.cpp \
java.cpp \
qscript.cpp \
- qml.cpp \
+ qdeclarative.cpp \
ui.cpp
HEADERS += \
diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp
new file mode 100644
index 0000000000..a734e99431
--- /dev/null
+++ b/tools/linguist/lupdate/qdeclarative.cpp
@@ -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 Qt Linguist of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "lupdate.h"
+
+#include <translator.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+#include <QtCore/QString>
+
+#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 <QCoreApplication>
+#include <QFile>
+#include <QFileInfo>
+#include <QtDebug>
+#include <QStringList>
+
+#include <iostream>
+#include <cstdlib>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QDeclarativeJS;
+
+class FindTrCalls: protected AST::Visitor
+{
+public:
+ void operator()(Translator *translator, const QString &fileName, AST::Node *node)
+ {
+ m_translator = translator;
+ m_fileName = fileName;
+ m_component = QFileInfo(fileName).baseName(); //matches qsTr usage in QScriptEngine
+ accept(node);
+ }
+
+protected:
+ using AST::Visitor::visit;
+ using AST::Visitor::endVisit;
+
+ void accept(AST::Node *node)
+ { AST::Node::acceptChild(node, this); }
+
+ virtual void endVisit(AST::CallExpression *node)
+ {
+ if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(node->base)) {
+ if (idExpr->name->asString() == QLatin1String("qsTr") ||
+ idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) {
+ if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) {
+ AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
+ const QString source = literal->value->asString();
+
+ QString comment;
+ bool plural = false;
+ AST::ArgumentList *commentNode = node->arguments->next;
+ if (commentNode) {
+ literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
+ comment = literal->value->asString();
+
+ AST::ArgumentList *nNode = commentNode->next;
+ if (nNode) {
+ AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
+ if (numLiteral) {
+ plural = true;
+ }
+ }
+ }
+
+ TranslatorMessage msg(m_component, source,
+ comment, QString(), m_fileName,
+ node->firstSourceLocation().startLine, QStringList(),
+ TranslatorMessage::Unfinished, plural);
+ m_translator->extend(msg);
+ }
+ } else if (idExpr->name->asString() == QLatin1String("qsTranslate") ||
+ idExpr->name->asString() == QLatin1String("QT_TRANSLATE_NOOP")) {
+ if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) {
+ AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
+ const QString context = literal->value->asString();
+
+ QString source;
+ QString comment;
+ bool plural = false;
+ AST::ArgumentList *sourceNode = node->arguments->next;
+ if (sourceNode) {
+ literal = AST::cast<AST::StringLiteral *>(sourceNode->expression);
+ source = literal->value->asString();
+ AST::ArgumentList *commentNode = sourceNode->next;
+ if (commentNode) {
+ literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
+ comment = literal->value->asString();
+
+ AST::ArgumentList *nNode = commentNode->next;
+ if (nNode) {
+ AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
+ if (numLiteral) {
+ plural = true;
+ }
+ }
+ }
+ }
+
+ TranslatorMessage msg(context, source,
+ comment, QString(), m_fileName,
+ node->firstSourceLocation().startLine, QStringList(),
+ TranslatorMessage::Unfinished, plural);
+ m_translator->extend(msg);
+ }
+
+ }
+ }
+ }
+
+private:
+ Translator *m_translator;
+ QString m_fileName;
+ QString m_component;
+};
+
+QString createErrorString(const QString &filename, const QString &code, Parser &parser)
+{
+ // print out error
+ QStringList lines = code.split(QLatin1Char('\n'));
+ lines.append(QLatin1String("\n")); // sentinel.
+ QString errorString;
+
+ foreach (const DiagnosticMessage &m, parser.diagnosticMessages()) {
+
+ if (m.isWarning())
+ continue;
+
+ QString error = filename + QLatin1Char(':') + QString::number(m.loc.startLine)
+ + QLatin1Char(':') + QString::number(m.loc.startColumn) + QLatin1String(": error: ")
+ + m.message + QLatin1Char('\n');
+
+ int line = 0;
+ if (m.loc.startLine > 0)
+ line = m.loc.startLine - 1;
+
+ const QString textLine = lines.at(line);
+
+ error += textLine + QLatin1Char('\n');
+
+ int column = m.loc.startColumn - 1;
+ if (column < 0)
+ column = 0;
+
+ column = qMin(column, textLine.length());
+
+ for (int i = 0; i < column; ++i) {
+ const QChar ch = textLine.at(i);
+ if (ch.isSpace())
+ error += ch.unicode();
+ else
+ error += QLatin1Char(' ');
+ }
+ error += QLatin1String("^\n");
+ errorString += error;
+ }
+ return errorString;
+}
+
+bool loadQml(Translator &translator, const QString &filename, ConversionData &cd)
+{
+ cd.m_sourceFileName = filename;
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ cd.appendError(QString::fromLatin1("Cannot open %1: %2")
+ .arg(filename, file.errorString()));
+ return false;
+ }
+
+ const QString code = QTextStream(&file).readAll();
+
+ Engine driver;
+ Parser parser(&driver);
+
+ NodePool nodePool(filename, &driver);
+ driver.setNodePool(&nodePool);
+
+ Lexer lexer(&driver);
+ lexer.setCode(code, /*line = */ 1);
+ driver.setLexer(&lexer);
+
+ if (parser.parse()) {
+ FindTrCalls trCalls;
+ trCalls(&translator, filename, parser.ast());
+ } else {
+ QString error = createErrorString(filename, code, parser);
+ cd.appendError(error);
+ return false;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/tools/linguist/lupdate/qml.cpp b/tools/linguist/lupdate/qml.cpp
deleted file mode 100644
index cb35f47fac..0000000000
--- a/tools/linguist/lupdate/qml.cpp
+++ /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 Qt Linguist of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "lupdate.h"
-
-#include <translator.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QFile>
-#include <QtCore/QString>
-
-#include "parser/qmljsengine_p.h"
-#include "parser/qmljsparser_p.h"
-#include "parser/qmljslexer_p.h"
-#include "parser/qmljsnodepool_p.h"
-#include "parser/qmljsastvisitor_p.h"
-#include "parser/qmljsast_p.h"
-
-#include <QCoreApplication>
-#include <QFile>
-#include <QFileInfo>
-#include <QtDebug>
-#include <QStringList>
-
-#include <iostream>
-#include <cstdlib>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QmlJS;
-
-class FindTrCalls: protected AST::Visitor
-{
-public:
- void operator()(Translator *translator, const QString &fileName, AST::Node *node)
- {
- m_translator = translator;
- m_fileName = fileName;
- m_component = QFileInfo(fileName).baseName(); //matches qsTr usage in QScriptEngine
- accept(node);
- }
-
-protected:
- using AST::Visitor::visit;
- using AST::Visitor::endVisit;
-
- void accept(AST::Node *node)
- { AST::Node::acceptChild(node, this); }
-
- virtual void endVisit(AST::CallExpression *node)
- {
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(node->base)) {
- if (idExpr->name->asString() == QLatin1String("qsTr") ||
- idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) {
- if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) {
- AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
- const QString source = literal->value->asString();
-
- QString comment;
- bool plural = false;
- AST::ArgumentList *commentNode = node->arguments->next;
- if (commentNode) {
- literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
- comment = literal->value->asString();
-
- AST::ArgumentList *nNode = commentNode->next;
- if (nNode) {
- AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
- if (numLiteral) {
- plural = true;
- }
- }
- }
-
- TranslatorMessage msg(m_component, source,
- comment, QString(), m_fileName,
- node->firstSourceLocation().startLine, QStringList(),
- TranslatorMessage::Unfinished, plural);
- m_translator->extend(msg);
- }
- } else if (idExpr->name->asString() == QLatin1String("qsTranslate") ||
- idExpr->name->asString() == QLatin1String("QT_TRANSLATE_NOOP")) {
- if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) {
- AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
- const QString context = literal->value->asString();
-
- QString source;
- QString comment;
- bool plural = false;
- AST::ArgumentList *sourceNode = node->arguments->next;
- if (sourceNode) {
- literal = AST::cast<AST::StringLiteral *>(sourceNode->expression);
- source = literal->value->asString();
- AST::ArgumentList *commentNode = sourceNode->next;
- if (commentNode) {
- literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
- comment = literal->value->asString();
-
- AST::ArgumentList *nNode = commentNode->next;
- if (nNode) {
- AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
- if (numLiteral) {
- plural = true;
- }
- }
- }
- }
-
- TranslatorMessage msg(context, source,
- comment, QString(), m_fileName,
- node->firstSourceLocation().startLine, QStringList(),
- TranslatorMessage::Unfinished, plural);
- m_translator->extend(msg);
- }
-
- }
- }
- }
-
-private:
- Translator *m_translator;
- QString m_fileName;
- QString m_component;
-};
-
-QString createErrorString(const QString &filename, const QString &code, Parser &parser)
-{
- // print out error
- QStringList lines = code.split(QLatin1Char('\n'));
- lines.append(QLatin1String("\n")); // sentinel.
- QString errorString;
-
- foreach (const DiagnosticMessage &m, parser.diagnosticMessages()) {
-
- if (m.isWarning())
- continue;
-
- QString error = filename + QLatin1Char(':') + QString::number(m.loc.startLine)
- + QLatin1Char(':') + QString::number(m.loc.startColumn) + QLatin1String(": error: ")
- + m.message + QLatin1Char('\n');
-
- int line = 0;
- if (m.loc.startLine > 0)
- line = m.loc.startLine - 1;
-
- const QString textLine = lines.at(line);
-
- error += textLine + QLatin1Char('\n');
-
- int column = m.loc.startColumn - 1;
- if (column < 0)
- column = 0;
-
- column = qMin(column, textLine.length());
-
- for (int i = 0; i < column; ++i) {
- const QChar ch = textLine.at(i);
- if (ch.isSpace())
- error += ch.unicode();
- else
- error += QLatin1Char(' ');
- }
- error += QLatin1String("^\n");
- errorString += error;
- }
- return errorString;
-}
-
-bool loadQml(Translator &translator, const QString &filename, ConversionData &cd)
-{
- cd.m_sourceFileName = filename;
- QFile file(filename);
- if (!file.open(QIODevice::ReadOnly)) {
- cd.appendError(QString::fromLatin1("Cannot open %1: %2")
- .arg(filename, file.errorString()));
- return false;
- }
-
- const QString code = QTextStream(&file).readAll();
-
- Engine driver;
- Parser parser(&driver);
-
- NodePool nodePool(filename, &driver);
- driver.setNodePool(&nodePool);
-
- Lexer lexer(&driver);
- lexer.setCode(code, /*line = */ 1);
- driver.setLexer(&lexer);
-
- if (parser.parse()) {
- FindTrCalls trCalls;
- trCalls(&translator, filename, parser.ast());
- } else {
- QString error = createErrorString(filename, code, parser);
- cd.appendError(error);
- return false;
- }
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/tools/qmlviewer/content/Browser.qml b/tools/qml/content/Browser.qml
index 35120bc621..35120bc621 100644
--- a/tools/qmlviewer/content/Browser.qml
+++ b/tools/qml/content/Browser.qml
diff --git a/tools/qmlviewer/content/images/folder.png b/tools/qml/content/images/folder.png
index e53e2ad464..e53e2ad464 100644
--- a/tools/qmlviewer/content/images/folder.png
+++ b/tools/qml/content/images/folder.png
Binary files differ
diff --git a/tools/qmlviewer/content/images/titlebar.png b/tools/qml/content/images/titlebar.png
index 51c90082d0..51c90082d0 100644
--- a/tools/qmlviewer/content/images/titlebar.png
+++ b/tools/qml/content/images/titlebar.png
Binary files differ
diff --git a/tools/qmlviewer/content/images/titlebar.sci b/tools/qml/content/images/titlebar.sci
index 0418d94cd6..0418d94cd6 100644
--- a/tools/qmlviewer/content/images/titlebar.sci
+++ b/tools/qml/content/images/titlebar.sci
diff --git a/tools/qmlviewer/content/images/up.png b/tools/qml/content/images/up.png
index b05f8025d0..b05f8025d0 100644
--- a/tools/qmlviewer/content/images/up.png
+++ b/tools/qml/content/images/up.png
Binary files differ
diff --git a/tools/qmlviewer/deviceorientation.cpp b/tools/qml/deviceorientation.cpp
index e7c70d5fde..e7c70d5fde 100644
--- a/tools/qmlviewer/deviceorientation.cpp
+++ b/tools/qml/deviceorientation.cpp
diff --git a/tools/qmlviewer/deviceorientation.h b/tools/qml/deviceorientation.h
index c8125cd830..c8125cd830 100644
--- a/tools/qmlviewer/deviceorientation.h
+++ b/tools/qml/deviceorientation.h
diff --git a/tools/qmlviewer/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo.cpp
index fa2c6e5776..fa2c6e5776 100644
--- a/tools/qmlviewer/deviceorientation_maemo.cpp
+++ b/tools/qml/deviceorientation_maemo.cpp
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
new file mode 100644
index 0000000000..9ef02ac3cb
--- /dev/null
+++ b/tools/qml/main.cpp
@@ -0,0 +1,356 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qmlruntime.h"
+#include <QWidget>
+#include <QDir>
+#include <QApplication>
+#include <QTranslator>
+#include <QDebug>
+#include "qfxtester.h"
+#include "qdeclarativefolderlistmodel.h"
+
+QT_USE_NAMESPACE
+
+#if defined (Q_OS_SYMBIAN)
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+void myMessageOutput(QtMsgType type, const char *msg)
+{
+ static int fd = -1;
+ if (fd == -1)
+ fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT);
+
+ ::write(fd, msg, strlen(msg));
+ ::write(fd, "\n", 1);
+ ::fsync(fd);
+
+ switch (type) {
+ case QtFatalMsg:
+ abort();
+ }
+}
+#endif
+
+void usage()
+{
+ qWarning("Usage: qml [options] <filename>");
+ qWarning(" ");
+ qWarning(" options:");
+ qWarning(" -v, -version ............................. display version");
+ qWarning(" -frameless ............................... run with no window frame");
+ qWarning(" -maximized................................ run maximized");
+ qWarning(" -fullscreen............................... run fullscreen");
+ qWarning(" -stayontop................................ keep viewer window on top");
+ qWarning(" -skin <qvfbskindir> ...................... run with a skin window frame");
+ qWarning(" \"list\" for a list of built-ins");
+ qWarning(" -resizeview .............................. resize the view, not the skin");
+ qWarning(" -qmlbrowser .............................. use a QML-based file browser");
+ qWarning(" -recordfile <output> ..................... set video recording file");
+ qWarning(" - ImageMagick 'convert' for GIF)");
+ qWarning(" - png file for raw frames");
+ qWarning(" - 'ffmpeg' for other formats");
+ qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode");
+ qWarning(" -recordrate <fps> ........................ set recording frame rate");
+ qWarning(" -record arg .............................. add a recording process argument");
+ qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop");
+ qWarning(" -devicekeys .............................. use numeric keys (see F1)");
+ qWarning(" -dragthreshold <size> .................... set mouse drag threshold size");
+ qWarning(" -netcache <size> ......................... set disk cache to size bytes");
+ qWarning(" -translation <translationfile> ........... set the language to run in");
+ qWarning(" -L <directory> ........................... prepend to the library search path");
+ qWarning(" -opengl .................................. use a QGLWidget for the viewport");
+ qWarning(" -script <path> ........................... set the script to use");
+ qWarning(" -scriptopts <options>|help ............... set the script options to use");
+
+ qWarning(" ");
+ qWarning(" Press F1 for interactive help");
+ exit(1);
+}
+
+void scriptOptsUsage()
+{
+ qWarning("Usage: qml -scriptopts <option>[,<option>...] ...");
+ qWarning(" options:");
+ qWarning(" record ................................... record a new script");
+ qWarning(" play ..................................... playback an existing script");
+ qWarning(" testimages ............................... record images or compare images on playback");
+ qWarning(" testerror ................................ test 'error' property of root item on playback");
+ qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion");
+ qWarning(" exitonfailure ............................ immediately exit the viewer on script failure");
+ qWarning(" saveonexit ............................... save recording on viewer exit");
+ qWarning(" ");
+ qWarning(" One of record, play or both must be specified.");
+ exit(1);
+}
+
+int main(int argc, char ** argv)
+{
+#if defined (Q_OS_SYMBIAN)
+ qInstallMsgHandler(myMessageOutput);
+#endif
+
+#if defined (Q_WS_X11)
+ //### default to using raster graphics backend for now
+ bool gsSpecified = false;
+ for (int i = 0; i < argc; ++i) {
+ QString arg = argv[i];
+ if (arg == "-graphicssystem") {
+ gsSpecified = true;
+ break;
+ }
+ }
+
+ if (!gsSpecified)
+ QApplication::setGraphicsSystem("raster");
+#endif
+
+ QApplication app(argc, argv);
+ app.setApplicationName("viewer");
+ app.setOrganizationName("Nokia");
+ app.setOrganizationDomain("nokia.com");
+
+ QDeclarativeViewer::registerTypes();
+ QDeclarativeTester::registerTypes();
+ QDeclarativeFolderListModel::registerTypes();
+
+ bool frameless = false;
+ bool resizeview = false;
+ QString fileName;
+ double fps = 0;
+ int autorecord_from = 0;
+ int autorecord_to = 0;
+ QString dither = "none";
+ QString recordfile;
+ QStringList recordargs;
+ QStringList libraries;
+ QString skin;
+ QString script;
+ QString scriptopts;
+ bool runScript = false;
+ bool devkeys = false;
+ int cache = 0;
+ QString translationFile;
+ bool useGL = false;
+ bool fullScreen = false;
+ bool stayOnTop = false;
+ bool maximized = false;
+ bool useNativeFileBrowser = true;
+
+#if defined(Q_OS_SYMBIAN)
+ maximized = true;
+ useNativeFileBrowser = false;
+#endif
+
+ for (int i = 1; i < argc; ++i) {
+ bool lastArg = (i == argc - 1);
+ QString arg = argv[i];
+ if (arg == "-frameless") {
+ frameless = true;
+ } else if (arg == "-maximized") {
+ maximized = true;
+ } else if (arg == "-fullscreen") {
+ fullScreen = true;
+ } else if (arg == "-stayontop") {
+ stayOnTop = true;
+ } else if (arg == "-skin") {
+ if (lastArg) usage();
+ skin = QString(argv[++i]);
+ } else if (arg == "-resizeview") {
+ resizeview = true;
+ } else if (arg == "-netcache") {
+ if (lastArg) usage();
+ cache = QString(argv[++i]).toInt();
+ } else if (arg == "-recordrate") {
+ if (lastArg) usage();
+ fps = QString(argv[++i]).toDouble();
+ } else if (arg == "-recordfile") {
+ if (lastArg) usage();
+ recordfile = QString(argv[++i]);
+ } else if (arg == "-record") {
+ if (lastArg) usage();
+ recordargs << QString(argv[++i]);
+ } else if (arg == "-recorddither") {
+ if (lastArg) usage();
+ dither = QString(argv[++i]);
+ } else if (arg == "-autorecord") {
+ if (lastArg) usage();
+ QString range = QString(argv[++i]);
+ int dash = range.indexOf('-');
+ if (dash > 0)
+ autorecord_from = range.left(dash).toInt();
+ autorecord_to = range.mid(dash+1).toInt();
+ } else if (arg == "-devicekeys") {
+ devkeys = true;
+ } else if (arg == "-dragthreshold") {
+ if (lastArg) usage();
+ app.setStartDragDistance(QString(argv[++i]).toInt());
+ } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
+ fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR);
+ return 0;
+ } else if (arg == "-translation") {
+ if (lastArg) usage();
+ translationFile = argv[++i];
+ } else if (arg == "-opengl") {
+ useGL = true;
+ } else if (arg == "-qmlbrowser") {
+ useNativeFileBrowser = false;
+ } else if (arg == "-L") {
+ if (lastArg) usage();
+ libraries << QString(argv[++i]);
+ } else if (arg == "-script") {
+ if (lastArg) usage();
+ script = QString(argv[++i]);
+ } else if (arg == "-scriptopts") {
+ if (lastArg) usage();
+ scriptopts = QString(argv[++i]);
+ } else if (arg == "-savescript") {
+ if (lastArg) usage();
+ script = QString(argv[++i]);
+ runScript = false;
+ } else if (arg == "-playscript") {
+ if (lastArg) usage();
+ script = QString(argv[++i]);
+ runScript = true;
+ } else if (arg[0] != '-') {
+ fileName = arg;
+ } else if (1 || arg == "-help") {
+ usage();
+ }
+ }
+
+ QTranslator qmlTranslator;
+ if (!translationFile.isEmpty()) {
+ qmlTranslator.load(translationFile);
+ app.installTranslator(&qmlTranslator);
+ }
+
+ Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget);
+ if (stayOnTop)
+ wflags |= Qt::WindowStaysOnTopHint;
+
+ QDeclarativeViewer viewer(0, wflags);
+ if (!scriptopts.isEmpty()) {
+ QStringList options =
+ scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
+
+ QDeclarativeViewer::ScriptOptions scriptOptions = 0;
+ for (int i = 0; i < options.count(); ++i) {
+ const QString &option = options.at(i);
+ if (option == QLatin1String("help")) {
+ scriptOptsUsage();
+ } else if (option == QLatin1String("play")) {
+ scriptOptions |= QDeclarativeViewer::Play;
+ } else if (option == QLatin1String("record")) {
+ scriptOptions |= QDeclarativeViewer::Record;
+ } else if (option == QLatin1String("testimages")) {
+ scriptOptions |= QDeclarativeViewer::TestImages;
+ } else if (option == QLatin1String("testerror")) {
+ scriptOptions |= QDeclarativeViewer::TestErrorProperty;
+ } else if (option == QLatin1String("exitoncomplete")) {
+ scriptOptions |= QDeclarativeViewer::ExitOnComplete;
+ } else if (option == QLatin1String("exitonfailure")) {
+ scriptOptions |= QDeclarativeViewer::ExitOnFailure;
+ } else if (option == QLatin1String("saveonexit")) {
+ scriptOptions |= QDeclarativeViewer::SaveOnExit;
+ } else {
+ scriptOptsUsage();
+ }
+ }
+
+ if (script.isEmpty())
+ usage();
+
+ if (!(scriptOptions & QDeclarativeViewer::Record) && !(scriptOptions & QDeclarativeViewer::Play))
+ scriptOptsUsage();
+ viewer.setScriptOptions(scriptOptions);
+ viewer.setScript(script);
+ } else if (!script.isEmpty()) {
+ usage();
+ }
+
+ foreach (QString lib, libraries)
+ viewer.addLibraryPath(lib);
+ viewer.setNetworkCacheSize(cache);
+ viewer.setRecordFile(recordfile);
+ if (resizeview)
+ viewer.setScaleView();
+ if (fps>0)
+ viewer.setRecordRate(fps);
+ if (autorecord_to)
+ viewer.setAutoRecord(autorecord_from,autorecord_to);
+ if (!skin.isEmpty()) {
+ if (skin == "list") {
+ foreach (QString s, viewer.builtinSkins())
+ qWarning(s.toUtf8());
+ exit(0);
+ } else {
+ viewer.setSkin(skin);
+ }
+ }
+ if (devkeys)
+ viewer.setDeviceKeys(true);
+ viewer.setRecordDither(dither);
+ if (recordargs.count())
+ viewer.setRecordArgs(recordargs);
+
+ viewer.setUseNativeFileBrowser(useNativeFileBrowser);
+ if (fullScreen && maximized)
+ qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen.";
+ if (!fileName.isEmpty()) {
+ viewer.open(fileName);
+ fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
+ } else {
+ if (!useNativeFileBrowser)
+ viewer.openFile();
+ fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
+ if (useNativeFileBrowser)
+ viewer.openFile();
+ }
+ viewer.setUseGL(useGL);
+ viewer.raise();
+
+ return app.exec();
+}
diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qml/proxysettings.cpp
index 3255e42f5d..3255e42f5d 100644
--- a/tools/qmlviewer/proxysettings.cpp
+++ b/tools/qml/proxysettings.cpp
diff --git a/tools/qmlviewer/proxysettings.h b/tools/qml/proxysettings.h
index 325929af7a..325929af7a 100644
--- a/tools/qmlviewer/proxysettings.h
+++ b/tools/qml/proxysettings.h
diff --git a/tools/qmlviewer/proxysettings.ui b/tools/qml/proxysettings.ui
index 84e39fe03d..84e39fe03d 100644
--- a/tools/qmlviewer/proxysettings.ui
+++ b/tools/qml/proxysettings.ui
diff --git a/tools/qml/qdeclarativefolderlistmodel.cpp b/tools/qml/qdeclarativefolderlistmodel.cpp
new file mode 100644
index 0000000000..58bf59ba05
--- /dev/null
+++ b/tools/qml/qdeclarativefolderlistmodel.cpp
@@ -0,0 +1,420 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qdeclarativefolderlistmodel.h"
+#include <QDirModel>
+#include <QDebug>
+#include <qdeclarativecontext.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeFolderListModelPrivate
+{
+public:
+ QDeclarativeFolderListModelPrivate()
+ : sortField(QDeclarativeFolderListModel::Name), sortReversed(false), count(0) {
+ nameFilters << QLatin1String("*");
+ }
+
+ void updateSorting() {
+ QDir::SortFlags flags = 0;
+ switch(sortField) {
+ case QDeclarativeFolderListModel::Unsorted:
+ flags |= QDir::Unsorted;
+ break;
+ case QDeclarativeFolderListModel::Name:
+ flags |= QDir::Name;
+ break;
+ case QDeclarativeFolderListModel::Time:
+ flags |= QDir::Time;
+ break;
+ case QDeclarativeFolderListModel::Size:
+ flags |= QDir::Size;
+ break;
+ case QDeclarativeFolderListModel::Type:
+ flags |= QDir::Type;
+ break;
+ }
+
+ if (sortReversed)
+ flags |= QDir::Reversed;
+
+ model.setSorting(flags);
+ }
+
+ QDirModel model;
+ QUrl folder;
+ QStringList nameFilters;
+ QModelIndex folderIndex;
+ QDeclarativeFolderListModel::SortField sortField;
+ bool sortReversed;
+ int count;
+};
+
+/*!
+ \qmlclass FolderListModel
+ \brief The FolderListModel provides a model of the contents of a folder in a filesystem.
+
+ FolderListModel provides access to the local filesystem. The \e folder property
+ specifies the folder to list.
+
+ Qt uses "/" as a universal directory separator in the same way that "/" is
+ used as a path separator in URLs. If you always use "/" as a directory
+ separator, Qt will translate your paths to conform to the underlying
+ operating system.
+
+ The roles available are:
+ \list
+ \o fileName
+ \o filePath
+ \endlist
+
+ Additionally a file entry can be differentiated from a folder entry
+ via the \l isFolder() method.
+*/
+
+QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent)
+ : QListModelInterface(parent)
+{
+ d = new QDeclarativeFolderListModelPrivate;
+ d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot);
+ connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int))
+ , this, SLOT(inserted(const QModelIndex&,int,int)));
+ connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int))
+ , this, SLOT(removed(const QModelIndex&,int,int)));
+ connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&))
+ , this, SLOT(dataChanged(const QModelIndex&,const QModelIndex&)));
+ connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh()));
+ connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh()));
+}
+
+QDeclarativeFolderListModel::~QDeclarativeFolderListModel()
+{
+ delete d;
+}
+
+QHash<int,QVariant> QDeclarativeFolderListModel::data(int index, const QList<int> &roles) const
+{
+ Q_UNUSED(roles);
+ QHash<int,QVariant> folderData;
+ QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex);
+ if (modelIndex.isValid()) {
+ folderData[QDirModel::FileNameRole] = d->model.data(modelIndex, QDirModel::FileNameRole);
+ folderData[QDirModel::FilePathRole] = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString());
+ }
+
+ return folderData;
+}
+
+QVariant QDeclarativeFolderListModel::data(int index, int role) const
+{
+ QVariant rv;
+ QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex);
+ if (modelIndex.isValid()) {
+ if (role == QDirModel::FileNameRole)
+ rv = d->model.data(modelIndex, QDirModel::FileNameRole);
+ else if (role == QDirModel::FilePathRole)
+ rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString());
+ }
+
+ return rv;
+}
+
+int QDeclarativeFolderListModel::count() const
+{
+ return d->count;
+}
+
+QList<int> QDeclarativeFolderListModel::roles() const
+{
+ QList<int> r;
+ r << QDirModel::FileNameRole;
+ r << QDirModel::FilePathRole;
+ return r;
+}
+
+QString QDeclarativeFolderListModel::toString(int role) const
+{
+ switch (role) {
+ case QDirModel::FileNameRole:
+ return QLatin1String("fileName");
+ case QDirModel::FilePathRole:
+ return QLatin1String("filePath");
+ }
+
+ return QString();
+}
+
+/*!
+ \qmlproperty string FolderListModel::folder
+
+ The \a folder property holds the folder the model is currently providing.
+
+ It is a URL, but must be a file: or qrc: URL (or relative to such a URL).
+*/
+QUrl QDeclarativeFolderListModel::folder() const
+{
+ return d->folder;
+}
+
+void QDeclarativeFolderListModel::setFolder(const QUrl &folder)
+{
+ if (folder == d->folder)
+ return;
+ QModelIndex index = d->model.index(folder.toLocalFile());
+ if (index.isValid() && d->model.isDir(index)) {
+ d->folder = folder;
+ QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
+ emit folderChanged();
+ }
+}
+
+QUrl QDeclarativeFolderListModel::parentFolder() const
+{
+ QUrl r;
+ QString localFile = d->folder.toLocalFile();
+ if (!localFile.isEmpty()) {
+ QDir dir(localFile);
+#if defined(Q_OS_SYMBIAN)
+ if (dir.isRoot())
+ dir.setPath("");
+ else
+#endif
+ dir.cdUp();
+ r = d->folder;
+ r.setPath(dir.path());
+ } else {
+ int pos = d->folder.path().lastIndexOf(QLatin1Char('/'));
+ if (pos == -1)
+ return QUrl();
+ r = d->folder;
+ r.setPath(d->folder.path().left(pos));
+ }
+ return r;
+}
+
+/*!
+ \qmlproperty list<string> FolderListModel::nameFilters
+
+ The \a nameFilters property contains a list of filename filters.
+ The filters may include the ? and * wildcards.
+
+ The example below filters on PNG and JPEG files:
+
+ \code
+ FolderListModel {
+ nameFilters: [ "*.png", "*.jpg" ]
+ }
+ \endcode
+*/
+QStringList QDeclarativeFolderListModel::nameFilters() const
+{
+ return d->nameFilters;
+}
+
+void QDeclarativeFolderListModel::setNameFilters(const QStringList &filters)
+{
+ d->nameFilters = filters;
+ d->model.setNameFilters(d->nameFilters);
+}
+
+void QDeclarativeFolderListModel::componentComplete()
+{
+ if (!d->folder.isValid() || !QDir().exists(d->folder.toLocalFile()))
+ setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
+
+ if (!d->folderIndex.isValid())
+ QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
+}
+
+QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField() const
+{
+ return d->sortField;
+}
+
+void QDeclarativeFolderListModel::setSortField(SortField field)
+{
+ if (field != d->sortField) {
+ d->sortField = field;
+ d->updateSorting();
+ }
+}
+
+bool QDeclarativeFolderListModel::sortReversed() const
+{
+ return d->sortReversed;
+}
+
+void QDeclarativeFolderListModel::setSortReversed(bool rev)
+{
+ if (rev != d->sortReversed) {
+ d->sortReversed = rev;
+ d->updateSorting();
+ }
+}
+
+/*!
+ \qmlmethod bool FolderListModel::isFolder(int index)
+
+ Returns true if the entry \a index is a folder; otherwise
+ returns false.
+*/
+bool QDeclarativeFolderListModel::isFolder(int index) const
+{
+ if (index != -1) {
+ QModelIndex idx = d->model.index(index, 0, d->folderIndex);
+ if (idx.isValid())
+ return d->model.isDir(idx);
+ }
+ return false;
+}
+
+void QDeclarativeFolderListModel::refresh()
+{
+ d->folderIndex = QModelIndex();
+ if (d->count) {
+ int tmpCount = d->count;
+ d->count = 0;
+ emit itemsRemoved(0, tmpCount);
+ }
+ d->folderIndex = d->model.index(d->folder.toLocalFile());
+ d->count = d->model.rowCount(d->folderIndex);
+ if (d->count) {
+ emit itemsInserted(0, d->count);
+ }
+}
+
+void QDeclarativeFolderListModel::inserted(const QModelIndex &index, int start, int end)
+{
+ if (index == d->folderIndex) {
+ d->count = d->model.rowCount(d->folderIndex);
+ emit itemsInserted(start, end - start + 1);
+ }
+}
+
+void QDeclarativeFolderListModel::removed(const QModelIndex &index, int start, int end)
+{
+ if (index == d->folderIndex) {
+ d->count = d->model.rowCount(d->folderIndex);
+ emit itemsRemoved(start, end - start + 1);
+ }
+}
+
+void QDeclarativeFolderListModel::dataChanged(const QModelIndex &start, const QModelIndex &end)
+{
+ qDebug() << "data changed";
+ if (start.parent() == d->folderIndex)
+ emit itemsChanged(start.row(), end.row() - start.row() + 1, roles());
+}
+
+/*!
+ \qmlproperty bool FolderListModel::showDirs
+
+ If true (the default), directories are included in the model.
+
+ Note that the nameFilters are ignored for directories.
+*/
+bool QDeclarativeFolderListModel::showDirs() const
+{
+ return d->model.filter() & QDir::AllDirs;
+}
+
+void QDeclarativeFolderListModel::setShowDirs(bool on)
+{
+ if (!(d->model.filter() & QDir::AllDirs) == !on)
+ return;
+ if (on)
+ d->model.setFilter(d->model.filter() | QDir::AllDirs | QDir::Drives);
+ else
+ d->model.setFilter(d->model.filter() & ~(QDir::AllDirs | QDir::Drives));
+}
+
+/*!
+ \qmlproperty bool FolderListModel::showDotAndDotDot
+
+ If true, the "." and ".." directories are included in the model.
+
+ The default is false.
+*/
+bool QDeclarativeFolderListModel::showDotAndDotDot() const
+{
+ return !(d->model.filter() & QDir::NoDotAndDotDot);
+}
+
+void QDeclarativeFolderListModel::setShowDotAndDotDot(bool on)
+{
+ if (!(d->model.filter() & QDir::NoDotAndDotDot) == on)
+ return;
+ if (on)
+ d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot);
+ else
+ d->model.setFilter(d->model.filter() | QDir::NoDotAndDotDot);
+}
+
+/*!
+ \qmlproperty bool FolderListModel::showOnlyReadable
+
+ If true, only readable files and directories are shown.
+
+ The default is false.
+*/
+bool QDeclarativeFolderListModel::showOnlyReadable() const
+{
+ return d->model.filter() & QDir::Readable;
+}
+
+void QDeclarativeFolderListModel::setShowOnlyReadable(bool on)
+{
+ if (!(d->model.filter() & QDir::Readable) == !on)
+ return;
+ if (on)
+ d->model.setFilter(d->model.filter() | QDir::Readable);
+ else
+ d->model.setFilter(d->model.filter() & ~QDir::Readable);
+}
+
+void QDeclarativeFolderListModel::registerTypes()
+{
+ QML_REGISTER_TYPE(Qt,4,6,FolderListModel,QDeclarativeFolderListModel);
+}
+
+QT_END_NAMESPACE
+
diff --git a/tools/qml/qdeclarativefolderlistmodel.h b/tools/qml/qdeclarativefolderlistmodel.h
new file mode 100644
index 0000000000..57b7fe5d62
--- /dev/null
+++ b/tools/qml/qdeclarativefolderlistmodel.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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEFOLDERLISTMODEL_H
+#define QDECLARATIVEFOLDERLISTMODEL_H
+
+#include <qdeclarative.h>
+#include <QStringList>
+#include <QUrl>
+#include "../../src/declarative/3rdparty/qlistmodelinterface_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeContext;
+class QModelIndex;
+
+class QDeclarativeFolderListModelPrivate;
+class QDeclarativeFolderListModel : public QListModelInterface, public QDeclarativeParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QDeclarativeParserStatus)
+
+ Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged)
+ Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
+ Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
+ Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
+ Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
+ Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
+ Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
+
+public:
+ QDeclarativeFolderListModel(QObject *parent = 0);
+ ~QDeclarativeFolderListModel();
+
+ static void registerTypes();
+
+ virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
+ virtual QVariant data(int index, int role) const;
+ virtual int count() const;
+ virtual QList<int> roles() const;
+ virtual QString toString(int role) const;
+
+ QUrl folder() const;
+ void setFolder(const QUrl &folder);
+
+ QUrl parentFolder() const;
+
+ QStringList nameFilters() const;
+ void setNameFilters(const QStringList &filters);
+
+ virtual void componentComplete();
+
+ Q_INVOKABLE bool isFolder(int index) const;
+
+ enum SortField { Unsorted, Name, Time, Size, Type };
+ SortField sortField() const;
+ void setSortField(SortField field);
+ Q_ENUMS(SortField)
+
+ bool sortReversed() const;
+ void setSortReversed(bool rev);
+
+ bool showDirs() const;
+ void setShowDirs(bool);
+ bool showDotAndDotDot() const;
+ void setShowDotAndDotDot(bool);
+ bool showOnlyReadable() const;
+ void setShowOnlyReadable(bool);
+
+Q_SIGNALS:
+ void folderChanged();
+
+private Q_SLOTS:
+ void refresh();
+ void inserted(const QModelIndex &index, int start, int end);
+ void removed(const QModelIndex &index, int start, int end);
+ void dataChanged(const QModelIndex &start, const QModelIndex &end);
+
+private:
+ Q_DISABLE_COPY(QDeclarativeFolderListModel)
+ QDeclarativeFolderListModelPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeFolderListModel)
+
+#endif // QDECLARATIVEFOLDERLISTMODEL_H
diff --git a/tools/qml/qfxtester.cpp b/tools/qml/qfxtester.cpp
new file mode 100644
index 0000000000..638a3c92f3
--- /dev/null
+++ b/tools/qml/qfxtester.cpp
@@ -0,0 +1,381 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qfxtester.h>
+#include <QDebug>
+#include <QApplication>
+#include <qdeclarativeview.h>
+#include <QFile>
+#include <QDeclarativeComponent>
+#include <QDir>
+#include <QCryptographicHash>
+#include <private/qabstractanimation_p.h>
+#include <private/qdeclarativeitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts,
+ QDeclarativeView *parent)
+: QAbstractAnimation(parent), m_script(script), m_view(parent), filterEvents(true), options(opts),
+ testscript(0), hasCompleted(false), hasFailed(false)
+{
+ parent->viewport()->installEventFilter(this);
+ parent->installEventFilter(this);
+ QUnifiedTimer::instance()->setConsistentTiming(true);
+ if (options & QDeclarativeViewer::Play)
+ this->run();
+ start();
+}
+
+QDeclarativeTester::~QDeclarativeTester()
+{
+ if (!hasFailed &&
+ options & QDeclarativeViewer::Record &&
+ options & QDeclarativeViewer::SaveOnExit)
+ save();
+}
+
+int QDeclarativeTester::duration() const
+{
+ return -1;
+}
+
+void QDeclarativeTester::addMouseEvent(Destination dest, QMouseEvent *me)
+{
+ MouseEvent e(me);
+ e.destination = dest;
+ m_mouseEvents << e;
+}
+
+void QDeclarativeTester::addKeyEvent(Destination dest, QKeyEvent *ke)
+{
+ KeyEvent e(ke);
+ e.destination = dest;
+ m_keyEvents << e;
+}
+
+bool QDeclarativeTester::eventFilter(QObject *o, QEvent *e)
+{
+ if (!filterEvents)
+ return false;
+
+ Destination destination;
+ if (o == m_view) {
+ destination = View;
+ } else if (o == m_view->viewport()) {
+ destination = ViewPort;
+ } else {
+ return false;
+ }
+
+ switch (e->type()) {
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ addKeyEvent(destination, (QKeyEvent *)e);
+ return true;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonDblClick:
+ addMouseEvent(destination, (QMouseEvent *)e);
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+void QDeclarativeTester::executefailure()
+{
+ hasFailed = true;
+
+ if (options & QDeclarativeViewer::ExitOnFailure)
+ exit(-1);
+}
+
+void QDeclarativeTester::imagefailure()
+{
+ hasFailed = true;
+
+ if (options & QDeclarativeViewer::ExitOnFailure)
+ exit(-1);
+}
+
+void QDeclarativeTester::complete()
+{
+ if ((options & QDeclarativeViewer::TestErrorProperty) && !hasFailed) {
+ QString e = m_view->rootObject()->property("error").toString();
+ if (!e.isEmpty()) {
+ qWarning() << "Test failed:" << e;
+ hasFailed = true;
+ }
+ }
+ if (options & QDeclarativeViewer::ExitOnComplete)
+ QApplication::exit(hasFailed?-1:0);
+
+ if (hasCompleted)
+ return;
+ hasCompleted = true;
+
+ if (options & QDeclarativeViewer::Play)
+ qWarning("Script playback complete");
+}
+
+void QDeclarativeTester::run()
+{
+ QDeclarativeComponent c(m_view->engine(), m_script + QLatin1String(".qml"));
+
+ testscript = qobject_cast<QDeclarativeVisualTest *>(c.create());
+ if (testscript) testscript->setParent(this);
+ else { executefailure(); exit(-1); }
+ testscriptidx = 0;
+}
+
+void QDeclarativeTester::save()
+{
+ QString filename = m_script + QLatin1String(".qml");
+ QFileInfo filenameInfo(filename);
+ QDir saveDir = filenameInfo.absoluteDir();
+ saveDir.mkpath(".");
+
+ QFile file(filename);
+ file.open(QIODevice::WriteOnly);
+ QTextStream ts(&file);
+
+ ts << "import Qt.VisualTest 4.6\n\n";
+ ts << "VisualTest {\n";
+
+ int imgCount = 0;
+ QList<KeyEvent> keyevents = m_savedKeyEvents;
+ QList<MouseEvent> mouseevents = m_savedMouseEvents;
+ for (int ii = 0; ii < m_savedFrameEvents.count(); ++ii) {
+ const FrameEvent &fe = m_savedFrameEvents.at(ii);
+ ts << " Frame {\n";
+ ts << " msec: " << fe.msec << "\n";
+ if (!fe.hash.isEmpty()) {
+ ts << " hash: \"" << fe.hash.toHex() << "\"\n";
+ } else if (!fe.image.isNull()) {
+ QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png";
+ fe.image.save(m_script + "." + QString::number(imgCount) + ".png");
+ imgCount++;
+ ts << " image: \"" << filename << "\"\n";
+ }
+ ts << " }\n";
+
+ while (!mouseevents.isEmpty() &&
+ mouseevents.first().msec == fe.msec) {
+ MouseEvent me = mouseevents.takeFirst();
+
+ ts << " Mouse {\n";
+ ts << " type: " << me.type << "\n";
+ ts << " button: " << me.button << "\n";
+ ts << " buttons: " << me.buttons << "\n";
+ ts << " x: " << me.pos.x() << "; y: " << me.pos.y() << "\n";
+ ts << " modifiers: " << me.modifiers << "\n";
+ if (me.destination == ViewPort)
+ ts << " sendToViewport: true\n";
+ ts << " }\n";
+ }
+
+ while (!keyevents.isEmpty() &&
+ keyevents.first().msec == fe.msec) {
+ KeyEvent ke = keyevents.takeFirst();
+
+ ts << " Key {\n";
+ ts << " type: " << ke.type << "\n";
+ ts << " key: " << ke.key << "\n";
+ ts << " modifiers: " << ke.modifiers << "\n";
+ ts << " text: \"" << ke.text.toUtf8().toHex() << "\"\n";
+ ts << " autorep: " << (ke.autorep?"true":"false") << "\n";
+ ts << " count: " << ke.count << "\n";
+ if (ke.destination == ViewPort)
+ ts << " sendToViewport: true\n";
+ ts << " }\n";
+ }
+ }
+
+ ts << "}\n";
+ file.close();
+}
+
+void QDeclarativeTester::updateCurrentTime(int msec)
+{
+ QDeclarativeItemPrivate::setConsistentTime(msec);
+
+ QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32);
+
+ if (options & QDeclarativeViewer::TestImages) {
+ img.fill(qRgb(255,255,255));
+ QPainter p(&img);
+ m_view->render(&p);
+ }
+
+ FrameEvent fe;
+ fe.msec = msec;
+ if (msec == 0 || !(options & QDeclarativeViewer::TestImages)) {
+ // Skip first frame, skip if not doing images
+ } else if (0 == (m_savedFrameEvents.count() % 60)) {
+ fe.image = img;
+ } else {
+ QCryptographicHash hash(QCryptographicHash::Md5);
+ hash.addData((const char *)img.bits(), img.bytesPerLine() * img.height());
+ fe.hash = hash.result();
+ }
+ m_savedFrameEvents.append(fe);
+
+ // Deliver mouse events
+ filterEvents = false;
+
+ if (!testscript) {
+ for (int ii = 0; ii < m_mouseEvents.count(); ++ii) {
+ MouseEvent &me = m_mouseEvents[ii];
+ me.msec = msec;
+ QMouseEvent event(me.type, me.pos, me.button, me.buttons, me.modifiers);
+
+ if (me.destination == View) {
+ QCoreApplication::sendEvent(m_view, &event);
+ } else {
+ QCoreApplication::sendEvent(m_view->viewport(), &event);
+ }
+ }
+
+ for (int ii = 0; ii < m_keyEvents.count(); ++ii) {
+ KeyEvent &ke = m_keyEvents[ii];
+ ke.msec = msec;
+ QKeyEvent event(ke.type, ke.key, ke.modifiers, ke.text, ke.autorep, ke.count);
+
+ if (ke.destination == View) {
+ QCoreApplication::sendEvent(m_view, &event);
+ } else {
+ QCoreApplication::sendEvent(m_view->viewport(), &event);
+ }
+ }
+ m_savedMouseEvents.append(m_mouseEvents);
+ m_savedKeyEvents.append(m_keyEvents);
+ }
+
+ m_mouseEvents.clear();
+ m_keyEvents.clear();
+
+ // Advance test script
+ while (testscript && testscript->count() > testscriptidx) {
+
+ QObject *event = testscript->event(testscriptidx);
+
+ if (QDeclarativeVisualTestFrame *frame = qobject_cast<QDeclarativeVisualTestFrame *>(event)) {
+ if (frame->msec() < msec) {
+ if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) {
+ qWarning() << "QDeclarativeTester: Extra frame. Seen:"
+ << msec << "Expected:" << frame->msec();
+ imagefailure();
+ }
+ } else if (frame->msec() == msec) {
+ if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) {
+ if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) {
+ qWarning() << "QDeclarativeTester: Mismatched frame hash. Seen:"
+ << fe.hash.toHex() << "Expected:"
+ << frame->hash().toUtf8();
+ imagefailure();
+ }
+ }
+ } else if (frame->msec() > msec) {
+ break;
+ }
+
+ if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record) && !frame->image().isEmpty()) {
+ QImage goodImage(frame->image().toLocalFile());
+ if (goodImage != img) {
+ QString reject(frame->image().toLocalFile() + ".reject.png");
+ qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:"
+ << reject;
+ img.save(reject);
+ imagefailure();
+ }
+ }
+ } else if (QDeclarativeVisualTestMouse *mouse = qobject_cast<QDeclarativeVisualTestMouse *>(event)) {
+ QPoint pos(mouse->x(), mouse->y());
+ QPoint globalPos = m_view->mapToGlobal(QPoint(0, 0)) + pos;
+ QMouseEvent event((QEvent::Type)mouse->type(), pos, globalPos, (Qt::MouseButton)mouse->button(), (Qt::MouseButtons)mouse->buttons(), (Qt::KeyboardModifiers)mouse->modifiers());
+
+ MouseEvent me(&event);
+ me.msec = msec;
+ if (!mouse->sendToViewport()) {
+ QCoreApplication::sendEvent(m_view, &event);
+ me.destination = View;
+ } else {
+ QCoreApplication::sendEvent(m_view->viewport(), &event);
+ me.destination = ViewPort;
+ }
+ m_savedMouseEvents.append(me);
+ } else if (QDeclarativeVisualTestKey *key = qobject_cast<QDeclarativeVisualTestKey *>(event)) {
+
+ QKeyEvent event((QEvent::Type)key->type(), key->key(), (Qt::KeyboardModifiers)key->modifiers(), QString::fromUtf8(QByteArray::fromHex(key->text().toUtf8())), key->autorep(), key->count());
+
+ KeyEvent ke(&event);
+ ke.msec = msec;
+ if (!key->sendToViewport()) {
+ QCoreApplication::sendEvent(m_view, &event);
+ ke.destination = View;
+ } else {
+ QCoreApplication::sendEvent(m_view->viewport(), &event);
+ ke.destination = ViewPort;
+ }
+ m_savedKeyEvents.append(ke);
+ }
+ testscriptidx++;
+ }
+
+ filterEvents = true;
+
+ if (testscript && testscript->count() <= testscriptidx)
+ complete();
+}
+
+void QDeclarativeTester::registerTypes()
+{
+ QML_REGISTER_TYPE(Qt.VisualTest, 4,6, VisualTest, QDeclarativeVisualTest);
+ QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Frame, QDeclarativeVisualTestFrame);
+ QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Mouse, QDeclarativeVisualTestMouse);
+ QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Key, QDeclarativeVisualTestKey);
+}
+
+QT_END_NAMESPACE
diff --git a/tools/qml/qfxtester.h b/tools/qml/qfxtester.h
new file mode 100644
index 0000000000..1a9f07744a
--- /dev/null
+++ b/tools/qml/qfxtester.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 tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QFXTESTER_H
+#define QFXTESTER_H
+
+#include <QEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QImage>
+#include <QUrl>
+#include <qmlruntime.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeVisualTest : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QList<QObject *>* events READ events CONSTANT)
+ Q_CLASSINFO("DefaultProperty", "events")
+public:
+ QDeclarativeVisualTest() {}
+
+ QList<QObject *> *events() { return &m_events; }
+
+ int count() const { return m_events.count(); }
+ QObject *event(int idx) { return m_events.at(idx); }
+
+private:
+ QList<QObject *> m_events;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeVisualTest)
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeVisualTestFrame : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int msec READ msec WRITE setMsec)
+ Q_PROPERTY(QString hash READ hash WRITE setHash)
+ Q_PROPERTY(QUrl image READ image WRITE setImage)
+public:
+ QDeclarativeVisualTestFrame() : m_msec(-1) {}
+
+ int msec() const { return m_msec; }
+ void setMsec(int m) { m_msec = m; }
+
+ QString hash() const { return m_hash; }
+ void setHash(const QString &hash) { m_hash = hash; }
+
+ QUrl image() const { return m_image; }
+ void setImage(const QUrl &image) { m_image = image; }
+
+private:
+ int m_msec;
+ QString m_hash;
+ QUrl m_image;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeVisualTestFrame)
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeVisualTestMouse : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int type READ type WRITE setType)
+ Q_PROPERTY(int button READ button WRITE setButton)
+ Q_PROPERTY(int buttons READ buttons WRITE setButtons)
+ Q_PROPERTY(int x READ x WRITE setX)
+ Q_PROPERTY(int y READ y WRITE setY)
+ Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers)
+ Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport)
+public:
+ QDeclarativeVisualTestMouse() : m_type(0), m_button(0), m_buttons(0), m_x(0), m_y(0), m_modifiers(0), m_viewport(false) {}
+
+ int type() const { return m_type; }
+ void setType(int t) { m_type = t; }
+
+ int button() const { return m_button; }
+ void setButton(int b) { m_button = b; }
+
+ int buttons() const { return m_buttons; }
+ void setButtons(int b) { m_buttons = b; }
+
+ int x() const { return m_x; }
+ void setX(int x) { m_x = x; }
+
+ int y() const { return m_y; }
+ void setY(int y) { m_y = y; }
+
+ int modifiers() const { return m_modifiers; }
+ void setModifiers(int modifiers) { m_modifiers = modifiers; }
+
+ bool sendToViewport() const { return m_viewport; }
+ void setSendToViewport(bool v) { m_viewport = v; }
+private:
+ int m_type;
+ int m_button;
+ int m_buttons;
+ int m_x;
+ int m_y;
+ int m_modifiers;
+ bool m_viewport;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeVisualTestMouse)
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeVisualTestKey : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int type READ type WRITE setType)
+ Q_PROPERTY(int key READ key WRITE setKey)
+ Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers)
+ Q_PROPERTY(QString text READ text WRITE setText)
+ Q_PROPERTY(bool autorep READ autorep WRITE setAutorep)
+ Q_PROPERTY(int count READ count WRITE setCount)
+ Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport)
+public:
+ QDeclarativeVisualTestKey() : m_type(0), m_key(0), m_modifiers(0), m_autorep(false), m_count(0), m_viewport(false) {}
+
+ int type() const { return m_type; }
+ void setType(int t) { m_type = t; }
+
+ int key() const { return m_key; }
+ void setKey(int k) { m_key = k; }
+
+ int modifiers() const { return m_modifiers; }
+ void setModifiers(int m) { m_modifiers = m; }
+
+ QString text() const { return m_text; }
+ void setText(const QString &t) { m_text = t; }
+
+ bool autorep() const { return m_autorep; }
+ void setAutorep(bool a) { m_autorep = a; }
+
+ int count() const { return m_count; }
+ void setCount(int c) { m_count = c; }
+
+ bool sendToViewport() const { return m_viewport; }
+ void setSendToViewport(bool v) { m_viewport = v; }
+private:
+ int m_type;
+ int m_key;
+ int m_modifiers;
+ QString m_text;
+ bool m_autorep;
+ int m_count;
+ bool m_viewport;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QDeclarativeVisualTestKey)
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeTester : public QAbstractAnimation
+{
+public:
+ QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions options, QDeclarativeView *parent);
+ ~QDeclarativeTester();
+
+ static void registerTypes();
+
+ virtual int duration() const;
+
+ void run();
+ void save();
+
+ void executefailure();
+protected:
+ virtual void updateCurrentTime(int msecs);
+ virtual bool eventFilter(QObject *, QEvent *);
+
+private:
+ QString m_script;
+
+ void imagefailure();
+ void complete();
+
+ enum Destination { View, ViewPort };
+ void addKeyEvent(Destination, QKeyEvent *);
+ void addMouseEvent(Destination, QMouseEvent *);
+ QDeclarativeView *m_view;
+
+ struct MouseEvent {
+ MouseEvent(QMouseEvent *e)
+ : type(e->type()), button(e->button()), buttons(e->buttons()),
+ pos(e->pos()), modifiers(e->modifiers()), destination(View) {}
+
+ QEvent::Type type;
+ Qt::MouseButton button;
+ Qt::MouseButtons buttons;
+ QPoint pos;
+ Qt::KeyboardModifiers modifiers;
+ Destination destination;
+
+ int msec;
+ };
+ struct KeyEvent {
+ KeyEvent(QKeyEvent *e)
+ : type(e->type()), key(e->key()), modifiers(e->modifiers()), text(e->text()),
+ autorep(e->isAutoRepeat()), count(e->count()), destination(View) {}
+ QEvent::Type type;
+ int key;
+ Qt::KeyboardModifiers modifiers;
+ QString text;
+ bool autorep;
+ ushort count;
+ Destination destination;
+
+ int msec;
+ };
+ struct FrameEvent {
+ QImage image;
+ QByteArray hash;
+ int msec;
+ };
+ QList<MouseEvent> m_mouseEvents;
+ QList<KeyEvent> m_keyEvents;
+
+ QList<MouseEvent> m_savedMouseEvents;
+ QList<KeyEvent> m_savedKeyEvents;
+ QList<FrameEvent> m_savedFrameEvents;
+ bool filterEvents;
+
+ QDeclarativeViewer::ScriptOptions options;
+ int testscriptidx;
+ QDeclarativeVisualTest *testscript;
+
+ bool hasCompleted;
+ bool hasFailed;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QFXTESTER_H
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
new file mode 100644
index 0000000000..9c9c398eb6
--- /dev/null
+++ b/tools/qml/qml.pro
@@ -0,0 +1,58 @@
+TEMPLATE = app
+CONFIG += qt \
+ uic
+DESTDIR = ../../bin
+QT += declarative \
+ script \
+ network \
+ sql
+
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+ DEFINES += GL_SUPPORTED
+}
+
+# Input
+HEADERS += qmlruntime.h \
+ proxysettings.h \
+ qfxtester.h \
+ deviceorientation.h \
+ qdeclarativefolderlistmodel.h
+SOURCES += main.cpp \
+ qmlruntime.cpp \
+ proxysettings.cpp \
+ qfxtester.cpp \
+ qdeclarativefolderlistmodel.cpp
+RESOURCES = qmlruntime.qrc
+maemo5 {
+ SOURCES += deviceorientation_maemo.cpp
+} else {
+ SOURCES += deviceorientation.cpp
+}
+FORMS = recopts.ui \
+ proxysettings.ui
+INCLUDEPATH += ../../include/QtDeclarative
+INCLUDEPATH += ../../src/declarative/util
+INCLUDEPATH += ../../src/declarative/graphicsitems
+include(../shared/deviceskin/deviceskin.pri)
+target.path = $$[QT_INSTALL_BINS]
+INSTALLS += target
+
+wince* {
+QT += scripttools \
+ xml \
+ xmlpatterns \
+ phonon
+
+ contains(QT_CONFIG, webkit) {
+ QT += webkit
+ }
+}
+symbian {
+# TARGET.UID3 =
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
+ HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h
+ LIBS += -lesock -lconnmon -linsock
+ TARGET.CAPABILITY = "All -TCB"
+}
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
new file mode 100644
index 0000000000..7da3f5a54a
--- /dev/null
+++ b/tools/qml/qmlruntime.cpp
@@ -0,0 +1,1468 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qdeclarativeview.h>
+
+#ifdef hz
+#undef hz
+#endif
+#include "ui_recopts.h"
+
+#include "qmlruntime.h"
+#include <qdeclarativecontext.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativenetworkaccessmanagerfactory.h>
+#include "qdeclarative.h"
+#include <private/qperformancelog_p_p.h>
+#include <private/qabstractanimation_p.h>
+#include <QAbstractAnimation>
+#include "deviceskin.h"
+
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3))
+#include <private/qzipreader_p.h>
+#define QDECLARATIVEVIEWER_ZIP_SUPPORT
+#endif
+
+#include <QSettings>
+#include <QXmlStreamReader>
+#include <QBuffer>
+#include <QNetworkReply>
+#include <QNetworkCookieJar>
+#include <QNetworkDiskCache>
+#include <QNetworkAccessManager>
+#include <QSignalMapper>
+#include <QDeclarativeComponent>
+#include <QWidget>
+#include <QApplication>
+#include <QDir>
+#include <QTextBrowser>
+#include <QFile>
+#include <QFileInfo>
+#include <QVBoxLayout>
+#include <QProgressDialog>
+#include <QProcess>
+#include <QMenuBar>
+#include <QMenu>
+#include <QAction>
+#include <QFileDialog>
+#include <QTimer>
+#include <QGraphicsObject>
+#include <QNetworkProxyFactory>
+#include <QKeyEvent>
+#include <QMutex>
+#include <QMutexLocker>
+#include "proxysettings.h"
+#include "deviceorientation.h"
+
+#ifdef GL_SUPPORTED
+#include <QGLWidget>
+#endif
+
+#include <qfxtester.h>
+
+#if defined (Q_OS_SYMBIAN)
+#define SYMBIAN_NETWORK_INIT
+#endif
+
+#if defined (SYMBIAN_NETWORK_INIT)
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <QTextCodec>
+#include "sym_iap_util.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class Screen : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(Orientation orientation READ orientation NOTIFY orientationChanged)
+ Q_ENUMS(Orientation)
+
+public:
+ Screen(QObject *parent=0) : QObject(parent) {
+ connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()),
+ this, SIGNAL(orientationChanged()));
+ }
+
+ enum Orientation { UnknownOrientation = DeviceOrientation::UnknownOrientation,
+ Portrait = DeviceOrientation::Portrait,
+ Landscape = DeviceOrientation::Landscape };
+ Orientation orientation() const { return Orientation(DeviceOrientation::instance()->orientation()); }
+
+signals:
+ void orientationChanged();
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(Screen)
+
+QT_BEGIN_NAMESPACE
+
+class SizedMenuBar : public QMenuBar
+{
+ Q_OBJECT
+public:
+ SizedMenuBar(QWidget *parent, QWidget *referenceWidget)
+ : QMenuBar(parent), refWidget(referenceWidget)
+ {
+ }
+
+ virtual QSize sizeHint() const
+ {
+ return QSize(refWidget->sizeHint().width(), QMenuBar::sizeHint().height());
+ }
+
+private:
+ QWidget *refWidget;
+};
+
+
+class PreviewDeviceSkin : public DeviceSkin
+{
+ Q_OBJECT
+public:
+ explicit PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent);
+
+ void setPreview(QWidget *formWidget);
+ void setPreviewAndScale(QWidget *formWidget);
+
+ void setScreenSize(const QSize& size)
+ {
+ QMatrix fit;
+ fit = fit.scale(qreal(size.width())/m_screenSize.width(),
+ qreal(size.height())/m_screenSize.height());
+ setTransform(fit);
+ QApplication::syncX();
+ }
+
+ QSize standardScreenSize() const { return m_screenSize; }
+
+ QMenu* menu;
+
+private slots:
+ void slotSkinKeyPressEvent(int code, const QString& text, bool autorep);
+ void slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep);
+ void slotPopupMenu();
+
+private:
+ const QSize m_screenSize;
+};
+
+
+PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent) :
+ DeviceSkin(parameters, parent),
+ m_screenSize(parameters.screenSize())
+{
+ menu = new QMenu(this);
+ connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)),
+ this, SLOT(slotSkinKeyPressEvent(int,QString,bool)));
+ connect(this, SIGNAL(skinKeyReleaseEvent(int,QString,bool)),
+ this, SLOT(slotSkinKeyReleaseEvent(int,QString,bool)));
+ connect(this, SIGNAL(popupMenu()), this, SLOT(slotPopupMenu()));
+}
+
+void PreviewDeviceSkin::setPreview(QWidget *formWidget)
+{
+ formWidget->setFixedSize(m_screenSize);
+ formWidget->setParent(this, Qt::SubWindow);
+ formWidget->setAutoFillBackground(true);
+ setView(formWidget);
+}
+
+void PreviewDeviceSkin::setPreviewAndScale(QWidget *formWidget)
+{
+ setScreenSize(formWidget->sizeHint());
+ formWidget->setParent(this, Qt::SubWindow);
+ formWidget->setAutoFillBackground(true);
+ setView(formWidget);
+}
+
+void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, bool autorep)
+{
+ if (QWidget *focusWidget = QApplication::focusWidget()) {
+ QKeyEvent e(QEvent::KeyPress,code,0,text,autorep);
+ QApplication::sendEvent(focusWidget, &e);
+ }
+
+}
+
+void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep)
+{
+ if (QWidget *focusWidget = QApplication::focusWidget()) {
+ QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep);
+ QApplication::sendEvent(focusWidget, &e);
+ }
+}
+
+void PreviewDeviceSkin::slotPopupMenu()
+{
+ menu->exec(QCursor::pos());
+}
+
+static struct { const char *name, *args; } ffmpegprofiles[] = {
+ {"Maximum Quality", "-sameq"},
+ {"High Quality", "-qmax 2"},
+ {"Medium Quality", "-qmax 6"},
+ {"Low Quality", "-qmax 16"},
+ {"Custom ffmpeg arguments", ""},
+ {0,0}
+};
+
+class RecordingDialog : public QDialog, public Ui::RecordingOptions {
+ Q_OBJECT
+
+public:
+ RecordingDialog(QWidget *parent) : QDialog(parent)
+ {
+ setupUi(this);
+ hz->setValidator(new QDoubleValidator(hz));
+ for (int i=0; ffmpegprofiles[i].name; ++i) {
+ profile->addItem(ffmpegprofiles[i].name);
+ }
+ }
+
+ void setArguments(QString a)
+ {
+ int i;
+ for (i=0; ffmpegprofiles[i].args[0]; ++i) {
+ if (ffmpegprofiles[i].args == a) {
+ profile->setCurrentIndex(i);
+ args->setText(QLatin1String(ffmpegprofiles[i].args));
+ return;
+ }
+ }
+ customargs = a;
+ args->setText(a);
+ profile->setCurrentIndex(i);
+ }
+
+ QString arguments() const
+ {
+ int i = profile->currentIndex();
+ return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs;
+ }
+
+private slots:
+ void pickProfile(int i)
+ {
+ if (ffmpegprofiles[i].args[0]) {
+ args->setText(QLatin1String(ffmpegprofiles[i].args));
+ } else {
+ args->setText(customargs);
+ }
+ }
+
+ void storeCustomArgs(QString s)
+ {
+ setArguments(s);
+ }
+
+private:
+ QString customargs;
+};
+
+class PersistentCookieJar : public QNetworkCookieJar {
+public:
+ PersistentCookieJar(QObject *parent) : QNetworkCookieJar(parent) { load(); }
+ ~PersistentCookieJar() { save(); }
+
+ virtual QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const
+ {
+ QMutexLocker lock(&mutex);
+ return QNetworkCookieJar::cookiesForUrl(url);
+ }
+
+ virtual bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url)
+ {
+ QMutexLocker lock(&mutex);
+ return QNetworkCookieJar::setCookiesFromUrl(cookieList, url);
+ }
+
+private:
+ void save()
+ {
+ QMutexLocker lock(&mutex);
+ QList<QNetworkCookie> list = allCookies();
+ QByteArray data;
+ foreach (QNetworkCookie cookie, list) {
+ if (!cookie.isSessionCookie()) {
+ data.append(cookie.toRawForm());
+ data.append("\n");
+ }
+ }
+ QSettings settings("Nokia", "QtQmlViewer");
+ settings.setValue("Cookies",data);
+ }
+
+ void load()
+ {
+ QMutexLocker lock(&mutex);
+ QSettings settings("Nokia", "QtQmlViewer");
+ QByteArray data = settings.value("Cookies").toByteArray();
+ setAllCookies(QNetworkCookie::parseCookies(data));
+ }
+
+ mutable QMutex mutex;
+};
+
+class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
+{
+public:
+ NetworkAccessManagerFactory() : cookieJar(0), cacheSize(0) {}
+ ~NetworkAccessManagerFactory() {
+ delete cookieJar;
+ }
+
+ QNetworkAccessManager *create(QObject *parent) {
+ QMutexLocker lock(&mutex);
+ QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
+ if (!cookieJar)
+ cookieJar = new PersistentCookieJar(0);
+ manager->setCookieJar(cookieJar);
+ cookieJar->setParent(0);
+ setupProxy(manager);
+ if (cacheSize > 0) {
+ QNetworkDiskCache *cache = new QNetworkDiskCache;
+ cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache"));
+ cache->setMaximumCacheSize(cacheSize);
+ manager->setCache(cache);
+ } else {
+ manager->setCache(0);
+ }
+ qDebug() << "created new network access manager for" << parent;
+ return manager;
+ }
+
+ void setupProxy(QNetworkAccessManager *nam)
+ {
+ class SystemProxyFactory : public QNetworkProxyFactory
+ {
+ public:
+ virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query)
+ {
+ QString protocolTag = query.protocolTag();
+ if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
+ QList<QNetworkProxy> ret;
+ ret << httpProxy;
+ return ret;
+ }
+ return QNetworkProxyFactory::systemProxyForQuery(query);
+ }
+ void setHttpProxy (QNetworkProxy proxy)
+ {
+ httpProxy = proxy;
+ httpProxyInUse = true;
+ }
+ void unsetHttpProxy ()
+ {
+ httpProxyInUse = false;
+ }
+ private:
+ bool httpProxyInUse;
+ QNetworkProxy httpProxy;
+ };
+
+ SystemProxyFactory *proxyFactory = new SystemProxyFactory;
+ if (ProxySettings::httpProxyInUse())
+ proxyFactory->setHttpProxy(ProxySettings::httpProxy());
+ else
+ proxyFactory->unsetHttpProxy();
+ nam->setProxyFactory(proxyFactory);
+ }
+
+ void setCacheSize(int size) {
+ if (size != cacheSize) {
+ cacheSize = size;
+ }
+ }
+
+ PersistentCookieJar *cookieJar;
+ QMutex mutex;
+ int cacheSize;
+};
+
+
+QString QDeclarativeViewer::getVideoFileName()
+{
+ QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames");
+ QStringList types;
+ if (ffmpegAvailable) types += tr("Common Video files")+QLatin1String(" (*.avi *.mpeg *.mov)");
+ if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)");
+ types += tr("Individual PNG frames")+QLatin1String(" (*.png)");
+ if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)");
+ return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
+}
+
+
+QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
+#if defined(Q_OS_SYMBIAN)
+ : QMainWindow(parent, flags)
+#else
+ : QWidget(parent, flags)
+#endif
+ , frame_stream(0), scaleSkin(true), mb(0)
+ , portraitOrientation(0), landscapeOrientation(0)
+ , m_scriptOptions(0), tester(0), useQmlFileBrowser(true)
+{
+ devicemode = false;
+ skin = 0;
+ canvas = 0;
+ record_autotime = 0;
+ record_rate = 50;
+ record_args += QLatin1String("-sameq");
+
+ recdlg = new RecordingDialog(this);
+ connect(recdlg->pickfile, SIGNAL(clicked()), this, SLOT(pickRecordingFile()));
+ senseFfmpeg();
+ senseImageMagick();
+ if (!ffmpegAvailable)
+ recdlg->ffmpegOptions->hide();
+ if (!ffmpegAvailable && !convertAvailable)
+ recdlg->rateOptions->hide();
+ QString warn;
+ if (!ffmpegAvailable) {
+ if (!convertAvailable)
+ warn = tr("ffmpeg and ImageMagick not available - no video output");
+ else
+ warn = tr("ffmpeg not available - GIF and PNG outputs only");
+ recdlg->warning->setText(warn);
+ } else {
+ recdlg->warning->hide();
+ }
+
+ canvas = new QDeclarativeView(this);
+ canvas->setAttribute(Qt::WA_OpaquePaintEvent);
+ canvas->setAttribute(Qt::WA_NoSystemBackground);
+ canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject);
+ canvas->setFocus();
+
+ QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
+ QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
+ QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
+
+ if (!(flags & Qt::FramelessWindowHint)) {
+ createMenu(menuBar(),0);
+ setPortrait();
+ }
+
+#if !defined(Q_OS_SYMBIAN)
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setMargin(0);
+ layout->setSpacing(0);
+ setLayout(layout);
+ if (mb)
+ layout->addWidget(mb);
+ layout->addWidget(canvas);
+#else
+ setCentralWidget(canvas);
+#endif
+
+ namFactory = new NetworkAccessManagerFactory;
+ canvas->engine()->setNetworkAccessManagerFactory(namFactory);
+
+ connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording()));
+ connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording()));
+ connect(&recordTimer, SIGNAL(triggered()), this, SLOT(recordFrame()));
+ autoStartTimer.setRunning(false);
+ autoStopTimer.setRunning(false);
+ recordTimer.setRunning(false);
+ recordTimer.setRepeating(true);
+}
+
+QDeclarativeViewer::~QDeclarativeViewer()
+{
+ canvas->engine()->setNetworkAccessManagerFactory(0);
+ delete namFactory;
+}
+
+QMenuBar *QDeclarativeViewer::menuBar() const
+{
+#if !defined(Q_OS_SYMBIAN)
+ if (!mb)
+ mb = new SizedMenuBar((QWidget*)this, canvas);
+#else
+ mb = QMainWindow::menuBar();
+#endif
+
+ return mb;
+}
+
+void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
+{
+ QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu;
+
+ QMenu *fileMenu = flatmenu ? flatmenu : menu->addMenu(tr("&File"));
+
+ QAction *openAction = new QAction(tr("&Open..."), parent);
+ openAction->setShortcut(QKeySequence("Ctrl+O"));
+ connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
+ fileMenu->addAction(openAction);
+
+ QAction *reloadAction = new QAction(tr("&Reload"), parent);
+ reloadAction->setShortcut(QKeySequence("Ctrl+R"));
+ connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
+ fileMenu->addAction(reloadAction);
+
+#if defined(Q_OS_SYMBIAN)
+ QAction *networkAction = new QAction(tr("Start &Network"), parent);
+ connect(networkAction, SIGNAL(triggered()), this, SLOT(startNetwork()));
+ fileMenu->addAction(networkAction);
+#endif
+
+#if !defined(Q_OS_SYMBIAN)
+ if (flatmenu) flatmenu->addSeparator();
+
+ QMenu *recordMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Recording"));
+
+ QAction *snapshotAction = new QAction(tr("&Take Snapshot\tF3"), parent);
+ connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
+ recordMenu->addAction(snapshotAction);
+
+ recordAction = new QAction(tr("Start Recording &Video\tF9"), parent);
+ connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
+ recordMenu->addAction(recordAction);
+
+ QAction *recordOptions = new QAction(tr("Video &Options..."), parent);
+ connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
+
+ if (flatmenu)
+ flatmenu->addAction(recordOptions);
+
+ if (flatmenu) flatmenu->addSeparator();
+
+ QMenu *debugMenu = flatmenu ? flatmenu->addMenu(tr("&Debugging")) : menu->addMenu(tr("&Debugging"));
+
+ QAction *slowAction = new QAction(tr("&Slow Down Animations"), parent);
+ slowAction->setShortcut(QKeySequence("Ctrl+."));
+ slowAction->setCheckable(true);
+ connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool)));
+ debugMenu->addAction(slowAction);
+
+ if (flatmenu) flatmenu->addSeparator();
+
+ QMenu *skinMenu = flatmenu ? flatmenu->addMenu(tr("&Skin")) : menu->addMenu(tr("&Skin"));
+
+ QActionGroup *skinActions;
+ QAction *skinAction;
+
+ skinActions = new QActionGroup(parent);
+ skinAction = new QAction(tr("Scale skin"), parent);
+ skinAction->setCheckable(true);
+ skinAction->setChecked(scaleSkin);
+ skinActions->addAction(skinAction);
+ skinMenu->addAction(skinAction);
+ connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleSkin()));
+ skinAction = new QAction(tr("Resize view"), parent);
+ skinAction->setCheckable(true);
+ skinAction->setChecked(!scaleSkin);
+ skinActions->addAction(skinAction);
+ skinMenu->addAction(skinAction);
+ connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleView()));
+ skinMenu->addSeparator();
+
+ skinActions = new QActionGroup(parent);
+ QSignalMapper *mapper = new QSignalMapper(parent);
+ skinAction = new QAction(tr("None"), parent);
+ skinAction->setCheckable(true);
+ if (currentSkin.isEmpty())
+ skinAction->setChecked(true);
+ skinActions->addAction(skinAction);
+ skinMenu->addAction(skinAction);
+ mapper->setMapping(skinAction, "");
+ connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map()));
+ skinMenu->addSeparator();
+
+ foreach (QString name, builtinSkins()) {
+ skinAction = new QAction(name, parent);
+ skinActions->addAction(skinAction);
+ skinMenu->addAction(skinAction);
+ skinAction->setCheckable(true);
+ if (":skin/"+name+".skin" == currentSkin)
+ skinAction->setChecked(true);
+ mapper->setMapping(skinAction, name);
+ connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map()));
+ }
+ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setSkin(QString)));
+
+ if (flatmenu) flatmenu->addSeparator();
+#endif // Q_OS_SYMBIAN
+
+ QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings"));
+ QAction *proxyAction = new QAction(tr("Http &proxy..."), parent);
+ connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings()));
+ settingsMenu->addAction(proxyAction);
+#if !defined(Q_OS_SYMBIAN)
+ if (!flatmenu)
+ settingsMenu->addAction(recordOptions);
+#else
+ QAction *fullscreenAction = new QAction(tr("Full Screen"), parent);
+ fullscreenAction->setCheckable(true);
+ connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
+ settingsMenu->addAction(fullscreenAction);
+#endif
+
+ QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
+ QActionGroup *orientation = new QActionGroup(parent);
+
+ QAction *toggleOrientation = new QAction(tr("&Toggle Orientation"), parent);
+ toggleOrientation->setCheckable(true);
+ toggleOrientation->setShortcut(QKeySequence("Ctrl+T"));
+ settingsMenu->addAction(toggleOrientation);
+ connect(toggleOrientation, SIGNAL(triggered()), this, SLOT(toggleOrientation()));
+
+ orientation->setExclusive(true);
+ portraitOrientation = new QAction(tr("orientation: Portrait"), parent);
+ portraitOrientation->setCheckable(true);
+ connect(portraitOrientation, SIGNAL(triggered()), this, SLOT(setPortrait()));
+ orientation->addAction(portraitOrientation);
+ propertiesMenu->addAction(portraitOrientation);
+
+ landscapeOrientation = new QAction(tr("orientation: Landscape"), parent);
+ landscapeOrientation->setCheckable(true);
+ connect(landscapeOrientation, SIGNAL(triggered()), this, SLOT(setLandscape()));
+ orientation->addAction(landscapeOrientation);
+ propertiesMenu->addAction(landscapeOrientation);
+
+ if (flatmenu) flatmenu->addSeparator();
+
+ QMenu *helpMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Help"));
+ QAction *aboutAction = new QAction(tr("&About Qt..."), parent);
+ connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ helpMenu->addAction(aboutAction);
+
+ QAction *quitAction = new QAction(tr("&Quit"), parent);
+ quitAction->setShortcut(QKeySequence("Ctrl+Q"));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ fileMenu->addSeparator();
+ fileMenu->addAction(quitAction);
+ if (menu) {
+ menu->setFixedHeight(menu->sizeHint().height());
+ menu->setMinimumWidth(10);
+ }
+}
+
+void QDeclarativeViewer::showProxySettings()
+{
+ ProxySettings settingsDlg (this);
+
+ connect (&settingsDlg, SIGNAL (accepted()), this, SLOT (proxySettingsChanged ()));
+
+ settingsDlg.exec();
+}
+
+void QDeclarativeViewer::proxySettingsChanged()
+{
+ reload ();
+}
+
+void QDeclarativeViewer::setPortrait()
+{
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
+ portraitOrientation->setChecked(true);
+}
+
+void QDeclarativeViewer::setLandscape()
+{
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape);
+ landscapeOrientation->setChecked(true);
+}
+
+void QDeclarativeViewer::toggleOrientation()
+{
+ DeviceOrientation::instance()->setOrientation(DeviceOrientation::instance()->orientation()==DeviceOrientation::Portrait?DeviceOrientation::Landscape:DeviceOrientation::Portrait);
+}
+
+void QDeclarativeViewer::toggleFullScreen()
+{
+ if (isFullScreen())
+ showMaximized();
+ else
+ showFullScreen();
+}
+
+void QDeclarativeViewer::setScaleSkin()
+{
+ if (scaleSkin)
+ return;
+ scaleSkin = true;
+ canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject);
+ if (skin) {
+ canvas->setFixedSize(canvas->sizeHint());
+ skin->setScreenSize(canvas->sizeHint());
+ }
+}
+
+void QDeclarativeViewer::setScaleView()
+{
+ if (!scaleSkin)
+ return;
+ scaleSkin = false;
+ if (skin) {
+ canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject);
+ canvas->setMinimumSize(QSize(0,0));
+ canvas->setMaximumSize(QSize(16777215,16777215));
+ canvas->resize(skin->standardScreenSize());
+ skin->setScreenSize(skin->standardScreenSize());
+ }
+}
+
+
+void QDeclarativeViewer::takeSnapShot()
+{
+ static int snapshotcount = 1;
+ QString snapFileName = QString(QLatin1String("snapshot%1.png")).arg(snapshotcount);
+ QPixmap::grabWidget(canvas).save(snapFileName);
+ qDebug() << "Wrote" << snapFileName;
+ ++snapshotcount;
+}
+
+void QDeclarativeViewer::pickRecordingFile()
+{
+ QString fileName = getVideoFileName();
+ if (!fileName.isEmpty())
+ recdlg->file->setText(fileName);
+}
+
+void QDeclarativeViewer::chooseRecordingOptions()
+{
+ // File
+ recdlg->file->setText(record_file);
+
+ // Size
+ recdlg->sizeOriginal->setText(tr("Original (%1x%2)").arg(canvas->width()).arg(canvas->height()));
+ if (recdlg->sizeWidth->value()<=1) {
+ recdlg->sizeWidth->setValue(canvas->width());
+ recdlg->sizeHeight->setValue(canvas->height());
+ }
+
+ // Rate
+ if (record_rate == 24)
+ recdlg->hz24->setChecked(true);
+ else if (record_rate == 25)
+ recdlg->hz25->setChecked(true);
+ else if (record_rate == 50)
+ recdlg->hz50->setChecked(true);
+ else if (record_rate == 60)
+ recdlg->hz60->setChecked(true);
+ else {
+ recdlg->hzCustom->setChecked(true);
+ recdlg->hz->setText(QString::number(record_rate));
+ }
+
+ // Profile
+ recdlg->setArguments(record_args.join(" "));
+ if (recdlg->exec()) {
+ // File
+ record_file = recdlg->file->text();
+ // Size
+ if (recdlg->sizeOriginal->isChecked())
+ record_outsize = QSize();
+ else if (recdlg->size720p->isChecked())
+ record_outsize = QSize(1280,720);
+ else if (recdlg->sizeVGA->isChecked())
+ record_outsize = QSize(640,480);
+ else if (recdlg->sizeQVGA->isChecked())
+ record_outsize = QSize(320,240);
+ else
+ record_outsize = QSize(recdlg->sizeWidth->value(),recdlg->sizeHeight->value());
+ // Rate
+ if (recdlg->hz24->isChecked())
+ record_rate = 24;
+ else if (recdlg->hz25->isChecked())
+ record_rate = 25;
+ else if (recdlg->hz50->isChecked())
+ record_rate = 50;
+ else if (recdlg->hz60->isChecked())
+ record_rate = 60;
+ else {
+ record_rate = recdlg->hz->text().toDouble();
+ }
+ // Profile
+ record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts);
+ }
+}
+
+void QDeclarativeViewer::toggleRecordingWithSelection()
+{
+ if (!recordTimer.isRunning()) {
+ if (record_file.isEmpty()) {
+ QString fileName = getVideoFileName();
+ if (fileName.isEmpty())
+ return;
+ if (!fileName.contains(QRegExp(".[^\\/]*$")))
+ fileName += ".avi";
+ setRecordFile(fileName);
+ }
+ }
+ toggleRecording();
+}
+
+void QDeclarativeViewer::toggleRecording()
+{
+ if (record_file.isEmpty()) {
+ toggleRecordingWithSelection();
+ return;
+ }
+ bool recording = !recordTimer.isRunning();
+ recordAction->setText(recording ? tr("&Stop Recording Video\tF9") : tr("&Start Recording Video\tF9"));
+ setRecording(recording);
+}
+
+void QDeclarativeViewer::setSlowMode(bool enable)
+{
+ QUnifiedTimer::instance()->setSlowModeEnabled(enable);
+}
+
+void QDeclarativeViewer::addLibraryPath(const QString& lib)
+{
+ canvas->engine()->addImportPath(lib);
+}
+
+void QDeclarativeViewer::reload()
+{
+ openQml(currentFileOrUrl);
+}
+
+void QDeclarativeViewer::open(const QString& doc)
+{
+#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT
+ if (doc.endsWith(".wgt",Qt::CaseInsensitive)
+ || doc.endsWith(".wgz",Qt::CaseInsensitive)
+ || doc.endsWith(".zip",Qt::CaseInsensitive))
+ openWgt(doc);
+ else
+#endif
+ openQml(doc);
+}
+
+void QDeclarativeViewer::openWgt(const QString& doc)
+{
+#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT
+ // XXX This functionality could be migrated to QDeclarativeView once refined
+
+ QUrl url(doc);
+ if (url.isRelative())
+ url = QUrl::fromLocalFile(doc);
+ delete canvas->rootObject();
+ canvas->engine()->clearComponentCache();
+ QNetworkAccessManager * nam = canvas->engine()->networkAccessManager();
+ wgtreply = nam->get(QNetworkRequest(url));
+ connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt()));
+#endif
+}
+
+#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT
+static void removeRecursive(const QString& dirname)
+{
+ QDir dir(dirname);
+ QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
+ for (int i = 0; i < entries.count(); ++i)
+ if (entries[i].isDir())
+ removeRecursive(entries[i].filePath());
+ else
+ dir.remove(entries[i].fileName());
+ QDir().rmdir(dirname);
+}
+#endif
+
+void QDeclarativeViewer::unpackWgt()
+{
+#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT
+ QByteArray all = wgtreply->readAll();
+ QBuffer buf(&all);
+ buf.open(QIODevice::ReadOnly);
+ QZipReader zip(&buf);
+ /*
+ for (int i=0; i<zip.count(); ++i) {
+ QZipReader::FileInfo info = zip.entryInfoAt(i);
+ qDebug() << "zip:" << info.filePath;
+ }
+ */
+ wgtdir = QDir::tempPath()+QDir::separator()+QLatin1String("qml-wgt");
+ removeRecursive(wgtdir);
+ QDir().mkpath(wgtdir);
+ zip.extractAll(wgtdir);
+
+ QString rootfile;
+
+ if (wgtreply->header(QNetworkRequest::ContentTypeHeader).toString() == "application/widget" || wgtreply->url().path().endsWith(".wgt",Qt::CaseInsensitive)) {
+ // W3C Draft http://www.w3.org/TR/2009/CR-widgets-20091201
+ QFile configfile(wgtdir+QDir::separator()+"config.xml");
+ if (configfile.open(QIODevice::ReadOnly)) {
+ QXmlStreamReader config(&configfile);
+ if (config.readNextStartElement() && config.name() == "widget") {
+ while (config.readNextStartElement()) {
+ if (config.name() == "content") {
+ rootfile = wgtdir + QDir::separator();
+ rootfile += config.attributes().value(QLatin1String("src"));
+ }
+ // XXX process other config
+
+ config.skipCurrentElement();
+ }
+ }
+ } else {
+ qWarning("No config.xml found - non-standard WGT file");
+ }
+ if (rootfile.isEmpty()) {
+ QString def = wgtdir+QDir::separator()+"index.qml";
+ if (QFile::exists(def))
+ rootfile = def;
+ }
+ } else {
+ // Just find index.qml, preferably at the root
+ for (int i=0; i<zip.count(); ++i) {
+ QZipReader::FileInfo info = zip.entryInfoAt(i);
+ if (info.filePath.compare(QLatin1String("index.qml"),Qt::CaseInsensitive)==0)
+ rootfile = wgtdir+QDir::separator()+info.filePath;
+ if (rootfile.isEmpty() && info.filePath.endsWith("/index.qml",Qt::CaseInsensitive))
+ rootfile = wgtdir+QDir::separator()+info.filePath;
+ }
+ }
+
+ openQml(rootfile);
+#endif
+}
+
+void QDeclarativeViewer::openFile()
+{
+ QString cur = canvas->source().toLocalFile();
+ if (useQmlFileBrowser) {
+ openQml("qrc:/content/Browser.qml");
+ } else {
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
+ if (!fileName.isEmpty()) {
+ QFileInfo fi(fileName);
+ openQml(fi.absoluteFilePath());
+ }
+ }
+}
+
+void QDeclarativeViewer::statusChanged()
+{
+ if (canvas->status() == QDeclarativeView::Error && tester)
+ tester->executefailure();
+
+ if (canvas->status() == QDeclarativeView::Ready)
+ resize(sizeHint());
+}
+
+void QDeclarativeViewer::launch(const QString& file_or_url)
+{
+ QMetaObject::invokeMethod(this, "openQml", Qt::QueuedConnection, Q_ARG(QString, file_or_url));
+}
+
+void QDeclarativeViewer::openQml(const QString& file_or_url)
+{
+ currentFileOrUrl = file_or_url;
+
+ QUrl url;
+ QFileInfo fi(file_or_url);
+ if (fi.exists())
+ url = QUrl::fromLocalFile(fi.absoluteFilePath());
+ else
+ url = QUrl(file_or_url);
+ setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(file_or_url));
+
+ if (!m_script.isEmpty())
+ tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas);
+
+ delete canvas->rootObject();
+ canvas->engine()->clearComponentCache();
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("qmlViewer", this);
+#ifdef Q_OS_SYMBIAN
+ ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone
+#else
+ ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
+#endif
+
+ QString fileName = url.toLocalFile();
+ if (!fileName.isEmpty()) {
+ QFileInfo fi(fileName);
+ if (fi.exists()) {
+ if (fi.suffix().toLower() != QLatin1String("qml")) {
+ qWarning() << "qml cannot open non-QML file" << fileName;
+ return;
+ }
+
+ QDir dir(fi.path()+"/dummydata", "*.qml");
+ QStringList list = dir.entryList();
+ for (int i = 0; i < list.size(); ++i) {
+ QString qml = list.at(i);
+ QFile f(dir.filePath(qml));
+ f.open(QIODevice::ReadOnly);
+ QByteArray data = f.readAll();
+ QDeclarativeComponent comp(canvas->engine());
+ comp.setData(data, QUrl());
+ QObject *dummyData = comp.create();
+
+ if(comp.isError()) {
+ QList<QDeclarativeError> errors = comp.errors();
+ foreach (const QDeclarativeError &error, errors) {
+ qWarning() << error;
+ }
+ if (tester) tester->executefailure();
+ }
+
+ if (dummyData) {
+ qWarning() << "Loaded dummy data:" << dir.filePath(qml);
+ qml.truncate(qml.length()-4);
+ ctxt->setContextProperty(qml, dummyData);
+ dummyData->setParent(this);
+ }
+ }
+ } else {
+ qWarning() << "qml cannot find file:" << fileName;
+ return;
+ }
+ }
+
+ QTime t;
+ t.start();
+
+ canvas->setSource(url);
+
+ qWarning() << "Wall startup time:" << t.elapsed();
+
+ if (!skin) {
+ canvas->updateGeometry();
+ if (mb)
+ mb->updateGeometry();
+ if (!isFullScreen() && !isMaximized())
+ resize(sizeHint());
+ } else {
+ if (scaleSkin)
+ canvas->resize(canvas->sizeHint());
+ else {
+ canvas->setFixedSize(skin->standardScreenSize());
+ canvas->resize(skin->standardScreenSize());
+ }
+ }
+
+#ifdef QTOPIA
+ show();
+#endif
+}
+
+void QDeclarativeViewer::startNetwork()
+{
+#if defined(SYMBIAN_NETWORK_INIT)
+ qt_SetDefaultIap();
+#endif
+}
+
+QStringList QDeclarativeViewer::builtinSkins() const
+{
+ QDir dir(":/skins/","*.skin");
+ const QFileInfoList l = dir.entryInfoList();
+ QStringList r;
+ for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) {
+ r += (*it).baseName();
+ }
+ return r;
+}
+
+void QDeclarativeViewer::setSkin(const QString& skinDirOrName)
+{
+ QString skinDirectory = skinDirOrName;
+
+ if (!QDir(skinDirOrName).exists() && QDir(":/skins/"+skinDirOrName+".skin").exists())
+ skinDirectory = ":/skins/"+skinDirOrName+".skin";
+
+ if (currentSkin == skinDirectory)
+ return;
+
+ currentSkin = skinDirectory;
+
+ // XXX QWidget::setMask does not handle changes well, and we may
+ // XXX have been signalled from an item in a menu we're replacing,
+ // XXX hence some rather convoluted resetting here...
+
+ QString err;
+ if (skin) {
+ skin->hide();
+ skin->deleteLater();
+ }
+
+ canvas->setResizeMode((!skin || !scaleSkin) ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject);
+
+ DeviceSkinParameters parameters;
+ if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) {
+ layout()->setEnabled(false);
+ //setMenuBar(0);
+ if (mb)
+ mb->hide();
+ if (!err.isEmpty())
+ qWarning() << err;
+ skin = new PreviewDeviceSkin(parameters,this);
+ canvas->resize(canvas->sizeHint());
+ if (scaleSkin)
+ skin->setPreviewAndScale(canvas);
+ else
+ skin->setPreview(canvas);
+ createMenu(0,skin->menu);
+ skin->show();
+ } else {
+ skin = 0;
+ clearMask();
+ menuBar()->clear();
+ canvas->setParent(this, Qt::SubWindow);
+ createMenu(menuBar(),0);
+ mb->show();
+ setMinimumSize(QSize(0,0));
+ setMaximumSize(QSize(16777215,16777215));
+ canvas->setMinimumSize(QSize(0,0));
+ canvas->setMaximumSize(QSize(16777215,16777215));
+ QRect g = geometry();
+ g.setSize(sizeHint());
+ setParent(0,windowFlags()); // recreate
+ canvas->move(0,menuBar()->sizeHint().height());
+ setGeometry(g);
+ layout()->setEnabled(true);
+ show();
+ }
+ canvas->show();
+}
+
+void QDeclarativeViewer::setAutoRecord(int from, int to)
+{
+ if (from==0) from=1; // ensure resized
+ record_autotime = to-from;
+ autoStartTimer.setInterval(from);
+ autoStartTimer.setRunning(true);
+}
+
+void QDeclarativeViewer::setRecordArgs(const QStringList& a)
+{
+ record_args = a;
+}
+
+void QDeclarativeViewer::setRecordFile(const QString& f)
+{
+ record_file = f;
+}
+
+void QDeclarativeViewer::setRecordRate(int fps)
+{
+ record_rate = fps;
+}
+
+void QDeclarativeViewer::sceneResized(QSize size)
+{
+ if (size.width() > 0 && size.height() > 0) {
+ if (skin && scaleSkin)
+ skin->setScreenSize(size);
+ }
+}
+
+void QDeclarativeViewer::keyPressEvent(QKeyEvent *event)
+{
+ if (event->key() == Qt::Key_0 && devicemode)
+ exit(0);
+ else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) {
+ qDebug() << "F1 - help\n"
+ << "F2 - save test script\n"
+ << "F3 - take PNG snapshot\n"
+ << "F4 - show items and state\n"
+ << "F5 - reload QML\n"
+ << "F6 - show object tree\n"
+ << "F7 - show timing\n"
+ << "F8 - show performance (if available)\n"
+ << "F9 - toggle video recording\n"
+ << "F10 - toggle orientation\n"
+ << "device keys: 0=quit, 1..8=F1..F8"
+ ;
+ } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) {
+ if (tester && m_scriptOptions & Record)
+ tester->save();
+ } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) {
+ takeSnapShot();
+ } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) {
+ reload();
+ } else if (event->key() == Qt::Key_F8 || (event->key() == Qt::Key_8 && devicemode)) {
+ QPerformanceLog::displayData();
+ QPerformanceLog::clear();
+ } else if (event->key() == Qt::Key_F9 || (event->key() == Qt::Key_9 && devicemode)) {
+ toggleRecording();
+ } else if (event->key() == Qt::Key_F10) {
+ if (portraitOrientation) {
+ if (portraitOrientation->isChecked())
+ setLandscape();
+ else
+ setPortrait();
+ }
+ }
+
+ QWidget::keyPressEvent(event);
+}
+
+void QDeclarativeViewer::senseImageMagick()
+{
+ QProcess proc;
+ proc.start("convert", QStringList() << "-h");
+ proc.waitForFinished(2000);
+ QString help = proc.readAllStandardOutput();
+ convertAvailable = help.contains("ImageMagick");
+}
+
+void QDeclarativeViewer::senseFfmpeg()
+{
+ QProcess proc;
+ proc.start("ffmpeg", QStringList() << "-h");
+ proc.waitForFinished(2000);
+ QString ffmpegHelp = proc.readAllStandardOutput();
+ ffmpegAvailable = ffmpegHelp.contains("-s ");
+ ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp;
+
+ QDialog *d = new QDialog(recdlg);
+ QVBoxLayout *l = new QVBoxLayout(d);
+ QTextBrowser *b = new QTextBrowser(d);
+ QFont f = b->font();
+ f.setFamily("courier");
+ b->setFont(f);
+ b->setText(ffmpegHelp);
+ l->addWidget(b);
+ d->setLayout(l);
+ ffmpegHelpWindow = d;
+ connect(recdlg->ffmpegHelp,SIGNAL(clicked()), ffmpegHelpWindow, SLOT(show()));
+}
+
+void QDeclarativeViewer::setRecording(bool on)
+{
+ if (on == recordTimer.isRunning())
+ return;
+
+ int period = int(1000/record_rate+0.5);
+ QUnifiedTimer::instance()->setTimingInterval(on ? period:16);
+ QUnifiedTimer::instance()->setConsistentTiming(on);
+ if (on) {
+ canvas->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+ recordTimer.setInterval(period);
+ recordTimer.setRunning(true);
+ frame_fmt = record_file.right(4).toLower();
+ frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32);
+ if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) {
+ // Stream video to ffmpeg
+
+ QProcess *proc = new QProcess(this);
+ connect(proc, SIGNAL(finished(int)), this, SLOT(ffmpegFinished(int)));
+ frame_stream = proc;
+
+ QStringList args;
+ args << "-y";
+ args << "-r" << QString::number(record_rate);
+ args << "-f" << "rawvideo";
+ args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32");
+ args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height());
+ args << "-i" << "-";
+ if (record_outsize.isValid()) {
+ args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
+ args << "-aspect" << QString::number(double(canvas->width())/canvas->height());
+ }
+ args += record_args;
+ args << record_file;
+ proc->start("ffmpeg",args);
+
+ } else {
+ // Store frames, save to GIF/PNG
+ frame_stream = 0;
+ }
+ } else {
+ canvas->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
+ recordTimer.setRunning(false);
+ if (frame_stream) {
+ qDebug() << "Saving video...";
+ frame_stream->close();
+ qDebug() << "Wrote" << record_file;
+ } else {
+ QProgressDialog progress(tr("Saving frames..."), tr("Cancel"), 0, frames.count()+10, this);
+ progress.setWindowModality(Qt::WindowModal);
+
+ int frame=0;
+ QStringList inputs;
+ qDebug() << "Saving frames...";
+
+ QString framename;
+ bool png_output = false;
+ if (record_file.right(4).toLower()==".png") {
+ if (record_file.contains('%'))
+ framename = record_file;
+ else
+ framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4);
+ png_output = true;
+ } else {
+ framename = "tmp-frame%04d.png";
+ png_output = false;
+ }
+ foreach (QImage* img, frames) {
+ progress.setValue(progress.value()+1);
+ if (progress.wasCanceled())
+ break;
+ QString name;
+ name.sprintf(framename.toLocal8Bit(),frame++);
+ if (record_outsize.isValid())
+ *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
+ if (record_dither=="ordered")
+ img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name);
+ else if (record_dither=="threshold")
+ img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name);
+ else if (record_dither=="floyd")
+ img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name);
+ else
+ img->save(name);
+ inputs << name;
+ delete img;
+ }
+
+ if (!progress.wasCanceled()) {
+ if (png_output) {
+ framename.replace(QRegExp("%\\d*."),"*");
+ qDebug() << "Wrote frames" << framename;
+ inputs.clear(); // don't remove them
+ } else {
+ // ImageMagick and gifsicle for GIF encoding
+ progress.setLabelText(tr("Converting frames to GIF file..."));
+ QStringList args;
+ args << "-delay" << QString::number(period/10);
+ args << inputs;
+ args << record_file;
+ qDebug() << "Converting..." << record_file << "(this may take a while)";
+ if (0!=QProcess::execute("convert", args)) {
+ qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted";
+ inputs.clear(); // don't remove them
+ qDebug() << "Wrote frames tmp-frame*.png";
+ } else {
+ if (record_file.right(4).toLower() == ".gif") {
+ qDebug() << "Compressing..." << record_file;
+ if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file))
+ qWarning() << "Cannot run 'gifsicle' - not compressed";
+ }
+ qDebug() << "Wrote" << record_file;
+ }
+ }
+ }
+
+ progress.setValue(progress.maximum()-1);
+ foreach (QString name, inputs)
+ QFile::remove(name);
+
+ frames.clear();
+ }
+ }
+ qDebug() << "Recording: " << (recordTimer.isRunning()?"ON":"OFF");
+}
+
+void QDeclarativeViewer::ffmpegFinished(int code)
+{
+ qDebug() << "ffmpeg returned" << code << frame_stream->readAllStandardError();
+}
+
+void QDeclarativeViewer::autoStartRecording()
+{
+ setRecording(true);
+ autoStopTimer.setInterval(record_autotime);
+ autoStopTimer.setRunning(true);
+}
+
+void QDeclarativeViewer::autoStopRecording()
+{
+ setRecording(false);
+}
+
+void QDeclarativeViewer::recordFrame()
+{
+ canvas->QWidget::render(&frame);
+ if (frame_stream) {
+ if (frame_fmt == ".gif") {
+ // ffmpeg can't do 32bpp with gif
+ QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888);
+ frame_stream->write((char*)rgb24.bits(),rgb24.numBytes());
+ } else {
+ frame_stream->write((char*)frame.bits(),frame.numBytes());
+ }
+ } else {
+ frames.append(new QImage(frame));
+ }
+}
+
+void QDeclarativeViewer::setDeviceKeys(bool on)
+{
+ devicemode = on;
+}
+
+void QDeclarativeViewer::setNetworkCacheSize(int size)
+{
+ namFactory->setCacheSize(size);
+}
+
+void QDeclarativeViewer::setUseGL(bool useGL)
+{
+#ifdef GL_SUPPORTED
+ if (useGL) {
+ QGLFormat format = QGLFormat::defaultFormat();
+ format.setSampleBuffers(false);
+
+ QGLWidget *glWidget = new QGLWidget(format);
+ glWidget->setAutoFillBackground(false);
+ canvas->setViewport(glWidget);
+ }
+#endif
+}
+
+void QDeclarativeViewer::setUseNativeFileBrowser(bool use)
+{
+ useQmlFileBrowser = !use;
+}
+
+void QDeclarativeViewer::registerTypes()
+{
+ QML_REGISTER_TYPE(QDeclarativeViewer, 1, 0, Screen, Screen);
+}
+
+QT_END_NAMESPACE
+
+#include "qmlruntime.moc"
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
new file mode 100644
index 0000000000..01777bd416
--- /dev/null
+++ b/tools/qml/qmlruntime.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 tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QDECLARATIVEVIEWER_H
+#define QDECLARATIVEVIEWER_H
+
+#include <QMainWindow>
+#include <QMenuBar>
+#include <private/qdeclarativetimer_p.h>
+#include <QTime>
+#include <QList>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeView;
+class PreviewDeviceSkin;
+class QDeclarativeTestEngine;
+class QProcess;
+class RecordingDialog;
+class QDeclarativeTester;
+class QNetworkReply;
+class QNetworkCookieJar;
+class NetworkAccessManagerFactory;
+
+class QDeclarativeViewer
+#if defined(Q_OS_SYMBIAN)
+ : public QMainWindow
+#else
+ : public QWidget
+#endif
+{
+Q_OBJECT
+public:
+ QDeclarativeViewer(QWidget *parent=0, Qt::WindowFlags flags=0);
+ ~QDeclarativeViewer();
+
+ static void registerTypes();
+
+ enum ScriptOption {
+ Play = 0x00000001,
+ Record = 0x00000002,
+ TestImages = 0x00000004,
+ TestErrorProperty = 0x00000008,
+ SaveOnExit = 0x00000010,
+ ExitOnComplete = 0x00000020,
+ ExitOnFailure = 0x00000040
+ };
+ Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
+ void setScript(const QString &s) { m_script = s; }
+ void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
+ void setRecordDither(const QString& s) { record_dither = s; }
+ void setRecordRate(int fps);
+ void setRecordFile(const QString&);
+ void setRecordArgs(const QStringList&);
+ void setRecording(bool on);
+ bool isRecording() const { return recordTimer.isRunning(); }
+ void setAutoRecord(int from, int to);
+ void setDeviceKeys(bool);
+ void setNetworkCacheSize(int size);
+ void addLibraryPath(const QString& lib);
+ void setUseGL(bool use);
+ void setUseNativeFileBrowser(bool);
+
+ QStringList builtinSkins() const;
+
+ QMenuBar *menuBar() const;
+
+public slots:
+ void sceneResized(QSize size);
+ void open(const QString&);
+ void openWgt(const QString&);
+ void openQml(const QString&);
+ void openFile();
+ void reload();
+ void takeSnapShot();
+ void toggleRecording();
+ void toggleRecordingWithSelection();
+ void ffmpegFinished(int code);
+ void setSkin(const QString& skinDirectory);
+ void showProxySettings ();
+ void proxySettingsChanged ();
+ void setScaleView();
+ void statusChanged();
+ void setSlowMode(bool);
+ void launch(const QString &);
+
+protected:
+ virtual void keyPressEvent(QKeyEvent *);
+
+ void createMenu(QMenuBar *menu, QMenu *flatmenu);
+
+private slots:
+ void autoStartRecording();
+ void autoStopRecording();
+ void recordFrame();
+ void chooseRecordingOptions();
+ void pickRecordingFile();
+ void setScaleSkin();
+ void setPortrait();
+ void setLandscape();
+ void toggleOrientation();
+ void startNetwork();
+ void toggleFullScreen();
+ void unpackWgt();
+
+private:
+ QString getVideoFileName();
+
+ PreviewDeviceSkin *skin;
+ QSize skinscreensize;
+ QDeclarativeView *canvas;
+ QString currentFileOrUrl;
+ QDeclarativeTimer recordTimer;
+ QString frame_fmt;
+ QImage frame;
+ QList<QImage*> frames;
+ QProcess* frame_stream;
+ QDeclarativeTimer autoStartTimer;
+ QDeclarativeTimer autoStopTimer;
+ QString record_dither;
+ QString record_file;
+ QSize record_outsize;
+ QStringList record_args;
+ int record_rate;
+ int record_autotime;
+ bool devicemode;
+ QAction *recordAction;
+ QString currentSkin;
+ bool scaleSkin;
+ mutable QMenuBar *mb;
+ RecordingDialog *recdlg;
+
+ void senseImageMagick();
+ void senseFfmpeg();
+ QWidget *ffmpegHelpWindow;
+ bool ffmpegAvailable;
+ bool convertAvailable;
+
+ QAction *portraitOrientation;
+ QAction *landscapeOrientation;
+
+ QString m_script;
+ ScriptOptions m_scriptOptions;
+ QDeclarativeTester *tester;
+
+ QNetworkReply *wgtreply;
+ QString wgtdir;
+
+ NetworkAccessManagerFactory *namFactory;
+
+ bool useQmlFileBrowser;
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions)
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tools/qmlviewer/qmlviewer.qrc b/tools/qml/qmlruntime.qrc
index 3a9e6080e3..3a9e6080e3 100644
--- a/tools/qmlviewer/qmlviewer.qrc
+++ b/tools/qml/qmlruntime.qrc
diff --git a/tools/qmlviewer/recopts.ui b/tools/qml/recopts.ui
index ce2da30767..ce2da30767 100644
--- a/tools/qmlviewer/recopts.ui
+++ b/tools/qml/recopts.ui
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
deleted file mode 100644
index 57c445fb54..0000000000
--- a/tools/qmlviewer/main.cpp
+++ /dev/null
@@ -1,350 +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 tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qmlviewer.h"
-#include <QWidget>
-#include <QDir>
-#include <QApplication>
-#include <QTranslator>
-#include <QDebug>
-
-QT_USE_NAMESPACE
-
-#if defined (Q_OS_SYMBIAN)
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-void myMessageOutput(QtMsgType type, const char *msg)
-{
- static int fd = -1;
- if (fd == -1)
- fd = ::open("E:\\qmlviewer.log", O_WRONLY | O_CREAT);
-
- ::write(fd, msg, strlen(msg));
- ::write(fd, "\n", 1);
- ::fsync(fd);
-
- switch (type) {
- case QtFatalMsg:
- abort();
- }
-}
-#endif
-
-void usage()
-{
- qWarning("Usage: qmlviewer [options] <filename>");
- qWarning(" ");
- qWarning(" options:");
- qWarning(" -v, -version ............................. display version");
- qWarning(" -frameless ............................... run with no window frame");
- qWarning(" -maximized................................ run maximized");
- qWarning(" -fullscreen............................... run fullscreen");
- qWarning(" -stayontop................................ keep viewer window on top");
- qWarning(" -skin <qvfbskindir> ...................... run with a skin window frame");
- qWarning(" \"list\" for a list of built-ins");
- qWarning(" -resizeview .............................. resize the view, not the skin");
- qWarning(" -qmlbrowser .............................. use a QML-based file browser");
- qWarning(" -recordfile <output> ..................... set video recording file");
- qWarning(" - ImageMagick 'convert' for GIF)");
- qWarning(" - png file for raw frames");
- qWarning(" - 'ffmpeg' for other formats");
- qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode");
- qWarning(" -recordrate <fps> ........................ set recording frame rate");
- qWarning(" -record arg .............................. add a recording process argument");
- qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop");
- qWarning(" -devicekeys .............................. use numeric keys (see F1)");
- qWarning(" -dragthreshold <size> .................... set mouse drag threshold size");
- qWarning(" -netcache <size> ......................... set disk cache to size bytes");
- qWarning(" -translation <translationfile> ........... set the language to run in");
- qWarning(" -L <directory> ........................... prepend to the library search path");
- qWarning(" -opengl .................................. use a QGLWidget for the viewport");
- qWarning(" -script <path> ........................... set the script to use");
- qWarning(" -scriptopts <options>|help ............... set the script options to use");
-
- qWarning(" ");
- qWarning(" Press F1 for interactive help");
- exit(1);
-}
-
-void scriptOptsUsage()
-{
- qWarning("Usage: qmlviewer -scriptopts <option>[,<option>...] ...");
- qWarning(" options:");
- qWarning(" record ................................... record a new script");
- qWarning(" play ..................................... playback an existing script");
- qWarning(" testimages ............................... record images or compare images on playback");
- qWarning(" testerror ................................ test 'error' property of root item on playback");
- qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion");
- qWarning(" exitonfailure ............................ immediately exit the viewer on script failure");
- qWarning(" saveonexit ............................... save recording on viewer exit");
- qWarning(" ");
- qWarning(" One of record, play or both must be specified.");
- exit(1);
-}
-
-int main(int argc, char ** argv)
-{
-#if defined (Q_OS_SYMBIAN)
- qInstallMsgHandler(myMessageOutput);
-#endif
-
-#if defined (Q_WS_X11)
- //### default to using raster graphics backend for now
- bool gsSpecified = false;
- for (int i = 0; i < argc; ++i) {
- QString arg = argv[i];
- if (arg == "-graphicssystem") {
- gsSpecified = true;
- break;
- }
- }
-
- if (!gsSpecified)
- QApplication::setGraphicsSystem("raster");
-#endif
-
- QApplication app(argc, argv);
- app.setApplicationName("viewer");
- app.setOrganizationName("Nokia");
- app.setOrganizationDomain("nokia.com");
-
- bool frameless = false;
- bool resizeview = false;
- QString fileName;
- double fps = 0;
- int autorecord_from = 0;
- int autorecord_to = 0;
- QString dither = "none";
- QString recordfile;
- QStringList recordargs;
- QStringList libraries;
- QString skin;
- QString script;
- QString scriptopts;
- bool runScript = false;
- bool devkeys = false;
- int cache = 0;
- QString translationFile;
- bool useGL = false;
- bool fullScreen = false;
- bool stayOnTop = false;
- bool maximized = false;
- bool useNativeFileBrowser = true;
-
-#if defined(Q_OS_SYMBIAN)
- maximized = true;
- useNativeFileBrowser = false;
-#endif
-
- for (int i = 1; i < argc; ++i) {
- bool lastArg = (i == argc - 1);
- QString arg = argv[i];
- if (arg == "-frameless") {
- frameless = true;
- } else if (arg == "-maximized") {
- maximized = true;
- } else if (arg == "-fullscreen") {
- fullScreen = true;
- } else if (arg == "-stayontop") {
- stayOnTop = true;
- } else if (arg == "-skin") {
- if (lastArg) usage();
- skin = QString(argv[++i]);
- } else if (arg == "-resizeview") {
- resizeview = true;
- } else if (arg == "-netcache") {
- if (lastArg) usage();
- cache = QString(argv[++i]).toInt();
- } else if (arg == "-recordrate") {
- if (lastArg) usage();
- fps = QString(argv[++i]).toDouble();
- } else if (arg == "-recordfile") {
- if (lastArg) usage();
- recordfile = QString(argv[++i]);
- } else if (arg == "-record") {
- if (lastArg) usage();
- recordargs << QString(argv[++i]);
- } else if (arg == "-recorddither") {
- if (lastArg) usage();
- dither = QString(argv[++i]);
- } else if (arg == "-autorecord") {
- if (lastArg) usage();
- QString range = QString(argv[++i]);
- int dash = range.indexOf('-');
- if (dash > 0)
- autorecord_from = range.left(dash).toInt();
- autorecord_to = range.mid(dash+1).toInt();
- } else if (arg == "-devicekeys") {
- devkeys = true;
- } else if (arg == "-dragthreshold") {
- if (lastArg) usage();
- app.setStartDragDistance(QString(argv[++i]).toInt());
- } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
- fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR);
- return 0;
- } else if (arg == "-translation") {
- if (lastArg) usage();
- translationFile = argv[++i];
- } else if (arg == "-opengl") {
- useGL = true;
- } else if (arg == "-qmlbrowser") {
- useNativeFileBrowser = false;
- } else if (arg == "-L") {
- if (lastArg) usage();
- libraries << QString(argv[++i]);
- } else if (arg == "-script") {
- if (lastArg) usage();
- script = QString(argv[++i]);
- } else if (arg == "-scriptopts") {
- if (lastArg) usage();
- scriptopts = QString(argv[++i]);
- } else if (arg == "-savescript") {
- if (lastArg) usage();
- script = QString(argv[++i]);
- runScript = false;
- } else if (arg == "-playscript") {
- if (lastArg) usage();
- script = QString(argv[++i]);
- runScript = true;
- } else if (arg[0] != '-') {
- fileName = arg;
- } else if (1 || arg == "-help") {
- usage();
- }
- }
-
- QTranslator qmlTranslator;
- if (!translationFile.isEmpty()) {
- qmlTranslator.load(translationFile);
- app.installTranslator(&qmlTranslator);
- }
-
- Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget);
- if (stayOnTop)
- wflags |= Qt::WindowStaysOnTopHint;
-
- QmlViewer viewer(0, wflags);
- if (!scriptopts.isEmpty()) {
- QStringList options =
- scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
-
- QmlViewer::ScriptOptions scriptOptions = 0;
- for (int i = 0; i < options.count(); ++i) {
- const QString &option = options.at(i);
- if (option == QLatin1String("help")) {
- scriptOptsUsage();
- } else if (option == QLatin1String("play")) {
- scriptOptions |= QmlViewer::Play;
- } else if (option == QLatin1String("record")) {
- scriptOptions |= QmlViewer::Record;
- } else if (option == QLatin1String("testimages")) {
- scriptOptions |= QmlViewer::TestImages;
- } else if (option == QLatin1String("testerror")) {
- scriptOptions |= QmlViewer::TestErrorProperty;
- } else if (option == QLatin1String("exitoncomplete")) {
- scriptOptions |= QmlViewer::ExitOnComplete;
- } else if (option == QLatin1String("exitonfailure")) {
- scriptOptions |= QmlViewer::ExitOnFailure;
- } else if (option == QLatin1String("saveonexit")) {
- scriptOptions |= QmlViewer::SaveOnExit;
- } else {
- scriptOptsUsage();
- }
- }
-
- if (script.isEmpty())
- usage();
-
- if (!(scriptOptions & QmlViewer::Record) && !(scriptOptions & QmlViewer::Play))
- scriptOptsUsage();
- viewer.setScriptOptions(scriptOptions);
- viewer.setScript(script);
- } else if (!script.isEmpty()) {
- usage();
- }
-
- foreach (QString lib, libraries)
- viewer.addLibraryPath(lib);
- viewer.setNetworkCacheSize(cache);
- viewer.setRecordFile(recordfile);
- if (resizeview)
- viewer.setScaleView();
- if (fps>0)
- viewer.setRecordRate(fps);
- if (autorecord_to)
- viewer.setAutoRecord(autorecord_from,autorecord_to);
- if (!skin.isEmpty()) {
- if (skin == "list") {
- foreach (QString s, viewer.builtinSkins())
- qWarning(s.toUtf8());
- exit(0);
- } else {
- viewer.setSkin(skin);
- }
- }
- if (devkeys)
- viewer.setDeviceKeys(true);
- viewer.setRecordDither(dither);
- if (recordargs.count())
- viewer.setRecordArgs(recordargs);
-
- viewer.setUseNativeFileBrowser(useNativeFileBrowser);
- if (fullScreen && maximized)
- qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen.";
- if (!fileName.isEmpty()) {
- viewer.open(fileName);
- fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
- } else {
- if (!useNativeFileBrowser)
- viewer.openFile();
- fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
- if (useNativeFileBrowser)
- viewer.openFile();
- }
- viewer.setUseGL(useGL);
- viewer.raise();
-
- return app.exec();
-}
diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp
deleted file mode 100644
index c3c0124b2e..0000000000
--- a/tools/qmlviewer/qfxtester.cpp
+++ /dev/null
@@ -1,378 +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 tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qfxtester.h>
-#include <QDebug>
-#include <QApplication>
-#include <qmlview.h>
-#include <QFile>
-#include <QmlComponent>
-#include <QDir>
-#include <QCryptographicHash>
-#include <private/qabstractanimation_p.h>
-#include <private/qmlgraphicsitem_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_TYPE(Qt.VisualTest, 4,6, VisualTest, QmlGraphicsVisualTest);
-QML_DEFINE_TYPE(Qt.VisualTest, 4,6, Frame, QmlGraphicsVisualTestFrame);
-QML_DEFINE_TYPE(Qt.VisualTest, 4,6, Mouse, QmlGraphicsVisualTestMouse);
-QML_DEFINE_TYPE(Qt.VisualTest, 4,6, Key, QmlGraphicsVisualTestKey);
-
-QmlGraphicsTester::QmlGraphicsTester(const QString &script, QmlViewer::ScriptOptions opts,
- QmlView *parent)
-: QAbstractAnimation(parent), m_script(script), m_view(parent), filterEvents(true), options(opts),
- testscript(0), hasCompleted(false), hasFailed(false)
-{
- parent->viewport()->installEventFilter(this);
- parent->installEventFilter(this);
- QUnifiedTimer::instance()->setConsistentTiming(true);
- if (options & QmlViewer::Play)
- this->run();
- start();
-}
-
-QmlGraphicsTester::~QmlGraphicsTester()
-{
- if (!hasFailed &&
- options & QmlViewer::Record &&
- options & QmlViewer::SaveOnExit)
- save();
-}
-
-int QmlGraphicsTester::duration() const
-{
- return -1;
-}
-
-void QmlGraphicsTester::addMouseEvent(Destination dest, QMouseEvent *me)
-{
- MouseEvent e(me);
- e.destination = dest;
- m_mouseEvents << e;
-}
-
-void QmlGraphicsTester::addKeyEvent(Destination dest, QKeyEvent *ke)
-{
- KeyEvent e(ke);
- e.destination = dest;
- m_keyEvents << e;
-}
-
-bool QmlGraphicsTester::eventFilter(QObject *o, QEvent *e)
-{
- if (!filterEvents)
- return false;
-
- Destination destination;
- if (o == m_view) {
- destination = View;
- } else if (o == m_view->viewport()) {
- destination = ViewPort;
- } else {
- return false;
- }
-
- switch (e->type()) {
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- addKeyEvent(destination, (QKeyEvent *)e);
- return true;
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- case QEvent::MouseButtonDblClick:
- addMouseEvent(destination, (QMouseEvent *)e);
- return true;
- default:
- break;
- }
- return false;
-}
-
-void QmlGraphicsTester::executefailure()
-{
- hasFailed = true;
-
- if (options & QmlViewer::ExitOnFailure)
- exit(-1);
-}
-
-void QmlGraphicsTester::imagefailure()
-{
- hasFailed = true;
-
- if (options & QmlViewer::ExitOnFailure)
- exit(-1);
-}
-
-void QmlGraphicsTester::complete()
-{
- if ((options & QmlViewer::TestErrorProperty) && !hasFailed) {
- QString e = m_view->rootObject()->property("error").toString();
- if (!e.isEmpty()) {
- qWarning() << "Test failed:" << e;
- hasFailed = true;
- }
- }
- if (options & QmlViewer::ExitOnComplete)
- QApplication::exit(hasFailed?-1:0);
-
- if (hasCompleted)
- return;
- hasCompleted = true;
-
- if (options & QmlViewer::Play)
- qWarning("Script playback complete");
-}
-
-void QmlGraphicsTester::run()
-{
- QmlComponent c(m_view->engine(), m_script + QLatin1String(".qml"));
-
- testscript = qobject_cast<QmlGraphicsVisualTest *>(c.create());
- if (testscript) testscript->setParent(this);
- else { executefailure(); exit(-1); }
- testscriptidx = 0;
-}
-
-void QmlGraphicsTester::save()
-{
- QString filename = m_script + QLatin1String(".qml");
- QFileInfo filenameInfo(filename);
- QDir saveDir = filenameInfo.absoluteDir();
- saveDir.mkpath(".");
-
- QFile file(filename);
- file.open(QIODevice::WriteOnly);
- QTextStream ts(&file);
-
- ts << "import Qt.VisualTest 4.6\n\n";
- ts << "VisualTest {\n";
-
- int imgCount = 0;
- QList<KeyEvent> keyevents = m_savedKeyEvents;
- QList<MouseEvent> mouseevents = m_savedMouseEvents;
- for (int ii = 0; ii < m_savedFrameEvents.count(); ++ii) {
- const FrameEvent &fe = m_savedFrameEvents.at(ii);
- ts << " Frame {\n";
- ts << " msec: " << fe.msec << "\n";
- if (!fe.hash.isEmpty()) {
- ts << " hash: \"" << fe.hash.toHex() << "\"\n";
- } else if (!fe.image.isNull()) {
- QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png";
- fe.image.save(m_script + "." + QString::number(imgCount) + ".png");
- imgCount++;
- ts << " image: \"" << filename << "\"\n";
- }
- ts << " }\n";
-
- while (!mouseevents.isEmpty() &&
- mouseevents.first().msec == fe.msec) {
- MouseEvent me = mouseevents.takeFirst();
-
- ts << " Mouse {\n";
- ts << " type: " << me.type << "\n";
- ts << " button: " << me.button << "\n";
- ts << " buttons: " << me.buttons << "\n";
- ts << " x: " << me.pos.x() << "; y: " << me.pos.y() << "\n";
- ts << " modifiers: " << me.modifiers << "\n";
- if (me.destination == ViewPort)
- ts << " sendToViewport: true\n";
- ts << " }\n";
- }
-
- while (!keyevents.isEmpty() &&
- keyevents.first().msec == fe.msec) {
- KeyEvent ke = keyevents.takeFirst();
-
- ts << " Key {\n";
- ts << " type: " << ke.type << "\n";
- ts << " key: " << ke.key << "\n";
- ts << " modifiers: " << ke.modifiers << "\n";
- ts << " text: \"" << ke.text.toUtf8().toHex() << "\"\n";
- ts << " autorep: " << (ke.autorep?"true":"false") << "\n";
- ts << " count: " << ke.count << "\n";
- if (ke.destination == ViewPort)
- ts << " sendToViewport: true\n";
- ts << " }\n";
- }
- }
-
- ts << "}\n";
- file.close();
-}
-
-void QmlGraphicsTester::updateCurrentTime(int msec)
-{
- QmlGraphicsItemPrivate::setConsistentTime(msec);
-
- QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32);
-
- if (options & QmlViewer::TestImages) {
- img.fill(qRgb(255,255,255));
- QPainter p(&img);
- m_view->render(&p);
- }
-
- FrameEvent fe;
- fe.msec = msec;
- if (msec == 0 || !(options & QmlViewer::TestImages)) {
- // Skip first frame, skip if not doing images
- } else if (0 == (m_savedFrameEvents.count() % 60)) {
- fe.image = img;
- } else {
- QCryptographicHash hash(QCryptographicHash::Md5);
- hash.addData((const char *)img.bits(), img.bytesPerLine() * img.height());
- fe.hash = hash.result();
- }
- m_savedFrameEvents.append(fe);
-
- // Deliver mouse events
- filterEvents = false;
-
- if (!testscript) {
- for (int ii = 0; ii < m_mouseEvents.count(); ++ii) {
- MouseEvent &me = m_mouseEvents[ii];
- me.msec = msec;
- QMouseEvent event(me.type, me.pos, me.button, me.buttons, me.modifiers);
-
- if (me.destination == View) {
- QCoreApplication::sendEvent(m_view, &event);
- } else {
- QCoreApplication::sendEvent(m_view->viewport(), &event);
- }
- }
-
- for (int ii = 0; ii < m_keyEvents.count(); ++ii) {
- KeyEvent &ke = m_keyEvents[ii];
- ke.msec = msec;
- QKeyEvent event(ke.type, ke.key, ke.modifiers, ke.text, ke.autorep, ke.count);
-
- if (ke.destination == View) {
- QCoreApplication::sendEvent(m_view, &event);
- } else {
- QCoreApplication::sendEvent(m_view->viewport(), &event);
- }
- }
- m_savedMouseEvents.append(m_mouseEvents);
- m_savedKeyEvents.append(m_keyEvents);
- }
-
- m_mouseEvents.clear();
- m_keyEvents.clear();
-
- // Advance test script
- static int imgCount = 0;
- while (testscript && testscript->count() > testscriptidx) {
-
- QObject *event = testscript->event(testscriptidx);
-
- if (QmlGraphicsVisualTestFrame *frame = qobject_cast<QmlGraphicsVisualTestFrame *>(event)) {
- if (frame->msec() < msec) {
- if (options & QmlViewer::TestImages && !(options & QmlViewer::Record)) {
- qWarning() << "QmlGraphicsTester: Extra frame. Seen:"
- << msec << "Expected:" << frame->msec();
- imagefailure();
- }
- } else if (frame->msec() == msec) {
- if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) {
- if (options & QmlViewer::TestImages && !(options & QmlViewer::Record)) {
- qWarning() << "QmlGraphicsTester: Mismatched frame hash. Seen:"
- << fe.hash.toHex() << "Expected:"
- << frame->hash().toUtf8();
- imagefailure();
- }
- }
- } else if (frame->msec() > msec) {
- break;
- }
-
- if (options & QmlViewer::TestImages && !(options & QmlViewer::Record) && !frame->image().isEmpty()) {
- QImage goodImage(frame->image().toLocalFile());
- if (goodImage != img) {
- QString reject(frame->image().toLocalFile() + ".reject.png");
- qWarning() << "QmlGraphicsTester: Image mismatch. Reject saved to:"
- << reject;
- img.save(reject);
- imagefailure();
- }
- }
- } else if (QmlGraphicsVisualTestMouse *mouse = qobject_cast<QmlGraphicsVisualTestMouse *>(event)) {
- QPoint pos(mouse->x(), mouse->y());
- QPoint globalPos = m_view->mapToGlobal(QPoint(0, 0)) + pos;
- QMouseEvent event((QEvent::Type)mouse->type(), pos, globalPos, (Qt::MouseButton)mouse->button(), (Qt::MouseButtons)mouse->buttons(), (Qt::KeyboardModifiers)mouse->modifiers());
-
- MouseEvent me(&event);
- me.msec = msec;
- if (!mouse->sendToViewport()) {
- QCoreApplication::sendEvent(m_view, &event);
- me.destination = View;
- } else {
- QCoreApplication::sendEvent(m_view->viewport(), &event);
- me.destination = ViewPort;
- }
- m_savedMouseEvents.append(me);
- } else if (QmlGraphicsVisualTestKey *key = qobject_cast<QmlGraphicsVisualTestKey *>(event)) {
-
- QKeyEvent event((QEvent::Type)key->type(), key->key(), (Qt::KeyboardModifiers)key->modifiers(), QString::fromUtf8(QByteArray::fromHex(key->text().toUtf8())), key->autorep(), key->count());
-
- KeyEvent ke(&event);
- ke.msec = msec;
- if (!key->sendToViewport()) {
- QCoreApplication::sendEvent(m_view, &event);
- ke.destination = View;
- } else {
- QCoreApplication::sendEvent(m_view->viewport(), &event);
- ke.destination = ViewPort;
- }
- m_savedKeyEvents.append(ke);
- }
- testscriptidx++;
- }
-
- filterEvents = true;
-
- if (testscript && testscript->count() <= testscriptidx)
- complete();
-}
-
-QT_END_NAMESPACE
diff --git a/tools/qmlviewer/qfxtester.h b/tools/qmlviewer/qfxtester.h
deleted file mode 100644
index 4b8ff9fb80..0000000000
--- a/tools/qmlviewer/qfxtester.h
+++ /dev/null
@@ -1,282 +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 tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QFXTESTER_H
-#define QFXTESTER_H
-
-#include <QEvent>
-#include <QMouseEvent>
-#include <QKeyEvent>
-#include <qmlviewer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsVisualTest : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QList<QObject *>* events READ events CONSTANT)
- Q_CLASSINFO("DefaultProperty", "events")
-public:
- QmlGraphicsVisualTest() {}
-
- QList<QObject *> *events() { return &m_events; }
-
- int count() const { return m_events.count(); }
- QObject *event(int idx) { return m_events.at(idx); }
-
-private:
- QList<QObject *> m_events;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsVisualTest)
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsVisualTestFrame : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int msec READ msec WRITE setMsec)
- Q_PROPERTY(QString hash READ hash WRITE setHash)
- Q_PROPERTY(QUrl image READ image WRITE setImage)
-public:
- QmlGraphicsVisualTestFrame() : m_msec(-1) {}
-
- int msec() const { return m_msec; }
- void setMsec(int m) { m_msec = m; }
-
- QString hash() const { return m_hash; }
- void setHash(const QString &hash) { m_hash = hash; }
-
- QUrl image() const { return m_image; }
- void setImage(const QUrl &image) { m_image = image; }
-
-private:
- int m_msec;
- QString m_hash;
- QUrl m_image;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsVisualTestFrame)
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsVisualTestMouse : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int type READ type WRITE setType)
- Q_PROPERTY(int button READ button WRITE setButton)
- Q_PROPERTY(int buttons READ buttons WRITE setButtons)
- Q_PROPERTY(int x READ x WRITE setX)
- Q_PROPERTY(int y READ y WRITE setY)
- Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers)
- Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport)
-public:
- QmlGraphicsVisualTestMouse() : m_type(0), m_button(0), m_buttons(0), m_x(0), m_y(0), m_modifiers(0), m_viewport(false) {}
-
- int type() const { return m_type; }
- void setType(int t) { m_type = t; }
-
- int button() const { return m_button; }
- void setButton(int b) { m_button = b; }
-
- int buttons() const { return m_buttons; }
- void setButtons(int b) { m_buttons = b; }
-
- int x() const { return m_x; }
- void setX(int x) { m_x = x; }
-
- int y() const { return m_y; }
- void setY(int y) { m_y = y; }
-
- int modifiers() const { return m_modifiers; }
- void setModifiers(int modifiers) { m_modifiers = modifiers; }
-
- bool sendToViewport() const { return m_viewport; }
- void setSendToViewport(bool v) { m_viewport = v; }
-private:
- int m_type;
- int m_button;
- int m_buttons;
- int m_x;
- int m_y;
- int m_modifiers;
- bool m_viewport;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsVisualTestMouse)
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsVisualTestKey : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int type READ type WRITE setType)
- Q_PROPERTY(int key READ key WRITE setKey)
- Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers)
- Q_PROPERTY(QString text READ text WRITE setText)
- Q_PROPERTY(bool autorep READ autorep WRITE setAutorep)
- Q_PROPERTY(int count READ count WRITE setCount)
- Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport)
-public:
- QmlGraphicsVisualTestKey() : m_type(0), m_key(0), m_modifiers(0), m_autorep(false), m_count(0), m_viewport(false) {}
-
- int type() const { return m_type; }
- void setType(int t) { m_type = t; }
-
- int key() const { return m_key; }
- void setKey(int k) { m_key = k; }
-
- int modifiers() const { return m_modifiers; }
- void setModifiers(int m) { m_modifiers = m; }
-
- QString text() const { return m_text; }
- void setText(const QString &t) { m_text = t; }
-
- bool autorep() const { return m_autorep; }
- void setAutorep(bool a) { m_autorep = a; }
-
- int count() const { return m_count; }
- void setCount(int c) { m_count = c; }
-
- bool sendToViewport() const { return m_viewport; }
- void setSendToViewport(bool v) { m_viewport = v; }
-private:
- int m_type;
- int m_key;
- int m_modifiers;
- QString m_text;
- bool m_autorep;
- int m_count;
- bool m_viewport;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsVisualTestKey)
-
-QT_BEGIN_NAMESPACE
-
-class QmlGraphicsTester : public QAbstractAnimation
-{
-public:
- QmlGraphicsTester(const QString &script, QmlViewer::ScriptOptions options, QmlView *parent);
- ~QmlGraphicsTester();
-
- virtual int duration() const;
-
- void run();
- void save();
-
- void executefailure();
-protected:
- virtual void updateCurrentTime(int msecs);
- virtual bool eventFilter(QObject *, QEvent *);
-
-private:
- QString m_script;
-
- void imagefailure();
- void complete();
-
- enum Destination { View, ViewPort };
- void addKeyEvent(Destination, QKeyEvent *);
- void addMouseEvent(Destination, QMouseEvent *);
- QmlView *m_view;
-
- struct MouseEvent {
- MouseEvent(QMouseEvent *e)
- : type(e->type()), button(e->button()), buttons(e->buttons()),
- pos(e->pos()), modifiers(e->modifiers()), destination(View) {}
-
- QEvent::Type type;
- Qt::MouseButton button;
- Qt::MouseButtons buttons;
- QPoint pos;
- Qt::KeyboardModifiers modifiers;
- Destination destination;
-
- int msec;
- };
- struct KeyEvent {
- KeyEvent(QKeyEvent *e)
- : type(e->type()), key(e->key()), modifiers(e->modifiers()), text(e->text()),
- autorep(e->isAutoRepeat()), count(e->count()), destination(View) {}
- QEvent::Type type;
- int key;
- Qt::KeyboardModifiers modifiers;
- QString text;
- bool autorep;
- ushort count;
- Destination destination;
-
- int msec;
- };
- struct FrameEvent {
- QImage image;
- QByteArray hash;
- int msec;
- };
- QList<MouseEvent> m_mouseEvents;
- QList<KeyEvent> m_keyEvents;
-
- QList<MouseEvent> m_savedMouseEvents;
- QList<KeyEvent> m_savedKeyEvents;
- QList<FrameEvent> m_savedFrameEvents;
- bool filterEvents;
-
- QmlViewer::ScriptOptions options;
- int testscriptidx;
- QmlGraphicsVisualTest *testscript;
-
- bool hasCompleted;
- bool hasFailed;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QFXTESTER_H
diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp
deleted file mode 100644
index 698df54c55..0000000000
--- a/tools/qmlviewer/qmlfolderlistmodel.cpp
+++ /dev/null
@@ -1,418 +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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 "qmlfolderlistmodel.h"
-#include <QDirModel>
-#include <QDebug>
-#include <qmlcontext.h>
-
-QT_BEGIN_NAMESPACE
-
-class QmlFolderListModelPrivate
-{
-public:
- QmlFolderListModelPrivate()
- : sortField(QmlFolderListModel::Name), sortReversed(false), count(0) {
- nameFilters << QLatin1String("*");
- }
-
- void updateSorting() {
- QDir::SortFlags flags = 0;
- switch(sortField) {
- case QmlFolderListModel::Unsorted:
- flags |= QDir::Unsorted;
- break;
- case QmlFolderListModel::Name:
- flags |= QDir::Name;
- break;
- case QmlFolderListModel::Time:
- flags |= QDir::Time;
- break;
- case QmlFolderListModel::Size:
- flags |= QDir::Size;
- break;
- case QmlFolderListModel::Type:
- flags |= QDir::Type;
- break;
- }
-
- if (sortReversed)
- flags |= QDir::Reversed;
-
- model.setSorting(flags);
- }
-
- QDirModel model;
- QUrl folder;
- QStringList nameFilters;
- QModelIndex folderIndex;
- QmlFolderListModel::SortField sortField;
- bool sortReversed;
- int count;
-};
-
-/*!
- \qmlclass FolderListModel
- \brief The FolderListModel provides a model of the contents of a folder in a filesystem.
-
- FolderListModel provides access to the local filesystem. The \e folder property
- specifies the folder to list.
-
- Qt uses "/" as a universal directory separator in the same way that "/" is
- used as a path separator in URLs. If you always use "/" as a directory
- separator, Qt will translate your paths to conform to the underlying
- operating system.
-
- The roles available are:
- \list
- \o fileName
- \o filePath
- \endlist
-
- Additionally a file entry can be differentiated from a folder entry
- via the \l isFolder() method.
-*/
-
-QmlFolderListModel::QmlFolderListModel(QObject *parent)
- : QListModelInterface(parent)
-{
- d = new QmlFolderListModelPrivate;
- d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot);
- connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int))
- , this, SLOT(inserted(const QModelIndex&,int,int)));
- connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int))
- , this, SLOT(removed(const QModelIndex&,int,int)));
- connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&))
- , this, SLOT(dataChanged(const QModelIndex&,const QModelIndex&)));
- connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh()));
- connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh()));
-}
-
-QmlFolderListModel::~QmlFolderListModel()
-{
- delete d;
-}
-
-QHash<int,QVariant> QmlFolderListModel::data(int index, const QList<int> &roles) const
-{
- Q_UNUSED(roles);
- QHash<int,QVariant> folderData;
- QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex);
- if (modelIndex.isValid()) {
- folderData[QDirModel::FileNameRole] = d->model.data(modelIndex, QDirModel::FileNameRole);
- folderData[QDirModel::FilePathRole] = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString());
- }
-
- return folderData;
-}
-
-QVariant QmlFolderListModel::data(int index, int role) const
-{
- QVariant rv;
- QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex);
- if (modelIndex.isValid()) {
- if (role == QDirModel::FileNameRole)
- rv = d->model.data(modelIndex, QDirModel::FileNameRole);
- else if (role == QDirModel::FilePathRole)
- rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString());
- }
-
- return rv;
-}
-
-int QmlFolderListModel::count() const
-{
- return d->count;
-}
-
-QList<int> QmlFolderListModel::roles() const
-{
- QList<int> r;
- r << QDirModel::FileNameRole;
- r << QDirModel::FilePathRole;
- return r;
-}
-
-QString QmlFolderListModel::toString(int role) const
-{
- switch (role) {
- case QDirModel::FileNameRole:
- return QLatin1String("fileName");
- case QDirModel::FilePathRole:
- return QLatin1String("filePath");
- }
-
- return QString();
-}
-
-/*!
- \qmlproperty string FolderListModel::folder
-
- The \a folder property holds the folder the model is currently providing.
-
- It is a URL, but must be a file: or qrc: URL (or relative to such a URL).
-*/
-QUrl QmlFolderListModel::folder() const
-{
- return d->folder;
-}
-
-void QmlFolderListModel::setFolder(const QUrl &folder)
-{
- if (folder == d->folder)
- return;
- QModelIndex index = d->model.index(folder.toLocalFile());
- if (index.isValid() && d->model.isDir(index)) {
- d->folder = folder;
- QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
- emit folderChanged();
- }
-}
-
-QUrl QmlFolderListModel::parentFolder() const
-{
- QUrl r;
- QString localFile = d->folder.toLocalFile();
- if (!localFile.isEmpty()) {
- QDir dir(localFile);
-#if defined(Q_OS_SYMBIAN)
- if (dir.isRoot())
- dir.setPath("");
- else
-#endif
- dir.cdUp();
- r = d->folder;
- r.setPath(dir.path());
- } else {
- int pos = d->folder.path().lastIndexOf(QLatin1Char('/'));
- if (pos == -1)
- return QUrl();
- r = d->folder;
- r.setPath(d->folder.path().left(pos));
- }
- return r;
-}
-
-/*!
- \qmlproperty list<string> FolderListModel::nameFilters
-
- The \a nameFilters property contains a list of filename filters.
- The filters may include the ? and * wildcards.
-
- The example below filters on PNG and JPEG files:
-
- \code
- FolderListModel {
- nameFilters: [ "*.png", "*.jpg" ]
- }
- \endcode
-*/
-QStringList QmlFolderListModel::nameFilters() const
-{
- return d->nameFilters;
-}
-
-void QmlFolderListModel::setNameFilters(const QStringList &filters)
-{
- d->nameFilters = filters;
- d->model.setNameFilters(d->nameFilters);
-}
-
-void QmlFolderListModel::componentComplete()
-{
- if (!d->folder.isValid() || !QDir().exists(d->folder.toLocalFile()))
- setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
-
- if (!d->folderIndex.isValid())
- QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
-}
-
-QmlFolderListModel::SortField QmlFolderListModel::sortField() const
-{
- return d->sortField;
-}
-
-void QmlFolderListModel::setSortField(SortField field)
-{
- if (field != d->sortField) {
- d->sortField = field;
- d->updateSorting();
- }
-}
-
-bool QmlFolderListModel::sortReversed() const
-{
- return d->sortReversed;
-}
-
-void QmlFolderListModel::setSortReversed(bool rev)
-{
- if (rev != d->sortReversed) {
- d->sortReversed = rev;
- d->updateSorting();
- }
-}
-
-/*!
- \qmlmethod bool FolderListModel::isFolder(int index)
-
- Returns true if the entry \a index is a folder; otherwise
- returns false.
-*/
-bool QmlFolderListModel::isFolder(int index) const
-{
- if (index != -1) {
- QModelIndex idx = d->model.index(index, 0, d->folderIndex);
- if (idx.isValid())
- return d->model.isDir(idx);
- }
- return false;
-}
-
-void QmlFolderListModel::refresh()
-{
- d->folderIndex = QModelIndex();
- if (d->count) {
- int tmpCount = d->count;
- d->count = 0;
- emit itemsRemoved(0, tmpCount);
- }
- d->folderIndex = d->model.index(d->folder.toLocalFile());
- d->count = d->model.rowCount(d->folderIndex);
- if (d->count) {
- emit itemsInserted(0, d->count);
- }
-}
-
-void QmlFolderListModel::inserted(const QModelIndex &index, int start, int end)
-{
- if (index == d->folderIndex) {
- d->count = d->model.rowCount(d->folderIndex);
- emit itemsInserted(start, end - start + 1);
- }
-}
-
-void QmlFolderListModel::removed(const QModelIndex &index, int start, int end)
-{
- if (index == d->folderIndex) {
- d->count = d->model.rowCount(d->folderIndex);
- emit itemsRemoved(start, end - start + 1);
- }
-}
-
-void QmlFolderListModel::dataChanged(const QModelIndex &start, const QModelIndex &end)
-{
- qDebug() << "data changed";
- if (start.parent() == d->folderIndex)
- emit itemsChanged(start.row(), end.row() - start.row() + 1, roles());
-}
-
-/*!
- \qmlproperty bool FolderListModel::showDirs
-
- If true (the default), directories are included in the model.
-
- Note that the nameFilters are ignored for directories.
-*/
-bool QmlFolderListModel::showDirs() const
-{
- return d->model.filter() & QDir::AllDirs;
-}
-
-void QmlFolderListModel::setShowDirs(bool on)
-{
- if (!(d->model.filter() & QDir::AllDirs) == !on)
- return;
- if (on)
- d->model.setFilter(d->model.filter() | QDir::AllDirs | QDir::Drives);
- else
- d->model.setFilter(d->model.filter() & ~(QDir::AllDirs | QDir::Drives));
-}
-
-/*!
- \qmlproperty bool FolderListModel::showDotAndDotDot
-
- If true, the "." and ".." directories are included in the model.
-
- The default is false.
-*/
-bool QmlFolderListModel::showDotAndDotDot() const
-{
- return !(d->model.filter() & QDir::NoDotAndDotDot);
-}
-
-void QmlFolderListModel::setShowDotAndDotDot(bool on)
-{
- if (!(d->model.filter() & QDir::NoDotAndDotDot) == on)
- return;
- if (on)
- d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot);
- else
- d->model.setFilter(d->model.filter() | QDir::NoDotAndDotDot);
-}
-
-/*!
- \qmlproperty bool FolderListModel::showOnlyReadable
-
- If true, only readable files and directories are shown.
-
- The default is false.
-*/
-bool QmlFolderListModel::showOnlyReadable() const
-{
- return d->model.filter() & QDir::Readable;
-}
-
-void QmlFolderListModel::setShowOnlyReadable(bool on)
-{
- if (!(d->model.filter() & QDir::Readable) == !on)
- return;
- if (on)
- d->model.setFilter(d->model.filter() | QDir::Readable);
- else
- d->model.setFilter(d->model.filter() & ~QDir::Readable);
-}
-
-
-QML_DEFINE_TYPE(Qt,4,6,FolderListModel,QmlFolderListModel)
-
-QT_END_NAMESPACE
-
diff --git a/tools/qmlviewer/qmlfolderlistmodel.h b/tools/qmlviewer/qmlfolderlistmodel.h
deleted file mode 100644
index c180e97757..0000000000
--- a/tools/qmlviewer/qmlfolderlistmodel.h
+++ /dev/null
@@ -1,123 +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 examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QMLFOLDERLISTMODEL_H
-#define QMLFOLDERLISTMODEL_H
-
-#include <qml.h>
-#include "../../src/declarative/3rdparty/qlistmodelinterface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QmlContext;
-class QModelIndex;
-
-class QmlFolderListModelPrivate;
-class QmlFolderListModel : public QListModelInterface, public QmlParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QmlParserStatus)
-
- Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
- Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged)
- Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
- Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
- Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
- Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
- Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
- Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
-
-public:
- QmlFolderListModel(QObject *parent = 0);
- ~QmlFolderListModel();
-
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const;
- virtual QVariant data(int index, int role) const;
- virtual int count() const;
- virtual QList<int> roles() const;
- virtual QString toString(int role) const;
-
- QUrl folder() const;
- void setFolder(const QUrl &folder);
-
- QUrl parentFolder() const;
-
- QStringList nameFilters() const;
- void setNameFilters(const QStringList &filters);
-
- virtual void componentComplete();
-
- Q_INVOKABLE bool isFolder(int index) const;
-
- enum SortField { Unsorted, Name, Time, Size, Type };
- SortField sortField() const;
- void setSortField(SortField field);
- Q_ENUMS(SortField)
-
- bool sortReversed() const;
- void setSortReversed(bool rev);
-
- bool showDirs() const;
- void setShowDirs(bool);
- bool showDotAndDotDot() const;
- void setShowDotAndDotDot(bool);
- bool showOnlyReadable() const;
- void setShowOnlyReadable(bool);
-
-Q_SIGNALS:
- void folderChanged();
-
-private Q_SLOTS:
- void refresh();
- void inserted(const QModelIndex &index, int start, int end);
- void removed(const QModelIndex &index, int start, int end);
- void dataChanged(const QModelIndex &start, const QModelIndex &end);
-
-private:
- Q_DISABLE_COPY(QmlFolderListModel)
- QmlFolderListModelPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlFolderListModel)
-
-#endif // QMLFOLDERLISTMODEL_H
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
deleted file mode 100644
index 626e4c45dd..0000000000
--- a/tools/qmlviewer/qmlviewer.cpp
+++ /dev/null
@@ -1,1465 +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 tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 <qmlview.h>
-
-#ifdef hz
-#undef hz
-#endif
-#include "ui_recopts.h"
-
-#include "qmlviewer.h"
-#include <qmlcontext.h>
-#include <qmlengine.h>
-#include <qmlnetworkaccessmanagerfactory.h>
-#include "qml.h"
-#include <private/qperformancelog_p_p.h>
-#include <private/qabstractanimation_p.h>
-#include <QAbstractAnimation>
-#include "deviceskin.h"
-
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3))
-#include <private/qzipreader_p.h>
-#define QMLVIEWER_ZIP_SUPPORT
-#endif
-
-#include <QSettings>
-#include <QXmlStreamReader>
-#include <QBuffer>
-#include <QNetworkReply>
-#include <QNetworkCookieJar>
-#include <QNetworkDiskCache>
-#include <QNetworkAccessManager>
-#include <QSignalMapper>
-#include <QmlComponent>
-#include <QWidget>
-#include <QApplication>
-#include <QDir>
-#include <QTextBrowser>
-#include <QFile>
-#include <QFileInfo>
-#include <QVBoxLayout>
-#include <QProgressDialog>
-#include <QProcess>
-#include <QMenuBar>
-#include <QMenu>
-#include <QAction>
-#include <QFileDialog>
-#include <QTimer>
-#include <QGraphicsObject>
-#include <QNetworkProxyFactory>
-#include <QKeyEvent>
-#include <QMutex>
-#include <QMutexLocker>
-#include "proxysettings.h"
-#include "deviceorientation.h"
-
-#ifdef GL_SUPPORTED
-#include <QGLWidget>
-#endif
-
-#include <qfxtester.h>
-
-#if defined (Q_OS_SYMBIAN)
-#define SYMBIAN_NETWORK_INIT
-#endif
-
-#if defined (SYMBIAN_NETWORK_INIT)
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <QTextCodec>
-#include "sym_iap_util.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class Screen : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(Orientation orientation READ orientation NOTIFY orientationChanged)
- Q_ENUMS(Orientation)
-
-public:
- Screen(QObject *parent=0) : QObject(parent) {
- connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()),
- this, SIGNAL(orientationChanged()));
- }
-
- enum Orientation { UnknownOrientation = DeviceOrientation::UnknownOrientation,
- Portrait = DeviceOrientation::Portrait,
- Landscape = DeviceOrientation::Landscape };
- Orientation orientation() const { return Orientation(DeviceOrientation::instance()->orientation()); }
-
-signals:
- void orientationChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(Screen)
-
-QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen)
-
-QT_BEGIN_NAMESPACE
-
-class SizedMenuBar : public QMenuBar
-{
- Q_OBJECT
-public:
- SizedMenuBar(QWidget *parent, QWidget *referenceWidget)
- : QMenuBar(parent), refWidget(referenceWidget)
- {
- }
-
- virtual QSize sizeHint() const
- {
- return QSize(refWidget->sizeHint().width(), QMenuBar::sizeHint().height());
- }
-
-private:
- QWidget *refWidget;
-};
-
-
-class PreviewDeviceSkin : public DeviceSkin
-{
- Q_OBJECT
-public:
- explicit PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent);
-
- void setPreview(QWidget *formWidget);
- void setPreviewAndScale(QWidget *formWidget);
-
- void setScreenSize(const QSize& size)
- {
- QMatrix fit;
- fit = fit.scale(qreal(size.width())/m_screenSize.width(),
- qreal(size.height())/m_screenSize.height());
- setTransform(fit);
- QApplication::syncX();
- }
-
- QSize standardScreenSize() const { return m_screenSize; }
-
- QMenu* menu;
-
-private slots:
- void slotSkinKeyPressEvent(int code, const QString& text, bool autorep);
- void slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep);
- void slotPopupMenu();
-
-private:
- const QSize m_screenSize;
-};
-
-
-PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters &parameters, QWidget *parent) :
- DeviceSkin(parameters, parent),
- m_screenSize(parameters.screenSize())
-{
- menu = new QMenu(this);
- connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)),
- this, SLOT(slotSkinKeyPressEvent(int,QString,bool)));
- connect(this, SIGNAL(skinKeyReleaseEvent(int,QString,bool)),
- this, SLOT(slotSkinKeyReleaseEvent(int,QString,bool)));
- connect(this, SIGNAL(popupMenu()), this, SLOT(slotPopupMenu()));
-}
-
-void PreviewDeviceSkin::setPreview(QWidget *formWidget)
-{
- formWidget->setFixedSize(m_screenSize);
- formWidget->setParent(this, Qt::SubWindow);
- formWidget->setAutoFillBackground(true);
- setView(formWidget);
-}
-
-void PreviewDeviceSkin::setPreviewAndScale(QWidget *formWidget)
-{
- setScreenSize(formWidget->sizeHint());
- formWidget->setParent(this, Qt::SubWindow);
- formWidget->setAutoFillBackground(true);
- setView(formWidget);
-}
-
-void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, bool autorep)
-{
- if (QWidget *focusWidget = QApplication::focusWidget()) {
- QKeyEvent e(QEvent::KeyPress,code,0,text,autorep);
- QApplication::sendEvent(focusWidget, &e);
- }
-
-}
-
-void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep)
-{
- if (QWidget *focusWidget = QApplication::focusWidget()) {
- QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep);
- QApplication::sendEvent(focusWidget, &e);
- }
-}
-
-void PreviewDeviceSkin::slotPopupMenu()
-{
- menu->exec(QCursor::pos());
-}
-
-static struct { const char *name, *args; } ffmpegprofiles[] = {
- {"Maximum Quality", "-sameq"},
- {"High Quality", "-qmax 2"},
- {"Medium Quality", "-qmax 6"},
- {"Low Quality", "-qmax 16"},
- {"Custom ffmpeg arguments", ""},
- {0,0}
-};
-
-class RecordingDialog : public QDialog, public Ui::RecordingOptions {
- Q_OBJECT
-
-public:
- RecordingDialog(QWidget *parent) : QDialog(parent)
- {
- setupUi(this);
- hz->setValidator(new QDoubleValidator(hz));
- for (int i=0; ffmpegprofiles[i].name; ++i) {
- profile->addItem(ffmpegprofiles[i].name);
- }
- }
-
- void setArguments(QString a)
- {
- int i;
- for (i=0; ffmpegprofiles[i].args[0]; ++i) {
- if (ffmpegprofiles[i].args == a) {
- profile->setCurrentIndex(i);
- args->setText(QLatin1String(ffmpegprofiles[i].args));
- return;
- }
- }
- customargs = a;
- args->setText(a);
- profile->setCurrentIndex(i);
- }
-
- QString arguments() const
- {
- int i = profile->currentIndex();
- return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs;
- }
-
-private slots:
- void pickProfile(int i)
- {
- if (ffmpegprofiles[i].args[0]) {
- args->setText(QLatin1String(ffmpegprofiles[i].args));
- } else {
- args->setText(customargs);
- }
- }
-
- void storeCustomArgs(QString s)
- {
- setArguments(s);
- }
-
-private:
- QString customargs;
-};
-
-class PersistentCookieJar : public QNetworkCookieJar {
-public:
- PersistentCookieJar(QObject *parent) : QNetworkCookieJar(parent) { load(); }
- ~PersistentCookieJar() { save(); }
-
- virtual QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const
- {
- QMutexLocker lock(&mutex);
- return QNetworkCookieJar::cookiesForUrl(url);
- }
-
- virtual bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url)
- {
- QMutexLocker lock(&mutex);
- return QNetworkCookieJar::setCookiesFromUrl(cookieList, url);
- }
-
-private:
- void save()
- {
- QMutexLocker lock(&mutex);
- QList<QNetworkCookie> list = allCookies();
- QByteArray data;
- foreach (QNetworkCookie cookie, list) {
- if (!cookie.isSessionCookie()) {
- data.append(cookie.toRawForm());
- data.append("\n");
- }
- }
- QSettings settings("Nokia", "QtQmlViewer");
- settings.setValue("Cookies",data);
- }
-
- void load()
- {
- QMutexLocker lock(&mutex);
- QSettings settings("Nokia", "QtQmlViewer");
- QByteArray data = settings.value("Cookies").toByteArray();
- setAllCookies(QNetworkCookie::parseCookies(data));
- }
-
- mutable QMutex mutex;
-};
-
-class NetworkAccessManagerFactory : public QmlNetworkAccessManagerFactory
-{
-public:
- NetworkAccessManagerFactory() : cookieJar(0), cacheSize(0) {}
- ~NetworkAccessManagerFactory() {
- delete cookieJar;
- }
-
- QNetworkAccessManager *create(QObject *parent) {
- QMutexLocker lock(&mutex);
- QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
- if (!cookieJar)
- cookieJar = new PersistentCookieJar(0);
- manager->setCookieJar(cookieJar);
- cookieJar->setParent(0);
- setupProxy(manager);
- if (cacheSize > 0) {
- QNetworkDiskCache *cache = new QNetworkDiskCache;
- cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache"));
- cache->setMaximumCacheSize(cacheSize);
- manager->setCache(cache);
- } else {
- manager->setCache(0);
- }
- qDebug() << "created new network access manager for" << parent;
- return manager;
- }
-
- void setupProxy(QNetworkAccessManager *nam)
- {
- class SystemProxyFactory : public QNetworkProxyFactory
- {
- public:
- virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query)
- {
- QString protocolTag = query.protocolTag();
- if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
- QList<QNetworkProxy> ret;
- ret << httpProxy;
- return ret;
- }
- return QNetworkProxyFactory::systemProxyForQuery(query);
- }
- void setHttpProxy (QNetworkProxy proxy)
- {
- httpProxy = proxy;
- httpProxyInUse = true;
- }
- void unsetHttpProxy ()
- {
- httpProxyInUse = false;
- }
- private:
- bool httpProxyInUse;
- QNetworkProxy httpProxy;
- };
-
- SystemProxyFactory *proxyFactory = new SystemProxyFactory;
- if (ProxySettings::httpProxyInUse())
- proxyFactory->setHttpProxy(ProxySettings::httpProxy());
- else
- proxyFactory->unsetHttpProxy();
- nam->setProxyFactory(proxyFactory);
- }
-
- void setCacheSize(int size) {
- if (size != cacheSize) {
- cacheSize = size;
- }
- }
-
- PersistentCookieJar *cookieJar;
- QMutex mutex;
- int cacheSize;
-};
-
-
-QString QmlViewer::getVideoFileName()
-{
- QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames");
- QStringList types;
- if (ffmpegAvailable) types += tr("Common Video files")+QLatin1String(" (*.avi *.mpeg *.mov)");
- if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)");
- types += tr("Individual PNG frames")+QLatin1String(" (*.png)");
- if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)");
- return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
-}
-
-
-QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
-#if defined(Q_OS_SYMBIAN)
- : QMainWindow(parent, flags)
-#else
- : QWidget(parent, flags)
-#endif
- , frame_stream(0), scaleSkin(true), mb(0)
- , portraitOrientation(0), landscapeOrientation(0)
- , m_scriptOptions(0), tester(0), useQmlFileBrowser(true)
-{
- devicemode = false;
- skin = 0;
- canvas = 0;
- record_autotime = 0;
- record_rate = 50;
- record_args += QLatin1String("-sameq");
-
- recdlg = new RecordingDialog(this);
- connect(recdlg->pickfile, SIGNAL(clicked()), this, SLOT(pickRecordingFile()));
- senseFfmpeg();
- senseImageMagick();
- if (!ffmpegAvailable)
- recdlg->ffmpegOptions->hide();
- if (!ffmpegAvailable && !convertAvailable)
- recdlg->rateOptions->hide();
- QString warn;
- if (!ffmpegAvailable) {
- if (!convertAvailable)
- warn = tr("ffmpeg and ImageMagick not available - no video output");
- else
- warn = tr("ffmpeg not available - GIF and PNG outputs only");
- recdlg->warning->setText(warn);
- } else {
- recdlg->warning->hide();
- }
-
- canvas = new QmlView(this);
- canvas->setAttribute(Qt::WA_OpaquePaintEvent);
- canvas->setAttribute(Qt::WA_NoSystemBackground);
- canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
- canvas->setFocus();
-
- QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
- QObject::connect(canvas, SIGNAL(statusChanged(QmlView::Status)), this, SLOT(statusChanged()));
- QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
-
- if (!(flags & Qt::FramelessWindowHint)) {
- createMenu(menuBar(),0);
- setPortrait();
- }
-
-#if !defined(Q_OS_SYMBIAN)
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(0);
- layout->setSpacing(0);
- setLayout(layout);
- if (mb)
- layout->addWidget(mb);
- layout->addWidget(canvas);
-#else
- setCentralWidget(canvas);
-#endif
-
- namFactory = new NetworkAccessManagerFactory;
- canvas->engine()->setNetworkAccessManagerFactory(namFactory);
-
- connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording()));
- connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording()));
- connect(&recordTimer, SIGNAL(triggered()), this, SLOT(recordFrame()));
- autoStartTimer.setRunning(false);
- autoStopTimer.setRunning(false);
- recordTimer.setRunning(false);
- recordTimer.setRepeating(true);
-}
-
-QmlViewer::~QmlViewer()
-{
- canvas->engine()->setNetworkAccessManagerFactory(0);
- delete namFactory;
-}
-
-QMenuBar *QmlViewer::menuBar() const
-{
-#if !defined(Q_OS_SYMBIAN)
- if (!mb)
- mb = new SizedMenuBar((QWidget*)this, canvas);
-#else
- mb = QMainWindow::menuBar();
-#endif
-
- return mb;
-}
-
-void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
-{
- QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu;
-
- QMenu *fileMenu = flatmenu ? flatmenu : menu->addMenu(tr("&File"));
-
- QAction *openAction = new QAction(tr("&Open..."), parent);
- openAction->setShortcut(QKeySequence("Ctrl+O"));
- connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
- fileMenu->addAction(openAction);
-
- QAction *reloadAction = new QAction(tr("&Reload"), parent);
- reloadAction->setShortcut(QKeySequence("Ctrl+R"));
- connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
- fileMenu->addAction(reloadAction);
-
-#if defined(Q_OS_SYMBIAN)
- QAction *networkAction = new QAction(tr("Start &Network"), parent);
- connect(networkAction, SIGNAL(triggered()), this, SLOT(startNetwork()));
- fileMenu->addAction(networkAction);
-#endif
-
-#if !defined(Q_OS_SYMBIAN)
- if (flatmenu) flatmenu->addSeparator();
-
- QMenu *recordMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Recording"));
-
- QAction *snapshotAction = new QAction(tr("&Take Snapshot\tF3"), parent);
- connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
- recordMenu->addAction(snapshotAction);
-
- recordAction = new QAction(tr("Start Recording &Video\tF9"), parent);
- connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
- recordMenu->addAction(recordAction);
-
- QAction *recordOptions = new QAction(tr("Video &Options..."), parent);
- connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
-
- if (flatmenu)
- flatmenu->addAction(recordOptions);
-
- if (flatmenu) flatmenu->addSeparator();
-
- QMenu *debugMenu = flatmenu ? flatmenu->addMenu(tr("&Debugging")) : menu->addMenu(tr("&Debugging"));
-
- QAction *slowAction = new QAction(tr("&Slow Down Animations"), parent);
- slowAction->setShortcut(QKeySequence("Ctrl+."));
- slowAction->setCheckable(true);
- connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool)));
- debugMenu->addAction(slowAction);
-
- if (flatmenu) flatmenu->addSeparator();
-
- QMenu *skinMenu = flatmenu ? flatmenu->addMenu(tr("&Skin")) : menu->addMenu(tr("&Skin"));
-
- QActionGroup *skinActions;
- QAction *skinAction;
-
- skinActions = new QActionGroup(parent);
- skinAction = new QAction(tr("Scale skin"), parent);
- skinAction->setCheckable(true);
- skinAction->setChecked(scaleSkin);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleSkin()));
- skinAction = new QAction(tr("Resize view"), parent);
- skinAction->setCheckable(true);
- skinAction->setChecked(!scaleSkin);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- connect(skinAction, SIGNAL(triggered()), this, SLOT(setScaleView()));
- skinMenu->addSeparator();
-
- skinActions = new QActionGroup(parent);
- QSignalMapper *mapper = new QSignalMapper(parent);
- skinAction = new QAction(tr("None"), parent);
- skinAction->setCheckable(true);
- if (currentSkin.isEmpty())
- skinAction->setChecked(true);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- mapper->setMapping(skinAction, "");
- connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map()));
- skinMenu->addSeparator();
-
- foreach (QString name, builtinSkins()) {
- skinAction = new QAction(name, parent);
- skinActions->addAction(skinAction);
- skinMenu->addAction(skinAction);
- skinAction->setCheckable(true);
- if (":skin/"+name+".skin" == currentSkin)
- skinAction->setChecked(true);
- mapper->setMapping(skinAction, name);
- connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map()));
- }
- connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setSkin(QString)));
-
- if (flatmenu) flatmenu->addSeparator();
-#endif // Q_OS_SYMBIAN
-
- QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings"));
- QAction *proxyAction = new QAction(tr("Http &proxy..."), parent);
- connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings()));
- settingsMenu->addAction(proxyAction);
-#if !defined(Q_OS_SYMBIAN)
- if (!flatmenu)
- settingsMenu->addAction(recordOptions);
-#else
- QAction *fullscreenAction = new QAction(tr("Full Screen"), parent);
- fullscreenAction->setCheckable(true);
- connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
- settingsMenu->addAction(fullscreenAction);
-#endif
-
- QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
- QActionGroup *orientation = new QActionGroup(parent);
-
- QAction *toggleOrientation = new QAction(tr("&Toggle Orientation"), parent);
- toggleOrientation->setCheckable(true);
- toggleOrientation->setShortcut(QKeySequence("Ctrl+T"));
- settingsMenu->addAction(toggleOrientation);
- connect(toggleOrientation, SIGNAL(triggered()), this, SLOT(toggleOrientation()));
-
- orientation->setExclusive(true);
- portraitOrientation = new QAction(tr("orientation: Portrait"), parent);
- portraitOrientation->setCheckable(true);
- connect(portraitOrientation, SIGNAL(triggered()), this, SLOT(setPortrait()));
- orientation->addAction(portraitOrientation);
- propertiesMenu->addAction(portraitOrientation);
-
- landscapeOrientation = new QAction(tr("orientation: Landscape"), parent);
- landscapeOrientation->setCheckable(true);
- connect(landscapeOrientation, SIGNAL(triggered()), this, SLOT(setLandscape()));
- orientation->addAction(landscapeOrientation);
- propertiesMenu->addAction(landscapeOrientation);
-
- if (flatmenu) flatmenu->addSeparator();
-
- QMenu *helpMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Help"));
- QAction *aboutAction = new QAction(tr("&About Qt..."), parent);
- connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
- helpMenu->addAction(aboutAction);
-
- QAction *quitAction = new QAction(tr("&Quit"), parent);
- quitAction->setShortcut(QKeySequence("Ctrl+Q"));
- connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
- fileMenu->addSeparator();
- fileMenu->addAction(quitAction);
- if (menu) {
- menu->setFixedHeight(menu->sizeHint().height());
- menu->setMinimumWidth(10);
- }
-}
-
-void QmlViewer::showProxySettings()
-{
- ProxySettings settingsDlg (this);
-
- connect (&settingsDlg, SIGNAL (accepted()), this, SLOT (proxySettingsChanged ()));
-
- settingsDlg.exec();
-}
-
-void QmlViewer::proxySettingsChanged()
-{
- reload ();
-}
-
-void QmlViewer::setPortrait()
-{
- DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
- portraitOrientation->setChecked(true);
-}
-
-void QmlViewer::setLandscape()
-{
- DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape);
- landscapeOrientation->setChecked(true);
-}
-
-void QmlViewer::toggleOrientation()
-{
- DeviceOrientation::instance()->setOrientation(DeviceOrientation::instance()->orientation()==DeviceOrientation::Portrait?DeviceOrientation::Landscape:DeviceOrientation::Portrait);
-}
-
-void QmlViewer::toggleFullScreen()
-{
- if (isFullScreen())
- showMaximized();
- else
- showFullScreen();
-}
-
-void QmlViewer::setScaleSkin()
-{
- if (scaleSkin)
- return;
- scaleSkin = true;
- canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
- if (skin) {
- canvas->setFixedSize(canvas->sizeHint());
- skin->setScreenSize(canvas->sizeHint());
- }
-}
-
-void QmlViewer::setScaleView()
-{
- if (!scaleSkin)
- return;
- scaleSkin = false;
- if (skin) {
- canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
- canvas->setMinimumSize(QSize(0,0));
- canvas->setMaximumSize(QSize(16777215,16777215));
- canvas->resize(skin->standardScreenSize());
- skin->setScreenSize(skin->standardScreenSize());
- }
-}
-
-
-void QmlViewer::takeSnapShot()
-{
- static int snapshotcount = 1;
- QString snapFileName = QString(QLatin1String("snapshot%1.png")).arg(snapshotcount);
- QPixmap::grabWidget(canvas).save(snapFileName);
- qDebug() << "Wrote" << snapFileName;
- ++snapshotcount;
-}
-
-void QmlViewer::pickRecordingFile()
-{
- QString fileName = getVideoFileName();
- if (!fileName.isEmpty())
- recdlg->file->setText(fileName);
-}
-
-void QmlViewer::chooseRecordingOptions()
-{
- // File
- recdlg->file->setText(record_file);
-
- // Size
- recdlg->sizeOriginal->setText(tr("Original (%1x%2)").arg(canvas->width()).arg(canvas->height()));
- if (recdlg->sizeWidth->value()<=1) {
- recdlg->sizeWidth->setValue(canvas->width());
- recdlg->sizeHeight->setValue(canvas->height());
- }
-
- // Rate
- if (record_rate == 24)
- recdlg->hz24->setChecked(true);
- else if (record_rate == 25)
- recdlg->hz25->setChecked(true);
- else if (record_rate == 50)
- recdlg->hz50->setChecked(true);
- else if (record_rate == 60)
- recdlg->hz60->setChecked(true);
- else {
- recdlg->hzCustom->setChecked(true);
- recdlg->hz->setText(QString::number(record_rate));
- }
-
- // Profile
- recdlg->setArguments(record_args.join(" "));
- if (recdlg->exec()) {
- // File
- record_file = recdlg->file->text();
- // Size
- if (recdlg->sizeOriginal->isChecked())
- record_outsize = QSize();
- else if (recdlg->size720p->isChecked())
- record_outsize = QSize(1280,720);
- else if (recdlg->sizeVGA->isChecked())
- record_outsize = QSize(640,480);
- else if (recdlg->sizeQVGA->isChecked())
- record_outsize = QSize(320,240);
- else
- record_outsize = QSize(recdlg->sizeWidth->value(),recdlg->sizeHeight->value());
- // Rate
- if (recdlg->hz24->isChecked())
- record_rate = 24;
- else if (recdlg->hz25->isChecked())
- record_rate = 25;
- else if (recdlg->hz50->isChecked())
- record_rate = 50;
- else if (recdlg->hz60->isChecked())
- record_rate = 60;
- else {
- record_rate = recdlg->hz->text().toDouble();
- }
- // Profile
- record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts);
- }
-}
-
-void QmlViewer::toggleRecordingWithSelection()
-{
- if (!recordTimer.isRunning()) {
- if (record_file.isEmpty()) {
- QString fileName = getVideoFileName();
- if (fileName.isEmpty())
- return;
- if (!fileName.contains(QRegExp(".[^\\/]*$")))
- fileName += ".avi";
- setRecordFile(fileName);
- }
- }
- toggleRecording();
-}
-
-void QmlViewer::toggleRecording()
-{
- if (record_file.isEmpty()) {
- toggleRecordingWithSelection();
- return;
- }
- bool recording = !recordTimer.isRunning();
- recordAction->setText(recording ? tr("&Stop Recording Video\tF9") : tr("&Start Recording Video\tF9"));
- setRecording(recording);
-}
-
-void QmlViewer::setSlowMode(bool enable)
-{
- QUnifiedTimer::instance()->setSlowModeEnabled(enable);
-}
-
-void QmlViewer::addLibraryPath(const QString& lib)
-{
- canvas->engine()->addImportPath(lib);
-}
-
-void QmlViewer::reload()
-{
- openQml(currentFileOrUrl);
-}
-
-void QmlViewer::open(const QString& doc)
-{
-#ifdef QMLVIEWER_ZIP_SUPPORT
- if (doc.endsWith(".wgt",Qt::CaseInsensitive)
- || doc.endsWith(".wgz",Qt::CaseInsensitive)
- || doc.endsWith(".zip",Qt::CaseInsensitive))
- openWgt(doc);
- else
-#endif
- openQml(doc);
-}
-
-void QmlViewer::openWgt(const QString& doc)
-{
-#ifdef QMLVIEWER_ZIP_SUPPORT
- // XXX This functionality could be migrated to QmlView once refined
-
- QUrl url(doc);
- if (url.isRelative())
- url = QUrl::fromLocalFile(doc);
- delete canvas->rootObject();
- canvas->engine()->clearComponentCache();
- QNetworkAccessManager * nam = canvas->engine()->networkAccessManager();
- wgtreply = nam->get(QNetworkRequest(url));
- connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt()));
-#endif
-}
-
-#ifdef QMLVIEWER_ZIP_SUPPORT
-static void removeRecursive(const QString& dirname)
-{
- QDir dir(dirname);
- QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
- if (entries[i].isDir())
- removeRecursive(entries[i].filePath());
- else
- dir.remove(entries[i].fileName());
- QDir().rmdir(dirname);
-}
-#endif
-
-void QmlViewer::unpackWgt()
-{
-#ifdef QMLVIEWER_ZIP_SUPPORT
- QByteArray all = wgtreply->readAll();
- QBuffer buf(&all);
- buf.open(QIODevice::ReadOnly);
- QZipReader zip(&buf);
- /*
- for (int i=0; i<zip.count(); ++i) {
- QZipReader::FileInfo info = zip.entryInfoAt(i);
- qDebug() << "zip:" << info.filePath;
- }
- */
- wgtdir = QDir::tempPath()+QDir::separator()+QLatin1String("qmlviewer-wgt");
- removeRecursive(wgtdir);
- QDir().mkpath(wgtdir);
- zip.extractAll(wgtdir);
-
- QString rootfile;
-
- if (wgtreply->header(QNetworkRequest::ContentTypeHeader).toString() == "application/widget" || wgtreply->url().path().endsWith(".wgt",Qt::CaseInsensitive)) {
- // W3C Draft http://www.w3.org/TR/2009/CR-widgets-20091201
- QFile configfile(wgtdir+QDir::separator()+"config.xml");
- if (configfile.open(QIODevice::ReadOnly)) {
- QXmlStreamReader config(&configfile);
- if (config.readNextStartElement() && config.name() == "widget") {
- while (config.readNextStartElement()) {
- if (config.name() == "content") {
- rootfile = wgtdir + QDir::separator();
- rootfile += config.attributes().value(QLatin1String("src"));
- }
- // XXX process other config
-
- config.skipCurrentElement();
- }
- }
- } else {
- qWarning("No config.xml found - non-standard WGT file");
- }
- if (rootfile.isEmpty()) {
- QString def = wgtdir+QDir::separator()+"index.qml";
- if (QFile::exists(def))
- rootfile = def;
- }
- } else {
- // Just find index.qml, preferably at the root
- for (int i=0; i<zip.count(); ++i) {
- QZipReader::FileInfo info = zip.entryInfoAt(i);
- if (info.filePath.compare(QLatin1String("index.qml"),Qt::CaseInsensitive)==0)
- rootfile = wgtdir+QDir::separator()+info.filePath;
- if (rootfile.isEmpty() && info.filePath.endsWith("/index.qml",Qt::CaseInsensitive))
- rootfile = wgtdir+QDir::separator()+info.filePath;
- }
- }
-
- openQml(rootfile);
-#endif
-}
-
-void QmlViewer::openFile()
-{
- QString cur = canvas->source().toLocalFile();
- if (useQmlFileBrowser) {
- openQml("qrc:/content/Browser.qml");
- } else {
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
- if (!fileName.isEmpty()) {
- QFileInfo fi(fileName);
- openQml(fi.absoluteFilePath());
- }
- }
-}
-
-void QmlViewer::statusChanged()
-{
- if (canvas->status() == QmlView::Error && tester)
- tester->executefailure();
-
- if (canvas->status() == QmlView::Ready)
- resize(sizeHint());
-}
-
-void QmlViewer::launch(const QString& file_or_url)
-{
- QMetaObject::invokeMethod(this, "openQml", Qt::QueuedConnection, Q_ARG(QString, file_or_url));
-}
-
-void QmlViewer::openQml(const QString& file_or_url)
-{
- currentFileOrUrl = file_or_url;
-
- QUrl url;
- QFileInfo fi(file_or_url);
- if (fi.exists())
- url = QUrl::fromLocalFile(fi.absoluteFilePath());
- else
- url = QUrl(file_or_url);
- setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(file_or_url));
-
- if (!m_script.isEmpty())
- tester = new QmlGraphicsTester(m_script, m_scriptOptions, canvas);
-
- delete canvas->rootObject();
- canvas->engine()->clearComponentCache();
- QmlContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("qmlViewer", this);
-#ifdef Q_OS_SYMBIAN
- ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone
-#else
- ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath());
-#endif
-
- QString fileName = url.toLocalFile();
- if (!fileName.isEmpty()) {
- QFileInfo fi(fileName);
- if (fi.exists()) {
- if (fi.suffix().toLower() != QLatin1String("qml")) {
- qWarning() << "qmlviewer cannot open non-QML file" << fileName;
- return;
- }
-
- QDir dir(fi.path()+"/dummydata", "*.qml");
- QStringList list = dir.entryList();
- for (int i = 0; i < list.size(); ++i) {
- QString qml = list.at(i);
- QFile f(dir.filePath(qml));
- f.open(QIODevice::ReadOnly);
- QByteArray data = f.readAll();
- QmlComponent comp(canvas->engine());
- comp.setData(data, QUrl());
- QObject *dummyData = comp.create();
-
- if(comp.isError()) {
- QList<QmlError> errors = comp.errors();
- foreach (const QmlError &error, errors) {
- qWarning() << error;
- }
- if (tester) tester->executefailure();
- }
-
- if (dummyData) {
- qWarning() << "Loaded dummy data:" << dir.filePath(qml);
- qml.truncate(qml.length()-4);
- ctxt->setContextProperty(qml, dummyData);
- dummyData->setParent(this);
- }
- }
- } else {
- qWarning() << "qmlviewer cannot find file:" << fileName;
- return;
- }
- }
-
- canvas->setSource(url);
-
- QTime t;
- t.start();
- canvas->execute();
- qWarning() << "Wall startup time:" << t.elapsed();
-
- if (!skin) {
- canvas->updateGeometry();
- if (mb)
- mb->updateGeometry();
- if (!isFullScreen() && !isMaximized())
- resize(sizeHint());
- } else {
- if (scaleSkin)
- canvas->resize(canvas->sizeHint());
- else {
- canvas->setFixedSize(skin->standardScreenSize());
- canvas->resize(skin->standardScreenSize());
- }
- }
-
-#ifdef QTOPIA
- show();
-#endif
-}
-
-void QmlViewer::startNetwork()
-{
-#if defined(SYMBIAN_NETWORK_INIT)
- qt_SetDefaultIap();
-#endif
-}
-
-QStringList QmlViewer::builtinSkins() const
-{
- QDir dir(":/skins/","*.skin");
- const QFileInfoList l = dir.entryInfoList();
- QStringList r;
- for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) {
- r += (*it).baseName();
- }
- return r;
-}
-
-void QmlViewer::setSkin(const QString& skinDirOrName)
-{
- QString skinDirectory = skinDirOrName;
-
- if (!QDir(skinDirOrName).exists() && QDir(":/skins/"+skinDirOrName+".skin").exists())
- skinDirectory = ":/skins/"+skinDirOrName+".skin";
-
- if (currentSkin == skinDirectory)
- return;
-
- currentSkin = skinDirectory;
-
- // XXX QWidget::setMask does not handle changes well, and we may
- // XXX have been signalled from an item in a menu we're replacing,
- // XXX hence some rather convoluted resetting here...
-
- QString err;
- if (skin) {
- skin->hide();
- skin->deleteLater();
- }
-
- canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject);
-
- DeviceSkinParameters parameters;
- if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) {
- layout()->setEnabled(false);
- //setMenuBar(0);
- if (mb)
- mb->hide();
- if (!err.isEmpty())
- qWarning() << err;
- skin = new PreviewDeviceSkin(parameters,this);
- canvas->resize(canvas->sizeHint());
- if (scaleSkin)
- skin->setPreviewAndScale(canvas);
- else
- skin->setPreview(canvas);
- createMenu(0,skin->menu);
- skin->show();
- } else {
- skin = 0;
- clearMask();
- menuBar()->clear();
- canvas->setParent(this, Qt::SubWindow);
- createMenu(menuBar(),0);
- mb->show();
- setMinimumSize(QSize(0,0));
- setMaximumSize(QSize(16777215,16777215));
- canvas->setMinimumSize(QSize(0,0));
- canvas->setMaximumSize(QSize(16777215,16777215));
- QRect g = geometry();
- g.setSize(sizeHint());
- setParent(0,windowFlags()); // recreate
- canvas->move(0,menuBar()->sizeHint().height());
- setGeometry(g);
- layout()->setEnabled(true);
- show();
- }
- canvas->show();
-}
-
-void QmlViewer::setAutoRecord(int from, int to)
-{
- if (from==0) from=1; // ensure resized
- record_autotime = to-from;
- autoStartTimer.setInterval(from);
- autoStartTimer.setRunning(true);
-}
-
-void QmlViewer::setRecordArgs(const QStringList& a)
-{
- record_args = a;
-}
-
-void QmlViewer::setRecordFile(const QString& f)
-{
- record_file = f;
-}
-
-void QmlViewer::setRecordRate(int fps)
-{
- record_rate = fps;
-}
-
-void QmlViewer::sceneResized(QSize size)
-{
- if (size.width() > 0 && size.height() > 0) {
- if (skin && scaleSkin)
- skin->setScreenSize(size);
- }
-}
-
-void QmlViewer::keyPressEvent(QKeyEvent *event)
-{
- if (event->key() == Qt::Key_0 && devicemode)
- exit(0);
- else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) {
- qDebug() << "F1 - help\n"
- << "F2 - save test script\n"
- << "F3 - take PNG snapshot\n"
- << "F4 - show items and state\n"
- << "F5 - reload QML\n"
- << "F6 - show object tree\n"
- << "F7 - show timing\n"
- << "F8 - show performance (if available)\n"
- << "F9 - toggle video recording\n"
- << "F10 - toggle orientation\n"
- << "device keys: 0=quit, 1..8=F1..F8"
- ;
- } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) {
- if (tester && m_scriptOptions & Record)
- tester->save();
- } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) {
- takeSnapShot();
- } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) {
- reload();
- } else if (event->key() == Qt::Key_F8 || (event->key() == Qt::Key_8 && devicemode)) {
- QPerformanceLog::displayData();
- QPerformanceLog::clear();
- } else if (event->key() == Qt::Key_F9 || (event->key() == Qt::Key_9 && devicemode)) {
- toggleRecording();
- } else if (event->key() == Qt::Key_F10) {
- if (portraitOrientation) {
- if (portraitOrientation->isChecked())
- setLandscape();
- else
- setPortrait();
- }
- }
-
- QWidget::keyPressEvent(event);
-}
-
-void QmlViewer::senseImageMagick()
-{
- QProcess proc;
- proc.start("convert", QStringList() << "-h");
- proc.waitForFinished(2000);
- QString help = proc.readAllStandardOutput();
- convertAvailable = help.contains("ImageMagick");
-}
-
-void QmlViewer::senseFfmpeg()
-{
- QProcess proc;
- proc.start("ffmpeg", QStringList() << "-h");
- proc.waitForFinished(2000);
- QString ffmpegHelp = proc.readAllStandardOutput();
- ffmpegAvailable = ffmpegHelp.contains("-s ");
- ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp;
-
- QDialog *d = new QDialog(recdlg);
- QVBoxLayout *l = new QVBoxLayout(d);
- QTextBrowser *b = new QTextBrowser(d);
- QFont f = b->font();
- f.setFamily("courier");
- b->setFont(f);
- b->setText(ffmpegHelp);
- l->addWidget(b);
- d->setLayout(l);
- ffmpegHelpWindow = d;
- connect(recdlg->ffmpegHelp,SIGNAL(clicked()), ffmpegHelpWindow, SLOT(show()));
-}
-
-void QmlViewer::setRecording(bool on)
-{
- if (on == recordTimer.isRunning())
- return;
-
- int period = int(1000/record_rate+0.5);
- QUnifiedTimer::instance()->setTimingInterval(on ? period:16);
- QUnifiedTimer::instance()->setConsistentTiming(on);
- if (on) {
- canvas->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
- recordTimer.setInterval(period);
- recordTimer.setRunning(true);
- frame_fmt = record_file.right(4).toLower();
- frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32);
- if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) {
- // Stream video to ffmpeg
-
- QProcess *proc = new QProcess(this);
- connect(proc, SIGNAL(finished(int)), this, SLOT(ffmpegFinished(int)));
- frame_stream = proc;
-
- QStringList args;
- args << "-y";
- args << "-r" << QString::number(record_rate);
- args << "-f" << "rawvideo";
- args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32");
- args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height());
- args << "-i" << "-";
- if (record_outsize.isValid()) {
- args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height());
- args << "-aspect" << QString::number(double(canvas->width())/canvas->height());
- }
- args += record_args;
- args << record_file;
- proc->start("ffmpeg",args);
-
- } else {
- // Store frames, save to GIF/PNG
- frame_stream = 0;
- }
- } else {
- canvas->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
- recordTimer.setRunning(false);
- if (frame_stream) {
- qDebug() << "Saving video...";
- frame_stream->close();
- qDebug() << "Wrote" << record_file;
- } else {
- QProgressDialog progress(tr("Saving frames..."), tr("Cancel"), 0, frames.count()+10, this);
- progress.setWindowModality(Qt::WindowModal);
-
- int frame=0;
- QStringList inputs;
- qDebug() << "Saving frames...";
-
- QString framename;
- bool png_output = false;
- if (record_file.right(4).toLower()==".png") {
- if (record_file.contains('%'))
- framename = record_file;
- else
- framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4);
- png_output = true;
- } else {
- framename = "tmp-frame%04d.png";
- png_output = false;
- }
- foreach (QImage* img, frames) {
- progress.setValue(progress.value()+1);
- if (progress.wasCanceled())
- break;
- QString name;
- name.sprintf(framename.toLocal8Bit(),frame++);
- if (record_outsize.isValid())
- *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
- if (record_dither=="ordered")
- img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name);
- else if (record_dither=="threshold")
- img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name);
- else if (record_dither=="floyd")
- img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name);
- else
- img->save(name);
- inputs << name;
- delete img;
- }
-
- if (!progress.wasCanceled()) {
- if (png_output) {
- framename.replace(QRegExp("%\\d*."),"*");
- qDebug() << "Wrote frames" << framename;
- inputs.clear(); // don't remove them
- } else {
- // ImageMagick and gifsicle for GIF encoding
- progress.setLabelText(tr("Converting frames to GIF file..."));
- QStringList args;
- args << "-delay" << QString::number(period/10);
- args << inputs;
- args << record_file;
- qDebug() << "Converting..." << record_file << "(this may take a while)";
- if (0!=QProcess::execute("convert", args)) {
- qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted";
- inputs.clear(); // don't remove them
- qDebug() << "Wrote frames tmp-frame*.png";
- } else {
- if (record_file.right(4).toLower() == ".gif") {
- qDebug() << "Compressing..." << record_file;
- if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file))
- qWarning() << "Cannot run 'gifsicle' - not compressed";
- }
- qDebug() << "Wrote" << record_file;
- }
- }
- }
-
- progress.setValue(progress.maximum()-1);
- foreach (QString name, inputs)
- QFile::remove(name);
-
- frames.clear();
- }
- }
- qDebug() << "Recording: " << (recordTimer.isRunning()?"ON":"OFF");
-}
-
-void QmlViewer::ffmpegFinished(int code)
-{
- qDebug() << "ffmpeg returned" << code << frame_stream->readAllStandardError();
-}
-
-void QmlViewer::autoStartRecording()
-{
- setRecording(true);
- autoStopTimer.setInterval(record_autotime);
- autoStopTimer.setRunning(true);
-}
-
-void QmlViewer::autoStopRecording()
-{
- setRecording(false);
-}
-
-void QmlViewer::recordFrame()
-{
- canvas->QWidget::render(&frame);
- if (frame_stream) {
- if (frame_fmt == ".gif") {
- // ffmpeg can't do 32bpp with gif
- QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888);
- frame_stream->write((char*)rgb24.bits(),rgb24.numBytes());
- } else {
- frame_stream->write((char*)frame.bits(),frame.numBytes());
- }
- } else {
- frames.append(new QImage(frame));
- }
-}
-
-void QmlViewer::setDeviceKeys(bool on)
-{
- devicemode = on;
-}
-
-void QmlViewer::setNetworkCacheSize(int size)
-{
- namFactory->setCacheSize(size);
-}
-
-void QmlViewer::setUseGL(bool useGL)
-{
-#ifdef GL_SUPPORTED
- if (useGL) {
- QGLFormat format = QGLFormat::defaultFormat();
- format.setSampleBuffers(false);
-
- QGLWidget *glWidget = new QGLWidget(format);
- glWidget->setAutoFillBackground(false);
- canvas->setViewport(glWidget);
- }
-#endif
-}
-
-void QmlViewer::setUseNativeFileBrowser(bool use)
-{
- useQmlFileBrowser = !use;
-}
-
-QT_END_NAMESPACE
-
-#include "qmlviewer.moc"
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
deleted file mode 100644
index c7f87ed060..0000000000
--- a/tools/qmlviewer/qmlviewer.h
+++ /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 tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt 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 QMLVIEWER_H
-#define QMLVIEWER_H
-
-#include <QMainWindow>
-#include <QMenuBar>
-#include <private/qmltimer_p.h>
-#include <QTime>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-
-class QmlView;
-class PreviewDeviceSkin;
-class QmlGraphicsTestEngine;
-class QProcess;
-class RecordingDialog;
-class QmlGraphicsTester;
-class QNetworkReply;
-class QNetworkCookieJar;
-class NetworkAccessManagerFactory;
-
-class QmlViewer
-#if defined(Q_OS_SYMBIAN)
- : public QMainWindow
-#else
- : public QWidget
-#endif
-{
-Q_OBJECT
-public:
- QmlViewer(QWidget *parent=0, Qt::WindowFlags flags=0);
- ~QmlViewer();
-
- enum ScriptOption {
- Play = 0x00000001,
- Record = 0x00000002,
- TestImages = 0x00000004,
- TestErrorProperty = 0x00000008,
- SaveOnExit = 0x00000010,
- ExitOnComplete = 0x00000020,
- ExitOnFailure = 0x00000040
- };
- Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
- void setScript(const QString &s) { m_script = s; }
- void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; }
- void setRecordDither(const QString& s) { record_dither = s; }
- void setRecordRate(int fps);
- void setRecordFile(const QString&);
- void setRecordArgs(const QStringList&);
- void setRecording(bool on);
- bool isRecording() const { return recordTimer.isRunning(); }
- void setAutoRecord(int from, int to);
- void setDeviceKeys(bool);
- void setNetworkCacheSize(int size);
- void addLibraryPath(const QString& lib);
- void setUseGL(bool use);
- void setUseNativeFileBrowser(bool);
-
- QStringList builtinSkins() const;
-
- QMenuBar *menuBar() const;
-
-public slots:
- void sceneResized(QSize size);
- void open(const QString&);
- void openWgt(const QString&);
- void openQml(const QString&);
- void openFile();
- void reload();
- void takeSnapShot();
- void toggleRecording();
- void toggleRecordingWithSelection();
- void ffmpegFinished(int code);
- void setSkin(const QString& skinDirectory);
- void showProxySettings ();
- void proxySettingsChanged ();
- void setScaleView();
- void statusChanged();
- void setSlowMode(bool);
- void launch(const QString &);
-
-protected:
- virtual void keyPressEvent(QKeyEvent *);
-
- void createMenu(QMenuBar *menu, QMenu *flatmenu);
-
-private slots:
- void autoStartRecording();
- void autoStopRecording();
- void recordFrame();
- void chooseRecordingOptions();
- void pickRecordingFile();
- void setScaleSkin();
- void setPortrait();
- void setLandscape();
- void toggleOrientation();
- void startNetwork();
- void toggleFullScreen();
- void unpackWgt();
-
-private:
- QString getVideoFileName();
-
- PreviewDeviceSkin *skin;
- QSize skinscreensize;
- QmlView *canvas;
- QString currentFileOrUrl;
- QmlTimer recordTimer;
- QString frame_fmt;
- QImage frame;
- QList<QImage*> frames;
- QProcess* frame_stream;
- QmlTimer autoStartTimer;
- QmlTimer autoStopTimer;
- QString record_dither;
- QString record_file;
- QSize record_outsize;
- QStringList record_args;
- int record_rate;
- int record_autotime;
- bool devicemode;
- QAction *recordAction;
- QString currentSkin;
- bool scaleSkin;
- mutable QMenuBar *mb;
- RecordingDialog *recdlg;
-
- void senseImageMagick();
- void senseFfmpeg();
- QWidget *ffmpegHelpWindow;
- bool ffmpegAvailable;
- bool convertAvailable;
-
- QAction *portraitOrientation;
- QAction *landscapeOrientation;
-
- QString m_script;
- ScriptOptions m_scriptOptions;
- QmlGraphicsTester *tester;
-
- QNetworkReply *wgtreply;
- QString wgtdir;
-
- NetworkAccessManagerFactory *namFactory;
-
- bool useQmlFileBrowser;
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QmlViewer::ScriptOptions)
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro
deleted file mode 100644
index aba3cf5de4..0000000000
--- a/tools/qmlviewer/qmlviewer.pro
+++ /dev/null
@@ -1,58 +0,0 @@
-TEMPLATE = app
-CONFIG += qt \
- uic
-DESTDIR = ../../bin
-QT += declarative \
- script \
- network \
- sql
-
-contains(QT_CONFIG, opengl) {
- QT += opengl
- DEFINES += GL_SUPPORTED
-}
-
-# Input
-HEADERS += qmlviewer.h \
- proxysettings.h \
- qfxtester.h \
- deviceorientation.h \
- qmlfolderlistmodel.h
-SOURCES += main.cpp \
- qmlviewer.cpp \
- proxysettings.cpp \
- qfxtester.cpp \
- qmlfolderlistmodel.cpp
-RESOURCES = qmlviewer.qrc
-maemo5 {
- SOURCES += deviceorientation_maemo.cpp
-} else {
- SOURCES += deviceorientation.cpp
-}
-FORMS = recopts.ui \
- proxysettings.ui
-INCLUDEPATH += ../../include/QtDeclarative
-INCLUDEPATH += ../../src/declarative/util
-INCLUDEPATH += ../../src/declarative/graphicsitems
-include(../shared/deviceskin/deviceskin.pri)
-target.path = $$[QT_INSTALL_BINS]
-INSTALLS += target
-
-wince* {
-QT += scripttools \
- xml \
- xmlpatterns \
- phonon
-
- contains(QT_CONFIG, webkit) {
- QT += webkit
- }
-}
-symbian {
-# TARGET.UID3 =
- include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
- TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
- HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h
- LIBS += -lesock -lconnmon -linsock
- TARGET.CAPABILITY = NetworkServices
-}
diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro
index 5cd52cf2bb..6b6b02aa97 100644
--- a/tools/qtestlib/wince/cetest/cetest.pro
+++ b/tools/qtestlib/wince/cetest/cetest.pro
@@ -18,7 +18,7 @@ DEFINES += QT_BUILD_QMAKE QT_BOOTSTRAPPED QT_NO_CODECS QT_LITE_UNICODE QT
INCLUDEPATH = \
$$QT_SOURCE_TREE/tools/qtestlib/ce/cetest \
$$QT_SOURCE_TREE/qmake \
- $$QT_SOURCE_TREE/qmake/generators/symbian \
+ $$QT_SOURCE_TREE/tools/shared \
$$QT_BUILD_TREE/include \
$$QT_BUILD_TREE/include/QtCore \
$$QT_BUILD_TREE/src/corelib/global
diff --git a/tools/qtestlib/wince/cetest/qmake_include.pri b/tools/qtestlib/wince/cetest/qmake_include.pri
index aa3265356d..8b415b0bb4 100644
--- a/tools/qtestlib/wince/cetest/qmake_include.pri
+++ b/tools/qtestlib/wince/cetest/qmake_include.pri
@@ -5,5 +5,7 @@ SOURCES += \
$$QT_SOURCE_TREE/qmake/option.cpp \
$$QT_SOURCE_TREE/qmake/project.cpp \
$$QT_SOURCE_TREE/qmake/property.cpp \
- $$QT_SOURCE_TREE/qmake/generators/symbian/initprojectdeploy_symbian.cpp
+ $$QT_SOURCE_TREE/qmake/generators/symbian/initprojectdeploy_symbian.cpp \
+ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \
+ $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp
diff --git a/tools/tools.pro b/tools/tools.pro
index d5569b6ab4..3ed07b1683 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -26,7 +26,7 @@ mac {
embedded:SUBDIRS += kmap2qmap
-contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer
+contains(QT_CONFIG, declarative):SUBDIRS += qml
contains(QT_CONFIG, dbus):SUBDIRS += qdbus
!wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator
embedded: SUBDIRS += makeqpf
diff --git a/translations/assistant_de.ts b/translations/assistant_de.ts
index b020003568..0a0d37f5a9 100644
--- a/translations/assistant_de.ts
+++ b/translations/assistant_de.ts
@@ -4,7 +4,7 @@
<context>
<name>AboutDialog</name>
<message>
- <location filename="../tools/assistant/tools/assistant/aboutdialog.cpp" line="+110"/>
+ <location filename="../tools/assistant/tools/assistant/aboutdialog.cpp" line="+117"/>
<source>&amp;Close</source>
<translation>&amp;Schließen</translation>
</message>
@@ -12,7 +12,7 @@
<context>
<name>AboutLabel</name>
<message>
- <location line="-14"/>
+ <location line="-15"/>
<source>Warning</source>
<translation>Achtung</translation>
</message>
@@ -24,12 +24,79 @@
</translation>
</message>
<message>
- <location line="+1"/>
+ <location line="+0"/>
<source>OK</source>
<translation>OK</translation>
</message>
</context>
<context>
+ <name>Assistant</name>
+ <message>
+ <location filename="../tools/assistant/tools/assistant/main.cpp" line="+177"/>
+ <source>Error registering documentation file &apos;%1&apos;: %2</source>
+ <translation>Beim Registrieren der Dokumentationsdatei &apos;%1&apos; trat ein Fehler auf: %2</translation>
+ </message>
+ <message>
+ <location line="+39"/>
+ <source>Error: %1</source>
+ <translation>Fehler: %1</translation>
+ </message>
+ <message>
+ <location line="+42"/>
+ <source>Could not register documentation file
+%1
+
+Reason:
+%2</source>
+ <translation>Dokumentationsdatei %1 kann nicht registriert werden
+
+Grund:
+%2</translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Documentation successfully registered.</source>
+ <translation>Dokumentation erfolgreich registriert.</translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>Could not unregister documentation file
+%1
+
+Reason:
+%2</source>
+ <translation>Registrierung der Dokumentationsdatei %1 kann nicht aufgehoben werden
+
+Grund:
+%2</translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Documentation successfully unregistered.</source>
+ <translation>Dokumentation erfolgreich entfernt.</translation>
+ </message>
+ <message>
+ <location line="+55"/>
+ <source>Error reading collection file &apos;%1&apos;: %2.</source>
+ <translation>Fehler beim Lesen der Katalogdatei &apos;%1&apos;: %2</translation>
+ </message>
+ <message>
+ <location line="+11"/>
+ <source>Error creating collection file &apos;%1&apos;: %2.</source>
+ <translation>Fehler beim Erstellen der Katalogdatei &apos;%1&apos;: %2.</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Error reading collection file &apos;%1&apos;: %2</source>
+ <translation>Fehler beim Lesen der Katalogdatei &apos;%1&apos;: %2</translation>
+ </message>
+ <message>
+ <location line="+53"/>
+ <source>Cannot load sqlite database driver!</source>
+ <translation>Der Datenbanktreiber für SQLite kann nicht geladen werden.</translation>
+ </message>
+</context>
+<context>
<name>BookmarkDialog</name>
<message>
<location filename="../tools/assistant/tools/assistant/bookmarkdialog.ui"/>
@@ -52,39 +119,20 @@
<translation>Neuer Ordner</translation>
</message>
<message>
- <location filename="../tools/assistant/tools/assistant/bookmarkmanager.cpp" line="+184"/>
- <location line="+18"/>
- <location line="+39"/>
- <location line="+18"/>
- <location line="+30"/>
- <source>Bookmarks</source>
- <translation>Lesezeichen</translation>
- </message>
- <message>
- <location filename="../tools/assistant/tools/assistant/bookmarkdialog.ui"/>
+ <location/>
<source>+</source>
<translation>+</translation>
</message>
- <message>
- <location filename="../tools/assistant/tools/assistant/bookmarkmanager.cpp" line="-61"/>
- <source>Delete Folder</source>
- <translation>Ordner löschen</translation>
- </message>
- <message>
- <location line="+1"/>
- <source>Rename Folder</source>
- <translation>Ordner umbenennen</translation>
- </message>
</context>
<context>
<name>BookmarkManager</name>
<message>
- <location line="+435"/>
- <source>Bookmarks</source>
- <translation>Lesezeichen</translation>
+ <location filename="../tools/assistant/tools/assistant/bookmarkmanager.cpp" line="+151"/>
+ <source>Untitled</source>
+ <translation>Ohne Titel</translation>
</message>
<message>
- <location line="+37"/>
+ <location line="+65"/>
<source>Remove</source>
<translation>Entfernen</translation>
</message>
@@ -94,26 +142,22 @@
<translation>Wenn Sie diesen Ordner löschen, wird auch&lt;br&gt;dessen kompletter Inhalt gelöscht. Möchten Sie wirklich fortfahren?</translation>
</message>
<message>
- <location line="+143"/>
- <location line="+9"/>
- <source>New Folder</source>
- <translation>Neuer Ordner</translation>
+ <location line="+147"/>
+ <source>Manage Bookmarks...</source>
+ <translation>Lesezeichen verwalten...</translation>
</message>
-</context>
-<context>
- <name>BookmarkWidget</name>
<message>
- <location line="-417"/>
- <source>Filter:</source>
- <translation>Filter:</translation>
+ <location line="+2"/>
+ <source>Add Bookmark...</source>
+ <translation>Lesezeichen hinzufügen ...</translation>
</message>
<message>
- <location line="+33"/>
- <source>Remove</source>
- <translation>Entfernen</translation>
+ <location line="+1"/>
+ <source>Ctrl+D</source>
+ <translation>Ctrl+D</translation>
</message>
<message>
- <location line="-79"/>
+ <location line="+68"/>
<source>Delete Folder</source>
<translation>Ordner löschen</translation>
</message>
@@ -133,7 +177,7 @@
<translation>Lesezeichen in neuem Reiter öffnen</translation>
</message>
<message>
- <location line="+3"/>
+ <location line="+2"/>
<source>Delete Bookmark</source>
<translation>Lesezeichen löschen</translation>
</message>
@@ -142,16 +186,11 @@
<source>Rename Bookmark</source>
<translation>Lesezeichen umbenennen</translation>
</message>
- <message>
- <location line="+62"/>
- <source>Add</source>
- <translation>Hinzufügen</translation>
- </message>
</context>
<context>
<name>CentralWidget</name>
<message>
- <location filename="../tools/assistant/tools/assistant/centralwidget.cpp" line="+239"/>
+ <location filename="../tools/assistant/tools/assistant/centralwidget.cpp" line="+117"/>
<source>Add new page</source>
<translation>Neue Seite hinzufügen</translation>
</message>
@@ -161,18 +200,18 @@
<translation>Aktuelle Seite schließen</translation>
</message>
<message>
- <location line="+312"/>
+ <location line="+287"/>
<source>Print Document</source>
<translation>Drucken</translation>
</message>
<message>
- <location line="+130"/>
+ <location line="+126"/>
<location line="+2"/>
<source>unknown</source>
<translation>unbekannt</translation>
</message>
<message>
- <location line="+93"/>
+ <location line="+100"/>
<source>Add New Page</source>
<translation>Neue Seite hinzufügen</translation>
</message>
@@ -192,15 +231,78 @@
<translation>Lesezeichen für diese Seite hinzufügen ...</translation>
</message>
<message>
- <location line="+235"/>
+ <location line="+264"/>
<source>Search</source>
<translation>Suchen</translation>
</message>
</context>
<context>
+ <name>CmdLineParser</name>
+ <message>
+ <location filename="../tools/assistant/tools/assistant/cmdlineparser.cpp" line="+137"/>
+ <source>Unknown option: %1</source>
+ <translation>Unbekannte Option: %1</translation>
+ </message>
+ <message>
+ <location line="+87"/>
+ <source>Unknown widget: %1</source>
+ <translation>Unbekanntes Widget-Objekt: %1</translation>
+ </message>
+ <message>
+ <location line="-54"/>
+ <source>The collection file &apos;%1&apos; does not exist.</source>
+ <translation>Die Katalogdatei &apos;%1&apos; existiert nicht.</translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Missing collection file.</source>
+ <translation>Fehlende Katalogdatei.</translation>
+ </message>
+ <message>
+ <location line="+13"/>
+ <source>Invalid URL &apos;%1&apos;.</source>
+ <translation>Ungültige URL &apos;%1&apos;.</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <source>Missing URL.</source>
+ <translation>Fehlende URL.</translation>
+ </message>
+ <message>
+ <location line="+38"/>
+ <source>Missing widget.</source>
+ <translation>Fehlendes Widget-Objekt.</translation>
+ </message>
+ <message>
+ <location line="+23"/>
+ <source>The Qt help file &apos;%1&apos; does not exist.</source>
+ <translation>Die Hilfedatei &apos;%1&apos; existiert nicht.</translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>Missing help file.</source>
+ <translation>Fehlende Hilfedatei.</translation>
+ </message>
+ <message>
+ <location line="+10"/>
+ <source>Missing filter argument.</source>
+ <translation>Das Filter-Argument fehlt.</translation>
+ </message>
+ <message>
+ <location line="+20"/>
+ <source>Error</source>
+ <translation>Fehler</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <source>Notice</source>
+ <translation>Hinweis</translation>
+ </message>
+</context>
+<context>
<name>ContentWindow</name>
<message>
- <location filename="../tools/assistant/tools/assistant/contentwindow.cpp" line="+158"/>
+ <location filename="../tools/assistant/tools/assistant/contentwindow.cpp" line="+171"/>
<source>Open Link</source>
<translation>Link öffnen</translation>
</message>
@@ -224,34 +326,6 @@
</message>
</context>
<context>
- <name>FindWidget</name>
- <message>
- <location filename="../tools/assistant/tools/assistant/centralwidget.cpp" line="-918"/>
- <source>Previous</source>
- <translation>Zurück</translation>
- </message>
- <message>
- <location line="+4"/>
- <source>Next</source>
- <translation>Weiter</translation>
- </message>
- <message>
- <location line="+4"/>
- <source>Case Sensitive</source>
- <translation>Groß-/Kleinschreibung beachten</translation>
- </message>
- <message>
- <location line="+3"/>
- <source>Whole words</source>
- <translation>Ganze Wörter</translation>
- </message>
- <message>
- <location line="+12"/>
- <source>&lt;img src=&quot;:/trolltech/assistant/images/wrap.png&quot;&gt;&amp;nbsp;Search wrapped</source>
- <translation>&lt;img src=&quot;:/trolltech/assistant/images/wrap.png&quot;&gt;&amp;nbsp;Seitenende</translation>
- </message>
-</context>
-<context>
<name>FontPanel</name>
<message>
<location filename="../tools/shared/fontpanel/fontpanel.cpp" line="+63"/>
@@ -282,52 +356,25 @@
<context>
<name>HelpViewer</name>
<message>
- <location filename="../tools/assistant/tools/assistant/helpviewer.cpp" line="+489"/>
- <source>Help</source>
- <translation>Hilfe</translation>
- </message>
- <message>
- <location line="+1"/>
- <source>OK</source>
- <translation>OK</translation>
+ <location filename="../tools/assistant/tools/assistant/helpviewer.cpp" line="+56"/>
+ <source>&lt;title&gt;about:blank&lt;/title&gt;</source>
+ <translation>&lt;title&gt;about:blank&lt;/title&gt;</translation>
</message>
<message>
- <location line="-62"/>
+ <location line="+6"/>
<source>&lt;title&gt;Error 404...&lt;/title&gt;&lt;div align=&quot;center&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;h1&gt;The page could not be found&lt;/h1&gt;&lt;br&gt;&lt;h3&gt;&apos;%1&apos;&lt;/h3&gt;&lt;/div&gt;</source>
<translation>&lt;title&gt;Fehler 404 ...&lt;/title&gt;&lt;div align=&quot;center&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;h1&gt;Die Seite kann nicht gefunden werden.&lt;/h1&gt;&lt;br&gt;&lt;h3&gt;&apos;%1&apos;&lt;/h3&gt;&lt;/div&gt;</translation>
</message>
- <message>
- <location line="+125"/>
- <source>Copy &amp;Link Location</source>
- <translation>&amp;Link-Adresse kopieren</translation>
- </message>
- <message>
- <location line="+3"/>
- <source>Open Link in New Tab Ctrl+LMB</source>
- <translation>Link in neuem Reiter öffnen </translation>
- </message>
- <message>
- <location line="-275"/>
- <source>Open Link in New Tab</source>
- <translation>Link in neuem Reiter öffnen</translation>
- </message>
- <message>
- <location line="+209"/>
- <source>Unable to launch external application.
-</source>
- <translation>Fehler beim Starten der externen Anwendung.
-</translation>
- </message>
</context>
<context>
<name>IndexWindow</name>
<message>
- <location filename="../tools/assistant/tools/assistant/indexwindow.cpp" line="+66"/>
+ <location filename="../tools/assistant/tools/assistant/indexwindow.cpp" line="+68"/>
<source>&amp;Look for:</source>
<translation>Suchen &amp;nach:</translation>
</message>
<message>
- <location line="+68"/>
+ <location line="+74"/>
<source>Open Link</source>
<translation>Link öffnen</translation>
</message>
@@ -341,29 +388,29 @@
<name>InstallDialog</name>
<message>
<location filename="../tools/assistant/tools/assistant/installdialog.ui"/>
- <location filename="../tools/assistant/tools/assistant/installdialog.cpp" line="+76"/>
+ <location filename="../tools/assistant/tools/assistant/installdialog.cpp" line="+78"/>
<source>Install Documentation</source>
<translation>Dokumentation installieren</translation>
</message>
<message>
- <location filename="../tools/assistant/tools/assistant/installdialog.cpp" line="+30"/>
+ <location filename="../tools/assistant/tools/assistant/installdialog.cpp" line="+33"/>
<source>Downloading documentation info...</source>
<translation>Dokumentationsinformation herunterladen ...</translation>
</message>
<message>
- <location line="+48"/>
+ <location line="+51"/>
<source>Download canceled.</source>
<translation>Herunterladen abgebrochen.</translation>
</message>
<message>
- <location line="+26"/>
- <location line="+78"/>
+ <location line="+28"/>
+ <location line="+79"/>
<location line="+27"/>
<source>Done.</source>
<translation>Fertig.</translation>
</message>
<message>
- <location line="-90"/>
+ <location line="-91"/>
<source>The file %1 already exists. Do you want to overwrite it?</source>
<translation>Die Datei %1 existiert bereits. Möchten Sie sie überschreiben?</translation>
</message>
@@ -378,14 +425,14 @@
<translation>Herunterladen der Datei %1 ...</translation>
</message>
<message>
- <location line="+19"/>
+ <location line="+20"/>
<location line="+42"/>
- <location line="+38"/>
+ <location line="+40"/>
<source>Download failed: %1.</source>
<translation>Herunterladen fehlgeschlagen: %1.</translation>
</message>
<message>
- <location line="-70"/>
+ <location line="-72"/>
<source>Documentation info file is corrupt!</source>
<translation>Die Dokumentationsdatei ist beschädigt.</translation>
</message>
@@ -400,7 +447,7 @@
<translation>Dokumentation %1 installieren ...</translation>
</message>
<message>
- <location line="+22"/>
+ <location line="+23"/>
<source>Error while installing documentation:
%1</source>
<translation>Fehler bei der Installation von:
@@ -440,20 +487,20 @@
<context>
<name>MainWindow</name>
<message>
- <location filename="../tools/assistant/tools/assistant/mainwindow.cpp" line="+110"/>
- <location line="+383"/>
+ <location filename="../tools/assistant/tools/assistant/mainwindow.cpp" line="+123"/>
+ <location line="+366"/>
<source>Index</source>
<translation>Index</translation>
</message>
<message>
- <location line="-377"/>
- <location line="+375"/>
+ <location line="-360"/>
+ <location line="+358"/>
<source>Contents</source>
<translation>Inhalt</translation>
</message>
<message>
- <location line="-370"/>
- <location line="+374"/>
+ <location line="-351"/>
+ <location line="+355"/>
<source>Bookmarks</source>
<translation>Lesezeichen</translation>
</message>
@@ -463,20 +510,14 @@
<translation>Suchen</translation>
</message>
<message>
- <location line="-364"/>
- <location line="+207"/>
- <location line="+514"/>
+ <location line="-335"/>
+ <location line="+672"/>
+ <location line="+284"/>
<source>Qt Assistant</source>
<translation>Qt Assistant</translation>
</message>
<message>
- <location line="-546"/>
- <location line="+5"/>
- <source>Unfiltered</source>
- <translation>Ohne Filter</translation>
- </message>
- <message>
- <location line="+107"/>
+ <location line="-702"/>
<source>Page Set&amp;up...</source>
<translation>S&amp;eite einrichten ...</translation>
</message>
@@ -506,7 +547,12 @@
<translation>&amp;Beenden</translation>
</message>
<message>
- <location line="+5"/>
+ <location line="+3"/>
+ <source>CTRL+Q</source>
+ <translation>CTRL+Q</translation>
+ </message>
+ <message>
+ <location line="+6"/>
<source>&amp;Copy selected Text</source>
<translation>Ausgewählten Text &amp;kopieren</translation>
</message>
@@ -616,12 +662,12 @@
<translation>Ctrl+Alt+Left</translation>
</message>
<message>
- <location line="+4"/>
- <source>Add Bookmark...</source>
- <translation>Lesezeichen hinzufügen ...</translation>
+ <location line="+591"/>
+ <source>Could not register file &apos;%1&apos;: %2</source>
+ <translation>Die Datei &apos;%1&apos; konnte nicht registriert werden: %2</translation>
</message>
<message>
- <location line="+5"/>
+ <location line="-584"/>
<source>About...</source>
<translation>Über ...</translation>
</message>
@@ -631,12 +677,12 @@
<translation>Navigationsleiste</translation>
</message>
<message>
- <location line="+76"/>
+ <location line="+69"/>
<source>Toolbars</source>
<translation>Werkzeugleisten</translation>
</message>
<message>
- <location line="+15"/>
+ <location line="+16"/>
<source>Filter Toolbar</source>
<translation>Filterleiste</translation>
</message>
@@ -646,7 +692,7 @@
<translation>Filter:</translation>
</message>
<message>
- <location line="+25"/>
+ <location line="+26"/>
<source>Address Toolbar</source>
<translation>Adressleiste</translation>
</message>
@@ -656,27 +702,27 @@
<translation>Adresse:</translation>
</message>
<message>
- <location line="+114"/>
+ <location line="+112"/>
<source>Could not find the associated content item.</source>
<translation>Der zugehörige Inhaltseintrag konnte nicht gefunden werden.</translation>
</message>
<message>
- <location line="+71"/>
+ <location line="+60"/>
<source>About %1</source>
<translation>Über %1</translation>
</message>
<message>
- <location line="+114"/>
+ <location line="+175"/>
<source>Updating search index</source>
<translation>Suchindex wird aufgebaut</translation>
</message>
<message>
- <location line="-640"/>
+ <location line="-661"/>
<source>Looking for Qt Documentation...</source>
<translation>Suche nach Qt-Dokumentation ...</translation>
</message>
<message>
- <location line="+241"/>
+ <location line="+219"/>
<source>&amp;Window</source>
<translation>&amp;Fenster</translation>
</message>
@@ -696,12 +742,12 @@
<translation>Zoom</translation>
</message>
<message>
- <location line="-159"/>
+ <location line="-161"/>
<source>&amp;File</source>
<translation>&amp;Datei</translation>
</message>
<message>
- <location line="+25"/>
+ <location line="+29"/>
<source>&amp;Edit</source>
<translation>&amp;Bearbeiten</translation>
</message>
@@ -721,41 +767,36 @@
<translation>ALT+Home</translation>
</message>
<message>
- <location line="+29"/>
+ <location line="+30"/>
<source>&amp;Bookmarks</source>
<translation>&amp;Lesezeichen</translation>
</message>
<message>
- <location line="+5"/>
+ <location line="+2"/>
<source>&amp;Help</source>
<translation>&amp;Hilfe</translation>
</message>
<message>
- <location line="-40"/>
+ <location line="-38"/>
<source>ALT+O</source>
<translation>ALT+O</translation>
</message>
- <message>
- <location line="+38"/>
- <source>CTRL+D</source>
- <translation>CTRL+D</translation>
- </message>
</context>
<context>
<name>PreferencesDialog</name>
<message>
- <location filename="../tools/assistant/tools/assistant/preferencesdialog.cpp" line="+259"/>
- <location line="+43"/>
+ <location filename="../tools/assistant/tools/assistant/preferencesdialog.cpp" line="+252"/>
+ <location line="+44"/>
<source>Add Documentation</source>
<translation>Dokumentation hinzufügen</translation>
</message>
<message>
- <location line="-43"/>
+ <location line="-44"/>
<source>Qt Compressed Help Files (*.qch)</source>
<translation>Komprimierte Hilfedateien (*.qch)</translation>
</message>
<message>
- <location line="+37"/>
+ <location line="+38"/>
<source>The specified file is not a valid Qt Help File!</source>
<translation>Die angegebene Datei ist keine Qt-Hilfedatei.</translation>
</message>
@@ -765,7 +806,7 @@
<translation>Der Namespace %1 ist bereits registriert.</translation>
</message>
<message>
- <location line="+31"/>
+ <location line="+32"/>
<source>Remove Documentation</source>
<translation>Dokumentation entfernen</translation>
</message>
@@ -785,7 +826,7 @@
<translation>OK</translation>
</message>
<message>
- <location line="+88"/>
+ <location line="+83"/>
<source>Use custom settings</source>
<translation>Benutzerdefinierte Einstellungen verwenden</translation>
</message>
@@ -909,118 +950,9 @@
</message>
</context>
<context>
- <name>QObject</name>
- <message>
- <location filename="../tools/assistant/tools/assistant/cmdlineparser.cpp" line="+112"/>
- <source>The specified collection file does not exist!</source>
- <translation>Die angegebene Katalogdatei (collection file) kann nicht gefunden werden.</translation>
- </message>
- <message>
- <location line="+4"/>
- <source>Missing collection file!</source>
- <translation>Fehlende Katalogdatei.</translation>
- </message>
- <message>
- <location line="+9"/>
- <source>Invalid URL!</source>
- <translation>Ungültige URL.</translation>
- </message>
- <message>
- <location line="+4"/>
- <source>Missing URL!</source>
- <translation>Fehlende URL.</translation>
- </message>
- <message>
- <location line="+17"/>
- <location line="+19"/>
- <location line="+19"/>
- <source>Unknown widget: %1</source>
- <translation>Unbekanntes Objekt: %1</translation>
- </message>
- <message>
- <location line="-34"/>
- <location line="+19"/>
- <location line="+19"/>
- <source>Missing widget!</source>
- <translation>Fehlendes Objekt.</translation>
- </message>
- <message>
- <location line="+7"/>
- <location line="+12"/>
- <source>The specified Qt help file does not exist!</source>
- <translation>Die angegebene Hilfedatei kann nicht gefunden werden.</translation>
- </message>
- <message>
- <location line="-7"/>
- <location line="+12"/>
- <source>Missing help file!</source>
- <translation>Fehlende Hilfedatei.</translation>
- </message>
- <message>
- <location line="+7"/>
- <source>Missing filter argument!</source>
- <translation>Das Filter-Argument fehlt.</translation>
- </message>
- <message>
- <location line="+12"/>
- <source>Unknown option: %1</source>
- <translation>Unbekannte Option: %1</translation>
- </message>
- <message>
- <location line="+30"/>
- <location line="+2"/>
- <source>Qt Assistant</source>
- <translation>Qt Assistant</translation>
- </message>
- <message>
- <location filename="../tools/assistant/tools/assistant/main.cpp" line="+225"/>
- <source>Could not register documentation file
-%1
-
-Reason:
-%2</source>
- <translation>Dokumentationsdatei %1 kann nicht registriert werden
-
-Grund:
-%2</translation>
- </message>
- <message>
- <location line="+4"/>
- <source>Documentation successfully registered.</source>
- <translation>Dokumentation erfolgreich registriert.</translation>
- </message>
- <message>
- <location line="+11"/>
- <source>Could not unregister documentation file
-%1
-
-Reason:
-%2</source>
- <translation>Registrierung der Dokumentationsdatei %1 kann nicht aufgehoben werden
-
-Grund:
-%2</translation>
- </message>
- <message>
- <location line="-3"/>
- <source>Documentation successfully unregistered.</source>
- <translation>Dokumentation erfolgreich entfernt.</translation>
- </message>
- <message>
- <location line="+40"/>
- <source>Cannot load sqlite database driver!</source>
- <translation>Der Datenbanktreiber für SQLite kann nicht geladen werden.</translation>
- </message>
- <message>
- <location line="+9"/>
- <source>The specified collection file could not be read!</source>
- <translation>Die angegebene Katalogdatei (collection file) kann nicht gelesen werden.</translation>
- </message>
-</context>
-<context>
<name>RemoteControl</name>
<message>
- <location filename="../tools/assistant/tools/assistant/remotecontrol.cpp" line="+163"/>
+ <location filename="../tools/assistant/tools/assistant/remotecontrol.cpp" line="+165"/>
<source>Debugging Remote Control</source>
<translation>Debugging Remote Control</translation>
</message>
@@ -1033,7 +965,7 @@ Grund:
<context>
<name>SearchWidget</name>
<message>
- <location filename="../tools/assistant/tools/assistant/searchwidget.cpp" line="+196"/>
+ <location filename="../tools/assistant/tools/assistant/searchwidget.cpp" line="+210"/>
<source>&amp;Copy</source>
<translation>&amp;Kopieren</translation>
</message>
@@ -1056,7 +988,7 @@ Grund:
<context>
<name>TopicChooser</name>
<message>
- <location filename="../tools/assistant/tools/assistant/topicchooser.cpp" line="+54"/>
+ <location filename="../tools/assistant/tools/assistant/topicchooser.cpp" line="+53"/>
<source>Choose a topic for &lt;b&gt;%1&lt;/b&gt;:</source>
<translation>Wählen Sie ein Thema für &lt;b&gt;%1&lt;/b&gt;:</translation>
</message>
diff --git a/translations/designer_de.ts b/translations/designer_de.ts
index 8c1ba68335..475a5d542f 100644
--- a/translations/designer_de.ts
+++ b/translations/designer_de.ts
@@ -506,7 +506,7 @@
<translation>Werkzeugleiste löschen</translation>
</message>
<message>
- <location filename="../tools/designer/src/lib/shared/qdesigner_menu.cpp" line="+1195"/>
+ <location filename="../tools/designer/src/lib/shared/qdesigner_menu.cpp" line="+1194"/>
<source>Set action text</source>
<translation>Text der Aktion setzen</translation>
</message>
@@ -621,7 +621,7 @@
<translation>Skript ändern</translation>
</message>
<message>
- <location filename="../tools/designer/src/lib/shared/qdesigner_propertycommand.cpp" line="+1213"/>
+ <location filename="../tools/designer/src/lib/shared/qdesigner_propertycommand.cpp" line="+1225"/>
<source>Changed &apos;%1&apos; of &apos;%2&apos;</source>
<translation>&apos;%1&apos; von &apos;%2&apos; geändert</translation>
</message>
@@ -635,7 +635,7 @@
</translation>
</message>
<message>
- <location line="+76"/>
+ <location line="+84"/>
<source>Reset &apos;%1&apos; of &apos;%2&apos;</source>
<translation>&apos;%1&apos; von &apos;%2&apos; zurücksetzen</translation>
</message>
@@ -1109,7 +1109,7 @@
<context>
<name>FormWindow</name>
<message>
- <location filename="../tools/designer/src/components/formeditor/formwindow.cpp" line="+1701"/>
+ <location filename="../tools/designer/src/components/formeditor/formwindow.cpp" line="+1754"/>
<source>Unexpected element &lt;%1&gt;</source>
<translation>Ungültiges Element &lt;%1&gt;</translation>
</message>
@@ -1985,7 +1985,7 @@ Möchten Sie es noch einmal versuchen?</translation>
<context>
<name>QDesignerMenu</name>
<message>
- <location filename="../tools/designer/src/lib/shared/qdesigner_menu.cpp" line="-1181"/>
+ <location filename="../tools/designer/src/lib/shared/qdesigner_menu.cpp" line="-1179"/>
<source>Type Here</source>
<translation>Geben Sie Text ein</translation>
</message>
@@ -2011,7 +2011,7 @@ Möchten Sie es noch einmal versuchen?</translation>
</message>
<message>
<location line="+27"/>
- <location line="+650"/>
+ <location line="+648"/>
<source>Add separator</source>
<translation>Trenner hinzufügen</translation>
</message>
@@ -2085,7 +2085,7 @@ Möchten Sie es noch einmal versuchen?</translation>
<context>
<name>QDesignerPropertySheet</name>
<message>
- <location filename="../tools/designer/src/lib/shared/qdesigner_propertysheet.cpp" line="+754"/>
+ <location filename="../tools/designer/src/lib/shared/qdesigner_propertysheet.cpp" line="+755"/>
<source>Dynamic Properties</source>
<translation>Dynamische Eigenschaften</translation>
</message>
@@ -2456,7 +2456,7 @@ Container-Seiten sollten ausschließlich im XML der domXML()-Methode spezifizier
<context>
<name>QtBoolEdit</name>
<message>
- <location filename="../tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp" line="+247"/>
+ <location filename="../tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp" line="+255"/>
<location line="+10"/>
<location line="+25"/>
<source>True</source>
@@ -2472,7 +2472,7 @@ Container-Seiten sollten ausschließlich im XML der domXML()-Methode spezifizier
<context>
<name>QtBoolPropertyManager</name>
<message>
- <location filename="../tools/shared/qtpropertybrowser/qtpropertymanager.cpp" line="+1469"/>
+ <location filename="../tools/shared/qtpropertybrowser/qtpropertymanager.cpp" line="+1507"/>
<source>True</source>
<translation>Wahr</translation>
</message>
@@ -2501,7 +2501,7 @@ Container-Seiten sollten ausschließlich im XML der domXML()-Methode spezifizier
<context>
<name>QtColorPropertyManager</name>
<message>
- <location filename="../tools/shared/qtpropertybrowser/qtpropertymanager.cpp" line="+4750"/>
+ <location filename="../tools/shared/qtpropertybrowser/qtpropertymanager.cpp" line="+4718"/>
<source>Red</source>
<translation>Rot</translation>
</message>
@@ -2524,7 +2524,7 @@ Container-Seiten sollten ausschließlich im XML der domXML()-Methode spezifizier
<context>
<name>QtCursorDatabase</name>
<message>
- <location filename="../tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp" line="-226"/>
+ <location filename="../tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp" line="-234"/>
<source>Arrow</source>
<translation>Pfeil</translation>
</message>
@@ -3080,7 +3080,7 @@ Container-Seiten sollten ausschließlich im XML der domXML()-Methode spezifizier
<context>
<name>QtKeySequenceEdit</name>
<message>
- <location filename="../tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp" line="+241"/>
+ <location filename="../tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp" line="+249"/>
<source>Clear Shortcut</source>
<translation>Tastenkürzel löschen</translation>
</message>
@@ -3522,7 +3522,7 @@ Dies kann zum Beispiel eine Sprachkennung wie &quot;_de&quot; sein.</translation
<context>
<name>QtResourceViewDialog</name>
<message>
- <location line="+250"/>
+ <location line="+252"/>
<source>Select Resource</source>
<translation>Ressource auswählen</translation>
</message>
@@ -4034,7 +4034,7 @@ Möchten Sie sie überschreiben?</translation>
<context>
<name>qdesigner_internal::ActionModel</name>
<message>
- <location filename="../tools/designer/src/lib/shared/actionrepository.cpp" line="+95"/>
+ <location filename="../tools/designer/src/lib/shared/actionrepository.cpp" line="+89"/>
<source>Name</source>
<translation>Name</translation>
</message>
@@ -4727,7 +4727,7 @@ Möchten Sie sie überschreiben?</translation>
<context>
<name>qdesigner_internal::FormWindow</name>
<message>
- <location filename="../tools/designer/src/components/formeditor/formwindow.cpp" line="-1267"/>
+ <location filename="../tools/designer/src/components/formeditor/formwindow.cpp" line="-1322"/>
<source>Edit contents</source>
<translation>Ändern</translation>
</message>
@@ -4737,34 +4737,33 @@ Möchten Sie sie überschreiben?</translation>
<translation>F2</translation>
</message>
<message>
- <location line="+841"/>
+ <location line="+840"/>
<source>Resize</source>
<translation>Größe ändern</translation>
</message>
<message>
- <location line="+218"/>
- <location line="+15"/>
+ <location line="+248"/>
<source>Key Move</source>
<translation>Verschieben mittels Tastatur</translation>
</message>
<message>
- <location line="+276"/>
+ <location line="+317"/>
<source>Paste error</source>
<translation>Fehler beim Einfügen</translation>
</message>
<message>
- <location line="+450"/>
+ <location line="+448"/>
<source>Lay out</source>
<translation>Layout</translation>
</message>
<message>
- <location line="+493"/>
+ <location line="+485"/>
<location line="+55"/>
<source>Drop widget</source>
<translation>Widget einfügen</translation>
</message>
<message numerus="yes">
- <location line="-1063"/>
+ <location line="-1053"/>
<source>Paste %n action(s)</source>
<translation>
<numerusform>Eine Aktion einfügen</numerusform>
@@ -4772,12 +4771,17 @@ Möchten Sie sie überschreiben?</translation>
</translation>
</message>
<message>
- <location line="-511"/>
+ <location line="-565"/>
<source>Insert widget &apos;%1&apos;</source>
<translation>Widget &apos;%1&apos; einfügen</translation>
</message>
+ <message>
+ <location line="+313"/>
+ <source>Key Resize</source>
+ <translation>Größe ändern mittels Tastatur</translation>
+ </message>
<message numerus="yes">
- <location line="+513"/>
+ <location line="+254"/>
<source>Paste %n widget(s)</source>
<translation>
<numerusform>Widget einfügen</numerusform>
@@ -4800,17 +4804,17 @@ Möchten Sie sie überschreiben?</translation>
<translation>Bitte lösen Sie das Layout des gewünschten Containers auf und wählen Sie ihn erneut aus, um die Widgets einzufügen.</translation>
</message>
<message>
- <location line="+408"/>
+ <location line="+406"/>
<source>Select Ancestor</source>
<translation>Übergeordnetes Widget auswählen</translation>
</message>
<message>
- <location line="+581"/>
+ <location line="+573"/>
<source>A QMainWindow-based form does not contain a central widget.</source>
<translation>Ein auf QMainWindow basierendes Formular enthält kein zentrales Widget.</translation>
</message>
<message>
- <location line="-802"/>
+ <location line="-794"/>
<source>Raise widgets</source>
<translation>Widgets nach vorn bringen</translation>
</message>
diff --git a/translations/linguist_de.ts b/translations/linguist_de.ts
index 101aa5b413..14095ba72f 100644
--- a/translations/linguist_de.ts
+++ b/translations/linguist_de.ts
@@ -4,7 +4,7 @@
<context>
<name>AboutDialog</name>
<message>
- <location filename="../tools/linguist/linguist/mainwindow.cpp" line="+1358"/>
+ <location filename="../tools/linguist/linguist/mainwindow.cpp" line="+1366"/>
<source>Qt Linguist</source>
<translation>Qt Linguist</translation>
</message>
@@ -286,7 +286,7 @@ Es wird mit einer einfachen Universalform gearbeitet.</translation>
<context>
<name>FormMultiWidget</name>
<message>
- <location filename="../tools/linguist/linguist/messageeditorwidgets.cpp" line="+296"/>
+ <location filename="../tools/linguist/linguist/messageeditorwidgets.cpp" line="+302"/>
<source>Alt+Delete</source>
<extracomment>translate, but don&apos;t change</extracomment>
<translation>Alt+Delete</translation>
@@ -317,7 +317,7 @@ Es wird mit einer einfachen Universalform gearbeitet.</translation>
<context>
<name>LRelease</name>
<message numerus="yes">
- <location filename="../tools/linguist/shared/qm.cpp" line="+761"/>
+ <location filename="../tools/linguist/shared/qm.cpp" line="+763"/>
<source>Dropped %n message(s) which had no ID.</source>
<translation>
<numerusform>Es wurde ein Eintrag ohne Bezeichner gelöscht.</numerusform>
@@ -862,11 +862,6 @@ Es wird mit einer einfachen Universalform gearbeitet.</translation>
</message>
<message>
<location/>
- <source>Display information about the Qt toolkit by Trolltech.</source>
- <translation>Informationen über das Qt-Toolkit von Trolltech anzeigen.</translation>
- </message>
- <message>
- <location/>
<source>&amp;What&apos;s This?</source>
<translation>&amp;Direkthilfe</translation>
</message>
@@ -914,13 +909,13 @@ Es wird mit einer einfachen Universalform gearbeitet.</translation>
<translation>Freigeben unter ...</translation>
</message>
<message>
- <location filename="../tools/linguist/linguist/mainwindow.cpp" line="-2005"/>
+ <location filename="../tools/linguist/linguist/mainwindow.cpp" line="-2013"/>
<source></source>
<comment>This is the application&apos;s main window.</comment>
<translation></translation>
</message>
<message>
- <location line="+188"/>
+ <location line="+190"/>
<source>Source text</source>
<translation>Ursprungstext</translation>
</message>
@@ -947,12 +942,12 @@ Es wird mit einer einfachen Universalform gearbeitet.</translation>
<translation>Dieser Bereich zeigt die Kontexte an.</translation>
</message>
<message>
- <location line="+15"/>
+ <location line="+13"/>
<source>Strings</source>
<translation>Zeichenketten</translation>
</message>
<message>
- <location line="+39"/>
+ <location line="+37"/>
<source>Phrases and guesses</source>
<translation>Wörterbuch und Vorschläge</translation>
</message>
@@ -973,7 +968,7 @@ Es wird mit einer einfachen Universalform gearbeitet.</translation>
<translation>Geändert</translation>
</message>
<message>
- <location line="+130"/>
+ <location line="+139"/>
<source>Loading...</source>
<translation>Lade ...</translation>
</message>
@@ -1010,7 +1005,7 @@ Soll die erstgenannte Datei übersprungen werden?</translation>
</translation>
</message>
<message>
- <location line="+93"/>
+ <location line="+94"/>
<source>Related files (%1);;</source>
<translation>Verwandte Dateien (%1);;</translation>
</message>
@@ -1390,7 +1385,7 @@ Alle Dateien (*)</translation>
<translation>Möchten Sie das Wörterbuch &apos;%1&apos; speichern?</translation>
</message>
<message>
- <location line="+323"/>
+ <location line="+349"/>
<source>All</source>
<translation>Alle</translation>
</message>
@@ -1411,7 +1406,7 @@ Alle Dateien (*)</translation>
</message>
<message>
<location/>
- <location filename="../tools/linguist/linguist/mainwindow.cpp" line="-536"/>
+ <location filename="../tools/linguist/linguist/mainwindow.cpp" line="-562"/>
<source>Translation File &amp;Settings...</source>
<translation>E&amp;instellungen ...</translation>
</message>
@@ -1495,6 +1490,11 @@ Alle Dateien (*)</translation>
<source>Length Variants</source>
<translation>Längenvarianten</translation>
</message>
+ <message>
+ <location/>
+ <source>Display information about the Qt toolkit by Nokia.</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>MessageEditor</name>
@@ -1535,12 +1535,12 @@ Alle Dateien (*)</translation>
<translation>Chinesisch</translation>
</message>
<message>
- <location line="+53"/>
+ <location line="+47"/>
<source>This whole panel allows you to view and edit the translation of some source text.</source>
<translation>Dieser Bereich erlaubt die Darstellung und Änderung der Übersetzung eines Textes.</translation>
</message>
<message>
- <location line="+18"/>
+ <location line="+10"/>
<source>Source text</source>
<translation>Ursprungstext</translation>
</message>
@@ -1575,7 +1575,7 @@ Alle Dateien (*)</translation>
<translation>Hier können Sie Hinweise für den eigenen Gebrauch eintragen. Diese haben keinen Einflusse auf die Übersetzung.</translation>
</message>
<message>
- <location line="+232"/>
+ <location line="+234"/>
<source>%1 translation (%2)</source>
<translation>Übersetzung %1 (%2)</translation>
</message>
@@ -1605,7 +1605,7 @@ Zeile: %2</translation>
<context>
<name>MessageModel</name>
<message>
- <location filename="../tools/linguist/linguist/messagemodel.cpp" line="+832"/>
+ <location filename="../tools/linguist/linguist/messagemodel.cpp" line="+839"/>
<source>Completion status for %1</source>
<translation>Bearbeitungsstand von %1</translation>
</message>
@@ -1628,7 +1628,7 @@ Zeile: %2</translation>
<context>
<name>MsgEdit</name>
<message>
- <location filename="../tools/linguist/linguist/messageeditor.cpp" line="-614"/>
+ <location filename="../tools/linguist/linguist/messageeditor.cpp" line="-602"/>
<source></source>
<comment>This is the right panel of the main window.</comment>
<translation></translation>
@@ -1807,7 +1807,7 @@ Zeile: %2</translation>
<translation>Alle Dateien (*)</translation>
</message>
<message>
- <location filename="../tools/linguist/linguist/messagemodel.cpp" line="-1127"/>
+ <location filename="../tools/linguist/linguist/messagemodel.cpp" line="-1134"/>
<location line="+27"/>
<location line="+67"/>
<location line="+39"/>
@@ -1843,7 +1843,7 @@ Zeile: %2</translation>
<translation>XLIFF-Übersetzungsdateien</translation>
</message>
<message>
- <location filename="../tools/linguist/shared/qph.cpp" line="+183"/>
+ <location filename="../tools/linguist/shared/qph.cpp" line="+195"/>
<source>Qt Linguist &apos;Phrase Book&apos;</source>
<translation>Qt-Linguist-Wörterbuch</translation>
</message>
@@ -1985,12 +1985,12 @@ Zeile: %2</translation>
<context>
<name>TranslationSettingsDialog</name>
<message>
- <location filename="../tools/linguist/linguist/translationsettingsdialog.cpp" line="+68"/>
+ <location filename="../tools/linguist/linguist/translationsettingsdialog.cpp" line="+93"/>
<source>Any Country</source>
<translation>Land</translation>
</message>
<message>
- <location line="+11"/>
+ <location line="-22"/>
<location line="+8"/>
<source>Settings for &apos;%1&apos; - Qt Linguist</source>
<translation>Einstellungen für &apos;%1&apos; - Qt Linguist</translation>
diff --git a/translations/qt_de.ts b/translations/qt_de.ts
index 6447451912..f02a7bbb66 100644
--- a/translations/qt_de.ts
+++ b/translations/qt_de.ts
@@ -4,7 +4,7 @@
<context>
<name>CloseButton</name>
<message>
- <location filename="../src/gui/widgets/qtabbar.cpp" line="+2264"/>
+ <location filename="../src/gui/widgets/qtabbar.cpp" line="+2266"/>
<source>Close Tab</source>
<translation>Schließen</translation>
</message>
@@ -372,6 +372,7 @@ Bitte überprüfen Sie Ihre GStreamer-Installation und stellen Sie sicher, dass
<message>
<location line="+6"/>
<source>Decay time (ms)</source>
+ <extracomment>DecayTime: Time over which reverberation is diminished.</extracomment>
<translation>Abklingzeit (ms)</translation>
</message>
<message>
@@ -548,7 +549,7 @@ Bitte überprüfen Sie Ihre GStreamer-Installation und stellen Sie sicher, dass
<context>
<name>Q3FileDialog</name>
<message>
- <location filename="../src/qt3support/dialogs/q3filedialog.cpp" line="+827"/>
+ <location filename="../src/qt3support/dialogs/q3filedialog.cpp" line="+835"/>
<source>Copy or Move a File</source>
<translation>Datei kopieren oder verschieben</translation>
</message>
@@ -1212,7 +1213,7 @@ nach
<translation>Diese Socket-Operation wird nicht unterstützt</translation>
</message>
<message>
- <location filename="../src/network/access/qhttpnetworkconnection.cpp" line="+585"/>
+ <location filename="../src/network/access/qhttpnetworkconnection.cpp" line="+586"/>
<location filename="../src/network/socket/qabstractsocket.cpp" line="+200"/>
<source>Socket operation timed out</source>
<translation>Das Zeitlimit für die Operation wurde überschritten</translation>
@@ -1257,7 +1258,7 @@ nach
<context>
<name>QApplication</name>
<message>
- <location filename="../src/gui/kernel/qapplication.cpp" line="+2287"/>
+ <location filename="../src/gui/kernel/qapplication.cpp" line="+2309"/>
<source>QT_LAYOUT_DIRECTION</source>
<comment>Translate this string to the string &apos;LTR&apos; in left-to-right languages or to &apos;RTL&apos; in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment>
<translation>LTR</translation>
@@ -1327,7 +1328,7 @@ nach
<context>
<name>QColorDialog</name>
<message>
- <location filename="../src/gui/dialogs/qcolordialog.cpp" line="+1356"/>
+ <location filename="../src/gui/dialogs/qcolordialog.cpp" line="+1355"/>
<source>Hu&amp;e:</source>
<translation>Farb&amp;ton:</translation>
</message>
@@ -1367,7 +1368,7 @@ nach
<translation>Farbauswahl</translation>
</message>
<message>
- <location line="+184"/>
+ <location line="+183"/>
<source>&amp;Basic colors</source>
<translation>Grundfar&amp;ben</translation>
</message>
@@ -1567,7 +1568,7 @@ nach
<message>
<location filename="../src/gui/dialogs/qmessagebox.cpp" line="+1876"/>
<location line="+464"/>
- <location filename="../src/gui/widgets/qdialogbuttonbox.cpp" line="+650"/>
+ <location filename="../src/gui/widgets/qdialogbuttonbox.cpp" line="+648"/>
<source>OK</source>
<translation>OK</translation>
</message>
@@ -1818,7 +1819,7 @@ nach
<context>
<name>QFileDialog</name>
<message>
- <location filename="../src/gui/dialogs/qfiledialog.cpp" line="+558"/>
+ <location filename="../src/gui/dialogs/qfiledialog.cpp" line="+557"/>
<location line="+471"/>
<source>All Files (*)</source>
<translation>Alle Dateien (*)</translation>
@@ -1906,7 +1907,7 @@ nach
<translation>Verzeichnisse</translation>
</message>
<message>
- <location filename="../src/gui/dialogs/qfiledialog_win.cpp" line="+174"/>
+ <location filename="../src/gui/dialogs/qfiledialog_win.cpp" line="+148"/>
<source>All Files (*.*)</source>
<translation>Alle Dateien (*.*)</translation>
</message>
@@ -2059,7 +2060,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QFileSystemModel</name>
<message>
- <location filename="../src/gui/dialogs/qfilesystemmodel.cpp" line="+744"/>
+ <location filename="../src/gui/dialogs/qfilesystemmodel.cpp" line="+740"/>
<location filename="../src/gui/itemviews/qdirmodel.cpp" line="+476"/>
<source>%1 TB</source>
<translation>%1 TB</translation>
@@ -2088,7 +2089,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<translation>%1 Byte</translation>
</message>
<message>
- <location line="+77"/>
+ <location line="+89"/>
<source>Invalid filename</source>
<translation>Ungültiger Dateiname</translation>
</message>
@@ -2125,7 +2126,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<translation>Änderungsdatum</translation>
</message>
<message>
- <location filename="../src/gui/dialogs/qfilesystemmodel_p.h" line="+258"/>
+ <location filename="../src/gui/dialogs/qfilesystemmodel_p.h" line="+261"/>
<source>My Computer</source>
<translation>Mein Computer</translation>
</message>
@@ -2558,17 +2559,30 @@ Möchten Sie die Datei trotzdem löschen?</translation>
</message>
</context>
<context>
+ <name>QGstreamerPlayerSession</name>
+ <message>
+ <location filename="../src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp" line="+270"/>
+ <source>Unable to play %1</source>
+ <translation>%1 kann nicht abgespielt werden</translation>
+ </message>
+</context>
+<context>
<name>QHostInfo</name>
<message>
<location filename="../src/network/kernel/qhostinfo_p.h" line="+101"/>
<source>Unknown error</source>
<translation>Unbekannter Fehler</translation>
</message>
+ <message>
+ <location filename="../src/network/kernel/qhostinfo.cpp" line="+168"/>
+ <source>No host name given</source>
+ <translation>Es wurde kein Hostname angegeben</translation>
+ </message>
</context>
<context>
<name>QHostInfoAgent</name>
<message>
- <location filename="../src/network/kernel/qhostinfo_unix.cpp" line="+257"/>
+ <location filename="../src/network/kernel/qhostinfo_unix.cpp" line="+259"/>
<location line="+32"/>
<location filename="../src/network/kernel/qhostinfo_win.cpp" line="+216"/>
<location line="+27"/>
@@ -2591,12 +2605,14 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<translation>Unbekannter Fehler</translation>
</message>
<message>
+ <location line="-98"/>
<location filename="../src/network/kernel/qhostinfo_win.cpp" line="-67"/>
<source>No host name given</source>
<translation>Es wurde kein Hostname angegeben</translation>
</message>
<message>
- <location line="+0"/>
+ <location line="+1"/>
+ <location filename="../src/network/kernel/qhostinfo_win.cpp" line="+0"/>
<source>Invalid hostname</source>
<translation>Ungültiger Rechnername</translation>
</message>
@@ -2919,7 +2935,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QIODevice</name>
<message>
- <location filename="../src/corelib/global/qglobal.cpp" line="+2096"/>
+ <location filename="../src/corelib/global/qglobal.cpp" line="+2094"/>
<source>Permission denied</source>
<translation>Zugriff verweigert</translation>
</message>
@@ -3003,7 +3019,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<translation>Operation unmap fehlgeschlagen für &apos;%1&apos;: %2</translation>
</message>
<message>
- <location line="+345"/>
+ <location line="+361"/>
<source>The plugin &apos;%1&apos; uses incompatible Qt library. (%2.%3.%4) [%5]</source>
<translation>Das Plugin &apos;%1&apos; verwendet eine inkompatible Qt-Bibliothek. (%2.%3.%4) [%5]</translation>
</message>
@@ -3055,7 +3071,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QLineEdit</name>
<message>
- <location filename="../src/gui/widgets/qlineedit.cpp" line="+2112"/>
+ <location filename="../src/gui/widgets/qlineedit.cpp" line="+2104"/>
<source>Select All</source>
<translation>Alles auswählen</translation>
</message>
@@ -3132,7 +3148,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<location line="+3"/>
<location filename="../src/network/socket/qlocalsocket_unix.cpp" line="+3"/>
<location filename="../src/network/socket/qlocalsocket_win.cpp" line="+80"/>
- <location line="+45"/>
+ <location line="+59"/>
<source>%1: Invalid name</source>
<translation>%1: Ungültiger Name</translation>
</message>
@@ -3163,7 +3179,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<message>
<location line="+3"/>
<location filename="../src/network/socket/qlocalsocket_unix.cpp" line="+3"/>
- <location filename="../src/network/socket/qlocalsocket_win.cpp" line="-50"/>
+ <location filename="../src/network/socket/qlocalsocket_win.cpp" line="-64"/>
<source>%1: Connection error</source>
<translation>%1: Verbindungsfehler</translation>
</message>
@@ -3376,6 +3392,39 @@ Möchten Sie die Datei trotzdem löschen?</translation>
</message>
</context>
<context>
+ <name>QMediaPlayer</name>
+ <message>
+ <location filename="../src/multimedia/playback/qmediaplayer.cpp" line="+471"/>
+ <source>The QMediaPlayer object does not have a valid service</source>
+ <translation>Das QMediaPlayer-Objekt verfügt über keinen gültigen Dienst</translation>
+ </message>
+</context>
+<context>
+ <name>QMediaPlaylist</name>
+ <message>
+ <location filename="../src/multimedia/base/qmediaplaylist.cpp" line="+454"/>
+ <location line="+46"/>
+ <source>Could not add items to read only playlist.</source>
+ <translation>Es konnten keine Einträge zur Wiedergabeliste hinzugefügt werden, da sie schreibgeschützt ist.</translation>
+ </message>
+ <message>
+ <location line="-27"/>
+ <location line="+46"/>
+ <source>Playlist format is not supported</source>
+ <translation>Das Format der Wiedergabeliste ist nicht unterstützt</translation>
+ </message>
+ <message>
+ <location line="+26"/>
+ <source>The file could not be accessed.</source>
+ <translation>Auf die Datei konnte nicht zugegriffen werden.</translation>
+ </message>
+ <message>
+ <location line="+35"/>
+ <source>Playlist format is not supported.</source>
+ <translation>Das Format der Wiedergabeliste ist nicht unterstützt.</translation>
+ </message>
+</context>
+<context>
<name>QMenu</name>
<message>
<location filename="../src/plugins/accessible/widgets/qaccessiblemenu.cpp" line="+157"/>
@@ -3470,7 +3519,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QNativeSocketEngine</name>
<message>
- <location filename="../src/network/socket/qnativesocketengine.cpp" line="+206"/>
+ <location filename="../src/network/socket/qnativesocketengine.cpp" line="+209"/>
<source>The remote host closed the connection</source>
<translation>Der entfernte Rechner hat die Verbindung geschlossen</translation>
</message>
@@ -3609,12 +3658,35 @@ Möchten Sie die Datei trotzdem löschen?</translation>
</message>
</context>
<context>
+ <name>QNetworkAccessDataBackend</name>
+ <message>
+ <location filename="../src/network/access/qnetworkaccessdatabackend.cpp" line="+76"/>
+ <source>Operation not supported on %1</source>
+ <translation>Diese Operation wird von %1 nicht unterstützt</translation>
+ </message>
+ <message>
+ <location line="+25"/>
+ <source>Invalid URI: %1</source>
+ <translation>Ungültiger URI: %1</translation>
+ </message>
+</context>
+<context>
<name>QNetworkAccessDebugPipeBackend</name>
<message>
<location filename="../src/network/access/qnetworkaccessdebugpipebackend.cpp" line="+195"/>
<source>Write error writing to %1: %2</source>
<translation>Fehler beim Schreiben zu %1: %2</translation>
</message>
+ <message>
+ <location line="+60"/>
+ <source>Socket error on %1: %2</source>
+ <translation>Socket-Fehler bei %1: %2</translation>
+ </message>
+ <message>
+ <location line="+15"/>
+ <source>Remote host closed the connection prematurely on %1</source>
+ <translation>Der entfernte Rechner hat die Verbindung zu %1 vorzeitig beendet</translation>
+ </message>
</context>
<context>
<name>QNetworkAccessFileBackend</name>
@@ -3678,37 +3750,106 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QNetworkAccessHttpBackend</name>
<message>
- <location filename="../src/network/access/qnetworkaccesshttpbackend.cpp" line="+599"/>
+ <location filename="../src/network/access/qnetworkaccesshttpbackend.cpp" line="+645"/>
<source>No suitable proxy found</source>
<translation>Es konnte kein geeigneter Proxy-Server gefunden werden</translation>
</message>
</context>
<context>
+ <name>QNetworkAccessManager</name>
+ <message>
+ <location filename="../src/network/access/qnetworkreplyimpl.cpp" line="+862"/>
+ <source>Network access is disabled.</source>
+ <translation>Der Zugriff auf das Netzwerk ist nicht gestattet.</translation>
+ </message>
+</context>
+<context>
<name>QNetworkReply</name>
<message>
- <location line="+101"/>
+ <location filename="../src/network/access/qnetworkaccesshttpbackend.cpp" line="+101"/>
<source>Error downloading %1 - server replied: %2</source>
<translation>Beim Herunterladen von %1 trat ein Fehler auf - Die Antwort des Servers ist: %2</translation>
</message>
<message>
- <location filename="../src/network/access/qnetworkreplyimpl.cpp" line="+80"/>
+ <location filename="../src/network/access/qnetworkreplyimpl.cpp" line="-780"/>
<source>Protocol &quot;%1&quot; is unknown</source>
<translation>Das Protokoll &quot;%1&quot; ist unbekannt</translation>
</message>
+ <message>
+ <location line="+486"/>
+ <source>Temporary network failure.</source>
+ <translation>Das Netzwerk ist zur Zeit ausgefallen.</translation>
+ </message>
</context>
<context>
<name>QNetworkReplyImpl</name>
<message>
- <location line="+525"/>
+ <location line="+110"/>
<location line="+28"/>
<source>Operation canceled</source>
<translation>Operation abgebrochen</translation>
</message>
</context>
<context>
+ <name>QNetworkSession</name>
+ <message>
+ <location filename="../src/network/bearer/qnetworksession.cpp" line="+437"/>
+ <source>Invalid configuration.</source>
+ <translation>Ungültige Konfiguration.</translation>
+ </message>
+</context>
+<context>
+ <name>QNetworkSessionPrivateImpl</name>
+ <message>
+ <location filename="../src/plugins/bearer/qnetworksession_impl.cpp" line="+247"/>
+ <location filename="../src/plugins/bearer/symbian/qnetworksession_impl.cpp" line="+213"/>
+ <source>Unknown session error.</source>
+ <translation>Unbekannter Fehler bei Netzwerkverbindung.</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <location filename="../src/plugins/bearer/symbian/qnetworksession_impl.cpp" line="+2"/>
+ <source>The session was aborted by the user or system.</source>
+ <translation>Die Verbindung wurde vom Nutzer oder vom Betriebssystem unterbrochen.</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <location filename="../src/plugins/bearer/symbian/qnetworksession_impl.cpp" line="+2"/>
+ <source>The requested operation is not supported by the system.</source>
+ <translation>Die angeforderte Operation wird vom System nicht unterstützt.</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <location filename="../src/plugins/bearer/symbian/qnetworksession_impl.cpp" line="+2"/>
+ <source>The specified configuration cannot be used.</source>
+ <translation>Die angegebene Konfiguration kann nicht verwendet werden.</translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <location filename="../src/plugins/bearer/symbian/qnetworksession_impl.cpp" line="+2"/>
+ <source>Roaming was aborted or is not possible.</source>
+ <translation>Das Roaming wurde abgebrochen oder ist hier nicht möglich.</translation>
+ </message>
+ <message>
+ <location filename="../src/plugins/bearer/icd/qnetworksession_impl.cpp" line="+1083"/>
+ <source>Roaming error</source>
+ <translation>Fehler beim Roaming</translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Session aborted by user or system</source>
+ <translation>Die Verbindung wurde vom Nutzer oder vom Betriebssystem unterbrochen</translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>Unidentified Error</source>
+ <translation>Unbekannter Fehler</translation>
+ </message>
+</context>
+<context>
<name>QOCIDriver</name>
<message>
- <location filename="../src/sql/drivers/oci/qsql_oci.cpp" line="+2083"/>
+ <location filename="../src/sql/drivers/oci/qsql_oci.cpp" line="+2082"/>
<source>Unable to logon</source>
<translation>Logon-Vorgang fehlgeschlagen</translation>
</message>
@@ -3782,12 +3923,12 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QODBCDriver</name>
<message>
- <location filename="../src/sql/drivers/odbc/qsql_odbc.cpp" line="+1806"/>
+ <location filename="../src/sql/drivers/odbc/qsql_odbc.cpp" line="+1791"/>
<source>Unable to connect</source>
<translation>Es kann keine Verbindung aufgebaut werden</translation>
</message>
<message>
- <location line="+238"/>
+ <location line="+233"/>
<source>Unable to disable autocommit</source>
<translation>&apos;autocommit&apos; konnte nicht deaktiviert werden</translation>
</message>
@@ -3807,7 +3948,7 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<translation>&apos;autocommit&apos; konnte nicht aktiviert werden</translation>
</message>
<message>
- <location line="-281"/>
+ <location line="-276"/>
<source>Unable to connect - Driver doesn&apos;t support all functionality required</source>
<translation>Es kann keine Verbindung aufgebaut werden weil der Treiber die benötigte Funktionalität nicht vollständig unterstützt</translation>
</message>
@@ -3815,19 +3956,19 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QODBCResult</name>
<message>
- <location line="-937"/>
+ <location line="-935"/>
<location line="+351"/>
<source>QODBCResult::reset: Unable to set &apos;SQL_CURSOR_STATIC&apos; as statement attribute. Please check your ODBC driver configuration</source>
<translation>QODBCResult::reset: &apos;SQL_CURSOR_STATIC&apos; konnte nicht als Attribut des Befehls gesetzt werden. Bitte prüfen Sie die Konfiguration Ihres ODBC-Treibers</translation>
</message>
<message>
<location line="-334"/>
- <location line="+628"/>
+ <location line="+626"/>
<source>Unable to execute statement</source>
<translation>Der Befehl konnte nicht ausgeführt werden</translation>
</message>
<message>
- <location line="-547"/>
+ <location line="-545"/>
<source>Unable to fetch next</source>
<translation>Der nächste Datensatz konnte nicht abgeholt werden</translation>
</message>
@@ -3837,19 +3978,19 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<translation>Der Befehl konnte nicht initialisiert werden</translation>
</message>
<message>
- <location line="+268"/>
+ <location line="+266"/>
<source>Unable to bind variable</source>
<translation>Die Variable konnte nicht gebunden werden</translation>
</message>
<message>
<location filename="../src/sql/drivers/db2/qsql_db2.cpp" line="+189"/>
- <location filename="../src/sql/drivers/odbc/qsql_odbc.cpp" line="-467"/>
- <location line="+576"/>
+ <location filename="../src/sql/drivers/odbc/qsql_odbc.cpp" line="-465"/>
+ <location line="+574"/>
<source>Unable to fetch last</source>
<translation>Der letzte Datensatz konnte nicht abgeholt werden</translation>
</message>
<message>
- <location filename="../src/sql/drivers/odbc/qsql_odbc.cpp" line="-670"/>
+ <location filename="../src/sql/drivers/odbc/qsql_odbc.cpp" line="-668"/>
<source>Unable to fetch</source>
<translation>Es konnten keine Daten abgeholt werden</translation>
</message>
@@ -3867,41 +4008,15 @@ Möchten Sie die Datei trotzdem löschen?</translation>
<context>
<name>QObject</name>
<message>
- <location filename="../src/network/kernel/qhostinfo_unix.cpp" line="-97"/>
- <source>Invalid hostname</source>
- <translation>Ungültiger Rechnername</translation>
- </message>
- <message>
- <location filename="../src/network/access/qnetworkaccessdatabackend.cpp" line="+74"/>
- <source>Operation not supported on %1</source>
- <translation>Diese Operation wird von %1 nicht unterstützt</translation>
- </message>
- <message>
- <location line="+57"/>
- <source>Invalid URI: %1</source>
- <translation>Ungültiger URI: %1</translation>
- </message>
- <message>
- <location filename="../src/network/access/qnetworkaccessdebugpipebackend.cpp" line="+60"/>
- <source>Socket error on %1: %2</source>
- <translation>Socket-Fehler bei %1: %2</translation>
- </message>
- <message>
- <location line="+15"/>
- <source>Remote host closed the connection prematurely on %1</source>
- <translation>Der entfernte Rechner hat die Verbindung zu %1 vorzeitig beendet</translation>
- </message>
- <message>
- <location filename="../src/network/kernel/qhostinfo.cpp" line="+168"/>
- <location filename="../src/network/kernel/qhostinfo_unix.cpp" line="+0"/>
- <source>No host name given</source>
- <translation>Es wurde kein Hostname angegeben</translation>
+ <location filename="../src/declarative/util/qmlxmllistmodel.cpp" line="+370"/>
+ <source>&quot;%1&quot; duplicates a previous role name and will be disabled.</source>
+ <translation>&quot;%1&quot; ist bereits als Name einer Rolle vergeben und wird daher deaktiviert.</translation>
</message>
</context>
<context>
<name>QPPDOptionsModel</name>
<message>
- <location filename="../src/gui/dialogs/qprintdialog_unix.cpp" line="+1197"/>
+ <location filename="../src/gui/dialogs/qprintdialog_unix.cpp" line="+1195"/>
<source>Name</source>
<translation>Name</translation>
</message>
@@ -4959,7 +5074,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<context>
<name>QSQLiteDriver</name>
<message>
- <location filename="../src/sql/drivers/sqlite/qsql_sqlite.cpp" line="+547"/>
+ <location filename="../src/sql/drivers/sqlite/qsql_sqlite.cpp" line="+538"/>
<source>Error opening database</source>
<translation>Die Datenbankverbindung konnte nicht geöffnet werden</translation>
</message>
@@ -4987,7 +5102,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<context>
<name>QSQLiteResult</name>
<message>
- <location line="-404"/>
+ <location line="-395"/>
<location line="+62"/>
<location line="+8"/>
<source>Unable to fetch row</source>
@@ -5245,7 +5360,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<context>
<name>QScriptDebuggerLocalsModel</name>
<message>
- <location filename="../src/scripttools/debugging/qscriptdebuggerlocalsmodel.cpp" line="+872"/>
+ <location filename="../src/scripttools/debugging/qscriptdebuggerlocalsmodel.cpp" line="+897"/>
<source>Name</source>
<translation>Name</translation>
</message>
@@ -6428,7 +6543,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<translation>Umdrehen</translation>
</message>
<message>
- <location line="+575"/>
+ <location line="+602"/>
<location line="+135"/>
<source>Ctrl</source>
<translation>Strg</translation>
@@ -6462,7 +6577,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<translation>F%1</translation>
</message>
<message>
- <location line="-871"/>
+ <location line="-898"/>
<source>Home Page</source>
<translation>Startseite</translation>
</message>
@@ -6596,7 +6711,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<translation>Abbrechen</translation>
</message>
<message>
- <location filename="../src/gui/kernel/qsoftkeymanager_s60.cpp" line="+273"/>
+ <location filename="../src/gui/kernel/qsoftkeymanager_s60.cpp" line="+312"/>
<source>Exit</source>
<translation>Beenden</translation>
</message>
@@ -6940,7 +7055,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<context>
<name>QTextControl</name>
<message>
- <location filename="../src/gui/text/qtextcontrol.cpp" line="+2027"/>
+ <location filename="../src/gui/text/qtextcontrol.cpp" line="+2029"/>
<source>&amp;Undo</source>
<translation>&amp;Rückgängig</translation>
</message>
@@ -7989,7 +8104,7 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
<context>
<name>QWidget</name>
<message>
- <location filename="../src/gui/kernel/qwidget.cpp" line="+5728"/>
+ <location filename="../src/gui/kernel/qwidget.cpp" line="+5761"/>
<source>*</source>
<translation>*</translation>
</message>
@@ -8454,6 +8569,866 @@ Bitte wählen Sie einen anderen Dateinamen.</translation>
</message>
</context>
<context>
+ <name>QmlAbstractAnimation</name>
+ <message>
+ <location filename="../src/declarative/util/qmlanimation.cpp" line="+235"/>
+ <source>Cannot animate non-existent property &quot;%1&quot;</source>
+ <translation>Die Eigenschaft &apos;%1&quot; existiert nicht und kann daher nicht animiert werden</translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Cannot animate read-only property &quot;%1&quot;</source>
+ <translation>Die Eigenschaft &apos;%1&quot; ist schreibgeschützt und kann daher nicht animiert werden</translation>
+ </message>
+</context>
+<context>
+ <name>QmlBehavior</name>
+ <message>
+ <location filename="../src/declarative/util/qmlbehavior.cpp" line="+122"/>
+ <source>Cannot change the animation assigned to a Behavior.</source>
+ <translation>Die zu einem Behavior-Element gehörende Animation kann nicht geändert werden.</translation>
+ </message>
+</context>
+<context>
+ <name>QmlBinding</name>
+ <message>
+ <location filename="../src/declarative/qml/qmlbinding.cpp" line="+195"/>
+ <source>Binding loop detected for property &quot;%1&quot;</source>
+ <translation>Bei der für die Eigenschaft &quot;%1&quot; angegebenen Bindung wurde eine Schleife festgestellt</translation>
+ </message>
+</context>
+<context>
+ <name>QmlCompiler</name>
+ <message>
+ <location filename="../src/declarative/qml/qmlcompiler.cpp" line="+214"/>
+ <location line="+1772"/>
+ <location line="+124"/>
+ <location line="+427"/>
+ <source>Invalid property assignment: &quot;%1&quot; is a read-only property</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: &quot;%1&quot; ist schreibgeschützt</translation>
+ </message>
+ <message>
+ <location line="-2314"/>
+ <source>Invalid property assignment: unknown enumeration</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Ungültiger Aufzählungswert</translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Invalid property assignment: string expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Zeichenkette erwartet</translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Invalid property assignment: url expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine URL erwartet</translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Invalid property assignment: unsigned int expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine vorzeichenloser Ganzzahlwert erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: int expected</source>
+ <translation type="unfinished">Ungültige Zuweisung bei Eigenschaft: Es wird ein Ganzzahlwert erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: float expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Gleitkommazahl erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: double expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Gleitkommazahl (double) erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: color expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Farbspezifikation erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: date expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Datumsangabe erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: time expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Zeitangabe erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: datetime expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Datumsangabe erwartet</translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Invalid property assignment: point expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Koordinatenangabe für einen Punkt erwartet</translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Invalid property assignment: size expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird eine Größenangabe erwartet</translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Invalid property assignment: rect expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es werden Parameter für ein Rechteck erwartet</translation>
+ </message>
+ <message>
+ <location line="+5"/>
+ <source>Invalid property assignment: boolean expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird ein Boolescher Wert erwartet</translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Invalid property assignment: 3D vector expected</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Es wird ein dreidimensionaler Vektor erwartet</translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Invalid property assignment: unsupported type &quot;%1&quot;</source>
+ <translation>Ungültige Zuweisung bei Eigenschaft: Der Typ &quot;%1&quot; ist nicht unterstützt</translation>
+ </message>
+ <message>
+ <location line="+801"/>
+ <location line="+3"/>
+ <source>Invalid component specification</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Invalid component id specification</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <location line="+565"/>
+ <source>id is not unique</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-555"/>
+ <source>Invalid component body specification</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Cannot create empty component specification</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+17"/>
+ <source>Invalid Script block. Specify either the source property or inline script</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>Invalid Script source value</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+24"/>
+ <source>Properties cannot be set on Script block</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+14"/>
+ <source>Invalid Script block</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+130"/>
+ <source>Incorrectly specified signal</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+13"/>
+ <source>Empty signal assignment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+36"/>
+ <source>Empty property assignment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>Attached properties cannot be used here</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+15"/>
+ <location line="+104"/>
+ <source>Non-existent attached object</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-100"/>
+ <location line="+103"/>
+ <source>Invalid attached object assignment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-50"/>
+ <source>Cannot assign to non-existent default property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <location line="+339"/>
+ <source>Cannot assign to non-existent property &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-308"/>
+ <source>Invalid use of namespace</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+5"/>
+ <source>Not an attached property name</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+169"/>
+ <source>Invalid use of id property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>&quot;%1&quot; is not a valid object id</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>id conflicts with type name</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <source>id conflicts with namespace prefix</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+78"/>
+ <source>Invalid value in grouped property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+10"/>
+ <location line="+8"/>
+ <source>Invalid grouped property access</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+16"/>
+ <source>Invalid property use</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>Property assignment expected</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Single property assignment expected</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Unexpected object assignment</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+57"/>
+ <source>Cannot assign object to list</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>Cannot assign primitives to lists</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-6"/>
+ <source>Can only assign one binding to lists</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+19"/>
+ <source>Cannot assign multiple values to a script property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Invalid property assignment: script expected</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+129"/>
+ <source>Cannot assign object to property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+97"/>
+ <source>Duplicate default property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+5"/>
+ <source>Duplicate property name</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+8"/>
+ <source>Duplicate signal name</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Duplicate method name</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+22"/>
+ <source>Invalid property nesting</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+55"/>
+ <source>Cannot override FINAL property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+25"/>
+ <source>Invalid property type</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+174"/>
+ <location line="+9"/>
+ <source>No property alias location</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-4"/>
+ <location line="+25"/>
+ <source>Invalid alias location</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-16"/>
+ <source>Invalid alias reference. An alias reference must be specified as &lt;id&gt; or &lt;id&gt;.&lt;property&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Invalid alias reference. Unable to find id &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlCompositeTypeManager</name>
+ <message>
+ <location filename="../src/declarative/qml/qmlcompositetypemanager.cpp" line="+415"/>
+ <location line="+220"/>
+ <source>Resource %1 unavailable</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-141"/>
+ <source>Import %1 unavailable</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+30"/>
+ <source>Namespace %1 cannot be used as a type</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+2"/>
+ <source>%1 is not a type</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+42"/>
+ <source>Type %1 unavailable</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlEngine</name>
+ <message>
+ <location filename="../src/declarative/qml/qmlsqldatabase.cpp" line="+204"/>
+ <source>executeSql called outside transaction()</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+52"/>
+ <source>Read-only Transaction</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+20"/>
+ <source>Version mismatch: expected %1, found %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+14"/>
+ <source>SQL transaction failed</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+21"/>
+ <source>transaction: missing callback</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+57"/>
+ <location line="+16"/>
+ <source>SQL: database version mismatch</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlGraphicsAnchors</name>
+ <message>
+ <location filename="../src/declarative/graphicsitems/qmlgraphicsanchors.cpp" line="+177"/>
+ <source>Possible anchor loop detected on fill.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+28"/>
+ <source>Possible anchor loop detected on centerIn.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+163"/>
+ <location line="+34"/>
+ <location line="+607"/>
+ <location line="+37"/>
+ <source>Cannot anchor to an item that isn&apos;t a parent or sibling.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-534"/>
+ <source>Possible anchor loop detected on vertical anchor.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+59"/>
+ <source>Possible anchor loop detected on horizontal anchor.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+422"/>
+ <source>Cannot specify left, right, and hcenter anchors.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+10"/>
+ <location line="+37"/>
+ <source>Cannot anchor to a null item.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-34"/>
+ <source>Cannot anchor a horizontal edge to a vertical edge.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <location line="+37"/>
+ <source>Cannot anchor item to self.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-25"/>
+ <source>Cannot specify top, bottom, and vcenter anchors.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+13"/>
+ <source>Cannot anchor a vertical edge to a horizontal edge.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlGraphicsFlipable</name>
+ <message>
+ <location filename="../src/declarative/graphicsitems/qmlgraphicsflipable.cpp" line="+149"/>
+ <source>front is a write-once property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+19"/>
+ <source>back is a write-once property</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlGraphicsTextInput</name>
+ <message>
+ <location filename="../src/declarative/graphicsitems/qmlgraphicstextinput.cpp" line="+594"/>
+ <location line="+9"/>
+ <source>Could not load cursor delegate</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+12"/>
+ <source>Could not instantiate cursor delegate</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlGraphicsVisualDataModel</name>
+ <message>
+ <location filename="../src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp" line="+826"/>
+ <source>Delegate component must be Item type.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlInfo</name>
+ <message>
+ <location filename="../src/declarative/qml/qmlinfo.cpp" line="+112"/>
+ <location line="+3"/>
+ <source>unknown location</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlListModel</name>
+ <message>
+ <location filename="../src/declarative/util/qmllistmodel.cpp" line="+491"/>
+ <source>remove: index %1 out of range</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+30"/>
+ <source>insert: value is not an object</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>insert: index %1 out of range</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+29"/>
+ <source>move: out of range</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+49"/>
+ <source>append: value is not an object</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+39"/>
+ <source>get: index %1 out of range</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+33"/>
+ <source>set: value is not an object</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <location line="+39"/>
+ <source>set: index %1 out of range</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+49"/>
+ <source>ListElement: cannot use default property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+4"/>
+ <source>ListElement: cannot use reserved &quot;id&quot; property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+46"/>
+ <source>ListElement: cannot use script for property value</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+25"/>
+ <source>ListModel: undefined property &apos;%1&apos;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlParentChange</name>
+ <message>
+ <location filename="../src/declarative/util/qmlstateoperations.cpp" line="+85"/>
+ <source>Unable to preserve appearance under complex transform</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+10"/>
+ <location line="+7"/>
+ <source>Unable to preserve appearance under non-uniform scale</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>Unable to preserve appearance under scale of 0</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlParser</name>
+ <message>
+ <location filename="../src/declarative/qml/parser/qmljslexer.cpp" line="+554"/>
+ <source>Illegal character</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+14"/>
+ <source>Unclosed string at end of line</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+26"/>
+ <source>Illegal escape squence</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+46"/>
+ <source>Illegal unicode escape sequence</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+26"/>
+ <source>Unclosed comment at end of file</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+87"/>
+ <source>Illegal syntax for exponential number</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+26"/>
+ <source>Identifier cannot start with numeric literal</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+331"/>
+ <source>Unterminated regular expression literal</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+24"/>
+ <source>Invalid regular expression flag &apos;%0&apos;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/declarative/qml/parser/qmljsparser.cpp" line="+1767"/>
+ <location line="+67"/>
+ <source>Syntax error</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="-65"/>
+ <source>Unexpected token `%1&apos;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+28"/>
+ <location line="+24"/>
+ <source>Expected token `%1&apos;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/declarative/qml/qmlscriptparser.cpp" line="+267"/>
+ <source>Expected type name</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+29"/>
+ <source>Invalid use of Script block</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+151"/>
+ <source>Invalid import qualifier ID</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+11"/>
+ <source>Library import requires a version</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+53"/>
+ <source>Expected parameter type</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+42"/>
+ <source>Invalid property type modifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Unexpected property type modifier</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Expected property type</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Readonly not yet supported</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+194"/>
+ <source>QmlJS declaration outside Script element</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+19"/>
+ <source>Variable declarations not allow in inline Script blocks</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlPauseAnimation</name>
+ <message>
+ <location filename="../src/declarative/util/qmlanimation.cpp" line="+410"/>
+ <source>Cannot set a duration of &lt; 0</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlPropertyAnimation</name>
+ <message>
+ <location line="-568"/>
+ <source>Unmatched parenthesis in easing function &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Easing function &quot;%1&quot; must start with &quot;ease&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+15"/>
+ <source>Unknown easing curve &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+10"/>
+ <location line="+9"/>
+ <source>Improperly specified parameter in easing function &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+11"/>
+ <source>Unknown easing parameter &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+1754"/>
+ <source>Cannot set a duration of &lt; 0</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlPropertyChanges</name>
+ <message>
+ <location filename="../src/declarative/util/qmlpropertychanges.cpp" line="+361"/>
+ <source>Cannot assign to non-existent property &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Cannot assign to read-only property &quot;%1&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlVME</name>
+ <message>
+ <location filename="../src/declarative/qml/qmlvme.cpp" line="+195"/>
+ <source>Unable to create object of type %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+306"/>
+ <source>Cannot assign value %1 to property %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+22"/>
+ <source>Cannot assign object type %1 with no default method</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Cannot connect mismatched signal/slot %1 %vs. %2</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+5"/>
+ <source>Cannot assign an object to signal property %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+147"/>
+ <source>Cannot assign object to list</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+41"/>
+ <source>Cannot assign object to interface property</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+11"/>
+ <source>Unable to create attached object</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+32"/>
+ <source>Cannot set properties on %1 as it is null</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlXmlListModelRole</name>
+ <message>
+ <location filename="../src/declarative/util/qmlxmllistmodel.cpp" line="-255"/>
+ <source>An XmlRole query must not start with &apos;/&apos;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QmlXmlRoleList</name>
+ <message>
+ <location line="+430"/>
+ <source>An XmlListModel query must start with &apos;/&apos; or &quot;//&quot;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>QtXmlPatterns</name>
<message>
<location filename="../src/xmlpatterns/data/qabstractduration.cpp" line="+99"/>
diff --git a/translations/qt_help_de.ts b/translations/qt_help_de.ts
index f64e741c85..40d115869f 100644
--- a/translations/qt_help_de.ts
+++ b/translations/qt_help_de.ts
@@ -63,7 +63,7 @@
<translation>Unbekannter Filter &apos;%1&apos;.</translation>
</message>
<message>
- <location line="+105"/>
+ <location line="+103"/>
<source>Invalid documentation file &apos;%1&apos;!</source>
<translation>Ungültige Dokumentationsdatei &apos;%1&apos;.</translation>
</message>
@@ -78,7 +78,7 @@
<translation>Die Datenbank &apos;%1&apos; kann nicht zur Optimierung geöffnet werden.</translation>
</message>
<message>
- <location line="-438"/>
+ <location line="-436"/>
<source>Cannot create directory: %1</source>
<translation>Das Verzeichnis kann nicht angelegt werden: %1</translation>
</message>
@@ -88,7 +88,7 @@
<translation>Die Katalogdatei kann nicht kopiert werden: %1</translation>
</message>
<message>
- <location line="+174"/>
+ <location line="+172"/>
<source>Cannot register filter %1!</source>
<translation>Der Filter kann nicht registriert werden: %1</translation>
</message>
@@ -120,23 +120,20 @@
<context>
<name>QHelpEngineCore</name>
<message>
- <location filename="../tools/assistant/lib/qhelpenginecore.cpp" line="+523"/>
- <source>The specified namespace does not exist!</source>
- <translation>Der angegebene Namensraum existiert nicht.</translation>
+ <location filename="../tools/assistant/lib/qhelpenginecore.cpp" line="+122"/>
+ <source>Cannot open documentation file %1: %2!</source>
+ <translation>Die Dokumentationsdatei %1 kann nicht geöffnet werden: %2!</translation>
</message>
-</context>
-<context>
- <name>QHelpEngineCorePrivate</name>
<message>
- <location line="-401"/>
- <source>Cannot open documentation file %1: %2!</source>
- <translation>Die Dokumentationsdatei %1 kann nicht geöffnet werden: %2.</translation>
+ <location line="+404"/>
+ <source>The specified namespace does not exist!</source>
+ <translation>Der angegebene Namensraum existiert nicht.</translation>
</message>
</context>
<context>
<name>QHelpGenerator</name>
<message>
- <location filename="../tools/assistant/lib/qhelpgenerator.cpp" line="+157"/>
+ <location filename="../tools/assistant/lib/qhelpgenerator.cpp" line="+158"/>
<source>Invalid help data!</source>
<translation>Ungültige Hilfe-Daten.</translation>
</message>
@@ -216,7 +213,7 @@
<translation>Die Datei %1 kann nicht geöffnet werden. Wird übersprungen.</translation>
</message>
<message>
- <location line="+131"/>
+ <location line="+133"/>
<source>The filter %1 is already registered!</source>
<translation>Der Filter %1 ist bereits registriert.</translation>
</message>
@@ -231,7 +228,7 @@
<translation>Indizes einfügen...</translation>
</message>
<message>
- <location line="+80"/>
+ <location line="+91"/>
<source>Insert contents...</source>
<translation>Inhalt einfügen...</translation>
</message>
@@ -245,122 +242,142 @@
<source>Cannot register contents!</source>
<translation>Inhalt kann nicht registriert werden.</translation>
</message>
+ <message>
+ <location line="+56"/>
+ <source>File &apos;%1&apos; does not exist.</source>
+ <translation>Die Datei &apos;%1&apos; existiert nicht.</translation>
+ </message>
+ <message>
+ <location line="+19"/>
+ <source>File &apos;%1&apos; cannot be opened.</source>
+ <translation>Die Datei &apos;%1&apos; kann nicht geöffnet werden.</translation>
+ </message>
+ <message>
+ <location line="+19"/>
+ <source>File &apos;%1&apos; contains an invalid link to file &apos;%2&apos;</source>
+ <translation>Die Datei &apos;%1&apos; enthält einen ungültigen Verweis auf die Datei &apos;%2&apos;</translation>
+ </message>
+ <message>
+ <location line="+9"/>
+ <source>Invalid links in HTML files.</source>
+ <translation>Es wurden ungültige Verweise in HTML-Dateien gefunden.</translation>
+ </message>
+</context>
+<context>
+ <name>QHelpProject</name>
+ <message>
+ <location filename="../tools/assistant/lib/qhelpprojectdata.cpp" line="+86"/>
+ <source>Unknown token.</source>
+ <translation>Unbekanntes Token.</translation>
+ </message>
+ <message>
+ <location line="+13"/>
+ <source>Unknown token. Expected &quot;QtHelpProject&quot;!</source>
+ <translation>Unbekanntes Token. &quot;QtHelpProject&quot; erwartet.</translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>Error in line %1: %2</source>
+ <translation>Fehler in Zeile %1: %2</translation>
+ </message>
+ <message>
+ <location line="+14"/>
+ <source>A virtual folder must not contain a &apos;/&apos; character!</source>
+ <translation>Ein virtuelles Verzeichnis darf kein &apos;/&apos;-Zeichen enthalten.</translation>
+ </message>
+ <message>
+ <location line="+6"/>
+ <source>A namespace must not contain a &apos;/&apos; character!</source>
+ <translation>Ein Namensraum darf kein &apos;/&apos;-Zeichen enthalten.</translation>
+ </message>
+ <message>
+ <location line="+20"/>
+ <source>Missing namespace in QtHelpProject.</source>
+ <translation>Fehlender Namensraum in QtHelpProject.</translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Missing virtual folder in QtHelpProject</source>
+ <translation>Fehlendes virtuelles Verzeichnis in QtHelpProject.</translation>
+ </message>
+ <message>
+ <location line="+89"/>
+ <source>Missing attribute in keyword at line %1.</source>
+ <translation>Fehlendes Attribut in Schlagwort in Zeile %1.</translation>
+ </message>
+ <message>
+ <location line="+125"/>
+ <source>The input file %1 could not be opened!</source>
+ <translation>Die Eingabe-Datei %1 kann nicht geöffnet werden.</translation>
+ </message>
</context>
<context>
<name>QHelpSearchQueryWidget</name>
<message>
- <location filename="../tools/assistant/lib/qhelpsearchquerywidget.cpp" line="+411"/>
+ <location filename="../tools/assistant/lib/qhelpsearchquerywidget.cpp" line="+124"/>
<source>Search for:</source>
<translation>Suche nach:</translation>
</message>
<message>
- <location line="+5"/>
+ <location line="+1"/>
<source>Previous search</source>
<translation>Vorige Suche</translation>
</message>
<message>
- <location line="+4"/>
+ <location line="+1"/>
<source>Next search</source>
<translation>Nächste Suche</translation>
</message>
<message>
- <location line="+2"/>
+ <location line="+1"/>
<source>Search</source>
<translation>Suche</translation>
</message>
<message>
- <location line="+20"/>
+ <location line="+2"/>
<source>Advanced search</source>
<translation>Erweiterte Suche</translation>
</message>
<message>
- <location line="+18"/>
+ <location line="+1"/>
<source>words &lt;B&gt;similar&lt;/B&gt; to:</source>
<translation>Worte &lt;B&gt;ähnlich&lt;/B&gt; zu:</translation>
</message>
<message>
- <location line="+6"/>
+ <location line="+1"/>
<source>&lt;B&gt;without&lt;/B&gt; the words:</source>
<translation>&lt;B&gt;ohne&lt;/B&gt; die Wörter:</translation>
</message>
<message>
- <location line="+6"/>
+ <location line="+1"/>
<source>with &lt;B&gt;exact phrase&lt;/B&gt;:</source>
<translation>mit der &lt;B&gt;genauen Wortgruppe&lt;/B&gt;:</translation>
</message>
<message>
- <location line="+6"/>
+ <location line="+1"/>
<source>with &lt;B&gt;all&lt;/B&gt; of the words:</source>
<translation>mit &lt;B&gt;allen&lt;/B&gt; Wörtern:</translation>
</message>
<message>
- <location line="+6"/>
+ <location line="+1"/>
<source>with &lt;B&gt;at least one&lt;/B&gt; of the words:</source>
<translation>mit &lt;B&gt;irgendeinem&lt;/B&gt; der Wörter:</translation>
</message>
</context>
<context>
<name>QHelpSearchResultWidget</name>
+ <message numerus="yes">
+ <location filename="../tools/assistant/lib/qhelpsearchresultwidget.cpp" line="+174"/>
+ <source>%1 - %2 of %n Hits</source>
+ <translation>
+ <numerusform>%1 - %2 - Ein Treffer</numerusform>
+ <numerusform>%1 - %2 von %n Treffern</numerusform>
+ </translation>
+ </message>
<message>
- <location filename="../tools/assistant/lib/qhelpsearchresultwidget.cpp" line="+235"/>
+ <location line="+61"/>
<source>0 - 0 of 0 Hits</source>
<translation>0 - 0 von 0 Treffern</translation>
</message>
</context>
-<context>
- <name>QHelpSearchResultWidgetPrivate</name>
- <message>
- <location line="-61"/>
- <source>%1 - %2 of %3 Hits</source>
- <translation>%1 - %2 von %3 Treffern</translation>
- </message>
-</context>
-<context>
- <name>QObject</name>
- <message>
- <location filename="../tools/assistant/lib/qhelpprojectdata.cpp" line="+85"/>
- <source>Unknown token.</source>
- <translation>Unbekanntes Token.</translation>
- </message>
- <message>
- <location line="+13"/>
- <source>Unknown token. Expected &quot;QtHelpProject&quot;!</source>
- <translation>Unbekanntes Token. &quot;QtHelpProject&quot; erwartet.</translation>
- </message>
- <message>
- <location line="+5"/>
- <source>Error in line %1: %2</source>
- <translation>Fehler in Zeile %1: %2</translation>
- </message>
- <message>
- <location line="+13"/>
- <source>A virtual folder must not contain a &apos;/&apos; character!</source>
- <translation>Ein virtuelles Verzeichnis darf kein &apos;/&apos;-Zeichen enthalten.</translation>
- </message>
- <message>
- <location line="+4"/>
- <source>A namespace must not contain a &apos;/&apos; character!</source>
- <translation>Ein Namensraum darf kein &apos;/&apos;-Zeichen enthalten.</translation>
- </message>
- <message>
- <location line="+16"/>
- <source>Missing namespace in QtHelpProject.</source>
- <translation>Fehlender Namensraum in QtHelpProject.</translation>
- </message>
- <message>
- <location line="+2"/>
- <source>Missing virtual folder in QtHelpProject</source>
- <translation>Fehlendes virtuelles Verzeichnis in QtHelpProject.</translation>
- </message>
- <message>
- <location line="+88"/>
- <source>Missing attribute in keyword at line %1.</source>
- <translation>Fehlendes Attribut in Schlagwort in Zeile %1.</translation>
- </message>
- <message>
- <location line="+123"/>
- <source>The input file %1 could not be opened!</source>
- <translation>Die Eingabe-Datei %1 kann nicht geöffnet werden.</translation>
- </message>
-</context>
</TS>
diff --git a/translations/translations.pri b/translations/translations.pri
index a8fb7ee51e..34da6b118e 100644
--- a/translations/translations.pri
+++ b/translations/translations.pri
@@ -58,7 +58,7 @@ ts-linguist.depends = sub-tools
ts-assistant.commands = (cd $$QT_SOURCE_TREE/src && $$LUPDATE \
../tools/assistant/translations/translations.pro \
&& $$LUPDATE \
- ../tools/assistant/translations/qt_help.pro))
+ ../tools/assistant/translations/qt_help.pro)
ts-assistant.depends = sub-tools
###### Qtconfig