aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore16
-rwxr-xr-xbin/rename-qtdeclarative-symbols.sh3
-rw-r--r--doc/config/qtquick.qdocconf3
-rw-r--r--doc/src/examples/examples-groups.qdoc29
-rw-r--r--doc/src/examples/examples-toys.qdoc7
-rw-r--r--doc/src/localstorage/localstorage.qdoc17
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml2
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml8
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml12
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml2
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml12
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml2
-rw-r--r--doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml2
-rw-r--r--doc/src/whatsnew.qdoc7
-rw-r--r--examples/HACKING23
-rw-r--r--examples/README12
-rw-r--r--examples/demos/calculator/CalculatorCore/Button.qml84
-rw-r--r--examples/demos/calculator/CalculatorCore/Display.qml68
-rw-r--r--examples/demos/calculator/CalculatorCore/calculator.js95
-rw-r--r--examples/demos/calculator/CalculatorCore/images/button-.pngbin0 -> 1288 bytes
-rw-r--r--examples/demos/calculator/CalculatorCore/images/button-blue.pngbin0 -> 1565 bytes
-rw-r--r--examples/demos/calculator/CalculatorCore/images/button-green.pngbin0 -> 1543 bytes
-rw-r--r--examples/demos/calculator/CalculatorCore/images/button-purple.pngbin0 -> 1566 bytes
-rw-r--r--examples/demos/calculator/CalculatorCore/images/button-red.pngbin0 -> 1586 bytes
-rw-r--r--examples/demos/calculator/CalculatorCore/images/display.pngbin0 -> 998 bytes
-rw-r--r--examples/demos/calculator/CalculatorCore/qmldir2
-rw-r--r--examples/demos/calculator/calculator-desktop.qml136
-rw-r--r--examples/demos/calculator/calculator-mobile.qml164
-rw-r--r--examples/demos/calculator/calculator.pro9
-rw-r--r--examples/demos/calculator/calculator.qdoc37
-rw-r--r--examples/demos/calculator/main.cpp66
-rw-r--r--examples/demos/clocks/clocks.qml88
-rw-r--r--examples/demos/clocks/content/Clock.qml143
-rw-r--r--examples/demos/clocks/content/QuitButton.qml52
-rw-r--r--examples/demos/clocks/content/arrow.pngbin0 -> 692 bytes
-rw-r--r--examples/demos/clocks/content/background.pngbin0 -> 46895 bytes
-rw-r--r--examples/demos/clocks/content/center.pngbin0 -> 765 bytes
-rw-r--r--examples/demos/clocks/content/clock-night.pngbin0 -> 23359 bytes
-rw-r--r--examples/demos/clocks/content/clock.pngbin0 -> 20653 bytes
-rw-r--r--examples/demos/clocks/content/hour.pngbin0 -> 625 bytes
-rw-r--r--examples/demos/clocks/content/minute.pngbin0 -> 625 bytes
-rw-r--r--examples/demos/clocks/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/demos/clocks/content/second.pngbin0 -> 303 bytes
-rw-r--r--examples/demos/demos.pro2
-rw-r--r--examples/demos/flickr/content/Button.qml79
-rw-r--r--examples/demos/flickr/content/GridDelegate.qml111
-rw-r--r--examples/demos/flickr/content/ImageDetails.qml323
-rw-r--r--examples/demos/flickr/content/ListDelegate.qml64
-rw-r--r--examples/demos/flickr/content/Progress.qml88
-rw-r--r--examples/demos/flickr/content/RssModel.qml64
-rw-r--r--examples/demos/flickr/content/ScrollBar.qml81
-rw-r--r--examples/demos/flickr/content/Slider.qml91
-rw-r--r--examples/demos/flickr/content/TitleBar.qml128
-rw-r--r--examples/demos/flickr/content/ToolBar.qml69
-rw-r--r--examples/demos/flickr/content/UnifiedDelegate.qml154
-rw-r--r--examples/demos/flickr/content/images/gloss.pngbin0 -> 1236 bytes
-rw-r--r--examples/demos/flickr/content/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/demos/flickr/content/images/lineedit.sci5
-rw-r--r--examples/demos/flickr/content/images/noise.pngbin0 -> 25447 bytes
-rw-r--r--examples/demos/flickr/content/images/particle.pngbin0 -> 5148 bytes
-rw-r--r--examples/demos/flickr/content/images/quit.pngbin0 -> 2369 bytes
-rw-r--r--examples/demos/flickr/content/images/squareParticle.pngbin0 -> 933 bytes
-rw-r--r--examples/demos/flickr/content/images/stripes.pngbin0 -> 257 bytes
-rw-r--r--examples/demos/flickr/content/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/demos/flickr/content/images/titlebar.sci5
-rw-r--r--examples/demos/flickr/content/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/demos/flickr/content/images/toolbutton.sci5
-rw-r--r--examples/demos/flickr/content/qmldir10
-rw-r--r--examples/demos/flickr/flickr-90.qml52
-rw-r--r--examples/demos/flickr/flickr.qml158
-rw-r--r--examples/demos/flickr/flickr.qmlproject17
-rw-r--r--examples/demos/minehunt/MinehuntCore/Explosion.qml69
-rw-r--r--examples/demos/minehunt/MinehuntCore/Tile.qml128
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/back.pngbin0 -> 558 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/background.pngbin0 -> 313930 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/bomb-color.pngbin0 -> 284 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/bomb.pngbin0 -> 535 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/face-sad.pngbin0 -> 14844 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/face-smile-big.pngbin0 -> 13810 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/flag-color.pngbin0 -> 219 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/flag.pngbin0 -> 196 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/front.pngbin0 -> 580 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/pics/star.pngbin0 -> 2677 bytes
-rw-r--r--examples/demos/minehunt/MinehuntCore/qmldir2
-rw-r--r--examples/demos/minehunt/README6
-rw-r--r--examples/demos/minehunt/main.cpp64
-rw-r--r--examples/demos/minehunt/minehunt.cpp221
-rw-r--r--examples/demos/minehunt/minehunt.h129
-rw-r--r--examples/demos/minehunt/minehunt.pro5
-rw-r--r--examples/demos/minehunt/minehunt.qml112
-rw-r--r--examples/demos/minehunt/minehunt.qmlproject16
-rw-r--r--examples/demos/minehunt/minehunt.qrc20
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml147
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml50
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/Button.qml72
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml86
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml188
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml57
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/RssModel.qml57
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/Tag.qml91
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.pngbin0 -> 588 bytes
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/images/cardboard.pngbin0 -> 8844 bytes
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/qmldir8
-rw-r--r--examples/demos/photoviewer/PhotoViewerCore/script/script.js27
-rw-r--r--examples/demos/photoviewer/i18n/base.ts30
-rw-r--r--examples/demos/photoviewer/i18n/qml_fr.qmbin0 -> 268 bytes
-rw-r--r--examples/demos/photoviewer/i18n/qml_fr.ts30
-rw-r--r--examples/demos/photoviewer/photoviewer.qml110
-rw-r--r--examples/demos/photoviewer/photoviewer.qmlproject20
-rw-r--r--examples/demos/plasmapatrol/PlasmaPatrol.qmlproject19
-rw-r--r--examples/demos/plasmapatrol/TODO10
-rw-r--r--examples/demos/plasmapatrol/content/BlasterHardpoint.qml133
-rw-r--r--examples/demos/plasmapatrol/content/Button.qml66
-rw-r--r--examples/demos/plasmapatrol/content/CannonHardpoint.qml97
-rw-r--r--examples/demos/plasmapatrol/content/ChoiceBox.qml105
-rw-r--r--examples/demos/plasmapatrol/content/Cruiser.qml146
-rw-r--r--examples/demos/plasmapatrol/content/Frigate.qml114
-rw-r--r--examples/demos/plasmapatrol/content/Hardpoint.qml114
-rw-r--r--examples/demos/plasmapatrol/content/HelpScreens.qml268
-rw-r--r--examples/demos/plasmapatrol/content/LaserHardpoint.qml108
-rw-r--r--examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml173
-rw-r--r--examples/demos/plasmapatrol/content/SequentialLoader.qml54
-rw-r--r--examples/demos/plasmapatrol/content/Ship.qml114
-rw-r--r--examples/demos/plasmapatrol/content/Sloop.qml108
-rw-r--r--examples/demos/plasmapatrol/content/pics/TitleText.pngbin0 -> 1109 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/blur-circle2.pngbin0 -> 3627 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/blur-circle3.pngbin0 -> 5148 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/finalfrontier.pngbin0 -> 695061 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/meteor.pngbin0 -> 83169 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/meteor_explo.pngbin0 -> 81528 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/nullRock.pngbin0 -> 140 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/star.pngbin0 -> 1550 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/star2.pngbin0 -> 6507 bytes
-rw-r--r--examples/demos/plasmapatrol/content/pics/star3.pngbin0 -> 4602 bytes
-rw-r--r--examples/demos/plasmapatrol/plasmapatrol.qml386
-rw-r--r--examples/demos/rssnews/content/BusyIndicator.qml53
-rw-r--r--examples/demos/rssnews/content/CategoryDelegate.qml82
-rw-r--r--examples/demos/rssnews/content/NewsDelegate.qml71
-rw-r--r--examples/demos/rssnews/content/RssFeeds.qml59
-rw-r--r--examples/demos/rssnews/content/ScrollBar.qml107
-rw-r--r--examples/demos/rssnews/content/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/demos/rssnews/content/images/scrollbar.pngbin0 -> 161 bytes
-rw-r--r--examples/demos/rssnews/rssnews.qml112
-rw-r--r--examples/demos/rssnews/rssnews.qmlproject16
-rw-r--r--examples/demos/samegame/content/BoomBlock.qml112
-rw-r--r--examples/demos/samegame/content/Button.qml75
-rw-r--r--examples/demos/samegame/content/Dialog.qml81
-rw-r--r--examples/demos/samegame/content/GameArea.qml92
-rw-r--r--examples/demos/samegame/content/NameInputDialog.qml93
-rw-r--r--examples/demos/samegame/content/pics/background.pngbin0 -> 313930 bytes
-rw-r--r--examples/demos/samegame/content/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--examples/demos/samegame/content/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--examples/demos/samegame/content/pics/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/demos/samegame/content/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--examples/demos/samegame/content/pics/yellowStone.pngbin0 -> 3056 bytes
-rwxr-xr-xexamples/demos/samegame/content/samegame.js290
-rw-r--r--examples/demos/samegame/samegame.qml87
-rw-r--r--examples/demos/samegame/samegame.qmlproject16
-rw-r--r--examples/demos/snake/content/Button.qml66
-rw-r--r--examples/demos/snake/content/Cookie.qml102
-rw-r--r--examples/demos/snake/content/HighScoreModel.qml140
-rw-r--r--examples/demos/snake/content/Link.qml129
-rw-r--r--examples/demos/snake/content/Skull.qml62
-rw-r--r--examples/demos/snake/content/pics/README1
-rw-r--r--examples/demos/snake/content/pics/background.pngbin0 -> 144508 bytes
-rw-r--r--examples/demos/snake/content/pics/blueStar.pngbin0 -> 272 bytes
-rw-r--r--examples/demos/snake/content/pics/blueStone.pngbin0 -> 3139 bytes
-rw-r--r--examples/demos/snake/content/pics/cookie.pngbin0 -> 2729 bytes
-rw-r--r--examples/demos/snake/content/pics/eyes.svg118
-rw-r--r--examples/demos/snake/content/pics/head.pngbin0 -> 3473 bytes
-rw-r--r--examples/demos/snake/content/pics/pause.pngbin0 -> 4327 bytes
-rw-r--r--examples/demos/snake/content/pics/redStar.pngbin0 -> 273 bytes
-rw-r--r--examples/demos/snake/content/pics/redStone.pngbin0 -> 3456 bytes
-rw-r--r--examples/demos/snake/content/pics/skull.pngbin0 -> 2543 bytes
-rw-r--r--examples/demos/snake/content/pics/snake.jpgbin0 -> 663901 bytes
-rw-r--r--examples/demos/snake/content/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/demos/snake/content/pics/stoneShadow.pngbin0 -> 1699 bytes
-rw-r--r--examples/demos/snake/content/pics/yellowStar.pngbin0 -> 276 bytes
-rw-r--r--examples/demos/snake/content/pics/yellowStone.pngbin0 -> 2667 bytes
-rw-r--r--examples/demos/snake/content/snake.js316
-rw-r--r--examples/demos/snake/snake.qml273
-rw-r--r--examples/demos/snake/snake.qmlproject16
-rw-r--r--examples/demos/tic-tac-toe/content/Button.qml79
-rw-r--r--examples/demos/tic-tac-toe/content/TicTac.qml60
-rw-r--r--examples/demos/tic-tac-toe/content/pics/board.pngbin0 -> 12258 bytes
-rw-r--r--examples/demos/tic-tac-toe/content/pics/o.pngbin0 -> 1470 bytes
-rw-r--r--examples/demos/tic-tac-toe/content/pics/x.pngbin0 -> 1331 bytes
-rw-r--r--examples/demos/tic-tac-toe/content/tic-tac-toe.js149
-rw-r--r--examples/demos/tic-tac-toe/tic-tac-toe.qml123
-rw-r--r--examples/demos/twitter/TwitterCore/Button.qml90
-rw-r--r--examples/demos/twitter/TwitterCore/FatDelegate.qml105
-rw-r--r--examples/demos/twitter/TwitterCore/Input.qml65
-rw-r--r--examples/demos/twitter/TwitterCore/Loading.qml49
-rw-r--r--examples/demos/twitter/TwitterCore/MultiTitleBar.qml60
-rw-r--r--examples/demos/twitter/TwitterCore/RssModel.qml80
-rw-r--r--examples/demos/twitter/TwitterCore/SearchView.qml124
-rw-r--r--examples/demos/twitter/TwitterCore/TitleBar.qml130
-rw-r--r--examples/demos/twitter/TwitterCore/ToolBar.qml64
-rw-r--r--examples/demos/twitter/TwitterCore/UserModel.qml66
-rw-r--r--examples/demos/twitter/TwitterCore/images/gloss.pngbin0 -> 1236 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/lineedit.sci5
-rw-r--r--examples/demos/twitter/TwitterCore/images/loading.pngbin0 -> 813 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/quit.pngbin0 -> 2369 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/stripes.pngbin0 -> 257 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/titlebar.sci5
-rw-r--r--examples/demos/twitter/TwitterCore/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/demos/twitter/TwitterCore/images/toolbutton.sci5
-rw-r--r--examples/demos/twitter/TwitterCore/qmldir10
-rw-r--r--examples/demos/twitter/twitter.qml135
-rw-r--r--examples/demos/twitter/twitter.qmlproject16
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/localstorage/hello.qml78
-rw-r--r--examples/localstorage/localstorage.pro1
-rw-r--r--examples/particles/affectors/age.qml97
-rw-r--r--examples/particles/affectors/attractor.qml213
-rw-r--r--examples/particles/affectors/customaffector.qml173
-rw-r--r--examples/particles/affectors/friction.qml109
-rw-r--r--examples/particles/affectors/gravity.qml103
-rw-r--r--examples/particles/affectors/groupgoal.qml193
-rw-r--r--examples/particles/affectors/move.qml141
-rw-r--r--examples/particles/affectors/spritegoal.qml212
-rw-r--r--examples/particles/affectors/turbulence.qml135
-rw-r--r--examples/particles/affectors/wander.qml95
-rw-r--r--examples/particles/customparticle/blurparticles.qml140
-rw-r--r--examples/particles/customparticle/fragmentshader.qml115
-rw-r--r--examples/particles/customparticle/imagecolors.qml118
-rw-r--r--examples/particles/emitters/burstandpulse.qml84
-rw-r--r--examples/particles/emitters/customemitter.qml92
-rw-r--r--examples/particles/emitters/emitmask.qml72
-rw-r--r--examples/particles/emitters/maximumemitted.qml81
-rw-r--r--examples/particles/emitters/shapeanddirection.qml112
-rw-r--r--examples/particles/emitters/timedgroupchanges.qml121
-rw-r--r--examples/particles/emitters/trailemitter.qml175
-rw-r--r--examples/particles/emitters/velocityfrommotion.qml311
-rw-r--r--examples/particles/exampleslauncher/content/Button.qml73
-rw-r--r--examples/particles/exampleslauncher/content/Shell.qml78
-rw-r--r--examples/particles/exampleslauncher/content/launcher.js8
-rw-r--r--examples/particles/exampleslauncher/exampleslauncher.qml116
-rw-r--r--examples/particles/imageparticle/allatonce.qml98
-rw-r--r--examples/particles/imageparticle/colored.qml86
-rw-r--r--examples/particles/imageparticle/colortable.qml84
-rw-r--r--examples/particles/imageparticle/deformation.qml121
-rw-r--r--examples/particles/imageparticle/rotation.qml71
-rw-r--r--examples/particles/imageparticle/sharing.qml199
-rw-r--r--examples/particles/imageparticle/sprites.qml116
-rw-r--r--examples/particles/images/_explo.pngbin0 -> 81528 bytes
-rwxr-xr-xexamples/particles/images/backgroundLeaves.jpgbin0 -> 78665 bytes
-rw-r--r--examples/particles/images/bear_tiles.pngbin0 -> 40349 bytes
-rw-r--r--examples/particles/images/candle.pngbin0 -> 1348 bytes
-rw-r--r--examples/particles/images/colortable.pngbin0 -> 704 bytes
-rw-r--r--examples/particles/images/finalfrontier.pngbin0 -> 695061 bytes
-rw-r--r--examples/particles/images/flower.pngbin0 -> 4683 bytes
-rw-r--r--examples/particles/images/launcherIcons/allatonce.pngbin0 -> 7075 bytes
-rw-r--r--examples/particles/images/launcherIcons/attractor.pngbin0 -> 31296 bytes
-rw-r--r--examples/particles/images/launcherIcons/blurparticles.pngbin0 -> 19109 bytes
-rw-r--r--examples/particles/images/launcherIcons/close.pngbin0 -> 2144 bytes
-rw-r--r--examples/particles/images/launcherIcons/colortable.pngbin0 -> 6538 bytes
-rw-r--r--examples/particles/images/launcherIcons/customaffector.pngbin0 -> 10350 bytes
-rw-r--r--examples/particles/images/launcherIcons/customemitter.pngbin0 -> 22967 bytes
-rw-r--r--examples/particles/images/launcherIcons/deformation.pngbin0 -> 2870 bytes
-rw-r--r--examples/particles/images/launcherIcons/delegates.pngbin0 -> 1892 bytes
-rw-r--r--examples/particles/images/launcherIcons/dynamicemitters.pngbin0 -> 9347 bytes
-rw-r--r--examples/particles/images/launcherIcons/emitmask.pngbin0 -> 45055 bytes
-rw-r--r--examples/particles/images/launcherIcons/flickr.pngbin0 -> 10542 bytes
-rw-r--r--examples/particles/images/launcherIcons/fragmentshader.pngbin0 -> 22294 bytes
-rw-r--r--examples/particles/images/launcherIcons/gridsplosion.pngbin0 -> 8154 bytes
-rw-r--r--examples/particles/images/launcherIcons/groupgoal.pngbin0 -> 7173 bytes
-rw-r--r--examples/particles/images/launcherIcons/imagecolors.pngbin0 -> 56647 bytes
-rw-r--r--examples/particles/images/launcherIcons/list.pngbin0 -> 32912 bytes
-rw-r--r--examples/particles/images/launcherIcons/maximumemitted.pngbin0 -> 1019 bytes
-rw-r--r--examples/particles/images/launcherIcons/multiplepainters.pngbin0 -> 8572 bytes
-rw-r--r--examples/particles/images/launcherIcons/package.pngbin0 -> 3163 bytes
-rw-r--r--examples/particles/images/launcherIcons/particleview.pngbin0 -> 26560 bytes
-rw-r--r--examples/particles/images/launcherIcons/plasmapatrol.pngbin0 -> 9839 bytes
-rw-r--r--examples/particles/images/launcherIcons/remove.pngbin0 -> 2144 bytes
-rw-r--r--examples/particles/images/launcherIcons/rotation.pngbin0 -> 20661 bytes
-rw-r--r--examples/particles/images/launcherIcons/samegame.pngbin0 -> 8647 bytes
-rw-r--r--examples/particles/images/launcherIcons/shapeanddirection.pngbin0 -> 11359 bytes
-rw-r--r--examples/particles/images/launcherIcons/spaceexplorer.pngbin0 -> 9152 bytes
-rw-r--r--examples/particles/images/launcherIcons/spritegoal.pngbin0 -> 35579 bytes
-rw-r--r--examples/particles/images/launcherIcons/sprites.pngbin0 -> 17009 bytes
-rw-r--r--examples/particles/images/launcherIcons/spritevariedparticles.pngbin0 -> 2569 bytes
-rw-r--r--examples/particles/images/launcherIcons/startstop.pngbin0 -> 13670 bytes
-rw-r--r--examples/particles/images/launcherIcons/timedgroupchanges.pngbin0 -> 16139 bytes
-rw-r--r--examples/particles/images/launcherIcons/trailemitter.pngbin0 -> 5371 bytes
-rw-r--r--examples/particles/images/launcherIcons/trails.pngbin0 -> 23168 bytes
-rw-r--r--examples/particles/images/launcherIcons/turbulence.pngbin0 -> 9684 bytes
-rw-r--r--examples/particles/images/launcherIcons/velocityfrommotion.pngbin0 -> 36360 bytes
-rw-r--r--examples/particles/images/launcherIcons/wander.pngbin0 -> 5858 bytes
-rw-r--r--examples/particles/images/matchmask.pngbin0 -> 2369 bytes
-rw-r--r--examples/particles/images/meteor.pngbin0 -> 83169 bytes
-rw-r--r--examples/particles/images/meteor_explo.pngbin0 -> 219946 bytes
-rw-r--r--examples/particles/images/meteors.pngbin0 -> 132137 bytes
-rw-r--r--examples/particles/images/nullRock.pngbin0 -> 140 bytes
-rw-r--r--examples/particles/images/particle.pngbin0 -> 861 bytes
-rw-r--r--examples/particles/images/particle2.pngbin0 -> 3909 bytes
-rw-r--r--examples/particles/images/particle3.pngbin0 -> 3186 bytes
-rw-r--r--examples/particles/images/particle4.pngbin0 -> 1799 bytes
-rw-r--r--examples/particles/images/particleA.pngbin0 -> 3541 bytes
-rw-r--r--examples/particles/images/portal_bg.pngbin0 -> 96858 bytes
-rw-r--r--examples/particles/images/realLeaf1.pngbin0 -> 15625 bytes
-rw-r--r--examples/particles/images/realLeaf2.pngbin0 -> 13660 bytes
-rw-r--r--examples/particles/images/realLeaf3.pngbin0 -> 23809 bytes
-rw-r--r--examples/particles/images/realLeaf4.pngbin0 -> 23655 bytes
-rw-r--r--examples/particles/images/rocket.pngbin0 -> 7315 bytes
-rw-r--r--examples/particles/images/rocket2.pngbin0 -> 1918 bytes
-rw-r--r--examples/particles/images/sizeInOut.pngbin0 -> 251 bytes
-rw-r--r--examples/particles/images/snowflake.pngbin0 -> 189327 bytes
-rw-r--r--examples/particles/images/sparkleSize.pngbin0 -> 378 bytes
-rw-r--r--examples/particles/images/star.pngbin0 -> 1550 bytes
-rw-r--r--examples/particles/images/starfish_0.pngbin0 -> 15972 bytes
-rw-r--r--examples/particles/images/starfish_1.pngbin0 -> 15746 bytes
-rw-r--r--examples/particles/images/starfish_2.pngbin0 -> 16067 bytes
-rw-r--r--examples/particles/images/starfish_3.pngbin0 -> 16201 bytes
-rw-r--r--examples/particles/images/starfish_4.pngbin0 -> 14698 bytes
-rw-r--r--examples/particles/images/starfish_mask.pngbin0 -> 11301 bytes
-rw-r--r--examples/particles/itemparticle/content/Delegate.qml88
-rw-r--r--examples/particles/itemparticle/content/Delegate2.qml79
-rw-r--r--examples/particles/itemparticle/content/ExpandingDelegate.qml204
-rw-r--r--examples/particles/itemparticle/content/RssModel.qml56
-rw-r--r--examples/particles/itemparticle/content/bubble.pngbin0 -> 3413 bytes
-rw-r--r--examples/particles/itemparticle/content/script.js27
-rw-r--r--examples/particles/itemparticle/delegates.qml91
-rw-r--r--examples/particles/itemparticle/particleview.qml274
-rw-r--r--examples/particles/particles.pro1
-rw-r--r--examples/particles/simple/dynamiccomparison.qml126
-rw-r--r--examples/particles/simple/dynamicemitters.qml122
-rw-r--r--examples/particles/simple/multiplepainters.qml90
-rw-r--r--examples/particles/simple/startstop.qml81
-rw-r--r--examples/qml/cppextensions/imageprovider/imageprovider.cpp6
-rw-r--r--examples/qml/cppextensions/imageprovider/imageprovider.json1
-rw-r--r--examples/qml/cppextensions/imageprovider/imageprovider.pro2
-rw-r--r--examples/qml/cppextensions/plugins/plugin.cpp6
-rw-r--r--examples/qml/cppextensions/plugins/plugin.json1
-rw-r--r--examples/qml/cppextensions/plugins/plugins.pro8
-rw-r--r--examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp2
-rw-r--r--examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp2
-rw-r--r--examples/qml/dynamicscene/content/Button.qml80
-rw-r--r--examples/qml/dynamicscene/content/GenericSceneItem.qml49
-rw-r--r--examples/qml/dynamicscene/content/PaletteItem.qml59
-rw-r--r--examples/qml/dynamicscene/content/PerspectiveItem.qml65
-rw-r--r--examples/qml/dynamicscene/content/Sun.qml78
-rw-r--r--examples/qml/dynamicscene/content/images/NOTE1
-rw-r--r--examples/qml/dynamicscene/content/images/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/qml/dynamicscene/content/images/moon.pngbin0 -> 1757 bytes
-rw-r--r--examples/qml/dynamicscene/content/images/rabbit_brown.pngbin0 -> 1245 bytes
-rw-r--r--examples/qml/dynamicscene/content/images/rabbit_bw.pngbin0 -> 1759 bytes
-rw-r--r--examples/qml/dynamicscene/content/images/star.pngbin0 -> 349 bytes
-rw-r--r--examples/qml/dynamicscene/content/images/sun.pngbin0 -> 8153 bytes
-rw-r--r--examples/qml/dynamicscene/content/images/tree_s.pngbin0 -> 3406 bytes
-rw-r--r--examples/qml/dynamicscene/content/itemCreation.js62
-rw-r--r--examples/qml/dynamicscene/dynamicscene.qml275
-rw-r--r--examples/qml/qml.pro37
-rw-r--r--examples/qml/xmlhttprequest/data.xml5
-rw-r--r--examples/qml/xmlhttprequest/xmlhttprequest-example.qml95
-rw-r--r--examples/quick/accessibility/accessibility.pro10
-rw-r--r--examples/quick/accessibility/accessibility.qml110
-rw-r--r--examples/quick/accessibility/accessibility.qmlproject16
-rw-r--r--examples/quick/accessibility/content/Button.qml80
-rw-r--r--examples/quick/accessibility/main.cpp41
-rw-r--r--examples/quick/animation/animation.pro10
-rw-r--r--examples/quick/animation/animation.qml93
-rw-r--r--examples/quick/animation/animation.qmlproject16
-rw-r--r--examples/quick/animation/basics/color-animation.qml121
-rw-r--r--examples/quick/animation/basics/images/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/quick/animation/basics/images/moon.pngbin0 -> 2433 bytes
-rw-r--r--examples/quick/animation/basics/images/shadow.pngbin0 -> 425 bytes
-rw-r--r--examples/quick/animation/basics/images/star.pngbin0 -> 349 bytes
-rw-r--r--examples/quick/animation/basics/images/sun.pngbin0 -> 8153 bytes
-rw-r--r--examples/quick/animation/basics/property-animation.qml105
-rw-r--r--examples/quick/animation/behaviors/SideRect.qml62
-rw-r--r--examples/quick/animation/behaviors/behavior-example.qml118
-rw-r--r--examples/quick/animation/behaviors/tvtennis.qml109
-rw-r--r--examples/quick/animation/behaviors/wigglytext.qml108
-rw-r--r--examples/quick/animation/easing/content/QuitButton.qml52
-rw-r--r--examples/quick/animation/easing/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/animation/easing/easing.qml157
-rw-r--r--examples/quick/animation/main.cpp41
-rw-r--r--examples/quick/animation/pathanimation/pathanimation.qml105
-rw-r--r--examples/quick/animation/pathinterpolator/pathinterpolator.qml112
-rw-r--r--examples/quick/animation/states/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/quick/animation/states/states.qml101
-rw-r--r--examples/quick/animation/states/transitions.qml130
-rw-r--r--examples/quick/canvas/bezierCurve/bezierCurve.qml124
-rw-r--r--examples/quick/canvas/clip/clip.qml150
-rw-r--r--examples/quick/canvas/contents/Button.qml87
-rw-r--r--examples/quick/canvas/contents/ScrollBar.qml74
-rw-r--r--examples/quick/canvas/contents/Slider.qml115
-rw-r--r--examples/quick/canvas/contents/Stocks.qml147
-rw-r--r--examples/quick/canvas/contents/TitleBar.qml70
-rw-r--r--examples/quick/canvas/contents/ToolBar.qml69
-rw-r--r--examples/quick/canvas/contents/images/button-pressed.pngbin0 -> 571 bytes
-rw-r--r--examples/quick/canvas/contents/images/button.pngbin0 -> 564 bytes
-rw-r--r--examples/quick/canvas/contents/images/default.svg82
-rwxr-xr-xexamples/quick/canvas/contents/images/gloss.pngbin0 -> 1236 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/lineedit.pngbin0 -> 1415 bytes
-rw-r--r--examples/quick/canvas/contents/images/lineedit.sci5
-rwxr-xr-xexamples/quick/canvas/contents/images/quit.pngbin0 -> 2369 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/stripes.pngbin0 -> 257 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/titlebar.pngbin0 -> 1436 bytes
-rw-r--r--examples/quick/canvas/contents/images/titlebar.sci5
-rwxr-xr-xexamples/quick/canvas/contents/images/toolbutton.pngbin0 -> 2550 bytes
-rw-r--r--examples/quick/canvas/contents/images/toolbutton.sci5
-rw-r--r--examples/quick/canvas/contents/qt-logo.pngbin0 -> 23519 bytes
-rw-r--r--examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml128
-rw-r--r--examples/quick/canvas/roundedrect/roundedrect.qml125
-rw-r--r--examples/quick/canvas/smile/smile.qml128
-rw-r--r--examples/quick/canvas/squircle/squircle.pngbin0 -> 771 bytes
-rw-r--r--examples/quick/canvas/squircle/squircle.qml155
-rw-r--r--examples/quick/canvas/stockchart/README5
-rw-r--r--examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir1
-rw-r--r--examples/quick/canvas/stockchart/model.cpp255
-rw-r--r--examples/quick/canvas/stockchart/model.h166
-rw-r--r--examples/quick/canvas/stockchart/plugin.cpp60
-rw-r--r--examples/quick/canvas/stockchart/stock.qml726
-rw-r--r--examples/quick/canvas/stockchart/stockchart.pro20
-rw-r--r--examples/quick/canvas/tiger/tiger.js721
-rw-r--r--examples/quick/canvas/tiger/tiger.qml129
-rw-r--r--examples/quick/canvas/twitterfriends/TwitterUser.qml294
-rw-r--r--examples/quick/canvas/twitterfriends/cache.js42
-rw-r--r--examples/quick/canvas/twitterfriends/twitter.qml141
-rw-r--r--examples/quick/draganddrop/draganddrop.pro10
-rw-r--r--examples/quick/draganddrop/draganddrop.qml68
-rw-r--r--examples/quick/draganddrop/draganddrop.qmlproject16
-rw-r--r--examples/quick/draganddrop/main.cpp41
-rw-r--r--examples/quick/draganddrop/tiles/DragTile.qml90
-rw-r--r--examples/quick/draganddrop/tiles/DropTile.qml68
-rw-r--r--examples/quick/draganddrop/tiles/tiles.qml109
-rw-r--r--examples/quick/draganddrop/views/gridview.qml129
-rw-r--r--examples/quick/imageelements/animatedsprite.qml76
-rw-r--r--examples/quick/imageelements/borderimage.qml119
-rw-r--r--examples/quick/imageelements/content/BearSheet.pngbin0 -> 406337 bytes
-rw-r--r--examples/quick/imageelements/content/BorderImageSelector.qml96
-rw-r--r--examples/quick/imageelements/content/ImageCell.qml60
-rw-r--r--examples/quick/imageelements/content/MyBorderImage.qml90
-rw-r--r--examples/quick/imageelements/content/ShadowRectangle.qml54
-rw-r--r--examples/quick/imageelements/content/bw.pngbin0 -> 1357 bytes
-rw-r--r--examples/quick/imageelements/content/colors-round.sci7
-rw-r--r--examples/quick/imageelements/content/colors-stretch.sci5
-rw-r--r--examples/quick/imageelements/content/colors.pngbin0 -> 1655 bytes
-rw-r--r--examples/quick/imageelements/content/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/quick/imageelements/content/shadow.pngbin0 -> 588 bytes
-rw-r--r--examples/quick/imageelements/content/speaker.pngbin0 -> 784525 bytes
-rw-r--r--examples/quick/imageelements/image.qml66
-rw-r--r--examples/quick/imageelements/imageelements.pro10
-rw-r--r--examples/quick/imageelements/imageelements.qml77
-rw-r--r--examples/quick/imageelements/imageelements.qmlproject16
-rw-r--r--examples/quick/imageelements/main.cpp41
-rw-r--r--examples/quick/imageelements/shadows.qml64
-rw-r--r--examples/quick/imageelements/spritesequence.qml116
-rw-r--r--examples/quick/keyinteraction/focus/Core/ContextMenu.qml65
-rw-r--r--examples/quick/keyinteraction/focus/Core/GridMenu.qml105
-rw-r--r--examples/quick/keyinteraction/focus/Core/ListMenu.qml105
-rw-r--r--examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml85
-rw-r--r--examples/quick/keyinteraction/focus/Core/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/keyinteraction/focus/Core/images/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/quick/keyinteraction/focus/focus.qml111
-rw-r--r--examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro10
-rw-r--r--examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc6
-rw-r--r--examples/quick/modelviews/abstractitemmodel/main.cpp70
-rw-r--r--examples/quick/modelviews/abstractitemmodel/model.cpp90
-rw-r--r--examples/quick/modelviews/abstractitemmodel/model.h83
-rw-r--r--examples/quick/modelviews/abstractitemmodel/view.qml50
-rw-r--r--examples/quick/modelviews/gridview/gridview-example.qml93
-rw-r--r--examples/quick/modelviews/gridview/pics/AddressBook_48.pngbin0 -> 3350 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/AudioPlayer_48.pngbin0 -> 3806 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/Camera_48.pngbin0 -> 3540 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/DateBook_48.pngbin0 -> 2610 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/EMail_48.pngbin0 -> 3655 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/TodoList_48.pngbin0 -> 3429 bytes
-rw-r--r--examples/quick/modelviews/gridview/pics/VideoPlayer_48.pngbin0 -> 4151 bytes
-rw-r--r--examples/quick/modelviews/listview/content/PetsModel.qml98
-rw-r--r--examples/quick/modelviews/listview/content/PressAndHoldButton.qml82
-rw-r--r--examples/quick/modelviews/listview/content/RecipesModel.qml129
-rw-r--r--examples/quick/modelviews/listview/content/TextButton.qml78
-rw-r--r--examples/quick/modelviews/listview/content/ToggleButton.qml58
-rw-r--r--examples/quick/modelviews/listview/content/pics/arrow-down.pngbin0 -> 594 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/arrow-up.pngbin0 -> 692 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/fruit-salad.jpgbin0 -> 17952 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/hamburger.jpgbin0 -> 8572 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/lemonade.jpgbin0 -> 6645 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/list-delete.pngbin0 -> 831 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/minus-sign.pngbin0 -> 250 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/moreDown.pngbin0 -> 217 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/moreUp.pngbin0 -> 212 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/pancakes.jpgbin0 -> 9163 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/plus-sign.pngbin0 -> 462 bytes
-rw-r--r--examples/quick/modelviews/listview/content/pics/vegetable-soup.jpgbin0 -> 8639 bytes
-rw-r--r--examples/quick/modelviews/listview/dynamiclist.qml203
-rw-r--r--examples/quick/modelviews/listview/expandingdelegates.qml202
-rw-r--r--examples/quick/modelviews/listview/highlight.qml99
-rw-r--r--examples/quick/modelviews/listview/highlightranges.qml122
-rw-r--r--examples/quick/modelviews/listview/sections.qml127
-rw-r--r--examples/quick/modelviews/modelviews.pro8
-rw-r--r--examples/quick/modelviews/modelviews.qml64
-rw-r--r--examples/quick/modelviews/modelviews.qmlproject16
-rw-r--r--examples/quick/modelviews/objectlistmodel/dataobject.cpp78
-rw-r--r--examples/quick/modelviews/objectlistmodel/dataobject.h76
-rw-r--r--examples/quick/modelviews/objectlistmodel/main.cpp78
-rw-r--r--examples/quick/modelviews/objectlistmodel/objectlistmodel.pro6
-rw-r--r--examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject14
-rw-r--r--examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc5
-rw-r--r--examples/quick/modelviews/objectlistmodel/view.qml55
-rw-r--r--examples/quick/modelviews/package/Delegate.qml88
-rw-r--r--examples/quick/modelviews/package/view.qml80
-rw-r--r--examples/quick/modelviews/parallax/content/Clock.qml143
-rw-r--r--examples/quick/modelviews/parallax/content/ParallaxView.qml123
-rw-r--r--examples/quick/modelviews/parallax/content/QuitButton.qml52
-rw-r--r--examples/quick/modelviews/parallax/content/Smiley.qml84
-rw-r--r--examples/quick/modelviews/parallax/content/background.pngbin0 -> 46895 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/center.pngbin0 -> 765 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/clock-night.pngbin0 -> 23359 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/clock.pngbin0 -> 20653 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/hour.pngbin0 -> 625 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/minute.pngbin0 -> 625 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/background.jpgbin0 -> 209814 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/home-page.pngbin0 -> 3051 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/home-page.svg445
-rw-r--r--examples/quick/modelviews/parallax/content/pics/shadow.pngbin0 -> 425 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/yast-joystick.pngbin0 -> 2723 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/pics/yast-wol.pngbin0 -> 3769 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/modelviews/parallax/content/second.pngbin0 -> 303 bytes
-rw-r--r--examples/quick/modelviews/parallax/parallax.qml76
-rw-r--r--examples/quick/modelviews/pathview/pathview-example.qml107
-rw-r--r--examples/quick/modelviews/pathview/pics/AddressBook_48.pngbin0 -> 3350 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/AudioPlayer_48.pngbin0 -> 3806 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/Camera_48.pngbin0 -> 3540 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/DateBook_48.pngbin0 -> 2610 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/EMail_48.pngbin0 -> 3655 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/TodoList_48.pngbin0 -> 3429 bytes
-rw-r--r--examples/quick/modelviews/pathview/pics/VideoPlayer_48.pngbin0 -> 4151 bytes
-rw-r--r--examples/quick/modelviews/stringlistmodel/main.cpp77
-rw-r--r--examples/quick/modelviews/stringlistmodel/stringlistmodel.pro4
-rw-r--r--examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc5
-rw-r--r--examples/quick/modelviews/stringlistmodel/view.qml54
-rw-r--r--examples/quick/modelviews/visualdatamodel/dragselection.qml200
-rw-r--r--examples/quick/modelviews/visualdatamodel/slideshow.qml156
-rw-r--r--examples/quick/modelviews/visualdatamodel/sortedmodel.qml141
-rw-r--r--examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject14
-rw-r--r--examples/quick/modelviews/visualitemmodel/visualitemmodel.qml116
-rw-r--r--examples/quick/mousearea/mousearea-example.qml176
-rw-r--r--examples/quick/openglunderqml/main.cpp60
-rw-r--r--examples/quick/openglunderqml/main.qml78
-rw-r--r--examples/quick/openglunderqml/openglunderqml.pro6
-rw-r--r--examples/quick/openglunderqml/squircle.cpp123
-rw-r--r--examples/quick/openglunderqml/squircle.h76
-rw-r--r--examples/quick/painteditem/painteditem.pro5
-rw-r--r--examples/quick/painteditem/smile/main.cpp96
-rw-r--r--examples/quick/painteditem/smile/smile.pro11
-rw-r--r--examples/quick/painteditem/smile/smile.qml132
-rw-r--r--examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h55
-rw-r--r--examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir1
-rw-r--r--examples/quick/painteditem/textballoons/textballoon.cpp92
-rw-r--r--examples/quick/painteditem/textballoons/textballoon.h68
-rw-r--r--examples/quick/painteditem/textballoons/textballoon.json1
-rw-r--r--examples/quick/painteditem/textballoons/textballoons.pro25
-rw-r--r--examples/quick/painteditem/textballoons/textballoons.qml110
-rw-r--r--examples/quick/positioners/content/Button.qml78
-rw-r--r--examples/quick/positioners/content/add.pngbin0 -> 810 bytes
-rw-r--r--examples/quick/positioners/content/del.pngbin0 -> 488 bytes
-rw-r--r--examples/quick/positioners/positioners-attachedproperties.qml106
-rw-r--r--examples/quick/positioners/positioners.qml268
-rw-r--r--examples/quick/quick.pro17
-rw-r--r--examples/quick/righttoleft/layoutdirection/layoutdirection.qml246
-rw-r--r--examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject16
-rw-r--r--examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml313
-rw-r--r--examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject16
-rw-r--r--examples/quick/righttoleft/textalignment/textalignment.qml427
-rw-r--r--examples/quick/righttoleft/textalignment/textalignment.qmlproject16
-rw-r--r--examples/quick/shadereffects/content/Slider.qml93
-rw-r--r--examples/quick/shadereffects/content/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/quick/shadereffects/content/qt-logo.pngbin0 -> 13923 bytes
-rw-r--r--examples/quick/shadereffects/shadereffects.qml315
-rw-r--r--examples/quick/text/fonts/availableFonts.qml57
-rw-r--r--examples/quick/text/fonts/banner.qml61
-rw-r--r--examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttfbin0 -> 24544 bytes
-rw-r--r--examples/quick/text/fonts/fonts.qml104
-rw-r--r--examples/quick/text/fonts/hello.qml79
-rw-r--r--examples/quick/text/imgtag/TextWithImage.qml55
-rw-r--r--examples/quick/text/imgtag/images/face-sad.pngbin0 -> 6148 bytes
-rw-r--r--examples/quick/text/imgtag/images/face-smile-big.pngbin0 -> 6058 bytes
-rw-r--r--examples/quick/text/imgtag/images/face-smile.pngbin0 -> 6446 bytes
-rw-r--r--examples/quick/text/imgtag/images/heart200.pngbin0 -> 8248 bytes
-rw-r--r--examples/quick/text/imgtag/images/qtlogo.pngbin0 -> 6450 bytes
-rw-r--r--examples/quick/text/imgtag/images/starfish_2.pngbin0 -> 18243 bytes
-rw-r--r--examples/quick/text/imgtag/imgtag.qml101
-rw-r--r--examples/quick/text/styledtext-layout.qml107
-rw-r--r--examples/quick/text/text.qml57
-rw-r--r--examples/quick/text/text.qmlproject16
-rw-r--r--examples/quick/text/textselection/pics/endHandle.pngbin0 -> 185 bytes
-rw-r--r--examples/quick/text/textselection/pics/endHandle.sci5
-rw-r--r--examples/quick/text/textselection/pics/startHandle.pngbin0 -> 178 bytes
-rw-r--r--examples/quick/text/textselection/pics/startHandle.sci5
-rw-r--r--examples/quick/text/textselection/textselection.qml211
-rw-r--r--examples/quick/threading/threadedlistmodel/dataloader.js49
-rw-r--r--examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject56
-rw-r--r--examples/quick/threading/threadedlistmodel/timedisplay.qml76
-rw-r--r--examples/quick/threading/workerscript/workerscript.js15
-rw-r--r--examples/quick/threading/workerscript/workerscript.qml83
-rw-r--r--examples/quick/threading/workerscript/workerscript.qmlproject16
-rw-r--r--examples/quick/touchinteraction/flickable/content/Day.qml153
-rw-r--r--examples/quick/touchinteraction/flickable/content/cork.jpgbin0 -> 149337 bytes
-rw-r--r--examples/quick/touchinteraction/flickable/content/note-yellow.pngbin0 -> 54559 bytes
-rw-r--r--examples/quick/touchinteraction/flickable/content/tack.pngbin0 -> 7282 bytes
-rw-r--r--examples/quick/touchinteraction/flickable/corkboards.qml116
-rw-r--r--examples/quick/touchinteraction/multipointtouch/bearwhack.qml133
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml70
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear0.pngbin0 -> 15163 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear1.pngbin0 -> 99378 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear2.pngbin0 -> 80759 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/Bear3.pngbin0 -> 21122 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/BearB.pngbin0 -> 18667 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml180
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml65
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/blur-circle.pngbin0 -> 4279 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/blur-circle3.pngbin0 -> 5148 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/heart-blur.pngbin0 -> 5406 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/content/title.pngbin0 -> 81252 bytes
-rw-r--r--examples/quick/touchinteraction/multipointtouch/multiflame.qml91
-rw-r--r--examples/quick/touchinteraction/pincharea/flickresize.qml97
-rw-r--r--examples/quick/touchinteraction/pincharea/qt-logo.jpgbin0 -> 40886 bytes
-rw-r--r--examples/quick/touchinteraction/touchinteraction.qml56
-rw-r--r--examples/quick/touchinteraction/touchinteraction.qmlproject16
-rw-r--r--examples/shared/Button.qml64
-rw-r--r--examples/shared/LauncherList.qml102
-rw-r--r--examples/shared/README11
-rw-r--r--examples/shared/SimpleLauncherDelegate.qml53
-rw-r--r--examples/shared/images/back.pngbin0 -> 404 bytes
-rw-r--r--examples/shared/qmldir3
-rw-r--r--examples/shared/shared.h49
-rw-r--r--examples/shared/shared.pro9
-rw-r--r--examples/tutorials/dynamicview/dynamicview1/PetsModel.qml102
-rw-r--r--examples/tutorials/dynamicview/dynamicview1/dynamicview.qml90
-rw-r--r--examples/tutorials/dynamicview/dynamicview2/PetsModel.qml98
-rw-r--r--examples/tutorials/dynamicview/dynamicview2/dynamicview.qml121
-rw-r--r--examples/tutorials/dynamicview/dynamicview3/PetsModel.qml98
-rw-r--r--examples/tutorials/dynamicview/dynamicview3/dynamicview.qml143
-rw-r--r--examples/tutorials/dynamicview/dynamicview4/ListSelector.qml120
-rw-r--r--examples/tutorials/dynamicview/dynamicview4/PetsModel.qml98
-rw-r--r--examples/tutorials/dynamicview/dynamicview4/dynamicview.qml219
-rw-r--r--examples/tutorials/extending/chapter1-basics/app.qml60
-rw-r--r--examples/tutorials/extending/chapter1-basics/chapter1-basics.pro5
-rw-r--r--examples/tutorials/extending/chapter1-basics/main.cpp57
-rw-r--r--examples/tutorials/extending/chapter1-basics/piechart.cpp79
-rw-r--r--examples/tutorials/extending/chapter1-basics/piechart.h71
-rw-r--r--examples/tutorials/extending/chapter2-methods/app.qml66
-rw-r--r--examples/tutorials/extending/chapter2-methods/chapter2-methods.pro5
-rw-r--r--examples/tutorials/extending/chapter2-methods/main.cpp57
-rw-r--r--examples/tutorials/extending/chapter2-methods/piechart.cpp84
-rw-r--r--examples/tutorials/extending/chapter2-methods/piechart.h84
-rw-r--r--examples/tutorials/extending/chapter3-bindings/app.qml74
-rw-r--r--examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro5
-rw-r--r--examples/tutorials/extending/chapter3-bindings/main.cpp57
-rw-r--r--examples/tutorials/extending/chapter3-bindings/piechart.cpp86
-rw-r--r--examples/tutorials/extending/chapter3-bindings/piechart.h84
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/app.qml60
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro7
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp66
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp70
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h78
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp66
-rw-r--r--examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h66
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/app.qml70
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro7
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/main.cpp58
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/piechart.cpp72
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/piechart.h75
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/pieslice.cpp86
-rw-r--r--examples/tutorials/extending/chapter5-listproperties/pieslice.h76
-rw-r--r--examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir1
-rw-r--r--examples/tutorials/extending/chapter6-plugins/app.qml69
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro18
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp53
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chartsplugin.h57
-rw-r--r--examples/tutorials/extending/chapter6-plugins/chartsplugin.json1
-rw-r--r--examples/tutorials/extending/chapter6-plugins/piechart.cpp71
-rw-r--r--examples/tutorials/extending/chapter6-plugins/piechart.h69
-rw-r--r--examples/tutorials/extending/chapter6-plugins/pieslice.cpp86
-rw-r--r--examples/tutorials/extending/chapter6-plugins/pieslice.h74
-rw-r--r--examples/tutorials/extending/extending.pro10
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp3
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h1
-rw-r--r--examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json1
-rw-r--r--examples/tutorials/helloworld/Cell.qml72
-rw-r--r--examples/tutorials/helloworld/tutorial1.qml63
-rw-r--r--examples/tutorials/helloworld/tutorial2.qml72
-rw-r--r--examples/tutorials/helloworld/tutorial3.qml91
-rw-r--r--examples/tutorials/samegame/samegame1/Block.qml53
-rw-r--r--examples/tutorials/samegame/samegame1/Button.qml83
-rw-r--r--examples/tutorials/samegame/samegame1/samegame.qml82
-rw-r--r--examples/tutorials/samegame/samegame1/samegame1.qmlproject16
-rw-r--r--examples/tutorials/samegame/samegame2/Block.qml51
-rw-r--r--examples/tutorials/samegame/samegame2/Button.qml81
-rw-r--r--examples/tutorials/samegame/samegame2/samegame.js63
-rw-r--r--examples/tutorials/samegame/samegame2/samegame.qml85
-rw-r--r--examples/tutorials/samegame/samegame2/samegame2.qmlproject16
-rw-r--r--examples/tutorials/samegame/samegame3/Block.qml63
-rw-r--r--examples/tutorials/samegame/samegame3/Button.qml81
-rw-r--r--examples/tutorials/samegame/samegame3/Dialog.qml71
-rw-r--r--examples/tutorials/samegame/samegame3/samegame.js174
-rw-r--r--examples/tutorials/samegame/samegame3/samegame.qml109
-rw-r--r--examples/tutorials/samegame/samegame3/samegame3.qmlproject16
-rw-r--r--examples/tutorials/samegame/samegame4/content/BoomBlock.qml122
-rw-r--r--examples/tutorials/samegame/samegame4/content/Button.qml81
-rw-r--r--examples/tutorials/samegame/samegame4/content/Dialog.qml107
-rwxr-xr-xexamples/tutorials/samegame/samegame4/content/samegame.js226
-rw-r--r--examples/tutorials/samegame/samegame4/highscores/README1
-rwxr-xr-xexamples/tutorials/samegame/samegame4/highscores/score_data.xml2
-rwxr-xr-xexamples/tutorials/samegame/samegame4/highscores/score_style.xsl28
-rwxr-xr-xexamples/tutorials/samegame/samegame4/highscores/scores.php31
-rw-r--r--examples/tutorials/samegame/samegame4/samegame.qml115
-rw-r--r--examples/tutorials/samegame/samegame4/samegame4.qmlproject16
-rw-r--r--examples/tutorials/samegame/shared/pics/background.jpgbin0 -> 36473 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/blueStar.pngbin0 -> 278 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/greenStar.pngbin0 -> 273 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/redStar.pngbin0 -> 274 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/tutorials/samegame/shared/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/Dial.qml86
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml52
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/background.pngbin0 -> 35876 bytes
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/needle.pngbin0 -> 342 bytes
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/needle_shadow.pngbin0 -> 632 bytes
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/overlay.pngbin0 -> 3564 bytes
-rw-r--r--examples/tutorials/ui-components/dialcontrol/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/tutorials/ui-components/dialcontrol/dialcontrol.qml98
-rw-r--r--examples/tutorials/ui-components/flipable/content/5_heart.pngbin0 -> 3872 bytes
-rw-r--r--examples/tutorials/ui-components/flipable/content/9_club.pngbin0 -> 6135 bytes
-rw-r--r--examples/tutorials/ui-components/flipable/content/Card.qml80
-rw-r--r--examples/tutorials/ui-components/flipable/content/back.pngbin0 -> 1418 bytes
-rw-r--r--examples/tutorials/ui-components/flipable/flipable.qml55
-rw-r--r--examples/tutorials/ui-components/progressbar/content/ProgressBar.qml83
-rw-r--r--examples/tutorials/ui-components/progressbar/content/background.pngbin0 -> 426 bytes
-rw-r--r--examples/tutorials/ui-components/progressbar/main.qml73
-rw-r--r--examples/tutorials/ui-components/scrollbar/ScrollBar.qml74
-rw-r--r--examples/tutorials/ui-components/scrollbar/main.qml93
-rw-r--r--examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpgbin0 -> 142510 bytes
-rw-r--r--examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject16
-rw-r--r--examples/tutorials/ui-components/searchbox/SearchBox.qml109
-rw-r--r--examples/tutorials/ui-components/searchbox/images/clear.pngbin0 -> 429 bytes
-rw-r--r--examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.pngbin0 -> 526 bytes
-rw-r--r--examples/tutorials/ui-components/searchbox/images/lineedit-bg.pngbin0 -> 426 bytes
-rw-r--r--examples/tutorials/ui-components/searchbox/main.qml60
-rw-r--r--examples/tutorials/ui-components/searchbox/searchbox.qmlproject16
-rw-r--r--examples/tutorials/ui-components/slideswitch/content/Switch.qml117
-rw-r--r--examples/tutorials/ui-components/slideswitch/content/background.pngbin0 -> 3091 bytes
-rw-r--r--examples/tutorials/ui-components/slideswitch/content/background.svg23
-rw-r--r--examples/tutorials/ui-components/slideswitch/content/knob.pngbin0 -> 3101 bytes
-rw-r--r--examples/tutorials/ui-components/slideswitch/content/knob.svg867
-rw-r--r--examples/tutorials/ui-components/slideswitch/slideswitch.qml51
-rw-r--r--examples/tutorials/ui-components/spinner/content/Spinner.qml70
-rw-r--r--examples/tutorials/ui-components/spinner/content/spinner-bg.pngbin0 -> 345 bytes
-rw-r--r--examples/tutorials/ui-components/spinner/content/spinner-select.pngbin0 -> 320 bytes
-rw-r--r--examples/tutorials/ui-components/spinner/main.qml61
-rw-r--r--examples/tutorials/ui-components/spinner/spinner.qmlproject16
-rw-r--r--examples/tutorials/ui-components/tabwidget/TabWidget.qml102
-rw-r--r--examples/tutorials/ui-components/tabwidget/main.qml99
-rw-r--r--examples/tutorials/ui-components/tabwidget/tab.pngbin0 -> 507 bytes
-rw-r--r--examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject16
-rw-r--r--examples/window/Window.qml58
-rw-r--r--examples/window/screen/screenInfo.qml90
-rw-r--r--examples/window/standalone.qml71
-rw-r--r--examples/window/window.cpp58
-rw-r--r--examples/window/window.pro5
-rw-r--r--src/imports/folderlistmodel/fileinfothread.cpp280
-rw-r--r--src/imports/folderlistmodel/fileinfothread_p.h107
-rw-r--r--src/imports/folderlistmodel/fileproperty_p.h94
-rw-r--r--src/imports/folderlistmodel/folderlistmodel.json1
-rw-r--r--src/imports/folderlistmodel/folderlistmodel.pro9
-rw-r--r--src/imports/folderlistmodel/plugin.cpp7
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp494
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h60
-rw-r--r--src/imports/gestures/gestures.json1
-rw-r--r--src/imports/localstorage/localstorage.json1
-rw-r--r--src/imports/localstorage/localstorage.pro4
-rw-r--r--src/imports/localstorage/plugin.cpp4
-rw-r--r--src/imports/shaders/shaders.json1
-rw-r--r--src/imports/testlib/main.cpp4
-rw-r--r--src/imports/testlib/testlib.json1
-rw-r--r--src/imports/testlib/testlib.pro3
-rw-r--r--src/imports/xmllistmodel/plugin.cpp4
-rw-r--r--src/imports/xmllistmodel/xmllistmodel.json1
-rw-r--r--src/plugins/accessible/quick/accessible.json3
-rw-r--r--src/plugins/accessible/quick/main.cpp8
-rw-r--r--src/plugins/accessible/quick/quick.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h1
-rw-r--r--src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json1
-rw-r--r--src/qml/debugger/qdebugmessageservice.cpp2
-rw-r--r--src/qml/debugger/qqmldebugserverconnection_p.h6
-rw-r--r--src/qml/debugger/qqmlinspectorinterface_p.h5
-rw-r--r--src/qml/debugger/qqmlprofilerservice.cpp62
-rw-r--r--src/qml/debugger/qqmlprofilerservice_p.h158
-rw-r--r--src/qml/debugger/qv8profilerservice.cpp14
-rw-r--r--src/qml/debugger/qv8profilerservice_p.h1
-rw-r--r--src/qml/qml/ftw/qfastmetabuilder.cpp64
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp15
-rw-r--r--src/qml/qml/qqmlcompiler.cpp30
-rw-r--r--src/qml/qml/qqmlcompiler_p.h1
-rw-r--r--src/qml/qml/qqmlcomponent.cpp22
-rw-r--r--src/qml/qml/qqmlcomponent_p.h4
-rw-r--r--src/qml/qml/qqmlengine.cpp16
-rw-r--r--src/qml/qml/qqmlexpression.cpp4
-rw-r--r--src/qml/qml/qqmlextensioninterface.h7
-rw-r--r--src/qml/qml/qqmlimageprovider.h2
-rw-r--r--src/qml/qml/qqmlincubator.cpp7
-rw-r--r--src/qml/qml/qqmlincubator.h3
-rw-r--r--src/qml/qml/qqmlinstruction.cpp4
-rw-r--r--src/qml/qml/qqmllocale.cpp5
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp2
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h1
-rw-r--r--src/qml/qml/qqmlpropertyvalueinterceptor_p.h5
-rw-r--r--src/qml/qml/qqmlpropertyvaluesource.h5
-rw-r--r--src/qml/qml/qqmlrewrite.cpp123
-rw-r--r--src/qml/qml/qqmlrewrite_p.h5
-rw-r--r--src/qml/qml/qqmltypeloader.cpp6
-rw-r--r--src/qml/qml/qqmlvme_p.h24
-rw-r--r--src/qml/qml/qquickworkerscript.cpp2
-rw-r--r--src/qml/qml/v4/qv4bindings.cpp79
-rw-r--r--src/qml/qml/v4/qv4bindings_p.h2
-rw-r--r--src/qml/qml/v4/qv4compiler.cpp25
-rw-r--r--src/qml/qml/v4/qv4compiler_p_p.h1
-rw-r--r--src/qml/qml/v4/qv4instruction.cpp9
-rw-r--r--src/qml/qml/v4/qv4instruction_p.h3
-rw-r--r--src/qml/qml/v4/qv4ir.cpp3
-rw-r--r--src/qml/qml/v4/qv4ir_p.h1
-rw-r--r--src/qml/qml/v4/qv4irbuilder.cpp9
-rw-r--r--src/qml/qml/v4/qv4program_p.h1
-rw-r--r--src/qml/qml/v8/qjsconverter_p.h38
-rw-r--r--src/qml/qml/v8/qjsengine.h38
-rw-r--r--src/qml/qml/v8/qjsengine_p.h40
-rw-r--r--src/qml/qml/v8/qjsvalue.h41
-rw-r--r--src/qml/qml/v8/qjsvalue_impl_p.h38
-rw-r--r--src/qml/qml/v8/qjsvalue_p.h38
-rw-r--r--src/qml/qml/v8/qjsvalueiterator.h39
-rw-r--r--src/qml/qml/v8/qjsvalueiterator_impl_p.h36
-rw-r--r--src/qml/qml/v8/qjsvalueiterator_p.h36
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp19
-rw-r--r--src/qml/qml/v8/qscript_impl_p.h40
-rw-r--r--src/qml/qml/v8/qscriptisolate_p.h38
-rw-r--r--src/qml/qml/v8/qscriptoriginalglobalobject_p.h38
-rw-r--r--src/qml/qml/v8/qscriptshareddata_p.h38
-rw-r--r--src/qml/qml/v8/qscripttools_p.h38
-rw-r--r--src/qml/qml/v8/qv8engine.cpp10
-rw-r--r--src/qml/qml/v8/qv8engine_impl_p.h36
-rw-r--r--src/qml/qml/v8/qv8engine_p.h2
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp4
-rw-r--r--src/quick/items/items.pri8
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp613
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h373
-rw-r--r--src/quick/items/qquickcanvas.cpp30
-rw-r--r--src/quick/items/qquickevents_p_p.h14
-rw-r--r--src/quick/items/qquickflickable.cpp17
-rw-r--r--src/quick/items/qquickgridview.cpp163
-rw-r--r--src/quick/items/qquickitem.cpp6
-rw-r--r--src/quick/items/qquickitem_p.h4
-rw-r--r--src/quick/items/qquickitemanimation.cpp2
-rw-r--r--src/quick/items/qquickitemsmodule.cpp8
-rw-r--r--src/quick/items/qquickitemview.cpp921
-rw-r--r--src/quick/items/qquickitemview_p.h51
-rw-r--r--src/quick/items/qquickitemview_p_p.h92
-rw-r--r--src/quick/items/qquickitemviewtransition.cpp876
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h209
-rw-r--r--src/quick/items/qquicklistview.cpp273
-rw-r--r--src/quick/items/qquicklistview_p.h3
-rw-r--r--src/quick/items/qquickpositioners.cpp375
-rw-r--r--src/quick/items/qquickpositioners_p.h16
-rw-r--r--src/quick/items/qquickpositioners_p_p.h11
-rw-r--r--src/quick/items/qquicksprite.cpp4
-rw-r--r--src/quick/items/qquicksprite_p.h24
-rw-r--r--src/quick/items/qquickspriteengine.cpp2
-rw-r--r--src/quick/items/qquickspriteengine_p.h2
-rw-r--r--src/quick/items/qquickspritesequence.cpp482
-rw-r--r--src/quick/items/qquickspritesequence_p.h148
-rw-r--r--src/quick/items/qquickstateoperations.cpp3
-rw-r--r--src/quick/items/qquicktext.cpp331
-rw-r--r--src/quick/items/qquicktext_p_p.h46
-rw-r--r--src/quick/items/qquicktextcontrol.cpp94
-rw-r--r--src/quick/items/qquicktextcontrol_p.h12
-rw-r--r--src/quick/items/qquicktextcontrol_p_p.h55
-rw-r--r--src/quick/items/qquicktextedit.cpp65
-rw-r--r--src/quick/items/qquicktextedit_p.h6
-rw-r--r--src/quick/items/qquicktextedit_p_p.h79
-rw-r--r--src/quick/items/qquicktextinput.cpp42
-rw-r--r--src/quick/items/qquicktextinput_p.h4
-rw-r--r--src/quick/items/qquicktextinput_p_p.h13
-rw-r--r--src/quick/items/qquickvisualadaptormodel_p.h4
-rw-r--r--src/quick/items/qquickvisualdatamodel.cpp41
-rw-r--r--src/quick/items/qquickvisualdatamodel_p.h1
-rw-r--r--src/quick/items/qquickvisualitemmodel_p.h1
-rw-r--r--src/quick/items/qquickwindowmanager.cpp176
-rw-r--r--src/quick/items/qquickwindowmanager_p.h5
-rw-r--r--src/quick/items/qquickwindowmodule.cpp2
-rw-r--r--src/quick/items/qquickwindowmodule_p.h2
-rw-r--r--src/quick/particles/qquickage.cpp2
-rw-r--r--src/quick/particles/qquickage_p.h2
-rw-r--r--src/quick/particles/qquickangledirection.cpp3
-rw-r--r--src/quick/particles/qquickangledirection_p.h2
-rw-r--r--src/quick/particles/qquickcumulativedirection.cpp2
-rw-r--r--src/quick/particles/qquickcumulativedirection_p.h2
-rw-r--r--src/quick/particles/qquickcustomaffector.cpp2
-rw-r--r--src/quick/particles/qquickcustomaffector_p.h2
-rw-r--r--src/quick/particles/qquickdirection.cpp2
-rw-r--r--src/quick/particles/qquickdirection_p.h2
-rw-r--r--src/quick/particles/qquickellipseextruder.cpp3
-rw-r--r--src/quick/particles/qquickellipseextruder_p.h2
-rw-r--r--src/quick/particles/qquickfriction.cpp2
-rw-r--r--src/quick/particles/qquickfriction_p.h2
-rw-r--r--src/quick/particles/qquickgravity.cpp2
-rw-r--r--src/quick/particles/qquickgravity_p.h2
-rw-r--r--src/quick/particles/qquickgroupgoal.cpp2
-rw-r--r--src/quick/particles/qquickgroupgoal_p.h2
-rw-r--r--src/quick/particles/qquickimageparticle.cpp9
-rw-r--r--src/quick/particles/qquickimageparticle_p.h2
-rw-r--r--src/quick/particles/qquickitemparticle.cpp2
-rw-r--r--src/quick/particles/qquickitemparticle_p.h2
-rw-r--r--src/quick/particles/qquicklineextruder.cpp3
-rw-r--r--src/quick/particles/qquicklineextruder_p.h2
-rw-r--r--src/quick/particles/qquickmaskextruder.cpp2
-rw-r--r--src/quick/particles/qquickmaskextruder_p.h2
-rw-r--r--src/quick/particles/qquickparticleaffector.cpp2
-rw-r--r--src/quick/particles/qquickparticleaffector_p.h2
-rw-r--r--src/quick/particles/qquickparticleemitter.cpp2
-rw-r--r--src/quick/particles/qquickparticleemitter_p.h2
-rw-r--r--src/quick/particles/qquickparticleextruder.cpp3
-rw-r--r--src/quick/particles/qquickparticleextruder_p.h2
-rw-r--r--src/quick/particles/qquickparticlegroup.cpp2
-rw-r--r--src/quick/particles/qquickparticlegroup_p.h2
-rw-r--r--src/quick/particles/qquickparticlepainter.cpp2
-rw-r--r--src/quick/particles/qquickparticlepainter_p.h2
-rw-r--r--src/quick/particles/qquickparticlesmodule.cpp2
-rw-r--r--src/quick/particles/qquickparticlesmodule_p.h2
-rw-r--r--src/quick/particles/qquickparticlesystem.cpp2
-rw-r--r--src/quick/particles/qquickparticlesystem_p.h2
-rw-r--r--src/quick/particles/qquickpointattractor.cpp2
-rw-r--r--src/quick/particles/qquickpointattractor_p.h2
-rw-r--r--src/quick/particles/qquickpointdirection.cpp3
-rw-r--r--src/quick/particles/qquickpointdirection_p.h2
-rw-r--r--src/quick/particles/qquickrectangleextruder.cpp3
-rw-r--r--src/quick/particles/qquickrectangleextruder_p.h2
-rw-r--r--src/quick/particles/qquickspritegoal.cpp2
-rw-r--r--src/quick/particles/qquickspritegoal_p.h2
-rw-r--r--src/quick/particles/qquicktargetdirection.cpp2
-rw-r--r--src/quick/particles/qquicktargetdirection_p.h2
-rw-r--r--src/quick/particles/qquicktrailemitter.cpp2
-rw-r--r--src/quick/particles/qquicktrailemitter_p.h2
-rw-r--r--src/quick/particles/qquickturbulence.cpp2
-rw-r--r--src/quick/particles/qquickturbulence_p.h2
-rw-r--r--src/quick/particles/qquickv8particledata.cpp2
-rw-r--r--src/quick/particles/qquickv8particledata_p.h2
-rw-r--r--src/quick/particles/qquickwander.cpp2
-rw-r--r--src/quick/particles/qquickwander_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp6
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode_p.h2
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp1
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp2
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp15
-rw-r--r--src/quick/scenegraph/qsgcontextplugin_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp1
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode.cpp3
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode_p.h4
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp6
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp39
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h2
-rw-r--r--src/quick/scenegraph/scenegraph.pri2
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil.cpp714
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil_p.h24
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp3
-rw-r--r--src/quick/util/qquickanimationcontroller_p.h2
-rw-r--r--src/quick/util/qquickpixmapcache.cpp10
-rw-r--r--src/quick/util/qquickstyledtext.cpp43
-rw-r--r--src/quick/util/qquickstyledtext_p.h6
-rw-r--r--tests/auto/host.pro9
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro2
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp14
-rw-r--r--tests/auto/qml/qml.pro1
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp3
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createParentReference.qml12
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp32
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml10
-rw-r--r--tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml13
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp51
-rw-r--r--tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp4
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.5.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.5.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h3
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp1
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp38
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/method.1.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/method.2.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/method.3.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml6
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml6
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml7
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.alias.qml7
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.bool.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.color.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.date.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.int.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml6
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.real.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.string.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.url.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.var.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/property.variant.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.1.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.2.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.3.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.4.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/data/signal.5.qml5
-rw-r--r--tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro14
-rw-r--r--tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp364
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/empty.json1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp4
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp17
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp4
-rw-r--r--tests/auto/qml/v4/data/colorType.qml18
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp18
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp28
-rw-r--r--tests/auto/quick/qquickanchors/data/stretch.qml39
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp41
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/basic.qml58
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro15
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp83
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp19
-rw-r--r--tests/auto/quick/qquickdroparea/qquickdroparea.pro2
-rw-r--r--tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp75
-rw-r--r--tests/auto/quick/qquickgridview/data/displacedTransitions.qml138
-rw-r--r--tests/auto/quick/qquickgridview/data/multipleTransitions.qml28
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp249
-rw-r--r--tests/auto/quick/qquicklistview/data/displacedTransitions.qml128
-rw-r--r--tests/auto/quick/qquicklistview/data/multipleTransitions.qml29
-rw-r--r--tests/auto/quick/qquicklistview/data/sectionpropertychange.qml92
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp323
-rw-r--r--tests/auto/quick/qquickpositioners/data/transitions.qml196
-rw-r--r--tests/auto/quick/qquickpositioners/qquickpositioners.pro1
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp455
-rw-r--r--tests/auto/quick/qquickspritesequence/data/advance.qml66
-rw-r--r--tests/auto/quick/qquickspritesequence/data/basic.qml60
-rw-r--r--tests/auto/quick/qquickspritesequence/data/squarefacesprite.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/quick/qquickspritesequence/qquickspritesequence.pro15
-rw-r--r--tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp98
-rw-r--r--tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp130
-rw-r--r--tests/auto/quick/qquicktext/data/fontSizeMode.qml2
-rw-r--r--tests/auto/quick/qquicktext/data/multilengthStrings.qml2
-rw-r--r--tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml2
-rw-r--r--tests/auto/quick/qquicktext/data/multilineelide.qml2
-rw-r--r--tests/auto/quick/qquicktext/data/pixelFontSizes.qml21
-rw-r--r--tests/auto/quick/qquicktext/data/pointFontSizes.qml21
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp620
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp41
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp77
-rw-r--r--tests/auto/quick/quick.pro13
-rw-r--r--tests/auto/quick/shared/viewtestutil.h2
-rw-r--r--tests/benchmarks/qml/script/data/enums.qml2
-rw-r--r--tests/benchmarks/qml/script/data/namespacedEnums.qml2
-rw-r--r--tests/benchmarks/qml/script/data/scriptCall.qml2
-rw-r--r--tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml51
-rw-r--r--tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml54
-rw-r--r--tests/benchmarks/qml/script/script.pro3
-rw-r--r--tests/benchmarks/qml/script/tst_script.cpp253
-rw-r--r--tools/qmlplugindump/main.cpp2
-rw-r--r--tools/qmlprofiler/profileclient.cpp16
-rw-r--r--tools/qmlprofiler/profileclient.h8
-rw-r--r--tools/qmlprofiler/profiledata.cpp188
-rw-r--r--tools/qmlprofiler/profiledata.h34
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp54
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h6
1107 files changed, 51141 insertions, 4207 deletions
diff --git a/.gitattributes b/.gitattributes
index a3c6108370..157176bdb8 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
.tag ident
+*_crlf.* eol=crlf
diff --git a/.gitignore b/.gitignore
index e1bf85aa29..4c8776bc5d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,20 +1,6 @@
# This file is used to ignore files which are generated in the Qt build system
# ----------------------------------------------------------------------------
-examples/*/*/*
-!examples/*/*/*[.]*
-!examples/*/*/README
-examples/*/*/*[.]app
-!examples/declarative/*
-!examples/tutorials/*
-!examples/tutorials/*/*
-!examples/ja_JP/*/*
-demos/*/*
-!demos/spectrum/*
-demos/spectrum/bin
-!demos/*/*[.]*
-demos/*/*[.]app
-!demos/declarative/*
config.tests/*/*/*
!config.tests/*/*/*[.]*
config.tests/*/*/*[.]app
@@ -273,4 +259,4 @@ tests/auto/*/*.o
tests/auto/*/*.moc
tests/auto/*/*/*.o
tests/auto/*/*/*.moc
-src/declarative/generated/ \ No newline at end of file
+src/declarative/generated/
diff --git a/bin/rename-qtdeclarative-symbols.sh b/bin/rename-qtdeclarative-symbols.sh
index 841850230f..0d521dd5a8 100755
--- a/bin/rename-qtdeclarative-symbols.sh
+++ b/bin/rename-qtdeclarative-symbols.sh
@@ -75,6 +75,7 @@ QML_SYMBOLS="\
QDeclarativeCompiledData
QDeclarativeCompiler
QDeclarativeCompilerTypes
+ QDeclarativeCompilingProfiler
QDeclarativeComponent
QDeclarativeComponentAttached
QDeclarativeComponentExtension
@@ -152,6 +153,7 @@ QML_SYMBOLS="\
QDeclarativeGuard
QDeclarativeGuardedContextData
QDeclarativeGuardImpl
+ QDeclarativeHandlingSignalProfiler
QDeclarativeImageProvider
QDeclarativeImageProviderPrivate
QDeclarativeImportDatabase
@@ -189,6 +191,7 @@ QML_SYMBOLS="\
QDeclarativeNotifierEndpoint
QDeclarativeNullableValue
QDeclarativeNumberExtension
+ QDeclarativeObjectCreatingProfiler
QDeclarativeObjectData
QDeclarativeObjectProperty
QDeclarativeObserverMode
diff --git a/doc/config/qtquick.qdocconf b/doc/config/qtquick.qdocconf
index 69e860919e..3f4645aeaa 100644
--- a/doc/config/qtquick.qdocconf
+++ b/doc/config/qtquick.qdocconf
@@ -19,7 +19,8 @@ headerdirs += ../src \
imagedirs += ../src/images \
sourcedirs += ../src \
- ../../src
+ ../../src \
+ ../../examples
#indexes = $QT5DOC/doc/html/qt.index
diff --git a/doc/src/examples/examples-groups.qdoc b/doc/src/examples/examples-groups.qdoc
index 9a6dafa435..0ecd117128 100644
--- a/doc/src/examples/examples-groups.qdoc
+++ b/doc/src/examples/examples-groups.qdoc
@@ -32,15 +32,6 @@
\brief This is an internationalization example
*/
/*!
- \title QML Examples - Shader Effects
- \example declarative/shadereffects
- \image qml-shadereffects-example.png
- \brief This is a shader effects example
-
- This example demonstrates a couple of visual effects that you can perform
- with shaders in QtQuick 2.0
-*/
-/*!
\title QML Examples - Positioners
\example declarative/positioners
\brief This is a positioners example
@@ -49,26 +40,6 @@
This example demonstrates the positioners and some of their animations.
*/
/*!
- \title QML Examples - Animation
- \example declarative/animation
- \brief This is a collection of QML examples
- \image qml-animations-example.png
-
- This is a collection of small QML examples relating to animation. Each example is
- a small QML file, usually containing or emphasizing a particular element or
- feature. You can run and observe the behavior of each example.
-*/
-/*!
- \title QML Examples - Image Elements
- \example declarative/imageelements
- \brief This is a collection of QML examples
- \image qml-imageelements-example.png
-
- This is a collection of small QML examples relating to image elements. Each example is
- a small QML file, usually containing or emphasizing a particular element or
- feature. You can run and observe the behavior of each example.
-*/
-/*!
\title QML Examples - Models and Views
\example declarative/modelviews
\brief This is a collection of QML examples
diff --git a/doc/src/examples/examples-toys.qdoc b/doc/src/examples/examples-toys.qdoc
index f076c1de6c..7414579e19 100644
--- a/doc/src/examples/examples-toys.qdoc
+++ b/doc/src/examples/examples-toys.qdoc
@@ -27,13 +27,6 @@
/*!
- \title QML Example - Calculator
- \example declarative/calculator
- \brief This is an example application written in QML.
- \image qml-calculator-demo-small.png
-*/
-
-/*!
\title QML Example - Samegame
\example declarative/samegame
\brief This example demonstrates creating a game with javascript game logic.
diff --git a/doc/src/localstorage/localstorage.qdoc b/doc/src/localstorage/localstorage.qdoc
index 406de25339..5287120e86 100644
--- a/doc/src/localstorage/localstorage.qdoc
+++ b/doc/src/localstorage/localstorage.qdoc
@@ -33,9 +33,24 @@ The local storage API provides a JavaScript interface to an SQL relational
database. The QtQuick.LocalStorage module contains the API and it may be given
a namespace.
+Import QtQuick.LocalStorage module from QML:
\code
-import QtQuick.LocalStorage 2.0 as SQL
+//sql.qml
+
+import QtQuick.LocalStorage 2.0 as Sql
+\endcode
+
+
+Import QtQuick.LocalStorage module from JavaScript:
+\code
+//sql.js
+.import QtQuick.LocalStorage 2.0 as Sql
\endcode
+
+Note, importing a module from JavaScript is different from importing from QML.
+The \l{JavaScript Code} article contains detailed information on importing in JavaScript code.
+
+
\section2 Database API
The \c openDatabaseSync() and related functions
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml
index 8a05491ee1..cb94acb2b1 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml
@@ -60,7 +60,7 @@ ListView {
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 }
}
- addDisplaced: Transition {
+ displaced: Transition {
NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce }
}
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml
index 79d00d2d1c..84c4848a76 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml
@@ -60,12 +60,12 @@ ListView {
}
//! [0]
- addDisplaced: Transition {
- id: addDispTrans
+ displaced: Transition {
+ id: dispTrans
SequentialAnimation {
PauseAnimation {
- duration: (addDispTrans.ViewTransition.index -
- addDispTrans.ViewTransition.targetIndexes[0]) * 100
+ duration: (dispTrans.ViewTransition.index -
+ dispTrans.ViewTransition.targetIndexes[0]) * 100
}
NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce }
}
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml
index a43d3a8b7f..89353b40e8 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml
@@ -60,20 +60,20 @@ ListView {
}
//! [0]
- addDisplaced: Transition {
- id: addDispTrans
+ displaced: Transition {
+ id: dispTrans
SequentialAnimation {
PauseAnimation {
- duration: (addDispTrans.ViewTransition.index -
- addDispTrans.ViewTransition.targetIndexes[0]) * 100
+ duration: (dispTrans.ViewTransition.index -
+ dispTrans.ViewTransition.targetIndexes[0]) * 100
}
ParallelAnimation {
NumberAnimation {
- property: "x"; to: addDispTrans.ViewTransition.item.x + 20
+ property: "x"; to: dispTrans.ViewTransition.item.x + 20
easing.type: Easing.OutQuad
}
NumberAnimation {
- property: "y"; to: addDispTrans.ViewTransition.item.y + 50
+ property: "y"; to: dispTrans.ViewTransition.item.y + 50
easing.type: Easing.OutQuad
}
}
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml
index 1355268710..0644caaec7 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml
@@ -60,7 +60,7 @@ ListView {
}
//! [0]
- addDisplaced: Transition {
+ displaced: Transition {
NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce }
// ensure opacity and scale values return to 1.0
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml
index 3d075c4367..4b1685719d 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml
@@ -76,20 +76,20 @@ ListView {
}
//! [0]
- addDisplaced: Transition {
- id: addDispTrans
+ displaced: Transition {
+ id: dispTrans
SequentialAnimation {
PauseAnimation {
- duration: (addDispTrans.ViewTransition.index -
- addDispTrans.ViewTransition.targetIndexes[0]) * 100
+ duration: (dispTrans.ViewTransition.index -
+ dispTrans.ViewTransition.targetIndexes[0]) * 100
}
ParallelAnimation {
NumberAnimation {
- property: "x"; to: addDispTrans.ViewTransition.item.x + 20
+ property: "x"; to: dispTrans.ViewTransition.item.x + 20
easing.type: Easing.OutQuad
}
NumberAnimation {
- property: "y"; to: addDispTrans.ViewTransition.item.y + 50
+ property: "y"; to: dispTrans.ViewTransition.item.y + 50
easing.type: Easing.OutQuad
}
}
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml
index 03348356e1..0e7d1e8d82 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml
@@ -70,7 +70,7 @@ ListView {
}
}
- moveDisplaced: Transition {
+ displaced: Transition {
NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce }
}
diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml
index eda5c35479..7fa7e48f82 100644
--- a/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml
+++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml
@@ -73,7 +73,7 @@ ListView {
}
//! [0]
- moveDisplaced: Transition {
+ displaced: Transition {
NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce }
}
diff --git a/doc/src/whatsnew.qdoc b/doc/src/whatsnew.qdoc
index bf77e0e6c0..c791e72c25 100644
--- a/doc/src/whatsnew.qdoc
+++ b/doc/src/whatsnew.qdoc
@@ -112,8 +112,11 @@ Setting Image sourceSize.width and sourceSize.height will now fit the image to t
Grid now has rowSpacing and columnSpacing properties. Spacing properties on positioners are now real numbers instead
of integers.
-Positioners now have attached properties that can be used to determine a subitem's location within a
-container such as Column or Row: Positioner.index, Positioner.isFirstItem, Positioner.isLastItem.
+Positioner (Row, Column, Grid, Flow) improvements:
+\list
+\o Transitions used for \c add and \c move now have improved features: they can access a ViewTransition attached property (see the ViewTransition documentation for examples) and can now animate arbitrary item properties (instead of being restricted to animating an item's position).
+\o Items in a positioner now have attached properties that can be used to determine a subitem's location: Positioner.index, Positioner.isFirstItem, Positioner.isLastItem.
+\endlist
Loader improvements:
- "active" property added to Loader, to allow delaying instantiation of a Loader element's item property
diff --git a/examples/HACKING b/examples/HACKING
new file mode 100644
index 0000000000..9539d2d129
--- /dev/null
+++ b/examples/HACKING
@@ -0,0 +1,23 @@
+Some guidelines for QtQml examples
+
+Snippets
+---
+Snippets are snatches of QML code that won't even run on their own. They don't belong here, they belong in doc/src/snippets. They should be contained in files that will compile on their own, for automated syntax validation, but don't have to look like anything.
+
+Examples
+---
+
+Examples are large blocks of QML code that demonstrate a feature. You should be able to launch an example and visually see the feature take effect. Examples should be written in a small form, and should automatically activate any features. Ideally, when you run an example, you see the feature demonstrate itself over and over until you get bored and close the application using your platform's close window mechanism. Examples shouldn't contain their own close buttons or start screen, explanatory text should be kept to a minimum (show, not tell), and reserve interaction for demonstrating interactive elements. The code should be held to a high level of quality, and should be understandable by people new to QML.
+
+Unless the demonstrated feature uses it, assume no interface devices other than a screen that can show a 320x480 rectangle and a generic pointing device (with the shared subset of mouse/touch functionality).
+
+Groups of similar examples should be placed in one folder with a single launcher application, which uses the shared folder of common components.
+
+The example, or launcher application in case of groups, should contain a qdoc comment explaining the example. The example or launcher should be buildable as a full C++ application and runnable with the standard qml file launcher. Usually this will consist primarily of using the macro found in shared.h.
+
+Demos
+---
+
+Demos are examples of creating full applications using QML. They should fit both a desktop and a mobile form factor, they should have their own start screen and method of exiting the application. They should be at a level of quality that you'd be comfortable submitting them to an app store for a platform of the appropriate hardware (screen size, input methods, etc.). The code should be written to a level that is easily understood and modified by a QML expert.
+
+Demos should have a qdoc file in their directory explaining the demo at a high level. The demo should be buildable as a full C++ application and preferably runnable with the standard qml file launcher.
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000000..aba1e2cc0d
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,12 @@
+The Qt Declarative module provides the ability to specify and implement
+your user interface declaratively, using the Qt Meta-Object Language (QML). This
+language is very expressive and human readable, and can be used by
+designers to actually implement their UI vision. QML UIs can integrate
+with C++ code in many ways, including being loaded as a part of a C++ UI
+and loading data models from C++ and interacting with them.
+
+Mostof these examples can be viewed directly with the
+QML viewer utility, without requiring compilation.
+
+Documentation for these examples can be found via the Examples
+link in the main Qt documentation.
diff --git a/examples/demos/calculator/CalculatorCore/Button.qml b/examples/demos/calculator/CalculatorCore/Button.qml
new file mode 100644
index 0000000000..e7b3637b4c
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/Button.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+BorderImage {
+ id: button
+
+ property alias operation: buttonText.text
+ property string color: ""
+
+ Accessible.name: operation
+ Accessible.description: "This button does " + operation
+ Accessible.role: Accessible.Button
+
+ signal clicked
+
+ source: "images/button-" + color + ".png"; clip: true
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Rectangle {
+ id: shade
+ anchors.fill: button; radius: 10; color: "black"; opacity: 0
+ }
+
+ Text {
+ id: buttonText
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -1
+ font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ window.doOp(operation)
+ button.clicked()
+ }
+ }
+
+ states: State {
+ name: "pressed"; when: mouseArea.pressed == true
+ PropertyChanges { target: shade; opacity: .4 }
+ }
+}
diff --git a/examples/demos/calculator/CalculatorCore/Display.qml b/examples/demos/calculator/CalculatorCore/Display.qml
new file mode 100644
index 0000000000..3dceeab169
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/Display.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+BorderImage {
+ id: image
+
+ property alias text : displayText.text
+ property alias currentOperation : operationText
+
+ source: "images/display.png"
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Text {
+ id: displayText
+ anchors {
+ right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1
+ rightMargin: 6; left: operationText.right
+ }
+ font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight
+ color: "#343434"; smooth: true; font.bold: true
+ }
+ Text {
+ id: operationText
+ font.bold: true; font.pixelSize: parent.height * .7
+ color: "#343434"; smooth: true
+ anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter }
+ }
+}
diff --git a/examples/demos/calculator/CalculatorCore/calculator.js b/examples/demos/calculator/CalculatorCore/calculator.js
new file mode 100644
index 0000000000..e2b5692cf3
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/calculator.js
@@ -0,0 +1,95 @@
+
+var curVal = 0
+var memory = 0
+var lastOp = ""
+var timer = 0
+
+function disabled(op) {
+ if (op == "." && display.text.toString().search(/\./) != -1) {
+ return true
+ } else if (op == squareRoot && display.text.toString().search(/-/) != -1) {
+ return true
+ } else {
+ return false
+ }
+}
+
+function doOperation(op) {
+ if (op == '*')//Keyboard Aliases
+ op = multiplication;
+ if (op == '/')
+ op = division;
+ if (disabled(op)) {
+ return
+ }
+
+ if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) {
+ if (display.text.toString().length >= 14)
+ return; // No arbitrary length numbers
+ if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
+ display.text = display.text + op.toString()
+ } else {
+ display.text = op
+ }
+ lastOp = op
+ return
+ }
+ lastOp = op
+
+ if (display.currentOperation.text == "+") {
+ display.text = Number(display.text.valueOf()) + Number(curVal.valueOf())
+ } else if (display.currentOperation.text == "-") {
+ display.text = Number(curVal) - Number(display.text.valueOf())
+ } else if (display.currentOperation.text == multiplication) {
+ display.text = Number(curVal) * Number(display.text.valueOf())
+ } else if (display.currentOperation.text == division) {
+ display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString()
+ } else if (display.currentOperation.text == "=") {
+ }
+
+ if (op == "+" || op == "-" || op == multiplication || op == division) {
+ display.currentOperation.text = op
+ curVal = display.text.valueOf()
+ return
+ }
+
+ curVal = 0
+ display.currentOperation.text = ""
+
+ if (op == "1/x") {
+ display.text = (1 / display.text.valueOf()).toString()
+ } else if (op == "x^2") {
+ display.text = (display.text.valueOf() * display.text.valueOf()).toString()
+ } else if (op == "Abs") {
+ display.text = (Math.abs(display.text.valueOf())).toString()
+ } else if (op == "Int") {
+ display.text = (Math.floor(display.text.valueOf())).toString()
+ } else if (op == plusminus) {
+ display.text = (display.text.valueOf() * -1).toString()
+ } else if (op == squareRoot) {
+ display.text = (Math.sqrt(display.text.valueOf())).toString()
+ } else if (op == "mc") {
+ memory = 0;
+ } else if (op == "m+") {
+ memory += display.text.valueOf()
+ } else if (op == "mr") {
+ display.text = memory.toString()
+ } else if (op == "m-") {
+ memory = display.text.valueOf()
+ } else if (op == leftArrow) {
+ display.text = display.text.toString().slice(0, -1)
+ if (display.text.length == 0) {
+ display.text = "0"
+ }
+ } else if (op == "Off") {
+ Qt.quit();
+ } else if (op == "C") {
+ display.text = "0"
+ } else if (op == "AC") {
+ curVal = 0
+ memory = 0
+ lastOp = ""
+ display.text ="0"
+ }
+}
+
diff --git a/examples/demos/calculator/CalculatorCore/images/button-.png b/examples/demos/calculator/CalculatorCore/images/button-.png
new file mode 100644
index 0000000000..544e514536
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/images/button-.png
Binary files differ
diff --git a/examples/demos/calculator/CalculatorCore/images/button-blue.png b/examples/demos/calculator/CalculatorCore/images/button-blue.png
new file mode 100644
index 0000000000..5f92de32d0
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/images/button-blue.png
Binary files differ
diff --git a/examples/demos/calculator/CalculatorCore/images/button-green.png b/examples/demos/calculator/CalculatorCore/images/button-green.png
new file mode 100644
index 0000000000..36c93914c7
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/images/button-green.png
Binary files differ
diff --git a/examples/demos/calculator/CalculatorCore/images/button-purple.png b/examples/demos/calculator/CalculatorCore/images/button-purple.png
new file mode 100644
index 0000000000..347cbbea9d
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/images/button-purple.png
Binary files differ
diff --git a/examples/demos/calculator/CalculatorCore/images/button-red.png b/examples/demos/calculator/CalculatorCore/images/button-red.png
new file mode 100644
index 0000000000..3b335891ae
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/images/button-red.png
Binary files differ
diff --git a/examples/demos/calculator/CalculatorCore/images/display.png b/examples/demos/calculator/CalculatorCore/images/display.png
new file mode 100644
index 0000000000..9507f4382e
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/images/display.png
Binary files differ
diff --git a/examples/demos/calculator/CalculatorCore/qmldir b/examples/demos/calculator/CalculatorCore/qmldir
new file mode 100644
index 0000000000..a926b93fac
--- /dev/null
+++ b/examples/demos/calculator/CalculatorCore/qmldir
@@ -0,0 +1,2 @@
+Button Button.qml
+Display Display.qml
diff --git a/examples/demos/calculator/calculator-desktop.qml b/examples/demos/calculator/calculator-desktop.qml
new file mode 100644
index 0000000000..be65c77170
--- /dev/null
+++ b/examples/demos/calculator/calculator-desktop.qml
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0
+import "CalculatorCore"
+import "CalculatorCore/calculator.js" as CalcEngine
+
+Rectangle {
+ id: window
+
+ width: 640; height: 480
+ color: "#282828"
+
+ property string rotateLeft: "\u2939"
+ property string rotateRight: "\u2935"
+ property string leftArrow: "\u2190"
+ property string division : "\u00f7"
+ property string multiplication : "\u00d7"
+ property string squareRoot : "\u221a"
+ property string plusminus : "\u00b1"
+
+ function doOp(operation) { CalcEngine.doOperation(operation) }
+ focus: true
+ Keys.onPressed: doOp(event.text);
+
+ Item {
+ id: main
+ width: 640
+ height: 480
+ anchors.centerIn: parent
+
+ Column {
+ id: box; spacing: 8
+
+ anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
+
+ Display {
+ id: display
+ width: box.width-3
+ height: 64
+ }
+
+ Column {
+ id: column; spacing: 6
+
+ property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Row {
+ spacing: 6
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
+ }
+
+ Row {
+ spacing: 6
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
+ }
+
+ Grid {
+ id: grid; rows: 5; columns: 5; spacing: 6
+
+ property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
+
+ Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: division }
+ Button { width: grid.w; height: column.h; operation: squareRoot }
+ Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: multiplication }
+ Button { width: grid.w; height: column.h; operation: "x^2" }
+ Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "-" }
+ Button { width: grid.w; height: column.h; operation: "1/x" }
+ Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "." }
+ Button { width: grid.w; height: column.h; operation: plusminus }
+ Button { width: grid.w; height: column.h; operation: "+" }
+ Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
+ }
+ }
+ }
+
+ }
+}
diff --git a/examples/demos/calculator/calculator-mobile.qml b/examples/demos/calculator/calculator-mobile.qml
new file mode 100644
index 0000000000..7ee622f698
--- /dev/null
+++ b/examples/demos/calculator/calculator-mobile.qml
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0
+import "CalculatorCore"
+import "CalculatorCore/calculator.js" as CalcEngine
+
+Rectangle {
+ id: window
+
+ width: 320; height: 480
+ color: "#282828"
+
+ property string rotateLeft: "\u2939"
+ property string rotateRight: "\u2935"
+ property string leftArrow: "\u2190"
+ property string division : "\u00f7"
+ property string multiplication : "\u00d7"
+ property string squareRoot : "\u221a"
+ property string plusminus : "\u00b1"
+
+ function doOp(operation) { CalcEngine.doOperation(operation) }
+
+ Item {
+ id: main
+ state: "orientation " + Screen.orientation
+
+ //Note: Assumes a primarily portrait device
+ property bool landscapeWindow: window.width > window.height
+ property real baseWidth: landscapeWindow ? window.height : window.width
+ property real baseHeight: landscapeWindow ? window.width : window.height
+ property real rotationDelta: landscapeWindow ? -90 : 0
+
+ rotation: rotationDelta
+ width: main.baseWidth
+ height: main.baseHeight
+ anchors.centerIn: parent
+
+ Column {
+ id: box; spacing: 8
+
+ anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 }
+
+ Display {
+ id: display
+ width: box.width-3
+ height: 64
+ }
+
+ Column {
+ id: column; spacing: 6
+
+ property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6)
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Row {
+ spacing: 6
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "C" }
+ Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" }
+ }
+
+ Row {
+ spacing: 6
+ property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4)
+
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mc" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m+" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "m-" }
+ Button { width: column.w; height: column.h; color: 'green'; operation: "mr" }
+ }
+
+ Grid {
+ id: grid; rows: 5; columns: 5; spacing: 6
+
+ property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns)
+
+ Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: division }
+ Button { width: grid.w; height: column.h; operation: squareRoot }
+ Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: multiplication }
+ Button { width: grid.w; height: column.h; operation: "x^2" }
+ Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "-" }
+ Button { width: grid.w; height: column.h; operation: "1/x" }
+ Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' }
+ Button { width: grid.w; height: column.h; operation: "." }
+ Button { width: grid.w; height: column.h; operation: plusminus }
+ Button { width: grid.w; height: column.h; operation: "+" }
+ Button { width: grid.w; height: column.h; operation: "="; color: 'red' }
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "orientation " + Qt.LandscapeOrientation
+ PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ },
+ State {
+ name: "orientation " + Qt.InvertedPortraitOrientation
+ PropertyChanges { target: main; rotation: 180 + rotationDelta; }
+ },
+ State {
+ name: "orientation " + Qt.InvertedLandscapeOrientation
+ PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ }
+ ]
+
+ transitions: Transition {
+ SequentialAnimation {
+ RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
+ NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
+ }
+ }
+ }
+}
diff --git a/examples/demos/calculator/calculator.pro b/examples/demos/calculator/calculator.pro
new file mode 100644
index 0000000000..297d5cfdbb
--- /dev/null
+++ b/examples/demos/calculator/calculator.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator
+qml.files = calculator-desktop.qml calculator-mobile.qml CalculatorCore
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator
+INSTALLS += target qml
diff --git a/examples/demos/calculator/calculator.qdoc b/examples/demos/calculator/calculator.qdoc
new file mode 100644
index 0000000000..e94bdb4cfd
--- /dev/null
+++ b/examples/demos/calculator/calculator.qdoc
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title QML Demo - Calculator
+ \example declarative/calculator
+ \brief This is an example calculator application written in QML.
+ \image qml-calculator-demo-small.png
+
+ The Calculator demo implements a simple calculator in QML. It is written for desktop and portrait devices,
+ although on device it supports orientation changes.
+*/
+
diff --git a/examples/demos/calculator/main.cpp b/examples/demos/calculator/main.cpp
new file mode 100644
index 0000000000..fafe14fe46
--- /dev/null
+++ b/examples/demos/calculator/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QStringList>
+#include <QQuickView>
+#include <QQmlEngine>
+
+void usage()
+{
+ printf("Pass -desktop to use the Desktop UI");
+ exit(0);
+}
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc,argv);
+ QQuickView view;
+ QUrl launchFile = QUrl::fromLocalFile(QLatin1String("calculator-mobile.qml"));
+ if (app.arguments().contains(QLatin1String("-help")))
+ usage();
+ if (app.arguments().contains(QLatin1String("-desktop")))
+ launchFile = QUrl::fromLocalFile(QLatin1String("calculator-desktop.qml"));
+ view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
+ view.setSource(launchFile);
+ view.show();
+ return app.exec();
+}
+
diff --git a/examples/demos/clocks/clocks.qml b/examples/demos/clocks/clocks.qml
new file mode 100644
index 0000000000..288e50c9eb
--- /dev/null
+++ b/examples/demos/clocks/clocks.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: root
+ width: 640; height: 320
+ color: "#646464"
+
+ ListView {
+ id: clockview
+ anchors.fill: parent
+ orientation: ListView.Horizontal
+ cacheBuffer: 2000
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.ApplyRange
+
+ delegate: Clock { city: cityName; shift: timeShift }
+ model: ListModel {
+ ListElement { cityName: "New York"; timeShift: -4 }
+ ListElement { cityName: "London"; timeShift: 0 }
+ ListElement { cityName: "Oslo"; timeShift: 1 }
+ ListElement { cityName: "Mumbai"; timeShift: 5.5 }
+ ListElement { cityName: "Tokyo"; timeShift: 9 }
+ ListElement { cityName: "Brisbane"; timeShift: 10 }
+ ListElement { cityName: "Los Angeles"; timeShift: -8 }
+ }
+ }
+
+ Image {
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ source: "content/arrow.png"
+ rotation: -90
+ opacity: clockview.atXBeginning ? 0 : 0.5
+ Behavior on opacity { NumberAnimation { duration: 500 } }
+ }
+
+ Image {
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ source: "content/arrow.png"
+ rotation: 90
+ opacity: clockview.atXEnd ? 0 : 0.5
+ Behavior on opacity { NumberAnimation { duration: 500 } }
+ }
+}
diff --git a/examples/demos/clocks/content/Clock.qml b/examples/demos/clocks/content/Clock.qml
new file mode 100644
index 0000000000..7f0e8cba83
--- /dev/null
+++ b/examples/demos/clocks/content/Clock.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id : clock
+ width: {
+ if (ListView.view && ListView.view.width >= 200)
+ return ListView.view.width / Math.floor(ListView.view.width / 200.0);
+ else
+ return 200;
+ }
+
+ height: {
+ if (ListView.view && ListView.view.height >= 240)
+ return ListView.view.height;
+ else
+ return 240;
+ }
+
+ property alias city: cityLabel.text
+ property int hours
+ property int minutes
+ property int seconds
+ property real shift
+ property bool night: false
+ property bool internationalTime: true //Unset for local time
+
+ function timeChanged() {
+ var date = new Date;
+ hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
+ night = ( hours < 7 || hours > 19 )
+ minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
+ seconds = date.getUTCSeconds();
+ }
+
+ Timer {
+ interval: 100; running: true; repeat: true;
+ onTriggered: clock.timeChanged()
+ }
+
+ Item {
+ anchors.centerIn: parent
+ width: 200; height: 240
+
+ Image { id: background; source: "clock.png"; visible: clock.night == false }
+ Image { source: "clock-night.png"; visible: clock.night == true }
+
+
+ Image {
+ x: 92.5; y: 27
+ source: "hour.png"
+ smooth: true
+ transform: Rotation {
+ id: hourRotation
+ origin.x: 7.5; origin.y: 73;
+ angle: (clock.hours * 30) + (clock.minutes * 0.5)
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 93.5; y: 17
+ source: "minute.png"
+ smooth: true
+ transform: Rotation {
+ id: minuteRotation
+ origin.x: 6.5; origin.y: 83;
+ angle: clock.minutes * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 97.5; y: 20
+ source: "second.png"
+ smooth: true
+ transform: Rotation {
+ id: secondRotation
+ origin.x: 2.5; origin.y: 80;
+ angle: clock.seconds * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel
+ y: 210; anchors.horizontalCenter: parent.horizontalCenter
+ color: "white"
+ font.family: "Helvetica"
+ font.bold: true; font.pixelSize: 16
+ style: Text.Raised; styleColor: "black"
+ }
+ }
+}
diff --git a/examples/demos/clocks/content/QuitButton.qml b/examples/demos/clocks/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/demos/clocks/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/demos/clocks/content/arrow.png b/examples/demos/clocks/content/arrow.png
new file mode 100644
index 0000000000..e437312217
--- /dev/null
+++ b/examples/demos/clocks/content/arrow.png
Binary files differ
diff --git a/examples/demos/clocks/content/background.png b/examples/demos/clocks/content/background.png
new file mode 100644
index 0000000000..a885950862
--- /dev/null
+++ b/examples/demos/clocks/content/background.png
Binary files differ
diff --git a/examples/demos/clocks/content/center.png b/examples/demos/clocks/content/center.png
new file mode 100644
index 0000000000..7fbd802a44
--- /dev/null
+++ b/examples/demos/clocks/content/center.png
Binary files differ
diff --git a/examples/demos/clocks/content/clock-night.png b/examples/demos/clocks/content/clock-night.png
new file mode 100644
index 0000000000..cc7151a397
--- /dev/null
+++ b/examples/demos/clocks/content/clock-night.png
Binary files differ
diff --git a/examples/demos/clocks/content/clock.png b/examples/demos/clocks/content/clock.png
new file mode 100644
index 0000000000..462edacc0e
--- /dev/null
+++ b/examples/demos/clocks/content/clock.png
Binary files differ
diff --git a/examples/demos/clocks/content/hour.png b/examples/demos/clocks/content/hour.png
new file mode 100644
index 0000000000..f8061a1235
--- /dev/null
+++ b/examples/demos/clocks/content/hour.png
Binary files differ
diff --git a/examples/demos/clocks/content/minute.png b/examples/demos/clocks/content/minute.png
new file mode 100644
index 0000000000..1297ec7c2b
--- /dev/null
+++ b/examples/demos/clocks/content/minute.png
Binary files differ
diff --git a/examples/demos/clocks/content/quit.png b/examples/demos/clocks/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/demos/clocks/content/quit.png
Binary files differ
diff --git a/examples/demos/clocks/content/second.png b/examples/demos/clocks/content/second.png
new file mode 100644
index 0000000000..4aa9fb5e8e
--- /dev/null
+++ b/examples/demos/clocks/content/second.png
Binary files differ
diff --git a/examples/demos/demos.pro b/examples/demos/demos.pro
new file mode 100644
index 0000000000..abe718b910
--- /dev/null
+++ b/examples/demos/demos.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = calculator
diff --git a/examples/demos/flickr/content/Button.qml b/examples/demos/flickr/content/Button.qml
new file mode 100644
index 0000000000..57f846aec3
--- /dev/null
+++ b/examples/demos/flickr/content/Button.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ color: "white"
+ anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15
+ text: container.text; style: Text.Raised; styleColor: "black"
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ }
+ ]
+}
diff --git a/examples/demos/flickr/content/GridDelegate.qml b/examples/demos/flickr/content/GridDelegate.qml
new file mode 100644
index 0000000000..f8838bd609
--- /dev/null
+++ b/examples/demos/flickr/content/GridDelegate.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
+
+ Item {
+ anchors.centerIn: parent
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
+
+ Item {
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ }
+ }
+
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1 }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ }
+ ]
+ }
+ MouseArea { anchors.fill: wrapper; onClicked: photoClicked() }
+}
+
diff --git a/examples/demos/flickr/content/ImageDetails.qml b/examples/demos/flickr/content/ImageDetails.qml
new file mode 100644
index 0000000000..42b5e845ea
--- /dev/null
+++ b/examples/demos/flickr/content/ImageDetails.qml
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Flipable {
+ id: container
+
+ property alias frontContainer: containerFront
+ property string photoTitle: ""
+ property string photoTags: ""
+ property int photoWidth
+ property int photoHeight
+ property string photoType
+ property string photoAuthor
+ property string photoDate
+ property string photoUrl
+ property int rating: 2
+ property variant prevScale: 1.0
+
+ property int flipDuration: 1600
+
+ signal closed
+
+ transform: Rotation {
+ id: itemRotation
+ origin.x: container.width / 2;
+ axis.y: 1; axis.z: 0
+ }
+
+ front: Item {
+ id: containerFront; anchors.fill: container
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"; opacity: 0.4
+ }
+
+ Column {
+ spacing: 10
+ anchors {
+ left: parent.left; leftMargin: 10
+ right: parent.right; rightMargin: 10
+ top: parent.top; topMargin: 120
+ }
+ Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width }
+ Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width }
+ }
+ }
+
+ back: Item {
+ anchors.fill: container
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 }
+
+ Progress {
+ anchors.centerIn: parent; width: 200; height: 22
+ progress: bigImage.progress; visible: bigImage.status != Image.Ready
+ }
+
+ Flickable {
+ id: flickable; anchors.fill: parent; clip: true
+ contentWidth: imageContainer.width; contentHeight: imageContainer.height
+
+ function updateMinimumScale() {
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ if (bigImage.width * slider.value > flickable.width) {
+ var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale;
+ flickable.contentX = xoff - flickable.width/2;
+ }
+ if (bigImage.height * slider.value > flickable.height) {
+ var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = slider.value;
+ }
+ }
+
+ onWidthChanged: updateMinimumScale()
+ onHeightChanged: updateMinimumScale()
+
+ Item {
+ id: imageContainer
+ width: Math.max(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.max(bigImage.height * bigImage.scale, flickable.height);
+ Image {
+ id: bigImage; source: container.photoUrl; scale: slider.value
+ anchors.centerIn: parent; smooth: !flickable.movingVertically
+ onStatusChanged : {
+ // Default scale shows the entire image.
+ if (bigImage.status == Image.Ready && bigImage.width != 0) {
+ slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
+ prevScale = Math.min(slider.minimum, 1);
+ slider.value = prevScale;
+ }
+ if (inBackState && bigImage.status == Image.Ready)
+ effectBox.imageInAnim();
+ }
+ property bool inBackState: false
+ onInBackStateChanged:{
+ if(inBackState && bigImage.status == Image.Ready)
+ effectBox.imageInAnim();
+ else if (!inBackState && bigImage.status == Image.Ready)
+ effectBox.imageOutAnim();
+ }
+ }
+ ShaderEffectSource{
+ id: pictureSource
+ sourceItem: bigImage
+ smooth: true
+ //Workaround: Doesn't work below lines
+ width: bigImage.width
+ height: bigImage.width
+ visible: false
+ }
+ Turbulence{//only fill visible rect
+ id: turbulence
+ system: imageSystem
+ anchors.fill: parent
+ strength: 240
+ enabled: false
+ }
+
+ Item{
+ id: effectBox
+ width: bigImage.width * bigImage.scale
+ height: bigImage.height * bigImage.scale
+ anchors.centerIn: parent
+ function imageInAnim(){
+ bigImage.visible = false;
+ noiseIn.visible = true;
+ endEffectTimer.start();
+ }
+ function imageOutAnim(){
+ bigImage.visible = false;
+ noiseIn.visible = false;
+ turbulence.enabled = true;
+ endEffectTimer.start();
+ pixelEmitter.burst(2048);
+ }
+ Timer{
+ id: endEffectTimer
+ interval: flipDuration
+ repeat: false
+ running: false
+ onTriggered:{
+ turbulence.enabled = false;
+ noiseIn.visible = false;
+ bigImage.visible = true;
+ }
+ }
+ ShaderEffect{
+ id: noiseIn
+ anchors.fill: parent
+ property real t: 0
+ visible: false
+ onVisibleChanged: tAnim.start()
+ NumberAnimation{
+ id: tAnim
+ target: noiseIn
+ property: "t"
+ from: 0.0
+ to: 1.0
+ duration: flipDuration
+ }
+ property variant source: pictureSource
+ property variant noise: ShaderEffectSource{
+ sourceItem:Image{
+ source: "images/noise.png"
+ }
+ hideSource: true
+ smooth: false
+ }
+ fragmentShader:"
+ uniform sampler2D noise;
+ uniform sampler2D source;
+ uniform highp float t;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(){
+ //Want to use noise2, but it always returns (0,0)?
+ if(texture2D(noise, qt_TexCoord0).w <= t)
+ gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;
+ else
+ gl_FragColor = vec4(0.,0.,0.,0.);
+ }
+ "
+ }
+ ParticleSystem{
+ id: imageSystem
+ }
+ Emitter{
+ id: pixelEmitter
+ system: imageSystem
+ //anchors.fill: parent
+ width: Math.min(bigImage.width * bigImage.scale, flickable.width);
+ height: Math.min(bigImage.height * bigImage.scale, flickable.height);
+ anchors.centerIn: parent
+ size: 4
+ lifeSpan: flipDuration
+ emitRate: 2048
+ enabled: false
+ }
+ CustomParticle{
+ id: blowOut
+ system: imageSystem
+ property real maxWidth: effectBox.width
+ property real maxHeight: effectBox.height
+ vertexShader:"
+ uniform highp float maxWidth;
+ uniform highp float maxHeight;
+
+ varying highp vec2 fTex2;
+
+ void main() {
+ defaultMain();
+ fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
+ }
+ "
+ property variant pictureTexture: pictureSource
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D pictureTexture;
+ varying highp vec2 fTex2;
+ void main() {
+ gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity;
+ }"
+ }
+
+
+
+ }
+ }
+ }
+
+ Text {
+ text: "Image Unavailable"
+ visible: bigImage.status == Image.Error
+ anchors.centerIn: parent; color: "white"; font.bold: true
+ }
+
+ Slider {
+ id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum }
+ anchors {
+ bottom: parent.bottom; bottomMargin: 65
+ left: parent.left; leftMargin: 25
+ right: parent.right; rightMargin: 25
+ }
+ onValueChanged: {
+ if (bigImage.width * value > flickable.width) {
+ 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.contentY) * value / prevScale;
+ flickable.contentY = yoff - flickable.height/2;
+ }
+ prevScale = value;
+ }
+ }
+ }
+
+ states: State {
+ name: "Back"
+ PropertyChanges { target: itemRotation; angle: 180 }
+ PropertyChanges { target: toolBar; button2Visible: false }
+ PropertyChanges { target: toolBar; button1Label: "Back" }
+ PropertyChanges { target: bigImage; inBackState: true }
+ }
+
+ transitions: Transition {
+ SequentialAnimation {
+ PropertyAction { target: bigImage; property: "smooth"; value: false }
+ NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration }
+ PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically }
+ }
+ }
+}
diff --git a/examples/demos/flickr/content/ListDelegate.qml b/examples/demos/flickr/content/ListDelegate.qml
new file mode 100644
index 0000000000..00f837f862
--- /dev/null
+++ b/examples/demos/flickr/content/ListDelegate.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ Item {
+ id: wrapper; width: wrapper.ListView.view.width; height: 86
+ Item {
+ id: moveMe
+ Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
+ Rectangle {
+ x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true
+
+ Image { source: imagePath; x: 1; y: 1 }
+ Image { source: "images/gloss.png" }
+ }
+ Column {
+ x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
+ Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
+ Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
+ Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
+ }
+ }
+ }
+}
diff --git a/examples/demos/flickr/content/Progress.qml b/examples/demos/flickr/content/Progress.qml
new file mode 100644
index 0000000000..ed2629b48a
--- /dev/null
+++ b/examples/demos/flickr/content/Progress.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item{
+ id: container
+ property variant progress: 0
+
+ Rectangle {
+ anchors.fill: parent; smooth: true
+ border.color: "white"; border.width: 0; radius: height/2 - 2
+ gradient: Gradient {
+ GradientStop { position: 0; color: "#66343434" }
+ GradientStop { position: 1.0; color: "#66000000" }
+ }
+ }
+
+ ParticleSystem{
+ running: container.visible
+ id: barSys
+ }
+ ImageParticle{
+ color: "lightsteelblue"
+ alpha: 0.1
+ colorVariation: 0.05
+ source: "images/particle.png"
+ system: barSys
+ }
+ Emitter{
+ y: 2; height: parent.height-4;
+ x: 2; width: Math.max(parent.width * progress - 4, 0);
+ speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 }
+ system: barSys
+ emitRate: width;
+ lifeSpan: 1000
+ size: 20
+ sizeVariation: 4
+ endSize: 12
+ maximumEmitted: parent.width;
+ }
+
+ Text {
+ text: Math.round(progress * 100) + "%"
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15
+ }
+}
diff --git a/examples/demos/flickr/content/RssModel.qml b/examples/demos/flickr/content/RssModel.qml
new file mode 100644
index 0000000000..51cea498e6
--- /dev/null
+++ b/examples/demos/flickr/content/RssModel.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2"
+ query: "/rss/channel/item"
+ namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" }
+ XmlRole { name: "url"; query: "media:content/@url/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "tags"; query: "media:category/string()" }
+ XmlRole { name: "photoWidth"; query: "media:content/@width/string()" }
+ XmlRole { name: "photoHeight"; query: "media:content/@height/string()" }
+ XmlRole { name: "photoType"; query: "media:content/@type/string()" }
+ XmlRole { name: "photoAuthor"; query: "author/string()" }
+ XmlRole { name: "photoDate"; query: "pubDate/string()" }
+}
diff --git a/examples/demos/flickr/content/ScrollBar.qml b/examples/demos/flickr/content/ScrollBar.qml
new file mode 100644
index 0000000000..7c62ad088f
--- /dev/null
+++ b/examples/demos/flickr/content/ScrollBar.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant flickableArea
+
+ Rectangle {
+ radius: 5
+ color: "black"
+ opacity: 0.3
+ border.color: "white"
+ border.width: 2
+ x: 0
+ y: flickableArea.visibleArea.yPosition * container.height
+ width: parent.width
+ height: flickableArea.visibleArea.heightRatio * container.height
+ }
+ states: [
+ State {
+ name: "show"
+ when: flickableArea.movingVertically
+ PropertyChanges {
+ target: container
+ opacity: 1
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ target: container
+ properties: "opacity"
+ duration: 400
+ }
+ }
+ ]
+}
diff --git a/examples/demos/flickr/content/Slider.qml b/examples/demos/flickr/content/Slider.qml
new file mode 100644
index 0000000000..c4e743641f
--- /dev/null
+++ b/examples/demos/flickr/content/Slider.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: slider; width: 400; height: 16
+
+ // value is read/write.
+ property real value: 1
+ onValueChanged: updatePos();
+ property real maximum: 1
+ property real minimum: 1
+ property int xMax: width - handle.width - 4
+ onXMaxChanged: updatePos();
+ onMinimumChanged: updatePos();
+
+ function updatePos() {
+ if (maximum > minimum) {
+ var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum);
+ pos = Math.min(pos, width - handle.width - 2);
+ pos = Math.max(pos, 2);
+ handle.x = pos;
+ } else {
+ handle.x = 2;
+ }
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ border.color: "white"; border.width: 0; radius: 8
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#66343434" }
+ GradientStop { position: 1.0; color: "#66000000" }
+ }
+ }
+
+ Rectangle {
+ id: handle; smooth: true
+ y: 2; width: 30; height: slider.height-4; radius: 6
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightgray" }
+ GradientStop { position: 1.0; color: "gray" }
+ }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent; drag.target: parent
+ drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2
+ onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
+ }
+ }
+}
diff --git a/examples/demos/flickr/content/TitleBar.qml b/examples/demos/flickr/content/TitleBar.qml
new file mode 100644
index 0000000000..223939f81a
--- /dev/null
+++ b/examples/demos/flickr/content/TitleBar.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string untaggedString: "Uploads from everyone"
+ property string taggedString: "Recent uploads tagged "
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Item {
+ id: container
+ width: (parent.width * 2) - 55 ; height: parent.height
+
+ function accept() {
+ imageDetails.closed()
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
+ }
+
+ Image {
+ id: quitButton
+ anchors.left: parent.left//; anchors.leftMargin: 0
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
+ font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black"
+ }
+
+ Button {
+ id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
+ onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Item {
+ id: lineEdit
+ y: 4; height: parent.height - 9
+ anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
+
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+
+ TextInput {
+ id: editor
+ anchors {
+ left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ cursorVisible: true; font.bold: true
+ color: "#151515"; selectionColor: "Green"
+ }
+
+ Keys.forwardTo: [ (returnKey), (editor)]
+
+ Item {
+ id: returnKey
+ Keys.onReturnPressed: container.accept()
+ Keys.onEnterPressed: container.accept()
+ Keys.onEscapePressed: titleBar.state = ""
+ }
+ }
+ }
+
+ states: State {
+ name: "Tags"
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: tagButton; text: "OK" }
+ PropertyChanges { target: editor; focus: true }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
+ }
+}
diff --git a/examples/demos/flickr/content/ToolBar.qml b/examples/demos/flickr/content/ToolBar.qml
new file mode 100644
index 0000000000..356993b41a
--- /dev/null
+++ b/examples/demos/flickr/content/ToolBar.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
+ property alias button2Visible: button2.visible
+
+ signal button1Clicked
+ signal button2Clicked
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Row {
+ anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30
+ Button {
+ id: button1
+ width: 140; height: 32
+ onClicked: toolbar.button1Clicked()
+ }
+
+ Button {
+ id: button2; width: 140; height: 32
+ onClicked: toolbar.button2Clicked()
+ }
+ }
+}
diff --git a/examples/demos/flickr/content/UnifiedDelegate.qml b/examples/demos/flickr/content/UnifiedDelegate.qml
new file mode 100644
index 0000000000..0b068c0abe
--- /dev/null
+++ b/examples/demos/flickr/content/UnifiedDelegate.qml
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Package {
+ function photoClicked() {
+ imageDetails.photoTitle = title;
+ imageDetails.photoTags = tags;
+ imageDetails.photoWidth = photoWidth;
+ imageDetails.photoHeight = photoHeight;
+ imageDetails.photoType = photoType;
+ imageDetails.photoAuthor = photoAuthor;
+ imageDetails.photoDate = photoDate;
+ imageDetails.photoUrl = url;
+ imageDetails.rating = 0;
+ scaleMe.state = "Details";
+ }
+
+ Item {
+ id: gridwrapper;
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+ Package.name: "grid"
+ }
+ Item {
+ id: streamwrapper;
+ width: 80; height: 80
+ Package.name: "stream"
+ }
+ Item {
+ //anchors.centerIn: parent//Doesn't animate :(
+ width: 80; height: 80
+ scale: 0.0
+ Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
+ id: scaleMe
+
+ Item {
+ id: whiteRectContainer
+ width: 77; height: 77; anchors.centerIn: parent
+ Rectangle {
+ id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
+ x:0; y:0
+ Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
+ Image { source: "images/gloss.png" }
+ MouseArea { anchors.fill: parent; onClicked: photoClicked() }
+ }
+ }
+
+ Connections {
+ target: toolBar
+ onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
+ }
+
+ state: 'inStream'
+ states: [
+ State {
+ name: "Show"; when: thumb.status == Image.Ready
+ PropertyChanges { target: scaleMe; scale: 1; }
+ },
+ State {
+ name: "Details"
+ PropertyChanges { target: scaleMe; scale: 1 }
+ ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
+ PropertyChanges { target: background; state: "DetailedView" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "Show"; to: "Details"
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ },
+ Transition {
+ from: "Details"; to: "Show"
+ SequentialAnimation{
+ ParentAnimation {
+ via: foreground
+ NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+ }
+ }
+ ]
+ Item{
+ id: stateContainer
+ states: [
+ State {
+ name: 'inStream'
+ when: screen.inGridView == false
+ ParentChange {
+ target: scaleMe; parent: streamwrapper
+ x: 0; y: 0;
+ }
+ },
+ State {
+ name: 'inGrid'
+ when: screen.inGridView == true
+ ParentChange {
+ target: scaleMe; parent: gridwrapper
+ x: 0; y: 0;
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/demos/flickr/content/images/gloss.png b/examples/demos/flickr/content/images/gloss.png
new file mode 100644
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/demos/flickr/content/images/gloss.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/lineedit.png b/examples/demos/flickr/content/images/lineedit.png
new file mode 100644
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/demos/flickr/content/images/lineedit.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/lineedit.sci b/examples/demos/flickr/content/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/demos/flickr/content/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/demos/flickr/content/images/noise.png b/examples/demos/flickr/content/images/noise.png
new file mode 100644
index 0000000000..c5a5ba0053
--- /dev/null
+++ b/examples/demos/flickr/content/images/noise.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/particle.png b/examples/demos/flickr/content/images/particle.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/demos/flickr/content/images/particle.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/quit.png b/examples/demos/flickr/content/images/quit.png
new file mode 100644
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/demos/flickr/content/images/quit.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/squareParticle.png b/examples/demos/flickr/content/images/squareParticle.png
new file mode 100644
index 0000000000..faf85c24e0
--- /dev/null
+++ b/examples/demos/flickr/content/images/squareParticle.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/stripes.png b/examples/demos/flickr/content/images/stripes.png
new file mode 100644
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/demos/flickr/content/images/stripes.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/titlebar.png b/examples/demos/flickr/content/images/titlebar.png
new file mode 100644
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/demos/flickr/content/images/titlebar.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/titlebar.sci b/examples/demos/flickr/content/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/demos/flickr/content/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/demos/flickr/content/images/toolbutton.png b/examples/demos/flickr/content/images/toolbutton.png
new file mode 100644
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/demos/flickr/content/images/toolbutton.png
Binary files differ
diff --git a/examples/demos/flickr/content/images/toolbutton.sci b/examples/demos/flickr/content/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/demos/flickr/content/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/demos/flickr/content/qmldir b/examples/demos/flickr/content/qmldir
new file mode 100644
index 0000000000..adc2479b9f
--- /dev/null
+++ b/examples/demos/flickr/content/qmldir
@@ -0,0 +1,10 @@
+ImageDetails ImageDetails.qml
+LikeOMeter LikeOMeter.qml
+Loading Loading.qml
+MediaButton MediaButton.qml
+MediaLineEdit MediaLineEdit.qml
+Progress Progress.qml
+RssModel RssModel.qml
+ScrollBar ScrollBar.qml
+Slider Slider.qml
+Star Star.qml
diff --git a/examples/demos/flickr/flickr-90.qml b/examples/demos/flickr/flickr-90.qml
new file mode 100644
index 0000000000..b95b1c9872
--- /dev/null
+++ b/examples/demos/flickr/flickr-90.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ width: 480; height: 320
+
+ Loader {
+ y: 320; rotation: -90
+ transformOrigin: Item.TopLeft
+ source: "flickr.qml"
+ }
+}
diff --git a/examples/demos/flickr/flickr.qml b/examples/demos/flickr/flickr.qml
new file mode 100644
index 0000000000..98ca5197ab
--- /dev/null
+++ b/examples/demos/flickr/flickr.qml
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Item {
+ id: screen; width: 320; height: 480
+ property bool inGridView : true
+
+ Rectangle {
+ id: background
+ anchors.fill: parent; color: "#343434";
+
+ Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
+ ParticleSystem {
+ id: bgParticles
+ anchors.fill: parent
+ ImageParticle {
+ groups: ["trail"]
+ source: "content/images/particle.png"
+ color: "#1A1A6F"
+ alpha: 0.1
+ colorVariation: 0.01
+ blueVariation: 0.8
+ }
+ Emitter {
+ group: "drops"
+ width: parent.width
+ emitRate: 0.5
+ lifeSpan: 20000
+ startTime: 16000
+ speed: PointDirection{
+ y: {screen.height/18}
+ }
+ }
+ TrailEmitter {
+ follow: "drops"
+ group: "trail"
+ emitRatePerParticle: 18
+ size: 32
+ endSize: 0
+ sizeVariation: 4
+ lifeSpan: 1200
+ anchors.fill: parent
+ emitWidth: 16
+ emitHeight: 16
+ emitShape: EllipseShape{}
+ }
+ }
+
+ VisualDataModel{
+ id: vdm
+ delegate: UnifiedDelegate{}
+ model: RssModel { id: rssModel }
+ }
+
+ Item {
+ id: views
+ width: parent.width
+ anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
+
+ GridView {
+ id: photoGridView; model: vdm.parts.grid
+ cacheBuffer: 1000
+ cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height
+ }
+
+ states: State {
+ name: "GridView"; when: state.inGridView == true
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+
+ ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height }
+
+ Item { id: foreground; anchors.fill: parent }
+ }
+
+ TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 }
+
+ ToolBar {
+ id: toolBar
+ height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
+ button1Label: "Update"; button2Label: "View mode"
+ onButton1Clicked: rssModel.reload()
+ onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true
+ }
+
+ Connections {
+ target: imageDetails
+ onClosed: {
+ if (background.state == "DetailedView") {
+ background.state = '';
+ imageDetails.photoUrl = "";
+ }
+ }
+ }
+
+ states: State {
+ name: "DetailedView"
+ PropertyChanges { target: views; x: -parent.width }
+ PropertyChanges { target: toolBar; button1Label: "View..." }
+ PropertyChanges {
+ target: toolBar
+ onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state=''
+ }
+ PropertyChanges { target: toolBar; button2Label: "Back" }
+ PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
+ }
+
+ }
+}
diff --git a/examples/demos/flickr/flickr.qmlproject b/examples/demos/flickr/flickr.qmlproject
new file mode 100644
index 0000000000..af5179d84b
--- /dev/null
+++ b/examples/demos/flickr/flickr.qmlproject
@@ -0,0 +1,17 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "flickr.qml"
+ //mainFile: "flickr-90.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/demos/minehunt/MinehuntCore/Explosion.qml b/examples/demos/minehunt/MinehuntCore/Explosion.qml
new file mode 100644
index 0000000000..a1b4292bcf
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/Explosion.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ property bool explode : false
+ ParticleSystem {
+ width: 40
+ height: 40
+ ImageParticle {
+ groups: ["star"]
+ source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed
+ }
+ Emitter {
+ id: particles
+ enabled: false
+ anchors.centerIn: parent
+ group: "star"
+ speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 }
+ emitRate: 200
+ z: 100
+ lifeSpan: 1000
+ }
+ }
+ states: State { name: "exploding"; when: explode
+ StateChangeScript { script: particles.burst(200); }
+ }
+
+}
diff --git a/examples/demos/minehunt/MinehuntCore/Tile.qml b/examples/demos/minehunt/MinehuntCore/Tile.qml
new file mode 100644
index 0000000000..1180b6f584
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/Tile.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: flipable
+ property int angle: 0
+
+ width: 40; height: 40
+ transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle }
+
+ front: Image {
+ source: "pics/front.png"; width: 40; height: 40
+
+ Image {
+ anchors.centerIn: parent
+ source: "pics/flag.png"; opacity: modelData.hasFlag
+
+ Behavior on opacity { NumberAnimation {} }
+ }
+ }
+
+ back: Image {
+ source: "pics/back.png"
+ width: 40; height: 40
+
+ Text {
+ anchors.centerIn: parent
+ text: modelData.hint; color: "white"; font.bold: true
+ opacity: !modelData.hasMine && modelData.hint > 0
+ }
+
+ Image {
+ anchors.centerIn: parent
+ source: "pics/bomb.png"; opacity: modelData.hasMine
+ }
+
+ Explosion { id: expl }
+ }
+
+ states: State {
+ name: "back"; when: modelData.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ property real pauseDur: 250
+ transitions: Transition {
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ var ret = Math.abs(flipable.x - field.clickx)
+ + Math.abs(flipable.y - field.clicky);
+ if (modelData.hasMine && modelData.flipped)
+ pauseDur = ret * 3
+ else
+ pauseDur = ret
+ }
+ }
+ PauseAnimation {
+ duration: pauseDur
+ }
+ RotationAnimation { easing.type: Easing.InOutQuad }
+ ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ field.clickx = flipable.x
+ field.clicky = flipable.y
+ var row = Math.floor(index / 9)
+ var col = index - (Math.floor(index / 9) * 9)
+ if (mouse.button == undefined || mouse.button == Qt.RightButton) {
+ flag(row, col)
+ } else {
+ flip(row, col)
+ }
+ }
+ onPressAndHold: {
+ field.clickx = flipable.x
+ field.clicky = flipable.y
+ var row = Math.floor(index / 9)
+ var col = index - (Math.floor(index / 9) * 9)
+ flag(row, col)
+ }
+ }
+}
diff --git a/examples/demos/minehunt/MinehuntCore/pics/back.png b/examples/demos/minehunt/MinehuntCore/pics/back.png
new file mode 100644
index 0000000000..f6b3f0b4d7
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/back.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/background.png b/examples/demos/minehunt/MinehuntCore/pics/background.png
new file mode 100644
index 0000000000..3734a27744
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/background.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/bomb-color.png b/examples/demos/minehunt/MinehuntCore/pics/bomb-color.png
new file mode 100644
index 0000000000..61ad0a928f
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/bomb-color.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/bomb.png b/examples/demos/minehunt/MinehuntCore/pics/bomb.png
new file mode 100644
index 0000000000..a992575518
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/bomb.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/face-sad.png b/examples/demos/minehunt/MinehuntCore/pics/face-sad.png
new file mode 100644
index 0000000000..cf00aafe1f
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/face-sad.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png
new file mode 100644
index 0000000000..f9c2335df5
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/face-smile.png b/examples/demos/minehunt/MinehuntCore/pics/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/face-smile.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/flag-color.png b/examples/demos/minehunt/MinehuntCore/pics/flag-color.png
new file mode 100644
index 0000000000..aadad0f11a
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/flag-color.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/flag.png b/examples/demos/minehunt/MinehuntCore/pics/flag.png
new file mode 100644
index 0000000000..39cde4df82
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/flag.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/front.png b/examples/demos/minehunt/MinehuntCore/pics/front.png
new file mode 100644
index 0000000000..834331bd49
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/front.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/quit.png b/examples/demos/minehunt/MinehuntCore/pics/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/quit.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/pics/star.png b/examples/demos/minehunt/MinehuntCore/pics/star.png
new file mode 100644
index 0000000000..3772359188
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/pics/star.png
Binary files differ
diff --git a/examples/demos/minehunt/MinehuntCore/qmldir b/examples/demos/minehunt/MinehuntCore/qmldir
new file mode 100644
index 0000000000..a0213a19c4
--- /dev/null
+++ b/examples/demos/minehunt/MinehuntCore/qmldir
@@ -0,0 +1,2 @@
+Explosion 2.0 Explosion.qml
+Tile 2.0 Tile.qml
diff --git a/examples/demos/minehunt/README b/examples/demos/minehunt/README
new file mode 100644
index 0000000000..3849ca5fbf
--- /dev/null
+++ b/examples/demos/minehunt/README
@@ -0,0 +1,6 @@
+Minehunt has to be compiled to run.
+
+To compile the C++ part, do 'qmake && make'.
+To run, simply run the executable.
+To deploy on a device, do 'make sis'.
+
diff --git a/examples/demos/minehunt/main.cpp b/examples/demos/minehunt/main.cpp
new file mode 100644
index 0000000000..0aa11a1d7a
--- /dev/null
+++ b/examples/demos/minehunt/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQuick/qquickview.h>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
+
+#include "minehunt.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQuickView canvas;
+
+ qmlRegisterType<TileData>();
+ MinehuntGame* game = new MinehuntGame();
+
+ canvas.setResizeMode(QQuickView::SizeRootObjectToView);
+ canvas.engine()->rootContext()->setContextObject(game);
+ canvas.setSource(QString("qrc:///minehunt.qml"));
+ QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit()));
+
+ canvas.show();
+ return app.exec();
+}
diff --git a/examples/demos/minehunt/minehunt.cpp b/examples/demos/minehunt/minehunt.cpp
new file mode 100644
index 0000000000..cde30278b3
--- /dev/null
+++ b/examples/demos/minehunt/minehunt.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdlib.h>
+#include <QTime>
+#include <QTimer>
+
+#include "minehunt.h"
+
+void tilesPropAppend(QQmlListProperty<TileData>* prop, TileData* value)
+{
+ Q_UNUSED(prop);
+ Q_UNUSED(value);
+ return; //Append not supported
+}
+
+int tilesPropCount(QQmlListProperty<TileData>* prop)
+{
+ return static_cast<QList<TileData*>*>(prop->data)->count();
+}
+
+TileData* tilesPropAt(QQmlListProperty<TileData>* prop, int index)
+{
+ return static_cast<QList<TileData*>*>(prop->data)->at(index);
+}
+
+QQmlListProperty<TileData> MinehuntGame::tiles(){
+ return QQmlListProperty<TileData>(this, &_tiles, &tilesPropAppend,
+ &tilesPropCount, &tilesPropAt, 0);
+}
+
+MinehuntGame::MinehuntGame()
+: numCols(9), numRows(9), playing(true), won(false)
+{
+ setObjectName("mainObject");
+ srand(QTime(0,0,0).secsTo(QTime::currentTime()));
+
+ //initialize array
+ for(int ii = 0; ii < numRows * numCols; ++ii) {
+ _tiles << new TileData;
+ }
+ reset();
+
+}
+
+void MinehuntGame::setBoard()
+{
+ foreach(TileData* t, _tiles){
+ t->setHasMine(false);
+ t->setHint(-1);
+ }
+ //place mines
+ int mines = nMines;
+ remaining = numRows*numCols-mines;
+ while ( mines ) {
+ int col = int((double(rand()) / double(RAND_MAX)) * numCols);
+ int row = int((double(rand()) / double(RAND_MAX)) * numRows);
+
+ TileData* t = tile( row, col );
+
+ if (t && !t->hasMine()) {
+ t->setHasMine( true );
+ mines--;
+ }
+ }
+
+ //set hints
+ for (int r = 0; r < numRows; r++)
+ for (int c = 0; c < numCols; c++) {
+ TileData* t = tile(r, c);
+ if (t && !t->hasMine()) {
+ int hint = getHint(r,c);
+ t->setHint(hint);
+ }
+ }
+
+ setPlaying(true);
+}
+
+void MinehuntGame::reset()
+{
+ foreach(TileData* t, _tiles){
+ t->unflip();
+ t->setHasFlag(false);
+ }
+ nMines = 12;
+ nFlags = 0;
+ emit numMinesChanged();
+ emit numFlagsChanged();
+ setPlaying(false);
+ QTimer::singleShot(600,this, SLOT(setBoard()));
+}
+
+int MinehuntGame::getHint(int row, int col)
+{
+ int hint = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData* t = tile(r, c);
+ if (t && t->hasMine())
+ hint++;
+ }
+ return hint;
+}
+
+bool MinehuntGame::flip(int row, int col)
+{
+ if(!playing)
+ return false;
+
+ TileData *t = tile(row, col);
+ if (!t || t->hasFlag())
+ return false;
+
+ if(t->flipped()){
+ int flags = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData *nearT = tile(r, c);
+ if(!nearT || nearT == t)
+ continue;
+ if(nearT->hasFlag())
+ flags++;
+ }
+ if(!t->hint() || t->hint() != flags)
+ return false;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData *nearT = tile(r, c);
+ if (nearT && !nearT->flipped() && !nearT->hasFlag()) {
+ flip( r, c );
+ }
+ }
+ return true;
+ }
+
+ t->flip();
+
+ if (t->hint() == 0) {
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ TileData* t = tile(r, c);
+ if (t && !t->flipped()) {
+ flip( r, c );
+ }
+ }
+ }
+
+ if(t->hasMine()){
+ for (int r = 0; r < numRows; r++)//Flip all other mines
+ for (int c = 0; c < numCols; c++) {
+ TileData* t = tile(r, c);
+ if (t && t->hasMine()) {
+ flip(r, c);
+ }
+ }
+ won = false;
+ hasWonChanged();
+ setPlaying(false);
+ return true;
+ }
+
+ remaining--;
+ if(!remaining){
+ won = true;
+ hasWonChanged();
+ setPlaying(false);
+ return true;
+ }
+ return true;
+}
+
+bool MinehuntGame::flag(int row, int col)
+{
+ TileData *t = tile(row, col);
+ if(!t || !playing || t->flipped())
+ return false;
+
+ t->setHasFlag(!t->hasFlag());
+ nFlags += (t->hasFlag()?1:-1);
+ emit numFlagsChanged();
+ return true;
+}
diff --git a/examples/demos/minehunt/minehunt.h b/examples/demos/minehunt/minehunt.h
new file mode 100644
index 0000000000..34bab71218
--- /dev/null
+++ b/examples/demos/minehunt/minehunt.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <qqml.h>
+
+class TileData : public QObject
+{
+ Q_OBJECT
+public:
+ TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {}
+
+ Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged)
+ bool hasFlag() const { return _hasFlag; }
+
+ Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged)
+ bool hasMine() const { return _hasMine; }
+
+ Q_PROPERTY(int hint READ hint NOTIFY hintChanged)
+ int hint() const { return _hint; }
+
+ Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged())
+ bool flipped() const { return _flipped; }
+
+ void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();}
+ void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();}
+ void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); }
+ void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); }
+ void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); }
+
+signals:
+ void flippedChanged();
+ void hasFlagChanged();
+ void hintChanged();
+ void hasMineChanged();
+
+private:
+ bool _hasFlag;
+ bool _hasMine;
+ int _hint;
+ bool _flipped;
+};
+
+class MinehuntGame : public QObject
+{
+ Q_OBJECT
+public:
+ MinehuntGame();
+
+ Q_PROPERTY(QQmlListProperty<TileData> tiles READ tiles CONSTANT)
+ QQmlListProperty<TileData> tiles();
+
+ Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
+ bool isPlaying() {return playing;}
+
+ Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged)
+ bool hasWon() {return won;}
+
+ Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged)
+ int numMines() const{return nMines;}
+
+ Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged)
+ int numFlags() const{return nFlags;}
+
+public slots:
+ Q_INVOKABLE bool flip(int row, int col);
+ Q_INVOKABLE bool flag(int row, int col);
+ void setBoard();
+ void reset();
+
+signals:
+ void isPlayingChanged();
+ void hasWonChanged();
+ void numMinesChanged();
+ void numFlagsChanged();
+
+private:
+ bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
+ TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; }
+ int getHint(int row, int col);
+ void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();}
+
+ QList<TileData *> _tiles;
+ int numCols;
+ int numRows;
+ bool playing;
+ bool won;
+ int remaining;
+ int nMines;
+ int nFlags;
+};
diff --git a/examples/demos/minehunt/minehunt.pro b/examples/demos/minehunt/minehunt.pro
new file mode 100644
index 0000000000..78e874d805
--- /dev/null
+++ b/examples/demos/minehunt/minehunt.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += minehunt.h
+SOURCES += main.cpp minehunt.cpp
+RESOURCES = minehunt.qrc
diff --git a/examples/demos/minehunt/minehunt.qml b/examples/demos/minehunt/minehunt.qml
new file mode 100644
index 0000000000..42dc408fff
--- /dev/null
+++ b/examples/demos/minehunt/minehunt.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "MinehuntCore" 2.0
+
+Item {
+ id: field
+ property int clickx: 0
+ property int clicky: 0
+
+ width: 450; height: 450
+
+ Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile }
+
+ Grid {
+ anchors.horizontalCenter: parent.horizontalCenter
+ columns: 9; spacing: 1
+
+ Repeater {
+ id: repeater
+ model: tiles
+ delegate: Tile {}
+ }
+ }
+
+ Row {
+ id: gamedata
+ x: 20; spacing: 20
+ anchors.bottom: field.bottom; anchors.bottomMargin: 15
+
+ Image {
+ source: "MinehuntCore/pics/quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ y: 10
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -20
+ onClicked: Qt.quit()
+ }
+ }
+ Column {
+ spacing: 2
+ Image { source: "MinehuntCore/pics/bomb-color.png" }
+ Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines }
+ }
+
+ Column {
+ spacing: 2
+ Image { source: "MinehuntCore/pics/flag-color.png" }
+ Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags }
+ }
+ }
+
+ Image {
+ anchors.bottom: field.bottom; anchors.bottomMargin: 15
+ anchors.right: field.right; anchors.rightMargin: 20
+ source: isPlaying ? 'MinehuntCore/pics/face-smile.png' :
+ hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png'
+
+ MouseArea { anchors.fill: parent; onPressed: reset() }
+ }
+ Text {
+ anchors.centerIn: parent; width: parent.width - 20
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.WordWrap
+ text: "Minehunt demo has to be compiled to run.\n\nPlease see README."
+ color: "white"; font.bold: true; font.pixelSize: 14
+ visible: tiles == undefined
+ }
+
+}
diff --git a/examples/demos/minehunt/minehunt.qmlproject b/examples/demos/minehunt/minehunt.qmlproject
new file mode 100644
index 0000000000..5aeb78f1ea
--- /dev/null
+++ b/examples/demos/minehunt/minehunt.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "minehunt.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/demos/minehunt/minehunt.qrc b/examples/demos/minehunt/minehunt.qrc
new file mode 100644
index 0000000000..fa8e27d383
--- /dev/null
+++ b/examples/demos/minehunt/minehunt.qrc
@@ -0,0 +1,20 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>minehunt.qml</file>
+ <file>MinehuntCore/Explosion.qml</file>
+ <file>MinehuntCore/Tile.qml</file>
+ <file>MinehuntCore/qmldir</file>
+ <file>MinehuntCore/pics/background.png</file>
+ <file>MinehuntCore/pics/back.png</file>
+ <file>MinehuntCore/pics/bomb-color.png</file>
+ <file>MinehuntCore/pics/bomb.png</file>
+ <file>MinehuntCore/pics/face-sad.png</file>
+ <file>MinehuntCore/pics/face-smile-big.png</file>
+ <file>MinehuntCore/pics/face-smile.png</file>
+ <file>MinehuntCore/pics/flag-color.png</file>
+ <file>MinehuntCore/pics/flag.png</file>
+ <file>MinehuntCore/pics/front.png</file>
+ <file>MinehuntCore/pics/quit.png</file>
+ <file>MinehuntCore/pics/star.png</file>
+</qresource>
+</RCC>
diff --git a/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
new file mode 100644
index 0000000000..164f47faa9
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Component {
+ id: albumDelegate
+ Package {
+
+ Item {
+ Package.name: 'browser'
+ GridView {
+ id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21
+ x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false
+ onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain)
+ }
+ }
+
+ Item {
+ Package.name: 'fullscreen'
+ ListView {
+ id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal
+ width: mainWindow.width; height: mainWindow.height; interactive: false
+ onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
+ highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
+ }
+ }
+
+ Item {
+ Package.name: 'album'
+ id: albumWrapper; width: 210; height: 220
+
+ VisualDataModel {
+ id: visualModel; delegate: PhotoDelegate { }
+ model: RssModel { id: rssModel; tags: tag }
+ }
+
+ BusyIndicator {
+ id: busyIndicator
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ on: rssModel.status != XmlListModel.Ready
+ }
+
+ PathView {
+ id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
+ visible: !busyIndicator.visible
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -30
+ path: Path {
+ PathAttribute { name: 'z'; value: 9999.0 }
+ PathLine { x: 1; y: 1 }
+ PathAttribute { name: 'z'; value: 0.0 }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
+ }
+
+ Tag {
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
+ frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode
+ onTagChanged: rssModel.tags = tag
+ onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
+ }
+
+ states: [
+ State {
+ name: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: true }
+ PropertyChanges { target: albumsShade; opacity: 1 }
+ PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 }
+ },
+ State {
+ name: 'fullscreen'; extend: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: false }
+ PropertyChanges { target: photosListView; interactive: true }
+ PropertyChanges { target: photosShade; opacity: 1 }
+ PropertyChanges { target: backButton; y: -backButton.height - 8 }
+ }
+ ]
+
+ GridView.onAdd: NumberAnimation {
+ target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad
+ }
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true }
+ NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad }
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false }
+ }
+
+ transitions: [
+ Transition {
+ from: '*'; to: 'inGrid'
+ SequentialAnimation {
+ NumberAnimation { properties: 'opacity'; duration: 250 }
+ PauseAnimation { duration: 350 }
+ NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: '*'
+ NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
new file mode 100644
index 0000000000..867c268399
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+ NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/Button.qml b/examples/demos/photoviewer/PhotoViewerCore/Button.qml
new file mode 100644
index 0000000000..8f4177c097
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/Button.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property alias label: labelText.text
+ property color tint: "transparent"
+ signal clicked
+
+ width: labelText.width + 70 ; height: labelText.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ Rectangle {
+ anchors.fill: container; color: container.tint; visible: container.tint != ""
+ opacity: 0.25; smooth: true
+ }
+
+ Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml
new file mode 100644
index 0000000000..435ad2644f
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property string label
+ signal clicked
+ signal labelChanged(string label)
+
+ width: textInput.width + 70 ; height: textInput.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true }
+
+ TextInput {
+ id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true
+ Keys.onReturnPressed: {
+ container.labelChanged(textInput.text)
+ container.focus = true
+ }
+ Keys.onEnterPressed: {
+ container.labelChanged(textInput.text)
+ container.focus = true
+ }
+ Keys.onEscapePressed: {
+ textInput.text = container.label
+ container.focus = true
+ }
+ }
+
+ Rectangle {
+ anchors.fill: container; border.color: "steelblue"; border.width: 4
+ color: "transparent"; visible: textInput.focus; smooth: true
+ }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); }
+ }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
new file mode 100644
index 0000000000..5d4e5aee5d
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "script/script.js" as Script
+
+Package {
+ Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
+ Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 }
+ Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 }
+
+ Item {
+ width: 160; height: 153
+
+ Item {
+ id: photoWrapper
+
+ property double randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property double randomAngle2: Math.random() * (2 * 6 + 1) - 6
+
+ x: 0; y: 0; width: 140; height: 133
+ z: stackItem.PathView.z; rotation: photoWrapper.randomAngle
+
+ BorderImage {
+ anchors {
+ fill: originalImage.status == Image.Ready ? border : placeHolder
+ leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8
+ }
+ source: 'images/box-shadow.png'; smooth: true
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+ Rectangle {
+ id: placeHolder
+
+ property int w: Script.getWidth(content)
+ property int h: Script.getHeight(content)
+ property double s: Script.calculateScale(w, h, photoWrapper.width)
+
+ color: 'white'; anchors.centerIn: parent; smooth: true
+ width: w * s; height: h * s; visible: originalImage.status != Image.Ready
+ Rectangle {
+ color: "#878787"; smooth: true
+ anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 }
+ }
+ }
+ Rectangle {
+ id: border; color: 'white'; anchors.centerIn: parent; smooth: true
+ width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6
+ visible: !placeHolder.visible
+ }
+ BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready }
+ Image {
+ id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Image {
+ id: hqImage; smooth: true; source: ""; visible: false; cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Binding {
+ target: mainWindow; property: "downloadProgress"; value: hqImage.progress
+ when: listItem.ListView.isCurrentItem
+ }
+ Binding {
+ target: mainWindow; property: "imageLoading"
+ value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem
+ }
+ MouseArea {
+ width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage
+ onClicked: {
+ if (albumWrapper.state == 'inGrid') {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'fullscreen'
+ } else {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'inGrid'
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: 'stacked'; when: albumWrapper.state == ''
+ ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 }
+ PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 }
+ },
+ State {
+ name: 'inGrid'; when: albumWrapper.state == 'inGrid'
+ ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 }
+ },
+ State {
+ name: 'fullscreen'; when: albumWrapper.state == 'fullscreen'
+ ParentChange {
+ target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0
+ width: mainWindow.width; height: mainWindow.height
+ }
+ PropertyChanges { target: border; opacity: 0 }
+ PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: 'stacked'; to: 'inGrid'
+ SequentialAnimation {
+ PauseAnimation { duration: 10 * index }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'stacked'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'fullscreen'
+ SequentialAnimation {
+ PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,opacity,rotation'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'fullscreen'; to: 'inGrid'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,rotation,opacity'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
new file mode 100644
index 0000000000..58beef57f3
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property real progress: 0
+
+ Behavior on opacity { NumberAnimation { duration: 600 } }
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 }
+
+ Rectangle {
+ id: fill; color: "white"; height: container.height
+ width: container.width * container.progress
+ }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml
new file mode 100644
index 0000000000..1598977bb1
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/Tag.qml b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml
new file mode 100644
index 0000000000..ed4a248a7b
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: flipable
+
+ property alias frontLabel: frontButton.label
+ property alias backLabel: backButton.label
+
+ property int angle: 0
+ property int randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property bool flipped: false
+
+ signal frontClicked
+ signal backClicked
+ signal tagChanged(string tag)
+
+ front: EditableButton {
+ id: frontButton; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.frontClicked()
+ onLabelChanged: flipable.tagChanged(label)
+ }
+
+ back: Button {
+ id: backButton; tint: "red"; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.backClicked()
+ }
+
+ transform: Rotation {
+ origin.x: flipable.width / 2; origin.y: flipable.height / 2
+ axis.x: 0; axis.y: 1; axis.z: 0
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"; when: flipable.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "angle"; duration: 400 }
+ SequentialAnimation {
+ NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 }
+ NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 }
+ }
+ }
+ }
+}
diff --git a/examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png
Binary files differ
diff --git a/examples/demos/photoviewer/PhotoViewerCore/images/busy.png b/examples/demos/photoviewer/PhotoViewerCore/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/images/busy.png
Binary files differ
diff --git a/examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png
new file mode 100644
index 0000000000..1847ab528d
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png
Binary files differ
diff --git a/examples/demos/photoviewer/PhotoViewerCore/qmldir b/examples/demos/photoviewer/PhotoViewerCore/qmldir
new file mode 100644
index 0000000000..d3c247f21a
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/qmldir
@@ -0,0 +1,8 @@
+AlbumDelegate AlbumDelegate.qml
+PhotoDelegate PhotoDelegate.qml
+ProgressBar ProgressBar.qml
+RssModel RssModel.qml
+BusyIndicator BusyIndicator.qml
+EditableButton EditableButton.qml
+Button Button.qml
+Tag Tag.qml
diff --git a/examples/demos/photoviewer/PhotoViewerCore/script/script.js b/examples/demos/photoviewer/PhotoViewerCore/script/script.js
new file mode 100644
index 0000000000..e8ef93a847
--- /dev/null
+++ b/examples/demos/photoviewer/PhotoViewerCore/script/script.js
@@ -0,0 +1,27 @@
+.pragma library
+
+function getWidth(string) {
+ return (string.match(/width=\"([0-9]+)\"/))[1]
+}
+
+function getHeight(string) {
+ return (string.match(/height=\"([0-9]+)\"/))[1]
+}
+
+function getImagePath(string) {
+ var pattern = /src=\"http:\/\/(\S+)\"/
+ return (string.match(pattern))[1]
+}
+
+function calculateScale(width, height, cellSize) {
+ var widthScale = (cellSize * 1.0) / width
+ var heightScale = (cellSize * 1.0) / height
+ var scale = 0
+
+ if (widthScale <= heightScale) {
+ scale = widthScale;
+ } else if (heightScale < widthScale) {
+ scale = heightScale;
+ }
+ return scale;
+}
diff --git a/examples/demos/photoviewer/i18n/base.ts b/examples/demos/photoviewer/i18n/base.ts
new file mode 100644
index 0000000000..1accfd2f90
--- /dev/null
+++ b/examples/demos/photoviewer/i18n/base.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/demos/photoviewer/i18n/qml_fr.qm b/examples/demos/photoviewer/i18n/qml_fr.qm
new file mode 100644
index 0000000000..c24fcbc46c
--- /dev/null
+++ b/examples/demos/photoviewer/i18n/qml_fr.qm
Binary files differ
diff --git a/examples/demos/photoviewer/i18n/qml_fr.ts b/examples/demos/photoviewer/i18n/qml_fr.ts
new file mode 100644
index 0000000000..9f892db616
--- /dev/null
+++ b/examples/demos/photoviewer/i18n/qml_fr.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation>Supprimer</translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation>Ajouter</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation>Éditer</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation>Retour</translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/demos/photoviewer/photoviewer.qml b/examples/demos/photoviewer/photoviewer.qml
new file mode 100644
index 0000000000..208720b9e6
--- /dev/null
+++ b/examples/demos/photoviewer/photoviewer.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "PhotoViewerCore"
+
+Rectangle {
+ id: mainWindow
+
+ property real downloadProgress: 0
+ property bool imageLoading: false
+ property bool editMode: false
+
+ width: 800; height: 480; color: "#d5d6d8"
+
+ ListModel {
+ id: photosModel
+ ListElement { tag: "Flowers" }
+ ListElement { tag: "Wildlife" }
+ ListElement { tag: "Prague" }
+ }
+
+ VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
+
+ GridView {
+ id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
+ model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
+ }
+
+ Column {
+ spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 }
+ Button {
+ id: newButton; label: qsTr("Add"); rotation: 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ mainWindow.editMode = false
+ photosModel.append( { tag: "" } )
+ albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain)
+ }
+ }
+ Button {
+ id: deleteButton; label: qsTr("Edit"); rotation: -2;
+ onClicked: mainWindow.editMode = !mainWindow.editMode
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ id: quitButton; label: qsTr("Quit"); rotation: -2;
+ onClicked: Qt.quit()
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Rectangle {
+ id: albumsShade; color: mainWindow.color
+ width: parent.width; height: parent.height; opacity: 0.0
+ }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false }
+
+ Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 }
+
+ Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false }
+
+ Item { id: foreground; anchors.fill: parent }
+
+ ProgressBar {
+ progress: mainWindow.downloadProgress; width: parent.width; height: 4
+ anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0
+ }
+}
diff --git a/examples/demos/photoviewer/photoviewer.qmlproject b/examples/demos/photoviewer/photoviewer.qmlproject
new file mode 100644
index 0000000000..600bdb10f4
--- /dev/null
+++ b/examples/demos/photoviewer/photoviewer.qmlproject
@@ -0,0 +1,20 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "photoviewer.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ Files {
+ filter: "*.ts"
+ directory: "i18n"
+ }
+}
diff --git a/examples/demos/plasmapatrol/PlasmaPatrol.qmlproject b/examples/demos/plasmapatrol/PlasmaPatrol.qmlproject
new file mode 100644
index 0000000000..548295243d
--- /dev/null
+++ b/examples/demos/plasmapatrol/PlasmaPatrol.qmlproject
@@ -0,0 +1,19 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "plasmapatrol.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ Files {
+ paths: ["TODO"]
+ }
+}
diff --git a/examples/demos/plasmapatrol/TODO b/examples/demos/plasmapatrol/TODO
new file mode 100644
index 0000000000..ef9d21a73d
--- /dev/null
+++ b/examples/demos/plasmapatrol/TODO
@@ -0,0 +1,10 @@
+Realistic Tasks:
+Particle explosions on ship death.
+Better help text (both content and styled a little nicer).
+Hardpoint help showing them firing across the screen.
+Endless Demo Mode
+
+Nice-but-i-doubt-it-will-get-done Tasks:
+Particle Text for the winner.
+Particle-based buttons.
+Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish').
diff --git a/examples/demos/plasmapatrol/content/BlasterHardpoint.qml b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml
new file mode 100644
index 0000000000..10c50d43c8
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property Item targetObj: container
+ property Item hardpoint: container
+ property ParticleSystem system
+ property int blasts: 16
+ property int bonusBlasts: 12
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter {
+ id: visualization
+ group: "blaster"
+ system: container.system
+ enabled: show
+ anchors.fill: parent
+ shape: EllipseShape {}
+ speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true}
+ lifeSpan: 1000
+ emitRate: 64
+
+ size: 24
+ sizeVariation: 24
+ endSize: 0
+ }
+
+ property int blastsLeft: 0
+ function fireAt(targetArg, container) {
+ target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
+ targetObj = targetArg;
+ hardpoint = container;
+ blastsLeft = blasts;
+ rofTimer.repeat = true;
+ rofTimer.start();
+ }
+ Timer {
+ id: rofTimer
+ interval: 30;//Has to be greater than 1 frame or they stack up
+ running: false
+ repeat: false
+ onTriggered: {
+ if (targetObj.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var hit;
+ if (blastsLeft >= bonusBlasts)
+ hit = Math.random() > targetObj.dodge;
+ else
+ hit = false; //purely aesthetic shots, because the damage isn't that fine grained
+ if (hit == true) {
+ switch (targetObj.shipType) {
+ case 1: hardpoint.damageDealt += 4; break;
+ case 2: hardpoint.damageDealt += 5; break;
+ case 3: hardpoint.damageDealt += 1; break;
+ default: hardpoint.damageDealt += 100;
+ }
+ }
+ blastVector.targetX = target.x;
+ blastVector.targetY = target.y;
+ if (!hit) {//TODO: Actual targetVariation
+ blastVector.targetX += (128 * Math.random() - 64);
+ blastVector.targetY += (128 * Math.random() - 64);
+ }
+ emitter.burst(1);
+ blastsLeft--;
+ if (!blastsLeft)
+ rofTimer.repeat = false;
+ }
+ }
+ Emitter {
+ id: emitter
+ group: "blaster"
+ enabled: false
+ system: container.system
+ anchors.centerIn: parent
+
+ lifeSpan: 1000
+ emitRate: 16
+ maximumEmitted: blasts
+ size: 24
+ endSize:16
+ sizeVariation: 8
+ speed: TargetDirection {
+ id: blastVector
+ targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
+ }
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/Button.qml b/examples/demos/plasmapatrol/content/Button.qml
new file mode 100644
index 0000000000..992be295fc
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/Button.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+//TODO: Add particles to this component too
+Rectangle {
+ id: container
+ property alias text: txt.text
+ signal clicked
+ //color: "lightsteelblue"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "steelblue" }
+ }
+ height: 64
+ radius: 16
+ width: 128
+ Text {
+ id: txt
+ anchors.centerIn: parent
+ font.pixelSize: 24
+ color: "white"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/CannonHardpoint.qml b/examples/demos/plasmapatrol/content/CannonHardpoint.qml
new file mode 100644
index 0000000000..48eb9d171a
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/CannonHardpoint.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter {
+ id: visualization
+ group: "cannon"
+ enabled: container.show
+ system: container.system
+ anchors.centerIn: parent
+ lifeSpan: 2000
+ emitRate: 1
+
+ size: 4
+ endSize: 0
+ }
+
+ function fireAt(targetArg, hardpoint) {
+ target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
+ if (container.hp <= 0 || targetArg.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var hit = Math.random() > targetArg.dodge
+ if (hit) {
+ switch (targetArg.shipType) {
+ case 1: hardpoint.damageDealt += 8; break;
+ case 2: hardpoint.damageDealt += 10; break;
+ case 3: hardpoint.damageDealt += 16; break;
+ default: hardpoint.damageDealt += 1000;
+ }
+ }
+ emitter.burst(1);
+ }
+ Emitter {
+ id: emitter
+ group: "cannon"
+ enabled: false
+ system: container.system
+ anchors.centerIn: parent
+
+ lifeSpan: 1000
+ emitRate: 1
+ size: 8
+ endSize: 4
+ speed: TargetDirection {
+ id: blastVector
+ targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
+ }
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/ChoiceBox.qml b/examples/demos/plasmapatrol/content/ChoiceBox.qml
new file mode 100644
index 0000000000..6e21101f2e
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/ChoiceBox.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ width: 360
+ height: 160
+ property ParticleSystem system
+ Ship {
+ id: nully
+ system: system
+ }
+ property Item target: nully
+ /*
+ Component.onCompleted: {
+ container.target.shipType = 1
+ container.target.gunType = 1
+ }
+ */
+ Row {
+ anchors.horizontalCenter: parent.horizontalCenter
+ height: parent.height
+ spacing: 8
+ Button {
+ width: 80
+ height: 80
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Cycle\nShip"
+ onClicked: {
+ var nextVal = container.target.shipType;
+ if(nextVal == 3)
+ nextVal = 1;
+ else
+ nextVal++;
+ container.target.shipType = nextVal;
+ }
+ }
+ Item {
+ width: 128
+ height: 128
+ anchors.verticalCenter: parent.verticalCenter
+ Ship {
+ hp: 20
+ anchors.centerIn: parent
+ shipType: container.target.shipType
+ gunType: container.target.gunType
+ system: container.system
+ }
+ }
+ Button {
+ width: 80
+ height: 80
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Cycle\nGun"
+ onClicked: {
+ var nextVal = container.target.gunType;
+ if(nextVal == 3)
+ nextVal = 1;
+ else
+ nextVal++;
+ container.target.gunType = nextVal;
+ }
+ }
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/Cruiser.qml b/examples/demos/plasmapatrol/content/Cruiser.qml
new file mode 100644
index 0000000000..c469eb46d2
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/Cruiser.qml
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.01
+ property real dodge: initialDodge
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter {
+ //TODO: Cooler would be an 'orbiting' affector
+ //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
+ system: container.system
+ group: container.shipParticle
+ anchors.centerIn: parent
+ width: 64
+ height: 64
+ shape: EllipseShape {}
+
+ emitRate: hp > 0 ? hp * 1 + 20 : 0
+ lifeSpan: 2400
+ maximumEmitted: (maxHP * 1 + 20)*2.4
+
+ size: 48
+ sizeVariation: 16
+ endSize: 16
+
+ speed: AngleDirection {angleVariation:360; magnitudeVariation: 32}
+ }
+ Emitter {
+ system: container.system
+ group: "cruiserArmor"
+ anchors.fill: parent
+ shape: EllipseShape { fill: false }
+ enabled: hp>0
+
+ emitRate: 16
+ lifeSpan: 2000
+
+ size: 48
+ sizeVariation: 24
+
+ SpriteGoal {
+ id: destructor
+ system: container.system
+ enabled: container.hp <=0
+ anchors.fill: parent
+ groups: ["cruiserArmor"]
+ goalState: "death"
+// jump: true
+ once: true
+ }
+ }
+
+ Timer {
+ id: fireControl
+ property int next: Math.floor(Math.random() * 3) + 1
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered: {
+ if (next == 1) {
+ gun1.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ } else if (next == 2) {
+ gun2.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ } else if (next == 3) {
+ gun3.fireAt(container.target);
+ next = Math.floor(Math.random() * 3) + 1;
+ }
+ }
+ }
+
+ Hardpoint {//TODO: Hardpoint abstraction
+ x: 112 - 12 - 8*2
+ y: 128 - 12 - 12*2
+ id: gun1
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint {
+ x: 64 - 12
+ y: 0 - 12 + 12*2
+ id: gun2
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint {
+ x: 16 - 12 + 8*2
+ y: 128 - 12 - 12*2
+ id: gun3
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/Frigate.qml b/examples/demos/plasmapatrol/content/Frigate.qml
new file mode 100644
index 0000000000..92c63b87d1
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/Frigate.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.2
+ property real dodge: initialDodge
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter {
+ system: container.system
+ group: "frigateShield"
+ anchors.centerIn: parent
+ size: 92
+ emitRate: 1
+ lifeSpan: 4800
+ enabled: hp > 0
+ }
+ Emitter {
+ system: container.system
+ group: container.shipParticle
+ anchors.centerIn: parent
+ width: 64
+ height: 16
+ shape: EllipseShape {}
+
+ size: 16
+ sizeVariation: 8
+ endSize: 8
+ emitRate: hp > 0 ? hp * 1 + 20 : 0
+ lifeSpan: 1200
+ maximumEmitted: (maxHP * 1 + 20)*2
+ }
+ Timer {
+ id: fireControl
+ property int next: Math.floor(Math.random() * 2) + 1
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered: {
+ if (next == 1) {
+ gun1.fireAt(container.target);
+ next = Math.floor(Math.random() * 2) + 1;
+ } else if (next == 2) {
+ gun2.fireAt(container.target);
+ next = Math.floor(Math.random() * 2) + 1;
+ }
+ }
+ }
+
+ Hardpoint {
+ x: 128 - 32 - 12
+ y: 64 - 12
+ id: gun1
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+ Hardpoint {
+ x: 0 + 32 - 12
+ y: 64 - 12
+ id: gun2
+ system: container.system
+ show: hp > 0
+ hardpointType: gunType
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/Hardpoint.qml b/examples/demos/plasmapatrol/content/Hardpoint.qml
new file mode 100644
index 0000000000..9e6057057d
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/Hardpoint.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ //ReflectiveProperties
+ //TransferredProperties
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+ property int hardpointType: 0 //default is pea shooter - always bad.
+
+ property Item targetObj: null
+ property int damageDealt: 0
+ onDamageDealtChanged: dealDamageTimer.start();
+ Timer {
+ id: dealDamageTimer
+ interval: 16
+ running: false
+ repeat: false
+ onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;}
+ }
+ width: 24
+ height: 24
+ function fireAt(targetArg) {//Each implement own
+ if (targetArg != null) {
+ hardpointLoader.item.fireAt(targetArg, container);
+ targetObj = targetArg;
+ }
+ }
+ Loader {
+ id: hardpointLoader
+ sourceComponent: {
+ switch (hardpointType) {
+ case 1: laserComponent; break;
+ case 2: blasterComponent; break;
+ case 3: cannonComponent; break;
+ default: emptyComponent;
+ }
+ }
+ }
+ Component {
+ id: laserComponent
+ LaserHardpoint {
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component {
+ id: blasterComponent
+ BlasterHardpoint {
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component {
+ id: cannonComponent
+ CannonHardpoint {
+ target: container.target
+ system: container.system
+ show: container.show
+ }
+ }
+ Component {
+ id: emptyComponent
+ Item {
+ function fireAt(obj) {
+ console.log("Firing null weapon. It hurts.");
+ }
+ }
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/HelpScreens.qml b/examples/demos/plasmapatrol/content/HelpScreens.qml
new file mode 100644
index 0000000000..db70c6ee90
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/HelpScreens.qml
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+SequentialLoader {
+ id: hLdr
+ signal exitDesired
+ Component.onCompleted: advance();
+ ParticleSystem { id: helpSystem }
+ PlasmaPatrolParticles { sys: helpSystem }
+ pages: [
+ Component {Item {
+ id: story
+ Text {
+ color: "white"
+ text: "Story"
+ font.pixelSize: 48
+ }
+ /*
+ Flickable {
+ y: 60
+ width: 360
+ height: 500
+ contentHeight: txt1.height
+ contentWidth: 360//TODO: Less magic numbers?
+ */
+ Text {
+ id: txt1
+ color: "white"
+ y: 60
+ font.pixelSize: 18
+ text: "
+In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths.
+
+You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat!
+ "
+ width: 360
+ wrapMode: Text.WordWrap
+ }
+ // }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component {Item {
+ id: ships
+ Text {
+ color: "white"
+ text: "Vessels"
+ font.pixelSize: 48
+ }
+ Column {
+ spacing: 16
+ y: 60
+ Row {
+ height: 128
+ Sloop {
+ system: helpSystem
+ }
+ Text {
+ text: "The nimble sloop"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ Frigate {
+ system: helpSystem
+ }
+ Text {
+ text: "The versitile shield frigate"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ Cruiser {
+ system: helpSystem
+ }
+ Text {
+ text: "The armored cruiser"
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component {Item {
+ id: guns
+ Text {
+ color: "white"
+ text: "Hardpoints"
+ font.pixelSize: 48
+ }
+ Column {
+ spacing: 16
+ y: 60
+ Row {
+ height: 128
+ LaserHardpoint {
+ system: helpSystem
+ }
+ Text {
+ text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ BlasterHardpoint {
+ system: helpSystem
+ }
+ Text {
+ text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ Row {
+ height: 128
+ CannonHardpoint {
+ system: helpSystem
+ }
+ Text {
+ text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser"
+ width: 332
+ wrapMode: Text.WordWrap
+ color: "white"
+ font.pixelSize: 18
+ }
+ }
+ }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Next"
+ onClicked: hLdr.advance();
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }},
+ Component {Item {
+ id: strategy
+ Text {
+ color: "white"
+ text: "Strategy"
+ font.pixelSize: 48
+ }
+ Flickable {
+ y: 60
+ width: 360
+ height: 500
+ contentHeight: txt1.height
+ contentWidth: 360//TODO: Less magic numbers?
+ Text {
+ id: txt1
+ color: "white"
+ font.pixelSize: 18
+ text: "
+Basic Strategy: Good luck, have fun - don't die.
+More to come after thorough playtesting.
+ "
+ width: 360
+ wrapMode: Text.WordWrap
+ }
+ }
+ Button {
+ x: 20
+ y: 560
+ height: 40
+ width: 120
+ text: "Story"
+ onClicked: {hLdr.at=0; hLdr.advance();}
+ }
+ Button {
+ x: 220
+ y: 560
+ height: 40
+ width: 120
+ text: "Menu"
+ onClicked: hLdr.exitDesired();
+ }
+ }}
+ ]
+}
diff --git a/examples/demos/plasmapatrol/content/LaserHardpoint.qml b/examples/demos/plasmapatrol/content/LaserHardpoint.qml
new file mode 100644
index 0000000000..a7baed604b
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/LaserHardpoint.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property variant target: {"y": -90, "x":12}
+ property ParticleSystem system
+ property bool show: true
+
+ width: 24
+ height: 24
+ Emitter {
+ id: visualization
+ group: "laser"
+ system: container.system
+ anchors.fill: parent
+ enabled: container.show
+ shape: EllipseShape {}
+ speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true }
+ lifeSpan: 1000
+ emitRate: 64
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+
+ function fireAt(targetArg, hardpoint) {
+ if (targetArg.hp <= 0)
+ return;
+ //TODO: calculate hit and damage at target, which must be a Ship
+ var offset = 0;
+ if (Math.random() < 0.99) {
+ switch (targetArg.shipType) {
+ case 1: hardpoint.damageDealt += 16; break;
+ case 2: hardpoint.damageDealt += 4; break;
+ case 3: hardpoint.damageDealt += 8; break;
+ default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels
+ }
+ } else {//Misses with Lasers are really rare
+ offset = Math.random() * 100;
+ }
+ target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2);
+ emitter.pulse(100);
+ // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y)));
+ }
+ Emitter {
+ id: emitter
+ group: "laser"
+ enabled: false
+ system: container.system
+ x: Math.min(container.width/2, target.x);
+ width: Math.max(container.width/2, target.x) - x;
+ y: Math.min(container.height/2, target.y);
+ height: Math.max(container.height/2, target.y) - y;
+ shape: LineShape {
+ mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR
+ }
+
+ lifeSpan: 1000
+ emitRate: 8000
+ maximumEmitted: 800
+ size: 16
+ endSize: 0
+
+ speed: PointDirection {xVariation: 4; yVariation: 4}
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml
new file mode 100644
index 0000000000..e1924c3467
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ property ParticleSystem sys
+ ImageParticle {
+ system: sys
+ groups: ["default"]
+ source: "pics/blur-circle3.png"
+ color: "#003A3A3A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle {
+ system: sys
+ groups: ["redTeam"]
+ source: "pics/blur-circle3.png"
+ color: "#0028060A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle {
+ system: sys
+ groups: ["greenTeam"]
+ source: "pics/blur-circle3.png"
+ color: "#0006280A"
+ colorVariation: 0.1
+ z: 0
+ }
+ ImageParticle {
+ system: sys
+ groups: ["blaster"]
+ source: "pics/star2.png"
+ //color: "#0F282406"
+ color: "#0F484416"
+ colorVariation: 0.2
+ z: 2
+ }
+ ImageParticle {
+ system: sys
+ groups: ["laser"]
+ source: "pics/star3.png"
+ //color: "#00123F68"
+ color: "#00428FF8"
+ colorVariation: 0.2
+ z: 2
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cannon"]
+ source: "pics/particle.png"
+ color: "#80FFAAFF"
+ colorVariation: 0.1
+ z: 2
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cannonCore"]
+ source: "pics/particle.png"
+ color: "#00666666"
+ colorVariation: 0.8
+ z: 1
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cannonWake"]
+ source: "pics/star.png"
+ color: "#00CCCCCC"
+ colorVariation: 0.2
+ z: 1
+ }
+ ImageParticle {
+ system: sys
+ groups: ["frigateShield"]
+ source: "pics/blur-circle2.png"
+ color: "#00000000"
+ colorVariation: 0.05
+ blueVariation: 0.5
+ greenVariation: 0.1
+ z: 3
+ }
+ ImageParticle {
+ system: sys
+ groups: ["cruiserArmor"]
+ z: 1
+ sprites:[Sprite {
+ id: spinState
+ name: "spinning"
+ source: "pics/meteor.png"
+ frameCount: 35
+ frameDuration: 40
+ to: {"death":0, "spinning":1}
+ },Sprite {
+ name: "death"
+ source: "pics/meteor_explo.png"
+ frameCount: 22
+ frameDuration: 40
+ to: {"null":1}
+ }, Sprite {
+ name: "null"
+ source: "pics/nullRock.png"
+ frameCount: 1
+ frameDuration: 1000
+ }
+ ]
+ }
+ TrailEmitter {
+ system: sys
+ group: "cannonWake"
+ follow: "cannon"
+ emitRatePerParticle: 64
+ lifeSpan: 600
+ speed: AngleDirection { angleVariation: 360; magnitude: 48}
+ size: 16
+ endSize: 8
+ sizeVariation: 2
+ enabled: true
+ width: 1000//XXX: Terrible hack
+ height: 1000
+ }
+ TrailEmitter {
+ system: sys
+ group: "cannonCore"
+ follow: "cannon"
+ emitRatePerParticle: 256
+ lifeSpan: 128
+ size: 24
+ endSize: 8
+ enabled: true
+ width: 1000//XXX: Terrible hack
+ height: 1000
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/SequentialLoader.qml b/examples/demos/plasmapatrol/content/SequentialLoader.qml
new file mode 100644
index 0000000000..3707759ce3
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/SequentialLoader.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ id: container
+ //TODO: Somehow get particles into this?
+ property list<Component> pages
+ property Item cur: null
+ property int at: 0
+ function advance() {
+ if(cur != null)
+ cur.destroy();
+ cur = pages[at++].createObject(container);
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/Ship.qml b/examples/demos/plasmapatrol/content/Ship.qml
new file mode 100644
index 0000000000..bd023b1dc2
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/Ship.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: me
+ //Reflective Properties
+ width: shipLoader.width
+ height: shipLoader.height
+ //Transfered Properties
+ property int hp: 100//shipLoader.item.maxHP
+ property real dodge: shipLoader.item.initialDodge
+ property ParticleSystem system
+ property int targetIdx: 0
+ property Item target: targets[targetIdx] == undefined?null:targets[targetIdx]
+ Connections {
+ target: me.target
+ onHpChanged: if (me.target.hp<=0) me.targetIdx++;
+ }
+ property list<Item> targets
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ property int shipType: 0
+ Component {
+ id: sloopComp
+ Sloop {
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component {
+ id: frigateComp
+ Frigate {
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component {
+ id: cruiserComp
+ Cruiser {
+ system: me.system
+ target: me.target
+ shipParticle: me.shipParticle
+ gunType: me.gunType
+ hp: me.hp
+ dodge: me.dodge
+ }
+ }
+ Component {
+ id: dumbComp
+ Item {
+ property int maxHP: 0
+ property int initialDodge: 0
+ }
+ }
+ Loader {
+ id: shipLoader
+ sourceComponent: {
+ switch (shipType) {
+ case 1: sloopComp; break;
+ case 2: frigateComp; break;
+ case 3: cruiserComp; break;
+ default: dumbComp;
+ }
+ }
+ }
+}
diff --git a/examples/demos/plasmapatrol/content/Sloop.qml b/examples/demos/plasmapatrol/content/Sloop.qml
new file mode 100644
index 0000000000..3bc58a28b0
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/Sloop.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property int maxHP: 100
+ property int hp: maxHP
+ property real initialDodge: 0.5
+ property real dodge: initialDodge
+ property int blinkInterval: 800
+ onHpChanged: if(hp <= 0) target = container;
+ property ParticleSystem system//TODO: Ship abstraction
+ property Item target: container
+ property string shipParticle: "default"//Per team colors?
+ property int gunType: 0
+ width: 128
+ height: 128
+ Emitter {
+ id: emitter
+ //TODO: Cooler would be an 'orbiting' affector
+ //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
+ system: container.system
+ group: container.shipParticle
+ shape: EllipseShape {}
+
+ emitRate: hp > 0 ? hp + 20 : 0
+ lifeSpan: blinkInterval
+ maximumEmitted: (maxHP + 20)
+
+ acceleration: AngleDirection {angleVariation: 360; magnitude: 8}
+
+ size: 24
+ endSize: 4
+ sizeVariation: 8
+ width: 16
+ height: 16
+ x: 64
+ y: 64
+ Behavior on x {NumberAnimation {duration:blinkInterval}}
+ Behavior on y {NumberAnimation {duration:blinkInterval}}
+ Timer {
+ interval: blinkInterval
+ running: true
+ repeat: true
+ onTriggered: {
+ emitter.x = Math.random() * 48 + 32
+ emitter.y = Math.random() * 48 + 32
+ }
+ }
+ }
+ Hardpoint {
+ anchors.centerIn: parent
+ id: gun2
+ system: container.system
+ show: container.hp > 0
+ hardpointType: gunType
+ }
+ Timer {
+ id: fireControl
+ interval: 800
+ running: root.readySetGo
+ repeat: true
+ onTriggered: {
+ gun2.fireAt(container.target);
+ }
+ }
+
+}
diff --git a/examples/demos/plasmapatrol/content/pics/TitleText.png b/examples/demos/plasmapatrol/content/pics/TitleText.png
new file mode 100644
index 0000000000..dc3acebe39
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/TitleText.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/blur-circle2.png b/examples/demos/plasmapatrol/content/pics/blur-circle2.png
new file mode 100644
index 0000000000..f7c9f3e98e
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/blur-circle2.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/blur-circle3.png b/examples/demos/plasmapatrol/content/pics/blur-circle3.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/blur-circle3.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/finalfrontier.png b/examples/demos/plasmapatrol/content/pics/finalfrontier.png
new file mode 100644
index 0000000000..2ba1815230
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/finalfrontier.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/meteor.png b/examples/demos/plasmapatrol/content/pics/meteor.png
new file mode 100644
index 0000000000..e8c368aea7
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/meteor.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/meteor_explo.png b/examples/demos/plasmapatrol/content/pics/meteor_explo.png
new file mode 100644
index 0000000000..4297245d49
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/meteor_explo.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/nullRock.png b/examples/demos/plasmapatrol/content/pics/nullRock.png
new file mode 100644
index 0000000000..4076327a1a
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/nullRock.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/particle.png b/examples/demos/plasmapatrol/content/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/particle.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/star.png b/examples/demos/plasmapatrol/content/pics/star.png
new file mode 100644
index 0000000000..0d592cfa87
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/star.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/star2.png b/examples/demos/plasmapatrol/content/pics/star2.png
new file mode 100644
index 0000000000..bb55c44788
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/star2.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/content/pics/star3.png b/examples/demos/plasmapatrol/content/pics/star3.png
new file mode 100644
index 0000000000..636a25f480
--- /dev/null
+++ b/examples/demos/plasmapatrol/content/pics/star3.png
Binary files differ
diff --git a/examples/demos/plasmapatrol/plasmapatrol.qml b/examples/demos/plasmapatrol/plasmapatrol.qml
new file mode 100644
index 0000000000..b14ac6385b
--- /dev/null
+++ b/examples/demos/plasmapatrol/plasmapatrol.qml
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Rectangle {
+ id: root
+ property bool readySetGo: false
+ //Debugging
+ property int hits: 0
+ property int misses: 0
+ property real ratio: hits/(misses?misses:1)
+ //Move to JS file?
+ property Ship redVar1: Ship {shipType: 1; gunType: 1}
+ property Ship redVar2: Ship {shipType: 1; gunType: 2}
+ property Ship redVar3: Ship {shipType: 1; gunType: 3}
+ property Ship greenVar1: Ship {shipType: 3; gunType: 1}
+ property Ship greenVar2: Ship {shipType: 2; gunType: 2}
+ property Ship greenVar3: Ship {shipType: 1; gunType: 3}
+ property string winner: "0"
+ property int players: 0
+ function aiSet(ship) {
+ ship.gunType = Math.floor(Math.random() * 3) + 1
+ ship.shipType = Math.floor(Math.random() * 3) + 1
+ }
+
+ width: 360
+ height: 600
+ color: "black"
+ SequentialLoader {
+ anchors.fill: parent
+ //General Children
+ Image {
+ anchors.centerIn: parent
+ source: "../images/finalfrontier.png"
+ }
+ ParticleSystem {
+ id: particles
+ }
+ PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane
+ //Component parts
+ id: pageControl
+ Component.onCompleted: advance();
+ pages:[
+ Component {Item {
+ id: menu
+ width: root.width
+ height: root.height
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width
+ spacing: 8
+ Item {
+ id: title
+ width: root.width
+ height: 240
+ Emitter {
+ anchors.fill: parent
+ system: particles
+ enabled: true
+ group: "default"
+ emitRate: 1200
+ lifeSpan: 1200
+ shape: MaskShape {source:"content/pics/TitleText.png"}
+ size: 16
+ endSize: 0
+ sizeVariation: 8
+ speed: AngleDirection {angleVariation:360; magnitudeVariation: 6}
+ }
+ }
+ Button {
+ text: "1P"
+ onClicked: {root.players = 1; pageControl.advance();}
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ text: "2P"
+ onClicked: {root.players = 2; pageControl.advance();}
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ text: "Demo"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {root.players = 0;
+ aiSet(redVar1);
+ aiSet(redVar2);
+ aiSet(redVar3);
+ aiSet(greenVar1);
+ aiSet(greenVar2);
+ aiSet(greenVar3);
+ pageControl.at = 5;//TODO: Not a magic number
+ pageControl.advance();}
+ }
+ Button {
+ text: "Help"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ pageControl.at = 7;//TODO: Not a magic number
+ pageControl.advance();
+ }
+ }
+ Button {
+ text: "Quit"
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: Qt.quit();
+ }
+ }
+ }},
+ Component {Item {
+ id: p1Screen
+ z: 101
+ width: root.width
+ height: root.height
+ Rectangle {
+ anchors.fill: parent
+ color: "red"
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player\n 1"
+ horizontalAlignment: Text.AlignHCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: pageControl.advance()
+ }
+ }},
+ Component {Item {
+ id: p1Choices
+ z: 3
+ width: root.width
+ height: root.height
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ }
+ Column {
+ spacing: 16
+ width: root.width
+ anchors.horizontalCenter: parent.horizontalCenter
+ ChoiceBox {
+ target: redVar1
+ system: particles
+ }
+ ChoiceBox {
+ target: redVar2
+ system: particles
+ }
+ ChoiceBox {
+ target: redVar3
+ system: particles
+ }
+ Button {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Next"
+ onClicked: {
+ if (root.players < 2) {
+ aiSet(greenVar1);
+ aiSet(greenVar2);
+ aiSet(greenVar3);
+ pageControl.at = 5;//TODO: Not a magic number
+ }
+ pageControl.advance();
+ }
+ }
+ }
+ }},
+ Component {Item {
+ id: p2Screen
+ z: 101
+ width: root.width
+ height: root.height
+ Rectangle {
+ anchors.fill: parent
+ color: "green"
+ }
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player\n 2"
+ horizontalAlignment: Text.AlignHCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: pageControl.advance()
+ }
+ }},
+ Component {Item {
+ id: p2Choices
+ z: 1
+ width: root.width
+ height: root.height
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ }
+ Column {
+ spacing: 16
+ width: root.width
+ anchors.horizontalCenter: parent.horizontalCenter
+ ChoiceBox {
+ target: greenVar1
+ system: particles
+ }
+ ChoiceBox {
+ target: greenVar2
+ system: particles
+ }
+ ChoiceBox {
+ target: greenVar3
+ system: particles
+ }
+ Button {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Next"
+ onClicked: pageControl.advance()
+ }
+ }
+ }},
+ Component {Item {
+ id: arena
+ width: root.width
+ height: root.height
+ z: 0
+ Component.onCompleted: root.readySetGo = true
+ Component.onDestruction: root.readySetGo = false
+ property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0
+ onVictoryChanged: {
+ if (redShip3.hp <= 0) {
+ if (greenShip3.hp <= 0) {
+ root.winner = "1&2"
+ }else {
+ root.winner = "2"
+ }
+ } else {
+ root.winner = "1"
+ }
+ winTimer.start()
+ }
+ Timer {
+ id: winTimer
+ interval: 1200
+ repeat: false
+ running: false
+ onTriggered: pageControl.advance();
+ }
+ Ship {
+ id: redShip1
+ shipParticle: "redTeam"
+ system: particles
+ x: 180-64
+ y: 128
+ shipType: redVar1.shipType
+ gunType: redVar1.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+ Ship {
+ id: redShip2
+ shipParticle: "redTeam"
+ system: particles
+ x: 0
+ y: 0
+ shipType: redVar2.shipType
+ gunType: redVar2.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+ Ship {
+ id: redShip3
+ shipParticle: "redTeam"
+ system: particles
+ x: 360-128
+ y: 0
+ shipType: redVar3.shipType
+ gunType: redVar3.gunType
+ targets: [greenShip1, greenShip2, greenShip3]
+ }
+
+ Ship {
+ id: greenShip1
+ shipParticle: "greenTeam"
+ system: particles
+ x: 180-64
+ y: 600 - 128 - 128
+ shipType: greenVar1.shipType
+ gunType: greenVar1.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ Ship {
+ id: greenShip2
+ shipParticle: "greenTeam"
+ system: particles
+ x: 0
+ y: 600-128
+ shipType: greenVar2.shipType
+ gunType: greenVar2.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ Ship {
+ id: greenShip3
+ shipParticle: "greenTeam"
+ system: particles
+ x: 360 - 128
+ y: 600 - 128
+ shipType: greenVar3.shipType
+ gunType: greenVar3.gunType
+ targets: [redShip1, redShip2, redShip3]
+ }
+ }},
+ Component {Item {
+ id: winScreen
+ z: 101
+ width: root.width
+ height: root.height
+ /*
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ }
+ */
+ Text {//TODO: Particle Text?
+ anchors.fill: parent
+ color: "white"
+ font.pixelSize: 64
+ font.bold: true
+ text: "Player " + root.winner + " wins!"
+ wrapMode: Text.WordWrap
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {pageControl.at = 0; pageControl.advance();}
+ }
+ }},
+ Component {
+ HelpScreens {
+ onExitDesired: {pageControl.at = 0; pageControl.advance();}
+ }
+ }
+ ]
+ }
+}
diff --git a/examples/demos/rssnews/content/BusyIndicator.qml b/examples/demos/rssnews/content/BusyIndicator.qml
new file mode 100644
index 0000000000..f1abd1119c
--- /dev/null
+++ b/examples/demos/rssnews/content/BusyIndicator.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+
+ NumberAnimation on rotation {
+ running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200
+ }
+}
diff --git a/examples/demos/rssnews/content/CategoryDelegate.qml b/examples/demos/rssnews/content/CategoryDelegate.qml
new file mode 100644
index 0000000000..fe64238adb
--- /dev/null
+++ b/examples/demos/rssnews/content/CategoryDelegate.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+
+ width: delegate.ListView.view.width; height: 60
+
+ Text {
+ text: name
+ color: delegate.ListView.isCurrentItem ? "white" : "black"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+
+ BusyIndicator {
+ scale: 0.6
+ on: delegate.ListView.isCurrentItem && window.loading
+ anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter }
+ }
+
+ Rectangle {
+ width: delegate.width; height: 1; color: "#cccccc"
+ anchors.bottom: delegate.bottom
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+ Rectangle {
+ width: delegate.width; height: 1; color: "white"
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+
+ MouseArea {
+ anchors.fill: delegate
+ onClicked: {
+ delegate.ListView.view.currentIndex = index
+ window.currentFeed = feed
+ }
+ }
+}
diff --git a/examples/demos/rssnews/content/NewsDelegate.qml b/examples/demos/rssnews/content/NewsDelegate.qml
new file mode 100644
index 0000000000..59ab269d3b
--- /dev/null
+++ b/examples/demos/rssnews/content/NewsDelegate.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+ height: column.height + 40
+ width: delegate.ListView.view.width
+
+ Column {
+ id: column
+ x: 20; y: 20
+ width: parent.width - 40
+
+ Text {
+ id: titleText
+ text: title; width: parent.width; wrapMode: Text.WordWrap
+ font { bold: true; family: "Helvetica"; pointSize: 16 }
+ }
+
+ Text {
+ id: descriptionText
+ width: parent.width; text: description
+ wrapMode: Text.WordWrap; font.family: "Helvetica"
+ }
+ }
+
+ Rectangle {
+ width: parent.width; height: 1; color: "#cccccc"
+ anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/demos/rssnews/content/RssFeeds.qml b/examples/demos/rssnews/content/RssFeeds.qml
new file mode 100644
index 0000000000..ed58ef3852
--- /dev/null
+++ b/examples/demos/rssnews/content/RssFeeds.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id: rssFeeds
+
+ ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" }
+ ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" }
+ ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" }
+ ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" }
+ ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" }
+ ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" }
+ ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" }
+ ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" }
+ ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" }
+ ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" }
+ ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" }
+ ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" }
+}
diff --git a/examples/demos/rssnews/content/ScrollBar.qml b/examples/demos/rssnews/content/ScrollBar.qml
new file mode 100644
index 0000000000..7b1a2ac3e5
--- /dev/null
+++ b/examples/demos/rssnews/content/ScrollBar.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant scrollArea
+ property variant orientation: Qt.Vertical
+
+ opacity: 0
+
+ function position()
+ {
+ var ny = 0;
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+ if (ny > 2) return ny; else return 2;
+ }
+
+ function size()
+ {
+ var nh, ny;
+
+ if (container.orientation == Qt.Vertical)
+ nh = scrollArea.visibleArea.heightRatio * container.height;
+ else
+ nh = scrollArea.visibleArea.widthRatio * container.width;
+
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+
+ if (ny > 3) {
+ var t;
+ if (container.orientation == Qt.Vertical)
+ t = Math.ceil(container.height - 3 - ny);
+ else
+ t = Math.ceil(container.width - 3 - ny);
+ if (nh > t) return t; else return nh;
+ } else return nh + ny;
+ }
+
+ Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
+
+ BorderImage {
+ source: "images/scrollbar.png"
+ border { left: 1; right: 1; top: 1; bottom: 1 }
+ x: container.orientation == Qt.Vertical ? 2 : position()
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
+ y: container.orientation == Qt.Vertical ? position() : 2
+ height: container.orientation == Qt.Vertical ? size() : container.height - 4
+ }
+
+ states: State {
+ name: "visible"
+ when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ PropertyChanges { target: container; opacity: 1.0 }
+ }
+
+ transitions: Transition {
+ from: "visible"; to: ""
+ NumberAnimation { properties: "opacity"; duration: 600 }
+ }
+}
diff --git a/examples/demos/rssnews/content/images/busy.png b/examples/demos/rssnews/content/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/demos/rssnews/content/images/busy.png
Binary files differ
diff --git a/examples/demos/rssnews/content/images/scrollbar.png b/examples/demos/rssnews/content/images/scrollbar.png
new file mode 100644
index 0000000000..0228dcf9eb
--- /dev/null
+++ b/examples/demos/rssnews/content/images/scrollbar.png
Binary files differ
diff --git a/examples/demos/rssnews/rssnews.qml b/examples/demos/rssnews/rssnews.qml
new file mode 100644
index 0000000000..d26b94b6d3
--- /dev/null
+++ b/examples/demos/rssnews/rssnews.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+import "content"
+
+Rectangle {
+ id: window
+ width: 800; height: 480
+
+ property string currentFeed: "rss.news.yahoo.com/rss/topstories"
+ property bool loading: feedModel.status == XmlListModel.Loading
+
+ RssFeeds { id: rssFeeds }
+
+ XmlListModel {
+ id: feedModel
+ source: "http://" + window.currentFeed
+ query: "/rss/channel/item"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "link"; query: "link/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ }
+
+ Row {
+ Rectangle {
+ width: 220; height: window.height
+ color: "#efefef"
+
+ ListView {
+ focus: true
+ id: categories
+ anchors.fill: parent
+ model: rssFeeds
+ footer: quitButtonDelegate
+ delegate: CategoryDelegate {}
+ highlight: Rectangle { color: "steelblue" }
+ highlightMoveSpeed: 9999999
+ }
+ ScrollBar {
+ scrollArea: categories; height: categories.height; width: 8
+ anchors.right: categories.right
+ }
+ }
+ ListView {
+ id: list
+ width: window.width - 220; height: window.height
+ model: feedModel
+ delegate: NewsDelegate {}
+ }
+ }
+ Component {
+ id: quitButtonDelegate
+ Item {
+ width: categories.width; height: 60
+ Text {
+ text: "Quit"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+ }
+ ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
+ Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" }
+}
diff --git a/examples/demos/rssnews/rssnews.qmlproject b/examples/demos/rssnews/rssnews.qmlproject
new file mode 100644
index 0000000000..5becbdaed0
--- /dev/null
+++ b/examples/demos/rssnews/rssnews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "rssnews.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/demos/samegame/content/BoomBlock.qml b/examples/demos/samegame/content/BoomBlock.qml
new file mode 100644
index 0000000000..a348368ae1
--- /dev/null
+++ b/examples/demos/samegame/content/BoomBlock.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if(type == 0){
+ "pics/redStone.png";
+ } else if(type == 1) {
+ "pics/blueStone.png";
+ } else {
+ "pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+ Emitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if(type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else {
+ "green";
+ }
+ }
+ anchors.fill: parent
+
+ speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60}
+ shape: EllipseShape{fill:true}
+ enabled: false;
+ lifeSpan: 700; lifeSpanVariation: 100
+ emitRate: 1000
+ maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
+ size: 28
+ endSize: 14
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml
new file mode 100644
index 0000000000..2d1a993226
--- /dev/null
+++ b/examples/demos/samegame/content/Button.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 20
+ smooth: true
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ radius: 8
+ color: activePalette.button
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24
+ }
+}
diff --git a/examples/demos/samegame/content/Dialog.qml b/examples/demos/samegame/content/Dialog.qml
new file mode 100644
index 0000000000..c81580e6a5
--- /dev/null
+++ b/examples/demos/samegame/content/Dialog.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ anchors.centerIn: parent
+
+ property Item text: dialogText
+ property bool open: false
+
+ signal closed
+ signal opened
+ function forceClose() {
+ if(!open)
+ return; //already closed
+ page.open = false;
+ page.closed();
+ page.opacity = 0;
+ }
+
+ function show(txt) {
+ page.open = true;
+ page.opened();
+ dialogText.text = txt;
+ page.opacity = 1;
+ }
+
+ width: dialogText.width + 20; height: dialogText.height + 20
+ color: "white"
+ border.width: 1
+ opacity: 0
+ visible: opacity > 0
+ Behavior on opacity {
+ NumberAnimation { duration: 1000 }
+ }
+
+ Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+
+ MouseArea { anchors.fill: parent; onClicked: forceClose(); }
+}
+
diff --git a/examples/demos/samegame/content/GameArea.qml b/examples/demos/samegame/content/GameArea.qml
new file mode 100644
index 0000000000..3422582b21
--- /dev/null
+++ b/examples/demos/samegame/content/GameArea.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "samegame.js" as Logic
+
+Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+ property ParticleSystem ps: particleSystem
+ Image {
+ id: background
+ anchors.fill: parent
+ z: -1
+ source: "pics/background.png"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ width: 480
+ height: 800
+ MouseArea {
+ anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y);
+ }
+ ParticleSystem{
+ id: particleSystem;
+ onEmptyChanged: if (empty) paused = true;
+ z:2
+ ImageParticle {
+ groups: ["red"]
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["green"]
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["blue"]
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "pics/particle.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ anchors.fill: parent
+ }
+}
+
diff --git a/examples/demos/samegame/content/NameInputDialog.qml b/examples/demos/samegame/content/NameInputDialog.qml
new file mode 100644
index 0000000000..7c3bfa274a
--- /dev/null
+++ b/examples/demos/samegame/content/NameInputDialog.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Dialog {
+ id: nameInputDialog
+
+ property int initialWidth: 0
+ property alias name: nameInputText.text
+
+ anchors.centerIn: parent
+ z: 22;
+
+ Behavior on width {
+ NumberAnimation {}
+ enabled: nameInputDialog.initialWidth != 0
+ }
+
+ signal accepted(string name)
+ onClosed: {
+ if (nameInputText.text != "")
+ accepted(name);
+ }
+ Text {
+ id: dialogText
+ anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter }
+ text: "You won! Please enter your name: "
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (nameInputText.text == "")
+ nameInputText.openSoftwareInputPanel();
+ else
+ nameInputDialog.forceClose();
+ }
+ }
+
+ TextInput {
+ id: nameInputText
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ focus: visible
+ autoScroll: false
+ maximumLength: 24
+ onTextChanged: {
+ var newWidth = nameInputText.width + dialogText.width + 40;
+ if ( (newWidth > nameInputDialog.width && newWidth < screen.width)
+ || (nameInputDialog.width > nameInputDialog.initialWidth) )
+ nameInputDialog.width = newWidth;
+ }
+ onAccepted: {
+ nameInputDialog.forceClose();
+ }
+ }
+}
diff --git a/examples/demos/samegame/content/pics/background.png b/examples/demos/samegame/content/pics/background.png
new file mode 100644
index 0000000000..3734a27744
--- /dev/null
+++ b/examples/demos/samegame/content/pics/background.png
Binary files differ
diff --git a/examples/demos/samegame/content/pics/blueStone.png b/examples/demos/samegame/content/pics/blueStone.png
new file mode 100644
index 0000000000..20e43c75b6
--- /dev/null
+++ b/examples/demos/samegame/content/pics/blueStone.png
Binary files differ
diff --git a/examples/demos/samegame/content/pics/greenStone.png b/examples/demos/samegame/content/pics/greenStone.png
new file mode 100644
index 0000000000..b568a1900c
--- /dev/null
+++ b/examples/demos/samegame/content/pics/greenStone.png
Binary files differ
diff --git a/examples/demos/samegame/content/pics/particle.png b/examples/demos/samegame/content/pics/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/demos/samegame/content/pics/particle.png
Binary files differ
diff --git a/examples/demos/samegame/content/pics/redStone.png b/examples/demos/samegame/content/pics/redStone.png
new file mode 100644
index 0000000000..36b09a2686
--- /dev/null
+++ b/examples/demos/samegame/content/pics/redStone.png
Binary files differ
diff --git a/examples/demos/samegame/content/pics/yellowStone.png b/examples/demos/samegame/content/pics/yellowStone.png
new file mode 100644
index 0000000000..b1ce76212c
--- /dev/null
+++ b/examples/demos/samegame/content/pics/yellowStone.png
Binary files differ
diff --git a/examples/demos/samegame/content/samegame.js b/examples/demos/samegame/content/samegame.js
new file mode 100755
index 0000000000..611767584b
--- /dev/null
+++ b/examples/demos/samegame/content/samegame.js
@@ -0,0 +1,290 @@
+/* This script file handles the game logic */
+.pragma library
+.import QtQuick.LocalStorage 2.0 as Sql
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn*maxRow;
+var board = new Array(maxIndex);
+var blockSrc = "BoomBlock.qml";
+var scoresURL = "";
+var gameDuration;
+var component = Qt.createComponent(blockSrc);
+var highScoreBar = -1;
+var gameCanvas;
+var nameInputDialog = null;
+var dialog = null;
+
+// Index function used instead of a 2D array
+function index(column, row)
+{
+ return column + row * maxColumn;
+}
+
+function timeStr(msecs)
+{
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
+function startNewGame(gc)
+{
+ gameCanvas = gc;
+ // Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ // Calculate board size
+ maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ // Close dialogs
+ if(nameInputDialog != null)
+ nameInputDialog.forceClose();
+ if(dialog != null)
+ dialog.forceClose();
+
+ // Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+ gameDuration = new Date();
+}
+
+var fillFound; // Set after a floodFill call to the number of blocks found
+var floodBoard; // Set to 1 if the floodFill reaches off that node
+
+// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+function handleClick(x,y)
+{
+ if(gameCanvas == undefined){
+ console.log("But the game hasn't started yet!");
+ return;
+ }
+ var column = Math.floor(x/gameCanvas.blockSize);
+ var row = Math.floor(y/gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ // If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column,row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column,row,type)
+{
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column,row)].type;
+
+ // Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; // Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ // Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * gameCanvas.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+function victoryCheck()
+{
+ // Awards bonuses for no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+ // Checks for game over
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ if(nameInputDialog == null){
+ nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml");
+ }
+ if(dialog == null){
+ dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas);
+ }
+ initHighScoreBar();
+ if(gameCanvas.score > highScoreBar){
+ nameInputDialog.show("You won! Please enter your name: ");
+ nameInputDialog.initialWidth = nameInputDialog.text.width + 20;
+ if (nameInputDialog.name == "")
+ nameInputDialog.width = nameInputDialog.initialWidth;
+ nameInputDialog.text.opacity = 0; // Just a spacer
+ }else{
+ dialog.show("You won!");
+ }
+ }
+}
+
+// Only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type)
+{
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+function createBlock(column,row)
+{
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if(component.status == 1){
+ var dynamicObject = component.createObject(gameCanvas,
+ {"type": Math.floor(Math.random() * 3),
+ "x": column*gameCanvas.blockSize,
+ "width": gameCanvas.blockSize,
+ "height": gameCanvas.blockSize,
+ "particleSystem": gameCanvas.ps});
+ if(dynamicObject == null){
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.y = row*gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+
+ board[index(column,row)] = dynamicObject;
+ }else{
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+function initHighScoreBar()
+{
+ var db = Sql.openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
+ if(rs.rows.length < 10)
+ highScoreBar = 0;
+ else
+ highScoreBar = rs.rows.item(rs.rows.length - 1).score;
+ }
+ );
+}
+
+function saveHighScore(name)
+{
+ if (scoresURL != "")
+ sendHighScore(name);
+ // Offline storage
+ var db = Sql.openDatabaseSync(
+ "SameGameScores",
+ "1.0",
+ "Local SameGame High Scores",
+ 100
+ );
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [
+ name,
+ gameCanvas.score,
+ maxColumn + "x" + maxRow,
+ Math.floor(gameDuration / 1000)
+ ];
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for this grid size\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i+1) + ". " + rs.rows.item(i).name + ' got '
+ + rs.rows.item(i).score + ' points in '
+ + rs.rows.item(i).time + ' seconds.\n';
+ }
+ if(rs.rows.length == 10)
+ highScoreBar = rs.rows.item(9).score;
+ dialog.show(r);
+ }
+ );
+}
diff --git a/examples/demos/samegame/samegame.qml b/examples/demos/samegame/samegame.qml
new file mode 100644
index 0000000000..b98b6a0074
--- /dev/null
+++ b/examples/demos/samegame/samegame.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+import "content/samegame.js" as Logic
+
+Rectangle {
+ id: screen
+ width: 480; height: 640
+
+ SystemPalette { id: activePalette }
+
+ GameArea {
+ id: gameCanvas
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 80
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ id: newGameButton
+ anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: Logic.startNewGame(gameCanvas)
+ }
+
+ Button {
+ text: "Quit"
+ anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ font.bold: true
+ font.pixelSize: 24
+ color: activePalette.windowText
+ }
+ }
+}
diff --git a/examples/demos/samegame/samegame.qmlproject b/examples/demos/samegame/samegame.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/demos/samegame/samegame.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/demos/snake/content/Button.qml b/examples/demos/snake/content/Button.qml
new file mode 100644
index 0000000000..4f294556b3
--- /dev/null
+++ b/examples/demos/snake/content/Button.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
diff --git a/examples/demos/snake/content/Cookie.qml b/examples/demos/snake/content/Cookie.qml
new file mode 100644
index 0000000000..35ffe400b8
--- /dev/null
+++ b/examples/demos/snake/content/Cookie.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: root
+ property bool dying: false
+ property int row;
+ property int column;
+ x: margin + column * gridSize
+ y: margin + row * gridSize
+
+ width: gridSize
+ height: gridSize
+ property int value : 1;
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "pics/cookie.png"
+ opacity: 0
+ Text {
+ font.bold: true
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: value
+ }
+ }
+
+
+ ParticleSystem {
+ width:1; height:1; anchors.centerIn: parent;
+ ImageParticle {
+ groups: ["star"]
+ source: "pics/yellowStar.png"
+ }
+ Emitter {
+ id: particles
+ anchors.fill: parent
+ group: "star"
+ emitRate: 50
+ enabled: false
+ lifeSpan: 700
+ acceleration: AngleDirection { angleVariation: 360; magnitude: 200 }
+ }
+ }
+
+ states: [
+ State{ name: "AliveState"; when: dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumberAnimation { target: img; property: "opacity"; duration: 100 }
+ }
+ ]
+}
diff --git a/examples/demos/snake/content/HighScoreModel.qml b/examples/demos/snake/content/HighScoreModel.qml
new file mode 100644
index 0000000000..734a661f5b
--- /dev/null
+++ b/examples/demos/snake/content/HighScoreModel.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.LocalStorage 2.0 as Sql
+
+// Models a high score table.
+//
+// Use this component like this:
+//
+// HighScoreModel {
+// id: highScores
+// game: "MyCoolGame"
+// }
+//
+// Then use either use the top-score properties:
+//
+// Text { text: "HI: " + highScores.topScore }
+//
+// or, use the model in a view:
+//
+// ListView {
+// model: highScore
+// delegate: Component {
+// ... player ... score ...
+// }
+// }
+//
+// Add new scores via:
+//
+// saveScore(newScore)
+//
+// or:
+//
+// savePlayerScore(playerName,newScore)
+//
+// The best maxScore scores added by this method will be retained in an SQL database,
+// and presented in the model and in the topScore/topPlayer properties.
+//
+
+ListModel {
+ id: model
+ property string game: ""
+ property int topScore: 0
+ property string topPlayer: ""
+ property int maxScores: 10
+
+ function __db()
+ {
+ return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000);
+ }
+ function __ensureTables(tx)
+ {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []);
+ }
+
+ function fillModel() {
+ __db().transaction(
+ function(tx) {
+ __ensureTables(tx);
+ var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]);
+ model.clear();
+ if (rs.rows.length > 0) {
+ topScore = rs.rows.item(0).score
+ topPlayer = rs.rows.item(0).player
+ for (var i=0; i<rs.rows.length; ++i) {
+ if (i < maxScores)
+ model.append(rs.rows.item(i))
+ }
+ if (rs.rows.length > maxScores)
+ tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?",
+ [game, rs.rows.item(maxScores).score]);
+ }
+ }
+ )
+ }
+
+ function savePlayerScore(player,score) {
+ __db().transaction(
+ function(tx) {
+ __ensureTables(tx);
+ tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]);
+ fillModel();
+ }
+ )
+ }
+
+ function saveScore(score) {
+ savePlayerScore("player",score);
+ }
+
+ function clearScores() {
+ __db().transaction(
+ function(tx) {
+ tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]);
+ fillModel();
+ }
+ )
+ }
+
+ Component.onCompleted: { fillModel() }
+}
diff --git a/examples/demos/snake/content/Link.qml b/examples/demos/snake/content/Link.qml
new file mode 100644
index 0000000000..aab005afd5
--- /dev/null
+++ b/examples/demos/snake/content/Link.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item { id:link
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property int row: 0
+ property int column: 0
+ property int rotation;
+
+ width: 40;
+ height: 40
+
+ x: margin - 3 + gridSize * column
+ y: margin - 3 + gridSize * row
+ Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} }
+ Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } }
+
+
+ Item {
+ id: img
+ anchors.fill: parent
+ Image {
+ source: {
+ if(type == 1) {
+ "pics/blueStone.png";
+ } else if (type == 2) {
+ "pics/head.png";
+ } else {
+ "pics/redStone.png";
+ }
+ }
+
+ transform: Rotation {
+ id: actualImageRotation
+ origin.x: width/2; origin.y: height/2;
+ angle: rotation * 90
+ Behavior on angle {
+ RotationAnimation{
+ direction: RotationAnimation.Shortest
+ duration: spawned ? 200 : 0
+ }
+ }
+ }
+ }
+
+ Image {
+ source: "pics/stoneShadow.png"
+ }
+
+ opacity: 0
+ }
+
+ ParticleSystem {
+ width:1; height:1; anchors.centerIn: parent;
+ ImageParticle {
+ groups: ["star"]
+ source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png"
+ }
+ Emitter {
+ id: particles
+ anchors.fill: parent
+ group: "star"
+ emitRate: 50
+ enabled: false
+ lifeSpan: 700
+ acceleration: AngleDirection { angleVariation: 360; magnitude: 200 }
+ }
+ }
+
+ states: [
+ State{ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ NumberAnimation { target: img; property: "opacity"; duration: 200 }
+ }
+ ]
+
+}
diff --git a/examples/demos/snake/content/Skull.qml b/examples/demos/snake/content/Skull.qml
new file mode 100644
index 0000000000..0c173be7da
--- /dev/null
+++ b/examples/demos/snake/content/Skull.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ property bool spawned: false
+ property int row;
+ property int column;
+ property int verticalMovement;
+ property int horizontalMovement;
+
+ x: screen.margin + column * screen.gridSize + 2
+ y: screen.margin + row * screen.gridSize - 3
+ Behavior on x { NumberAnimation { duration: spawned ? screen.halfbeatInterval : 0} }
+ Behavior on y { NumberAnimation { duration: spawned ? screen.halfbeatInterval : 0 } }
+
+ opacity: spawned ? 1 : 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+
+ source: "pics/skull.png"
+ width: 24
+ height: 40
+}
diff --git a/examples/demos/snake/content/pics/README b/examples/demos/snake/content/pics/README
new file mode 100644
index 0000000000..0215132caa
--- /dev/null
+++ b/examples/demos/snake/content/pics/README
@@ -0,0 +1 @@
+snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo.
diff --git a/examples/demos/snake/content/pics/background.png b/examples/demos/snake/content/pics/background.png
new file mode 100644
index 0000000000..72dffaa843
--- /dev/null
+++ b/examples/demos/snake/content/pics/background.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/blueStar.png b/examples/demos/snake/content/pics/blueStar.png
new file mode 100644
index 0000000000..ba7acabd26
--- /dev/null
+++ b/examples/demos/snake/content/pics/blueStar.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/blueStone.png b/examples/demos/snake/content/pics/blueStone.png
new file mode 100644
index 0000000000..356affdd95
--- /dev/null
+++ b/examples/demos/snake/content/pics/blueStone.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/cookie.png b/examples/demos/snake/content/pics/cookie.png
new file mode 100644
index 0000000000..aec2957f34
--- /dev/null
+++ b/examples/demos/snake/content/pics/cookie.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/eyes.svg b/examples/demos/snake/content/pics/eyes.svg
new file mode 100644
index 0000000000..1078692725
--- /dev/null
+++ b/examples/demos/snake/content/pics/eyes.svg
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ width="40"
+ height="40"
+ version="1.0"
+ sodipodi:docname="eyes.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs5">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective9" />
+ </defs>
+ <sodipodi:namedview
+ inkscape:window-height="838"
+ inkscape:window-width="907"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="12.35"
+ inkscape:cx="20"
+ inkscape:cy="20"
+ inkscape:window-x="117"
+ inkscape:window-y="45"
+ inkscape:current-layer="svg2" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2384"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,-4.9233835,3.3301401)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path3158"
+ sodipodi:cx="18.056681"
+ sodipodi:cy="9.5141697"
+ sodipodi:rx="7.1255059"
+ sodipodi:ry="11.295547"
+ d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
+ transform="matrix(1.0089865,0,0,0.5462656,9.6190931,3.3522563)" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path3182"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(11.65992,-9.740891)"
+ sodipodi:open="true" />
+ <rect
+ style="fill:#000000;fill-opacity:0"
+ id="rect2382"
+ width="40"
+ height="40"
+ x="0"
+ y="-7.1054274e-15"
+ inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1"
+ id="path2383"
+ sodipodi:cx="16.275303"
+ sodipodi:cy="12.307693"
+ sodipodi:rx="2.2672064"
+ sodipodi:ry="3.4008098"
+ d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
+ sodipodi:start="0"
+ sodipodi:end="3.1240432"
+ transform="translate(-3.3200119,-9.821862)"
+ sodipodi:open="true" />
+</svg>
diff --git a/examples/demos/snake/content/pics/head.png b/examples/demos/snake/content/pics/head.png
new file mode 100644
index 0000000000..550e002687
--- /dev/null
+++ b/examples/demos/snake/content/pics/head.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/pause.png b/examples/demos/snake/content/pics/pause.png
new file mode 100644
index 0000000000..056d97dd17
--- /dev/null
+++ b/examples/demos/snake/content/pics/pause.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/redStar.png b/examples/demos/snake/content/pics/redStar.png
new file mode 100644
index 0000000000..cd06854719
--- /dev/null
+++ b/examples/demos/snake/content/pics/redStar.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/redStone.png b/examples/demos/snake/content/pics/redStone.png
new file mode 100644
index 0000000000..9bb7fe4277
--- /dev/null
+++ b/examples/demos/snake/content/pics/redStone.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/skull.png b/examples/demos/snake/content/pics/skull.png
new file mode 100644
index 0000000000..63186167bd
--- /dev/null
+++ b/examples/demos/snake/content/pics/skull.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/snake.jpg b/examples/demos/snake/content/pics/snake.jpg
new file mode 100644
index 0000000000..e91a784f71
--- /dev/null
+++ b/examples/demos/snake/content/pics/snake.jpg
Binary files differ
diff --git a/examples/demos/snake/content/pics/star.png b/examples/demos/snake/content/pics/star.png
new file mode 100644
index 0000000000..defbde53ca
--- /dev/null
+++ b/examples/demos/snake/content/pics/star.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/stoneShadow.png b/examples/demos/snake/content/pics/stoneShadow.png
new file mode 100644
index 0000000000..1bd56afd04
--- /dev/null
+++ b/examples/demos/snake/content/pics/stoneShadow.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/yellowStar.png b/examples/demos/snake/content/pics/yellowStar.png
new file mode 100644
index 0000000000..52fb9c4b78
--- /dev/null
+++ b/examples/demos/snake/content/pics/yellowStar.png
Binary files differ
diff --git a/examples/demos/snake/content/pics/yellowStone.png b/examples/demos/snake/content/pics/yellowStone.png
new file mode 100644
index 0000000000..c56124a895
--- /dev/null
+++ b/examples/demos/snake/content/pics/yellowStone.png
Binary files differ
diff --git a/examples/demos/snake/content/snake.js b/examples/demos/snake/content/snake.js
new file mode 100644
index 0000000000..107c9f4591
--- /dev/null
+++ b/examples/demos/snake/content/snake.js
@@ -0,0 +1,316 @@
+
+var snake = new Array;
+var board = new Array;
+var links = new Array;
+var scheduledDirections = new Array;
+var numRows = 1;
+var numColumns = 1;
+var linkComponent = Qt.createComponent("Link.qml");
+var cookieComponent = Qt.createComponent("Cookie.qml");
+var cookie;
+var linksToGrow = 0;
+var linksToDie = 0;
+var waitForCookie = 0;
+var growType = 0;
+var skullMovementsBeforeDirectionChange = 0;
+
+
+function rand(n)
+{
+ return (Math.floor(Math.random() * n));
+}
+
+function scheduleDirection(dir)
+{
+ if (state == "starting") {
+ direction = dir;
+ headDirection = direction;
+ head.rotation = headDirection;
+ } else if (state == "running"){
+ direction = dir;
+ if(scheduledDirections[scheduledDirections.length-1]!=direction)
+ scheduledDirections.push(direction);
+ }
+}
+
+function startNewGame()
+{
+ if (state == "starting") {
+ return;
+ }
+
+ if (activeGame) {
+ endGame();
+ startNewGameTimer.running = true;
+ return;
+ }
+
+ state = "starting";
+
+ numRows = numRowsAvailable;
+ numColumns = numColumnsAvailable;
+ board = new Array(numRows * numColumns);
+ snake = new Array;
+ scheduledDirections = new Array;
+ growType = 0;
+
+ skull.z = numRows * numColumns + 1;
+
+ for (var i = 0; i < numRows * numColumns; ++i) {
+ if (i < links.length) {
+ var link = links[i];
+ link.spawned = false;
+ link.dying = false;
+ } else {
+ if(linkComponent.status != Component.Ready) {
+ if(linkComponent.status == Component.Error)
+ console.log(linkComponent.errorString());
+ else
+ console.log("Still loading linkComponent");
+ continue;//TODO: Better error handling?
+ }
+ var link = linkComponent.createObject(playfield);
+ link.z = numRows * numColumns + 1 - i;
+ link.type = i == 0 ? 2 : 0;
+ link.spawned = false;
+ link.dying = false;
+ links.push(link);
+ }
+ }
+
+ head = links[0];
+ snake.push(head);
+ head.row = numRows/2 -1;
+ head.column = numColumns/2 -1;
+ head.spawned = true;
+
+ linksToGrow = 5;
+ linksToDie = 0;
+ waitForCookie = 5;
+ score = 0;
+ startHeartbeatTimer.running = true;
+}
+
+function endGame()
+{
+ activeGame = false;
+ for(var i in snake)
+ snake[i].dying = true;
+ if (cookie) {
+ cookie.dying = true;
+ cookie = 0;
+ }
+ lastScore = score;
+ highScores.saveScore(lastScore);
+ state = "";
+}
+
+function move() {
+
+ if (!head)
+ return;
+
+ var dir = direction;
+
+ if (scheduledDirections.length) {
+ dir = scheduledDirections.shift();
+ }
+
+ if (state == "starting") {
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+ return;
+ }
+
+ var row = head.row;
+ var column = head.column;
+
+ if (dir == 0) {
+ row = row - 1;
+ } else if (dir == 1) {
+ column = column + 1
+ } else if (dir == 2) {
+ row = row + 1;
+ } else if (dir == 3) {
+ column = column - 1;
+ }
+
+ //validate the new position
+ if (row < 0 || row >= numRows
+ || column < 0 || column >= numColumns
+ || (row == skull.row && column == skull.column)
+ || !isFree(row, column)) {
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+ endGame();
+ return;
+ }
+
+ var newLink;
+ if (linksToGrow > 0) {
+ --linksToGrow;
+ newLink = links[snake.length];
+ newLink.spawned = false;
+ newLink.rotation = snake[snake.length-1].rotation;
+ newLink.type = growType;
+ newLink.dying = false;
+ snake.push(newLink);
+ } else {
+ var lastLink = snake[snake.length-1];
+ board[lastLink.row * numColumns + lastLink.column] = undefined;
+ }
+
+ if (waitForCookie > 0) {
+ if (--waitForCookie == 0)
+ createCookie(cookie? (cookie.value+1) : 1);
+ }
+
+ for (var i = snake.length-1; i > 0; --i) {
+ snake[i].row = snake[i-1].row;
+ snake[i].column = snake[i-1].column;
+ snake[i].rotation = snake[i-1].rotation;
+ }
+
+ if (newLink) {
+ newLink.spawned = true;
+ }
+
+ // move the head
+ head.row = row;
+ head.column = column;
+ board[row * numColumns + column] = head;
+
+ var turn = (dir - headDirection);
+ head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
+ headDirection = dir;
+
+ var value = testCookie(row, column);
+ if (value > 0) {
+ linksToGrow += value;
+ score += value;
+ }
+}
+
+function isFree(row, column)
+{
+ return board[row * numColumns + column] == undefined;
+}
+
+function isHead(row, column)
+{
+ return head.column == column && head.row == row;
+}
+
+function testCookie(row, column)
+{
+ if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) {
+ var value = cookie.value;
+ waitForCookie = value;
+ growType = snake[snake.length-1].type == 1 ? 0 : 1;
+ cookie.dying = true;
+ cookie.z = numRows * numColumns + 2;
+ return value;
+ }
+ return 0;
+}
+
+function moveSkull()
+{
+
+ if (linksToDie > 0) {
+ --linksToDie;
+ var link = snake.pop();
+ link.dying = true;
+ board[link.row * numColumns + link.column] = undefined;
+ if (score > 0)
+ --score;
+ if (snake.length == 0) {
+ endGame();
+ return;
+ }
+ }
+
+ var row = skull.row;
+ var column = skull.column;
+ if (isHead(row, column)) {
+ endGame();
+ return;
+ }
+ row += skull.verticalMovement;
+ column += skull.horizontalMovement;
+
+ var attempts = 4;
+
+ while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows
+ || column < 0 || column >= numColumns
+ || (!isFree(row, column) && !isHead(row, column))) {
+ var d = rand(8);
+ skull.verticalMovement = 0;
+ skull.horizontalMovement = 0;
+ skullMovementsBeforeDirectionChange = rand(20)+1;
+ if (d == 0) {
+ skull.verticalMovement = -1
+ } else if (d == 1) {
+ skull.horizontalMovement = -1;
+ } else if (d == 2) {
+ skull.verticalMovement = 1
+ } else if (d == 3){
+ skull.horizontalMovement = 1;
+ } else if (cookie) {
+ var rd = cookie.row - skull.row;
+ var rc = cookie.column - skull.column;
+ if (Math.abs(rd) > Math.abs(rc)) {
+ skull.verticalMovement = rd > 0 ? 1 : -1;
+ skullMovementsBeforeDirectionChange = Math.abs(rd);
+ } else {
+ skull.horizontalMovement= rc > 0 ? 1 : -1;
+ skullMovementsBeforeDirectionChange = Math.abs(rc);
+ }
+ }
+ row = skull.row + skull.verticalMovement;
+ column = skull.column + skull.horizontalMovement;
+ if (--attempts == 0)
+ return;
+ }
+
+ skull.row = row;
+ skull.column = column;
+ --skullMovementsBeforeDirectionChange;
+ var value = testCookie(row, column);
+ if (value > 0)
+ linksToDie += value/2;
+
+ if (isHead(row, column))
+ endGame();
+}
+
+function createCookie(value) {
+ if (numRows * numColumns - snake.length < 10)
+ return;
+
+ var column = rand(numColumns);
+ var row = rand(numRows);
+ while (!isFree(row, column)) {
+ column++;
+ if (column == numColumns) {
+ column = 0;
+ row++;
+ if (row == numRows)
+ row = 0;
+ }
+ }
+
+ if(cookieComponent.status != Component.Ready) {
+ if(cookieComponent.status == Component.Error)
+ console.log(cookieComponent.errorString());
+ else
+ console.log("Still loading cookieComponent");
+ return;//TODO: Better error handling?
+ }
+ cookie = cookieComponent.createObject(head.parent);
+ cookie.value = value;
+ cookie.row = row;
+ cookie.column = column;
+}
diff --git a/examples/demos/snake/snake.qml b/examples/demos/snake/snake.qml
new file mode 100644
index 0000000000..efd5747173
--- /dev/null
+++ b/examples/demos/snake/snake.qml
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content" as Content
+import "content/snake.js" as Logic
+Item{
+Rectangle {
+ id: screen;
+ SystemPalette { id: activePalette }
+ color: activePalette.window
+ property bool activeGame: false
+
+ property int gridSize : 34
+ property int margin: 4
+ property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize)
+ property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize)
+
+ property int lastScore : 0
+
+ property int score: 0;
+ property int heartbeatInterval: 200
+ property int halfbeatInterval: 160
+
+ width: 480
+ height: 750
+
+ property int direction
+ property int headDirection
+
+ property variant head;
+
+ Content.HighScoreModel {
+ id: highScores
+ game: "Snake"
+ }
+
+ Timer {
+ id: heartbeat;
+ interval: screen.heartbeatInterval;
+ running: screen.activeGame
+ repeat: true
+ onTriggered: { Logic.move() }
+ }
+ Timer {
+ id: halfbeat;
+ interval: screen.halfbeatInterval;
+ repeat: true
+ running: heartbeat.running
+ onTriggered: { Logic.moveSkull() }
+ }
+ Timer {
+ id: startNewGameTimer;
+ interval: 700;
+ onTriggered: { Logic.startNewGame(); }
+ }
+
+ Timer {
+ id: startHeartbeatTimer;
+ interval: 1000 ;
+ onTriggered: { screen.state = "running"; screen.activeGame = true; }
+ }
+
+ Image{
+ id: pauseDialog
+ z: 1
+ source: "content/pics/pause.png"
+ anchors.centerIn: parent;
+ //opacity is deliberately not animated
+ opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331)
+ }
+
+ Image {
+
+ Image {
+ id: title
+ source: "content/pics/snake.jpg"
+ fillMode: Image.PreserveAspectCrop
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+
+ Column {
+ spacing: 140
+ anchors.verticalCenter: parent.verticalCenter;
+ anchors.left: parent.left;
+ anchors.right: parent.right;
+
+ Text {
+ color: "white"
+ font.pointSize: 48
+ font.italic: true;
+ font.bold: true;
+ text: "Snake"
+ anchors.horizontalCenter: parent.horizontalCenter;
+ }
+
+ Text {
+ color: "white"
+ font.pointSize: 24
+ anchors.horizontalCenter: parent.horizontalCenter;
+ //horizontalAlignment: Text.AlignHCenter
+ text: "Last Score:\t" + screen.lastScore + "\nHighscore:\t" + highScores.topScore;
+ }
+ }
+ }
+
+ source: "content/pics/background.png"
+ fillMode: Image.PreserveAspectCrop
+
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: toolbar.top
+
+ Rectangle {
+ id: playfield
+ border.width: 1
+ border.color: "white"
+ color: "transparent"
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: (screen.height - 32 - height)/2;
+ width: screen.numColumnsAvailable * screen.gridSize + 2*screen.margin
+ height: screen.numRowsAvailable * screen.gridSize + 2*screen.margin
+
+
+ Content.Skull {
+ id: skull
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ if (screen.state == "") {
+ Logic.startNewGame();
+ return;
+ }
+ if (direction == 0 || direction == 2)
+ Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3);
+ else
+ Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0);
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ id: progressBar
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ color: "transparent"
+ border.width: 2
+ border.color: "#221edd"
+ x: 50
+ y: 50
+ width: 200
+ height: 30
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: 40
+
+ Rectangle {
+ id: progressIndicator
+ color: "#221edd";
+ width: 0;
+ height: 30;
+ }
+ }
+
+ Rectangle {
+ id: toolbar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+ Content.Button {
+ id: btnA; text: "New Game"; onClicked: Logic.startNewGame();
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Content.Button {
+ text: "Quit"
+ anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
+ onClicked: Qt.quit();
+ }
+
+ Text {
+ color: activePalette.text
+ text: "Score: " + screen.score; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ focus: true
+ Keys.onSpacePressed: Logic.startNewGame();
+ Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3);
+ Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1);
+ Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0);
+ Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2);
+
+ states: [
+ State {
+ name: "starting"
+ PropertyChanges {target: progressIndicator; width: 200}
+ PropertyChanges {target: title; opacity: 0}
+ PropertyChanges {target: progressBar; opacity: 1}
+ },
+ State {
+ name: "running"
+ PropertyChanges {target: progressIndicator; width: 200}
+ PropertyChanges {target: title; opacity: 0}
+ PropertyChanges {target: skull; row: 0; column: 0; }
+ PropertyChanges {target: skull; spawned: 1}
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+ NumberAnimation { property: "opacity"; duration: 200 }
+ },
+ Transition {
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+ NumberAnimation { property: "opacity"; duration: 200 }
+ }
+ ]
+
+}
+}
diff --git a/examples/demos/snake/snake.qmlproject b/examples/demos/snake/snake.qmlproject
new file mode 100644
index 0000000000..fb015465d1
--- /dev/null
+++ b/examples/demos/snake/snake.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "snake.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/demos/tic-tac-toe/content/Button.qml b/examples/demos/tic-tac-toe/content/Button.qml
new file mode 100644
index 0000000000..6dd141f838
--- /dev/null
+++ b/examples/demos/tic-tac-toe/content/Button.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text
+ property bool pressed: false
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
+ border { width: 1; color: Qt.darker(container.color) }
+ radius: 8
+ color: "lightgray"
+ smooth: true
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: container.pressed ? "darkgray" : "white"
+ }
+ GradientStop {
+ position: 1.0
+ color: container.color
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ text: container.text
+ font.pixelSize: 14
+ }
+}
diff --git a/examples/demos/tic-tac-toe/content/TicTac.qml b/examples/demos/tic-tac-toe/content/TicTac.qml
new file mode 100644
index 0000000000..e74bc6bcda
--- /dev/null
+++ b/examples/demos/tic-tac-toe/content/TicTac.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ signal clicked
+
+ states: [
+ State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } },
+ State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } }
+ ]
+
+ Image {
+ id: image
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+}
diff --git a/examples/demos/tic-tac-toe/content/pics/board.png b/examples/demos/tic-tac-toe/content/pics/board.png
new file mode 100644
index 0000000000..7e5b7ba27c
--- /dev/null
+++ b/examples/demos/tic-tac-toe/content/pics/board.png
Binary files differ
diff --git a/examples/demos/tic-tac-toe/content/pics/o.png b/examples/demos/tic-tac-toe/content/pics/o.png
new file mode 100644
index 0000000000..abc7ee020b
--- /dev/null
+++ b/examples/demos/tic-tac-toe/content/pics/o.png
Binary files differ
diff --git a/examples/demos/tic-tac-toe/content/pics/x.png b/examples/demos/tic-tac-toe/content/pics/x.png
new file mode 100644
index 0000000000..ddc65c83b8
--- /dev/null
+++ b/examples/demos/tic-tac-toe/content/pics/x.png
Binary files differ
diff --git a/examples/demos/tic-tac-toe/content/tic-tac-toe.js b/examples/demos/tic-tac-toe/content/tic-tac-toe.js
new file mode 100644
index 0000000000..5a166b750f
--- /dev/null
+++ b/examples/demos/tic-tac-toe/content/tic-tac-toe.js
@@ -0,0 +1,149 @@
+function winner(board)
+{
+ for (var i=0; i<3; ++i) {
+ if (board.children[i].state != ""
+ && board.children[i].state == board.children[i+3].state
+ && board.children[i].state == board.children[i+6].state)
+ return true
+
+ if (board.children[i*3].state != ""
+ && board.children[i*3].state == board.children[i*3+1].state
+ && board.children[i*3].state == board.children[i*3+2].state)
+ return true
+ }
+
+ if (board.children[0].state != ""
+ && board.children[0].state == board.children[4].state != ""
+ && board.children[0].state == board.children[8].state != "")
+ return true
+
+ if (board.children[2].state != ""
+ && board.children[2].state == board.children[4].state != ""
+ && board.children[2].state == board.children[6].state != "")
+ return true
+
+ return false
+}
+
+function restartGame()
+{
+ game.running = true
+
+ for (var i=0; i<9; ++i)
+ board.children[i].state = ""
+}
+
+function makeMove(pos, player)
+{
+ board.children[pos].state = player
+ if (winner(board)) {
+ gameFinished(player + " wins")
+ return true
+ } else {
+ return false
+ }
+}
+
+function canPlayAtPos(pos)
+{
+ return board.children[pos].state == ""
+}
+
+function computerTurn()
+{
+ var r = Math.random();
+ if (r < game.difficulty)
+ smartAI();
+ else
+ randomAI();
+}
+
+function smartAI()
+{
+ function boardCopy(a) {
+ var ret = new Object;
+ ret.children = new Array(9);
+ for (var i = 0; i<9; i++) {
+ ret.children[i] = new Object;
+ ret.children[i].state = a.children[i].state;
+ }
+ return ret;
+ }
+
+ for (var i=0; i<9; i++) {
+ var simpleBoard = boardCopy(board);
+ if (canPlayAtPos(i)) {
+ simpleBoard.children[i].state = "O";
+ if (winner(simpleBoard)) {
+ makeMove(i, "O")
+ return
+ }
+ }
+ }
+ for (var i=0; i<9; i++) {
+ var simpleBoard = boardCopy(board);
+ if (canPlayAtPos(i)) {
+ simpleBoard.children[i].state = "X";
+ if (winner(simpleBoard)) {
+ makeMove(i, "O")
+ return
+ }
+ }
+ }
+
+ function thwart(a,b,c) { //If they are at a, try b or c
+ if (board.children[a].state == "X") {
+ if (canPlayAtPos(b)) {
+ makeMove(b, "O")
+ return true
+ } else if (canPlayAtPos(c)) {
+ makeMove(c, "O")
+ return true
+ }
+ }
+ return false;
+ }
+
+ if (thwart(4,0,2)) return;
+ if (thwart(0,4,3)) return;
+ if (thwart(2,4,1)) return;
+ if (thwart(6,4,7)) return;
+ if (thwart(8,4,5)) return;
+ if (thwart(1,4,2)) return;
+ if (thwart(3,4,0)) return;
+ if (thwart(5,4,8)) return;
+ if (thwart(7,4,6)) return;
+
+ for (var i =0; i<9; i++) {
+ if (canPlayAtPos(i)) {
+ makeMove(i, "O")
+ return
+ }
+ }
+ restartGame();
+}
+
+function randomAI()
+{
+ var unfilledPosns = new Array();
+
+ for (var i=0; i<9; ++i) {
+ if (canPlayAtPos(i))
+ unfilledPosns.push(i);
+ }
+
+ if (unfilledPosns.length == 0) {
+ restartGame();
+ } else {
+ var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)];
+ makeMove(choice, "O");
+ }
+}
+
+function gameFinished(message)
+{
+ messageDisplay.text = message
+ messageDisplay.visible = true
+ game.running = false
+}
+
diff --git a/examples/demos/tic-tac-toe/tic-tac-toe.qml b/examples/demos/tic-tac-toe/tic-tac-toe.qml
new file mode 100644
index 0000000000..8d15233eaa
--- /dev/null
+++ b/examples/demos/tic-tac-toe/tic-tac-toe.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/tic-tac-toe.js" as Logic
+
+Rectangle {
+ id: game
+
+ property bool running: true
+ property real difficulty: 1.0 //chance it will actually think
+
+ width: display.width; height: display.height + 10
+
+ Image {
+ id: boardImage
+ source: "content/pics/board.png"
+ }
+
+
+ Column {
+ id: display
+
+ Grid {
+ id: board
+ width: boardImage.width; height: boardImage.height
+ columns: 3
+
+ Repeater {
+ model: 9
+
+ TicTac {
+ width: board.width/3
+ height: board.height/3
+
+ onClicked: {
+ if (game.running && Logic.canPlayAtPos(index)) {
+ if (!Logic.makeMove(index, "X"))
+ Logic.computerTurn();
+ }
+ }
+ }
+ }
+ }
+
+ Row {
+ spacing: 4
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Button {
+ text: "Hard"
+ pressed: game.difficulty == 1.0
+ onClicked: { game.difficulty = 1.0 }
+ }
+ Button {
+ text: "Moderate"
+ pressed: game.difficulty == 0.8
+ onClicked: { game.difficulty = 0.8 }
+ }
+ Button {
+ text: "Easy"
+ pressed: game.difficulty == 0.2
+ onClicked: { game.difficulty = 0.2 }
+ }
+ }
+ }
+
+
+ Text {
+ id: messageDisplay
+ anchors.centerIn: parent
+ color: "blue"
+ style: Text.Outline; styleColor: "white"
+ font.pixelSize: 50; font.bold: true
+ visible: false
+
+ Timer {
+ running: messageDisplay.visible
+ onTriggered: {
+ messageDisplay.visible = false;
+ Logic.restartGame();
+ }
+ }
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/Button.qml b/examples/demos/twitter/TwitterCore/Button.qml
new file mode 100644
index 0000000000..353b993742
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/Button.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+ property bool keyUsing: false
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width; height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ id: btnText
+ color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
+ anchors.centerIn: buttonImage; font.bold: true
+ text: container.text; style: Text.Raised; styleColor: "black"
+ font.pixelSize: 12
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ },
+ State {
+ name: "Focused"
+ when: container.activeFocus == true
+ PropertyChanges { target: btnText; color: "#FFFFFF" }
+ }
+ ]
+ transitions: Transition {
+ ColorAnimation { target: btnText; }
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/FatDelegate.qml b/examples/demos/twitter/TwitterCore/FatDelegate.qml
new file mode 100644
index 0000000000..4cb0dfc713
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/FatDelegate.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ id: listDelegate
+ Item {
+ id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5
+ function handleLink(link){
+ if(link.slice(0,3) == 'app'){
+ screen.setUser(link.slice(7));
+ }else if(link.slice(0,4) == 'http'){
+ Qt.openUrlExternally(link);
+ }
+ }
+ function addTags(str){
+ var ret = str.replace(/@[a-zA-Z0-9_]+/g, '<a href="app://$&">$&</a>');//click to jump to user?
+ var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '<a href="$&">$&</a>');//surrounds http links with html link tags
+ return ret2;
+ }
+
+ // Strip away paranthesis
+ function userName(str) {
+ var user = str.replace(/\([\S|\s]*\)/gi, "");
+ return user.trim();
+ }
+
+ Item {
+ id: moveMe; height: parent.height
+ Rectangle {
+ id: blackRect
+ color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1
+ }
+ Item {
+ id: image; x: 6; width: 48; height: 48; smooth: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready }
+ Image {
+ id: realImage;
+ source: userImage; x: 1; y: 1;
+ width:48; height:48; opacity:0 ;
+ onStatusChanged: {
+ if(status==Image.Ready)
+ image.state="loaded"
+ }
+ }
+ states: State {
+ name: "loaded";
+ PropertyChanges { target: realImage ; opacity:1 }
+ }
+ transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } }
+
+ }
+ Text { id:txt; y:4; x: 56
+ text: '<html>'
+ + '<a href="app://@'+userName(name)+'"><b>'+userName(name) + "</b></a> from " +source
+ + "<br /><b>" + statusText + "</b></html>";
+ textFormat: Text.StyledText
+ color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa"
+ anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
+ onLinkActivated: wrapper.handleLink(link)
+ }
+ }
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/Input.qml b/examples/demos/twitter/TwitterCore/Input.qml
new file mode 100644
index 0000000000..68b1c6186a
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/Input.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id:container
+ width: 220
+ height: 28
+ BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
+ signal accepted
+ property alias text: input.text
+ property alias item:input
+ TextInput{
+ id: input
+ width: parent.width - 12
+ anchors.centerIn: parent
+ maximumLength:21
+ font.pixelSize: 16;
+ font.bold: true
+ color: "#151515"; selectionColor: "mediumseagreen"
+ focus: true
+ onAccepted:{container.accepted()}
+ text: ""
+ selectByMouse: true
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/Loading.qml b/examples/demos/twitter/TwitterCore/Loading.qml
new file mode 100644
index 0000000000..566857b8b2
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/Loading.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: loading; source: "images/loading.png"
+ NumberAnimation on rotation {
+ from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml
new file mode 100644
index 0000000000..3920520b7a
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ TitleBar { id: titleBar; width: parent.width; height: 60;
+ y: -80
+ untaggedString: "Latest tweets from everyone"
+ taggedString: "Latest tweets from "
+ }
+ states: [
+ State {
+ name: "search"; when: screen.state!="search"
+ PropertyChanges { target: titleBar; y: 0 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
+}
+
diff --git a/examples/demos/twitter/TwitterCore/RssModel.qml b/examples/demos/twitter/TwitterCore/RssModel.qml
new file mode 100644
index 0000000000..27f7495be2
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/RssModel.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Item { id: wrapper
+ property variant model: xmlModel
+ property string from : ""
+ property string to : ""
+ property string phrase : ""
+
+ property string mode : "everyone"
+ property int status: xmlModel.status
+ function reload() { xmlModel.reload(); }
+
+ XmlListModel {
+ id: xmlModel
+
+ function encodePhrase(x) { return encodeURIComponent(x); }
+
+ source: (from=="" && to=="" && phrase=="") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase)
+
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "statusText"; query: "content/string()" }
+ XmlRole { name: "timestamp"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+ Binding {
+ property: "mode"
+ target: wrapper
+ value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}}
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/SearchView.qml b/examples/demos/twitter/TwitterCore/SearchView.qml
new file mode 100644
index 0000000000..7732e6f68d
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/SearchView.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: wrapper
+ Column {
+ anchors.centerIn: parent
+ spacing: 20
+ Column{
+ spacing: 4
+ Text {
+ text: "Posted by:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: fromIn
+ KeyNavigation.backtab: searchbutton
+ KeyNavigation.tab:toIn
+ onAccepted:searchbutton.doSearch();
+ focus: true
+ }
+ Text {
+ text: "In reply to:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: toIn
+ KeyNavigation.backtab: fromIn
+ KeyNavigation.tab:phraseIn
+ onAccepted:searchbutton.doSearch();
+ }
+ Text {
+ text: "Search phrase:"
+ font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black"
+ horizontalAlignment: Qt.AlignRight
+ }
+ Input{
+ id: phraseIn
+ KeyNavigation.backtab: toIn
+ KeyNavigation.tab:searchbutton
+ onAccepted:searchbutton.doSearch();
+ text: "Qt Quick"
+ }
+ }
+ Button {
+ width: 100
+ height: 32
+ id: searchbutton
+ keyUsing: true;
+ opacity: 1
+ text: "Search"
+ KeyNavigation.tab: fromIn
+ Keys.onReturnPressed: searchbutton.doSearch();
+ Keys.onEnterPressed: searchbutton.doSearch();
+ Keys.onSelectPressed: searchbutton.doSearch();
+ Keys.onSpacePressed: searchbutton.doSearch();
+ onClicked: searchbutton.doSearch();
+
+ function doSearch() {
+ // Search ! allowed
+ if (wrapper.state=="invalidinput")
+ return;
+
+ rssModel.from=fromIn.text;
+ rssModel.to= toIn.text;
+ rssModel.phrase = phraseIn.text;
+ screen.focus = true;
+ screen.state = ""
+ }
+ }
+ }
+ states:
+ State {
+ name: "invalidinput"
+ when: fromIn.text=="" && toIn.text=="" && phraseIn.text==""
+ PropertyChanges { target: searchbutton ; opacity: 0.6 ; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 }
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/TitleBar.qml b/examples/demos/twitter/TwitterCore/TitleBar.qml
new file mode 100644
index 0000000000..3e0818b0dd
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/TitleBar.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string untaggedString: "Uploads from everyone"
+ property string taggedString: "Recent uploads tagged "
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Item {
+ id: container
+ width: (parent.width * 2) - 55 ; height: parent.height
+
+ function accept() {
+ titleBar.state = ""
+ background.state = ""
+ rssModel.tags = editor.text
+ }
+
+ Item {
+ id:imageBox
+ x: 6; width: 0; height: 50; smooth: true
+ anchors.verticalCenter: parent.verticalCenter
+
+ UserModel { user: rssModel.from; id: userModel }
+ Component {
+ id: imgDelegate;
+ Item {
+ id:imageitem
+ visible:true
+ Loading { width:48; height:48; visible: realImage.status != Image.Ready }
+ Image { id: realImage; source: image; width:48; height:48; opacity:0; }
+ states:
+ State {
+ name: "loaded"
+ when: (realImage.status == Image.Ready)
+ PropertyChanges { target: realImage; opacity:1 }
+ }
+ transitions: Transition {
+ NumberAnimation { target: realImage; property: "opacity"; duration: 200 }
+ }
+ }
+ }
+ ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate }
+ states:
+ State {
+ when: !userModel.user==""
+ PropertyChanges { target: imageBox; width: 50; }
+ }
+ transitions:
+ Transition {
+ NumberAnimation { target: imageBox; property: "width"; duration: 200 }
+ }
+ }
+
+ Image {
+ id: quitButton
+ x: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from)
+ font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
+ font.pixelSize: 12
+ }
+ }
+
+ states: State {
+ name: "Tags"
+ PropertyChanges { target: container; x: -tagButton.x + 5 }
+ PropertyChanges { target: editor; focus: true }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/ToolBar.qml b/examples/demos/twitter/TwitterCore/ToolBar.qml
new file mode 100644
index 0000000000..d4265f3e98
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/ToolBar.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property alias button1Label: button1.text
+ property alias button2Label: button2.text
+ signal button1Clicked
+ signal button2Clicked
+ focus:true
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+ Button {
+ id: button1
+ anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32
+ onClicked: toolbar.button1Clicked()
+ focus:true
+ }
+ Button {
+ id: button2
+ anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32
+ onClicked: toolbar.button2Clicked()
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/UserModel.qml b/examples/demos/twitter/TwitterCore/UserModel.qml
new file mode 100644
index 0000000000..428089b539
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/UserModel.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+//This "model" gets the user information about the searched user. Mainly for the icon.
+
+Item { id: wrapper
+ property variant model: xmlModel
+ property string user : ""
+ property int status: xmlModel.status
+ function reload() { xmlModel.reload(); }
+ XmlListModel {
+ id: xmlModel
+
+ source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : ""
+ query: "/user"
+
+ XmlRole { name: "name"; query: "name/string()" }
+ XmlRole { name: "screenName"; query: "screen_name/string()" }
+ XmlRole { name: "image"; query: "profile_image_url/string()" }
+ XmlRole { name: "location"; query: "location/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "followers"; query: "followers_count/string()" }
+ //TODO: Could also get the user's color scheme, timezone and a few other things
+ }
+}
diff --git a/examples/demos/twitter/TwitterCore/images/gloss.png b/examples/demos/twitter/TwitterCore/images/gloss.png
new file mode 100644
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/gloss.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/lineedit.png b/examples/demos/twitter/TwitterCore/images/lineedit.png
new file mode 100644
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/lineedit.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/lineedit.sci b/examples/demos/twitter/TwitterCore/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/demos/twitter/TwitterCore/images/loading.png b/examples/demos/twitter/TwitterCore/images/loading.png
new file mode 100644
index 0000000000..47a1589c5d
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/loading.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/quit.png b/examples/demos/twitter/TwitterCore/images/quit.png
new file mode 100644
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/quit.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/stripes.png b/examples/demos/twitter/TwitterCore/images/stripes.png
new file mode 100644
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/stripes.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/titlebar.png b/examples/demos/twitter/TwitterCore/images/titlebar.png
new file mode 100644
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/titlebar.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/titlebar.sci b/examples/demos/twitter/TwitterCore/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/demos/twitter/TwitterCore/images/toolbutton.png b/examples/demos/twitter/TwitterCore/images/toolbutton.png
new file mode 100644
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/toolbutton.png
Binary files differ
diff --git a/examples/demos/twitter/TwitterCore/images/toolbutton.sci b/examples/demos/twitter/TwitterCore/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/demos/twitter/TwitterCore/qmldir b/examples/demos/twitter/TwitterCore/qmldir
new file mode 100644
index 0000000000..452a648b23
--- /dev/null
+++ b/examples/demos/twitter/TwitterCore/qmldir
@@ -0,0 +1,10 @@
+SearchView 2.0 SearchView.qml
+Button 2.0 Button.qml
+Input 2.0 Input.qml
+FatDelegate 2.0 FatDelegate.qml
+Loading 2.0 Loading.qml
+MultiTitleBar 2.0 MultiTitleBar.qml
+TitleBar 2.0 TitleBar.qml
+RssModel 2.0 RssModel.qml
+UserModel 2.0 UserModel.qml
+ToolBar 2.0 ToolBar.qml
diff --git a/examples/demos/twitter/twitter.qml b/examples/demos/twitter/twitter.qml
new file mode 100644
index 0000000000..aca0968cfb
--- /dev/null
+++ b/examples/demos/twitter/twitter.qml
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+import "TwitterCore" 2.0 as Twitter
+
+Item {
+ id: screen; width: 320; height: 480
+ property bool userView : false
+ property variant tmpStr
+ function setUser(str){hack.running = true; tmpStr = str}
+ function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
+ state:"searchquery"
+ //Workaround for bug 260266
+ Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
+ Keys.onEscapePressed: screen.state="searchquery"
+ Keys.onBacktabPressed: screen.state="searchquery"
+ Rectangle {
+ id: background
+ anchors.fill: parent; color: "#343434";
+
+ state:"searchquery"
+ Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: screen.focus = false;
+ }
+
+ Twitter.RssModel { id: rssModel }
+ Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'}
+ Text {
+ width: 180
+ text: "Could not access twitter using this screen name and password pair.";
+ color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
+ visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent
+ }
+
+ Item {
+ id: views
+ x: 2; width: parent.width - 4
+ y:60 //Below the title bars
+ height: parent.height - 100
+
+ Text {
+ id:title
+ text: "Search Twitter"
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
+ opacity:0
+ }
+
+ Twitter.SearchView{
+ id: searchView
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.width; height: parent.height-60;
+ x: -(screen.width * 1.5)
+ }
+
+ Twitter.FatDelegate { id: fatDelegate }
+ ListView {
+ id: mainView; model: rssModel.model; delegate: fatDelegate;
+ width: parent.width; height: parent.height; x: 0; cacheBuffer: 100;
+ }
+ }
+
+ Twitter.MultiTitleBar { id: titleBar; width: parent.width }
+ Twitter.ToolBar { id: toolBar; height: 40;
+ //anchors.bottom: parent.bottom;
+ //TODO: Use anchor changes instead of hard coding
+ y: screen.height - 40
+ width: parent.width; opacity: 0.9
+ button1Label: "New Search"
+ button2Label: "Update"
+ onButton1Clicked:
+ {
+ screen.state="searchquery"
+ }
+ onButton2Clicked: rssModel.reload();
+ }
+ }
+ states: [
+ State {
+ name: "searchquery";
+ PropertyChanges { target: searchView; x: 0; focus:true}
+ PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
+ PropertyChanges { target: titleBar; y: -80 }
+ PropertyChanges { target: toolBar; y: screen.height }
+ PropertyChanges { target: toolBar }
+ PropertyChanges { target: title; opacity:1}
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
+ ]
+}
diff --git a/examples/demos/twitter/twitter.qmlproject b/examples/demos/twitter/twitter.qmlproject
new file mode 100644
index 0000000000..b14f71fdfd
--- /dev/null
+++ b/examples/demos/twitter/twitter.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "twitter.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/examples.pro b/examples/examples.pro
index 3e5c4d08a5..d3d2f5520f 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += qml tutorials
+SUBDIRS += demos shared localstorage particles qml quick tutorials window
contains(QT_CONFIG, qmltest): SUBDIRS += qmltest
diff --git a/examples/localstorage/hello.qml b/examples/localstorage/hello.qml
new file mode 100644
index 0000000000..3496b86bd9
--- /dev/null
+++ b/examples/localstorage/hello.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import QtQuick 2.0
+import QtQuick.LocalStorage 2.0 as LS
+
+Rectangle {
+ color: "white"
+ width: 200
+ height: 100
+
+ Text {
+ text: "?"
+ anchors.horizontalCenter: parent.horizontalCenter
+ function findGreetings() {
+ var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
+
+ db.transaction(
+ function(tx) {
+ // Create the database if it doesn't already exist
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+
+ // Add (another) greeting row
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+
+ // Show all added greetings
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+
+ var r = ""
+ for(var i = 0; i < rs.rows.length; i++) {
+ r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ }
+ text = r
+ }
+ )
+ }
+
+ Component.onCompleted: findGreetings()
+ }
+}
+//![0]
diff --git a/examples/localstorage/localstorage.pro b/examples/localstorage/localstorage.pro
new file mode 100644
index 0000000000..967108504e
--- /dev/null
+++ b/examples/localstorage/localstorage.pro
@@ -0,0 +1 @@
+TEMPLATE = subdirs
diff --git a/examples/particles/affectors/age.qml b/examples/particles/affectors/age.qml
new file mode 100644
index 0000000000..ea1b30275e
--- /dev/null
+++ b/examples/particles/affectors/age.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 600
+ color: "white"
+
+ ParticleSystem { id: particles }
+
+ ImageParticle {
+ system: particles
+ sprites: Sprite {
+ name: "snow"
+ source: "../images/snowflake.png"
+ frameCount: 51
+ frameDuration: 40
+ frameDurationVariation: 8
+ }
+ }
+
+ Emitter {
+ system: particles
+ emitRate: 20
+ lifeSpan: 8000
+ speed: PointDirection { y:80; yVariation: 40; }
+ acceleration: PointDirection { y: 4 }
+ size: 36
+ endSize: 12
+ sizeVariation: 8
+ width: parent.width
+ height: 100
+ }
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ hoverEnabled: true
+ }
+
+ Rectangle {
+ color: "#803333AA"
+ border.color: "black"
+ x: ma.mouseX - 36
+ y: ma.mouseY - 36
+ width: 72
+ height: 72
+ Age {
+ anchors.fill: parent
+ system: particles
+ once: true
+ lifeLeft: 1200
+ advancePosition: false
+ }
+ }
+}
diff --git a/examples/particles/affectors/attractor.qml b/examples/particles/affectors/attractor.qml
new file mode 100644
index 0000000000..0d50937fe7
--- /dev/null
+++ b/examples/particles/affectors/attractor.qml
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+ property bool spacePressed: false
+ focus: true
+ Image {
+ source: "../images/finalfrontier.png"
+ anchors.centerIn:parent
+ }
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Space) {
+ spacePressed = true;
+ event.accepted = true;
+ }
+ }
+ Keys.onReleased: {
+ if (event.key == Qt.Key_Space) {
+ spacePressed = false;
+ event.accepted = true;
+ }
+ }
+
+ Emitter {
+ group: "stars"
+ system: particles
+ emitRate: 40
+ lifeSpan: 4000
+ enabled: true
+ size: 30
+ sizeVariation: 10
+ speed: PointDirection { x: 220; xVariation: 40 }
+ height: parent.height
+ }
+ Emitter {
+ group: "roids"
+ system: particles
+ emitRate: 10
+ lifeSpan: 4000
+ enabled: true
+ size: 30
+ sizeVariation: 10
+ speed: PointDirection { x: 220; xVariation: 40 }
+ height: parent.height
+ }
+ ParticleSystem {
+ id: particles
+ anchors.fill: parent
+ }
+ ImageParticle {
+ id: stars
+ groups: ["stars"]
+ system: particles
+ source: "../images/star.png"
+ color: "white"
+ colorVariation: 0.1
+ alpha: 0
+ }
+ ImageParticle {
+ id: roids
+ groups: ["roids"]
+ system: particles
+ sprites: Sprite {
+ id: spinState
+ name: "spinning"
+ source: "../images/meteor.png"
+ frameCount: 35
+ frameDuration: 60
+ }
+ }
+ ImageParticle {
+ id: shot
+ groups: ["shot"]
+ system: particles
+ source: "../images/star.png"
+
+ color: "#0FF06600"
+ colorVariation: 0.3
+ }
+ ImageParticle {
+ id: engine
+ groups: ["engine"]
+ system: particles
+ source: "../images/particle4.png"
+
+ color: "orange"
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "red"
+ to: "cyan"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "cyan"
+ to: "red"
+ duration: 1000
+ }
+ }
+
+ colorVariation: 0.2
+ }
+ Attractor {
+ id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000;
+ system: particles
+ affectedParameter: Attractor.Acceleration
+ proportionalToDistance: Attractor.InverseQuadratic
+ }
+ Age {
+ system: particles
+ x: gs.pointX - 8;
+ y: gs.pointY - 8;
+ width: 16
+ height: 16
+ }
+ Rectangle {
+ color: "black"
+ width: 8
+ height: 8
+ radius: 4
+ x: gs.pointX - 4
+ y: gs.pointY - 4
+ }
+
+ Image {
+ source:"../images/rocket2.png"
+ id: ship
+ width: 45
+ height: 22
+ MouseArea {
+ id: ma
+ anchors.fill: parent;
+ drag.axis: Drag.XandYAxis
+ drag.target: ship
+ }
+ }
+ Emitter {
+ group: "engine"
+ system: particles
+ emitRate: 200
+ lifeSpan: 1000
+ size: 10
+ endSize: 4
+ sizeVariation: 4
+ speed: PointDirection { x: -128; xVariation: 32 }
+ height: ship.height
+ y: ship.y
+ x: ship.x
+ width: 20
+ }
+ Emitter {
+ group: "shot"
+ system: particles
+ emitRate: 32
+ lifeSpan: 2000
+ enabled: spacePressed
+ size: 40
+ speed: PointDirection { x: 256; }
+ x: ship.x + ship.width
+ y: ship.y + ship.height/2
+ }
+
+ Text {
+ color: "white"
+ anchors.bottom: parent.bottom
+ text:"Drag the ship, Spacebar to fire."
+ }
+}
+
diff --git a/examples/particles/affectors/customaffector.qml b/examples/particles/affectors/customaffector.qml
new file mode 100644
index 0000000000..9ccf45d3e6
--- /dev/null
+++ b/examples/particles/affectors/customaffector.qml
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ width: 360
+ height: 600
+
+ Image {
+ source: "../images/backgroundLeaves.jpg"
+ anchors.fill: parent
+ }
+ ParticleSystem {
+ id: sys
+ }
+ Emitter {
+ system: sys
+ width: parent.width
+ emitRate: 4
+ lifeSpan: 14000
+ size: 80
+ speed: PointDirection { y: 60 }
+ }
+ Wander {
+ system: sys
+ anchors.fill: parent
+ anchors.bottomMargin: 100
+ xVariance: 60
+ pace: 60
+ }
+
+ Affector {
+ system: sys
+ property real coefficient: 0.1
+ property real speed: 1.5
+ width: parent.width
+ height: parent.height - 100
+ onAffectParticles: {
+ /* //Linear movement
+ if (particle.r == 0) {
+ particle.r = Math.random() > 0.5 ? -1 : 1;
+ }else if (particle.r == 1) {
+ particle.rotation += speed * dt;
+ if(particle.rotation >= maxAngle)
+ particle.r = -1;
+ }else if (particle.r == -1) {
+ particle.rotation -= speed * dt;
+ if(particle.rotation <= -1 * maxAngle)
+ particle.r = 1;
+ }
+ */
+ //Wobbly movement
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ if (particle.r == 0.0) {
+ particle.r = Math.random() + 0.01;
+ }
+ particle.rotation += speed * particle.r * dt;
+ particle.r -= particle.rotation * coefficient;
+ if (particle.r == 0.0)
+ particle.r -= particle.rotation * 0.000001;
+ particle.update = 1;
+ }
+ }
+ }
+
+ Affector {//Custom Friction, adds some 'randomness'
+ system: sys
+ //onceOff: true
+ x: -60
+ width: parent.width + 120
+ height: 100
+ anchors.bottom: parent.bottom
+ onAffectParticles: {
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
+ var yslow = dt * pseudoRand * 0.5 + 1;
+ var xslow = dt * pseudoRand * 0.05 + 1;
+ if (particle.vy < 1)
+ particle.vy = 0;
+ else
+ particle.vy = (particle.vy / yslow);
+ if (particle.vx < 1)
+ particle.vx = 0;
+ else
+ particle.vx = (particle.vx / xslow);
+ particle.update = true;
+ }
+ }
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ id: particles
+ system: sys
+ sprites: [Sprite {
+ source: "../images/realLeaf1.png"
+ frameCount: 1
+ frameDuration: 1
+ to: {"a":1, "b":1, "c":1, "d":1}
+ }, Sprite {
+ name: "a"
+ source: "../images/realLeaf1.png"
+ frameCount: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "b"
+ source: "../images/realLeaf2.png"
+ frameCount: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "c"
+ source: "../images/realLeaf3.png"
+ frameCount: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "d"
+ source: "../images/realLeaf4.png"
+ frameCount: 1
+ frameDuration: 10000
+ }
+ ]
+
+ width: 100
+ height: 100
+ x: 20
+ y: 20
+ z:4
+ }
+}
diff --git a/examples/particles/affectors/friction.qml b/examples/particles/affectors/friction.qml
new file mode 100644
index 0000000000..b93ead1967
--- /dev/null
+++ b/examples/particles/affectors/friction.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ width: 360
+ height: 600
+
+ Image {
+ source: "../images/backgroundLeaves.jpg"
+ anchors.fill: parent
+ }
+ ParticleSystem { id: sys }
+ Emitter {
+ system: sys
+ width: parent.width
+ emitRate: 4
+ lifeSpan: 14000
+ size: 80
+ speed: PointDirection { y: 160; yVariation: 80; xVariation: 20 }
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ id: particles
+ system: sys
+ sprites: [Sprite {
+ source: "../images/realLeaf1.png"
+ frameCount: 1
+ frameDuration: 1
+ to: {"a":1, "b":1, "c":1, "d":1}
+ }, Sprite {
+ name: "a"
+ source: "../images/realLeaf1.png"
+ frameCount: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "b"
+ source: "../images/realLeaf2.png"
+ frameCount: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "c"
+ source: "../images/realLeaf3.png"
+ frameCount: 1
+ frameDuration: 10000
+ },
+ Sprite {
+ name: "d"
+ source: "../images/realLeaf4.png"
+ frameCount: 1
+ frameDuration: 10000
+ }
+ ]
+
+ width: 100
+ height: 100
+ x: 20
+ y: 20
+ z:4
+ }
+ Friction {
+ anchors.fill: parent
+ anchors.margins: -40
+ system: sys
+ factor: 0.4
+ }
+}
diff --git a/examples/particles/affectors/gravity.qml b/examples/particles/affectors/gravity.qml
new file mode 100644
index 0000000000..b90d83e1c8
--- /dev/null
+++ b/examples/particles/affectors/gravity.qml
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: window
+ width: 480; height: 480
+ Rectangle {
+ id: sky
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: "DeepSkyBlue"
+ }
+ GradientStop {
+ position: 1.0
+ color: "SkyBlue"
+ }
+ }
+ }
+
+ Rectangle {
+ id: ground
+ width: parent.width * 2
+ height: parent.height
+ y: parent.height/2
+ x: -parent.height/2
+ transformOrigin: Item.Top
+ rotation: 0
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen"; }
+ GradientStop { position: 1.0; color: "DarkGreen"; }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPositionChanged: {
+ var rot = Math.atan2(mouseY - window.height/2,mouseX - window.width/2) * 180/Math.PI;
+ ground.rotation = rot;
+ }
+ }
+
+ ParticleSystem { id: sys }
+ Gravity {
+ system: sys
+ magnitude: 32
+ angle: ground.rotation + 90
+ }
+ Emitter {
+ system: sys
+ anchors.centerIn: parent
+ emitRate: 1
+ lifeSpan: 10000
+ size: 64
+ }
+ ImageParticle {
+ anchors.fill: parent
+ system: sys
+ source: "../images/realLeaf1.png"
+ }
+
+}
diff --git a/examples/particles/affectors/groupgoal.qml b/examples/particles/affectors/groupgoal.qml
new file mode 100644
index 0000000000..273ec1a30c
--- /dev/null
+++ b/examples/particles/affectors/groupgoal.qml
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+
+Rectangle {
+ id: root
+ width: 360
+ height: 600
+ color: "black"
+
+ property int score: 0
+ Text {
+ color: "white"
+ anchors.right: parent.right
+ text: score
+ }
+
+ ParticleSystem {
+ id: particles
+ anchors.fill: parent
+ ParticleGroup {
+ name: "unlit"
+ duration: 1000
+ to: {"lighting":1, "unlit":99}
+ ImageParticle {
+ source: "../images/particleA.png"
+ colorVariation: 0.1
+ color: "#2060160f"
+ }
+ GroupGoal {
+ whenCollidingWith: ["lit"]
+ goalState: "lighting"
+ jump: true
+ }
+ }
+ ParticleGroup {
+ name: "lighting"
+ duration: 100
+ to: {"lit":1}
+ }
+ ParticleGroup {
+ name: "lit"
+ duration: 10000
+ onEntered: score++;
+ TrailEmitter {
+ id: fireballFlame
+ group: "flame"
+
+ emitRatePerParticle: 48
+ lifeSpan: 200
+ emitWidth: 8
+ emitHeight: 8
+
+ size: 24
+ sizeVariation: 8
+ endSize: 4
+ }
+
+ TrailEmitter {
+ id: fireballSmoke
+ group: "smoke"
+
+ emitRatePerParticle: 120
+ lifeSpan: 2000
+ emitWidth: 16
+ emitHeight: 16
+
+ speed: PointDirection {yVariation: 16; xVariation: 16}
+ acceleration: PointDirection {y: -16}
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+ }
+
+ ImageParticle {
+ id: smoke
+ anchors.fill: parent
+ groups: ["smoke"]
+ source: "../images/particle.png"
+ colorVariation: 0
+ color: "#00111111"
+ }
+ ImageParticle {
+ id: pilot
+ anchors.fill: parent
+ groups: ["pilot"]
+ source: "../images/particle.png"
+ redVariation: 0.01
+ blueVariation: 0.4
+ color: "#0010004f"
+ }
+ ImageParticle {
+ id: flame
+ anchors.fill: parent
+ groups: ["flame", "lit", "lighting"]
+ source: "../images/particleA.png"
+ colorVariation: 0.1
+ color: "#00ff400f"
+ }
+
+ Emitter {
+ height: parent.height/2
+ emitRate: 4
+ lifeSpan: 4000//TODO: Infinite & kill zone
+ size: 24
+ sizeVariation: 4
+ speed: PointDirection {x:120; xVariation: 80; yVariation: 50}
+ acceleration: PointDirection {y:120}
+ group: "unlit"
+ }
+
+ Emitter {
+ id: flamer
+ x: 100
+ y: 300
+ group: "pilot"
+ emitRate: 80
+ lifeSpan: 600
+ size: 24
+ sizeVariation: 2
+ endSize: 0
+ speed: PointDirection { y:-100; yVariation: 4; xVariation: 4 }
+ GroupGoal {
+ groups: ["unlit"]
+ goalState: "lit"
+ jump: true
+ system: particles
+ x: -15
+ y: -55
+ height: 75
+ width: 30
+ shape: MaskShape {source: "../images/matchmask.png"}
+ }
+ }
+ //Click to enflame
+ GroupGoal {
+ groups: ["unlit"]
+ goalState: "lighting"
+ jump: true
+ enabled: ma.pressed
+ width: 18
+ height: 18
+ x: ma.mouseX - width/2
+ y: ma.mouseY - height/2
+ }
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/examples/particles/affectors/move.qml b/examples/particles/affectors/move.qml
new file mode 100644
index 0000000000..f290173ca8
--- /dev/null
+++ b/examples/particles/affectors/move.qml
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ ParticleSystem {
+ anchors.fill: parent
+ ImageParticle {
+ groups: ["A"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ color:"#FF1010"
+ redVariation: 0.8
+ }
+
+ Emitter {
+ group: "A"
+ emitRate: 100
+ lifeSpan: 2800
+ size: 32
+ sizeVariation: 8
+ speed: PointDirection{ x: 66; xVariation: 20 }
+ width: 80
+ height: 80
+ }
+
+ Affector {
+ groups: ["A"]
+ x: 120
+ width: 80
+ height: 80
+ once: true
+ position: PointDirection { x: 120; }
+ }
+
+ ImageParticle {
+ groups: ["B"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ color:"#10FF10"
+ greenVariation: 0.8
+ }
+
+ Emitter {
+ group: "B"
+ emitRate: 100
+ lifeSpan: 2800
+ size: 32
+ sizeVariation: 8
+ speed: PointDirection{ x: 240; xVariation: 60 }
+ y: 260
+ width: 10
+ height: 10
+ }
+
+ Affector {
+ groups: ["B"]
+ x: 120
+ y: 240
+ width: 80
+ height: 80
+ once: true
+ speed: AngleDirection { angleVariation:360; magnitude: 72 }
+ }
+
+ ImageParticle {
+ groups: ["C"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ color:"#1010FF"
+ blueVariation: 0.8
+ }
+
+ Emitter {
+ group: "C"
+ y: 400
+ emitRate: 100
+ lifeSpan: 2800
+ size: 32
+ sizeVariation: 8
+ speed: PointDirection{ x: 80; xVariation: 10 }
+ acceleration: PointDirection { y: 10; x: 20; }
+ width: 80
+ height: 80
+ }
+
+ Affector {
+ groups: ["C"]
+ x: 120
+ y: 400
+ width: 80
+ height: 120
+ once: true
+ relative: false
+ acceleration: PointDirection { y: -80; }
+ }
+
+ }
+}
diff --git a/examples/particles/affectors/spritegoal.qml b/examples/particles/affectors/spritegoal.qml
new file mode 100644
index 0000000000..7102d09bc2
--- /dev/null
+++ b/examples/particles/affectors/spritegoal.qml
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: root
+ width: 360
+ height: 540
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ }
+
+ ParticleSystem { id: sys }
+ Image {
+ source: "../images/finalfrontier.png"
+ transformOrigin: Item.Center
+ anchors.centerIn: parent
+ smooth: true
+ NumberAnimation on rotation {
+ from: 0
+ to: 360
+ duration: 200000
+ loops: Animation.Infinite
+ }
+
+ }
+ ImageParticle {
+ system: sys
+ groups: ["starfield"]
+ source: "../images/star.png"
+ colorVariation: 0.3
+ color: "white"
+ }
+ Emitter {
+ id: starField
+ system: sys
+ group: "starfield"
+
+ emitRate: 80
+ lifeSpan: 2500
+
+ anchors.centerIn: parent
+
+ //acceleration: AngledDirection {angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed?
+ acceleration: PointDirection { xVariation: 200; yVariation: 200; }
+
+ size: 0
+ endSize: 80
+ sizeVariation: 10
+ }
+ Emitter {
+ system: sys
+ group: "meteor"
+ emitRate: 12
+ lifeSpan: 5000
+ acceleration: PointDirection { xVariation: 80; yVariation: 80; }
+ size: 15
+ endSize: 300
+ anchors.centerIn: parent
+ }
+ ImageParticle {
+ system: sys
+ groups: ["meteor"]
+ sprites:[Sprite {
+ id: spinState
+ name: "spinning"
+ source: "../images/meteor.png"
+ frameCount: 35
+ frameDuration: 40
+ randomStart: true
+ to: {"explode":0, "spinning":1}
+ },Sprite {
+ name: "explode"
+ source: "../images/_explo.png"
+ frameCount: 22
+ frameDuration: 40
+ to: {"nullFrame":1}
+ },Sprite {//Not sure if this is needed, but seemed easiest
+ name: "nullFrame"
+ source: "../images/nullRock.png"
+ frameCount: 1
+ frameDuration: 1000
+ }
+ ]
+ }
+ SpriteGoal {
+ groups: ["meteor"]
+ system: sys
+ goalState: "explode"
+ jump: true
+ anchors.centerIn: holder//A bug in affectors currently isn't compensating for relative x,y. when that's fixed this can just anchors.fill: rocketShip
+ width: 60
+ height: 60
+ }
+ Image {
+ id: rocketShip
+ source: "../images/rocket.png"
+ smooth: true
+ anchors.centerIn: holder
+ rotation: (circle.percent+0.25) * 360
+ z: 2
+ }
+ Item {
+ id: holder
+ x: circle.x - Math.sin(circle.percent * 6.28316530714)*200
+ y: circle.y + Math.cos(circle.percent * 6.28316530714)*200
+ z: 1
+ }
+
+ Item {
+ id: circle
+ x: root.width / 1.2
+ y: root.height / 1.7
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ id: circleAnim1
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ duration: 4000
+ from: 1
+ to: 0
+ }
+
+ }
+ }
+
+ ImageParticle {
+ z:0
+ system: sys
+ groups: ["exhaust"]
+ source: "../images/particle4.png"
+
+ color: "orange"
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "red"
+ to: "cyan"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "cyan"
+ to: "red"
+ duration: 1000
+ }
+ }
+
+ colorVariation: 0.2
+ }
+
+ Emitter {
+ id: trailsNormal2
+ system: sys
+ group: "exhaust"
+
+ emitRate: 300
+ lifeSpan: 500
+
+ y: holder.y
+ x: holder.x
+
+ speed: PointDirection { xVariation: 40; yVariation: 40; }
+ speedFromMovement: 16
+
+ acceleration: PointDirection { xVariation: 10; yVariation: 10; }
+
+ size: 4
+ sizeVariation: 4
+ }
+}
diff --git a/examples/particles/affectors/turbulence.qml b/examples/particles/affectors/turbulence.qml
new file mode 100644
index 0000000000..f3ad13431f
--- /dev/null
+++ b/examples/particles/affectors/turbulence.qml
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 600
+ color: "#222222"
+ id: root
+ Image {
+ source: "../images/candle.png"
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottomMargin: -8
+ anchors.horizontalCenterOffset: 2
+ }
+ ParticleSystem {
+ id: ps
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: turb.enabled = !turb.enabled
+ }
+
+ Turbulence {
+ id: turb
+ system: ps
+ enabled: true
+ height: (parent.height / 2)
+ width: parent.width / 2
+ x: parent. width / 4
+ anchors.fill: parent
+ strength: 32
+ }
+
+ ImageParticle {
+ groups: ["smoke"]
+ system: ps
+ source: "../images/particle.png"
+ color: "#11111111"
+ colorVariation: 0
+ }
+ ImageParticle {
+ groups: ["flame"]
+ system: ps
+ source: "../images/particle.png"
+ color: "#11ff400f"
+ colorVariation: 0.1
+ }
+ Emitter {
+ anchors.centerIn: parent
+ system: ps
+ group: "flame"
+
+ emitRate: 120
+ lifeSpan: 1200
+ size: 20
+ endSize: 10
+ sizeVariation: 10
+ acceleration: PointDirection { y: -40 }
+ speed: AngleDirection { angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
+ }
+ TrailEmitter {
+ id: smoke1
+ width: root.width
+ height: root.height/2 - 20
+ system: ps
+ group: "smoke"
+ follow: "flame"
+
+ emitRatePerParticle: 1
+ lifeSpan: 2400
+ lifeSpanVariation: 400
+ size: 16
+ endSize: 8
+ sizeVariation: 8
+ acceleration: PointDirection { y: -40 }
+ speed: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ }
+ TrailEmitter {
+ id: smoke2
+ width: root.width
+ height: root.height/2 - 40
+ system: ps
+ group: "smoke"
+ follow: "flame"
+
+ emitRatePerParticle: 4
+ lifeSpan: 2400
+ size: 36
+ endSize: 24
+ sizeVariation: 12
+ acceleration: PointDirection { y: -40 }
+ speed: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+ }
+}
diff --git a/examples/particles/affectors/wander.qml b/examples/particles/affectors/wander.qml
new file mode 100644
index 0000000000..ea008795c2
--- /dev/null
+++ b/examples/particles/affectors/wander.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "../exampleslauncher/content" as UI
+
+Rectangle {
+ width: 360
+ height: 540
+ ParticleSystem { id: particles }
+ ImageParticle {
+ system: particles
+ sprites: Sprite {
+ name: "snow"
+ source: "../images/snowflake.png"
+ frameCount: 51
+ frameDuration: 40
+ frameDurationVariation: 8
+ }
+ }
+
+ Wander {
+ id: wanderer
+ system: particles
+ anchors.fill: parent
+ xVariance: 360/(wanderer.affectedParameter+1);
+ pace: 100*(wanderer.affectedParameter+1);
+ }
+
+ Emitter {
+ system: particles
+ emitRate: 20
+ lifeSpan: 7000
+ speed: PointDirection { y:80; yVariation: 40; }
+ acceleration: PointDirection { y: 4 }
+ size: 20
+ sizeVariation: 10
+ width: parent.width
+ height: 100
+ }
+ Row {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ UI.Button {
+ text:"dx/dt"
+ onClicked: wanderer.affectedParameter = Wander.Position;
+ }
+ UI.Button {
+ text:"dv/dt"
+ onClicked: wanderer.affectedParameter = Wander.Velocity;
+ }
+ UI.Button {
+ text:"da/dt"
+ onClicked: wanderer.affectedParameter = Wander.Acceleration;
+ }
+ }
+}
diff --git a/examples/particles/customparticle/blurparticles.qml b/examples/particles/customparticle/blurparticles.qml
new file mode 100644
index 0000000000..3d72425655
--- /dev/null
+++ b/examples/particles/customparticle/blurparticles.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "white"
+ width: 240
+ height: 360
+ ParticleSystem {
+ id: sys
+ }
+ Emitter {
+ system:sys
+ height: parent.height
+ emitRate: 1
+ lifeSpan: 12000
+ speed: PointDirection {x:20;}
+ size: 128
+ }
+ ShaderEffectSource {
+ id: theSource
+ sourceItem: theItem
+ hideSource: true
+ }
+ Image {
+ id: theItem
+ source: "../images/starfish_1.png"
+ }
+
+ CustomParticle {
+ system: sys
+ vertexShader:"
+ uniform lowp float qt_Opacity;
+ varying lowp float fFade;
+ varying lowp float fBlur;
+
+ void main() {
+ defaultMain();
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
+ highp float fadeIn = min(t * 10., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * qt_Opacity;
+ fBlur = max(0.2 * t, t * qt_ParticleR);
+ }
+ "
+ property variant source: theSource
+ property variant blurred: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform sampler2D blurred;
+ varying highp vec2 qt_TexCoord0;
+ varying highp float fBlur;
+ varying highp float fFade;
+ void main() {
+ gl_FragColor = mix(texture2D(source, qt_TexCoord0), texture2D(blurred, qt_TexCoord0), min(1.0,fBlur*3.0)) * fFade;
+ }"
+
+ }
+}
+
diff --git a/examples/particles/customparticle/fragmentshader.qml b/examples/particles/customparticle/fragmentshader.qml
new file mode 100644
index 0000000000..34acb1bd7c
--- /dev/null
+++ b/examples/particles/customparticle/fragmentshader.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ id: root
+ width: 1024
+ height: 768
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color: "black"
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 36
+ color: "white"
+ text: "It's all in the fragment shader."
+ }
+ }
+
+ Emitter {
+ emitRate: 400
+ lifeSpan: 8000
+ size: 24
+ sizeVariation: 16
+ speed: PointDirection {x: root.width/10; y: root.height/10;}
+ //acceleration: AngledDirection {angle:225; magnitude: root.width/36; angleVariation: 45; magnitudeVariation: 80}
+ acceleration: PointDirection {x: -root.width/40; y: -root.height/40; xVariation: -root.width/20; yVariation: -root.width/20}
+ }
+
+ CustomParticle {
+ vertexShader:"
+ uniform lowp float qt_Opacity;
+ varying lowp float fFade;
+ varying highp vec2 fPos;
+
+ void main() {
+ qt_TexCoord0 = qt_ParticleTex;
+ highp float size = qt_ParticleData.z;
+ highp float endSize = qt_ParticleData.w;
+
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
+
+ highp float currentSize = mix(size, endSize, t * t);
+
+ if (t < 0. || t > 1.)
+ currentSize = 0.;
+
+ highp vec2 pos = qt_ParticlePos
+ - currentSize / 2. + currentSize * qt_ParticleTex // adjust size
+ + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..
+ + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);
+
+ gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
+
+ highp float fadeIn = min(t * 20., 1.);
+ highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+ fFade = fadeIn * fadeOut * qt_Opacity;
+ fPos = vec2(pos.x/1024., pos.y/768.);
+ }
+ "
+ fragmentShader: "
+ varying highp vec2 fPos;
+ varying lowp float fFade;
+ varying highp vec2 qt_TexCoord0;
+ void main() {//*2 because this generates dark colors mostly
+ highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0);
+ highp float dist = length(circlePos);
+ highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0);
+ gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade;
+ }"
+
+ }
+}
diff --git a/examples/particles/customparticle/imagecolors.qml b/examples/particles/customparticle/imagecolors.qml
new file mode 100644
index 0000000000..94e5123a0c
--- /dev/null
+++ b/examples/particles/customparticle/imagecolors.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: root
+ color: "white"
+ width: 310
+ height: 300
+ anchors.centerIn: parent
+ ParticleSystem { id: sys }
+ CustomParticle {
+ system: sys
+ property real maxWidth: root.width
+ property real maxHeight: root.height
+ ShaderEffectSource {
+ id: pictureSource
+ sourceItem: picture
+ hideSource: true
+ }
+ Image {
+ id: picture
+ source: "../images/starfish_3.png"
+ }
+ ShaderEffectSource {
+ id: particleSource
+ sourceItem: particle
+ hideSource: true
+ }
+ Image {
+ id: particle
+ source: "../images/particle4.png"
+ }
+ vertexShader:"
+ uniform highp float maxWidth;
+ uniform highp float maxHeight;
+ varying highp vec2 fTex2;
+ varying lowp float fFade;
+ uniform lowp float qt_Opacity;
+
+ void main() {
+ fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
+ fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity;
+ defaultMain();
+ }
+ "
+ property variant particleTexture: particleSource
+ property variant pictureTexture: pictureSource
+ fragmentShader: "
+ uniform sampler2D particleTexture;
+ uniform sampler2D pictureTexture;
+ varying highp vec2 qt_TexCoord0;
+ varying highp vec2 fTex2;
+ varying lowp float fFade;
+ void main() {
+ gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade;
+ }"
+ }
+
+ Emitter {
+ id: emitter
+ system: sys
+ enabled: false
+ lifeSpan: 8000
+ maximumEmitted: 4000
+ anchors.fill: parent
+ size: 16
+ acceleration: PointDirection { xVariation: 12; yVariation: 12 }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: emitter.burst(4000);
+ }
+ }
+}
diff --git a/examples/particles/emitters/burstandpulse.qml b/examples/particles/emitters/burstandpulse.qml
new file mode 100644
index 0000000000..1b1c2a60c9
--- /dev/null
+++ b/examples/particles/emitters/burstandpulse.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button == Qt.LeftButton)
+ emitter.burst(1000);
+ else
+ emitter.pulse(500);
+ }
+ }
+
+ ParticleSystem {
+ id: particles
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/star.png"
+ alpha: 0
+ colorVariation: 0.6
+ }
+
+ Emitter {
+ id: emitter
+ x: ma.mouseX
+ y: ma.mouseY
+ system: particles
+ emitRate: 2000
+ lifeSpan: 2000
+ enabled: false
+ speed: AngleDirection{magnitude: 64; angleVariation: 360}
+ size: 24
+ sizeVariation: 8
+ }
+}
diff --git a/examples/particles/emitters/customemitter.qml b/examples/particles/emitters/customemitter.qml
new file mode 100644
index 0000000000..757c836106
--- /dev/null
+++ b/examples/particles/emitters/customemitter.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ id: sys
+ width: 360
+ height: 600
+ running: true
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color: "black"
+ }
+
+ property real petalLength: 180
+ property real petalRotation: 0
+ NumberAnimation on petalRotation {
+ from: 0;
+ to: 360;
+ loops: -1;
+ running: true
+ duration: 24000
+ }
+
+ function convert(a) {return a*(Math.PI/180);}
+ Emitter {
+ lifeSpan: 4000
+ emitRate: 120
+ size: 12
+ anchors.centerIn: parent
+ onEmitParticles: {
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24));
+ var theta = Math.floor(Math.random() * 6.0) / 6.0;
+ theta *= 2.0*Math.PI;
+ theta += sys.convert(sys.petalRotation);
+ particle.initialVX = petalLength * Math.cos(theta);
+ particle.initialVY = petalLength * Math.sin(theta);
+ particle.initialAX = particle.initialVX * -0.5;
+ particle.initialAY = particle.initialVY * -0.5;
+ }
+ }
+ }
+
+ ImageParticle {
+ source: "../images/particle4.png"
+ alpha: 0.0
+ redVariation: 0.6
+ color: "white"
+ }
+}
diff --git a/examples/particles/emitters/emitmask.qml b/examples/particles/emitters/emitmask.qml
new file mode 100644
index 0000000000..9c02f6a213
--- /dev/null
+++ b/examples/particles/emitters/emitmask.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "goldenrod"
+ width: 400
+ height: 400
+ ParticleSystem {
+ width: 300
+ height: 300
+ anchors.centerIn: parent
+
+ ImageParticle {
+ source: "../images/particle.png"
+ z: 2
+ anchors.fill: parent
+ color: "#336666CC"
+ colorVariation: 0.0
+ }
+
+ Emitter {
+ anchors.fill: parent
+ emitRate: 6000
+ lifeSpan: 720
+ size: 10
+ shape: MaskShape {
+ source: "../images/starfish_mask.png"
+ }
+ }
+
+ }
+}
diff --git a/examples/particles/emitters/maximumemitted.qml b/examples/particles/emitters/maximumemitted.qml
new file mode 100644
index 0000000000..6dbdf8db61
--- /dev/null
+++ b/examples/particles/emitters/maximumemitted.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "black"
+ width: 360
+ height: 540
+ ParticleSystem {
+ id: sys
+ onEmptyChanged: if (empty) sys.pause();
+ }
+
+ ImageParticle {
+ system: sys
+ id: cp
+ source: "../images/particle.png"
+ colorVariation: 0.4
+ color: "#000000FF"
+ }
+
+ Emitter {
+ //burst on click
+ id: bursty
+ system: sys
+ enabled: ma.pressed
+ x: ma.mouseX
+ y: ma.mouseY
+ emitRate: 16000
+ maximumEmitted: 4000
+ acceleration: AngleDirection {angleVariation: 360; magnitude: 360; }
+ size: 8
+ endSize: 16
+ sizeVariation: 4
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: sys.resume()
+ id: ma
+ }
+}
diff --git a/examples/particles/emitters/shapeanddirection.qml b/examples/particles/emitters/shapeanddirection.qml
new file mode 100644
index 0000000000..43623427b6
--- /dev/null
+++ b/examples/particles/emitters/shapeanddirection.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+ Image {
+ anchors.fill: parent
+ source: "../images/portal_bg.png"
+ }
+
+ ParticleSystem {
+ id: particles
+ }
+
+ ImageParticle {
+ groups: ["center","edge"]
+ anchors.fill: parent
+ system: particles
+ source: "../images/particle.png"
+ colorVariation: 0.1
+ color: "#009999FF"
+ }
+
+ Emitter {
+ anchors.fill: parent
+ group: "center"
+ system: particles
+ emitRate: 400
+ lifeSpan: 2000
+ size: 20
+ sizeVariation: 2
+ endSize: 0
+ shape: EllipseShape {fill: false}
+ speed: TargetDirection {
+ targetX: root.width/2
+ targetY: root.height/2
+ proportionalMagnitude: true
+ magnitude: 0.5
+ }
+ }
+
+ Emitter {
+ anchors.fill: parent
+ group: "edge"
+ startTime: 2000
+ system: particles
+ emitRate: 2000
+ lifeSpan: 2000
+ size: 28
+ sizeVariation: 2
+ endSize: 16
+ shape: EllipseShape {fill: false}
+ speed: TargetDirection {
+ targetX: root.width/2
+ targetY: root.height/2
+ proportionalMagnitude: true
+ magnitude: 0.1
+ magnitudeVariation: 0.1
+ }
+ acceleration: TargetDirection {
+ targetX: root.width/2
+ targetY: root.height/2
+ targetVariation: 200
+ proportionalMagnitude: true
+ magnitude: 0.1
+ magnitudeVariation: 0.1
+ }
+ }
+}
diff --git a/examples/particles/emitters/timedgroupchanges.qml b/examples/particles/emitters/timedgroupchanges.qml
new file mode 100644
index 0000000000..699e7eb066
--- /dev/null
+++ b/examples/particles/emitters/timedgroupchanges.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 600
+ color: "black"
+ ParticleSystem {
+ anchors.fill: parent
+ id: syssy
+ ParticleGroup {
+ name: "fire"
+ duration: 2000
+ durationVariation: 2000
+ to: {"splode":1}
+ }
+ ParticleGroup {
+ name: "splode"
+ duration: 400
+ to: {"dead":1}
+ TrailEmitter {
+ group: "works"
+ emitRatePerParticle: 100
+ lifeSpan: 1000
+ maximumEmitted: 1200
+ size: 8
+ speed: AngleDirection {angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;}
+ acceleration: PointDirection {y:100; yVariation: 20}
+ }
+ }
+ ParticleGroup {
+ name: "dead"
+ duration: 1000
+ Affector {
+ once: true
+ onAffected: worksEmitter.burst(400,x,y)
+ }
+ }
+
+ Timer {
+ interval: 6000
+ running: true
+ triggeredOnStart: true
+ repeat: true
+ onTriggered:startingEmitter.pulse(100);
+ }
+ Emitter {
+ id: startingEmitter
+ group: "fire"
+ width: parent.width
+ y: parent.height
+ enabled: false
+ emitRate: 80
+ lifeSpan: 6000
+ speed: PointDirection {y:-100;}
+ size: 32
+ }
+
+ Emitter {
+ id: worksEmitter
+ group: "works"
+ enabled: false
+ emitRate: 100
+ lifeSpan: 1600
+ maximumEmitted: 6400
+ size: 8
+ speed: CumulativeDirection {
+ PointDirection {y:-100}
+ AngleDirection {angleVariation: 360; magnitudeVariation: 80;}
+ }
+ acceleration: PointDirection {y:100; yVariation: 20}
+ }
+
+ ImageParticle {
+ groups: ["works", "fire", "splode"]
+ source: "../images/particle.png"
+ entryEffect: ImageParticle.Scale
+ }
+ }
+}
+
diff --git a/examples/particles/emitters/trailemitter.qml b/examples/particles/emitters/trailemitter.qml
new file mode 100644
index 0000000000..e896329ca1
--- /dev/null
+++ b/examples/particles/emitters/trailemitter.qml
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+
+ ParticleSystem {
+ id: particles
+ }
+
+ ImageParticle {
+ id: smoke
+ system: particles
+ anchors.fill: parent
+ groups: ["A", "B"]
+ source: "../images/particle.png"
+ colorVariation: 0
+ color: "#00111111"
+ }
+ ImageParticle {
+ id: flame
+ anchors.fill: parent
+ system: particles
+ groups: ["C", "D"]
+ source: "../images/particle.png"
+ colorVariation: 0.1
+ color: "#00ff400f"
+ }
+
+ Emitter {
+ id: fire
+ system: particles
+ group: "C"
+
+ y: parent.height
+ width: parent.width
+
+ emitRate: 350
+ lifeSpan: 3500
+
+ acceleration: PointDirection { y: -17; xVariation: 3 }
+ speed: PointDirection {xVariation: 3}
+
+ size: 24
+ sizeVariation: 8
+ endSize: 4
+ }
+
+ TrailEmitter {
+ id: fireSmoke
+ group: "B"
+ system: particles
+ follow: "C"
+ width: root.width
+ height: root.height - 68
+
+ emitRatePerParticle: 1
+ lifeSpan: 2000
+
+ speed: PointDirection {y:-17*6; yVariation: -17; xVariation: 3}
+ acceleration: PointDirection {xVariation: 3}
+
+ size: 36
+ sizeVariation: 8
+ endSize: 16
+ }
+
+ TrailEmitter {
+ id: fireballFlame
+ anchors.fill: parent
+ system: particles
+ group: "D"
+ follow: "E"
+
+ emitRatePerParticle: 120
+ lifeSpan: 180
+ emitWidth: TrailEmitter.ParticleSize
+ emitHeight: TrailEmitter.ParticleSize
+ emitShape: EllipseShape{}
+
+ size: 16
+ sizeVariation: 4
+ endSize: 4
+ }
+
+ TrailEmitter {
+ id: fireballSmoke
+ anchors.fill: parent
+ system: particles
+ group: "A"
+ follow: "E"
+
+ emitRatePerParticle: 128
+ lifeSpan: 2400
+ emitWidth: TrailEmitter.ParticleSize
+ emitHeight: TrailEmitter.ParticleSize
+ emitShape: EllipseShape{}
+
+ speed: PointDirection {yVariation: 16; xVariation: 16}
+ acceleration: PointDirection {y: -16}
+
+ size: 24
+ sizeVariation: 8
+ endSize: 8
+ }
+
+ Emitter {
+ id: balls
+ system: particles
+ group: "E"
+
+ y: parent.height
+ width: parent.width
+
+ emitRate: 2
+ lifeSpan: 7000
+
+ speed: PointDirection {y:-17*4*2; xVariation: 6*6}
+ acceleration: PointDirection {y: 17*2; xVariation: 6*6}
+
+ size: 8
+ sizeVariation: 4
+ }
+
+ Turbulence { //A bit of turbulence makes the smoke look better
+ anchors.fill: parent
+ groups: ["A","B"]
+ strength: 32
+ system: particles
+ }
+}
+
diff --git a/examples/particles/emitters/velocityfrommotion.qml b/examples/particles/emitters/velocityfrommotion.qml
new file mode 100644
index 0000000000..7ad2b4d6c4
--- /dev/null
+++ b/examples/particles/emitters/velocityfrommotion.qml
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+
+ id: root
+
+ height: 540
+ width: 360
+
+ gradient: Gradient {
+ GradientStop { position: 0; color: "#000020" }
+ GradientStop { position: 1; color: "#000000" }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: root
+ }
+
+ ParticleSystem { id: sys1 }
+ ImageParticle {
+ system: sys1
+ source: "../images/particle.png"
+ color: "cyan"
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "cyan"
+ to: "magenta"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "magenta"
+ to: "blue"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "blue"
+ to: "violet"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "violet"
+ to: "cyan"
+ duration: 2000
+ }
+ }
+ colorVariation: 0.3
+ }
+ Emitter {
+ id: trailsNormal
+ system: sys1
+
+ emitRate: 500
+ lifeSpan: 2000
+
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
+
+ speed: PointDirection {xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+ speedFromMovement: 8
+
+ size: 8
+ sizeVariation: 4
+ }
+ ParticleSystem { id: sys2 }
+ ImageParticle {
+ color: "cyan"
+ system: sys2
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "magenta"
+ to: "cyan"
+ duration: 1000
+ }
+ ColorAnimation {
+ from: "cyan"
+ to: "magenta"
+ duration: 2000
+ }
+ }
+ colorVariation: 0.5
+ source: "../images/star.png"
+ }
+ Emitter {
+ id: trailsStars
+ system: sys2
+
+ emitRate: 100
+ lifeSpan: 2200
+
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
+
+ speed: PointDirection {xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+ speedFromMovement: 8
+
+ size: 22
+ sizeVariation: 4
+ }
+ ParticleSystem { id: sys3; }
+ ImageParticle {
+ source: "../images/particle.png"
+ system: sys3
+ color: "orange"
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "red"
+ to: "green"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "green"
+ to: "red"
+ duration: 2000
+ }
+ }
+
+ colorVariation: 0.2
+
+ }
+ Emitter {
+ id: trailsNormal2
+ system: sys3
+
+ emitRate: 300
+ lifeSpan: 2000
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx
+
+ speedFromMovement: 16
+
+ speed: PointDirection {xVariation: 4; yVariation: 4;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+
+ size: 12
+ sizeVariation: 4
+ }
+ ParticleSystem { id: sys4; }
+ ImageParticle {
+ system: sys4
+ source: "../images/star.png"
+ color: "green"
+ alpha: 0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation {
+ from: "green"
+ to: "red"
+ duration: 2000
+ }
+ ColorAnimation {
+ from: "red"
+ to: "green"
+ duration: 2000
+ }
+ }
+
+ colorVariation: 0.5
+ }
+ Emitter {
+ id: trailsStars2
+ system: sys4
+
+ emitRate: 50
+ lifeSpan: 2200
+
+
+ y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy
+ x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx
+
+ speedFromMovement: 16
+ speed: PointDirection {xVariation: 2; yVariation: 2;}
+ acceleration: PointDirection {xVariation: 10; yVariation: 10;}
+
+ size: 22
+ sizeVariation: 4
+ }
+
+
+
+ color: "white"
+
+ Item {
+ id: circle
+ //anchors.fill: parent
+ property real radius: 0
+ property real dx: root.width / 2
+ property real dy: root.height / 2
+ property real cx: radius * Math.sin(percent*6.283185307179) + dx
+ property real cy: radius * Math.cos(percent*6.283185307179) + dy
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ duration: 1000
+ from: 1
+ to: 0
+ loops: 8
+ }
+ NumberAnimation {
+ duration: 1000
+ from: 0
+ to: 1
+ loops: 8
+ }
+
+ }
+
+ SequentialAnimation on radius {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ duration: 4000
+ from: 0
+ to: 100
+ }
+ NumberAnimation {
+ duration: 4000
+ from: 100
+ to: 0
+ }
+ }
+ }
+
+ Item {
+ id: circle3
+ property real radius: 100
+ property real dx: root.width / 2
+ property real dy: root.height / 2
+ property real cx: radius * Math.sin(percent*6.283185307179) + dx
+ property real cy: radius * Math.cos(percent*6.283185307179) + dy
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation { from: 0.0; to: 1 ; duration: 10000; }
+ }
+ }
+
+ Item {
+ id: circle2
+ property real radius: 30
+ property real dx: circle3.cx
+ property real dy: circle3.cy
+ property real cx: radius * Math.sin(percent*6.283185307179) + dx
+ property real cy: radius * Math.cos(percent*6.283185307179) + dy
+ property real percent: 0
+
+ SequentialAnimation on percent {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation { from: 0.0; to: 1 ; duration: 1000; }
+ }
+ }
+
+}
diff --git a/examples/particles/exampleslauncher/content/Button.qml b/examples/particles/exampleslauncher/content/Button.qml
new file mode 100644
index 0000000000..e51a9be003
--- /dev/null
+++ b/examples/particles/exampleslauncher/content/Button.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 20
+ smooth: true
+ property color myCol: "#999999"
+ border { width: 1; color: Qt.darker(myCol) }
+ radius: 8
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return Qt.darker(myCol)
+ else
+ return Qt.lighter(myCol)
+ }
+ }
+ GradientStop { position: 1.0; color: myCol }
+ }
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: "black"; font.pixelSize: 24
+ }
+}
diff --git a/examples/particles/exampleslauncher/content/Shell.qml b/examples/particles/exampleslauncher/content/Shell.qml
new file mode 100644
index 0000000000..afab77485f
--- /dev/null
+++ b/examples/particles/exampleslauncher/content/Shell.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Loader {
+ id: ldr
+ visible: false
+ focus: visible
+ onVisibleChanged: source = ""
+ opacity: visible?1:0
+ Behavior on opacity {NumberAnimation {}}
+
+ function setDemo(str) {
+ visible = true;
+ source = str;
+ }
+ Image {//TODO: Augment with PARTICLES
+ z: 1
+ source: "../../images/launcherIcons/close.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: ldr.visible = false;
+ }
+ }
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color:"black"
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: ldr.Status == Loader.Error ? "Error :(" : "Loading..."
+ }
+ MouseArea {
+ id: graball
+ anchors.fill: parent
+ onClicked:;
+ }
+ }
+}
diff --git a/examples/particles/exampleslauncher/content/launcher.js b/examples/particles/exampleslauncher/content/launcher.js
new file mode 100644
index 0000000000..a296dbd6a6
--- /dev/null
+++ b/examples/particles/exampleslauncher/content/launcher.js
@@ -0,0 +1,8 @@
+function nameFromPath(path){
+ var ret = path.split('/');
+ return ret[ret.length-1].split('.')[0];
+}
+function iconFromPath(path){
+ var ret = path.split('/');
+ return "../images/launcherIcons/" + ret[ret.length-1].split('.')[0] + ".png";
+}
diff --git a/examples/particles/exampleslauncher/exampleslauncher.qml b/examples/particles/exampleslauncher/exampleslauncher.qml
new file mode 100644
index 0000000000..22914343ba
--- /dev/null
+++ b/examples/particles/exampleslauncher/exampleslauncher.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/launcher.js" as Util
+import "content"
+
+Rectangle {
+ color: "black"
+ width: 360
+ height: 600
+ Shell {
+ z: 1
+ id: shell
+ anchors.fill: parent
+ }
+
+ VisualDataModel {//TODO: Transitions between modes (and a second mode...)
+ id: vdm
+ model: [
+ "../../affectors/attractor.qml",
+ "../../affectors/customaffector.qml",
+ "../../affectors/groupgoal.qml",
+ "../../affectors/spritegoal.qml",
+ "../../affectors/turbulence.qml",
+ "../../affectors/wander.qml",
+ "../../customparticle/blurparticles.qml",
+ "../../customparticle/fragmentshader.qml",
+ "../../customparticle/imagecolors.qml",
+ "../../emitters/customemitter.qml",
+ "../../emitters/emitmask.qml",
+ "../../emitters/maximumemitted.qml",
+ "../../emitters/shapeanddirection.qml",
+ "../../emitters/timedgroupchanges.qml",
+ "../../emitters/trailemitter.qml",
+ "../../emitters/velocityfrommotion.qml",
+ "../../imageparticle/allatonce.qml",
+ "../../imageparticle/colortable.qml",
+ "../../imageparticle/deformation.qml",
+ "../../imageparticle/rotation.qml",
+ "../../imageparticle/sprites.qml",
+ "../../itemparticle/delegates.qml",
+ "../../itemparticle/particleview.qml",
+ "../../simple/dynamicemitters.qml",
+ "../../simple/multiplepainters.qml",
+ "../../simple/startstop.qml",
+ "../../plasmapatrol/plasmapatrol.qml"
+ ]
+ delegate: Rectangle {
+ color: "white"
+ width: 96
+ height: 96
+ Image {
+ width: 72
+ height: 72
+ anchors.centerIn: parent
+ source: Util.iconFromPath(modelData)
+ }
+ Text {
+ text: Util.nameFromPath(modelData)
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 8
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: shell.setDemo(modelData)
+ }
+ }
+ }
+
+ GridView {
+ anchors.fill: parent
+ cellWidth: 120
+ cellHeight: 120
+ model: vdm
+ }
+}
diff --git a/examples/particles/imageparticle/allatonce.qml b/examples/particles/imageparticle/allatonce.qml
new file mode 100644
index 0000000000..b62735d7f9
--- /dev/null
+++ b/examples/particles/imageparticle/allatonce.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "white"
+ width: 640
+ height: 480
+ ParticleSystem {
+ id: sys
+ }
+
+ ImageParticle {
+ sprites: [
+ Sprite {
+ name: "bear"
+ source: "../images/bear_tiles.png"
+ frameCount: 13
+ frameDuration: 120
+ }
+ ]
+ colorVariation: 0.5
+ rotationSpeedVariation: 360
+ system: sys
+ colorTable: "../trails/../images/colortable.png"
+ }
+
+ Friction {
+ factor: 0.1
+ system: sys
+ }
+
+ Emitter {
+ system: sys
+ anchors.centerIn: parent
+ id: particles
+ emitRate: 200
+ lifeSpan: 6000
+ speed: AngleDirection {angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
+ size: 60
+ endSize: 120
+ }
+
+ Text {
+ x: 16
+ y: 16
+ text: "QML..."
+ style: Text.Outline; styleColor: "#AAAAAA"
+ font.pixelSize: 32
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.margins: 16
+ text: "... can you be trusted with the power?"
+ style: Text.Outline; styleColor: "#AAAAAA"
+ font.pixelSize: width > 400 ? 32 : 16
+ }
+}
diff --git a/examples/particles/imageparticle/colored.qml b/examples/particles/imageparticle/colored.qml
new file mode 100644
index 0000000000..ac760b6219
--- /dev/null
+++ b/examples/particles/imageparticle/colored.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ ParticleSystem {
+ anchors.fill: parent
+ ImageParticle {
+ groups: ["stars"]
+ anchors.fill: parent
+ source: "../images/star.png"
+ }
+ Emitter {
+ group: "stars"
+ emitRate: 800
+ lifeSpan: 2400
+ size: 24
+ sizeVariation: 8
+ anchors.fill: parent
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ source: "../images/star.png"
+ alpha: 0
+ alphaVariation: 0.2
+ colorVariation: 1.0
+ }
+
+ Emitter {
+ anchors.centerIn: parent
+ emitRate: 400
+ lifeSpan: 2400
+ size: 48
+ sizeVariation: 8
+ speed: AngleDirection {angleVariation: 180; magnitude: 60}
+ }
+
+ Turbulence {
+ anchors.fill: parent
+ strength: 2
+ }
+ }
+}
diff --git a/examples/particles/imageparticle/colortable.qml b/examples/particles/imageparticle/colortable.qml
new file mode 100644
index 0000000000..623029dae0
--- /dev/null
+++ b/examples/particles/imageparticle/colortable.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick.Particles 2.0
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 540
+ color: "black"
+
+ ParticleSystem { id: particles }
+
+ ImageParticle {
+ system: particles
+ colorVariation: 0.5
+ alpha: 0
+
+ source: "../images/particle.png"
+ colorTable: "../images/colortable.png"
+ sizeTable: "../images/colortable.png"
+ }
+
+ Emitter {
+ system: particles
+ emitRate: 500
+ lifeSpan: 2000
+
+ y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3
+ x: root.width / 2 + Math.cos(t) * root.width * 0.3
+ property real t;
+
+ NumberAnimation on t {
+ from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite
+ }
+
+ speedFromMovement: 20
+
+ speed: PointDirection { xVariation: 5; yVariation: 5;}
+ acceleration: PointDirection { xVariation: 5; yVariation: 5;}
+
+ size: 16
+ //endSize: 8
+ //sizeVariation: 8
+ }
+}
diff --git a/examples/particles/imageparticle/deformation.qml b/examples/particles/imageparticle/deformation.qml
new file mode 100644
index 0000000000..e282927e78
--- /dev/null
+++ b/examples/particles/imageparticle/deformation.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "goldenrod"
+ width: 400
+ height: 400
+ ParticleSystem {id:sys}
+
+ ImageParticle {
+ system: sys
+ groups: ["goingLeft", "goingRight"]
+ source: "../images/starfish_4.png"
+ rotation: 90
+ rotationSpeed: 90
+ autoRotation: true
+ }
+ ImageParticle {
+ system: sys
+ groups: ["goingDown"]
+ source: "../images/starfish_0.png"
+ rotation: 180
+ yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; }
+ }
+
+ Timer {
+ running: true
+ repeat: false
+ interval: 100
+ onTriggered: emitA.enabled = true;
+ }
+ Timer {
+ running: true
+ repeat: false
+ interval: 4200
+ onTriggered: emitB.enabled = true;
+ }
+ Timer {
+ running: true
+ repeat: false
+ interval: 8400
+ onTriggered: emitC.enabled = true;
+ }
+
+ Emitter {
+ id: emitA
+ x: 0
+ y: 120
+ system: sys
+ enabled: false
+ group: "goingRight"
+ speed: PointDirection { x: 100 }
+ lifeSpan: 4000
+ emitRate: 1
+ size: 128
+ }
+ Emitter {
+ id: emitB
+ x: 400
+ y: 240
+ system: sys
+ enabled: false
+ group: "goingLeft"
+ speed: PointDirection { x: -100 }
+ lifeSpan: 4000
+ emitRate: 1
+ size: 128
+ }
+ Emitter {
+ id: emitC
+ x: 0
+ y: 360
+ system: sys
+ enabled: false
+ group: "goingDown"
+ speed: PointDirection { x: 100 }
+ lifeSpan: 4000
+ emitRate: 1
+ size: 128
+ }
+}
diff --git a/examples/particles/imageparticle/rotation.qml b/examples/particles/imageparticle/rotation.qml
new file mode 100644
index 0000000000..3a75c379ed
--- /dev/null
+++ b/examples/particles/imageparticle/rotation.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "goldenrod"
+ width: 2000
+ height: 2000
+ ParticleSystem {id: sys}
+ ImageParticle {
+ id: up
+ system: sys
+ source: "../images/starfish_2.png"
+ }
+
+ Emitter {
+ anchors.centerIn: parent
+ system: sys
+ emitRate: 10
+ size: 200
+ lifeSpan: 10000
+ speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;}
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ up.autoRotation = !up.autoRotation
+ up.rotation = up.autoRotation ? -90 : 0
+ }
+ }
+}
diff --git a/examples/particles/imageparticle/sharing.qml b/examples/particles/imageparticle/sharing.qml
new file mode 100644
index 0000000000..27e08322d9
--- /dev/null
+++ b/examples/particles/imageparticle/sharing.qml
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example shows how to create your own highlight delegate for a ListView
+// that uses a SpringAnimation to provide custom movement when the
+// highlight bar is moved between items.
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ property real delegateHeight: 65
+ width: 200; height: 300
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#EEEEFF" }
+ GradientStop { position: 1.0; color: "lightblue" }
+ }
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+ Component {
+ id: petDelegate
+ Item {
+ id: wrapper
+ width: 200; height: delegateHeight
+ z: 10
+ Column {
+ Text {color: "white"; text: name; font.pixelSize: 18 }
+ Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 }
+ Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 }
+ }
+ // indent the item if it is the current item
+ states: State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 20 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 200 }
+ }
+ }
+ }
+
+ // Define a highlight with customised movement between items.
+ Component {
+ id: highlightBar
+ Rectangle {
+ z: 0
+ width: 200; height: delegateHeight
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#99FF99" }
+ GradientStop { position: 1.0; color: "#88FF88" }
+ }
+ y: listView.currentItem.y;
+ Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/flower.png"
+ color: "red"
+ clip: true
+ alpha: 1.0
+ }
+ }
+ }
+
+ ListView {
+ id: listView
+ width: 200; height: parent.height
+
+ model: petsModel
+ delegate: petDelegate
+ focus: true
+
+ // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem
+ // to false so the highlight delegate can control how the highlight is moved.
+ highlight: highlightBar
+ highlightFollowsCurrentItem: false
+
+ ParticleSystem { id: particles }
+ Emitter {
+ system: particles
+ anchors.fill: parent
+ emitRate: 1
+ lifeSpan: 10000
+ size: 24
+ sizeVariation: 8
+ speed: AngleDirection { angleVariation: 360; magnitude: 3 }
+ maximumEmitted: 10
+ startTime: 5000
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/flower.png"
+ alpha: 0.1
+ color: "white"
+ rotationVariation: 180
+ z: -1
+ }
+ }
+
+ ListModel {
+ id: petsModel
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+ }
+
+}
diff --git a/examples/particles/imageparticle/sprites.qml b/examples/particles/imageparticle/sprites.qml
new file mode 100644
index 0000000000..45ff2ebbaf
--- /dev/null
+++ b/examples/particles/imageparticle/sprites.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ color: "lightsteelblue"
+ width: 800
+ height: 800
+ id: root
+
+ SpriteSequence {
+ sprites: Sprite {
+ name: "bear"
+ source: "../images/bear_tiles.png"
+ frameCount: 13
+ frameDuration: 120
+ }
+ width: 250
+ height: 250
+ x: 20
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 20
+ z:4
+ }
+
+ ParticleSystem { id: sys }
+
+ ImageParticle {
+ anchors.fill: parent
+ id: particles
+ system: sys
+ sprites: [Sprite {
+ name: "happy"
+ source: "../images/starfish_1.png"
+ frameCount: 1
+ frameDuration: 260
+ to: {"happy": 1, "silly": 1, "angry": 1}
+ }, Sprite {
+ name: "angry"
+ source: "../images/starfish_0.png"
+ frameCount: 1
+ frameDuration: 260
+ to: {"happy": 1, "silly": 1, "angry": 1}
+ }, Sprite {
+ name: "silly"
+ source: "../images/starfish_2.png"
+ frameCount: 1
+ frameDuration: 260
+ to: {"happy": 1, "silly": 1, "noticedbear": 0}
+ }, Sprite {
+ name: "noticedbear"
+ source: "../images/starfish_3.png"
+ frameCount: 1
+ frameDuration: 2600
+ }]
+ }
+
+ Emitter {
+ system: sys
+ emitRate: 2
+ lifeSpan: 10000
+ speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5}
+ acceleration: PointDirection { y: 10 }
+ size: 160
+ sizeVariation: 40
+ width: parent.width
+ height: 100
+ }
+
+ SpriteGoal {
+ system: sys
+ width: root.width;
+ height: root.height/2;
+ y: root.height/2;
+ goalState:"noticedbear"
+ }
+}
diff --git a/examples/particles/images/_explo.png b/examples/particles/images/_explo.png
new file mode 100644
index 0000000000..4297245d49
--- /dev/null
+++ b/examples/particles/images/_explo.png
Binary files differ
diff --git a/examples/particles/images/backgroundLeaves.jpg b/examples/particles/images/backgroundLeaves.jpg
new file mode 100755
index 0000000000..08be16751d
--- /dev/null
+++ b/examples/particles/images/backgroundLeaves.jpg
Binary files differ
diff --git a/examples/particles/images/bear_tiles.png b/examples/particles/images/bear_tiles.png
new file mode 100644
index 0000000000..6bbb2a9b6d
--- /dev/null
+++ b/examples/particles/images/bear_tiles.png
Binary files differ
diff --git a/examples/particles/images/candle.png b/examples/particles/images/candle.png
new file mode 100644
index 0000000000..8fa3193719
--- /dev/null
+++ b/examples/particles/images/candle.png
Binary files differ
diff --git a/examples/particles/images/colortable.png b/examples/particles/images/colortable.png
new file mode 100644
index 0000000000..a62ceeb4a0
--- /dev/null
+++ b/examples/particles/images/colortable.png
Binary files differ
diff --git a/examples/particles/images/finalfrontier.png b/examples/particles/images/finalfrontier.png
new file mode 100644
index 0000000000..2ba1815230
--- /dev/null
+++ b/examples/particles/images/finalfrontier.png
Binary files differ
diff --git a/examples/particles/images/flower.png b/examples/particles/images/flower.png
new file mode 100644
index 0000000000..b5c606210e
--- /dev/null
+++ b/examples/particles/images/flower.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/allatonce.png b/examples/particles/images/launcherIcons/allatonce.png
new file mode 100644
index 0000000000..b61d2d50d8
--- /dev/null
+++ b/examples/particles/images/launcherIcons/allatonce.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/attractor.png b/examples/particles/images/launcherIcons/attractor.png
new file mode 100644
index 0000000000..4bd8040c3b
--- /dev/null
+++ b/examples/particles/images/launcherIcons/attractor.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/blurparticles.png b/examples/particles/images/launcherIcons/blurparticles.png
new file mode 100644
index 0000000000..4337f979cb
--- /dev/null
+++ b/examples/particles/images/launcherIcons/blurparticles.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/close.png b/examples/particles/images/launcherIcons/close.png
new file mode 100644
index 0000000000..c37714ee8f
--- /dev/null
+++ b/examples/particles/images/launcherIcons/close.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/colortable.png b/examples/particles/images/launcherIcons/colortable.png
new file mode 100644
index 0000000000..8841ea30f9
--- /dev/null
+++ b/examples/particles/images/launcherIcons/colortable.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/customaffector.png b/examples/particles/images/launcherIcons/customaffector.png
new file mode 100644
index 0000000000..d02e7918fa
--- /dev/null
+++ b/examples/particles/images/launcherIcons/customaffector.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/customemitter.png b/examples/particles/images/launcherIcons/customemitter.png
new file mode 100644
index 0000000000..6d492573d1
--- /dev/null
+++ b/examples/particles/images/launcherIcons/customemitter.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/deformation.png b/examples/particles/images/launcherIcons/deformation.png
new file mode 100644
index 0000000000..d1b722df01
--- /dev/null
+++ b/examples/particles/images/launcherIcons/deformation.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/delegates.png b/examples/particles/images/launcherIcons/delegates.png
new file mode 100644
index 0000000000..929414cd0e
--- /dev/null
+++ b/examples/particles/images/launcherIcons/delegates.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/dynamicemitters.png b/examples/particles/images/launcherIcons/dynamicemitters.png
new file mode 100644
index 0000000000..0cdef9d21e
--- /dev/null
+++ b/examples/particles/images/launcherIcons/dynamicemitters.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/emitmask.png b/examples/particles/images/launcherIcons/emitmask.png
new file mode 100644
index 0000000000..e943a4adb9
--- /dev/null
+++ b/examples/particles/images/launcherIcons/emitmask.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/flickr.png b/examples/particles/images/launcherIcons/flickr.png
new file mode 100644
index 0000000000..4de2650280
--- /dev/null
+++ b/examples/particles/images/launcherIcons/flickr.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/fragmentshader.png b/examples/particles/images/launcherIcons/fragmentshader.png
new file mode 100644
index 0000000000..7c6de498d5
--- /dev/null
+++ b/examples/particles/images/launcherIcons/fragmentshader.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/gridsplosion.png b/examples/particles/images/launcherIcons/gridsplosion.png
new file mode 100644
index 0000000000..ec75453df6
--- /dev/null
+++ b/examples/particles/images/launcherIcons/gridsplosion.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/groupgoal.png b/examples/particles/images/launcherIcons/groupgoal.png
new file mode 100644
index 0000000000..69c6f64e54
--- /dev/null
+++ b/examples/particles/images/launcherIcons/groupgoal.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/imagecolors.png b/examples/particles/images/launcherIcons/imagecolors.png
new file mode 100644
index 0000000000..0ff13a346e
--- /dev/null
+++ b/examples/particles/images/launcherIcons/imagecolors.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/list.png b/examples/particles/images/launcherIcons/list.png
new file mode 100644
index 0000000000..bc13263cff
--- /dev/null
+++ b/examples/particles/images/launcherIcons/list.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/maximumemitted.png b/examples/particles/images/launcherIcons/maximumemitted.png
new file mode 100644
index 0000000000..4ef0435991
--- /dev/null
+++ b/examples/particles/images/launcherIcons/maximumemitted.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/multiplepainters.png b/examples/particles/images/launcherIcons/multiplepainters.png
new file mode 100644
index 0000000000..a28e3c4f02
--- /dev/null
+++ b/examples/particles/images/launcherIcons/multiplepainters.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/package.png b/examples/particles/images/launcherIcons/package.png
new file mode 100644
index 0000000000..eba8951c26
--- /dev/null
+++ b/examples/particles/images/launcherIcons/package.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/particleview.png b/examples/particles/images/launcherIcons/particleview.png
new file mode 100644
index 0000000000..a74f9a0340
--- /dev/null
+++ b/examples/particles/images/launcherIcons/particleview.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/plasmapatrol.png b/examples/particles/images/launcherIcons/plasmapatrol.png
new file mode 100644
index 0000000000..fda852b420
--- /dev/null
+++ b/examples/particles/images/launcherIcons/plasmapatrol.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/remove.png b/examples/particles/images/launcherIcons/remove.png
new file mode 100644
index 0000000000..c37714ee8f
--- /dev/null
+++ b/examples/particles/images/launcherIcons/remove.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/rotation.png b/examples/particles/images/launcherIcons/rotation.png
new file mode 100644
index 0000000000..6a8dbea236
--- /dev/null
+++ b/examples/particles/images/launcherIcons/rotation.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/samegame.png b/examples/particles/images/launcherIcons/samegame.png
new file mode 100644
index 0000000000..d00698264b
--- /dev/null
+++ b/examples/particles/images/launcherIcons/samegame.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/shapeanddirection.png b/examples/particles/images/launcherIcons/shapeanddirection.png
new file mode 100644
index 0000000000..9c1f910d0c
--- /dev/null
+++ b/examples/particles/images/launcherIcons/shapeanddirection.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/spaceexplorer.png b/examples/particles/images/launcherIcons/spaceexplorer.png
new file mode 100644
index 0000000000..770584a0fa
--- /dev/null
+++ b/examples/particles/images/launcherIcons/spaceexplorer.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/spritegoal.png b/examples/particles/images/launcherIcons/spritegoal.png
new file mode 100644
index 0000000000..77480c6f09
--- /dev/null
+++ b/examples/particles/images/launcherIcons/spritegoal.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/sprites.png b/examples/particles/images/launcherIcons/sprites.png
new file mode 100644
index 0000000000..144216ac7c
--- /dev/null
+++ b/examples/particles/images/launcherIcons/sprites.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/spritevariedparticles.png b/examples/particles/images/launcherIcons/spritevariedparticles.png
new file mode 100644
index 0000000000..495bb6beee
--- /dev/null
+++ b/examples/particles/images/launcherIcons/spritevariedparticles.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/startstop.png b/examples/particles/images/launcherIcons/startstop.png
new file mode 100644
index 0000000000..0ff53196a6
--- /dev/null
+++ b/examples/particles/images/launcherIcons/startstop.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/timedgroupchanges.png b/examples/particles/images/launcherIcons/timedgroupchanges.png
new file mode 100644
index 0000000000..ec9f826495
--- /dev/null
+++ b/examples/particles/images/launcherIcons/timedgroupchanges.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/trailemitter.png b/examples/particles/images/launcherIcons/trailemitter.png
new file mode 100644
index 0000000000..39acf8b40d
--- /dev/null
+++ b/examples/particles/images/launcherIcons/trailemitter.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/trails.png b/examples/particles/images/launcherIcons/trails.png
new file mode 100644
index 0000000000..0337ebcfd8
--- /dev/null
+++ b/examples/particles/images/launcherIcons/trails.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/turbulence.png b/examples/particles/images/launcherIcons/turbulence.png
new file mode 100644
index 0000000000..2b9446ea90
--- /dev/null
+++ b/examples/particles/images/launcherIcons/turbulence.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/velocityfrommotion.png b/examples/particles/images/launcherIcons/velocityfrommotion.png
new file mode 100644
index 0000000000..79baa08293
--- /dev/null
+++ b/examples/particles/images/launcherIcons/velocityfrommotion.png
Binary files differ
diff --git a/examples/particles/images/launcherIcons/wander.png b/examples/particles/images/launcherIcons/wander.png
new file mode 100644
index 0000000000..d98e14b8ae
--- /dev/null
+++ b/examples/particles/images/launcherIcons/wander.png
Binary files differ
diff --git a/examples/particles/images/matchmask.png b/examples/particles/images/matchmask.png
new file mode 100644
index 0000000000..e575875c55
--- /dev/null
+++ b/examples/particles/images/matchmask.png
Binary files differ
diff --git a/examples/particles/images/meteor.png b/examples/particles/images/meteor.png
new file mode 100644
index 0000000000..e8c368aea7
--- /dev/null
+++ b/examples/particles/images/meteor.png
Binary files differ
diff --git a/examples/particles/images/meteor_explo.png b/examples/particles/images/meteor_explo.png
new file mode 100644
index 0000000000..e659bfe2cf
--- /dev/null
+++ b/examples/particles/images/meteor_explo.png
Binary files differ
diff --git a/examples/particles/images/meteors.png b/examples/particles/images/meteors.png
new file mode 100644
index 0000000000..bada8a1407
--- /dev/null
+++ b/examples/particles/images/meteors.png
Binary files differ
diff --git a/examples/particles/images/nullRock.png b/examples/particles/images/nullRock.png
new file mode 100644
index 0000000000..4076327a1a
--- /dev/null
+++ b/examples/particles/images/nullRock.png
Binary files differ
diff --git a/examples/particles/images/particle.png b/examples/particles/images/particle.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/particles/images/particle.png
Binary files differ
diff --git a/examples/particles/images/particle2.png b/examples/particles/images/particle2.png
new file mode 100644
index 0000000000..36349c6c6e
--- /dev/null
+++ b/examples/particles/images/particle2.png
Binary files differ
diff --git a/examples/particles/images/particle3.png b/examples/particles/images/particle3.png
new file mode 100644
index 0000000000..905d8f37b8
--- /dev/null
+++ b/examples/particles/images/particle3.png
Binary files differ
diff --git a/examples/particles/images/particle4.png b/examples/particles/images/particle4.png
new file mode 100644
index 0000000000..bc95b703c1
--- /dev/null
+++ b/examples/particles/images/particle4.png
Binary files differ
diff --git a/examples/particles/images/particleA.png b/examples/particles/images/particleA.png
new file mode 100644
index 0000000000..c63acdee1f
--- /dev/null
+++ b/examples/particles/images/particleA.png
Binary files differ
diff --git a/examples/particles/images/portal_bg.png b/examples/particles/images/portal_bg.png
new file mode 100644
index 0000000000..3c59eeabb9
--- /dev/null
+++ b/examples/particles/images/portal_bg.png
Binary files differ
diff --git a/examples/particles/images/realLeaf1.png b/examples/particles/images/realLeaf1.png
new file mode 100644
index 0000000000..6cabf29efd
--- /dev/null
+++ b/examples/particles/images/realLeaf1.png
Binary files differ
diff --git a/examples/particles/images/realLeaf2.png b/examples/particles/images/realLeaf2.png
new file mode 100644
index 0000000000..bfeca861d5
--- /dev/null
+++ b/examples/particles/images/realLeaf2.png
Binary files differ
diff --git a/examples/particles/images/realLeaf3.png b/examples/particles/images/realLeaf3.png
new file mode 100644
index 0000000000..b1071e862b
--- /dev/null
+++ b/examples/particles/images/realLeaf3.png
Binary files differ
diff --git a/examples/particles/images/realLeaf4.png b/examples/particles/images/realLeaf4.png
new file mode 100644
index 0000000000..d61d53d10e
--- /dev/null
+++ b/examples/particles/images/realLeaf4.png
Binary files differ
diff --git a/examples/particles/images/rocket.png b/examples/particles/images/rocket.png
new file mode 100644
index 0000000000..a171610b03
--- /dev/null
+++ b/examples/particles/images/rocket.png
Binary files differ
diff --git a/examples/particles/images/rocket2.png b/examples/particles/images/rocket2.png
new file mode 100644
index 0000000000..7110f8fdc6
--- /dev/null
+++ b/examples/particles/images/rocket2.png
Binary files differ
diff --git a/examples/particles/images/sizeInOut.png b/examples/particles/images/sizeInOut.png
new file mode 100644
index 0000000000..0a306ea21a
--- /dev/null
+++ b/examples/particles/images/sizeInOut.png
Binary files differ
diff --git a/examples/particles/images/snowflake.png b/examples/particles/images/snowflake.png
new file mode 100644
index 0000000000..490887a82f
--- /dev/null
+++ b/examples/particles/images/snowflake.png
Binary files differ
diff --git a/examples/particles/images/sparkleSize.png b/examples/particles/images/sparkleSize.png
new file mode 100644
index 0000000000..752056541b
--- /dev/null
+++ b/examples/particles/images/sparkleSize.png
Binary files differ
diff --git a/examples/particles/images/star.png b/examples/particles/images/star.png
new file mode 100644
index 0000000000..0d592cfa87
--- /dev/null
+++ b/examples/particles/images/star.png
Binary files differ
diff --git a/examples/particles/images/starfish_0.png b/examples/particles/images/starfish_0.png
new file mode 100644
index 0000000000..8747f0236e
--- /dev/null
+++ b/examples/particles/images/starfish_0.png
Binary files differ
diff --git a/examples/particles/images/starfish_1.png b/examples/particles/images/starfish_1.png
new file mode 100644
index 0000000000..1f3f159d5e
--- /dev/null
+++ b/examples/particles/images/starfish_1.png
Binary files differ
diff --git a/examples/particles/images/starfish_2.png b/examples/particles/images/starfish_2.png
new file mode 100644
index 0000000000..c6c7e5a676
--- /dev/null
+++ b/examples/particles/images/starfish_2.png
Binary files differ
diff --git a/examples/particles/images/starfish_3.png b/examples/particles/images/starfish_3.png
new file mode 100644
index 0000000000..307a89f815
--- /dev/null
+++ b/examples/particles/images/starfish_3.png
Binary files differ
diff --git a/examples/particles/images/starfish_4.png b/examples/particles/images/starfish_4.png
new file mode 100644
index 0000000000..d61c26545a
--- /dev/null
+++ b/examples/particles/images/starfish_4.png
Binary files differ
diff --git a/examples/particles/images/starfish_mask.png b/examples/particles/images/starfish_mask.png
new file mode 100644
index 0000000000..2ef74f902b
--- /dev/null
+++ b/examples/particles/images/starfish_mask.png
Binary files differ
diff --git a/examples/particles/itemparticle/content/Delegate.qml b/examples/particles/itemparticle/content/Delegate.qml
new file mode 100644
index 0000000000..97c7840cb4
--- /dev/null
+++ b/examples/particles/itemparticle/content/Delegate.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![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 }
+ MouseArea {
+ 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
+ x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/particles/itemparticle/content/Delegate2.qml b/examples/particles/itemparticle/content/Delegate2.qml
new file mode 100644
index 0000000000..cf60d43dc2
--- /dev/null
+++ b/examples/particles/itemparticle/content/Delegate2.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Package {
+ Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' }
+ Item { id: particleDelegate; width: w; height: h; Package.name: 'particles'
+
+ Rectangle {
+ id: wrapper
+ width: w; height: h;
+ color: col
+ rotation: Math.random()*360
+ Behavior on rotation {RotationAnimation {}}
+
+ states: State {
+ name: "gridded"
+ when: root.inGrid
+ PropertyChanges {
+ target: wrapper
+ rotation: 0
+ }
+ ParentChange {
+ target: wrapper
+ parent: gridDelegate
+ x:0
+ y:0
+ }
+ }
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+ }
+}
+//![0]
diff --git a/examples/particles/itemparticle/content/ExpandingDelegate.qml b/examples/particles/itemparticle/content/ExpandingDelegate.qml
new file mode 100644
index 0000000000..87f723d3f7
--- /dev/null
+++ b/examples/particles/itemparticle/content/ExpandingDelegate.qml
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../../modelviews/listview/content"
+
+// This example illustrates expanding a list item to show a more detailed view.
+
+ // Delegate for the recipes. This delegate has two modes:
+ // 1. List mode (default), which just shows the picture and title of the recipe.
+ // 2. Details mode, which also shows the ingredients and method.
+ Component {
+ id: recipeDelegate
+
+ Item {
+ id: recipe
+
+ // Create a property to contain the visibility of the details.
+ // We can bind multiple element's opacity to this one property,
+ // rather than having a "PropertyChanges" line for each element we
+ // want to fade.
+ property real detailsOpacity : 0
+
+ //this bit changed for aesthetics
+ width: 70
+ height: 70
+ // A simple rounded rectangle for the background
+ Rectangle {
+ id: background
+ x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
+ color: "ivory"
+ border.color: "orange"
+ radius: 5
+ }
+ Image {
+ anchors.fill:parent
+ anchors.margins: -32
+ source: "bubble.png"
+ }
+
+
+ // This mouse region covers the entire delegate.
+ // When clicked it changes mode to 'Details'. If we are already
+ // in Details mode, then no change will happen.
+ MouseArea {
+ anchors.fill: parent
+ onClicked: recipe.state = 'Details';
+ }
+
+ // Lay out the page: picture, title and ingredients at the top, and method at the
+ // bottom. Note that elements that should not be visible in the list
+ // mode have their opacity set to recipe.detailsOpacity.
+ Row {
+ id: topLayout
+ x: 10; y: 10; height: recipeImage.height; width: parent.width
+ spacing: 10
+
+ Image {
+ id: recipeImage
+ width: 50; height: 50
+ source: "../../modelviews/listview/" + picture
+ }
+
+ Column {
+ width: background.width - recipeImage.width - 20; height: recipeImage.height
+ spacing: 5
+
+ Text {
+ text: title
+ font.bold: true; font.pointSize: 16
+ }
+
+ Text {
+ text: "Ingredients"
+ font.pointSize: 12; font.bold: true
+ opacity: recipe.detailsOpacity
+ }
+
+ Text {
+ text: ingredients
+ wrapMode: Text.WordWrap
+ width: parent.width
+ opacity: recipe.detailsOpacity
+ }
+ }
+ }
+
+ Item {
+ id: details
+ x: 10; width: parent.width - 20
+ anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
+ opacity: recipe.detailsOpacity
+
+ Text {
+ id: methodTitle
+ anchors.top: parent.top
+ text: "Method"
+ font.pointSize: 12; font.bold: true
+ }
+
+ Flickable {
+ id: flick
+ width: parent.width
+ anchors { top: methodTitle.bottom; bottom: parent.bottom }
+ contentHeight: methodText.height
+ clip: true
+
+ Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
+ }
+
+ Image {
+ anchors { right: flick.right; top: flick.top }
+ source: "../../modelviews/listview/" + "content/pics/moreUp.png"
+ opacity: flick.atYBeginning ? 0 : 1
+ }
+
+ Image {
+ anchors { right: flick.right; bottom: flick.bottom }
+ source: "../../modelviews/listview/" + "content/pics/moreDown.png"
+ opacity: flick.atYEnd ? 0 : 1
+ }
+ }
+
+ // A button to close the detailed view, i.e. set the state back to default ('').
+ TextButton {
+ y: 10
+ anchors { right: background.right; rightMargin: 10 }
+ opacity: recipe.detailsOpacity
+ text: "Close"
+
+ onClicked: recipe.state = '';
+ }
+
+ states: State {
+ name: "Details"
+
+ PropertyChanges { target: background; color: "white" }
+ PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
+ PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible
+ PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view
+
+ // Move the list so that this item is at the top.
+ //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
+
+ // Disallow flicking while we're in detailed view
+ //PropertyChanges { target: recipe.ListView.view; interactive: false }
+ }
+
+ transitions: Transition {
+ //The only strictly necessary particle specific lines
+ to: "Details"
+ reversible: true
+ ScriptAction {script: {
+ if(state == "Details")
+ mp.freeze(index);
+ else
+ mp.unfreeze(index);
+ }
+ }
+ // Make the state changes smooth
+ ParallelAnimation {
+ ColorAnimation { property: "color"; duration: 500 }
+ NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" }
+ }
+ }
+ }
+ }
diff --git a/examples/particles/itemparticle/content/RssModel.qml b/examples/particles/itemparticle/content/RssModel.qml
new file mode 100644
index 0000000000..46027600b3
--- /dev/null
+++ b/examples/particles/itemparticle/content/RssModel.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
+}
diff --git a/examples/particles/itemparticle/content/bubble.png b/examples/particles/itemparticle/content/bubble.png
new file mode 100644
index 0000000000..c7f479e9e3
--- /dev/null
+++ b/examples/particles/itemparticle/content/bubble.png
Binary files differ
diff --git a/examples/particles/itemparticle/content/script.js b/examples/particles/itemparticle/content/script.js
new file mode 100644
index 0000000000..e8ef93a847
--- /dev/null
+++ b/examples/particles/itemparticle/content/script.js
@@ -0,0 +1,27 @@
+.pragma library
+
+function getWidth(string) {
+ return (string.match(/width=\"([0-9]+)\"/))[1]
+}
+
+function getHeight(string) {
+ return (string.match(/height=\"([0-9]+)\"/))[1]
+}
+
+function getImagePath(string) {
+ var pattern = /src=\"http:\/\/(\S+)\"/
+ return (string.match(pattern))[1]
+}
+
+function calculateScale(width, height, cellSize) {
+ var widthScale = (cellSize * 1.0) / width
+ var heightScale = (cellSize * 1.0) / height
+ var scale = 0
+
+ if (widthScale <= heightScale) {
+ scale = widthScale;
+ } else if (heightScale < widthScale) {
+ scale = heightScale;
+ }
+ return scale;
+}
diff --git a/examples/particles/itemparticle/delegates.qml b/examples/particles/itemparticle/delegates.qml
new file mode 100644
index 0000000000..58734d320a
--- /dev/null
+++ b/examples/particles/itemparticle/delegates.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root;
+ width: 360
+ height: 600
+ color: "black"
+
+ function newPithySaying() {
+ switch (Math.floor(Math.random()*16)) {
+ case 0: return "Hello World";
+ case 1: return "G'day Mate";
+ case 2: return "Code Less";
+ case 3: return "Create More";
+ case 4: return "Deploy Everywhere";
+ case 5: return "Qt Meta-object Language";
+ case 6: return "Qt Magic Language";
+ case 7: return "Fluid UIs";
+ case 8: return "Touchable";
+ case 9: return "How's it going?";
+ case 10: return "Do you like text?";
+ case 11: return "Enjoy!";
+ case 12: return "ERROR: Out of pith";
+ case 13: return "Punctuation Failure";
+ case 14: return "I can go faster";
+ case 15: return "I can go slower";
+ default: return "OMGWTFBBQ";
+ }
+ }
+
+ ParticleSystem {
+ anchors.fill: parent
+ id: syssy
+ Emitter {
+ anchors.centerIn: parent
+ emitRate: 1
+ lifeSpan: 4800
+ lifeSpanVariation: 1600
+ speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20}
+ }
+ ItemParticle {
+ delegate: Text {
+ text: root.newPithySaying();
+ color: "white"
+ font.pixelSize: 18
+ font.bold: true
+ }
+ }
+ }
+}
diff --git a/examples/particles/itemparticle/particleview.qml b/examples/particles/itemparticle/particleview.qml
new file mode 100644
index 0000000000..774539a958
--- /dev/null
+++ b/examples/particles/itemparticle/particleview.qml
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/script.js" as Script
+import "content"
+
+Item {
+ id: root
+ width: 640
+ height: 480
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ z: -1
+ }
+ Item {
+ id: loading
+ Behavior on opacity {NumberAnimation {}}
+ anchors.fill: parent
+ Text {
+ anchors.centerIn: parent
+ text: "Loading"
+ color: "white"
+ }
+ }
+ ParticleSystem {
+ id: sys;
+ running: true
+ }
+ Emitter {
+ id: emitter
+ system: sys
+ height: parent.height - 132/2
+ x: -132/2
+ y: 132/2
+ speed: PointDirection { x: 32; xVariation: 8 }
+ emitRate: 0.5
+ lifeSpan: Emitter.InfiniteLife
+ group: "photos"
+ }
+ Age {
+ system: sys
+ x: parent.width + 132/2
+ height: parent.height
+ width: 1000
+ }
+ ImageParticle {
+ system: sys
+ groups: ["fireworks"]
+ source: "../trails/../images/star.png"
+ color: "lightsteelblue"
+ alpha: 0
+ colorVariation: 0
+ z: 1000
+ }
+ ItemParticle {
+ id: mp
+ z: 0
+ system: sys
+ fade: false
+ groups: ["photos"]
+ }
+ Component {
+ id: alertDelegate
+ Rectangle {
+ width: 132
+ height: 132
+ NumberAnimation on scale {
+ running: true
+ loops: 1
+ from: 0.2
+ to: 1
+ }
+ Image {
+ source: "../asteroid/../images/rocket.png"
+ anchors.centerIn: parent
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "A new ship has arrived!"
+ }
+ }
+ }
+ property Item alertItem;
+ function alert() {
+ //resetter.active = false
+ force.active = true;
+ alertItem = alertDelegate.createObject(root);
+ alertItem.x = root.width/2 - alertItem.width/2
+ alertItem.y = root.height/2 - alertItem.height/2
+ spawnFireworks.pulse(200);
+ stopAlert.start();
+ }
+ focus: true
+ Keys.onSpacePressed: alert();
+ Timer {
+ id: stopAlert
+ running: false
+ repeat: false
+ interval: 800
+ onTriggered: {
+ force.active = false
+ //resetter.active = true;
+ mp.take(alertItem, true);
+ centerEmitter.burst(1);
+ }
+ }
+ Attractor {
+ id: force
+ system: sys
+ pointX: root.width/2
+ pointY: root.height/2
+ strength: -10000
+ enabled: false
+ anchors.centerIn: parent
+ width: parent.width/2
+ height: parent.height/2
+ groups:["photos"]
+ affectedParameter: Attractor.Position
+ }
+ Emitter {
+ id: centerEmitter
+ speed: PointDirection { x: 32; xVariation: 8;}
+ emitRate: 0.5
+ lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
+ maximumEmitted: 20
+ group: "photos"
+ system: sys
+ anchors.centerIn: parent
+ enabled: false
+
+ //TODO: Zoom in effect
+ }
+ Emitter {
+ id: spawnFireworks
+ group: "fireworks"
+ system: sys
+ maximumEmitted: 400
+ emitRate: 400
+ lifeSpan: 2800
+ x: parent.width/2
+ y: parent.height/2 - 64
+ width: 8
+ height: 8
+ enabled: false
+ size: 32
+ endSize: 8
+ speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
+ acceleration: PointDirection { y: 160 }
+ }
+ Item { x: -1000; y: -1000 //offscreen
+ Repeater {//Load them here, add to system on completed
+ model: theModel
+ delegate: theDelegate
+ }
+ }
+ RssModel {id: theModel; tags:"particle,particles"}
+ Component {
+ id: theDelegate
+ Rectangle {
+ id: container
+ border.width: 2
+ property real myRand: Math.random();//'depth'
+ z: Math.floor(myRand * 100)
+ scale: (myRand + 1.0)/2;
+ //TODO: Darken based on 'depth'
+ width: 132
+ height: 132
+ //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity);
+ ItemParticle.onDetached: mp.take(container);//respawns
+ function manage()
+ {
+ if (state == "selected") {
+ console.log("Taking " + index);
+ mp.freeze(container);
+ } else {
+ console.log("Returning " +index);
+ mp.unfreeze(container);
+ }
+ }
+ Image {
+ id: img
+ anchors.centerIn: parent
+ smooth: true; source: "http://" + Script.getImagePath(content); cache: true
+ fillMode: Image.PreserveAspectFit;
+ width: parent.width-4; height: parent.height-4
+ onStatusChanged: if (img.status == Image.Ready) {
+ loading.opacity = 0;
+ mp.take(container);
+ }
+ }
+ Text {
+ anchors.bottom: parent.bottom
+ width: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ elide: Text.ElideRight
+ text: title
+ color: "black"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.state == "selected" ? container.state = "" : container.state = "selected"
+ }
+ states: State {
+ name: "selected"
+ ParentChange {
+ target: container
+ parent: root
+ x: 0
+ y: 0
+ }
+ PropertyChanges {
+ target: container
+ width: root.width
+ height: root.height
+ z: 101
+ opacity: 1
+ rotation: 0
+ }
+ }
+ transitions: Transition {
+ to: "selected"
+ reversible: true
+ SequentialAnimation {
+ ScriptAction {script: container.manage();}
+ ParallelAnimation {
+ ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly
+ NumberAnimation { properties: "width, height, z, rotation" }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/particles/particles.pro b/examples/particles/particles.pro
new file mode 100644
index 0000000000..967108504e
--- /dev/null
+++ b/examples/particles/particles.pro
@@ -0,0 +1 @@
+TEMPLATE = subdirs
diff --git a/examples/particles/simple/dynamiccomparison.qml b/examples/particles/simple/dynamiccomparison.qml
new file mode 100644
index 0000000000..a7cdb9b32a
--- /dev/null
+++ b/examples/particles/simple/dynamiccomparison.qml
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ color: "black"
+ width: 640
+ height: 480
+ ParticleSystem {
+ id: sys
+ }
+
+ ImageParticle {
+ system: sys
+ source: "../images/particle.png"
+ color: "white"
+ colorVariation: 1.0
+ alpha: 0.1
+ entryEffect: ImageParticle.None
+ }
+
+ Emitter {
+ id: emitter
+ system: sys
+ width: parent.width/2
+ speed: PointDirection {y: 72; yVariation: 24}
+ lifeSpan: 10000
+ emitRate: 1000
+ enabled: false
+ size: 32
+ }
+
+ Item {
+ id: fakeEmitter
+ function burst(number) {
+ while (number > 0) {
+ var item = fakeParticle.createObject(root);
+ item.lifeSpan = Math.random() * 5000 + 5000;
+ item.x = Math.random() * 320 + 320;
+ item.y = 0;
+ number--;
+ }
+ }
+
+ Component {
+ id: fakeParticle
+ Image {
+ id: container
+ property int lifeSpan: 10000
+ width: 32
+ height: 32
+ source: "../images/particle.png"
+ y: 0
+ PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true}
+ SequentialAnimation on opacity {
+ running: true
+ NumberAnimation { from:0; to: 1; duration: 500}
+ PauseAnimation { duration: container.lifeSpan - 1000}
+ NumberAnimation { from:1; to: 0; duration: 500}
+ ScriptAction { script: container.destroy(); }
+ }
+ }
+ }
+ }
+
+ Text {
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ text: "1000 particles"
+ color: "white"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: emitter.burst(1000);
+ }
+ }
+ Text {
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ text: "1000 items"
+ color: "white"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: fakeEmitter.burst(1000);
+ }
+ }
+}
diff --git a/examples/particles/simple/dynamicemitters.qml b/examples/particles/simple/dynamicemitters.qml
new file mode 100644
index 0000000000..4431ebe82e
--- /dev/null
+++ b/examples/particles/simple/dynamicemitters.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ color: "black"
+ width: 640
+ height: 480
+ ParticleSystem {
+ id: sys
+ }
+ ImageParticle {
+ system: sys
+ source: "../images/particle.png"
+ color: "white"
+ colorVariation: 1.0
+ alpha: 0.1
+ }
+
+ Component {
+ id: emitterComp
+ Emitter {
+ id: container
+ Emitter {
+ id: emitMore
+ system: sys
+ emitRate: 128
+ lifeSpan: 600
+ size: 16
+ endSize: 8
+ speed: AngleDirection {angleVariation:360; magnitude: 60}
+ }
+
+ property int life: 2600
+ property real targetX: 0
+ property real targetY: 0
+ function go() {
+ xAnim.start();
+ yAnim.start();
+ container.enabled = true
+ }
+ system: sys
+ emitRate: 32
+ lifeSpan: 600
+ size: 24
+ endSize: 8
+ NumberAnimation on x {
+ id: xAnim;
+ to: targetX
+ duration: life
+ running: false
+ }
+ NumberAnimation on y {
+ id: yAnim;
+ to: targetY
+ duration: life
+ running: false
+ }
+ Timer {
+ interval: life
+ running: true
+ onTriggered: container.destroy();
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ for (var i=0; i<8; i++) {
+ var obj = emitterComp.createObject(root);
+ obj.x = mouse.x
+ obj.y = mouse.y
+ obj.targetX = Math.random() * 240 - 120 + obj.x
+ obj.targetY = Math.random() * 240 - 120 + obj.y
+ obj.life = Math.round(Math.random() * 2400) + 200
+ obj.emitRate = Math.round(Math.random() * 32) + 32
+ obj.go();
+ }
+ }
+ }
+}
diff --git a/examples/particles/simple/multiplepainters.qml b/examples/particles/simple/multiplepainters.qml
new file mode 100644
index 0000000000..c1b85caa2d
--- /dev/null
+++ b/examples/particles/simple/multiplepainters.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ id: root
+ width: 360
+ height: 600
+ color: "darkblue"
+ property bool cloneMode: false
+ ParticleSystem {
+ id: sys
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: cloneMode = !cloneMode;
+ }
+ Emitter {
+ system: sys
+ y:root.height + 20
+ width: root.width
+ emitRate: 200
+ lifeSpan: 4000
+ startTime: 4000
+ speed: PointDirection { y: -120; }
+ }
+
+ ImageParticle {
+ system: sys
+ visible: !cloneMode
+ source: "../images/particle2.png"
+ }
+
+ ImageParticle {
+ system: sys
+ visible: cloneMode
+ z: 0
+ source: "../images/particle3.png"
+ }
+
+ ImageParticle {
+ system: sys
+ clip: true
+ visible: cloneMode
+ y: 120
+ height: 240
+ width: root.width
+ z: 1
+ source: "../images/particle.png"
+ }
+}
diff --git a/examples/particles/simple/startstop.qml b/examples/particles/simple/startstop.qml
new file mode 100644
index 0000000000..62105b28a0
--- /dev/null
+++ b/examples/particles/simple/startstop.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle {
+ width: 360
+ height: 540
+ color: "black"
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (mouse.button == Qt.LeftButton)
+ particles.running = !particles.running
+ else
+ particles.paused = !particles.paused;
+ }
+ }
+
+ ParticleSystem {
+ id: particles
+ running: false
+ }
+
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../images/star.png"
+ sizeTable: "../images/sparkleSize.png"
+ alpha: 0
+ colorVariation: 0.6
+ }
+
+ Emitter {
+ anchors.fill: parent
+ system: particles
+ emitRate: 2000
+ lifeSpan: 2000
+ size: 30
+ sizeVariation: 10
+ }
+}
diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.cpp b/examples/qml/cppextensions/imageprovider/imageprovider.cpp
index 506d5b0812..f6632a89e8 100644
--- a/examples/qml/cppextensions/imageprovider/imageprovider.cpp
+++ b/examples/qml/cppextensions/imageprovider/imageprovider.cpp
@@ -87,6 +87,7 @@ public:
class ImageProviderExtensionPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "imageprovider.json")
public:
void registerTypes(const char *uri)
{
@@ -101,7 +102,8 @@ public:
};
-#include "imageprovider.moc"
-Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin);
+#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface"
+
+#include "imageprovider.moc"
diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.json b/examples/qml/cppextensions/imageprovider/imageprovider.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/examples/qml/cppextensions/imageprovider/imageprovider.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.pro b/examples/qml/cppextensions/imageprovider/imageprovider.pro
index f75a6ebd89..b4a832b720 100644
--- a/examples/qml/cppextensions/imageprovider/imageprovider.pro
+++ b/examples/qml/cppextensions/imageprovider/imageprovider.pro
@@ -7,6 +7,8 @@ TARGET = qmlimageproviderplugin
SOURCES += imageprovider.cpp
+OTHER_FILES += imageprovider.json
+
sources.files = $$SOURCES imageprovider.qml imageprovider.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider
diff --git a/examples/qml/cppextensions/plugins/plugin.cpp b/examples/qml/cppextensions/plugins/plugin.cpp
index b53ef2ccb3..5e9900cb4f 100644
--- a/examples/qml/cppextensions/plugins/plugin.cpp
+++ b/examples/qml/cppextensions/plugins/plugin.cpp
@@ -141,6 +141,8 @@ MinuteTimer *TimeModel::timer=0;
class QExampleQmlPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json")
+
public:
void registerTypes(const char *uri)
{
@@ -151,7 +153,3 @@ public:
//![plugin]
#include "plugin.moc"
-
-//![export]
-Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin);
-//![export]
diff --git a/examples/qml/cppextensions/plugins/plugin.json b/examples/qml/cppextensions/plugins/plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/examples/qml/cppextensions/plugins/plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/qml/cppextensions/plugins/plugins.pro b/examples/qml/cppextensions/plugins/plugins.pro
index e6c7fe64a0..08a4d1a61c 100644
--- a/examples/qml/cppextensions/plugins/plugins.pro
+++ b/examples/qml/cppextensions/plugins/plugins.pro
@@ -7,7 +7,9 @@ TARGET = qmlqtimeexampleplugin
SOURCES += plugin.cpp
-qqmlsources.files += \
+OTHER_FILES += "plugin.json"
+
+qdeclarativesources.files += \
com/nokia/TimeExample/qmldir \
com/nokia/TimeExample/center.png \
com/nokia/TimeExample/clock.png \
@@ -15,11 +17,11 @@ qqmlsources.files += \
com/nokia/TimeExample/hour.png \
com/nokia/TimeExample/minute.png
-qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample
sources.files += plugins.pro plugin.cpp plugins.qml README
sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins
target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample
-INSTALLS += qqmlsources sources target
+INSTALLS += qdeclarativesources sources target
diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp
index 6b784fdccd..c4f906119a 100644
--- a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp
@@ -69,7 +69,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp
index 9a38c3b646..62499862f0 100644
--- a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp
@@ -75,7 +75,7 @@ void BirthdayParty::setHost(Person *c)
emit hostChanged();
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp
index d697ac22b6..e15ffe1604 100644
--- a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp
@@ -54,7 +54,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp
index d697ac22b6..e15ffe1604 100644
--- a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp
@@ -54,7 +54,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp
index d697ac22b6..e15ffe1604 100644
--- a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp
@@ -54,7 +54,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp
index 0935d708a7..c96f41d944 100644
--- a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp
@@ -55,7 +55,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp
index f7280560ab..8e79d07748 100644
--- a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp
@@ -55,7 +55,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp
index 078c5f9a2d..b9f7e15907 100644
--- a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp
@@ -70,7 +70,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp
index a69a58557e..aa8bc77116 100644
--- a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp
+++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp
@@ -70,7 +70,7 @@ void BirthdayParty::setHost(Person *c)
m_host = c;
}
-QQmlListProperty<Person> BirthdayParty::guests()
+QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
diff --git a/examples/qml/dynamicscene/content/Button.qml b/examples/qml/dynamicscene/content/Button.qml
new file mode 100644
index 0000000000..014692274a
--- /dev/null
+++ b/examples/qml/dynamicscene/content/Button.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property variant text
+ signal clicked
+
+ height: text.height + 10; width: text.width + 20
+ border.width: 1
+ radius: 4
+ smooth: true
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: !mouseArea.pressed ? activePalette.light : activePalette.button
+ }
+ GradientStop {
+ position: 1.0
+ color: !mouseArea.pressed ? activePalette.button : activePalette.dark
+ }
+ }
+
+ SystemPalette { id: activePalette }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked()
+ }
+
+ Text {
+ id: text
+ anchors.centerIn:parent
+ font.pointSize: 10
+ text: parent.text
+ color: activePalette.buttonText
+ }
+}
diff --git a/examples/qml/dynamicscene/content/GenericSceneItem.qml b/examples/qml/dynamicscene/content/GenericSceneItem.qml
new file mode 100644
index 0000000000..0408aa87fb
--- /dev/null
+++ b/examples/qml/dynamicscene/content/GenericSceneItem.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ property bool created: false
+ property string image
+
+ source: image
+
+}
diff --git a/examples/qml/dynamicscene/content/PaletteItem.qml b/examples/qml/dynamicscene/content/PaletteItem.qml
new file mode 100644
index 0000000000..e993f89989
--- /dev/null
+++ b/examples/qml/dynamicscene/content/PaletteItem.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "itemCreation.js" as Code
+
+Image {
+ id: paletteItem
+
+ property string componentFile
+ property string image
+
+ source: image
+
+ MouseArea {
+ anchors.fill: parent
+
+ onPressed: Code.startDrag(mouse);
+ onPositionChanged: Code.continueDrag(mouse);
+ onReleased: Code.endDrag(mouse);
+ }
+}
diff --git a/examples/qml/dynamicscene/content/PerspectiveItem.qml b/examples/qml/dynamicscene/content/PerspectiveItem.qml
new file mode 100644
index 0000000000..f651369452
--- /dev/null
+++ b/examples/qml/dynamicscene/content/PerspectiveItem.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: rootItem
+
+ property bool created: false
+ property string image
+
+ property double scaledBottom: y + (height + height*scale) / 2
+ property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset)
+
+ source: image
+ opacity: onLand ? 1 : 0.25
+ scale: Math.max((y + height - 250) * 0.01, 0.3)
+ smooth: true
+
+ onCreatedChanged: {
+ if (created && !onLand)
+ rootItem.destroy();
+ else
+ z = scaledBottom;
+ }
+
+ onYChanged: z = scaledBottom;
+}
diff --git a/examples/qml/dynamicscene/content/Sun.qml b/examples/qml/dynamicscene/content/Sun.qml
new file mode 100644
index 0000000000..b84516eecc
--- /dev/null
+++ b/examples/qml/dynamicscene/content/Sun.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: sun
+
+ property bool created: false
+ property string image: "images/sun.png"
+
+ source: image
+
+ // once item is created, start moving offscreen
+ NumberAnimation on y {
+ to: (window.height / 2) + window.centerOffset
+ running: created
+ onRunningChanged: {
+ if (running)
+ duration = (window.height + window.centerOffset - sun.y) * 10;
+ else
+ state = "OffScreen"
+ }
+ }
+
+ states: State {
+ name: "OffScreen"
+ StateChangeScript {
+ script: { sun.created = false; sun.destroy() }
+ }
+ }
+
+ onCreatedChanged: {
+ if (created) {
+ sun.z = 1; // above the sky but below the ground layer
+ window.activeSuns++;
+ } else {
+ window.activeSuns--;
+ }
+ }
+}
diff --git a/examples/qml/dynamicscene/content/images/NOTE b/examples/qml/dynamicscene/content/images/NOTE
new file mode 100644
index 0000000000..fcd87f9132
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/NOTE
@@ -0,0 +1 @@
+Images (except star.png) are from the KDE project.
diff --git a/examples/qml/dynamicscene/content/images/face-smile.png b/examples/qml/dynamicscene/content/images/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/face-smile.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/images/moon.png b/examples/qml/dynamicscene/content/images/moon.png
new file mode 100644
index 0000000000..1c0d6066a8
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/moon.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/images/rabbit_brown.png b/examples/qml/dynamicscene/content/images/rabbit_brown.png
new file mode 100644
index 0000000000..ebfdeed332
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/rabbit_brown.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/images/rabbit_bw.png b/examples/qml/dynamicscene/content/images/rabbit_bw.png
new file mode 100644
index 0000000000..7bff9b92ca
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/rabbit_bw.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/images/star.png b/examples/qml/dynamicscene/content/images/star.png
new file mode 100644
index 0000000000..27ef924267
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/star.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/images/sun.png b/examples/qml/dynamicscene/content/images/sun.png
new file mode 100644
index 0000000000..7713ca5ce7
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/sun.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/images/tree_s.png b/examples/qml/dynamicscene/content/images/tree_s.png
new file mode 100644
index 0000000000..6eac35a729
--- /dev/null
+++ b/examples/qml/dynamicscene/content/images/tree_s.png
Binary files differ
diff --git a/examples/qml/dynamicscene/content/itemCreation.js b/examples/qml/dynamicscene/content/itemCreation.js
new file mode 100644
index 0000000000..40f5415f9f
--- /dev/null
+++ b/examples/qml/dynamicscene/content/itemCreation.js
@@ -0,0 +1,62 @@
+var itemComponent = null;
+var draggedItem = null;
+var startingMouse;
+var posnInWindow;
+
+function startDrag(mouse)
+{
+ posnInWindow = paletteItem.mapToItem(window, 0, 0);
+ startingMouse = { x: mouse.x, y: mouse.y }
+ loadComponent();
+}
+
+//Creation is split into two functions due to an asynchronous wait while
+//possible external files are loaded.
+
+function loadComponent() {
+ if (itemComponent != null) { // component has been previously loaded
+ createItem();
+ return;
+ }
+
+ itemComponent = Qt.createComponent(paletteItem.componentFile);
+ if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately
+ component.statusChanged.connect(createItem);
+ else
+ createItem();
+}
+
+function createItem() {
+ if (itemComponent.status == Component.Ready && draggedItem == null) {
+ draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3});
+ // make sure created item is above the ground layer
+ } else if (itemComponent.status == Component.Error) {
+ draggedItem = null;
+ console.log("error creating component");
+ console.log(itemComponent.errorString());
+ }
+}
+
+function continueDrag(mouse)
+{
+ if (draggedItem == null)
+ return;
+
+ draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x;
+ draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y;
+}
+
+function endDrag(mouse)
+{
+ if (draggedItem == null)
+ return;
+
+ if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox
+ draggedItem.destroy();
+ draggedItem = null;
+ } else {
+ draggedItem.created = true;
+ draggedItem = null;
+ }
+}
+
diff --git a/examples/qml/dynamicscene/dynamicscene.qml b/examples/qml/dynamicscene/dynamicscene.qml
new file mode 100644
index 0000000000..c64df5cfc0
--- /dev/null
+++ b/examples/qml/dynamicscene/dynamicscene.qml
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Item {
+ id: window
+
+ property int activeSuns: 0
+ property int centerOffset: 72
+
+ height: 480; width: 320
+
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: window.focus = false;
+ }
+
+ //This is the message box that pops up when there's an error
+ Rectangle {
+ id: dialog
+
+ opacity: 0
+ anchors.centerIn: parent
+ width: dialogText.width + 6; height: dialogText.height + 6
+ border.color: 'black'
+ color: 'lightsteelblue'
+ z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones.
+
+ function show(str){
+ dialogText.text = str;
+ dialogAnim.start();
+ }
+
+ Text {
+ id: dialogText
+ x: 3; y: 3
+ font.pixelSize: 14
+ }
+
+ SequentialAnimation {
+ id: dialogAnim
+ NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 }
+ PauseAnimation { duration: 5000 }
+ NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 }
+ }
+ }
+
+ Item {
+ id: scene
+ anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right}
+ z: 10
+ }
+
+ // sky
+ Rectangle {
+ id: sky
+ anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" }
+ GradientStop { id: gradientStopB; position: 1.0; color: "#437284" }
+ }
+ }
+
+ // stars (when there's no sun)
+ ParticleSystem {
+ id: particlesystem
+ anchors.fill: sky
+
+ ImageParticle {
+ id: stars
+ source: "content/images/star.png"
+ groups: ["stars"]
+ opacity: .5
+ }
+
+ Emitter {
+ id: starsemitter
+ anchors.fill: parent
+ emitRate: parent.width / 50
+ lifeSpan: 5000
+ group: "stars"
+ }
+ }
+
+ // ground
+ Rectangle {
+ id: ground
+ z: 2 // just above the sun so that the sun can set behind it
+ anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ SystemPalette { id: activePalette }
+
+ // right-hand panel
+ Rectangle {
+ id: toolbox
+
+ height: centerOffset * 2
+ color: activePalette.window
+ anchors { right: parent.right; top: parent.top; left: parent.left}
+
+ Column {
+ anchors.centerIn: parent
+ spacing: 8
+
+ Text { text: "Drag an item into the scene." }
+
+ Rectangle {
+ width: palette.width + 10; height: palette.height + 10
+ border.color: "black"
+
+ Row {
+ id: palette
+ anchors.centerIn: parent
+ spacing: 8
+
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "Sun.qml"
+ source: "content/images/sun.png"
+ image: "images/sun.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "GenericSceneItem.qml"
+ source: "content/images/moon.png"
+ image: "images/moon.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "PerspectiveItem.qml"
+ source: "content/images/tree_s.png"
+ image: "images/tree_s.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "PerspectiveItem.qml"
+ source: "content/images/rabbit_brown.png"
+ image: "images/rabbit_brown.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ componentFile: "PerspectiveItem.qml"
+ source: "content/images/rabbit_bw.png"
+ image: "images/rabbit_bw.png"
+ }
+ }
+ }
+
+ Text { text: "Active Suns: " + activeSuns }
+ }
+ }
+
+ //Popup toolbox down the bottom
+ Rectangle {
+ id: popupToolbox
+ z: 1000
+ width: parent.width
+ height: popupColumn.height + 16
+ color: activePalette.window
+
+ property bool poppedUp: false
+ property int downY: window.height - (createButton.height + 16)
+ property int upY: window.height - (popupColumn.height + 16)
+ y: poppedUp ? upY : downY
+ Behavior on y { NumberAnimation {}}
+
+ Column {
+ id: popupColumn
+ y: 8
+ anchors.centerIn: parent
+ spacing: 8
+
+ Row {
+ height: createButton.height
+ spacing: 8
+ Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter }
+ Button {
+ id: popupButton
+ text: popupToolbox.poppedUp ? "Hide" : "Show"
+ onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp
+ }
+ Button {
+ id: createButton
+ text: "Create"
+ onClicked: {
+ try {
+ Qt.createQmlObject(qmlText.text, scene, 'CustomObject');
+ } catch(err) {
+ dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message);
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ width: 360; height: 240
+
+ TextEdit {
+ id: qmlText
+ anchors.fill: parent; anchors.margins: 5
+ readOnly: false
+ font.pixelSize: 14
+ selectByMouse: true
+ wrapMode: TextEdit.WordWrap
+
+ text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ }
+ }
+ }
+ }
+
+ //Day state, for when a sun is added to the scene
+ states: State {
+ name: "Day"
+ when: window.activeSuns > 0
+
+ PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" }
+ PropertyChanges { target: gradientStopB; color: "SkyBlue" }
+ PropertyChanges { target: stars; opacity: 0 }
+ }
+
+ //! [top-level transitions]
+ transitions: Transition {
+ PropertyAnimation { duration: 3000 }
+ ColorAnimation { duration: 3000 }
+ }
+ //! [top-level transitions]
+}
diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro
index 23d33bd653..967108504e 100644
--- a/examples/qml/qml.pro
+++ b/examples/qml/qml.pro
@@ -1,38 +1 @@
TEMPLATE = subdirs
-
-# These examples contain some C++ and need to be built
-SUBDIRS = \
- cppextensions \
- minehunt \
- modelviews \
- painteditem \
- tutorials \
- script
-
-# These examples contain no C++ and can simply be copied
-sources.files = \
- animation \
- calculator \
- cppextensions \
- flickr \
- i18n \
- imageelements \
- keyinteraction \
- photoviewer \
- positioners \
- rssnews \
- samegame \
- snake \
- sqllocalstorage \
- text \
- threading \
- touchinteraction \
- toys \
- twitter \
- ui-components \
- webbrowser \
- xml
-
-
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml
-INSTALLS += sources
diff --git a/examples/qml/xmlhttprequest/data.xml b/examples/qml/xmlhttprequest/data.xml
new file mode 100644
index 0000000000..8b7f1e116d
--- /dev/null
+++ b/examples/qml/xmlhttprequest/data.xml
@@ -0,0 +1,5 @@
+<data>
+ <element1 />
+ <element2 />
+</data>
+
diff --git a/examples/qml/xmlhttprequest/xmlhttprequest-example.qml b/examples/qml/xmlhttprequest/xmlhttprequest-example.qml
new file mode 100644
index 0000000000..28ba078160
--- /dev/null
+++ b/examples/qml/xmlhttprequest/xmlhttprequest-example.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 350; height: 400
+
+ function showRequestInfo(text) {
+ log.text = log.text + "\n" + text
+ console.log(text)
+ }
+
+ Text { id: log; anchors.fill: parent; anchors.margins: 10 }
+
+ Rectangle {
+ id: button
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10
+ width: buttonText.width + 10; height: buttonText.height + 10
+ border.width: mouseArea.pressed ? 2 : 1
+ radius : 5; smooth: true
+
+ Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ log.text = ""
+ console.log("\n")
+
+ var doc = new XMLHttpRequest();
+ doc.onreadystatechange = function() {
+ if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ showRequestInfo("Headers -->");
+ showRequestInfo(doc.getAllResponseHeaders ());
+ showRequestInfo("Last modified -->");
+ showRequestInfo(doc.getResponseHeader ("Last-Modified"));
+
+ } else if (doc.readyState == XMLHttpRequest.DONE) {
+ var a = doc.responseXML.documentElement;
+ for (var ii = 0; ii < a.childNodes.length; ++ii) {
+ showRequestInfo(a.childNodes[ii].nodeName);
+ }
+ showRequestInfo("Headers -->");
+ showRequestInfo(doc.getAllResponseHeaders ());
+ showRequestInfo("Last modified -->");
+ showRequestInfo(doc.getResponseHeader ("Last-Modified"));
+ }
+ }
+
+ doc.open("GET", "data.xml");
+ doc.send();
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/accessibility/accessibility.pro b/examples/quick/accessibility/accessibility.pro
new file mode 100644
index 0000000000..2826161945
--- /dev/null
+++ b/examples/quick/accessibility/accessibility.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility
+qml.files = accessibility.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility
+INSTALLS += target qml
+
diff --git a/examples/quick/accessibility/accessibility.qml b/examples/quick/accessibility/accessibility.qml
new file mode 100644
index 0000000000..2804d2abc8
--- /dev/null
+++ b/examples/quick/accessibility/accessibility.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+/*!
+ \title QtQuick Examples - Accessibility
+ \example qtquick/accessibility
+ \brief This example has accessible buttons.
+
+*/
+
+Rectangle {
+ id: window
+
+ width: 320; height: 480
+ color: "white"
+
+ Column {
+ id: column
+ spacing: 6
+ anchors.fill: parent
+ width: parent.width
+ Row {
+ spacing: 6
+ width: column.width
+ Button { width: 100; height: column.h + 20; text: "Send" }
+ Button { width: 100; height: column.h + 20; text: "Discard" }
+ }
+
+ Row {
+ spacing: 6
+ width: column.width
+ height: column.h
+ Text {
+ id: subjectLabel
+ Accessible.role: Accessible.StaticText
+ Accessible.name: text
+ text: "Subject:"
+ }
+ Rectangle {
+ id: subjectBorder
+ Accessible.role: Accessible.EditableText
+ Accessible.name: subjectEdit.text
+ border.width: 1
+ border.color: "black"
+ height: subjectEdit.height
+ width: 240
+ TextInput {
+ id: subjectEdit
+ text: "Vacation plans"
+ }
+ }
+ }
+ Rectangle {
+ id: textBorder
+ Accessible.role: Accessible.EditableText
+ property alias text : textEdit.text
+ border.width: 1
+ border.color: "black"
+ width: parent.width - 2
+ height: parent.height - (textBorder.y + column.spacing)
+ TextEdit {
+ id: textEdit
+ text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke"
+ width: parent.width
+ wrapMode: TextEdit.WordWrap
+ }
+ }
+ }
+}
diff --git a/examples/quick/accessibility/accessibility.qmlproject b/examples/quick/accessibility/accessibility.qmlproject
new file mode 100644
index 0000000000..04a3190914
--- /dev/null
+++ b/examples/quick/accessibility/accessibility.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "accessibility.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/accessibility/content/Button.qml b/examples/quick/accessibility/content/Button.qml
new file mode 100644
index 0000000000..2c203abe11
--- /dev/null
+++ b/examples/quick/accessibility/content/Button.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: button
+
+ property bool checked: false
+ property alias text : buttonText.text
+ Accessible.name: text
+ Accessible.description: "This button does " + text
+ Accessible.role: Accessible.Button
+
+ signal clicked
+
+ width: buttonText.width + 20
+ height: 30
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0; color: "blue" }
+ }
+ border.width: 2
+ border.color: "black";
+ radius: 10
+
+ Text {
+ id: buttonText
+ text: parent.description
+ anchors.centerIn: parent
+ font.pixelSize: parent.height * .5
+ style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ checked = !checked;
+ }
+ }
+}
diff --git a/examples/quick/accessibility/main.cpp b/examples/quick/accessibility/main.cpp
new file mode 100644
index 0000000000..89e23b477b
--- /dev/null
+++ b/examples/quick/accessibility/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(accessibility)
diff --git a/examples/quick/animation/animation.pro b/examples/quick/animation/animation.pro
new file mode 100644
index 0000000000..cdf83f80c8
--- /dev/null
+++ b/examples/quick/animation/animation.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation
+qml.files = animation.qml basics behaviors easing pathanimation pathinterpolator states
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation
+INSTALLS += target qml
+
diff --git a/examples/quick/animation/animation.qml b/examples/quick/animation/animation.qml
new file mode 100644
index 0000000000..bca68457d9
--- /dev/null
+++ b/examples/quick/animation/animation.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared" as Examples
+
+/*!
+ \title QtQuick Examples - Animation
+ \example qtquick/animation
+ \brief This is a collection of QML Animation examples.
+ \image qml-animations-example.png
+
+ This is a collection of small QML examples relating to animation. Each example is
+ a small QML file emphasizing a particular element or feature.
+
+ ColorAnimation demonstrates using a color animation to fade a sky from day to night.
+
+ PropertyAnimation demonstrates using a number animation to bounce a circle up and down.
+
+ Behaviors demonstrates using behaviors to animate moving a rectangle to whereever you click.
+
+ Wiggly Text demonstrates using more complex behaviors to animate and wiggle some text around as you drag it.
+
+ Tv Tennis demonstrates using more complex behaviors to get paddles following a ball for an infinite game.
+
+ Easing Curves shows off all the easing curves available in Qt Quick animations.
+
+ States demonstrates how the properties of an item can vary between states.
+
+ Transitions takes the States example and animates the property changes.
+
+ PathAnimation animates an image along a beizer curve using a PathAnimation.
+
+ PathInterpolator animates an image along the same beizer curve, using a PathInterpolator instead.
+*/
+
+Item {
+ height: 480
+ width: 320
+ Examples.LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml"));
+ addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml"));
+ addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml"));
+ addExample("Wiggly Text", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml"));
+ addExample("Tv Tennis", "Paddles that follow a ball", Qt.resolvedUrl("behaviors/tvtennis.qml"));
+ addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml"));
+ addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml"));
+ addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml"));
+ addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml"));
+ addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml"));
+ }
+ }
+}
diff --git a/examples/quick/animation/animation.qmlproject b/examples/quick/animation/animation.qmlproject
new file mode 100644
index 0000000000..2e96daa881
--- /dev/null
+++ b/examples/quick/animation/animation.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "animation.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/animation/basics/color-animation.qml b/examples/quick/animation/basics/color-animation.qml
new file mode 100644
index 0000000000..f1bf40c40b
--- /dev/null
+++ b/examples/quick/animation/basics/color-animation.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ // Let's draw the sky...
+ Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 }
+ ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 }
+ }
+ }
+ GradientStop {
+ position: 1.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 }
+ ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 }
+ }
+ }
+ }
+ }
+
+ // the sun, moon, and stars
+ Item {
+ width: parent.width; height: 2 * parent.height
+ NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite }
+ Image {
+ source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter
+ rotation: -3 * parent.rotation
+ }
+ Image {
+ source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter
+ rotation: -parent.rotation
+ }
+ ParticleSystem {
+ id: particlesystem
+ x: 0; y: parent.height/2
+ width: parent.width; height: parent.height/2
+ ImageParticle {
+ source: "images/star.png"
+ groups: ["star"]
+ color: "#00333333"
+ SequentialAnimation on opacity {
+ loops: Animation.Infinite
+ NumberAnimation { from: 0; to: 1; duration: 5000 }
+ NumberAnimation { from: 1; to: 0; duration: 5000 }
+ }
+ }
+ Emitter {
+ group: "star"
+ anchors.fill: parent
+ emitRate: parent.width / 50
+ lifeSpan: 5000
+ }
+ }
+ }
+
+ // ...and the ground.
+ Rectangle {
+ anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 }
+ ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 }
+ }
+ }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+}
diff --git a/examples/quick/animation/basics/images/face-smile.png b/examples/quick/animation/basics/images/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/quick/animation/basics/images/face-smile.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/moon.png b/examples/quick/animation/basics/images/moon.png
new file mode 100644
index 0000000000..9407b2b4f0
--- /dev/null
+++ b/examples/quick/animation/basics/images/moon.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/shadow.png b/examples/quick/animation/basics/images/shadow.png
new file mode 100644
index 0000000000..8270565e87
--- /dev/null
+++ b/examples/quick/animation/basics/images/shadow.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/star.png b/examples/quick/animation/basics/images/star.png
new file mode 100644
index 0000000000..27ef924267
--- /dev/null
+++ b/examples/quick/animation/basics/images/star.png
Binary files differ
diff --git a/examples/quick/animation/basics/images/sun.png b/examples/quick/animation/basics/images/sun.png
new file mode 100644
index 0000000000..7713ca5ce7
--- /dev/null
+++ b/examples/quick/animation/basics/images/sun.png
Binary files differ
diff --git a/examples/quick/animation/basics/property-animation.qml b/examples/quick/animation/basics/property-animation.qml
new file mode 100644
index 0000000000..4a4d3e3b2a
--- /dev/null
+++ b/examples/quick/animation/basics/property-animation.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ // Let's draw the sky...
+ Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "DeepSkyBlue" }
+ GradientStop { position: 1.0; color: "LightSkyBlue" }
+ }
+ }
+
+ // ...and the ground.
+ Rectangle {
+ anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ // The shadow for the smiley face
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: smiley.minHeight + 58
+ source: "images/shadow.png"
+
+ // The scale property depends on the y position of the smiley face.
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: minHeight
+ source: "images/face-smile.png"
+
+ // Animate the y property. Setting loops to Animation.Infinite makes the
+ // animation repeat indefinitely, otherwise it would only run once.
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing.type: Easing.OutExpo; duration: 300
+ }
+
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing.type: Easing.OutBounce; duration: 1000
+ }
+
+ // Then pause for 500ms
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
diff --git a/examples/quick/animation/behaviors/SideRect.qml b/examples/quick/animation/behaviors/SideRect.qml
new file mode 100644
index 0000000000..623c6965d8
--- /dev/null
+++ b/examples/quick/animation/behaviors/SideRect.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: myRect
+
+ property string text
+
+ width: 75; height: 50
+ radius: 6
+ color: "#646464"
+ border.width: 4; border.color: "white"
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: {
+ focusRect.x = myRect.x;
+ focusRect.y = myRect.y;
+ focusRect.text = myRect.text;
+ }
+ }
+}
diff --git a/examples/quick/animation/behaviors/behavior-example.qml b/examples/quick/animation/behaviors/behavior-example.qml
new file mode 100644
index 0000000000..a88d7c8c7b
--- /dev/null
+++ b/examples/quick/animation/behaviors/behavior-example.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 320; height: 480
+ color: "#343434"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 200; height: 200
+ radius: 30
+ color: "transparent"
+ border.width: 4; border.color: "white"
+
+
+ SideRect {
+ id: leftRect
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left }
+ text: "Left"
+ }
+
+ SideRect {
+ id: rightRect
+ anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right }
+ text: "Right"
+ }
+
+ SideRect {
+ id: topRect
+ anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter }
+ text: "Top"
+ }
+
+ SideRect {
+ id: bottomRect
+ anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter }
+ text: "Bottom"
+ }
+
+
+ Rectangle {
+ id: focusRect
+
+ property string text
+
+ x: 62; y: 75; width: 75; height: 50
+ radius: 6
+ border.width: 4; border.color: "white"
+ color: "firebrick"
+
+ // Set an 'elastic' behavior on the focusRect's x property.
+ Behavior on x {
+ NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 }
+ }
+
+ // Set an 'elastic' behavior on the focusRect's y property.
+ Behavior on y {
+ NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 }
+ }
+
+ Text {
+ id: focusText
+ text: focusRect.text
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 16; font.bold: true
+
+ // Set a behavior on the focusText's x property:
+ // Set the opacity to 0, set the new text value, then set the opacity back to 1.
+ Behavior on text {
+ SequentialAnimation {
+ NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 }
+ NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/animation/behaviors/tvtennis.qml b/examples/quick/animation/behaviors/tvtennis.qml
new file mode 100644
index 0000000000..108f19a11d
--- /dev/null
+++ b/examples/quick/animation/behaviors/tvtennis.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 320; height: 480;
+ color: "Black"
+
+ // Make a ball to bounce
+ Rectangle {
+ id: ball
+
+ // Add a property for the target y coordinate
+ property variant direction : "right"
+
+ x: 20; width: 20; height: 20; z: 1
+ color: "Lime"
+
+ // Move the ball to the right and back to the left repeatedly
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { to: page.width - 40; duration: 2000 }
+ PropertyAction { target: ball; property: "direction"; value: "left" }
+ NumberAnimation { to: 20; duration: 2000 }
+ PropertyAction { target: ball; property: "direction"; value: "right" }
+ }
+
+ // Make y move with a velocity of 200
+ Behavior on y { SpringAnimation{ velocity: 200; }
+ }
+
+ Component.onCompleted: y = page.height-10; // start the ball motion
+
+ // Detect the ball hitting the top or bottom of the view and bounce it
+ onYChanged: {
+ if (y <= 0) {
+ y = page.height - 20;
+ } else if (y >= page.height - 20) {
+ y = 0;
+ }
+ }
+ }
+
+ // Place bats to the left and right of the view, following the y
+ // coordinates of the ball.
+ Rectangle {
+ id: leftBat
+ color: "Lime"
+ x: 2; width: 20; height: 90
+ y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45;
+ Behavior on y { SpringAnimation{ velocity: 300 } }
+ }
+ Rectangle {
+ id: rightBat
+ color: "Lime"
+ x: page.width - 22; width: 20; height: 90
+ y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45;
+ Behavior on y { SpringAnimation{ velocity: 300 } }
+ }
+
+ // The rest, to make it look realistic, if neither ever scores...
+ Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 }
+ Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 }
+ Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 }
+ Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 }
+ Repeater {
+ model: page.height / 20
+ Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 }
+ }
+}
diff --git a/examples/quick/animation/behaviors/wigglytext.qml b/examples/quick/animation/behaviors/wigglytext.qml
new file mode 100644
index 0000000000..4bb94da100
--- /dev/null
+++ b/examples/quick/animation/behaviors/wigglytext.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Drag me!"
+ property bool animated: true
+
+ width: 320; height: 480; color: "#474747"; focus: true
+
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace)
+ container.remove()
+ else if (event.text != "") {
+ container.append(event.text)
+ }
+ }
+
+ function append(text) {
+ container.animated = false
+ var lastLetter = container.children[container.children.length - 1]
+ var newLetter = letterComponent.createObject(container)
+ newLetter.text = text
+ newLetter.follow = lastLetter
+ container.animated = true
+ }
+
+ function remove() {
+ if (container.children.length)
+ container.children[container.children.length - 1].destroy()
+ }
+
+ function doLayout() {
+ var follow = null
+ for (var i = 0; i < container.text.length; ++i) {
+ var newLetter = letterComponent.createObject(container)
+ newLetter.text = container.text[i]
+ newLetter.follow = follow
+ follow = newLetter
+ }
+ }
+
+ Component {
+ id: letterComponent
+ Text {
+ id: letter
+ property variant follow
+
+ x: follow ? follow.x + follow.width : container.width / 6
+ y: follow ? follow.y : container.height / 2
+
+ font.pixelSize: 40; font.bold: true
+ color: "#999999"; styleColor: "#222222"; style: Text.Raised
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: letter; drag.axis: Drag.XandYAxis
+ onPressed: letter.color = "#dddddd"
+ onReleased: letter.color = "#999999"
+ }
+
+ Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } }
+ Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } }
+ }
+ }
+
+ Component.onCompleted: doLayout()
+}
diff --git a/examples/quick/animation/easing/content/QuitButton.qml b/examples/quick/animation/easing/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/quick/animation/easing/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/quick/animation/easing/content/quit.png b/examples/quick/animation/easing/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/quick/animation/easing/content/quit.png
Binary files differ
diff --git a/examples/quick/animation/easing/easing.qml b/examples/quick/animation/easing/easing.qml
new file mode 100644
index 0000000000..8977029fb3
--- /dev/null
+++ b/examples/quick/animation/easing/easing.qml
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+ width: 320; height: 480; color: "#232323"
+
+ property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8,
+ 0.624, 0.98, 0.93, 0.95, 1, 1 ]
+
+ ListModel {
+ id: easingTypes
+ ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" }
+ ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" }
+ ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" }
+ ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" }
+ ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" }
+ ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" }
+ ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" }
+ ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" }
+ ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" }
+ ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" }
+ ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" }
+ ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" }
+ ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" }
+ ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" }
+ ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" }
+ ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" }
+ ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" }
+ ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" }
+ ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" }
+ ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" }
+ ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" }
+ ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" }
+ ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" }
+ ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" }
+ ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" }
+ ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" }
+ ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" }
+ ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" }
+ ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" }
+ ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" }
+ ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" }
+ ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" }
+ ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" }
+ ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" }
+ ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" }
+ ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" }
+ ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" }
+ ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" }
+ ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" }
+ ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" }
+ ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" }
+ ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; }
+ }
+
+ Component {
+ id: delegate
+
+ Item {
+ height: 56; width: window.width
+
+ Text { text: name; anchors.centerIn: parent; color: "White" }
+
+ Rectangle {
+ id: slot1; color: "#121212"; x: 30; height: 46; width: 46
+ border.color: "#343434"; border.width: 1; radius: 12
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Rectangle {
+ id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46
+ border.color: "#343434"; border.width: 1; radius: 12
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Rectangle {
+ id: rect; x: 30; color: "#454545"
+ border.color: "White"; border.width: 2
+ height: 46; width: 46; radius: 12
+ anchors.verticalCenter: parent.verticalCenter
+
+ MouseArea {
+ onClicked: if (rect.state == '') rect.state = "right"; else rect.state = ''
+ anchors.fill: parent
+ anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself
+ }
+
+ states : State {
+ name: "right"
+ PropertyChanges { target: rect; x: window.width - 76; color: ballColor }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 }
+ ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 }
+ }
+ }
+ }
+ }
+
+ Flickable {
+ anchors.fill: parent
+ contentHeight: layout.height
+ Column {
+ id: layout
+ Repeater { model: easingTypes; delegate: delegate }
+ }
+ }
+
+ function getBezierCurve(name)
+ {
+ if (name === "Easing.Bezier")
+ return easingCurve;
+ return [];
+ }
+}
diff --git a/examples/quick/animation/main.cpp b/examples/quick/animation/main.cpp
new file mode 100644
index 0000000000..799dfd7725
--- /dev/null
+++ b/examples/quick/animation/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(animation)
diff --git a/examples/quick/animation/pathanimation/pathanimation.qml b/examples/quick/animation/pathanimation/pathanimation.qml
new file mode 100644
index 0000000000..f995218c6c
--- /dev/null
+++ b/examples/quick/animation/pathanimation/pathanimation.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: window
+ width: 320
+ height: 480
+
+ Canvas {
+ id: canvas
+ anchors.fill: parent
+ smooth: true
+
+ onPaint: {
+ var context = canvas.getContext("2d")
+ context.clearRect(0, 0, width, height)
+ context.strokeStyle = "black"
+ context.path = pathAnim.path
+ context.stroke()
+ }
+ }
+
+ SequentialAnimation {
+ running: true
+ loops: -1
+
+ PauseAnimation { duration: 1000 }
+ PathAnimation {
+ id: pathAnim
+
+ duration: 2000
+ easing.type: Easing.InQuad
+
+ target: box
+ orientation: PathAnimation.RightFirst
+ anchorPoint: Qt.point(box.width/2, box.height/2)
+ path: Path {
+ startX: 50; startY: 50
+
+ PathCubic {
+ x: window.width - 50
+ y: window.height - 50
+
+ control1X: x; control1Y: 50
+ control2X: 50; control2Y: y
+ }
+
+ onChanged: canvas.requestPaint()
+ }
+ }
+ }
+
+ Rectangle {
+ id: box
+
+ x: 25; y: 25
+ width: 50; height: 50
+ border.width: 1
+ smooth: true
+
+ Text {
+ anchors.centerIn: parent
+ text: "Box"
+ }
+ }
+}
diff --git a/examples/quick/animation/pathinterpolator/pathinterpolator.qml b/examples/quick/animation/pathinterpolator/pathinterpolator.qml
new file mode 100644
index 0000000000..5a137c732d
--- /dev/null
+++ b/examples/quick/animation/pathinterpolator/pathinterpolator.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: window
+ width: 320
+ height: 480
+
+ Canvas {
+ id: canvas
+ anchors.fill: parent
+ smooth: true
+
+ onPaint: {
+ var context = canvas.getContext("2d")
+ context.clearRect(0, 0, width, height)
+ context.strokeStyle = "black"
+ context.path = motionPath.path
+ context.stroke()
+ }
+ }
+
+ PathInterpolator {
+ id: motionPath
+
+ path: Path {
+ startX: 50; startY: 50
+
+ PathCubic {
+ x: window.width - 50
+ y: window.height - 50
+
+ control1X: x; control1Y: 50
+ control2X: 50; control2Y: y
+ }
+
+ onChanged: canvas.requestPaint()
+ }
+
+ SequentialAnimation on progress {
+ running: true
+ loops: -1
+ PauseAnimation { duration: 1000 }
+ NumberAnimation {
+ id: progressAnim
+ running: false
+ from: 0; to: 1
+ duration: 2000
+ easing.type: Easing.InQuad
+ }
+ }
+ }
+
+ Rectangle {
+ id: box
+
+ width: 50; height: 50
+ border.width: 1
+ smooth: true
+
+ //bind our attributes to follow the path as progress changes
+ x: motionPath.x
+ y: motionPath.y
+ rotation: motionPath.angle
+ transform: Translate { x: -box.width/2; y: -box.height/2 }
+
+ Text {
+ anchors.centerIn: parent
+ text: "Box"
+ }
+ }
+
+}
diff --git a/examples/quick/animation/states/qt-logo.png b/examples/quick/animation/states/qt-logo.png
new file mode 100644
index 0000000000..14ddf2a028
--- /dev/null
+++ b/examples/quick/animation/states/qt-logo.png
Binary files differ
diff --git a/examples/quick/animation/states/states.qml b/examples/quick/animation/states/states.qml
new file mode 100644
index 0000000000..7ca56a9295
--- /dev/null
+++ b/examples/quick/animation/states/states.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 640; height: 480
+ color: "#343434"
+
+ Image {
+ id: userIcon
+ x: topLeftRect.x; y: topLeftRect.y
+ source: "qt-logo.png"
+ }
+
+ Rectangle {
+ id: topLeftRect
+
+ anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to the default state, returning the image to
+ // its initial position
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
+ }
+
+ Rectangle {
+ id: middleRightRect
+
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'middleRight'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' }
+ }
+
+ Rectangle {
+ id: bottomLeftRect
+
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'bottomLeft'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
+ }
+
+ states: [
+ // In state 'middleRight', move the image to middleRightRect
+ State {
+ name: "middleRight"
+ PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
+ },
+
+ // In state 'bottomLeft', move the image to bottomLeftRect
+ State {
+ name: "bottomLeft"
+ PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y }
+ }
+ ]
+}
diff --git a/examples/quick/animation/states/transitions.qml b/examples/quick/animation/states/transitions.qml
new file mode 100644
index 0000000000..d57924d6d2
--- /dev/null
+++ b/examples/quick/animation/states/transitions.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+/*
+ This is exactly the same as states.qml, except that we have appended
+ a set of transitions to apply animations when the item changes
+ between each state.
+*/
+
+Rectangle {
+ id: page
+ width: 640; height: 480
+ color: "#343434"
+
+ Image {
+ id: userIcon
+ x: topLeftRect.x; y: topLeftRect.y
+ source: "qt-logo.png"
+ }
+
+ Rectangle {
+ id: topLeftRect
+
+ anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to the default state, returning the image to
+ // its initial position
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
+ }
+
+ Rectangle {
+ id: middleRightRect
+
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'middleRight'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' }
+ }
+
+ Rectangle {
+ id: bottomLeftRect
+
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
+ width: 46; height: 54
+ color: "Transparent"; border.color: "Gray"; radius: 6
+
+ // Clicking in here sets the state to 'bottomLeft'
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' }
+ }
+
+ states: [
+ // In state 'middleRight', move the image to middleRightRect
+ State {
+ name: "middleRight"
+ PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y }
+ },
+
+ // In state 'bottomLeft', move the image to bottomLeftRect
+ State {
+ name: "bottomLeft"
+ PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y }
+ }
+ ]
+
+ // Transitions define how the properties change when the item moves between each state
+ transitions: [
+
+ // When transitioning to 'middleRight' move x,y over a duration of 1 second,
+ // with OutBounce easing function.
+ Transition {
+ from: "*"; to: "middleRight"
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 }
+ },
+
+ // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds,
+ // with InOutQuad easing function.
+ Transition {
+ from: "*"; to: "bottomLeft"
+ NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 }
+ },
+
+ // For any other state changes move x,y linearly over duration of 200ms.
+ Transition {
+ NumberAnimation { properties: "x,y"; duration: 200 }
+ }
+ ]
+}
diff --git a/examples/quick/canvas/bezierCurve/bezierCurve.qml b/examples/quick/canvas/bezierCurve/bezierCurve.qml
new file mode 100644
index 0000000000..f57839b0a5
--- /dev/null
+++ b/examples/quick/canvas/bezierCurve/bezierCurve.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"red"
+ property string fillStyle:"red"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75,40);
+ ctx.bezierCurveTo(75,37,70,25,50,25);
+ ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
+ ctx.bezierCurveTo(20,80,40,102,75,120);
+ ctx.bezierCurveTo(110,102,130,80,130,62.5);
+ ctx.bezierCurveTo(130,62.5,130,25,100,25);
+ ctx.bezierCurveTo(85,25,75,37,75,40);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/clip/clip.qml b/examples/quick/canvas/clip/clip.qml
new file mode 100644
index 0000000000..d861ff0a46
--- /dev/null
+++ b/examples/quick/canvas/clip/clip.qml
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter}
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px:xCtrl.value
+ property real py:yCtrl.value
+ property real alpha:alphaCtrl.value
+ property string imagefile:"../contents/qt-logo.png"
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+ Component.onCompleted:loadImage(canvas.imagefile);
+
+ onAlphaChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onPxChanged:requestPaint();
+ onPyChanged:requestPaint();
+
+ onImageLoaded : requestPaint();
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.save();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "gray";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+ ctx.clip();
+
+ ctx.drawImage(canvas.imagefile, 0, 0);
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"}
+ Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"}
+ Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"}
+ Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/contents/Button.qml b/examples/quick/canvas/contents/Button.qml
new file mode 100644
index 0000000000..1413cdb9fa
--- /dev/null
+++ b/examples/quick/canvas/contents/Button.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ signal clicked
+
+ property string text
+ width: buttonText.width + 28
+ height: buttonText.height + 14
+
+ BorderImage {
+ id: buttonImage
+ source: "images/toolbutton.sci"
+ width: container.width - 10
+ height: container.height
+ }
+ BorderImage {
+ id: pressed
+ opacity: 0
+ source: "images/toolbutton.sci"
+ width: container.width - 10
+ height: container.height
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: buttonImage
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ id: buttonText
+ color: "white"
+ anchors.centerIn: buttonImage
+ font.bold: true
+ font.pointSize: 15
+ text: container.text
+ style: Text.Raised
+ styleColor: "black"
+ }
+ states: [
+ State {
+ name: "Pressed"
+ when: mouseRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ }
+ ]
+} \ No newline at end of file
diff --git a/examples/quick/canvas/contents/ScrollBar.qml b/examples/quick/canvas/contents/ScrollBar.qml
new file mode 100644
index 0000000000..98b8efee4a
--- /dev/null
+++ b/examples/quick/canvas/contents/ScrollBar.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: scrollBar
+ // The properties that define the scrollbar's state.
+ // position and pageSize are in the range 0.0 - 1.0. They are relative to the
+ // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
+ // of the height of the view.
+ // orientation can be either 'Vertical' or 'Horizontal'
+ property real position
+ property real pageSize
+ property string orientation : "Vertical"
+ property alias bgColor: background.color
+ property alias fgColor: thumb.color
+
+ // A light, semi-transparent background
+ Rectangle {
+ id: background
+ radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
+ color: "white"; opacity: 0.3
+ anchors.fill: parent
+ }
+ // Size the bar to the required size, depending upon the orientation.
+ Rectangle {
+ id: thumb
+ opacity: 0.7
+ color: "black"
+ radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
+ x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
+ y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
+ width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
+ height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ }
+}
diff --git a/examples/quick/canvas/contents/Slider.qml b/examples/quick/canvas/contents/Slider.qml
new file mode 100644
index 0000000000..093b9e40dd
--- /dev/null
+++ b/examples/quick/canvas/contents/Slider.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id:slider
+ property real min:0
+ property real max:1
+ property real value: min + (max - min) * (bar.x / (foo.width - bar.width))
+ property real init:min+(max-min)/2
+ property string name:"Slider"
+
+ Component.onCompleted: setValue(init)
+ function setValue(v) {
+ if (min < max)
+ bar.x = v/(max - min) * (foo.width - bar.width);
+ }
+ Rectangle {
+ id:sliderName
+ anchors.left:parent.left
+ height: childrenRect.height
+ width:childrenRect.width
+ anchors.verticalCenter:parent.verticalCenter
+ Text {
+ text:slider.name
+ font.pointSize:12
+ }
+ }
+ Item {
+ id: foo
+ height: 6
+ width: parent.width - 4 - sliderName.width
+ anchors.verticalCenter:parent.verticalCenter
+ anchors.left:sliderName.right
+ anchors.leftMargin:5
+ Rectangle {
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: bar.horizontalCenter
+ color: "blue"
+ radius: 3
+ }
+ Rectangle {
+ height: parent.height
+ anchors.left: bar.horizontalCenter
+ anchors.right: parent.right
+ color: "gray"
+ radius: 3
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ radius: 3
+ border.width: 2
+ border.color: "black"
+ }
+
+ Rectangle {
+ id: bar
+ y: -7
+ width: 20
+ height: 20
+ radius: 15
+ color: "white"
+ border.width: 2
+ border.color: "black"
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: foo.width - parent.width
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/contents/Stocks.qml b/examples/quick/canvas/contents/Stocks.qml
new file mode 100644
index 0000000000..043bca132e
--- /dev/null
+++ b/examples/quick/canvas/contents/Stocks.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id:stocks
+ //Data from : http://en.wikipedia.org/wiki/NASDAQ-100
+
+ ListElement {name:"Activision Blizzard"; stockId:"ATVI"}
+ ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"}
+ ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"}
+ ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"}
+ ListElement {name:"Altera Corporation"; stockId:"ALTR"}
+ ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"}
+ ListElement {name:"Amgen Inc."; stockId:"AMGN"}
+ ListElement {name:"Apollo Group, Inc."; stockId:"APOL"}
+ ListElement {name:"Apple Inc."; stockId:"AAPL"}
+ ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"}
+ ListElement {name:"Autodesk, Inc."; stockId:"ADSK"}
+ ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"}
+ ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"}
+ ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"}
+ ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"}
+ ListElement {name:"BMC Software, Inc."; stockId:"BMC"}
+ ListElement {name:"Broadcom Corporation"; stockId:"BRCM"}
+ ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"}
+ ListElement {name:"CA, Inc."; stockId:"CA"}
+ ListElement {name:"Celgene Corporation"; stockId:"CELG"}
+ ListElement {name:"Cephalon, Inc."; stockId:"CEPH"}
+ ListElement {name:"Cerner Corporation"; stockId:"CERN"}
+ ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"}
+ ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"}
+ ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"}
+ ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"}
+ ListElement {name:"Comcast Corporation"; stockId:"CMCSA"}
+ ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"}
+ ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"}
+ ListElement {name:"Dell Inc."; stockId:"DELL"}
+ ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"}
+ ListElement {name:"DirecTV"; stockId:"DTV"}
+ ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"}
+ ListElement {name:"eBay Inc."; stockId:"EBAY"}
+ ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"}
+ ListElement {name:"Expedia, Inc."; stockId:"EXPE"}
+ ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"}
+ ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"}
+ ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"}
+ ListElement {name:"Fastenal Company"; stockId:"FAST"}
+ ListElement {name:"First Solar, Inc."; stockId:"FSLR"}
+ ListElement {name:"Fiserv, Inc."; stockId:"FISV"}
+ ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"}
+ ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"}
+ ListElement {name:"Garmin Ltd."; stockId:"GRMN"}
+ ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"}
+ ListElement {name:"Google Inc."; stockId:"GOOG"}
+ ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"}
+ ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"}
+ ListElement {name:"Illumina, Inc."; stockId:"ILMN"}
+ ListElement {name:"Infosys Technologies"; stockId:"INFY"}
+ ListElement {name:"Intel Corporation"; stockId:"INTC"}
+ ListElement {name:"Intuit, Inc."; stockId:"INTU"}
+ ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"}
+ ListElement {name:"Joy Global Inc."; stockId:"JOYG"}
+ ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"}
+ ListElement {name:"Lam Research Corporation"; stockId:"LRCX"}
+ ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"}
+ ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"}
+ ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"}
+ ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"}
+ ListElement {name:"Mattel, Inc."; stockId:"MAT"}
+ ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"}
+ ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"}
+ ListElement {name:"Micron Technology, Inc."; stockId:"MU"}
+ ListElement {name:"Microsoft Corporation"; stockId:"MSFT"}
+ ListElement {name:"Mylan, Inc."; stockId:"MYL"}
+ ListElement {name:"NetApp, Inc."; stockId:"NTAP"}
+ ListElement {name:"Netflix, Inc."; stockId:"NFLX"}
+ ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"}
+ ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"}
+ ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"}
+ ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"}
+ ListElement {name:"Oracle Corporation"; stockId:"ORCL"}
+ ListElement {name:"PACCAR Inc."; stockId:"PCAR"}
+ ListElement {name:"Paychex, Inc."; stockId:"PAYX"}
+ ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"}
+ ListElement {name:"Qiagen N.V."; stockId:"QGEN"}
+ ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"}
+ ListElement {name:"Research in Motion Limited"; stockId:"RIMM"}
+ ListElement {name:"Ross Stores Inc."; stockId:"ROST"}
+ ListElement {name:"SanDisk Corporation"; stockId:"SNDK"}
+ ListElement {name:"Seagate Technology Holdings"; stockId:"STX"}
+ ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"}
+ ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"}
+ ListElement {name:"Staples Inc."; stockId:"SPLS"}
+ ListElement {name:"Starbucks Corporation"; stockId:"SBUX"}
+ ListElement {name:"Stericycle, Inc"; stockId:"SRCL"}
+ ListElement {name:"Symantec Corporation"; stockId:"SYMC"}
+ ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"}
+ ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"}
+ ListElement {name:"VeriSign, Inc."; stockId:"VRSN"}
+ ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"}
+ ListElement {name:"Virgin Media, Inc."; stockId:"VMED"}
+ ListElement {name:"Vodafone Group, plc."; stockId:"VOD"}
+ ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"}
+ ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"}
+ ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"}
+ ListElement {name:"Xilinx, Inc."; stockId:"XLNX"}
+ ListElement {name:"Yahoo! Inc."; stockId:"YHOO"}
+}
diff --git a/examples/quick/canvas/contents/TitleBar.qml b/examples/quick/canvas/contents/TitleBar.qml
new file mode 100644
index 0000000000..28edda2ae7
--- /dev/null
+++ b/examples/quick/canvas/contents/TitleBar.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: titleBar
+ property string title: ""
+
+ BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+
+ Image {
+ id: quitButton
+ anchors.left: parent.left//; anchors.leftMargin: 0
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/quit.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+
+ Text {
+ id: categoryText
+ anchors {
+ left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ elide: Text.ElideLeft
+ text: title
+ font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black"
+ }
+}
diff --git a/examples/quick/canvas/contents/ToolBar.qml b/examples/quick/canvas/contents/ToolBar.qml
new file mode 100644
index 0000000000..7ae7391ddf
--- /dev/null
+++ b/examples/quick/canvas/contents/ToolBar.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: toolbar
+
+ property variant labels
+ signal buttonClicked(int index)
+
+ BorderImage {
+ source: "images/titlebar.sci"
+ width: parent.width
+ height: parent.height + 14
+ y: -7
+ }
+
+ Row {
+ y: 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ Repeater {
+ model: toolbar.labels
+ delegate:
+ Button {
+ text: modelData
+ onClicked: toolbar.buttonClicked(model.index)
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/canvas/contents/images/button-pressed.png b/examples/quick/canvas/contents/images/button-pressed.png
new file mode 100644
index 0000000000..e434d327f2
--- /dev/null
+++ b/examples/quick/canvas/contents/images/button-pressed.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/button.png b/examples/quick/canvas/contents/images/button.png
new file mode 100644
index 0000000000..56a63ce641
--- /dev/null
+++ b/examples/quick/canvas/contents/images/button.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/default.svg b/examples/quick/canvas/contents/images/default.svg
new file mode 100644
index 0000000000..248199cc4e
--- /dev/null
+++ b/examples/quick/canvas/contents/images/default.svg
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48px" height="48px" id="svg1306">
+ <defs id="defs1308">
+ <linearGradient id="linearGradient4083">
+ <stop id="stop4085" offset="0" stop-color="#ffffff" stop-opacity="0"/>
+ <stop offset="0.75" id="stop4089" stop-color="#ffffff" stop-opacity="0"/>
+ <stop id="stop4087" offset="1" stop-color="#ffffff" stop-opacity="1"/>
+ </linearGradient>
+ <linearGradient id="linearGradient4032">
+ <stop id="stop4034" offset="0" stop-color="#fff7c2" stop-opacity="0.63829786"/>
+ <stop offset="0.59394139" id="stop4036" stop-color="#fcaf3e" stop-opacity="0.18348624"/>
+ <stop id="stop4038" offset="0.83850551" stop-color="#fcaf3e" stop-opacity="0.50458717"/>
+ <stop id="stop4040" offset="1" stop-color="#fcaf3e" stop-opacity="1"/>
+ </linearGradient>
+ <linearGradient id="linearGradient4026">
+ <stop id="stop4028" offset="0" stop-color="#fff9c6" stop-opacity="1"/>
+ <stop offset="0.54166669" id="stop4042" stop-color="#fff28c" stop-opacity="1"/>
+ <stop id="stop4030" offset="1" stop-color="#ffea85" stop-opacity="1"/>
+ </linearGradient>
+ <linearGradient xlink:href="#linearGradient4026" id="linearGradient3168" gradientUnits="userSpaceOnUse" x1="-28.968945" y1="-25.326815" x2="-37.19698" y2="-9.5590506"/>
+ <radialGradient xlink:href="#linearGradient4032" id="radialGradient4020" cx="-33.519073" cy="-22.113297" fx="-33.519073" fy="-22.113297" r="9.5" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.487739,1.292402,-1.10267,0.497242,-41.77393,32.41492)"/>
+ <radialGradient xlink:href="#linearGradient4083" id="radialGradient4081" cx="23.99999" cy="23.381506" fx="23.99999" fy="23.381506" r="19.141981" gradientTransform="matrix(1.006701,2.235326e-16,-2.23715e-16,1.007522,-0.160816,0.426981)" gradientUnits="userSpaceOnUse"/>
+ </defs>
+
+ <metadata id="metadata1311">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:title>weather-clear</dc:title>
+ <dc:date>January 2006</dc:date>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Ryan Collier (pseudo)</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:publisher>
+ <cc:Agent>
+ <dc:title>http://www.tango-project.org</dc:title>
+ </cc:Agent>
+ </dc:publisher>
+ <dc:source>http://www.pseudocode.org</dc:source>
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>weather</rdf:li>
+ <rdf:li>applet</rdf:li>
+ <rdf:li>notification</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"/>
+ <dc:contributor>
+ <cc:Agent>
+ <dc:title>Garrett LeSage</dc:title>
+ </cc:Agent>
+ </dc:contributor>
+ </cc:Work>
+ <cc:License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/>
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1">
+ <g>
+ <g opacity="0.7">
+ <path d="M 24 2.5 L 21.625 9.1875 C 22.399034 9.0641318 23.191406 9 24 9 C 24.808594 9 25.600966 9.0641317 26.375 9.1875 L 24 2.5 z M 8.8125 8.78125 L 11.84375 15.21875 C 12.779034 13.928569 13.928569 12.779034 15.21875 11.84375 L 8.8125 8.78125 z M 39.21875 8.78125 L 32.78125 11.84375 C 34.071431 12.779034 35.220966 13.928569 36.15625 15.21875 L 39.21875 8.78125 z M 9.1875 21.59375 L 2.5 23.96875 L 9.1875 26.34375 C 9.0673373 25.57952 9 24.797813 9 24 C 9 23.180625 9.0608858 22.377571 9.1875 21.59375 z M 38.8125 21.625 C 38.935868 22.399034 39 23.191406 39 24 C 39 24.808594 38.935868 25.600966 38.8125 26.375 L 45.5 24 L 38.8125 21.625 z M 11.84375 32.78125 L 8.8125 39.1875 L 15.21875 36.15625 C 13.928569 35.220966 12.779034 34.071431 11.84375 32.78125 z M 36.15625 32.78125 C 35.229789 34.05926 34.087617 35.194799 32.8125 36.125 L 39.21875 39.1875 L 36.15625 32.78125 z M 21.625 38.8125 L 24 45.5 L 26.375 38.8125 C 25.600966 38.935868 24.808594 39 24 39 C 23.191406 39 22.399034 38.935868 21.625 38.8125 z " fill="#fce94f" fill-opacity="1" stroke="#fcaf3e" stroke-width="0.73732895" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ <path d="M 24 5.25 L 22.65625 9.0625 C 23.098888 9.0231486 23.547187 9 24 9 C 24.452813 9 24.901112 9.0231486 25.34375 9.0625 L 24 5.25 z M 10.78125 10.75 L 12.5 14.375 C 13.071538 13.694089 13.724004 13.038745 14.40625 12.46875 L 10.78125 10.75 z M 37.25 10.75 L 33.625 12.46875 C 34.304675 13.038189 34.961811 13.695325 35.53125 14.375 L 37.25 10.75 z M 9.0625 22.625 L 5.28125 23.96875 L 9.0625 25.3125 C 9.024981 24.880146 9 24.442031 9 24 C 9 23.536406 9.0212735 23.077908 9.0625 22.625 z M 38.9375 22.65625 C 38.976851 23.098888 39 23.547187 39 24 C 39 24.452813 38.976851 24.901112 38.9375 25.34375 L 42.71875 24 L 38.9375 22.65625 z M 35.53125 33.59375 C 34.958293 34.27954 34.309985 34.957363 33.625 35.53125 L 37.25 37.25 L 35.53125 33.59375 z M 12.5 33.625 L 10.78125 37.21875 L 14.375 35.5 C 13.702932 34.935884 13.064116 34.297068 12.5 33.625 z M 22.65625 38.9375 L 24 42.71875 L 25.34375 38.9375 C 24.901112 38.976851 24.452813 39 24 39 C 23.547187 39 23.098888 38.976851 22.65625 38.9375 z " fill="none" fill-opacity="1" stroke="url(#radialGradient4081)" stroke-width="0.84646249" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ </g>
+ <g>
+ <g>
+ <path transform="matrix(0.778062,-1.061285,1.061287,0.778062,67.47952,3.641324)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="#ffee54" fill-opacity="1" stroke="#fcaf3e" stroke-width="0.75991178" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ <path transform="matrix(1.244257,-0.167707,0.216642,1.251844,67.61648,40.527)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="url(#radialGradient4020)" fill-opacity="1" stroke="none" stroke-width="1.01737845" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ <path transform="matrix(0.715791,-0.976349,0.97635,0.715792,64.00044,5.269544)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="none" fill-opacity="1" stroke="url(#linearGradient3168)" stroke-width="0.82601947" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
+ </g>
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/examples/quick/canvas/contents/images/gloss.png b/examples/quick/canvas/contents/images/gloss.png
new file mode 100755
index 0000000000..5d370cd93d
--- /dev/null
+++ b/examples/quick/canvas/contents/images/gloss.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/lineedit.png b/examples/quick/canvas/contents/images/lineedit.png
new file mode 100755
index 0000000000..2cc38dc35b
--- /dev/null
+++ b/examples/quick/canvas/contents/images/lineedit.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/lineedit.sci b/examples/quick/canvas/contents/images/lineedit.sci
new file mode 100644
index 0000000000..054bff78be
--- /dev/null
+++ b/examples/quick/canvas/contents/images/lineedit.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 10
+border.bottom: 10
+border.right: 10
+source: lineedit.png
diff --git a/examples/quick/canvas/contents/images/quit.png b/examples/quick/canvas/contents/images/quit.png
new file mode 100755
index 0000000000..5bda1b6e0d
--- /dev/null
+++ b/examples/quick/canvas/contents/images/quit.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/stripes.png b/examples/quick/canvas/contents/images/stripes.png
new file mode 100755
index 0000000000..9f36727ea4
--- /dev/null
+++ b/examples/quick/canvas/contents/images/stripes.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/titlebar.png b/examples/quick/canvas/contents/images/titlebar.png
new file mode 100755
index 0000000000..51c90082d0
--- /dev/null
+++ b/examples/quick/canvas/contents/images/titlebar.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/titlebar.sci b/examples/quick/canvas/contents/images/titlebar.sci
new file mode 100644
index 0000000000..0418d94cd6
--- /dev/null
+++ b/examples/quick/canvas/contents/images/titlebar.sci
@@ -0,0 +1,5 @@
+border.left: 10
+border.top: 12
+border.bottom: 12
+border.right: 10
+source: titlebar.png
diff --git a/examples/quick/canvas/contents/images/toolbutton.png b/examples/quick/canvas/contents/images/toolbutton.png
new file mode 100755
index 0000000000..11310013ee
--- /dev/null
+++ b/examples/quick/canvas/contents/images/toolbutton.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/toolbutton.sci b/examples/quick/canvas/contents/images/toolbutton.sci
new file mode 100644
index 0000000000..9e4f965307
--- /dev/null
+++ b/examples/quick/canvas/contents/images/toolbutton.sci
@@ -0,0 +1,5 @@
+border.left: 15
+border.top: 4
+border.bottom: 4
+border.right: 15
+source: toolbutton.png
diff --git a/examples/quick/canvas/contents/qt-logo.png b/examples/quick/canvas/contents/qt-logo.png
new file mode 100644
index 0000000000..5ab3a1b0c4
--- /dev/null
+++ b/examples/quick/canvas/contents/qt-logo.png
Binary files differ
diff --git a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
new file mode 100644
index 0000000000..bc3ca0071a
--- /dev/null
+++ b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ property string strokeStyle:"steelblue"
+ property string fillStyle:"yellow"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75,25);
+ ctx.quadraticCurveTo(25,25,25,62.5);
+ ctx.quadraticCurveTo(25,100,50,100);
+ ctx.quadraticCurveTo(50,120,30,125);
+ ctx.quadraticCurveTo(60,120,65,100);
+ ctx.quadraticCurveTo(125,100,125,62.5);
+ ctx.quadraticCurveTo(125,25,75,25);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+
+
+ ctx.fillStyle="green";
+ ctx.font = "Bold 15px";
+
+ ctx.fillText("QML酷毙了", 30, 60);
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/roundedrect/roundedrect.qml b/examples/quick/canvas/roundedrect/roundedrect.qml
new file mode 100644
index 0000000000..fd86c63a3b
--- /dev/null
+++ b/examples/quick/canvas/roundedrect/roundedrect.qml
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter}
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property int radius: rCtrl.value
+ property int rectx: rxCtrl.value
+ property int recty: ryCtrl.value
+ property int rectWidth: width - 2*rectx
+ property int rectHeight: height - 2*recty
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onRectxChanged:requestPaint();
+ onRectyChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.save();
+ ctx.clearRect(0,0,canvas.width, canvas.height);
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.lineWidth = canvas.lineWidth
+ ctx.fillStyle = canvas.fillStyle
+ ctx.globalAlpha = canvas.alpha
+ ctx.beginPath();
+ ctx.moveTo(rectx+radius,recty); // top side
+ ctx.lineTo(rectx+rectWidth-radius,recty);
+ // draw top right corner
+ ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius);
+ ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side
+ // draw bottom right corner
+ ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius);
+ ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side
+ // draw bottom left corner
+ ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius);
+ ctx.lineTo(rectx,recty+radius); // left side
+ // draw top left corner
+ ctx.arcTo(rectx,recty,rectx+radius,recty,radius);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"}
+ Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"}
+ Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/smile/smile.qml b/examples/quick/canvas/smile/smile.qml
new file mode 100644
index 0000000000..28a48a6c81
--- /dev/null
+++ b/examples/quick/canvas/smile/smile.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property string strokeStyle:"green"
+ property string fillStyle:"yellow"
+ property int lineWidth:lineWidthCtrl.value
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onAlphaChanged:requestPaint();
+ onScaleXChanged:requestPaint();
+ onScaleYChanged:requestPaint();
+ onRotateChanged:requestPaint();
+
+ Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
+ Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.beginPath();
+ ctx.moveTo(75 + 50 * Math.cos(0),
+ 75 - 50 * Math.sin(Math.PI*2));
+ ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
+ ctx.moveTo(75,70);
+ ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise)
+ ctx.moveTo(60,65);
+ ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
+ ctx.moveTo(90 + 5 * Math.cos(0),
+ 65 - 5 * Math.sin(Math.PI*2));
+ ctx.moveTo(90,65);
+ ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"}
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/squircle/squircle.png b/examples/quick/canvas/squircle/squircle.png
new file mode 100644
index 0000000000..86c69d945f
--- /dev/null
+++ b/examples/quick/canvas/squircle/squircle.png
Binary files differ
diff --git a/examples/quick/canvas/squircle/squircle.qml b/examples/quick/canvas/squircle/squircle.qml
new file mode 100644
index 0000000000..2fc65b67b3
--- /dev/null
+++ b/examples/quick/canvas/squircle/squircle.qml
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter}
+ Image {
+ anchors.horizontalCenter:parent.horizontalCenter
+ source:"squircle.png"
+ width:250
+ height:25
+ }
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property string strokeStyle:"blue"
+ property string fillStyle:"steelblue"
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px:xCtrl.value
+ property real py:yCtrl.value
+ property real alpha:alphaCtrl.value
+
+ onAlphaChanged:requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onPxChanged:requestPaint();
+ onPyChanged:requestPaint();
+
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.save();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "gray";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+
+ ctx.fillStyle = "yellow";
+ ctx.font = "Helvetica 16px";
+ ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py);
+ ctx.restore();
+ }
+ }
+
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"}
+ Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"}
+ Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"}
+ Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/stockchart/README b/examples/quick/canvas/stockchart/README
new file mode 100644
index 0000000000..2652866ed6
--- /dev/null
+++ b/examples/quick/canvas/stockchart/README
@@ -0,0 +1,5 @@
+To run:
+
+ make install
+ QML_IMPORT_PATH=$PWD qmlscene stock.qml
+
diff --git a/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir
new file mode 100644
index 0000000000..4c60e556d4
--- /dev/null
+++ b/examples/quick/canvas/stockchart/com/nokia/StockChartExample/qmldir
@@ -0,0 +1 @@
+plugin qmlstockchartexampleplugin
diff --git a/examples/quick/canvas/stockchart/model.cpp b/examples/quick/canvas/stockchart/model.cpp
new file mode 100644
index 0000000000..42eb2d592f
--- /dev/null
+++ b/examples/quick/canvas/stockchart/model.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QDate>
+#include <QtCore/QList>
+#include <QtCore/QStringList>
+#include <QtCore/QDebug>
+
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkReply>
+
+StockModel::StockModel(QObject *parent)
+ : QAbstractListModel(parent)
+ , _startDate(QDate(1995, 4, 25))
+ , _endDate(QDate::currentDate())
+ , _dataCycle(StockModel::Daily)
+ , _manager(0)
+ , _updating(false)
+{
+ QHash<int, QByteArray> roles;
+ roles[StockModel::DateRole] = "date";
+ roles[StockModel::SectionRole] = "year";
+ roles[StockModel::OpenPriceRole] = "openPrice";
+ roles[StockModel::ClosePriceRole] = "closePrice";
+ roles[StockModel::HighPriceRole] = "highPrice";
+ roles[StockModel::LowPriceRole] = "lowPrice";
+ roles[StockModel::VolumeRole] = "volume";
+ roles[StockModel::AdjustedPriceRole] = "adjustedPrice";
+ setRoleNames(roles);
+
+ connect(this, SIGNAL(stockNameChanged()), SLOT(requestData()));
+ connect(this, SIGNAL(startDateChanged()), SLOT(requestData()));
+ connect(this, SIGNAL(endDateChanged()), SLOT(requestData()));
+ connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData()));
+
+ _manager = new QNetworkAccessManager(this);
+ connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*)));
+
+}
+
+int StockModel::rowCount(const QModelIndex & parent) const {
+ Q_UNUSED(parent);
+ return _prices.count();
+}
+
+StockPrice* StockModel::stockPriceAtIndex(int idx) const
+{
+ if (idx >=0 && idx < _prices.size()) {
+ return _prices[idx];
+ }
+ return 0;
+}
+
+
+void StockModel::requestData()
+{
+ if (!_updating) {
+ _updating = true;
+ QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection);
+ }
+}
+
+void StockModel::doRequest()
+{
+ /*
+ Fetch stock data from yahoo finance:
+ url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv
+ s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962
+ d:end day, e:end month, f:end year, default:today (data only available 3 days before today)
+ g:data cycle(d daily, w weekly, m monthly, v Dividend)
+ */
+ if (_manager && !_stockName.isEmpty() && _endDate > _startDate) {
+ QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv");
+ query = query.arg(_stockName)
+ .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year())
+ .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year())
+ .arg(dataCycleString());
+
+ qDebug() << "request stock data:" << query;
+ QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query)));
+ connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64)));
+ }
+}
+
+void StockModel::update(QNetworkReply *reply)
+{
+ _updating = false;
+
+ if (reply) {
+ if (reply->error() == QNetworkReply::NoError) {
+ beginResetModel();
+
+ foreach (StockPrice* p, _prices) {
+ p->deleteLater();
+ }
+
+ _prices.clear();
+
+ while (!reply->atEnd()) {
+ QString line = reply->readLine();
+ QStringList fields = line.split(',');
+
+ //data format:Date,Open,High,Low,Close,Volume,Adjusted close price
+ //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88
+ if (fields.size() == 7) {
+ StockPrice* price = new StockPrice(this);
+ price->setDate(QDate::fromString(fields[0], Qt::ISODate));
+ price->setOpenPrice(fields[1].toFloat());
+ price->setHighPrice(fields[2].toFloat());
+ price->setLowPrice(fields[3].toFloat());
+ price->setClosePrice(fields[4].toFloat());
+ price->setVolume(fields[5].toInt());
+ price->setAdjustedPrice(fields[6].toFloat());
+ _prices.prepend(price);
+ }
+ }
+ qDebug() << "get stock data successfully, total:" << _prices.count() << "records.";
+ } else {
+ qDebug() << "get stock data failed:" << reply->errorString();
+ }
+ reply->deleteLater();
+ endResetModel();
+ emit dataChanged(QModelIndex(), QModelIndex());
+ }
+}
+
+QVariant StockModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() > _prices.count())
+ return QVariant();
+
+ const StockPrice* price = _prices[index.row()];
+ if (role == StockModel::DateRole)
+ return price->date();
+ else if (role == StockModel::OpenPriceRole)
+ return price->openPrice();
+ else if (role == StockModel::ClosePriceRole)
+ return price->closePrice();
+ else if (role == StockModel::HighPriceRole)
+ return price->highPrice();
+ else if (role == StockModel::LowPriceRole)
+ return price->lowPrice();
+ else if (role == StockModel::AdjustedPriceRole)
+ return price->adjustedPrice();
+ else if (role == StockModel::VolumeRole)
+ return price->volume();
+ else if (role == StockModel::SectionRole)
+ return price->date().year();
+ return QVariant();
+}
+
+QString StockModel::stockName() const
+{
+ return _stockName;
+}
+void StockModel::setStockName(const QString& name)
+{
+ if (_stockName != name) {
+ _stockName = name;
+ emit stockNameChanged();
+ }
+}
+
+QDate StockModel::startDate() const
+{
+ return _startDate;
+}
+void StockModel::setStartDate(const QDate& date)
+{
+ if (_startDate.isValid() && _startDate != date) {
+ _startDate = date;
+ emit startDateChanged();
+ }
+}
+
+QDate StockModel::endDate() const
+{
+ return _endDate;
+}
+void StockModel::setEndDate(const QDate& date)
+{
+ if (_endDate.isValid() && _endDate != date) {
+ _endDate = date;
+ emit endDateChanged();
+ }
+}
+
+StockModel::StockDataCycle StockModel::dataCycle() const
+{
+ return _dataCycle;
+}
+
+QString StockModel::dataCycleString() const
+{
+ switch (_dataCycle) {
+ case StockModel::Daily:
+ return QString('d');
+ break;
+ case StockModel::Weekly:
+ return QString('w');
+ case StockModel::Monthly:
+ return QString('m');
+ case StockModel::Dividend:
+ return QString('v');
+ }
+
+ return QString('d');
+}
+
+
+void StockModel::setDataCycle(StockModel::StockDataCycle cycle)
+{
+ if (_dataCycle != cycle) {
+ _dataCycle = cycle;
+ emit dataCycleChanged();
+ }
+}
diff --git a/examples/quick/canvas/stockchart/model.h b/examples/quick/canvas/stockchart/model.h
new file mode 100644
index 0000000000..95e6f4891c
--- /dev/null
+++ b/examples/quick/canvas/stockchart/model.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QDate>
+
+class StockPrice : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDate date READ date)
+ Q_PROPERTY(qreal openPrice READ openPrice)
+ Q_PROPERTY(qreal closePrice READ closePrice)
+ Q_PROPERTY(qreal highPrice READ highPrice)
+ Q_PROPERTY(qreal lowPrice READ lowPrice)
+ Q_PROPERTY(qint32 volume READ volume)
+ Q_PROPERTY(qreal adjustedPrice READ adjustedPrice)
+public:
+
+ StockPrice(QObject *parent = 0)
+ : QObject(parent)
+ , _openPrice(-1)
+ , _closePrice(-1)
+ , _highPrice(-1)
+ , _lowPrice(-1)
+ , _volume(-1)
+ , _adjustedPrice(-1)
+ {
+ }
+ QDate date() const {return _date;}
+ qreal openPrice() const {return _openPrice; }
+ qreal closePrice() const {return _closePrice;}
+ qreal highPrice() const {return _highPrice;}
+ qreal lowPrice() const{return _lowPrice;}
+ qreal adjustedPrice() const{return _adjustedPrice;}
+ qint32 volume() const{return _volume;}
+
+ void setDate(const QDate& date){_date = date;}
+ void setOpenPrice(qreal price){_openPrice = price;}
+ void setClosePrice(qreal price){_closePrice = price;}
+ void setHighPrice(qreal price){_highPrice = price;}
+ void setLowPrice(qreal price){_lowPrice = price;}
+ void setAdjustedPrice(qreal price) {_adjustedPrice = price;}
+ void setVolume(qint32 volume) {_volume = volume;}
+
+private:
+ QDate _date;
+ qreal _openPrice;
+ qreal _closePrice;
+ qreal _highPrice;
+ qreal _lowPrice;
+ qint32 _volume;
+ qreal _adjustedPrice;
+};
+
+class QNetworkReply;
+class QNetworkAccessManager;
+class StockModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged)
+ Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged)
+ Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged)
+ Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged)
+
+ Q_ENUMS(StockDataCycle)
+public:
+ enum StockDataCycle {
+ Daily,
+ Weekly,
+ Monthly,
+ Dividend
+ };
+
+ enum StockModelRoles {
+ DateRole = Qt::UserRole + 1,
+ SectionRole,
+ OpenPriceRole,
+ ClosePriceRole,
+ HighPriceRole,
+ LowPriceRole,
+ VolumeRole,
+ AdjustedPriceRole
+ };
+
+ StockModel(QObject *parent = 0);
+
+ QString stockName() const;
+ void setStockName(const QString& name);
+
+ QDate startDate() const;
+ void setStartDate(const QDate& date);
+
+ QDate endDate() const;
+ void setEndDate(const QDate& date);
+
+ StockDataCycle dataCycle() const;
+ void setDataCycle(StockDataCycle cycle);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+signals:
+ void stockNameChanged();
+ void startDateChanged();
+ void endDateChanged();
+ void dataCycleChanged();
+ void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+
+public slots:
+ void requestData();
+ StockPrice* stockPriceAtIndex(int idx) const;
+private slots:
+ void doRequest();
+ void update(QNetworkReply* reply);
+private:
+ QString dataCycleString() const;
+ QList<StockPrice*> _prices;
+ QString _stockName;
+ QDate _startDate;
+ QDate _endDate;
+ StockDataCycle _dataCycle;
+ QNetworkAccessManager* _manager;
+ bool _updating;
+};
+
+
+
+
diff --git a/examples/quick/canvas/stockchart/plugin.cpp b/examples/quick/canvas/stockchart/plugin.cpp
new file mode 100644
index 0000000000..3b354e2b31
--- /dev/null
+++ b/examples/quick/canvas/stockchart/plugin.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtQml/qqml.h>
+#include <QtGui/QGuiApplication>
+#include "model.h"
+
+class QStockChartExampleQmlPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample"));
+ qmlRegisterType<StockModel>(uri, 1, 0, "StockModel");
+ qmlRegisterType<StockPrice>(uri, 1, 0, "StockPrice");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin);
diff --git a/examples/quick/canvas/stockchart/stock.qml b/examples/quick/canvas/stockchart/stock.qml
new file mode 100644
index 0000000000..1c95fde2ce
--- /dev/null
+++ b/examples/quick/canvas/stockchart/stock.qml
@@ -0,0 +1,726 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import com.nokia.StockChartExample 1.0
+import "../contents"
+
+Rectangle {
+ id:container
+ width: 360; height: 600
+ color: "#343434";
+ Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 }
+
+
+ TitleBar {
+ id: titleBar
+ width: parent.width
+ anchors.top : container.top
+ height: 40
+ opacity: 0.9
+ }
+
+ StockModel {
+ id:stockModel
+ dataCycle: StockModel.Daily
+ function dataCycleName() {
+ if (dataCycle === StockModel.Weekly)
+ return "Weekly";
+ else if (dataCycle === StockModel.Monthly)
+ return "Monthly";
+ return "Daily";
+ }
+
+ onDataChanged: {
+ if (view.viewType == "chart") {
+ canvas.requestPaint();
+ }
+ }
+ onDownloadProgress: {
+ if (bytesReceived == bytesTotal && bytesTotal != -1) {
+ progress.opacity = 0;
+ } else {
+ progress.opacity = 0.8;
+ progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB";
+ }
+ }
+
+ property string description:"";
+ }
+
+ Stocks {id:stocks}
+
+ Rectangle {
+ id: header
+ width: parent.width
+ height: 20
+ color: "steelblue"
+ opacity: 0
+ Row {
+ spacing: 2
+ Text {
+ id:t
+ font.pointSize:15
+ horizontalAlignment:Text.AlignHCenter
+ font.bold: true
+ font.underline:true
+ }
+ Rectangle {
+ height:20
+ width:50
+ Text {text:"Stock list"; font.pointSize:15; font.bold: true}
+ }
+ }
+ }
+
+ ListView {
+ id:stockList
+ width: parent.width
+ anchors.bottom: container.bottom
+ anchors.top : titleBar.bottom
+ focus: true
+ keyNavigationWraps: true
+ spacing:1
+ opacity: 1
+ model: stocks
+
+ Component.onCompleted: opacity = 0.9;
+ onOpacityChanged: {
+ titleBar.title = "Top 100 NASDAQ stocks"
+ }
+
+
+ delegate : Rectangle {
+ height: 30
+ width: view.width
+ color: {
+ if (ListView.isCurrentItem)
+ return focus ? "lightyellow" : "pink";
+ return index % 2 == 0 ? "lightblue" : "lightsteelblue"
+ }
+ Text {
+ font.pointSize:20
+ text: index + ". " + stockId + " \t(" + name + ")";
+ }
+ MouseArea {
+ anchors.fill: parent;
+ onDoubleClicked: {
+ stockList.opacity = 0;
+ stockModel.stockName = stockId;
+ stockModel.description = "NASDAQ:" + stockId + " (" + name + ")";
+ view.opacity = 1;
+ view.viewType = "chart";
+ canvas.opacity = 0.7;
+ }
+ onClicked: stockList.currentIndex = index
+ }//mousearea
+ }//delegate
+ }
+
+ ListView {
+ id:view
+ width: container.width
+ height: container.height - 50
+ anchors.bottom: container.bottom
+ focus: true
+ keyNavigationWraps: true
+
+ spacing:1
+ opacity: 0
+ model: stockModel
+ highlightFollowsCurrentItem: false
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin:50
+ preferredHighlightEnd : height - 50
+ highlight: listHighlight
+
+ //header : Text {}
+ delegate: listDelegate
+ snapMode: ListView.SnapToItem
+
+ property string viewType : "list"
+ property int topIndex:indexAt(0,contentY);
+ property int bottomIndex:indexAt(0, contentY+height);
+
+ onCountChanged: {
+
+ titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " +
+ Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() +
+ " records:" + view.count;
+
+ }
+
+ Component {
+ id: listDelegate
+ Rectangle {
+ height: 20
+ width: view.width
+ border.color: "lightsteelblue"
+ border.width: 1
+ color: {
+ if (ListView.isCurrentItem)
+ return focus ? "lightyellow" : "pink";
+
+ return index % 2 == 0 ? "lightblue" : "lightsteelblue"
+ }
+ Text {
+ font.pointSize:13
+ text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd")
+ + "\t " + Math.round(openPrice*100)/100
+ + "\t " + Math.round(highPrice*100)/100
+ + "\t " + Math.round(lowPrice*100)/100
+ + "\t " + Math.round(closePrice*100)/100
+ + "\t " + volume + "\t "
+ + Math.round(adjustedPrice*100)/100;
+ }
+ MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index}
+ }
+ }
+
+ Component {
+ id: chartDelegate
+ Rectangle {
+ height: 20
+ width: view.width/view.count * canvas.scaleX
+ border.color: "lightsteelblue"
+ border.width: 1
+ color: {
+ if (ListView.isCurrentItem)
+ return focus ? "lightyellow" : "pink";
+
+ return index % 2 == 0 ? "lightblue" : "lightsteelblue"
+ }
+
+ Text {
+ anchors.bottom: parent.bottom
+ font.pointSize: {
+ if (parent.width <= 4)
+ return 1;
+ if (parent.width <= 50)
+ return parent.width/4;
+ return 15;
+ }
+ horizontalAlignment:Text.AlignHCenter
+ verticalAlignment:Text.AlignBottom
+ text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : ""
+ }
+ MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index}
+ }
+ }
+
+ Component {
+ id:chartHighlight
+ Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" }
+ }
+
+ Component {
+ id:listHighlight
+ Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" }
+ }
+
+
+
+
+ onViewTypeChanged : {
+ if (viewType == "list") {
+ view.orientation = ListView.Vertical;
+ view.delegate = listDelegate;
+// view.section.property = "year";
+// view.section.criteria = ViewSection.FullString;
+// view.section.delegate = sectionHeading;
+ view.highlight = listHighlight;
+ view.opacity = 1;
+ canvas.opacity = 0;
+ // comment.opacity = 0;
+
+ } else if (viewType == "chart") {
+ view.orientation = ListView.Horizontal;
+ view.delegate = chartDelegate;
+ //comment.opacity = 0.6;
+
+ view.opacity = 1;
+ view.height = 30
+
+ canvas.opacity = 0.7;
+ canvas.requestPaint();
+ } else {
+ viewType = "list";
+ }
+ }
+
+
+ onCurrentIndexChanged: {
+ //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex));
+ if (viewType == "chart") {
+ canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX);
+ canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX);
+
+ canvas.requestPaint();
+ }
+ }
+ onContentYChanged: { // keep "current" item visible
+ topIndex = indexAt(0,contentY);
+ bottomIndex = indexAt(0, contentY+height);
+
+ if (topIndex != -1 && currentIndex <= topIndex)
+ currentIndex = topIndex+1;
+ else if (bottomIndex != -1 && currentIndex >= bottomIndex)
+ currentIndex = bottomIndex-1;
+ if (viewType == "chart")
+ canvas.requestPaint();
+ }
+
+ onContentXChanged: { // keep "current" item visible
+ topIndex = indexAt(contentX,0);
+ bottomIndex = indexAt(contentX+width, 0);
+
+ if (topIndex != -1 && currentIndex <= topIndex)
+ currentIndex = topIndex+1;
+ else if (bottomIndex != -1 && currentIndex >= bottomIndex)
+ currentIndex = bottomIndex-1;
+ if (viewType == "chart")
+ canvas.requestPaint();
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onDoubleClicked: {
+ if (view.viewType == "list")
+ view.viewType = "chart";
+ else
+ view.viewType = "list";
+ }
+ }
+ }
+
+
+
+ Canvas {
+ id:canvas
+ anchors.top : titleBar.bottom
+ anchors.bottom : view.top
+ width:container.width;
+ opacity:0
+ renderTarget: Canvas.Image
+ renderStrategy: Canvas.Immediate
+ property bool running:false
+ property int frames:first
+ property int mouseX:0;
+ property int mouseY:0;
+ property int mousePressedX:0;
+ property int mousePressedY:0;
+ property int movedY:0
+ property real scaleX:1.0;
+ property real scaleY:1.0;
+ property int first:0;
+ property int last:view.count - 1;
+
+ onOpacityChanged: {
+ if (opacity > 0)
+ requestPaint();
+ }
+ Text {
+ id:comment
+ x:100
+ y:50
+ font.pointSize: 20
+ color:"white"
+ opacity: 0.7
+ focus:false
+ text: stockModel.description
+ function updateCurrent(price)
+ {
+ if (price !== undefined) {
+ text =stockModel.description + "\n"
+ + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:"
+ + Math.round(price.openPrice*100)/100 + " HIGH:"
+ + Math.round(price.highPrice*100)/100 + " LOW:"
+ + Math.round(price.lowPrice*100)/100 + " CLOSE:"
+ + Math.round(price.closePrice*100)/100 + " VOLUME:"
+ + price.volume;
+ }
+ }
+ }
+
+ Text {
+ id:priceAxis
+ x:25
+ y:25
+ font.pointSize: 15
+ color:"yellow"
+ opacity: 0.7
+ focus: false
+ }
+ Text {
+ id:volumeAxis
+ x:canvas.width - 200
+ y:25
+ font.pointSize: 15
+ color:"yellow"
+ opacity: 0.7
+ }
+
+ Rectangle {
+ id:progress
+ x:canvas.width/2 - 100
+ y:canvas.height/2
+ width:childrenRect.width
+ height: childrenRect.height
+ opacity: 0
+ color:"white"
+ property string text;
+ Text {
+ text:parent.text
+ font.pointSize: 20
+ }
+ }
+
+ Button {
+ id:runButton
+ text:"Run this chart"
+ y:0
+ x:canvas.width/2 - 50
+ opacity: 0.5
+ onClicked: {
+ if (canvas.running) {
+ canvas.running = false;
+ canvas.frames = canvas.first;
+ canvas.requestPaint();
+ text = "Run this chart";
+ comment.text = stockModel.description;
+ } else {
+ text = " Stop running ";
+ canvas.runChart();
+ }
+ }
+ }
+ Button {
+ id:returnButton
+ text:"Stocks"
+ y:0
+ anchors.left : runButton.right
+ anchors.leftMargin : 20
+ opacity: 0.5
+ onClicked: {
+ stockList.opacity = 1;
+ canvas.opacity = 0;
+ }
+ }
+ PinchArea {
+ anchors.fill: parent
+ onPinchUpdated : {
+ var current = pinch.center;
+ var scale = pinch.scale;
+ console.log("center:" + pinch.center + " scale:" + pinch.scale);
+ //canvas.requestPaint();
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onDoubleClicked: {
+ if (stockModel.dataCycle == StockModel.Daily)
+ stockModel.dataCycle = StockModel.Weekly;
+ else if (stockModel.dataCycle == StockModel.Weekly)
+ stockModel.dataCycle = StockModel.Monthly;
+ else
+ stockModel.dataCycle = StockModel.Daily;
+ }
+
+ onPositionChanged: {
+ if (mouse.modifiers & Qt.ControlModifier) {
+ if (canvas.mouseX == 0 && canvas.mouseY == 0) {
+ canvas.mouseX = mouse.x;
+ canvas.mouseY = mouse.y;
+ }
+ } else{
+ var w = (view.width/view.count)*canvas.scaleX;
+
+ //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2);
+
+ var movedX = Math.round((canvas.mousePressedX - mouse.x)/w);
+ if (movedX != 0 || canvas.movedY != 0) {
+ if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) {
+ canvas.first += movedX;
+ canvas.last += movedX;
+ }
+ canvas.requestPaint();
+ }
+ }
+ }
+
+ onPressed: {
+ canvas.mousePressedX = mouse.x;
+ canvas.mousePressedY = mouse.y;
+ }
+
+ onReleased : {
+ if (mouse.modifiers & Qt.ControlModifier) {
+ var sx = mouse.x - canvas.mouseX;
+ var sy = canvas.mouseY - mouse.y;
+
+ if (Math.abs(sx) < 50) sx = 0;
+ if (Math.abs(sy) < 50) sy = 0;
+
+ if (sx > 0)
+ canvas.scaleX *= sx/100 +1;
+ else
+ canvas.scaleX *= 1/(-sx/100 + 1);
+
+ if (sy > 0)
+ canvas.scaleY *= sy/100 +1;
+ else
+ canvas.scaleY *= 1/(-sy/100 + 1);
+
+ if (canvas.scaleX < 1)
+ canvas.scaleX = 1;
+
+ //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY);
+
+ canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX);
+ canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX);
+
+ canvas.mouseX = 0;
+ canvas.mouseY = 0;
+ canvas.mousePressedX = 0;
+ canvas.mousePressedY = 0;
+ canvas.requestPaint();
+ }
+ }
+ }
+
+ function runChart() {
+ canvas.running = true;
+ requestPaint();
+ }
+
+ function showPriceAt(x) {
+ var w = (view.width/view.count)*canvas.scaleX;
+ //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w)));
+ //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w)));
+ }
+
+ function drawPrice(ctx, from, to, color, price, points, highest)
+ {
+ ctx.globalAlpha = 0.7;
+ ctx.strokeStyle = color;
+ ctx.lineWidth = 1;
+ ctx.beginPath();
+
+ //price x axis
+ priceAxis.text = "price:" + Math.round(highest);
+ ctx.font = "bold 12px sans-serif";
+
+ ctx.strokeText("price", 25, 25);
+ for (var j = 1; j < 30; j++) {
+ var val = (highest * j) / 30;
+ val = canvas.height * (1 - val/highest);
+ ctx.beginPath();
+
+ ctx.moveTo(10, val);
+ if (j % 5)
+ ctx.lineTo(15, val);
+ else
+ ctx.lineTo(20, val);
+ ctx.stroke();
+ }
+
+ ctx.beginPath();
+ ctx.moveTo(10, 0);
+ ctx.lineTo(10, canvas.height);
+ ctx.stroke();
+
+
+ var w = canvas.width/points.length;
+ var end = canvas.running? canvas.frames - canvas.first :points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y += canvas.movedY;
+
+ y = canvas.height * (1 - y/highest);
+ if (i == 0) {
+ ctx.moveTo(x+w/2, y);
+ } else {
+ ctx.lineTo(x+w/2, y);
+ }
+ }
+ ctx.stroke();
+ }
+
+ function drawKLine(ctx, from, to, points, highest)
+ {
+ ctx.globalAlpha = 0.4;
+ ctx.lineWidth = 2;
+ var end = canvas.running? canvas.frames - canvas.first :points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY;
+ var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY;
+ var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY;
+ var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY;
+
+ var top, bottom;
+ if (close <= open) {
+ ctx.fillStyle = Qt.rgba(1, 0, 0, 1);
+ ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
+ top = close;
+ bottom = open;
+ } else {
+ ctx.fillStyle = Qt.rgba(0, 1, 0, 1);
+ ctx.strokeStyle = Qt.rgba(0, 1, 0, 1);
+ top = open;
+ bottom = close;
+ }
+
+ var w1, w2;
+ w1 = canvas.width/points.length;
+ w2 = w1 > 10 ? w1/2 : w1;
+
+ ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top);
+ ctx.beginPath();
+ ctx.moveTo(x+w1/2, high);
+ ctx.lineTo(x+w1/2, low);
+ ctx.stroke();
+ }
+ ctx.globalAlpha = 1;
+
+ }
+
+ function drawVolume(ctx, from, to, color, price, points, highest)
+ {
+ ctx.fillStyle = color;
+ ctx.globalAlpha = 0.6;
+ ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1);
+ ctx.lineWidth = 1;
+
+ //volume x axis
+ volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M";
+ for (var j = 1; j < 30; j++) {
+ var val = (highest * j) / 30;
+ val = canvas.height * (1 - val/highest);
+ ctx.beginPath();
+ if (j % 5)
+ ctx.moveTo(canvas.width - 15, val);
+ else
+ ctx.moveTo(canvas.width - 20, val);
+ ctx.lineTo(canvas.width - 10, val);
+ ctx.stroke();
+ }
+
+ ctx.beginPath();
+ ctx.moveTo(canvas.width - 10, 0);
+ ctx.lineTo(canvas.width - 10, canvas.height);
+ ctx.stroke();
+
+ var end = canvas.running? canvas.frames - canvas.first :points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y = canvas.height * (1 - y/highest);
+ ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y);
+ }
+ }
+/*
+ onPainted : {
+ if (canvas.running) {
+ if (frames >= last) {
+ canvas.running = false;
+ canvas.frames = first;
+ runButton.text = "Run this chart";
+ comment.text = stockModel.description;
+ requestPaint();
+ } else {
+ frames += Math.round(view.count / 100);
+ if (frames > last) frames = last;
+ var price = stockModel.stockPriceAtIndex(frames);
+ if (price) {
+ comment.updateCurrent(price);
+ }
+
+ requestPaint();
+ }
+ }
+ }
+*/
+ onPaint: {
+ if (view.currentIndex <= 0)
+ first = 0;
+ if (last >= view.count)
+ last = view.count - 1;
+
+ //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex);
+ var ctx = canvas.getContext("2d");
+ ctx.save();
+
+ ctx.globalCompositeOperation = "source-over";
+ ctx.lineWidth = 1;
+ ctx.lineJoin = "round";
+ ctx.fillStyle = "rgba(0,0,0,0)";
+
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+
+
+ var highestPrice = 500/canvas.scaleY;
+ var highestValume = 600 * 1000 * 1000/canvas.scaleY;
+ var points = [];
+ for (var i = 0; i <= last - first; i++) {
+ var price = stockModel.stockPriceAtIndex(i + first);
+ points.push({
+ x: i*canvas.width/(last-first+1),
+ open: price.openPrice,
+ close: price.closePrice,
+ high:price.highPrice,
+ low:price.lowPrice,
+ volume:price.volume
+ });
+ }
+
+ drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice);
+ drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice);
+ drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice);
+ drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice);
+ drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume);
+ drawKLine(ctx, first, last, points, highestPrice);
+ ctx.restore();
+ }
+ }
+}
diff --git a/examples/quick/canvas/stockchart/stockchart.pro b/examples/quick/canvas/stockchart/stockchart.pro
new file mode 100644
index 0000000000..e368746db5
--- /dev/null
+++ b/examples/quick/canvas/stockchart/stockchart.pro
@@ -0,0 +1,20 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml network
+
+DESTDIR = com/nokia/StockChartExample
+TARGET = qmlstockchartexampleplugin
+
+SOURCES += model.cpp plugin.cpp
+HEADERS += model.h
+qdeclarativesources.files += \
+ com/nokia/StockChartExample/qmldir \
+ stock.qml
+
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample
+
+sources.files += stockchart.pro model.h model.cpp plugin.cpp README
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample
+
+INSTALLS += qdeclarativesources sources target
diff --git a/examples/quick/canvas/tiger/tiger.js b/examples/quick/canvas/tiger/tiger.js
new file mode 100644
index 0000000000..4be0d26c9d
--- /dev/null
+++ b/examples/quick/canvas/tiger/tiger.js
@@ -0,0 +1,721 @@
+var tiger = [
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.172,
+ "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000",
+ "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"}
+ ,
+ {"fill": "#cc7226", "stroke":"#000000",
+ "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"}
+ ,
+ {"fill": "#e87f3a",
+ "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"}
+ ,
+ {"fill": "#ea8c4d",
+ "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"}
+ ,
+ {"fill": "#ec9961",
+ "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"}
+ ,
+ {"fill": "#eea575",
+ "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"}
+ ,
+ {"fill": "#f1b288",
+ "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"}
+ ,
+ {"fill": "#f3bf9c",
+ "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"}
+ ,
+ {"fill": "#f5ccb0",
+ "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"}
+ ,
+ {"fill": "#f8d8c4",
+ "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"}
+ ,
+ {"fill": "#fae5d7",
+ "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"}
+ ,
+ {"fill": "#fcf2eb",
+ "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"}
+ ,
+ {"fill": "#e5668c",
+ "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"}
+ ,
+ {"fill": "#b23259",
+ "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"}
+ ,
+ {"fill": "#a5264c",
+ "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"}
+ ,
+ {"fill": "#ff727f", "stroke":"#000000",
+ "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"}
+ ,
+ {"fill": "#cc3f4c",
+ "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"}
+ ,
+ {"stroke":"#a51926", "width":2,
+ "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"}
+ ,
+ {"stroke":"#a5264c", "width":2,
+ "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"}
+ ,
+ {"fill": "#b2b2b2",
+ "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"}
+ ,
+ {"fill": "#ffffcc", "stroke":"#000000", "width":0.5,
+ "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"}
+ ,
+ {"fill": "#e5e5b2",
+ "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"}
+ ,
+ {"fill": "#e5e5b2",
+ "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"}
+ ,
+ {"fill": "#ea8e51",
+ "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"}
+ ,
+ {"fill": "#efaa7c",
+ "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"}
+ ,
+ {"fill": "#f4c6a8",
+ "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"}
+ ,
+ {"fill": "#f9e2d3",
+ "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"}
+ ,
+ {"fill": "#659900",
+ "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"}
+ ,
+ {"fill": "#000000",
+ "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"}
+ ,
+ {"fill": "#eb955c",
+ "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"}
+ ,
+ {"fill": "#f2b892",
+ "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"}
+ ,
+ {"fill": "#f8dcc8",
+ "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"}
+ ,
+ {"fill": "#000000",
+ "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"}
+ ,
+ {"fill": "#000000",
+ "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"}
+ ,
+ {"fill": "#323232",
+ "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"}
+ ,
+ {"fill": "#666666",
+ "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"}
+ ,
+ {"fill": "#999999",
+ "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"}
+ ,
+ {"fill": "#992600",
+ "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"}
+ ,
+ {"fill": "#000000",
+ "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"}
+ ,
+ {"fill": "#cc7226",
+ "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"}
+ ,
+ {"fill": "#000000",
+ "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"}
+ ,
+ {"stroke":"#4c0000", "width":2,
+ "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"}
+ ,
+ {"fill": "#000000",
+ "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"}
+ ,
+ {"fill": "#4c0000",
+ "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"}
+ ,
+ {"fill": "#99cc32",
+ "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"}
+ ,
+ {"fill": "#659900",
+ "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-65.4 9z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"}
+ ,
+ {"fill": "#e59999",
+ "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"}
+ ,
+ {"fill": "#b26565",
+ "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"}
+ ,
+ {"fill": "#000000",
+ "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"}
+ ,
+ {"fill": "#000000",
+ "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"}
+ ,
+ {"fill": "#000000",
+ "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"}
+ ,
+ {"fill": "#000000",
+ "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"}
+ ,
+ {"fill": "#ffffff",
+ "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"}
+ ,
+ {"fill": "#000000",
+ "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"}
+ ,
+ {"fill": "#000000",
+ "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"}
+ ,
+ {"fill": "#000000",
+ "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"}
+ ,
+ {"fill": "#000000",
+ "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"}
+ ,
+ {"fill": "#992600",
+ "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"}
+ ,
+ {"fill": "#000000",
+ "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"}
+ ,
+ {"fill": "#000000",
+ "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"}
+ ,
+ {"fill": "#000000",
+ "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"}
+ ,
+ {"fill": "#000000",
+ "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"}
+ ,
+ {"fill": "#000000",
+ "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"}
+ ,
+ {"fill": "#000000",
+ "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"}
+ ,
+ {"fill": "#000000",
+ "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"}
+ ,
+ {"fill": "#000000",
+ "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"}
+ ,
+ {"fill": "#000000",
+ "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"}
+ ,
+ {"fill": "#ffffff", "stroke":"#000000", "width":0.1,
+ "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"}
+ ,
+ {"fill": "#000000",
+ "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"}
+ ,
+ {"fill": "#cccccc",
+ "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-89.25 169L-67.25 173.75"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"}
+ ,
+ {"stroke":"#000000",
+ "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"}
+ ,
+ {"stroke":"#000000",
+ "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"}
+]; \ No newline at end of file
diff --git a/examples/quick/canvas/tiger/tiger.qml b/examples/quick/canvas/tiger/tiger.qml
new file mode 100644
index 0000000000..2eb1bb2106
--- /dev/null
+++ b/examples/quick/canvas/tiger/tiger.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+import "tiger.js" as Tiger
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.FramebufferObject
+ renderStrategy: Canvas.Cooperative
+ property string strokeStyle:"steelblue"
+ property string fillStyle:"yellow"
+ property bool fill:true
+ property bool stroke:true
+ property real alpha:alphaCtrl.value
+ property real scaleX : scaleXCtrl.value
+ property real scaleY : scaleYCtrl.value
+ property real rotate : rotateCtrl.value
+ property int frame:0
+
+ onFillChanged: requestPaint();
+ onStrokeChanged: requestPaint();
+ onAlphaChanged: requestPaint();
+ onScaleXChanged: requestPaint();
+ onScaleYChanged: requestPaint();
+ onRotateChanged: requestPaint();
+
+ onPainted : {
+ canvas.frame++;
+ if (canvas.frame < Tiger.tiger.length)
+ requestPaint();
+ }
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.scale(canvas.scaleX, canvas.scaleY);
+ ctx.rotate(canvas.rotate);
+ ctx.globalCompositeOperation = "source-over";
+ ctx.translate(canvas.width/2, canvas.height/2);
+ ctx.strokeStyle = Qt.rgba(.3, .3, .3,1);
+ ctx.lineWidth = 1;
+
+
+ for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) {
+ if (Tiger.tiger[i].width != undefined)
+ ctx.lineWidth = Tiger.tiger[i].width;
+
+ if (Tiger.tiger[i].path != undefined)
+ ctx.path = Tiger.tiger[i].path;
+
+ if (Tiger.tiger[i].fill != undefined) {
+ ctx.fillStyle = Tiger.tiger[i].fill;
+ ctx.fill();
+ }
+
+ if (Tiger.tiger[i].stroke != undefined) {
+ ctx.strokeStyle = Tiger.tiger[i].stroke;
+ ctx.stroke();
+ }
+ }
+ ctx.restore();
+ }
+ }
+ Rectangle {
+ id:controls
+ width:360
+ height:160
+ Column {
+ spacing:3
+ Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"}
+ Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"}
+ Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"}
+ }
+ }
+ }
+}
diff --git a/examples/quick/canvas/twitterfriends/TwitterUser.qml b/examples/quick/canvas/twitterfriends/TwitterUser.qml
new file mode 100644
index 0000000000..8b906216ef
--- /dev/null
+++ b/examples/quick/canvas/twitterfriends/TwitterUser.qml
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id:twitterUser
+ property variant friends : [];
+ property string name : "";
+ property string twitterId : "";
+ property string image : "";
+ property string url : "";
+ property string desc : "";
+ width : 0;
+ height : 0;
+ property int posX:0;
+ property int posY:0;
+ property bool hasFocus : false;
+ property variant canvas;
+ property variant manager;
+ property variant linkColor;
+ property bool selected : false;
+
+ Rectangle {
+ id:twitterStatus
+ x:twitterUser.width
+ y:twitterUser.height
+ width:250
+ height:60
+ opacity: 0
+ border.color:"steelblue"
+ border.width:3
+ Column {
+ spacing:2
+ Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere}
+ Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere}
+ }
+ }
+
+ function moved() {
+ twitterUser.posX = twitterUser.x;
+ twitterUser.posY = twitterUser.y;
+ twitterUser.canvas.requestPaint();
+ }
+
+ onXChanged: moved();
+ onYChanged: moved();
+
+ MouseArea {
+ anchors.fill:parent
+ drag.target : twitterUser
+ drag.axis : Drag.XandYAxis
+
+ onClicked: {
+ if (!twitterUser.selected) {
+ twitterUser.selected = true;
+ twitterStatus.opacity = 1;
+ twitterStatus.visible = true;
+ } else {
+ twitterUser.selected = false;
+ twitterStatus.opacity = 0;
+ }
+ }
+
+ onDoubleClicked : {
+ twitterStatus.opacity = 0;
+ twitterUser.selected = false;
+ twitterUser.hasFocus = true;
+ twitterUser.canvas.twitterName = twitterUser.name;
+ twitterUser.canvas.twitterId = twitterUser.twitterId;
+ twitterUser.canvas.loading = true;
+ twitterUser.createFriends();
+ }
+ }
+
+ function show(ctx, layoutChanged) {
+ var w = canvas.width;
+ var h = canvas.height;
+ if (twitterUser.hasFocus) {
+ twitterUser.width = 60
+ twitterUser.height = 60
+ twitterUser.posX = w/2;
+ twitterUser.posY = h/2;
+ } else {
+ twitterUser.width = 40
+ twitterUser.height = 40
+ }
+
+
+ if (twitterUser.hasFocus) {
+ if (layoutChanged)
+ twitterUser.layoutFriends();
+ twitterUser.linkFriends(ctx);
+ twitterUser.showFriends(ctx);
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowBlur = 7;
+ ctx.shadowColor = "blue";
+ ctx.globalAlpha = 1;
+ } else {
+ ctx.shadowOffsetX = 5;
+ ctx.shadowOffsetY = 5;
+ ctx.shadowBlur = 7;
+ ctx.shadowColor = twitterUser.linkColor;
+ ctx.globalAlpha = 0.6;
+ }
+
+ if (twitterUser.canvas.isImageLoaded(twitterUser.image)) {
+ ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height);
+ }
+// ctx.font = "15px";
+// var nameSize = ctx.measureText(twitterUser.name).width;
+// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10);
+ }
+ function dump() {
+ console.log("name:" + twitterUser.name
+ + " x:" + twitterUser.posX
+ + " y:" + twitterUser.posY
+ + " width:" + twitterUser.width
+ + " height:" + twitterUser.height
+ + " id:" + twitterUser.twitterId
+ + " image:" + twitterUser.image
+ + " url:" + twitterUser.url + "\n" + twitterUser.desc);
+ }
+
+ function layoutFriends() {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend) {
+ friend.x = Math.random() *w;
+ friend.y = Math.random() *h;
+ }
+ }
+ }
+
+ function showFriends(ctx) {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
+ friend.hasFocus = false;
+ friend.show(ctx, false);
+ }
+ }
+ }
+
+ function linkFriends(ctx) {
+ var w = canvas.width;
+ var h = canvas.height;
+ for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
+ if (!friend.linkColor)
+ friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255
+ , ((Math.random() * 200) +55)/255
+ , ((Math.random() * 200) +55)/255, 0.8);
+ ctx.strokeStyle = friend.linkColor;
+ ctx.lineWidth = 8;
+ ctx.beginPath();
+ ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2);
+ ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2);
+ ctx.stroke();
+ }
+ }
+ }
+
+
+ function create(url) {
+ var x = new XMLHttpRequest;
+ x.open("GET", url);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ var user = eval('(' + x.responseText +')')[0];
+ twitterUser.name = user.name;
+ twitterUser.twitterId = user.id;
+ twitterUser.image = user.profile_image_url;
+ twitterUser.canvas.loadImage(twitterUser.image);
+ twitterUser.url = user.url;
+ twitterUser.desc = user.description;
+ twitterUser.createFriends();
+ }
+ }
+ x.send();
+ }
+
+ function createByName(name) {
+ if (twitterUser.name === "" && twitterUser.twitterId === "") {
+ twitterUser.name = name;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name;
+ twitterUser.create(userUrl);
+ }
+ }
+
+ function createById(id) {
+ if (twitterUser.name === "" && twitterUser.twitterId === "") {
+ twitterUser.twitterId = id;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id;
+ twitterUser.create(userUrl);
+ }
+ }
+
+ function createFriends() {
+ if (twitterUser.friends.length === 0) {
+ var x = new XMLHttpRequest;
+ var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId;
+ x.open("GET", friendsUrl);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ twitterUser.friends = eval('(' + x.responseText +')').ids;
+ var doRequest = false;
+ var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=";
+
+ for (var i=0; i<twitterUser.friends.length && i < 100; i++) {
+ var friend = manager.getById(twitterUser.friends[i]);
+ if (!friend) {
+ userUrl += "," + twitterUser.friends[i];
+ doRequest = true;
+ }
+ }
+
+ if (!doRequest) return;
+
+ var xx = new XMLHttpRequest;
+ xx.open("GET", userUrl);
+ xx.onreadystatechange = function() {
+ if (xx.readyState == XMLHttpRequest.DONE) {
+ var friendUsers = eval('(' + xx.responseText +')');
+ for(var i=0; i<friendUsers.length; i++) {
+ var friend = manager.createTwitterUser(twitterUser.canvas);
+ friend.name = friendUsers[i].name;
+ friend.twitterId = friendUsers[i].id;
+ friend.image = friendUsers[i].profile_image_url ? friendUsers[i].profile_image_url : "";
+ friend.url = friendUsers[i].url ? friendUsers[i].url : "";
+ friend.desc = friendUsers[i].description ? friendUsers[i].description : "";
+ friend.manager = twitterUser.manager;
+ twitterUser.canvas.loadImage(friend.image);
+ }
+
+ if (twitterUser.hasFocus && twitterUser.canvas) {
+ twitterUser.canvas.layoutChanged = true;
+ twitterUser.canvas.loading = false;
+ twitterUser.canvas.requestPaint();
+ }
+ }
+ }
+ xx.send();
+ }
+ }
+ x.send();
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/quick/canvas/twitterfriends/cache.js b/examples/quick/canvas/twitterfriends/cache.js
new file mode 100644
index 0000000000..6c8a1cd71a
--- /dev/null
+++ b/examples/quick/canvas/twitterfriends/cache.js
@@ -0,0 +1,42 @@
+var UserCache = function() {
+ this._users = [];
+}
+
+
+UserCache.prototype.getById = function(id){
+ for (var i=0; i < this._users.length; i++){
+ var user = this._users[i];
+ if (user.twitterId == id) {
+ return user;
+ }
+ }
+}
+UserCache.prototype.getByName = function(name){
+ for (var i=0; i < this._users.length; i++){
+ var user = this._users[i];
+ if (user.name == name)
+ return user;
+ }
+}
+
+UserCache.prototype.add = function(user){
+ this._users[this._users.length] = user;
+}
+
+
+var cache = new UserCache;
+
+function getById(id) {
+ return cache.getById(id);
+}
+
+function getByName(name) {
+ return cache.getByName(name);
+}
+
+function createTwitterUser(canvas) {
+ var user = Qt.createQmlObject("import QtQuick 2.0; TwitterUser{}", canvas);
+ user.canvas = canvas;
+ cache.add(user);
+ return user;
+}
diff --git a/examples/quick/canvas/twitterfriends/twitter.qml b/examples/quick/canvas/twitterfriends/twitter.qml
new file mode 100644
index 0000000000..9dc2bcc939
--- /dev/null
+++ b/examples/quick/canvas/twitterfriends/twitter.qml
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../contents"
+import "cache.js" as TwitterUserCache
+Rectangle {
+ width:360
+ height:600
+ color:"black"
+ QtObject {
+ id:twitterManager
+ function getById(id) {
+ return TwitterUserCache.cache.getById(id);
+ }
+
+ function getByName(name) {
+ return TwitterUserCache.cache.getByName(name);
+ }
+
+ function createTwitterUser(canvas) {
+ return TwitterUserCache.createTwitterUser(canvas);
+ }
+ }
+ Rectangle {
+ id:inputContainer
+ width:parent.width-4
+ height:40
+ anchors.top:parent.top
+ anchors.topMargin:4
+ anchors.horizontalCenter:parent.horizontalCenter
+ radius:8
+ border.color:"steelblue"
+ Text {
+ text:inputName.text == "" ? "Enter your twitter name..." : ""
+ id:inputLabel
+ anchors.centerIn:parent
+ font.pointSize:12
+ opacity:.5
+ color:"steelblue"
+ }
+ TextInput {
+ id:inputName
+ anchors.centerIn:parent
+ font.pointSize : 20
+ opacity:1
+ color:"steelblue"
+ width:parent.width-6
+ height:parent.height-6
+ text:""
+ autoScroll:true
+ focus:true
+ selectByMouse:true
+ onAccepted : {canvas.twitterName = text; canvas.requestPaint();}
+ }
+ }
+ Canvas {
+ id:canvas
+ width:parent.width
+ anchors.top :inputContainer.bottom
+ anchors.bottom : parent.bottom
+ smooth:true
+ renderTarget:Canvas.Image
+ renderStrategy: Canvas.Immediate
+
+ property bool layoutChanged:true
+ property string twitterName:""
+ property string twitterId:""
+ property bool loading:false
+
+ onLoadingChanged: requestPaint();
+ onWidthChanged: { layoutChanged = true; requestPaint();}
+ onHeightChanged: { layoutChanged = true; requestPaint();}
+ onTwitterNameChanged: inputName.text = twitterName;
+ onImageLoaded:requestPaint();
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ ctx.save();
+ ctx.fillStyle="black";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ if (canvas.twitterName != "" || canvas.twitterId != "") {
+ var user = canvas.twitterId ? TwitterUserCache.getById(canvas.twitterId) : TwitterUserCache.getByName(canvas.twitterName);
+ if (!user) {
+ user = TwitterUserCache.createTwitterUser(canvas);
+ user.hasFocus = true;
+ user.manager = twitterManager;
+ user.createByName(canvas.twitterName);
+ canvas.loading = true;
+ }
+
+ if (canvas.loading) {
+ ctx.font = "40px";
+ ctx.fillStyle = "steelblue";
+ ctx.fillText("Loading...", canvas.width/2 - 80, canvas.height/2);
+ } else {
+ user.show(ctx, layoutChanged);
+ }
+ layoutChanged = false;
+ }
+ ctx.restore();
+ }
+ }
+}
diff --git a/examples/quick/draganddrop/draganddrop.pro b/examples/quick/draganddrop/draganddrop.pro
new file mode 100644
index 0000000000..3f535312e0
--- /dev/null
+++ b/examples/quick/draganddrop/draganddrop.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop
+qml.files = draganddrop.qml tiles views
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop
+INSTALLS += target qml
+
diff --git a/examples/quick/draganddrop/draganddrop.qml b/examples/quick/draganddrop/draganddrop.qml
new file mode 100644
index 0000000000..88e6d5e021
--- /dev/null
+++ b/examples/quick/draganddrop/draganddrop.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared" as Examples
+
+/*!
+ \title QtQuick Examples - Drag and Drop
+ \example qtquick/draganddrop
+ \brief This is a collection of QML drag and drop examples
+ \image qml-draganddrop-example.png
+
+ This is a collection of small QML examples relating to drag and drop functionality.
+
+ Tiles adds drag and drog to simple rectangles, which you can drag into a specific grid.
+
+ GridView adds drag and drog to a GridView, allowing you to reorder the list.
+*/
+
+Item {
+ height: 480
+ width: 320
+ Examples.LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Tiles", "", Qt.resolvedUrl("tiles/tiles.qml"));
+ addExample("GridView", "", Qt.resolvedUrl("views/gridview.qml"));
+ }
+ }
+}
diff --git a/examples/quick/draganddrop/draganddrop.qmlproject b/examples/quick/draganddrop/draganddrop.qmlproject
new file mode 100644
index 0000000000..b8b15c3444
--- /dev/null
+++ b/examples/quick/draganddrop/draganddrop.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ mainFile: "draganddrop.qml"
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/draganddrop/main.cpp b/examples/quick/draganddrop/main.cpp
new file mode 100644
index 0000000000..0d74fbfe2e
--- /dev/null
+++ b/examples/quick/draganddrop/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(draganddrop)
diff --git a/examples/quick/draganddrop/tiles/DragTile.qml b/examples/quick/draganddrop/tiles/DragTile.qml
new file mode 100644
index 0000000000..1f4a8c2bea
--- /dev/null
+++ b/examples/quick/draganddrop/tiles/DragTile.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+ property string colorKey
+
+ width: 64; height: 64
+
+ MouseArea {
+ id: mouseArea
+
+ width: 64; height: 64
+ anchors.centerIn: parent
+
+ drag.target: tile
+
+ onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root
+
+ Rectangle {
+ id: tile
+
+ width: 64; height: 64
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ color: colorKey
+
+ Drag.keys: [ colorKey ]
+ Drag.active: mouseArea.drag.active
+ Drag.hotSpot.x: 32
+ Drag.hotSpot.y: 32
+
+ Text {
+ anchors.fill: parent
+ color: "white"
+ font.pixelSize: 48
+ text: modelData + 1
+ horizontalAlignment:Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ states: State {
+ when: mouseArea.drag.active
+ ParentChange { target: tile; parent: root }
+ AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/draganddrop/tiles/DropTile.qml b/examples/quick/draganddrop/tiles/DropTile.qml
new file mode 100644
index 0000000000..98fedeb775
--- /dev/null
+++ b/examples/quick/draganddrop/tiles/DropTile.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+DropArea {
+ id: dragTarget
+
+ property string colorKey
+ property alias dropProxy: dragTarget
+
+ width: 64; height: 64
+ keys: [ colorKey ]
+
+ Rectangle {
+ id: dropRectangle
+
+ anchors.fill: parent
+ color: colorKey
+
+ states: [
+ State {
+ when: dragTarget.containsDrag
+ PropertyChanges {
+ target: dropRectangle
+ color: "grey"
+ }
+ }
+ ]
+ }
+}
diff --git a/examples/quick/draganddrop/tiles/tiles.qml b/examples/quick/draganddrop/tiles/tiles.qml
new file mode 100644
index 0000000000..0b5647bc2b
--- /dev/null
+++ b/examples/quick/draganddrop/tiles/tiles.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 320
+ height: 480
+
+ color: "black"
+
+ Grid {
+ id: redDestination
+
+ anchors.left: redSource.right; anchors.top: parent.top;
+ anchors.margins: 5
+ width: 64*3
+ height: 64*3
+ opacity: 0.5
+ columns: 3
+
+ Repeater {
+ model: 9;
+ delegate: DropTile { colorKey: "red" }
+ }
+ }
+
+ Grid {
+ anchors.right: blueSource.left; anchors.bottom: parent.bottom;
+ anchors.margins: 5
+ width: 64*3
+ height: 64*3
+
+ opacity: 0.5
+
+ columns: 3
+
+ Repeater {
+ model: 9
+ delegate: DropTile { colorKey: "blue" }
+ }
+ }
+
+ Column {
+ id: redSource
+
+ anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom
+ anchors.margins: 5
+ width: 64
+ spacing: -16
+
+ Repeater {
+ model: 9
+ delegate: DragTile { colorKey: "red" }
+ }
+ }
+ Column {
+ id: blueSource
+
+ anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom
+ anchors.margins: 5
+ width: 64
+ spacing: -16
+
+ Repeater {
+ model: 9
+ delegate: DragTile { colorKey: "blue" }
+ }
+ }
+}
diff --git a/examples/quick/draganddrop/views/gridview.qml b/examples/quick/draganddrop/views/gridview.qml
new file mode 100644
index 0000000000..b18078f48d
--- /dev/null
+++ b/examples/quick/draganddrop/views/gridview.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+GridView {
+ id: root
+ width: 320; height: 480
+ cellWidth: 80; cellHeight: 80
+
+ displaced: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad }
+ }
+
+ model: VisualDataModel {
+ id: visualModel
+ model: ListModel {
+ id: colorModel
+ ListElement { color: "blue" }
+ ListElement { color: "green" }
+ ListElement { color: "red" }
+ ListElement { color: "yellow" }
+ ListElement { color: "orange" }
+ ListElement { color: "purple" }
+ ListElement { color: "cyan" }
+ ListElement { color: "magenta" }
+ ListElement { color: "chartreuse" }
+ ListElement { color: "aquamarine" }
+ ListElement { color: "indigo" }
+ ListElement { color: "black" }
+ ListElement { color: "lightsteelblue" }
+ ListElement { color: "violet" }
+ ListElement { color: "grey" }
+ ListElement { color: "springgreen" }
+ ListElement { color: "salmon" }
+ ListElement { color: "blanchedalmond" }
+ ListElement { color: "forestgreen" }
+ ListElement { color: "pink" }
+ ListElement { color: "navy" }
+ ListElement { color: "goldenrod" }
+ ListElement { color: "crimson" }
+ ListElement { color: "teal" }
+ }
+
+ delegate: MouseArea {
+ id: delegateRoot
+
+ property int visualIndex: VisualDataModel.itemsIndex
+
+ width: 80; height: 80
+ drag.target: icon
+
+ Rectangle {
+ id: icon
+ width: 72; height: 72
+ anchors {
+ horizontalCenter: parent.horizontalCenter;
+ verticalCenter: parent.verticalCenter
+ }
+ color: model.color
+ radius: 3
+
+ Drag.active: delegateRoot.drag.active
+ Drag.source: delegateRoot
+ Drag.hotSpot.x: 36
+ Drag.hotSpot.y: 36
+
+ states: [
+ State {
+ when: icon.Drag.active
+ ParentChange {
+ target: icon
+ parent: root
+ }
+
+ AnchorChanges {
+ target: icon;
+ anchors.horizontalCenter: undefined;
+ anchors.verticalCenter: undefined
+ }
+ }
+ ]
+ }
+
+ DropArea {
+ anchors { fill: parent; margins: 15 }
+
+ onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex)
+ }
+ }
+ }
+}
diff --git a/examples/quick/imageelements/animatedsprite.qml b/examples/quick/imageelements/animatedsprite.qml
new file mode 100644
index 0000000000..337456f785
--- /dev/null
+++ b/examples/quick/imageelements/animatedsprite.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+ Rectangle {
+ anchors.fill: parent
+ color: "white"
+ }
+ AnimatedSprite {
+ id: sprite
+ width: 170
+ height: 170
+ anchors.centerIn: parent
+ source: "content/speaker.png"
+ frameCount: 60
+ frameSync: true
+ frameWidth: 170
+ frameHeight: 170
+ loops: 3
+ }
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: {
+ if (!sprite.running)
+ sprite.start();
+ if (!sprite.paused)
+ sprite.pause();
+ if ( mouse.button == Qt.LeftButton ) {
+ sprite.advance(1);
+ } else {
+ sprite.advance(-1);
+ }
+ }
+ }
+}
diff --git a/examples/quick/imageelements/borderimage.qml b/examples/quick/imageelements/borderimage.qml
new file mode 100644
index 0000000000..30120fe60d
--- /dev/null
+++ b/examples/quick/imageelements/borderimage.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: page
+ width: 320
+ height: 480
+
+ BorderImageSelector {
+ id: selector
+ curIdx: 0
+ maxIdx: 3
+ gridWidth: 240
+ flickable: mainFlickable
+ width: parent.width
+ height: 64
+ }
+
+ Flickable {
+ id: mainFlickable
+ width: parent.width
+ anchors.bottom: parent.bottom
+ anchors.top: selector.bottom
+ interactive: false //Animated through selector control
+ contentX: -120
+ Behavior on contentX { NumberAnimation {}}
+ contentWidth: 1030
+ contentHeight: 420
+ Grid {
+ anchors.centerIn: parent; spacing: 20
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200
+ source: "content/colors.png"; margin: 30
+ }
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat
+ }
+
+ MyBorderImage {
+ minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round
+ }
+ }
+ }
+}
diff --git a/examples/quick/imageelements/content/BearSheet.png b/examples/quick/imageelements/content/BearSheet.png
new file mode 100644
index 0000000000..a084bf0f1e
--- /dev/null
+++ b/examples/quick/imageelements/content/BearSheet.png
Binary files differ
diff --git a/examples/quick/imageelements/content/BorderImageSelector.qml b/examples/quick/imageelements/content/BorderImageSelector.qml
new file mode 100644
index 0000000000..f3a534b3cd
--- /dev/null
+++ b/examples/quick/imageelements/content/BorderImageSelector.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: selector
+ property int curIdx: 0
+ property int maxIdx: 3
+ property int gridWidth: 240
+ property Flickable flickable
+ width: parent.width
+ height: 64
+ function advance(steps) {
+ var nextIdx = curIdx + steps
+ if (nextIdx < 0 || nextIdx > maxIdx)
+ return;
+ flickable.contentX += gridWidth * steps;
+ curIdx += steps;
+ }
+ Image {
+ source: "../../../shared/images/back.png"
+ MouseArea{
+ anchors.fill: parent
+ onClicked: selector.advance(-1)
+ }
+ anchors.left: parent.left
+ anchors.leftMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ opacity: selector.curIdx == 0 ? 0.2 : 1.0
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Image {
+ source: "../../../shared/images/back.png"
+ mirror: true
+ MouseArea{
+ anchors.fill: parent
+ onClicked: selector.advance(1)
+ }
+ opacity: selector.curIdx == selector.maxIdx ? 0.2 : 1.0
+ Behavior on opacity {NumberAnimation{}}
+ anchors.right: parent.right
+ anchors.rightMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ Repeater {
+ model: [ "Scale", "Repeat", "Scale/Repeat", "Round" ]
+ delegate: Text {
+ text: model.modelData
+ anchors.verticalCenter: parent.verticalCenter
+
+ x: (index - selector.curIdx) * 80 + 140
+ Behavior on x { NumberAnimation{} }
+
+ opacity: selector.curIdx == index ? 1.0 : 0.0
+ Behavior on opacity { NumberAnimation{} }
+ }
+ }
+}
diff --git a/examples/quick/imageelements/content/ImageCell.qml b/examples/quick/imageelements/content/ImageCell.qml
new file mode 100644
index 0000000000..fcc6b47af5
--- /dev/null
+++ b/examples/quick/imageelements/content/ImageCell.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ property alias mode: image.fillMode
+ property alias caption: captionItem.text
+
+ width: parent.cellWidth; height: parent.cellHeight
+
+ Image {
+ id: image
+ width: parent.width; height: parent.height - captionItem.height
+ source: "qt-logo.png"
+ clip: true // only makes a difference if mode is PreserveAspectCrop
+ smooth: true
+ }
+
+ Text {
+ id: captionItem
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/quick/imageelements/content/MyBorderImage.qml b/examples/quick/imageelements/content/MyBorderImage.qml
new file mode 100644
index 0000000000..93880f12bb
--- /dev/null
+++ b/examples/quick/imageelements/content/MyBorderImage.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property alias horizontalMode: image.horizontalTileMode
+ property alias verticalMode: image.verticalTileMode
+ property alias source: image.source
+
+ property int minWidth
+ property int minHeight
+ property int maxWidth
+ property int maxHeight
+ property int margin
+
+ width: 240; height: 200
+
+ BorderImage {
+ id: image; anchors.centerIn: parent
+
+ SequentialAnimation on width {
+ loops: Animation.Infinite
+ NumberAnimation {
+ from: container.minWidth; to: container.maxWidth
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ NumberAnimation {
+ from: container.maxWidth; to: container.minWidth
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ }
+
+ SequentialAnimation on height {
+ loops: Animation.Infinite
+ NumberAnimation {
+ from: container.minHeight; to: container.maxHeight
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ NumberAnimation {
+ from: container.maxHeight; to: container.minHeight
+ duration: 2000; easing.type: Easing.InOutQuad
+ }
+ }
+
+ border.top: container.margin
+ border.left: container.margin
+ border.bottom: container.margin
+ border.right: container.margin
+ }
+}
diff --git a/examples/quick/imageelements/content/ShadowRectangle.qml b/examples/quick/imageelements/content/ShadowRectangle.qml
new file mode 100644
index 0000000000..e6fd13bb26
--- /dev/null
+++ b/examples/quick/imageelements/content/ShadowRectangle.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property alias color : rectangle.color
+
+ BorderImage {
+ anchors.fill: rectangle
+ anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ border { left: 10; top: 10; right: 10; bottom: 10 }
+ source: "shadow.png"; smooth: true
+ }
+
+ Rectangle { id: rectangle; anchors.fill: parent }
+}
diff --git a/examples/quick/imageelements/content/bw.png b/examples/quick/imageelements/content/bw.png
new file mode 100644
index 0000000000..486eaae96e
--- /dev/null
+++ b/examples/quick/imageelements/content/bw.png
Binary files differ
diff --git a/examples/quick/imageelements/content/colors-round.sci b/examples/quick/imageelements/content/colors-round.sci
new file mode 100644
index 0000000000..506f6f5f99
--- /dev/null
+++ b/examples/quick/imageelements/content/colors-round.sci
@@ -0,0 +1,7 @@
+border.left:30
+border.top:30
+border.right:30
+border.bottom:30
+horizontalTileRule:Round
+verticalTileRule:Round
+source:colors.png
diff --git a/examples/quick/imageelements/content/colors-stretch.sci b/examples/quick/imageelements/content/colors-stretch.sci
new file mode 100644
index 0000000000..e4989a723c
--- /dev/null
+++ b/examples/quick/imageelements/content/colors-stretch.sci
@@ -0,0 +1,5 @@
+border.left:30
+border.top:30
+border.right:30
+border.bottom:30
+source:colors.png
diff --git a/examples/quick/imageelements/content/colors.png b/examples/quick/imageelements/content/colors.png
new file mode 100644
index 0000000000..dfb62f3d64
--- /dev/null
+++ b/examples/quick/imageelements/content/colors.png
Binary files differ
diff --git a/examples/quick/imageelements/content/qt-logo.png b/examples/quick/imageelements/content/qt-logo.png
new file mode 100644
index 0000000000..14ddf2a028
--- /dev/null
+++ b/examples/quick/imageelements/content/qt-logo.png
Binary files differ
diff --git a/examples/quick/imageelements/content/shadow.png b/examples/quick/imageelements/content/shadow.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/examples/quick/imageelements/content/shadow.png
Binary files differ
diff --git a/examples/quick/imageelements/content/speaker.png b/examples/quick/imageelements/content/speaker.png
new file mode 100644
index 0000000000..fb0e857859
--- /dev/null
+++ b/examples/quick/imageelements/content/speaker.png
Binary files differ
diff --git a/examples/quick/imageelements/image.qml b/examples/quick/imageelements/image.qml
new file mode 100644
index 0000000000..ccefaf6b74
--- /dev/null
+++ b/examples/quick/imageelements/image.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 320
+ height: 480
+ Grid {
+ property int cellWidth: (width - (spacing * (columns - 1))) / columns
+ property int cellHeight: (height - (spacing * (rows - 1))) / rows
+
+ anchors.fill: parent
+ anchors.margins: 30
+
+ columns: 2
+ rows: 3
+ spacing: 30
+
+ ImageCell { mode: Image.Stretch; caption: "Stretch" }
+ ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" }
+ ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" }
+
+ ImageCell { mode: Image.Tile; caption: "Tile" }
+ ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" }
+ ImageCell { mode: Image.TileVertically; caption: "TileVertically" }
+ }
+}
diff --git a/examples/quick/imageelements/imageelements.pro b/examples/quick/imageelements/imageelements.pro
new file mode 100644
index 0000000000..89abac6e25
--- /dev/null
+++ b/examples/quick/imageelements/imageelements.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements
+qml.files = borderimage.qml content imageelements.qml image.qml shadows.qml simplesprite.qml spriteimage.qml
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements
+INSTALLS += target qml
+
diff --git a/examples/quick/imageelements/imageelements.qml b/examples/quick/imageelements/imageelements.qml
new file mode 100644
index 0000000000..bb23ef6979
--- /dev/null
+++ b/examples/quick/imageelements/imageelements.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared"
+
+/*!
+ \title QML Examples - Image Elements
+ \example declarative/imageelements
+ \brief This is a collection of QML examples
+ \image qml-imageelements-example.png
+
+ This is a collection of small QML examples relating to image elements.
+
+ BorderImage shows off the various scaling modes of the BorderImage item.
+
+ Image shows off the various tiling modes of the Image item.
+
+ Shadows shows how to create a drop shadow for a rectangle using a BorderImage.
+
+ AnimatedSprite shows a simple use for the AnimatedSprite element.
+
+ SpriteSequence demonstrates using the SpriteSequence element to draw an animated and slightly interactive bear.
+*/
+
+Item {
+ height: 480
+ width: 320
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml"));
+ addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml"));
+ addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml"));
+ addExample("AnimatedSprite", "A simple sprite-based animation", Qt.resolvedUrl("animatedsprite.qml"));
+ addExample("SpriteSequence", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spritesequence.qml"));
+ }
+ }
+}
diff --git a/examples/quick/imageelements/imageelements.qmlproject b/examples/quick/imageelements/imageelements.qmlproject
new file mode 100644
index 0000000000..4292a0c112
--- /dev/null
+++ b/examples/quick/imageelements/imageelements.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "imageelements.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/imageelements/main.cpp b/examples/quick/imageelements/main.cpp
new file mode 100644
index 0000000000..72850f93c1
--- /dev/null
+++ b/examples/quick/imageelements/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(imageelements)
diff --git a/examples/quick/imageelements/shadows.qml b/examples/quick/imageelements/shadows.qml
new file mode 100644
index 0000000000..aa5022ab36
--- /dev/null
+++ b/examples/quick/imageelements/shadows.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+
+ width: 480; height: 320
+ color: "gray"
+
+ ShadowRectangle {
+ anchors.centerIn: parent; width: 250; height: 250
+ color: "lightsteelblue"
+ }
+
+ ShadowRectangle {
+ anchors.centerIn: parent; width: 200; height: 200
+ color: "steelblue"
+ }
+
+ ShadowRectangle {
+ anchors.centerIn: parent; width: 150; height: 150
+ color: "thistle"
+ }
+}
diff --git a/examples/quick/imageelements/spritesequence.qml b/examples/quick/imageelements/spritesequence.qml
new file mode 100644
index 0000000000..01f34e5c7a
--- /dev/null
+++ b/examples/quick/imageelements/spritesequence.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+ MouseArea {
+ onClicked: anim.start();
+ anchors.fill: parent
+ }
+ SequentialAnimation {
+ id: anim
+ ScriptAction { script: image.goalSprite = "falling"; }
+ NumberAnimation { target: image; property: "y"; to: 480; duration: 12000; }
+ ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} }
+ PropertyAction { target: image; property: "y"; value: 0 }
+ }
+ SpriteSequence {
+ id: image
+ width: 256
+ height: 256
+ anchors.horizontalCenter: parent.horizontalCenter
+ interpolate: false
+ goalSprite: ""
+ Sprite{
+ name: "still"
+ source: "content/BearSheet.png"
+ frameCount: 1
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 100
+ to: {"still":1, "blink":0.1, "floating":0}
+ }
+ Sprite{
+ name: "blink"
+ source: "content/BearSheet.png"
+ frameCount: 3
+ frameX: 256
+ frameY: 1536
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 100
+ to: {"still":1}
+ }
+ Sprite{
+ name: "floating"
+ source: "content/BearSheet.png"
+ frameCount: 9
+ frameX: 0
+ frameY: 0
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 160
+ to: {"still":0, "flailing":1}
+ }
+ Sprite{
+ name: "flailing"
+ source: "content/BearSheet.png"
+ frameCount: 8
+ frameX: 0
+ frameY: 768
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 160
+ to: {"falling":1}
+ }
+ Sprite{
+ name: "falling"
+ source: "content/BearSheet.png"
+ frameCount: 5
+ frameY: 1280
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 160
+ to: {"falling":1}
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/ContextMenu.qml b/examples/quick/keyinteraction/focus/Core/ContextMenu.qml
new file mode 100644
index 0000000000..dc68aa2b30
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/ContextMenu.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: container
+
+ property bool open: false
+
+ Item {
+ anchors.fill: parent
+
+ Rectangle {
+ anchors.fill: parent
+ color: "#D1DBBD"
+ focus: true
+ Keys.onRightPressed: mainView.focus = true
+
+ Text {
+ anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 }
+ color: "black"
+ font.pixelSize: 14
+ text: "Context Menu"
+ }
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/GridMenu.qml b/examples/quick/keyinteraction/focus/Core/GridMenu.qml
new file mode 100644
index 0000000000..75bbe682af
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/GridMenu.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ property alias interactive: gridView.interactive
+
+ onActiveFocusChanged: {
+ if (activeFocus)
+ mainView.state = ""
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ clip: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#193441" }
+ GradientStop { position: 1.0; color: Qt.darker("#193441") }
+ }
+
+ GridView {
+ id: gridView
+ anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20
+ cellWidth: 152; cellHeight: 152
+ focus: true
+ model: 12
+
+ KeyNavigation.down: listMenu
+ KeyNavigation.left: contextMenu
+
+ delegate: Item {
+ id: container
+ width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ Rectangle {
+ id: content
+ color: "transparent"
+ smooth: true
+ anchors.fill: parent; anchors.margins: 20; radius: 10
+
+ Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true }
+ Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ onClicked: {
+ container.GridView.view.currentIndex = index
+ container.forceActiveFocus()
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.activeFocus
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/ListMenu.qml b/examples/quick/keyinteraction/focus/Core/ListMenu.qml
new file mode 100644
index 0000000000..7a62f33428
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/ListMenu.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ clip: true
+
+ onActiveFocusChanged: {
+ if (activeFocus)
+ mainView.state = "showListViews"
+ }
+
+ ListView {
+ id: list1
+ y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20
+ focus: true
+ KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
+ model: 10; cacheBuffer: 200
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ ListView {
+ id: list2
+ y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
+ KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
+ model: 10; cacheBuffer: 200
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ ListView {
+ id: list3
+ y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
+ KeyNavigation.up: gridMenu; KeyNavigation.left: list2
+ model: 10; cacheBuffer: 200
+ delegate: ListViewDelegate {}
+
+ Behavior on y {
+ NumberAnimation { duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ Rectangle { width: parent.width; height: 1; color: "#D1DBBD" }
+
+ Rectangle {
+ y: 1; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#3E606F" }
+ GradientStop { position: 1.0; color: "transparent" }
+ }
+ }
+
+ Rectangle {
+ y: parent.height - 10; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#3E606F" }
+ GradientStop { position: 0.0; color: "transparent" }
+ }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml
new file mode 100644
index 0000000000..b28b02616d
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/ListViewDelegate.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+ width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10
+
+ Rectangle {
+ id: content
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 10
+ color: "transparent"
+ smooth: true
+ radius: 10
+
+ Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 }
+ }
+
+ Text {
+ id: label
+ anchors.centerIn: content
+ text: "List element " + (index + 1)
+ color: "#193441"
+ font.pixelSize: 14
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ onClicked: {
+ container.ListView.view.currentIndex = index
+ container.forceActiveFocus()
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.activeFocus
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ PropertyChanges { target: label; font.pixelSize: 16 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+}
diff --git a/examples/quick/keyinteraction/focus/Core/images/arrow.png b/examples/quick/keyinteraction/focus/Core/images/arrow.png
new file mode 100644
index 0000000000..14978c2e56
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/images/arrow.png
Binary files differ
diff --git a/examples/quick/keyinteraction/focus/Core/images/qt-logo.png b/examples/quick/keyinteraction/focus/Core/images/qt-logo.png
new file mode 100644
index 0000000000..14ddf2a028
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/Core/images/qt-logo.png
Binary files differ
diff --git a/examples/quick/keyinteraction/focus/focus.qml b/examples/quick/keyinteraction/focus/focus.qml
new file mode 100644
index 0000000000..9300ad4f6e
--- /dev/null
+++ b/examples/quick/keyinteraction/focus/focus.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "Core"
+
+Rectangle {
+ id: window
+
+ width: 800; height: 480
+ color: "#3E606F"
+
+ FocusScope {
+ id: mainView
+
+ width: parent.width; height: parent.height
+ focus: true
+
+ GridMenu {
+ id: gridMenu
+ width: parent.width; height: 320
+
+ focus: true
+ interactive: parent.activeFocus
+ }
+
+ ListMenu {
+ id: listMenu
+ y: 320; width: parent.width; height: 320
+ }
+
+ Rectangle {
+ id: shade
+ anchors.fill: parent
+ color: "black"
+ opacity: 0
+ }
+
+ states: State {
+ name: "showListViews"
+ PropertyChanges { target: gridMenu; y: -160 }
+ PropertyChanges { target: listMenu; y: 160 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint }
+ }
+ }
+
+ Image {
+ source: "Core/images/arrow.png"
+ rotation: 90
+ anchors.verticalCenter: parent.verticalCenter
+
+ MouseArea {
+ anchors.fill: parent; anchors.margins: -10
+ onClicked: contextMenu.focus = true
+ }
+ }
+
+ ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height }
+
+ states: State {
+ name: "contextMenuOpen"
+ when: !mainView.activeFocus
+ PropertyChanges { target: contextMenu; x: 0; open: true }
+ PropertyChanges { target: mainView; x: 130 }
+ PropertyChanges { target: shade; opacity: 0.25 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint }
+ }
+}
diff --git a/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro
new file mode 100644
index 0000000000..f786d9356f
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = abstractitemmodel
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += qml quick
+
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
+RESOURCES += abstractitemmodel.qrc
diff --git a/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc
new file mode 100644
index 0000000000..4ae861cb3d
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/abstractitemmodel.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
+
diff --git a/examples/quick/modelviews/abstractitemmodel/main.cpp b/examples/quick/modelviews/abstractitemmodel/main.cpp
new file mode 100644
index 0000000000..f5930ce840
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/main.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+#include <QGuiApplication>
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ AnimalModel model;
+ model.addAnimal(Animal("Wolf", "Medium"));
+ model.addAnimal(Animal("Polar bear", "Large"));
+ model.addAnimal(Animal("Quoll", "Small"));
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/quick/modelviews/abstractitemmodel/model.cpp b/examples/quick/modelviews/abstractitemmodel/model.cpp
new file mode 100644
index 0000000000..8f7649c0d4
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/model.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "model.h"
+
+Animal::Animal(const QString &type, const QString &size)
+ : m_type(type), m_size(size)
+{
+}
+
+QString Animal::type() const
+{
+ return m_type;
+}
+
+QString Animal::size() const
+{
+ return m_size;
+}
+
+//![0]
+AnimalModel::AnimalModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ roles[SizeRole] = "size";
+ setRoleNames(roles);
+}
+//![0]
+
+void AnimalModel::addAnimal(const Animal &animal)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ m_animals << animal;
+ endInsertRows();
+}
+
+int AnimalModel::rowCount(const QModelIndex & parent) const {
+ return m_animals.count();
+}
+
+QVariant AnimalModel::data(const QModelIndex & index, int role) const {
+ if (index.row() < 0 || index.row() >= m_animals.count())
+ return QVariant();
+
+ const Animal &animal = m_animals[index.row()];
+ if (role == TypeRole)
+ return animal.type();
+ else if (role == SizeRole)
+ return animal.size();
+ return QVariant();
+}
+
diff --git a/examples/quick/modelviews/abstractitemmodel/model.h b/examples/quick/modelviews/abstractitemmodel/model.h
new file mode 100644
index 0000000000..1378c4487e
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/model.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QAbstractListModel>
+#include <QStringList>
+
+//![0]
+class Animal
+{
+public:
+ Animal(const QString &type, const QString &size);
+//![0]
+
+ QString type() const;
+ QString size() const;
+
+private:
+ QString m_type;
+ QString m_size;
+//![1]
+};
+
+class AnimalModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum AnimalRoles {
+ TypeRole = Qt::UserRole + 1,
+ SizeRole
+ };
+
+ AnimalModel(QObject *parent = 0);
+//![1]
+
+ void addAnimal(const Animal &animal);
+
+ int rowCount(const QModelIndex & parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+
+private:
+ QList<Animal> m_animals;
+//![2]
+};
+//![2]
+
+
diff --git a/examples/quick/modelviews/abstractitemmodel/view.qml b/examples/quick/modelviews/abstractitemmodel/view.qml
new file mode 100644
index 0000000000..64f5871d4b
--- /dev/null
+++ b/examples/quick/modelviews/abstractitemmodel/view.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+//![0]
+ListView {
+ width: 200; height: 250
+
+ model: myModel
+ delegate: Text { text: "Animal: " + type + ", " + size }
+}
+//![0]
+
diff --git a/examples/quick/modelviews/gridview/gridview-example.qml b/examples/quick/modelviews/gridview/gridview-example.qml
new file mode 100644
index 0000000000..ea3bb5cec9
--- /dev/null
+++ b/examples/quick/modelviews/gridview/gridview-example.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 300; height: 400
+ color: "white"
+
+ ListModel {
+ id: appModel
+ ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" }
+ ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" }
+ ListElement { name: "Camera"; icon: "pics/Camera_48.png" }
+ ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" }
+ ListElement { name: "Messaging"; icon: "pics/EMail_48.png" }
+ ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" }
+ ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" }
+ }
+
+ Component {
+ id: appDelegate
+
+ Item {
+ width: 100; height: 100
+
+ Image {
+ id: myIcon
+ y: 20; anchors.horizontalCenter: parent.horizontalCenter
+ source: icon
+ }
+ Text {
+ anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
+ text: name
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.GridView.view.currentIndex = index
+ }
+ }
+ }
+
+ Component {
+ id: appHighlight
+ Rectangle { width: 80; height: 80; color: "lightsteelblue" }
+ }
+
+ GridView {
+ anchors.fill: parent
+ cellWidth: 100; cellHeight: 100
+ highlight: appHighlight
+ focus: true
+ model: appModel
+ delegate: appDelegate
+ }
+}
diff --git a/examples/quick/modelviews/gridview/pics/AddressBook_48.png b/examples/quick/modelviews/gridview/pics/AddressBook_48.png
new file mode 100644
index 0000000000..1ab7c8eec1
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png b/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png
new file mode 100644
index 0000000000..f4b8689f87
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/Camera_48.png b/examples/quick/modelviews/gridview/pics/Camera_48.png
new file mode 100644
index 0000000000..c76b524945
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/Camera_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/DateBook_48.png b/examples/quick/modelviews/gridview/pics/DateBook_48.png
new file mode 100644
index 0000000000..58f5787fb8
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/EMail_48.png b/examples/quick/modelviews/gridview/pics/EMail_48.png
new file mode 100644
index 0000000000..d6d84a61be
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/EMail_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/TodoList_48.png b/examples/quick/modelviews/gridview/pics/TodoList_48.png
new file mode 100644
index 0000000000..0988448d9b
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png b/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png
new file mode 100644
index 0000000000..52638c50a7
--- /dev/null
+++ b/examples/quick/modelviews/gridview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/PetsModel.qml b/examples/quick/modelviews/listview/content/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/quick/modelviews/listview/content/PressAndHoldButton.qml b/examples/quick/modelviews/listview/content/PressAndHoldButton.qml
new file mode 100644
index 0000000000..b20d8f64f1
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/PressAndHoldButton.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+
+ property int repeatDelay: 300
+ property int repeatDuration: 75
+ property bool pressed: false
+
+ signal clicked
+
+ scale: pressed ? 0.9 : 1
+
+ function release() {
+ autoRepeatClicks.stop()
+ container.pressed = false
+ }
+
+ SequentialAnimation on pressed {
+ id: autoRepeatClicks
+ running: false
+
+ PropertyAction { target: container; property: "pressed"; value: true }
+ ScriptAction { script: container.clicked() }
+ PauseAnimation { duration: repeatDelay }
+
+ SequentialAnimation {
+ loops: Animation.Infinite
+ ScriptAction { script: container.clicked() }
+ PauseAnimation { duration: repeatDuration }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onPressed: autoRepeatClicks.start()
+ onReleased: container.release()
+ onCanceled: container.release()
+ }
+}
+
diff --git a/examples/quick/modelviews/listview/content/RecipesModel.qml b/examples/quick/modelviews/listview/content/RecipesModel.qml
new file mode 100644
index 0000000000..86210ba436
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/RecipesModel.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ title: "Pancakes"
+ picture: "content/pics/pancakes.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 1 cup (150g) self-raising flour
+ <li> 1 tbs caster sugar
+ <li> 3/4 cup (185ml) milk
+ <li> 1 egg
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Sift flour and sugar together into a bowl. Add a pinch of salt.
+ <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth.
+ <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface.
+ <li> Turn over and cook other side until golden.
+ </ol>
+ </html>"
+ }
+ ListElement {
+ title: "Fruit Salad"
+ picture: "content/pics/fruit-salad.jpg"
+ ingredients: "* Seasonal Fruit"
+ method: "* Chop fruit and place in a bowl."
+ }
+ ListElement {
+ title: "Vegetable Soup"
+ picture: "content/pics/vegetable-soup.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 1 onion
+ <li> 1 turnip
+ <li> 1 potato
+ <li> 1 carrot
+ <li> 1 head of celery
+ <li> 1 1/2 litres of water
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Chop vegetables.
+ <li> Boil in water until vegetables soften.
+ <li> Season with salt and pepper to taste.
+ </ol>
+ </html>"
+ }
+ ListElement {
+ title: "Hamburger"
+ picture: "content/pics/hamburger.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 500g minced beef
+ <li> Seasoning
+ <li> lettuce, tomato, onion, cheese
+ <li> 1 hamburger bun for each burger
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Mix the beef, together with seasoning, in a food processor.
+ <li> Shape the beef into burgers.
+ <li> Grill the burgers for about 5 mins on each side (until cooked through)
+ <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion.
+ </ol>
+ </html>"
+ }
+ ListElement {
+ title: "Lemonade"
+ picture: "content/pics/lemonade.jpg"
+ ingredients: "<html>
+ <ul>
+ <li> 1 cup Lemon Juice
+ <li> 1 cup Sugar
+ <li> 6 Cups of Water (2 cups warm water, 4 cups cold water)
+ </ul>
+ </html>"
+ method: "<html>
+ <ol>
+ <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves.
+ <li> Pour in lemon juice, stir again, and add 4 cups of cold water.
+ <li> Chill or serve over ice cubes.
+ </ol>
+ </html>"
+ }
+}
diff --git a/examples/quick/modelviews/listview/content/TextButton.qml b/examples/quick/modelviews/listview/content/TextButton.qml
new file mode 100644
index 0000000000..980ee21553
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/TextButton.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property alias text: label.text
+
+ signal clicked
+
+ width: label.width + 20; height: label.height + 6
+ smooth: true
+ radius: 10
+
+ gradient: Gradient {
+ GradientStop { id: gradientStop; position: 0.0; color: palette.light }
+ GradientStop { position: 1.0; color: palette.button }
+ }
+
+ SystemPalette { id: palette }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: { container.clicked() }
+ }
+
+ Text {
+ id: label
+ anchors.centerIn: parent
+ }
+
+ states: State {
+ name: "pressed"
+ when: mouseArea.pressed
+ PropertyChanges { target: gradientStop; color: palette.dark }
+ }
+}
+
diff --git a/examples/quick/modelviews/listview/content/ToggleButton.qml b/examples/quick/modelviews/listview/content/ToggleButton.qml
new file mode 100644
index 0000000000..52f4988f03
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/ToggleButton.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ property alias label: text.text
+ property bool active: false
+ signal toggled
+ width: 149
+ height: 30
+ radius: 3
+ color: active ? "green" : "lightgray"
+ border.width: 1
+ Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { active = !active; root.toggled() }
+ }
+}
diff --git a/examples/quick/modelviews/listview/content/pics/arrow-down.png b/examples/quick/modelviews/listview/content/pics/arrow-down.png
new file mode 100644
index 0000000000..29d1d4439a
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/arrow-down.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/arrow-up.png b/examples/quick/modelviews/listview/content/pics/arrow-up.png
new file mode 100644
index 0000000000..e437312217
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/arrow-up.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg b/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg
new file mode 100644
index 0000000000..da5a6b10a2
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/fruit-salad.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/hamburger.jpg b/examples/quick/modelviews/listview/content/pics/hamburger.jpg
new file mode 100644
index 0000000000..d0a15be1bf
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/hamburger.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/lemonade.jpg b/examples/quick/modelviews/listview/content/pics/lemonade.jpg
new file mode 100644
index 0000000000..db445c9ac8
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/lemonade.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/list-delete.png b/examples/quick/modelviews/listview/content/pics/list-delete.png
new file mode 100644
index 0000000000..df2a147d24
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/list-delete.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/minus-sign.png b/examples/quick/modelviews/listview/content/pics/minus-sign.png
new file mode 100644
index 0000000000..d6f233d739
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/minus-sign.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/moreDown.png b/examples/quick/modelviews/listview/content/pics/moreDown.png
new file mode 100644
index 0000000000..31a35d5c20
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/moreDown.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/moreUp.png b/examples/quick/modelviews/listview/content/pics/moreUp.png
new file mode 100644
index 0000000000..fefb9c9098
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/moreUp.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/pancakes.jpg b/examples/quick/modelviews/listview/content/pics/pancakes.jpg
new file mode 100644
index 0000000000..60c439638e
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/pancakes.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/plus-sign.png b/examples/quick/modelviews/listview/content/pics/plus-sign.png
new file mode 100644
index 0000000000..40df1134f8
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/plus-sign.png
Binary files differ
diff --git a/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg
new file mode 100644
index 0000000000..9dce332041
--- /dev/null
+++ b/examples/quick/modelviews/listview/content/pics/vegetable-soup.jpg
Binary files differ
diff --git a/examples/quick/modelviews/listview/dynamiclist.qml b/examples/quick/modelviews/listview/dynamiclist.qml
new file mode 100644
index 0000000000..ee7c6329bc
--- /dev/null
+++ b/examples/quick/modelviews/listview/dynamiclist.qml
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import "content"
+
+// This example shows how items can be dynamically added to and removed from
+// a ListModel, and how these list modifications can be animated.
+
+Rectangle {
+ id: container
+ width: 500; height: 400
+ color: "#343434"
+
+ // The model:
+ ListModel {
+ id: fruitModel
+
+ ListElement {
+ name: "Apple"; cost: 2.45
+ attributes: [
+ ListElement { description: "Core" },
+ ListElement { description: "Deciduous" }
+ ]
+ }
+ ListElement {
+ name: "Banana"; cost: 1.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Seedless" }
+ ]
+ }
+ ListElement {
+ name: "Cumquat"; cost: 3.25
+ attributes: [
+ ListElement { description: "Citrus" }
+ ]
+ }
+ ListElement {
+ name: "Durian"; cost: 9.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Smelly" }
+ ]
+ }
+ }
+
+ // The delegate for each fruit in the model:
+ Component {
+ id: listDelegate
+
+ Item {
+ id: delegateItem
+ width: listView.width; height: 55
+ clip: true
+
+ Row {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: 10
+
+ Column {
+ Image {
+ source: "content/pics/arrow-up.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) }
+ }
+ Image { source: "content/pics/arrow-down.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) }
+ }
+ }
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+
+ Text {
+ text: name
+ font.pixelSize: 15
+ color: "white"
+ }
+ Row {
+ spacing: 5
+ Repeater {
+ model: attributes
+ Text { text: description; color: "White" }
+ }
+ }
+ }
+ }
+
+ Row {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ spacing: 10
+
+ PressAndHoldButton {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "content/pics/plus-sign.png"
+ onClicked: fruitModel.setProperty(index, "cost", cost + 0.25)
+ }
+
+ Text {
+ id: costText
+ anchors.verticalCenter: parent.verticalCenter
+ text: '$' + Number(cost).toFixed(2)
+ font.pixelSize: 15
+ color: "white"
+ font.bold: true
+ }
+
+ PressAndHoldButton {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "content/pics/minus-sign.png"
+ onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25))
+ }
+
+ Image {
+ source: "content/pics/list-delete.png"
+ MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
+ }
+ }
+
+ // Animate adding and removing of items:
+
+ ListView.onAdd: SequentialAnimation {
+ PropertyAction { target: delegateItem; property: "height"; value: 0 }
+ NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad }
+ }
+
+ ListView.onRemove: SequentialAnimation {
+ PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true }
+ NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
+
+ // Make sure delayRemove is set back to false so that the item can be destroyed
+ PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false }
+ }
+ }
+ }
+
+ // The view:
+ ListView {
+ id: listView
+ anchors.fill: parent; anchors.margins: 20
+ model: fruitModel
+ delegate: listDelegate
+ }
+
+ Row {
+ anchors { left: parent.left; bottom: parent.bottom; margins: 20 }
+ spacing: 10
+
+ TextButton {
+ text: "Add an item"
+ onClicked: {
+ fruitModel.append({
+ "name": "Pizza Margarita",
+ "cost": 5.95,
+ "attributes": [{"description": "Cheese"}, {"description": "Tomato"}]
+ })
+ }
+ }
+
+ TextButton {
+ text: "Remove all items"
+ onClicked: fruitModel.clear()
+ }
+ }
+}
+
diff --git a/examples/quick/modelviews/listview/expandingdelegates.qml b/examples/quick/modelviews/listview/expandingdelegates.qml
new file mode 100644
index 0000000000..43a9662422
--- /dev/null
+++ b/examples/quick/modelviews/listview/expandingdelegates.qml
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+// This example illustrates expanding a list item to show a more detailed view.
+
+Rectangle {
+ id: page
+ width: 400; height: 240
+ color: "black"
+
+ // Delegate for the recipes. This delegate has two modes:
+ // 1. List mode (default), which just shows the picture and title of the recipe.
+ // 2. Details mode, which also shows the ingredients and method.
+ Component {
+ id: recipeDelegate
+
+ Item {
+ id: recipe
+
+ // Create a property to contain the visibility of the details.
+ // We can bind multiple element's opacity to this one property,
+ // rather than having a "PropertyChanges" line for each element we
+ // want to fade.
+ property real detailsOpacity : 0
+
+ width: listView.width
+ height: 70
+
+ // A simple rounded rectangle for the background
+ Rectangle {
+ id: background
+ x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
+ color: "ivory"
+ border.color: "orange"
+ radius: 5
+ }
+
+ // This mouse region covers the entire delegate.
+ // When clicked it changes mode to 'Details'. If we are already
+ // in Details mode, then no change will happen.
+ MouseArea {
+ anchors.fill: parent
+ onClicked: recipe.state = 'Details';
+ }
+
+ // Lay out the page: picture, title and ingredients at the top, and method at the
+ // bottom. Note that elements that should not be visible in the list
+ // mode have their opacity set to recipe.detailsOpacity.
+ Row {
+ id: topLayout
+ x: 10; y: 10; height: recipeImage.height; width: parent.width
+ spacing: 10
+
+ Image {
+ id: recipeImage
+ width: 50; height: 50
+ source: picture
+ }
+
+ Column {
+ width: background.width - recipeImage.width - 20; height: recipeImage.height
+ spacing: 5
+
+ Text {
+ text: title
+ font.bold: true; font.pointSize: 16
+ }
+
+ Text {
+ text: "Ingredients"
+ font.pointSize: 12; font.bold: true
+ opacity: recipe.detailsOpacity
+ }
+
+ Text {
+ text: ingredients
+ wrapMode: Text.WordWrap
+ width: parent.width
+ opacity: recipe.detailsOpacity
+ }
+ }
+ }
+
+ Item {
+ id: details
+ x: 10; width: parent.width - 20
+ anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
+ opacity: recipe.detailsOpacity
+
+ Text {
+ id: methodTitle
+ anchors.top: parent.top
+ text: "Method"
+ font.pointSize: 12; font.bold: true
+ }
+
+ Flickable {
+ id: flick
+ width: parent.width
+ anchors { top: methodTitle.bottom; bottom: parent.bottom }
+ contentHeight: methodText.height
+ clip: true
+
+ Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
+ }
+
+ Image {
+ anchors { right: flick.right; top: flick.top }
+ source: "content/pics/moreUp.png"
+ opacity: flick.atYBeginning ? 0 : 1
+ }
+
+ Image {
+ anchors { right: flick.right; bottom: flick.bottom }
+ source: "content/pics/moreDown.png"
+ opacity: flick.atYEnd ? 0 : 1
+ }
+ }
+
+ // A button to close the detailed view, i.e. set the state back to default ('').
+ TextButton {
+ y: 10
+ anchors { right: background.right; rightMargin: 10 }
+ opacity: recipe.detailsOpacity
+ text: "Close"
+
+ onClicked: recipe.state = '';
+ }
+
+ states: State {
+ name: "Details"
+
+ PropertyChanges { target: background; color: "white" }
+ PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
+ PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible
+ PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view
+
+ // Move the list so that this item is at the top.
+ PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
+
+ // Disallow flicking while we're in detailed view
+ PropertyChanges { target: recipe.ListView.view; interactive: false }
+ }
+
+ transitions: Transition {
+ // Make the state changes smooth
+ ParallelAnimation {
+ ColorAnimation { property: "color"; duration: 500 }
+ NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" }
+ }
+ }
+ }
+ }
+
+ // The actual list
+ ListView {
+ id: listView
+ anchors.fill: parent
+ model: RecipesModel {}
+ delegate: recipeDelegate
+ }
+}
diff --git a/examples/quick/modelviews/listview/highlight.qml b/examples/quick/modelviews/listview/highlight.qml
new file mode 100644
index 0000000000..d8f76080e6
--- /dev/null
+++ b/examples/quick/modelviews/listview/highlight.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example shows how to create your own highlight delegate for a ListView
+// that uses a SpringAnimation to provide custom movement when the
+// highlight bar is moved between items.
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 200; height: 300
+
+ // Define a delegate component. A component will be
+ // instantiated for each visible item in the list.
+ Component {
+ id: petDelegate
+ Item {
+ id: wrapper
+ width: 200; height: 55
+ Column {
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ // indent the item if it is the current item
+ states: State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 20 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 200 }
+ }
+ }
+ }
+
+ // Define a highlight with customised movement between items.
+ Component {
+ id: highlightBar
+ Rectangle {
+ width: 200; height: 50
+ color: "#FFFF88"
+ y: listView.currentItem.y;
+ Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
+ }
+ }
+
+ ListView {
+ id: listView
+ width: 200; height: parent.height
+
+ model: PetsModel {}
+ delegate: petDelegate
+ focus: true
+
+ // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem
+ // to false so the highlight delegate can control how the highlight is moved.
+ highlight: highlightBar
+ highlightFollowsCurrentItem: false
+ }
+}
diff --git a/examples/quick/modelviews/listview/highlightranges.qml b/examples/quick/modelviews/listview/highlightranges.qml
new file mode 100644
index 0000000000..a536ddcbb2
--- /dev/null
+++ b/examples/quick/modelviews/listview/highlightranges.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: root
+ property int current: 0
+ width: 600; height: 300
+
+ // This example shows the same model in three different ListView items,
+ // with different highlight ranges. The highlight ranges are set by the
+ // preferredHighlightBegin and preferredHighlightEnd properties in ListView.
+ //
+ // The first ListView does not set a highlight range, so its currentItem
+ // can move freely within the visible area. If it moves outside the
+ // visible area, the view is automatically scrolled to keep the current
+ // item visible.
+ //
+ // The second ListView sets a highlight range which attempts to keep the
+ // current item within the the bounds of the range. However,
+ // items will not scroll beyond the beginning or end of the view,
+ // forcing the highlight to move outside the range at the ends.
+ //
+ // The third ListView sets the highlightRangeMode to StrictlyEnforceRange
+ // and sets a range smaller than the height of an item. This
+ // forces the current item to change when the view is flicked,
+ // since the highlight is unable to move.
+ //
+ // All ListViews bind their currentIndex to the root.current property.
+ // The first ListView sets root.current whenever its currentIndex changes
+ // due to keyboard interaction.
+ // Flicking the third ListView with the mouse also changes root.current.
+
+ ListView {
+ id: list1
+ width: 200; height: parent.height
+ model: PetsModel {}
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "lightsteelblue" }
+ currentIndex: root.current
+ onCurrentIndexChanged: root.current = currentIndex
+ focus: true
+ }
+
+ ListView {
+ id: list2
+ x: list1.width
+ width: 200; height: parent.height
+ model: PetsModel {}
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "yellow" }
+ currentIndex: root.current
+ preferredHighlightBegin: 80; preferredHighlightEnd: 220
+ highlightRangeMode: ListView.ApplyRange
+ }
+
+ ListView {
+ id: list3
+ x: list1.width + list2.width
+ width: 200; height: parent.height
+ model: PetsModel {}
+ delegate: petDelegate
+
+ highlight: Rectangle { color: "yellow" }
+ currentIndex: root.current
+ onCurrentIndexChanged: root.current = currentIndex
+ preferredHighlightBegin: 125; preferredHighlightEnd: 125
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ }
+
+ // The delegate for each list
+ Component {
+ id: petDelegate
+ Column {
+ width: 200
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ }
+}
diff --git a/examples/quick/modelviews/listview/sections.qml b/examples/quick/modelviews/listview/sections.qml
new file mode 100644
index 0000000000..2e63a86bb6
--- /dev/null
+++ b/examples/quick/modelviews/listview/sections.qml
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example shows how a ListView can be separated into sections using
+// the ListView.section attached property.
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: container
+ width: 300
+ height: 360
+
+ ListModel {
+ id: animalsModel
+ ListElement { name: "Ant"; size: "Tiny" }
+ ListElement { name: "Flea"; size: "Tiny" }
+ ListElement { name: "Parrot"; size: "Small" }
+ ListElement { name: "Guinea pig"; size: "Small" }
+ ListElement { name: "Rat"; size: "Small" }
+ ListElement { name: "Butterfly"; size: "Small" }
+ ListElement { name: "Dog"; size: "Medium" }
+ ListElement { name: "Cat"; size: "Medium" }
+ ListElement { name: "Pony"; size: "Medium" }
+ ListElement { name: "Koala"; size: "Medium" }
+ ListElement { name: "Horse"; size: "Large" }
+ ListElement { name: "Tiger"; size: "Large" }
+ ListElement { name: "Giraffe"; size: "Large" }
+ ListElement { name: "Elephant"; size: "Huge" }
+ ListElement { name: "Whale"; size: "Huge" }
+ }
+
+//! [0]
+ // The delegate for each section header
+ Component {
+ id: sectionHeading
+ Rectangle {
+ width: container.width
+ height: childrenRect.height
+ color: "lightsteelblue"
+
+ Text {
+ text: section
+ font.bold: true
+ font.pixelSize: 20
+ }
+ }
+ }
+
+ ListView {
+ id: view
+ anchors.top: parent.top
+ anchors.bottom: buttonBar.top
+ width: parent.width
+ model: animalsModel
+ delegate: Text { text: name; font.pixelSize: 18 }
+
+ section.property: "size"
+ section.criteria: ViewSection.FullString
+ section.delegate: sectionHeading
+ }
+//! [0]
+
+ Row {
+ id: buttonBar
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 1
+ spacing: 1
+ ToggleButton {
+ label: "CurrentLabelAtStart"
+ onToggled: {
+ if (active)
+ view.section.labelPositioning |= ViewSection.CurrentLabelAtStart
+ else
+ view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart
+ }
+ }
+ ToggleButton {
+ label: "NextLabelAtEnd"
+ onToggled: {
+ if (active)
+ view.section.labelPositioning |= ViewSection.NextLabelAtEnd
+ else
+ view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/modelviews/modelviews.pro b/examples/quick/modelviews/modelviews.pro
new file mode 100644
index 0000000000..7748da0471
--- /dev/null
+++ b/examples/quick/modelviews/modelviews.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ abstractitemmodel \
+ objectlistmodel \
+ stringlistmodel
+
+
diff --git a/examples/quick/modelviews/modelviews.qml b/examples/quick/modelviews/modelviews.qml
new file mode 100644
index 0000000000..f11608bcc7
--- /dev/null
+++ b/examples/quick/modelviews/modelviews.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared"
+
+Item {
+ height: 480
+ width: 480
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml"));
+ addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml"));
+ addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml"));
+ addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml"));
+ addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml"));
+ addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml"));
+ addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml"));
+ addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml"));
+ addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml"));
+ addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml"));
+ addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml"));
+ }
+ }
+}
diff --git a/examples/quick/modelviews/modelviews.qmlproject b/examples/quick/modelviews/modelviews.qmlproject
new file mode 100644
index 0000000000..40f9e568fd
--- /dev/null
+++ b/examples/quick/modelviews/modelviews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "modelviews.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/modelviews/objectlistmodel/dataobject.cpp b/examples/quick/modelviews/objectlistmodel/dataobject.cpp
new file mode 100644
index 0000000000..7216283616
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/dataobject.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "dataobject.h"
+
+DataObject::DataObject(QObject *parent)
+ : QObject(parent)
+{
+}
+
+DataObject::DataObject(const QString &name, const QString &color, QObject *parent)
+ : QObject(parent), m_name(name), m_color(color)
+{
+}
+
+QString DataObject::name() const
+{
+ return m_name;
+}
+
+void DataObject::setName(const QString &name)
+{
+ if (name != m_name) {
+ m_name = name;
+ emit nameChanged();
+ }
+}
+
+QString DataObject::color() const
+{
+ return m_color;
+}
+
+void DataObject::setColor(const QString &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ emit colorChanged();
+ }
+}
diff --git a/examples/quick/modelviews/objectlistmodel/dataobject.h b/examples/quick/modelviews/objectlistmodel/dataobject.h
new file mode 100644
index 0000000000..bea92a273c
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/dataobject.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DATAOBJECT_H
+#define DATAOBJECT_H
+
+#include <QObject>
+
+//![0]
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
+//![0]
+
+public:
+ DataObject(QObject *parent=0);
+ DataObject(const QString &name, const QString &color, QObject *parent=0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString color() const;
+ void setColor(const QString &color);
+
+signals:
+ void nameChanged();
+ void colorChanged();
+
+private:
+ QString m_name;
+ QString m_color;
+//![1]
+};
+//![1]
+
+#endif // DATAOBJECT_H
diff --git a/examples/quick/modelviews/objectlistmodel/main.cpp b/examples/quick/modelviews/objectlistmodel/main.cpp
new file mode 100644
index 0000000000..bb3895f7c0
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+#include "dataobject.h"
+
+/*
+ This example illustrates exposing a QList<QObject*> as a
+ model in QML
+*/
+
+//![0]
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ 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"));
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro b/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro
new file mode 100644
index 0000000000..7f323c3999
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.pro
@@ -0,0 +1,6 @@
+QT += qml quick
+
+SOURCES += main.cpp \
+ dataobject.cpp
+HEADERS += dataobject.h
+RESOURCES += objectlistmodel.qrc
diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc
new file mode 100644
index 0000000000..17e9301471
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/objectlistmodel.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/quick/modelviews/objectlistmodel/view.qml b/examples/quick/modelviews/objectlistmodel/view.qml
new file mode 100644
index 0000000000..3954e79829
--- /dev/null
+++ b/examples/quick/modelviews/objectlistmodel/view.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+ListView {
+ width: 100; height: 100
+
+ model: myModel
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ color: model.modelData.color
+ Text { text: name }
+ }
+}
+//![0]
diff --git a/examples/quick/modelviews/package/Delegate.qml b/examples/quick/modelviews/package/Delegate.qml
new file mode 100644
index 0000000000..97c7840cb4
--- /dev/null
+++ b/examples/quick/modelviews/package/Delegate.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![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 }
+ MouseArea {
+ 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
+ x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/quick/modelviews/package/view.qml b/examples/quick/modelviews/package/view.qml
new file mode 100644
index 0000000000..7ba6664ae2
--- /dev/null
+++ b/examples/quick/modelviews/package/view.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "white"
+ 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]
+ Text {
+ anchors.bottom: parent.bottom
+ text: "Tap a delegate to move between views"
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/Clock.qml b/examples/quick/modelviews/parallax/content/Clock.qml
new file mode 100644
index 0000000000..7f0e8cba83
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/Clock.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id : clock
+ width: {
+ if (ListView.view && ListView.view.width >= 200)
+ return ListView.view.width / Math.floor(ListView.view.width / 200.0);
+ else
+ return 200;
+ }
+
+ height: {
+ if (ListView.view && ListView.view.height >= 240)
+ return ListView.view.height;
+ else
+ return 240;
+ }
+
+ property alias city: cityLabel.text
+ property int hours
+ property int minutes
+ property int seconds
+ property real shift
+ property bool night: false
+ property bool internationalTime: true //Unset for local time
+
+ function timeChanged() {
+ var date = new Date;
+ hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
+ night = ( hours < 7 || hours > 19 )
+ minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
+ seconds = date.getUTCSeconds();
+ }
+
+ Timer {
+ interval: 100; running: true; repeat: true;
+ onTriggered: clock.timeChanged()
+ }
+
+ Item {
+ anchors.centerIn: parent
+ width: 200; height: 240
+
+ Image { id: background; source: "clock.png"; visible: clock.night == false }
+ Image { source: "clock-night.png"; visible: clock.night == true }
+
+
+ Image {
+ x: 92.5; y: 27
+ source: "hour.png"
+ smooth: true
+ transform: Rotation {
+ id: hourRotation
+ origin.x: 7.5; origin.y: 73;
+ angle: (clock.hours * 30) + (clock.minutes * 0.5)
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 93.5; y: 17
+ source: "minute.png"
+ smooth: true
+ transform: Rotation {
+ id: minuteRotation
+ origin.x: 6.5; origin.y: 83;
+ angle: clock.minutes * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 97.5; y: 20
+ source: "second.png"
+ smooth: true
+ transform: Rotation {
+ id: secondRotation
+ origin.x: 2.5; origin.y: 80;
+ angle: clock.seconds * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel
+ y: 210; anchors.horizontalCenter: parent.horizontalCenter
+ color: "white"
+ font.family: "Helvetica"
+ font.bold: true; font.pixelSize: 16
+ style: Text.Raised; styleColor: "black"
+ }
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/ParallaxView.qml b/examples/quick/modelviews/parallax/content/ParallaxView.qml
new file mode 100644
index 0000000000..2acf50dcef
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/ParallaxView.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ property alias background: background.source
+ property int currentIndex: 0
+ default property alias content: visualModel.children
+
+ Image {
+ id: background
+ fillMode: Image.TileHorizontally
+ x: -list.contentX / 2
+ width: Math.max(list.contentWidth, parent.width)
+ }
+
+ ListView {
+ id: list
+ anchors.fill: parent
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ orientation: Qt.Horizontal
+ boundsBehavior: Flickable.DragOverBounds
+ model: VisualItemModel { id: visualModel }
+
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ snapMode: ListView.SnapOneItem
+ }
+
+ ListView {
+ id: selector
+
+ height: 50
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: Math.min(count * 50, parent.width - 20)
+ interactive: width == parent.width - 20
+ orientation: Qt.Horizontal
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ model: visualModel.children
+ delegate: Item {
+ width: 50; height: 50
+ id: delegateRoot
+
+ Image {
+ id: image
+ source: modelData.icon
+ smooth: true
+ scale: 0.8
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { root.currentIndex = index }
+ }
+
+ states: State {
+ name: "Selected"
+ when: delegateRoot.ListView.isCurrentItem == true
+ PropertyChanges {
+ target: image
+ scale: 1
+ y: -5
+ }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "scale,y" }
+ }
+ }
+
+ Rectangle {
+ color: "#60FFFFFF"
+ x: -10; y: -10; z: -1
+ width: parent.width + 20; height: parent.height + 20
+ radius: 10
+ }
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/QuitButton.qml b/examples/quick/modelviews/parallax/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/quick/modelviews/parallax/content/Smiley.qml b/examples/quick/modelviews/parallax/content/Smiley.qml
new file mode 100644
index 0000000000..982b6c5d2b
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/Smiley.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+// This is taken from the declarative animation/basics/property-animation.qml
+// example
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: smiley.minHeight + 58
+ source: "pics/shadow.png"
+
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: minHeight
+ source: "pics/face-smile.png"
+
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing.type: Easing.OutExpo; duration: 300
+ }
+
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing.type: Easing.OutBounce; duration: 1000
+ }
+
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
+
diff --git a/examples/quick/modelviews/parallax/content/background.png b/examples/quick/modelviews/parallax/content/background.png
new file mode 100644
index 0000000000..a885950862
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/background.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/center.png b/examples/quick/modelviews/parallax/content/center.png
new file mode 100644
index 0000000000..7fbd802a44
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/center.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/clock-night.png b/examples/quick/modelviews/parallax/content/clock-night.png
new file mode 100644
index 0000000000..cc7151a397
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/clock-night.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/clock.png b/examples/quick/modelviews/parallax/content/clock.png
new file mode 100644
index 0000000000..462edacc0e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/clock.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/hour.png b/examples/quick/modelviews/parallax/content/hour.png
new file mode 100644
index 0000000000..f8061a1235
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/hour.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/minute.png b/examples/quick/modelviews/parallax/content/minute.png
new file mode 100644
index 0000000000..1297ec7c2b
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/minute.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/background.jpg b/examples/quick/modelviews/parallax/content/pics/background.jpg
new file mode 100644
index 0000000000..61cca2f138
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/background.jpg
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/face-smile.png b/examples/quick/modelviews/parallax/content/pics/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/face-smile.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/home-page.png b/examples/quick/modelviews/parallax/content/pics/home-page.png
new file mode 100644
index 0000000000..bd090c3708
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/home-page.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/home-page.svg b/examples/quick/modelviews/parallax/content/pics/home-page.svg
new file mode 100644
index 0000000000..4f16958844
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/home-page.svg
@@ -0,0 +1,445 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ overflow="visible"
+ enable-background="new 0 0 128 129.396"
+ xml:space="preserve"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="go-home.svg"
+ sodipodi:docbase="/home/jimmac/src/cvs/tango-icon-theme/scalable/actions"
+ version="1.0"
+ inkscape:export-filename="/home/tigert/My Downloads/go-home.png"
+ inkscape:export-xdpi="90.000000"
+ inkscape:export-ydpi="90.000000"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata367"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" /><dc:title>Go Home</dc:title><dc:creator><cc:Agent><dc:title>Jakub Steiner</dc:title></cc:Agent></dc:creator><dc:source>http://jimmac.musichall.cz</dc:source><dc:subject><rdf:Bag><rdf:li>home</rdf:li><rdf:li>return</rdf:li><rdf:li>go</rdf:li><rdf:li>default</rdf:li><rdf:li>user</rdf:li><rdf:li>directory</rdf:li></rdf:Bag></dc:subject><dc:contributor><cc:Agent><dc:title>Tuomas Kuosmanen</dc:title></cc:Agent></dc:contributor></cc:Work><cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/"><cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /></cc:License></rdf:RDF></metadata><defs
+ id="defs365"><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 24 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="48 : 24 : 1"
+ inkscape:persp3d-origin="24 : 16 : 1"
+ id="perspective92" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5060"
+ id="radialGradient5031"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
+ cx="605.71429"
+ cy="486.64789"
+ fx="605.71429"
+ fy="486.64789"
+ r="117.14286" /><linearGradient
+ inkscape:collect="always"
+ id="linearGradient5060"><stop
+ style="stop-color:black;stop-opacity:1;"
+ offset="0"
+ id="stop5062" /><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="1"
+ id="stop5064" /></linearGradient><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5060"
+ id="radialGradient5029"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
+ cx="605.71429"
+ cy="486.64789"
+ fx="605.71429"
+ fy="486.64789"
+ r="117.14286" /><linearGradient
+ id="linearGradient5048"><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="0"
+ id="stop5050" /><stop
+ id="stop5056"
+ offset="0.5"
+ style="stop-color:black;stop-opacity:1;" /><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="1"
+ id="stop5052" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5048"
+ id="linearGradient5027"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
+ x1="302.85715"
+ y1="366.64789"
+ x2="302.85715"
+ y2="609.50507" /><linearGradient
+ id="linearGradient2406"><stop
+ style="stop-color:#7c7e79;stop-opacity:1;"
+ offset="0"
+ id="stop2408" /><stop
+ id="stop2414"
+ offset="0.1724138"
+ style="stop-color:#848681;stop-opacity:1;" /><stop
+ style="stop-color:#898c86;stop-opacity:1;"
+ offset="1"
+ id="stop2410" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2390"><stop
+ style="stop-color:#919191;stop-opacity:1;"
+ offset="0"
+ id="stop2392" /><stop
+ style="stop-color:#919191;stop-opacity:0;"
+ offset="1"
+ id="stop2394" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2378"><stop
+ style="stop-color:#575757;stop-opacity:1;"
+ offset="0"
+ id="stop2380" /><stop
+ style="stop-color:#575757;stop-opacity:0;"
+ offset="1"
+ id="stop2382" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2368"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2370" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2372" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2349"><stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2351" /><stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2353" /></linearGradient><linearGradient
+ id="linearGradient2341"><stop
+ id="stop2343"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" /><stop
+ id="stop2345"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:0;" /></linearGradient><linearGradient
+ id="linearGradient2329"><stop
+ style="stop-color:#000000;stop-opacity:0.18556701;"
+ offset="0"
+ id="stop2331" /><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="1"
+ id="stop2333" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2319"><stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2321" /><stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2323" /></linearGradient><linearGradient
+ id="linearGradient2307"><stop
+ style="stop-color:#edd400;stop-opacity:1;"
+ offset="0"
+ id="stop2309" /><stop
+ style="stop-color:#998800;stop-opacity:1;"
+ offset="1"
+ id="stop2311" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2299"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2301" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2303" /></linearGradient><linearGradient
+ id="XMLID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="80.223602"
+ y1="117.5205"
+ x2="48.046001"
+ y2="59.7995"
+ gradientTransform="matrix(0.314683,0.000000,0.000000,0.314683,4.128264,3.742874)">
+ <stop
+ offset="0"
+ style="stop-color:#CCCCCC"
+ id="stop17" />
+ <stop
+ offset="0.9831"
+ style="stop-color:#FFFFFF"
+ id="stop19" />
+ <midPointStop
+ offset="0"
+ style="stop-color:#CCCCCC"
+ id="midPointStop48" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#CCCCCC"
+ id="midPointStop50" />
+ <midPointStop
+ offset="0.9831"
+ style="stop-color:#FFFFFF"
+ id="midPointStop52" />
+ </linearGradient><linearGradient
+ inkscape:collect="always"
+ xlink:href="#XMLID_2_"
+ id="linearGradient1514"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.336922,0.000000,0.000000,0.166888,17.98288,15.46151)"
+ x1="52.006104"
+ y1="166.1331"
+ x2="14.049017"
+ y2="-42.218513" /><linearGradient
+ id="XMLID_39_"
+ gradientUnits="userSpaceOnUse"
+ x1="64.387703"
+ y1="65.124001"
+ x2="64.387703"
+ y2="35.569"
+ gradientTransform="matrix(0.354101,0.000000,0.000000,0.354101,1.638679,-8.364921e-2)">
+ <stop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="stop336" />
+ <stop
+ offset="0.8539"
+ style="stop-color:#FF6200"
+ id="stop338" />
+ <stop
+ offset="1"
+ style="stop-color:#F25D00"
+ id="stop340" />
+ <midPointStop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="midPointStop335" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#FFFFFF"
+ id="midPointStop337" />
+ <midPointStop
+ offset="0.8539"
+ style="stop-color:#FF6200"
+ id="midPointStop339" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#FF6200"
+ id="midPointStop341" />
+ <midPointStop
+ offset="1"
+ style="stop-color:#F25D00"
+ id="midPointStop343" />
+ </linearGradient><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2299"
+ id="radialGradient2305"
+ cx="7.5326638"
+ cy="24.202574"
+ fx="7.5326638"
+ fy="24.202574"
+ r="8.2452128"
+ gradientTransform="matrix(4.100086,-1.627292e-17,2.125447e-14,4.201322,-25.41506,-78.53967)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2307"
+ id="radialGradient2313"
+ cx="19.985598"
+ cy="36.77816"
+ fx="19.985598"
+ fy="36.77816"
+ r="1.0821035"
+ gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.565787)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2319"
+ id="radialGradient2325"
+ cx="20.443665"
+ cy="37.425829"
+ fx="20.443665"
+ fy="37.425829"
+ r="1.0821035"
+ gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.731106)"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2329"
+ id="linearGradient2335"
+ x1="17.602522"
+ y1="26.057423"
+ x2="17.682528"
+ y2="32.654099"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.898789,0,0,1.071914,0.478025,-2.080838)" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2341"
+ id="radialGradient2339"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(4.100086,1.627292e-17,2.125447e-14,-4.201322,-5.198109,105.3535)"
+ cx="11.68129"
+ cy="19.554111"
+ fx="11.68129"
+ fy="19.554111"
+ r="8.2452126" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2349"
+ id="radialGradient2355"
+ cx="24.023088"
+ cy="40.56913"
+ fx="24.023088"
+ fy="40.56913"
+ r="16.28684"
+ gradientTransform="matrix(1.000000,0.000000,0.000000,0.431250,1.157278e-15,23.07369)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2368"
+ id="radialGradient2374"
+ cx="29.913452"
+ cy="30.442923"
+ fx="29.913452"
+ fy="30.442923"
+ r="4.0018832"
+ gradientTransform="matrix(3.751495,-2.191984e-22,1.723265e-22,3.147818,-82.00907,-65.70704)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2378"
+ id="radialGradient2384"
+ cx="24.195112"
+ cy="10.577631"
+ fx="24.195112"
+ fy="10.577631"
+ r="15.242914"
+ gradientTransform="matrix(1.125263,-3.585417e-8,4.269819e-8,1.340059,-3.006704,1.355395)"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2390"
+ id="linearGradient2396"
+ x1="30.603519"
+ y1="37.337803"
+ x2="30.603519"
+ y2="36.112415"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.263867,0,0,0.859794,-6.499556,8.390924)" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2406"
+ id="linearGradient2412"
+ x1="17.850183"
+ y1="28.939463"
+ x2="19.040216"
+ y2="41.03223"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.888785,0,0,1.08932,2.41099,-1.524336)" /></defs><sodipodi:namedview
+ inkscape:cy="-2.3755359"
+ inkscape:cx="25.234802"
+ inkscape:zoom="1"
+ inkscape:window-height="691"
+ inkscape:window-width="872"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="0.21568627"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:showpageshadow="false"
+ inkscape:window-x="466"
+ inkscape:window-y="157"
+ inkscape:current-layer="svg2"
+ fill="#555753"
+ showgrid="false"
+ stroke="#a40000"
+ showguides="true"
+ inkscape:guide-bbox="true" />
+ <g
+ style="display:inline"
+ id="g5022"
+ transform="matrix(2.158196e-2,0,0,1.859457e-2,43.12251,41.63767)"><rect
+ y="-150.69685"
+ x="-1559.2523"
+ height="478.35718"
+ width="1339.6335"
+ id="rect4173"
+ style="opacity:0.40206185;color:black;fill:url(#linearGradient5027);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:nodetypes="cccc"
+ id="path5058"
+ d="M -219.61876,-150.68038 C -219.61876,-150.68038 -219.61876,327.65041 -219.61876,327.65041 C -76.744594,328.55086 125.78146,220.48075 125.78138,88.454235 C 125.78138,-43.572302 -33.655436,-150.68036 -219.61876,-150.68038 z "
+ style="opacity:0.40206185;color:black;fill:url(#radialGradient5029);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:0.40206185;color:black;fill:url(#radialGradient5031);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M -1559.2523,-150.68038 C -1559.2523,-150.68038 -1559.2523,327.65041 -1559.2523,327.65041 C -1702.1265,328.55086 -1904.6525,220.48075 -1904.6525,88.454235 C -1904.6525,-43.572302 -1745.2157,-150.68036 -1559.2523,-150.68038 z "
+ id="path5018"
+ sodipodi:nodetypes="cccc" /></g><path
+ style="color:#000000;fill:url(#linearGradient1514);fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:1.0000006;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 21.619576,8.1833733 L 27.577035,8.1833733 C 28.416767,8.1833733 41.46351,23.618701 41.46351,24.524032 L 41.019989,43.020777 C 41.019989,43.92611 40.343959,44.654954 39.504227,44.654954 L 8.0469496,44.654954 C 7.2072167,44.654954 6.5311871,43.92611 6.5311871,43.020777 L 6.5876651,24.524032 C 6.5876651,23.618701 20.779844,8.1833733 21.619576,8.1833733 z "
+ id="rect1512"
+ sodipodi:nodetypes="ccccccccc" /><path
+ style="fill:none"
+ id="path5"
+ d="M 46.963575,45.735573 L 1.6386762,45.735573 L 1.6386762,0.41067554 L 46.963575,0.41067554 L 46.963575,45.735573 z " /><path
+ style="fill:url(#linearGradient2335);fill-opacity:1;fill-rule:evenodd"
+ id="path2327"
+ d="M 23,29 L 22.954256,44.090942 L 11.111465,44.090942 L 11,29 L 23,29 z "
+ clip-rule="evenodd"
+ sodipodi:nodetypes="ccccc" /><path
+ sodipodi:nodetypes="ccccccccc"
+ id="path2357"
+ d="M 21.780459,9.405584 L 27.339556,9.405584 C 28.123138,9.405584 40.340425,23.805172 40.340425,24.649756 L 39.993267,42.862067 C 39.993267,43.321326 39.84953,43.515532 39.480892,43.515532 L 8.0936894,43.529812 C 7.7250517,43.529812 7.5097258,43.449894 7.5097258,43.076262 L 7.7250676,24.649756 C 7.7250676,23.805172 20.99688,9.405584 21.780459,9.405584 z "
+ style="opacity:0.3125;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.00000012;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ clip-rule="evenodd"
+ d="M 7.2075295,27.943053 L 7.1532728,30.538247 L 25.521437,17.358993 L 40.807832,28.513421 L 40.879142,28.201707 L 24.508686,12.297576 L 7.2075295,27.943053 z "
+ id="path23"
+ style="opacity:0.2;fill:url(#radialGradient2384);fill-opacity:1;fill-rule:evenodd"
+ sodipodi:nodetypes="ccccccc" /><path
+ clip-rule="evenodd"
+ d="M 22,30 L 22,44.090942 L 12.188971,44.090942 L 12,30 L 22,30 z "
+ id="path188"
+ style="fill:url(#linearGradient2412);fill-opacity:1;fill-rule:evenodd"
+ sodipodi:nodetypes="ccccc" /><path
+ style="opacity:0.40909089;fill:url(#radialGradient2325);fill-opacity:1;fill-rule:evenodd"
+ id="path2315"
+ d="M 19.576856,36.44767 C 20.249646,36.44767 20.793472,36.922275 20.793472,37.506177 C 20.793472,38.095988 20.249646,38.574532 19.576856,38.574532 C 18.904584,38.574532 18.35817,38.095988 18.35817,37.506177 C 18.358685,36.922275 18.904584,36.44767 19.576856,36.44767 z "
+ clip-rule="evenodd" /><path
+ clip-rule="evenodd"
+ d="M 19.462314,35.932229 C 20.135103,35.932229 20.678929,36.406834 20.678929,36.990736 C 20.678929,37.580545 20.135103,38.059089 19.462314,38.059089 C 18.790041,38.059089 18.243627,37.580545 18.243627,36.990736 C 18.244142,36.406834 18.790041,35.932229 19.462314,35.932229 z "
+ id="path217"
+ style="fill:url(#radialGradient2313);fill-opacity:1;fill-rule:evenodd" /><path
+ d="M 24.447748,11.559337 L 43.374808,28.729205 L 43.869487,29.121196 L 44.273163,28.949811 L 43.900293,28.188138 L 43.622679,27.964702 L 24.447748,12.392396 L 5.0582327,28.135731 L 4.8206309,28.279851 L 4.603921,28.986637 L 5.0373408,29.115885 L 5.4218948,28.807462 L 24.447748,11.559337 z "
+ id="path342"
+ style="fill:url(#XMLID_39_)"
+ sodipodi:nodetypes="ccccccccccccc" /><path
+ style="fill:#ef2929;stroke:#a40000"
+ id="path362"
+ d="M 24.330168,2.2713382 L 2.4484294,20.372675 L 1.8237005,27.538603 L 3.8236367,29.602926 C 3.8236367,29.602926 24.231018,12.445641 24.44773,12.274963 L 44.08027,29.818223 L 45.978694,27.494226 L 44.362903,20.382852 L 24.44773,2.1668788 L 24.330168,2.2713382 z "
+ sodipodi:nodetypes="cccccccccc" />
+<path
+ style="opacity:0.40909089;color:#000000;fill:url(#radialGradient2305);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 2.8413446,20.613129 L 2.5497894,27.236494 L 24.369219,8.980075 L 24.298891,3.0867443 L 2.8413446,20.613129 z "
+ id="path1536"
+ sodipodi:nodetypes="ccccc" /><path
+ sodipodi:nodetypes="ccccc"
+ id="path2337"
+ d="M 24.483763,8.7509884 L 24.583223,2.9098867 L 43.912186,20.56184 L 45.403998,27.062652 L 24.483763,8.7509884 z "
+ style="opacity:0.13636367;color:#000000;fill:url(#radialGradient2339);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:0.31818183;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.99999934;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 27.102228,27.719824 L 36.142223,27.719824 C 36.912818,27.719824 37.53319,28.340194 37.53319,29.110791 L 37.525229,38.190012 C 37.525229,38.960608 36.928907,39.455981 36.158311,39.455981 L 27.102228,39.455981 C 26.331631,39.455981 25.711261,38.835608 25.711261,38.065012 L 25.711261,29.110791 C 25.711261,28.340194 26.331631,27.719824 27.102228,27.719824 z "
+ id="rect2361"
+ sodipodi:nodetypes="ccccccccc" /><rect
+ style="opacity:1;color:#000000;fill:#3465a4;fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:0.9999994;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect3263"
+ width="10.001333"
+ height="9.9624557"
+ x="26.507767"
+ y="28.514256"
+ rx="0.38128215"
+ ry="0.38128215" /><path
+ style="opacity:0.39772728;color:#000000;fill:url(#radialGradient2374);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999958;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 27.107118,34.408261 C 30.725101,34.739438 32.634842,32.962557 35.97527,32.855521 L 36,29.00603 L 27.088388,29 L 27.107118,34.408261 z "
+ id="rect2363"
+ sodipodi:nodetypes="ccccc" /></svg> \ No newline at end of file
diff --git a/examples/quick/modelviews/parallax/content/pics/shadow.png b/examples/quick/modelviews/parallax/content/pics/shadow.png
new file mode 100644
index 0000000000..8270565e87
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/shadow.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/yast-joystick.png b/examples/quick/modelviews/parallax/content/pics/yast-joystick.png
new file mode 100644
index 0000000000..858cea0301
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/yast-joystick.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/pics/yast-wol.png b/examples/quick/modelviews/parallax/content/pics/yast-wol.png
new file mode 100644
index 0000000000..7712180a3b
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/pics/yast-wol.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/quit.png b/examples/quick/modelviews/parallax/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/quit.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/content/second.png b/examples/quick/modelviews/parallax/content/second.png
new file mode 100644
index 0000000000..4aa9fb5e8e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/content/second.png
Binary files differ
diff --git a/examples/quick/modelviews/parallax/parallax.qml b/examples/quick/modelviews/parallax/parallax.qml
new file mode 100644
index 0000000000..30578e510e
--- /dev/null
+++ b/examples/quick/modelviews/parallax/parallax.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 320; height: 480
+
+ ParallaxView {
+ id: parallax
+ anchors.fill: parent
+ background: "content/pics/background.jpg"
+
+ Item {
+ property url icon: "content/pics/yast-wol.png"
+ width: 320; height: 480
+ Clock { anchors.centerIn: parent }
+ }
+
+ Item {
+ property url icon: "content/pics/home-page.png"
+ width: 320; height: 480
+ Smiley { }
+ }
+
+ Item {
+ property url icon: "content/pics/yast-joystick.png"
+ width: 320; height: 480
+
+ Loader {
+ anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter }
+ width: 300; height: 400
+ clip: true;
+ source: "../../samegame/samegame.qml"
+ }
+ }
+ }
+}
diff --git a/examples/quick/modelviews/pathview/pathview-example.qml b/examples/quick/modelviews/pathview/pathview-example.qml
new file mode 100644
index 0000000000..6161343830
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pathview-example.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 400; height: 240
+ color: "white"
+
+ ListModel {
+ id: appModel
+ ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" }
+ ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" }
+ ListElement { name: "Camera"; icon: "pics/Camera_48.png" }
+ ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" }
+ ListElement { name: "Messaging"; icon: "pics/EMail_48.png" }
+ ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" }
+ ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" }
+ }
+
+ Component {
+ id: appDelegate
+ Item {
+ width: 100; height: 100
+ scale: PathView.iconScale
+
+ Image {
+ id: myIcon
+ y: 20; anchors.horizontalCenter: parent.horizontalCenter
+ source: icon
+ smooth: true
+ }
+ Text {
+ anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
+ text: name
+ smooth: true
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: view.currentIndex = index
+ }
+ }
+ }
+
+ Component {
+ id: appHighlight
+ Rectangle { width: 80; height: 80; color: "lightsteelblue" }
+ }
+
+ PathView {
+ id: view
+ anchors.fill: parent
+ highlight: appHighlight
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ focus: true
+ model: appModel
+ delegate: appDelegate
+ path: Path {
+ startX: 10
+ startY: 50
+ PathAttribute { name: "iconScale"; value: 0.5 }
+ PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 }
+ PathAttribute { name: "iconScale"; value: 1.0 }
+ PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 }
+ PathAttribute { name: "iconScale"; value: 0.5 }
+ }
+ }
+}
diff --git a/examples/quick/modelviews/pathview/pics/AddressBook_48.png b/examples/quick/modelviews/pathview/pics/AddressBook_48.png
new file mode 100644
index 0000000000..1ab7c8eec1
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png b/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png
new file mode 100644
index 0000000000..f4b8689f87
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/Camera_48.png b/examples/quick/modelviews/pathview/pics/Camera_48.png
new file mode 100644
index 0000000000..c76b524945
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/Camera_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/DateBook_48.png b/examples/quick/modelviews/pathview/pics/DateBook_48.png
new file mode 100644
index 0000000000..58f5787fb8
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/EMail_48.png b/examples/quick/modelviews/pathview/pics/EMail_48.png
new file mode 100644
index 0000000000..d6d84a61be
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/EMail_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/TodoList_48.png b/examples/quick/modelviews/pathview/pics/TodoList_48.png
new file mode 100644
index 0000000000..0988448d9b
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png b/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png
new file mode 100644
index 0000000000..52638c50a7
--- /dev/null
+++ b/examples/quick/modelviews/pathview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/quick/modelviews/stringlistmodel/main.cpp b/examples/quick/modelviews/stringlistmodel/main.cpp
new file mode 100644
index 0000000000..12859316a3
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QStringList>
+
+#include <qqmlengine.h>
+#include <qqmlcontext.h>
+#include <qqml.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+
+/*
+ This example illustrates exposing a QStringList as a
+ model in QML
+*/
+
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+//![0]
+ QStringList dataList;
+ dataList.append("Item 1");
+ dataList.append("Item 2");
+ dataList.append("Item 3");
+ dataList.append("Item 4");
+
+ QQuickView view;
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+//![0]
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro b/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro
new file mode 100644
index 0000000000..19e62cd1b7
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/stringlistmodel.pro
@@ -0,0 +1,4 @@
+QT += qml quick
+
+SOURCES += main.cpp
+RESOURCES += stringlistmodel.qrc
diff --git a/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc
new file mode 100644
index 0000000000..17e9301471
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/stringlistmodel.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/quick/modelviews/stringlistmodel/view.qml b/examples/quick/modelviews/stringlistmodel/view.qml
new file mode 100644
index 0000000000..945763c295
--- /dev/null
+++ b/examples/quick/modelviews/stringlistmodel/view.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![0]
+
+ListView {
+ width: 100; height: 100
+
+ model: myModel
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ Text { text: modelData }
+ }
+}
+//![0]
diff --git a/examples/quick/modelviews/visualdatamodel/dragselection.qml b/examples/quick/modelviews/visualdatamodel/dragselection.qml
new file mode 100644
index 0000000000..c3186a5ad8
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/dragselection.qml
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+
+ width: 320
+ height: 480
+
+ property bool dragging: false
+
+ Component {
+ id: packageDelegate
+ Package {
+ id: packageRoot
+
+ MouseArea {
+ id: visibleContainer
+ Package.name: "visible"
+
+ width: 64
+ height: 64
+ enabled: packageRoot.VisualDataModel.inSelected
+
+ drag.target: draggable
+
+ Item {
+ id: draggable
+
+ width: 64
+ height: 64
+
+ Drag.active: visibleContainer.drag.active
+
+ anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
+
+ states: State {
+ when: visibleContainer.drag.active
+ AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} }
+ ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 }
+ PropertyChanges { target: root; dragging: true }
+ ParentChange { target: draggable; parent: root }
+ }
+ }
+ DropArea {
+ anchors.fill: parent
+ onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count)
+ }
+ }
+ Item {
+ id: selectionContainer
+ Package.name: "selection"
+
+ width: 64
+ height: 64
+
+ visible: PathView.onPath
+ }
+ Rectangle {
+ id: content
+ parent: visibleContainer
+
+ width: 58
+ height: 58
+
+ radius: 8
+
+ gradient: Gradient {
+ GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" }
+ GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" }
+ }
+
+ border.width: 2
+ border.color: "#007423"
+
+ state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible"
+
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "white"
+ text: modelData
+ font.pixelSize: 18
+ }
+
+ Rectangle {
+ anchors { right: parent.right; top: parent.top; margins: 3 }
+ width: 12; height: 12
+ color: packageRoot.VisualDataModel.inSelected ? "black" : "white"
+ radius: 6
+
+ border.color: "white"
+ border.width: 2
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected
+ }
+ }
+
+ states: [
+ State {
+ name: "selected"
+ ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 }
+ PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active }
+ PropertyChanges { target: gradientStart; color: "#017423" }
+ PropertyChanges { target: gradientStart; color: "#007423" }
+ }, State {
+ name: "visible"
+ PropertyChanges { target: packageRoot; VisualDataModel.inItems: true }
+ ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 }
+ PropertyChanges { target: gradientStart; color: "#8AC953" }
+ PropertyChanges { target: gradientStart; color: "#8BC953" }
+ }
+ ]
+ transitions: Transition {
+ PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" }
+ ParentAnimation {
+ target: content
+ NumberAnimation { target: content; properties: "x,y"; duration: 500 }
+ }
+ ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 }
+ }
+ }
+ }
+ }
+
+ VisualDataModel {
+ id: visualModel
+ model: 35
+ delegate: packageDelegate
+
+ groups: VisualDataGroup { id: selectedItems; name: "selected" }
+
+ Component.onCompleted: parts.selection.filterOnGroup = "selected"
+ }
+
+ PathView {
+ id: selectionView
+
+ height: 64
+ width: 64
+
+ model: visualModel.parts.selection
+
+ path: Path {
+ startX: 0
+ startY: 0
+ PathLine { x: 64; y: 64 }
+ }
+ }
+
+ GridView {
+ id: itemsView
+ anchors { fill: parent }
+ cellWidth: 64
+ cellHeight: 64
+ model: visualModel.parts.visible
+ }
+}
diff --git a/examples/quick/modelviews/visualdatamodel/slideshow.qml b/examples/quick/modelviews/visualdatamodel/slideshow.qml
new file mode 100644
index 0000000000..040c6be307
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/slideshow.qml
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Rectangle {
+ id: root
+
+ property Item displayItem: null
+
+ width: 300; height: 400
+
+ color: "black"
+
+ VisualDataModel {
+ id: visualModel
+
+ model: XmlListModel {
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2"
+ query: "/rss/channel/item"
+ namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
+
+ XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" }
+ XmlRole { name: "url"; query: "media:content/@url/string()" }
+ }
+
+ delegate: Item {
+ id: delegateItem
+
+ width: 76; height: 76
+
+ Rectangle {
+ id: image
+ x: 0; y: 0; width: 76; height: 76
+ border.width: 1
+ border.color: "white"
+ color: "black"
+
+ Image {
+ anchors.fill: parent
+ anchors.leftMargin: 1
+ anchors.topMargin: 1
+
+ source: imagePath
+ fillMode: Image.PreserveAspectFit
+
+ }
+
+ MouseArea {
+ id: clickArea
+ anchors.fill: parent
+
+ onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null
+ }
+
+ states: [
+ State {
+ when: root.displayItem === delegateItem
+ name: "inDisplay";
+ ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 }
+ PropertyChanges { target: image; z: 2 }
+ PropertyChanges { target: delegateItem; VisualDataModel.inItems: false }
+ },
+ State {
+ when: root.displayItem !== delegateItem
+ name: "inList";
+ ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 }
+ PropertyChanges { target: image; z: 1 }
+ PropertyChanges { target: delegateItem; VisualDataModel.inItems: true }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "inList"
+ SequentialAnimation {
+ PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true }
+ ParentAnimation {
+ target: image;
+ via: root
+ NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 }
+ }
+ }
+ }, Transition {
+ from: "inDisplay"
+ SequentialAnimation {
+ ParentAnimation {
+ target: image
+ NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 }
+ }
+ PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false }
+ }
+ }
+ ]
+ }
+ }
+ }
+
+
+ PathView {
+ id: imagePath
+
+ anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom }
+ model: visualModel
+
+ pathItemCount: 7
+ path: Path {
+ startX: -50; startY: 0
+ PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 }
+ PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 }
+ }
+ }
+
+ Item {
+ id: imageContainer
+ anchors { fill: parent; bottomMargin: 100 }
+ }
+}
diff --git a/examples/quick/modelviews/visualdatamodel/sortedmodel.qml b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml
new file mode 100644
index 0000000000..8d3b0a58e5
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/sortedmodel.qml
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 480; height: 640
+
+ Component {
+ id: numberDelegate
+
+ Text {
+ id: numberText
+ anchors { left: parent.left; right: parent.right }
+ text: number
+
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: 18
+
+ Text {
+ anchors { left: parent.left; baseline: parent.baseline }
+ text: index
+
+ horizontalAlignment: Text.AlignLeft
+ font.pixelSize: 12
+ }
+ Text {
+ anchors { right: parent.right; baseline: parent.baseline }
+ text: numberText.VisualDataModel.itemsIndex
+
+ horizontalAlignment: Text.AlignRight
+ font.pixelSize: 12
+ }
+ }
+ }
+
+ ListView {
+ anchors {
+ left: parent.left; top: parent.top;
+ right: parent.horizontalCenter; bottom: button.top
+ leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2
+ }
+
+ model: ListModel {
+ id: unsortedModel
+ }
+ delegate: numberDelegate
+ }
+ ListView {
+ anchors {
+ left: parent.horizontalCenter; top: parent.top;
+ right: parent.right; bottom: button.top
+ leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2
+ }
+ model: VisualDataModel {
+ model: unsortedModel
+ delegate: numberDelegate
+
+ items.onChanged: {
+ for (var i = 0; i < inserted.length; ++i) {
+ for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) {
+ var number = items.get(j).model.number
+ for (var l = 0, k = 0; l < unsortedModel.count; ++l) {
+ if (l == inserted[k].index) {
+ l += inserted[k].count - 1
+ ++k
+ } else if (number < items.get(l).model.number) {
+ items.move(j, l, 1)
+ break
+ }
+ }
+ inserted[i].index += 1;
+ inserted[i].count -= 1;
+ }
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: button
+
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 }
+ height: moreText.implicitHeight + 4
+
+ color: "black"
+
+ Text {
+ id: moreText
+
+ anchors.fill: parent
+ text: "More"
+ color: "white"
+ font.pixelSize: 18
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) })
+ }
+ }
+}
diff --git a/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject
new file mode 100644
index 0000000000..2bb4016996
--- /dev/null
+++ b/examples/quick/modelviews/visualdatamodel/visualdatamodel.qmlproject
@@ -0,0 +1,14 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/modelviews/visualitemmodel/visualitemmodel.qml b/examples/quick/modelviews/visualitemmodel/visualitemmodel.qml
new file mode 100644
index 0000000000..2e012adec6
--- /dev/null
+++ b/examples/quick/modelviews/visualitemmodel/visualitemmodel.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// This example demonstrates placing items in a view using
+// a VisualItemModel
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ color: "lightgray"
+ width: 320
+ height: 480
+ property bool printDestruction: false
+
+ VisualItemModel {
+ id: itemModel
+
+ Rectangle {
+ width: view.width; height: view.height
+ color: "#FFFEF0"
+ Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent }
+
+ Component.onDestruction: if (printDestruction) print("destroyed 1")
+ }
+ Rectangle {
+ width: view.width; height: view.height
+ color: "#F0FFF7"
+ Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent }
+
+ Component.onDestruction: if (printDestruction) print("destroyed 2")
+ }
+ Rectangle {
+ width: view.width; height: view.height
+ color: "#F4F0FF"
+ Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent }
+
+ Component.onDestruction: if (printDestruction) print("destroyed 3")
+ }
+ }
+
+ ListView {
+ id: view
+ anchors { fill: parent; bottomMargin: 30 }
+ model: itemModel
+ preferredHighlightBegin: 0; preferredHighlightEnd: 0
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem; flickDeceleration: 2000
+ cacheBuffer: 200
+ }
+
+ Rectangle {
+ width: root.width; height: 30
+ anchors { top: view.bottom; bottom: parent.bottom }
+ color: "gray"
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ Repeater {
+ model: itemModel.count
+
+ Rectangle {
+ width: 5; height: 5
+ radius: 3
+ color: view.currentIndex == index ? "blue" : "white"
+
+ MouseArea {
+ width: 20; height: 20
+ anchors.centerIn: parent
+ onClicked: view.currentIndex = index
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/mousearea/mousearea-example.qml b/examples/quick/mousearea/mousearea-example.qml
new file mode 100644
index 0000000000..30e3e62864
--- /dev/null
+++ b/examples/quick/mousearea/mousearea-example.qml
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: box
+ width: 400; height: 300
+
+ Rectangle {
+ id: redSquare
+ width: 120; height: 120
+ anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10
+ color: "red"
+
+ Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ property string buttonID
+
+ acceptedButtons: Qt.AllButtons
+ // Value 'All.Buttons' is eqivalent to:
+ // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24'
+
+ onEntered: info.text = 'Entered'
+ onExited: info.text = 'Exited (pressed=' + pressed + ')'
+
+ onPressed: {
+ if (mouse.button == Qt.LeftButton)
+ buttonID = 'LeftButton'
+ else if (mouse.button == Qt.RightButton)
+ buttonID = 'RightButton'
+ else if (mouse.button == Qt.MidButton)
+ buttonID = 'MiddleButton'
+ else if (mouse.button == Qt.BackButton)
+ buttonID = 'BackButton'
+ else if (mouse.button == Qt.ForwardButton)
+ buttonID = 'ForwardButton'
+ else if (mouse.button == Qt.TaskButton)
+ buttonID = 'TaskButton'
+ else if (mouse.button == Qt.ExtraButton4)
+ buttonID = 'ExtraButton4'
+ else if (mouse.button == Qt.ExtraButton5)
+ buttonID = 'ExtraButton5'
+ else if (mouse.button == Qt.ExtraButton6)
+ buttonID = 'ExtraButton6'
+ else if (mouse.button == Qt.ExtraButton7)
+ buttonID = 'ExtraButton7'
+ else if (mouse.button == Qt.ExtraButton8)
+ buttonID = 'ExtraButton8'
+ else if (mouse.button == Qt.ExtraButton9)
+ buttonID = 'ExtraButton9'
+ else if (mouse.button == Qt.ExtraButton10)
+ buttonID = 'ExtraButton10'
+ else if (mouse.button == Qt.ExtraButton11)
+ buttonID = 'ExtraButton11'
+ else if (mouse.button == Qt.ExtraButton12)
+ buttonID = 'ExtraButton12'
+ else if (mouse.button == Qt.ExtraButton13)
+ buttonID = 'ExtraButton13'
+ else if (mouse.button == Qt.ExtraButton14)
+ buttonID = 'ExtraButton14'
+ else if (mouse.button == Qt.ExtraButton15)
+ buttonID = 'ExtraButton15'
+ else if (mouse.button == Qt.ExtraButton16)
+ buttonID = 'ExtraButton16'
+ else if (mouse.button == Qt.ExtraButton17)
+ buttonID = 'ExtraButton17'
+ else if (mouse.button == Qt.ExtraButton18)
+ buttonID = 'ExtraButton18'
+ else if (mouse.button == Qt.ExtraButton19)
+ buttonID = 'ExtraButton19'
+ else if (mouse.button == Qt.ExtraButton20)
+ buttonID = 'ExtraButton20'
+ else if (mouse.button == Qt.ExtraButton21)
+ buttonID = 'ExtraButton21'
+ else if (mouse.button == Qt.ExtraButton22)
+ buttonID = 'ExtraButton22'
+ else if (mouse.button == Qt.ExtraButton23)
+ buttonID = 'ExtraButton23'
+ else if (mouse.button == Qt.ExtraButton24)
+ buttonID = 'ExtraButton24'
+
+ info.text = 'Pressed (' + buttonID + ' shift='
+ + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')'
+ var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y)
+ posInfo.text = + mouse.x + ',' + mouse.y + ' in square'
+ + ' (' + posInBox.x + ',' + posInBox.y + ' in window)'
+ }
+
+ onReleased: {
+ btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')'
+ posInfo.text = ''
+ }
+
+ onPressAndHold: btn.text = 'Press and hold'
+ onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')'
+ onDoubleClicked: btn.text = 'Double clicked'
+ }
+ }
+
+ Rectangle {
+ id: blueSquare
+ width: 120; height: 120
+ x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors
+ color: "blue"
+
+ Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: blueSquare
+ drag.axis: Drag.XandYAxis
+ drag.minimumX: 0
+ drag.maximumX: box.width - parent.width
+ drag.minimumY: 0
+ drag.maximumY: box.height - parent.width
+ }
+ }
+
+ Text {
+ id: info
+ anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
+
+ onTextChanged: console.log(text)
+ }
+
+ Text {
+ id: btn
+ anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
+ }
+
+ Text {
+ id: posInfo
+ anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20
+ }
+}
diff --git a/examples/quick/openglunderqml/main.cpp b/examples/quick/openglunderqml/main.cpp
new file mode 100644
index 0000000000..3b682deaec
--- /dev/null
+++ b/examples/quick/openglunderqml/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+
+#include <QtQuick/QQuickView>
+
+#include "squircle.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<Squircle>("QtQuick", 2, 0, "Squircle");
+
+ QQuickView view;
+ view.setSource(QUrl("main.qml"));
+ view.show();
+
+ return app.exec();
+
+}
diff --git a/examples/quick/openglunderqml/main.qml b/examples/quick/openglunderqml/main.qml
new file mode 100644
index 0000000000..1485cbbdb8
--- /dev/null
+++ b/examples/quick/openglunderqml/main.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+
+ width: 400
+ height: 300
+
+ Squircle {
+ SequentialAnimation on t {
+ NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
+ NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
+ loops: Animation.Infinite
+ running: true
+ }
+ }
+
+ Rectangle {
+ color: Qt.rgba(1, 1, 1, 0.8);
+ radius: 10
+ border.width: 1
+ border.color: "white"
+ anchors.fill: label
+ anchors.margins: -10
+ }
+
+ Text {
+ id: label
+ color: "black"
+ wrapMode: Text.WordWrap
+ text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML"
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: 20
+ }
+
+}
diff --git a/examples/quick/openglunderqml/openglunderqml.pro b/examples/quick/openglunderqml/openglunderqml.pro
new file mode 100644
index 0000000000..64a58b3729
--- /dev/null
+++ b/examples/quick/openglunderqml/openglunderqml.pro
@@ -0,0 +1,6 @@
+QT += qml quick
+
+HEADERS += squircle.h
+SOURCES += squircle.cpp main.cpp
+
+OTHER_FILES += main.qml
diff --git a/examples/quick/openglunderqml/squircle.cpp b/examples/quick/openglunderqml/squircle.cpp
new file mode 100644
index 0000000000..b56f0baaf6
--- /dev/null
+++ b/examples/quick/openglunderqml/squircle.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "squircle.h"
+
+#include <QtQuick/qsgengine.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QOpenGLShaderProgram>
+
+Squircle::Squircle()
+ : m_program(0)
+{
+ setFlag(ItemHasContents);
+}
+
+void Squircle::itemChange(ItemChange change, const ItemChangeData &)
+{
+ // The ItemSceneChange event is sent when we are first attached to a canvas.
+ if (change == ItemSceneChange) {
+ QQuickCanvas *c = canvas();
+
+ // Connect our the beforeRendering signal to our paint function.
+ // Since this call is executed on the rendering thread it must be
+ // a Qt::DirectConnection
+ connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
+
+ // If we allow QML to do the clearing, they would clear what we paint
+ // and nothing would show.
+ c->setClearBeforeRendering(false);
+ }
+}
+
+
+void Squircle::paint()
+{
+ if (!m_program) {
+ m_program = new QOpenGLShaderProgram();
+ m_program->addShaderFromSourceCode(QOpenGLShader::Vertex,
+ "attribute highp vec4 vertices;"
+ "varying highp vec2 coords;"
+ "void main() {"
+ " gl_Position = vertices;"
+ " coords = vertices.xy;"
+ "}");
+ m_program->addShaderFromSourceCode(QOpenGLShader::Fragment,
+ "uniform lowp float t;"
+ "varying highp vec2 coords;"
+ "void main() {"
+ " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));"
+ " i = smoothstep(t - 0.3, t + 0.3, i);"
+ " gl_FragColor = vec4(coords / 2. + .5, i, i);"
+ "}");
+
+ m_program->bindAttributeLocation("vertices", 0);
+ m_program->link();
+ }
+
+ m_program->bind();
+
+ m_program->enableAttributeArray(0);
+
+ float values[] = {
+ -1, -1,
+ 1, -1,
+ -1, 1,
+ 1, 1
+ };
+ m_program->setAttributeArray(0, GL_FLOAT, values, 2);
+ m_program->setUniformValue("t", (float) m_t);
+
+ glDisable(GL_DEPTH_TEST);
+
+ glClearColor(0, 0, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ m_program->disableAttributeArray(0);
+ m_program->release();
+}
+
+
diff --git a/examples/quick/openglunderqml/squircle.h b/examples/quick/openglunderqml/squircle.h
new file mode 100644
index 0000000000..283131a662
--- /dev/null
+++ b/examples/quick/openglunderqml/squircle.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SQUIRCLE_H
+#define SQUIRCLE_H
+
+#include <QtQuick/QQuickItem>
+#include <QtGui/QOpenGLShaderProgram>
+
+class Squircle : public QQuickItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
+
+public:
+ Squircle();
+
+ qreal t() const { return m_t; }
+ void setT(qreal t) { m_t = t; emit tChanged(); }
+
+ void itemChange(ItemChange change, const ItemChangeData &);
+
+signals:
+ void tChanged();
+
+public slots:
+ void paint();
+
+private:
+ QOpenGLShaderProgram *m_program;
+
+ qreal m_t;
+ bool m_render_under;
+ bool m_render_over;
+};
+
+#endif // SQUIRCLE_H
diff --git a/examples/quick/painteditem/painteditem.pro b/examples/quick/painteditem/painteditem.pro
new file mode 100644
index 0000000000..e3afd6b0f0
--- /dev/null
+++ b/examples/quick/painteditem/painteditem.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ smile \
+ textballoons
diff --git a/examples/quick/painteditem/smile/main.cpp b/examples/quick/painteditem/smile/main.cpp
new file mode 100644
index 0000000000..1c7888b10b
--- /dev/null
+++ b/examples/quick/painteditem/smile/main.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QPainter>
+#include <QtQml/qqml.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickpainteditem.h>
+class MyPaintItem : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged)
+public:
+ MyPaintItem()
+ : QQuickPaintedItem()
+ , m_face(QLatin1String(":-)"))
+ {
+ setAntialiasing(true);
+ }
+ QString face() const {return m_face;}
+ void setFace(const QString &face) {
+ if (m_face != face) {
+ m_face = face;
+ emit faceChanged();
+ }
+ }
+ virtual void paint(QPainter *p)
+ {
+ QRectF rect(0, 0, width(), height());
+ rect.adjust(10, 10, -10, -10);
+ p->setPen(QPen(Qt::black, 20));
+ p->setBrush(Qt::yellow);
+ p->drawEllipse(rect);
+ p->setPen(Qt::black);
+ p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2)));
+ p->drawText(rect, Qt::AlignCenter, m_face);
+ }
+signals:
+ void faceChanged();
+private:
+ QString m_face;
+};
+
+int main(int argc, char ** argv)
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<MyPaintItem>("MyModule", 1, 0, "MyPaintItem");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("smile.qml"));
+ view.show();
+ view.raise();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/quick/painteditem/smile/smile.pro b/examples/quick/painteditem/smile/smile.pro
new file mode 100644
index 0000000000..b1af4ee0ad
--- /dev/null
+++ b/examples/quick/painteditem/smile/smile.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = painteditem
+
+QT += qml quick
+
+macx: CONFIG -= app_bundle
+
+SOURCES += main.cpp
+
+CONFIG += console
+
diff --git a/examples/quick/painteditem/smile/smile.qml b/examples/quick/painteditem/smile/smile.qml
new file mode 100644
index 0000000000..33919bc04f
--- /dev/null
+++ b/examples/quick/painteditem/smile/smile.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import MyModule 1.0
+
+Rectangle {
+ width: 500
+ height: 500
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#00249a" }
+ GradientStop { position: 0.7; color: "#ffd94f" }
+ GradientStop { position: 1.0; color: "#ffa322" }
+ }
+ MyPaintItem {
+ renderTarget:PaintedItem.Image
+ clip:true
+ width:240
+ height:240
+ anchors.left : parent.left
+ anchors.top :parent.top
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+ MyPaintItem {
+ clip:true
+ renderTarget:PaintedItem.Image
+ width:240
+ height:240
+ anchors.right : parent.right
+ anchors.top :parent.top
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+ MyPaintItem {
+ clip:true
+ renderTarget:PaintedItem.Image
+ width:240
+ height:240
+ anchors.left : parent.left
+ anchors.bottom :parent.bottom
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+ MyPaintItem {
+ clip:true
+ renderTarget:PaintedItem.Image
+ width:240
+ height:240
+ anchors.right : parent.right
+ anchors.bottom :parent.bottom
+ anchors.margins: 10
+ smooth: true
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (parent.face == ":-)")
+ parent.face = ":-(";
+ else
+ parent.face = ":-)";
+ parent.update()
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h
new file mode 100644
index 0000000000..c500c1c525
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/TextBalloonPlugin/plugin.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QQmlExtensionPlugin>
+
+#include "../textballoon.h"
+
+class TextBalloonPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "textballoon.json")
+public:
+ void registerTypes(const char *uri)
+ {
+ qmlRegisterType<TextBalloon>(uri, 1, 0, "TextBalloon");
+ }
+};
diff --git a/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir
new file mode 100644
index 0000000000..e8a08ae9d3
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/TextBalloonPlugin/qmldir
@@ -0,0 +1 @@
+plugin qmltextballoonplugin
diff --git a/examples/quick/painteditem/textballoons/textballoon.cpp b/examples/quick/painteditem/textballoons/textballoon.cpp
new file mode 100644
index 0000000000..d097adfe1b
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoon.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textballoon.h"
+
+//! [0]
+TextBalloon::TextBalloon(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+ , rightAligned(false)
+{
+}
+//! [0]
+
+//! [1]
+void TextBalloon::paint(QPainter *painter)
+{
+ QBrush brush(QColor("#007430"));
+
+ painter->setBrush(brush);
+ painter->setPen(Qt::NoPen);
+ painter->setRenderHint(QPainter::Antialiasing);
+
+ painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10);
+
+ if (rightAligned)
+ {
+ const QPointF points[3] = {
+ QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0),
+ QPointF(boundingRect().width() - 20.0, boundingRect().height()),
+ QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0),
+ };
+ painter->drawConvexPolygon(points, 3);
+ }
+ else
+ {
+ const QPointF points[3] = {
+ QPointF(10.0, boundingRect().height() - 10.0),
+ QPointF(20.0, boundingRect().height()),
+ QPointF(30.0, boundingRect().height() - 10.0),
+ };
+ painter->drawConvexPolygon(points, 3);
+ }
+}
+//! [1]
+
+bool TextBalloon::isRightAligned()
+{
+ return this->rightAligned;
+}
+
+void TextBalloon::setRightAligned(bool rightAligned)
+{
+ this->rightAligned = rightAligned;
+}
diff --git a/examples/quick/painteditem/textballoons/textballoon.h b/examples/quick/painteditem/textballoons/textballoon.h
new file mode 100644
index 0000000000..93ed0a7105
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoon.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTBALLOON_H
+#define TEXTBALLOON_H
+
+#include <QtQuick>
+
+//! [0]
+class TextBalloon : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged)
+
+ public:
+ TextBalloon(QQuickItem *parent = 0);
+ void paint(QPainter *painter);
+
+ bool isRightAligned();
+ void setRightAligned(bool rightAligned);
+
+ private:
+ bool rightAligned;
+
+ signals:
+ void rightAlignedChanged();
+};
+//! [0]
+
+#endif
diff --git a/examples/quick/painteditem/textballoons/textballoon.json b/examples/quick/painteditem/textballoons/textballoon.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoon.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/quick/painteditem/textballoons/textballoons.pro b/examples/quick/painteditem/textballoons/textballoons.pro
new file mode 100644
index 0000000000..d612048ee8
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoons.pro
@@ -0,0 +1,25 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+
+TARGET = qmltextballoonplugin
+
+HEADERS += TextBalloonPlugin/plugin.h \
+ textballoon.h
+
+SOURCES += textballoon.cpp
+
+OTHER_FILES += textballoon.json
+
+DESTDIR = TextBalloonPlugin
+
+qdeclarativesources.files += \
+ TextBalloonPlugin/qmldir
+
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin
+
+sources.files = textballoons.qml
+sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons
+target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin
+
+INSTALLS = qdeclarativesources sources target
diff --git a/examples/quick/painteditem/textballoons/textballoons.qml b/examples/quick/painteditem/textballoons/textballoons.qml
new file mode 100644
index 0000000000..b00ce2bfed
--- /dev/null
+++ b/examples/quick/painteditem/textballoons/textballoons.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import TextBalloonPlugin 1.0
+
+Item {
+ height: 480
+ width: 640
+
+ //! [0]
+ ListModel {
+ id: balloonModel
+ ListElement {
+ balloonWidth: 200
+ }
+ ListElement {
+ balloonWidth: 350
+ }
+ }
+
+ ListView {
+ anchors.bottom: controls.top
+ anchors.bottomMargin: 2
+ anchors.top: parent.top
+ id: balloonView
+ delegate: TextBalloon {
+ anchors.right: index % 2 == 0 ? undefined : parent.right
+ height: 60
+ rightAligned: index % 2 == 0 ? false : true
+ width: balloonWidth
+ }
+ model: balloonModel
+ spacing: 5
+ width: parent.width
+ }
+ //! [0]
+
+ //! [1]
+ Rectangle {
+ id: controls
+
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.margins: 1
+ anchors.right: parent.right
+ border.width: 2
+ color: "white"
+ height: parent.height * 0.15
+
+ Text {
+ anchors.centerIn: parent
+ text: "Add another balloon"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: {
+ balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)})
+ balloonView.positionViewAtIndex(balloonView.count -1, ListView.End)
+ }
+ onEntered: {
+ parent.color = "#8ac953"
+ }
+ onExited: {
+ parent.color = "white"
+ }
+ }
+ }
+ //! [1]
+}
diff --git a/examples/quick/positioners/content/Button.qml b/examples/quick/positioners/content/Button.qml
new file mode 100644
index 0000000000..ee3aa9057e
--- /dev/null
+++ b/examples/quick/positioners/content/Button.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+
+ property string text
+ property string icon
+ signal clicked
+
+ border.color: "black"; color: "steelblue"; radius: 5
+ width: pix.width + textelement.width + 13
+ height: pix.height + 10
+
+ Image { id: pix; x: 5; y:5; source: parent.icon }
+
+ Text {
+ id: textelement
+ text: page.text; color: "white"
+ x: pix.width + pix.x + 3
+ anchors.verticalCenter: pix.verticalCenter
+ }
+
+ MouseArea {
+ id: mr
+ anchors.fill: parent
+ onClicked: { parent.focus = true; page.clicked() }
+ }
+
+ states: State {
+ name: "pressed"; when: mr.pressed
+ PropertyChanges { target: textelement; x: 5 }
+ PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+}
diff --git a/examples/quick/positioners/content/add.png b/examples/quick/positioners/content/add.png
new file mode 100644
index 0000000000..1ee45423e3
--- /dev/null
+++ b/examples/quick/positioners/content/add.png
Binary files differ
diff --git a/examples/quick/positioners/content/del.png b/examples/quick/positioners/content/del.png
new file mode 100644
index 0000000000..8d2eaed523
--- /dev/null
+++ b/examples/quick/positioners/content/del.png
Binary files differ
diff --git a/examples/quick/positioners/positioners-attachedproperties.qml b/examples/quick/positioners/positioners-attachedproperties.qml
new file mode 100644
index 0000000000..a05927f5ea
--- /dev/null
+++ b/examples/quick/positioners/positioners-attachedproperties.qml
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 100
+
+ // Create row with four rectangles, the fourth one is hidden
+ Row {
+ id: row
+
+ Rectangle {
+ id: red
+ color: "red"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(red.Positioner)
+ }
+ }
+
+ Rectangle {
+ id: green
+ color: "green"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(green.Positioner)
+ }
+ }
+
+ Rectangle {
+ id: blue
+ color: "blue"
+ width: 100
+ height: 100
+
+ // When mouse is clicked, display the values of the positioner
+ MouseArea {
+ anchors.fill: parent
+ onClicked: row.showInfo(blue.Positioner)
+ }
+ }
+
+ // This rectangle is not visible, so it doesn't have a positioner value
+ Rectangle {
+ color: "black"
+ width: 100
+ height: 100
+ visible: false
+ }
+
+ // Print the index of the child item in the positioner and convenience
+ // properties showing if it's the first or last item.
+ function showInfo(positioner) {
+ console.log("Item Index = " + positioner.index)
+ console.log(" isFirstItem = " + positioner.isFirstItem)
+ console.log(" isLastItem = " + positioner.isLastItem)
+ }
+ }
+}
diff --git a/examples/quick/positioners/positioners.qml b/examples/quick/positioners/positioners.qml
new file mode 100644
index 0000000000..6627ad7dd4
--- /dev/null
+++ b/examples/quick/positioners/positioners.qml
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: page
+ width: 320; height: 480
+ Flickable {
+ anchors.fill: parent
+ contentWidth: 420; contentHeight: 420
+
+ Column {
+ id: layout1
+ y: 0
+ move: Transition {
+ NumberAnimation { properties: "y"; easing.type: Easing.OutBounce }
+ }
+ add: Transition {
+ NumberAnimation { properties: "y"; easing.type: Easing.OutQuad }
+ }
+
+ Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueV1
+ visible: opacity != 0
+ width: 100; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueV2
+ visible: opacity != 0
+ width: 100; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Row {
+ id: layout2
+ y: 300
+ move: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.OutBounce }
+ }
+ add: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.OutQuad }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueH1
+ visible: opacity != 0
+ width: 50; height: 100
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueH2
+ visible: opacity != 0
+ width: 50; height: 100
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ }
+
+ Button {
+ x: 135; y: 90
+ text: "Remove"
+ icon: "del.png"
+
+ onClicked: {
+ blueH2.opacity = 0
+ blueH1.opacity = 0
+ blueV1.opacity = 0
+ blueV2.opacity = 0
+ blueG1.opacity = 0
+ blueG2.opacity = 0
+ blueG3.opacity = 0
+ blueF1.opacity = 0
+ blueF2.opacity = 0
+ blueF3.opacity = 0
+ }
+ }
+
+ Button {
+ x: 145; y: 140
+ text: "Add"
+ icon: "add.png"
+
+ onClicked: {
+ blueH2.opacity = 1
+ blueH1.opacity = 1
+ blueV1.opacity = 1
+ blueV2.opacity = 1
+ blueG1.opacity = 1
+ blueG2.opacity = 1
+ blueG3.opacity = 1
+ blueF1.opacity = 1
+ blueF2.opacity = 1
+ blueF3.opacity = 1
+ }
+ }
+
+ Grid {
+ x: 260; y: 0
+ columns: 3
+
+ move: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ add: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueG1
+ visible: opacity != 0
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueG2
+ visible: opacity != 0
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueG3
+ visible: opacity != 0
+ width: 50; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Flow {
+ id: layout4
+ x: 260; y: 250; width: 150
+
+ move: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ add: Transition {
+ NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueF1
+ visible: opacity != 0
+ width: 60; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueF2
+ visible: opacity != 0
+ width: 60; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+
+ Rectangle {
+ id: blueF3
+ visible: opacity != 0
+ width: 40; height: 50
+ color: "lightsteelblue"
+ border.color: "black"
+ radius: 15
+ Behavior on opacity { NumberAnimation {} }
+ }
+
+ Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ }
+}
diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro
new file mode 100644
index 0000000000..529f65ac25
--- /dev/null
+++ b/examples/quick/quick.pro
@@ -0,0 +1,17 @@
+TEMPLATE = subdirs
+SUBDIRS = accessibility \
+ animation \
+ draganddrop
+ #canvas \
+ #imageelements \
+ #keyinteraction \
+ #modelviews \
+ #mousearea \
+ #openglunderqml \
+ #painteditem \
+ #positioners \
+ #righttoleft \
+ #shadereffects \
+ #text \
+ #threading \
+ #touchinteraction
diff --git a/examples/quick/righttoleft/layoutdirection/layoutdirection.qml b/examples/quick/righttoleft/layoutdirection/layoutdirection.qml
new file mode 100644
index 0000000000..0c65647d5b
--- /dev/null
+++ b/examples/quick/righttoleft/layoutdirection/layoutdirection.qml
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ property bool mirror
+ property int direction: Qt.application.layoutDirection
+ LayoutMirroring.enabled: mirror
+ LayoutMirroring.childrenInherit: true
+ width: column.width + 80
+ height: column.height + 40
+ Column {
+ id: column
+ width: 190
+ spacing: 10
+ anchors.centerIn: parent
+
+ Text {
+ text: "Row"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Row {
+ layoutDirection: root.direction
+ spacing: 10
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 4
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "Grid"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Grid {
+ layoutDirection: root.direction
+ spacing: 10; columns: 4
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 11
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "Flow"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Flow {
+ layoutDirection: root.direction
+ spacing: 10; width: parent.width
+ move: Transition {
+ NumberAnimation {
+ properties: "x"
+ }
+ }
+ Repeater {
+ model: 10
+ Loader {
+ property int value: index
+ sourceComponent: positionerDelegate
+ }
+ }
+ }
+
+ Text {
+ text: "ListView"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ ListView {
+ id: listView
+ clip: true
+ width: parent.width; height: 40
+ layoutDirection: root.direction
+ orientation: Qt.Horizontal
+ model: 48
+ delegate: viewDelegate
+ }
+
+ Text {
+ text: "GridView"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ GridView {
+ clip: true
+ width: 200; height: 160
+ cellWidth: 50; cellHeight: 50
+ layoutDirection: root.direction
+ model: 48
+ delegate: viewDelegate
+ }
+
+ Rectangle {
+ height: 50; width: parent.width
+ color: mouseArea.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.direction ? "Right to left" : "Left to right"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ if (root.direction == Qt.LeftToRight) {
+ root.direction = Qt.RightToLeft;
+ } else {
+ root.direction = Qt.LeftToRight;
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ height: 50; width: parent.width
+ color: mouseArea2.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ anchors.fill: parent
+ onClicked: {
+ root.mirror = !root.mirror;
+ }
+ }
+ }
+ }
+
+ Component {
+ id: positionerDelegate
+ Rectangle {
+ width: 40; height: 40
+ color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0)
+ Text {
+ text: parent.parent.value+1
+ color: "white"
+ font.pixelSize: 18
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Component {
+ id: viewDelegate
+ Item {
+ width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50
+ Rectangle {
+ width: 40; height: 40
+ color: Qt.rgba(0.5+(48 - index)*Math.random()/48,
+ 0.3+index*Math.random()/48,
+ 0.3*Math.random(),
+ 1.0)
+ Text {
+ text: index+1
+ color: "white"
+ font.pixelSize: 18
+ anchors.centerIn: parent
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject
new file mode 100644
index 0000000000..33cbb3c9e2
--- /dev/null
+++ b/examples/quick/righttoleft/layoutdirection/layoutdirection.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "layoutdirection.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml
new file mode 100644
index 0000000000..5c4739bd57
--- /dev/null
+++ b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qml
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft
+ LayoutMirroring.enabled: mirror
+ LayoutMirroring.childrenInherit: true
+ width: 400
+ height: 875
+ color: "lightsteelblue"
+
+ Column {
+ spacing: 10
+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 }
+
+ Text {
+ text: "Positioners"
+ anchors.left: parent.left
+ }
+
+ Column {
+ id: positioners
+ spacing: 5
+ anchors.left: parent.left
+ Row {
+ id: row
+ spacing: 4
+ property string text: "THISISROW"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Flow {
+ id: flow
+ spacing: 4
+ width: 90
+ property string text: "THISISFLOW"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Grid {
+ id: grid
+ spacing: 4
+ columns: 6
+ property string text: "THISISGRID"
+ anchors.left: parent.left
+ Repeater {
+ model: parent.text.length
+ delegate: positionerDelegate
+ }
+ }
+ Component {
+ id: positionerDelegate
+ Text {
+ color: "white"
+ font.pixelSize: 20
+ text: parent.text[index]
+ Rectangle {
+ z: -1
+ opacity: 0.7
+ color: "black"
+ anchors.fill: parent
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Text alignment"
+ anchors.left: parent.left
+ }
+
+ Rectangle {
+ id: textStrings
+ width: 148
+ height: 85
+ color: "white"
+ anchors.left: parent.left
+ Column {
+ spacing: 5
+ width: parent.width
+ anchors { fill: parent; margins: 5 }
+ Text {
+ id: englishText
+ width: parent.width
+ text: "English text"
+ }
+ Text {
+ id: arabicText
+ width: parent.width
+ text: "النص العربي"
+ }
+ Text {
+ id: leftAlignedText
+ width: parent.width
+ text: "Text aligned to left"
+ horizontalAlignment: Text.AlignLeft
+ }
+ Text {
+ id: rightAlignedText
+ width: parent.width
+ text: "Text aligned to right"
+ horizontalAlignment: Text.AlignRight
+ }
+ }
+ }
+
+ Text {
+ text: "Model views"
+ anchors.left: parent.left
+ }
+
+ Column {
+ id: views
+ spacing: 10
+ anchors.left: parent.left
+ ListView {
+ id: listView
+ z: -1
+ clip: true
+ model: text.length
+ width: 360; height: 45
+ orientation: Qt.Horizontal
+ property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW"
+ delegate: Rectangle {
+ color: "black"
+ width: 45; height: 45
+ Rectangle {
+ anchors { fill: parent; margins: 1 }
+ color: "red"
+ }
+ Text {
+ text: listView.text[index]
+ font.pixelSize: 30
+ anchors.centerIn: parent
+ }
+ }
+ }
+ GridView {
+ id: gridView
+ z: -1
+ clip: true
+ model: text.length
+ width: 180; height: 90
+ cellWidth: 45; cellHeight: 45
+ property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW"
+ anchors.left: parent.left
+ delegate: Rectangle {
+ color: "black"
+ width: 45; height: 45
+ Rectangle {
+ anchors { fill: parent; margins: 1 }
+ color: "red"
+ }
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 30
+ text: gridView.text[index]
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Item x"
+ anchors.left: parent.left
+ }
+ Rectangle {
+ id: items
+ color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
+ width: 275; height: 95
+ anchors.left: parent.left
+ Rectangle {
+ y: 5; x: 5
+ width: 130; height: 40
+ Text {
+ text: "Item with x: 5\n(not mirrored)"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ color: Qt.rgba(0.7, 0.7, 0.7)
+ y: 50; x: mirror(5)
+ width: 130; height: 40
+ function mirror(value) {
+ return LayoutMirroring.enabled ? (parent.width - width - value) : value;
+ }
+ Text {
+ text: "Item with x: " + parent.x + "\n(manually mirrored)"
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Text {
+ text: "Item anchors"
+ anchors.left: parent.left
+ }
+
+ Rectangle {
+ id: anchoredItems
+ color: Qt.rgba(0.2, 0.2, 0.2, 0.6)
+ width: 270; height: 170
+ anchors.left: parent.left
+ Rectangle {
+ id: blackRectangle
+ color: "black"
+ width: 180; height: 90
+ anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 }
+ Text {
+ text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent."
+ color: "white"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: whiteRectangle
+ color: "white"
+ width: 120; height: 70
+ anchors { left: parent.left; bottom: parent.bottom }
+ Text {
+ text: "Left side anchored\nto the left side\nof the parent."
+ color: "black"
+ anchors.centerIn: parent
+ }
+ }
+ Rectangle {
+ id: grayRectangle
+ color: Qt.rgba(0.7, 0.7, 0.7)
+ width: 140; height: 90
+ anchors { right: parent.right; bottom: parent.bottom }
+ Text {
+ text: "Right side anchored\nto the right side\nof the parent."
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Rectangle {
+ id: mirrorButton
+ color: mouseArea2.pressed ? "black" : "gray"
+ height: 50; width: parent.width
+ anchors.left: parent.left
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ anchors.fill: parent
+ onClicked: {
+ root.mirror = !root.mirror;
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject
new file mode 100644
index 0000000000..72bc04a8a9
--- /dev/null
+++ b/examples/quick/righttoleft/layoutmirroring/layoutmirroring.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "layoutmirroring.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/righttoleft/textalignment/textalignment.qml b/examples/quick/righttoleft/textalignment/textalignment.qml
new file mode 100644
index 0000000000..ef5b97bb1a
--- /dev/null
+++ b/examples/quick/righttoleft/textalignment/textalignment.qml
@@ -0,0 +1,427 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ color: "white"
+ width: containerColumn.width
+ height: containerColumn.height + containerColumn.anchors.topMargin
+
+ property bool mirror: false
+ property variant horizontalAlignment: undefined
+
+ property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"]
+ property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"]
+ property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"]
+ property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput]
+
+ function shortText(horizontalAlignment) {
+
+ // all the different QML editors have
+ // the same alignment values
+ switch (horizontalAlignment) {
+ case Text.AlignLeft:
+ return "L";
+ case Text.AlignRight:
+ return "R";
+ case Text.AlignHCenter:
+ return "C";
+ case Text.AlignJustify:
+ return "J";
+ default:
+ return "Error";
+ }
+ }
+ Column {
+ id: containerColumn
+ spacing: 10
+ width: editorTypeRow.width
+ anchors { top: parent.top; topMargin: 5 }
+ Row {
+ id: editorTypeRow
+ Repeater {
+ model: editorType.length
+ Item {
+ width: editorColumn.width
+ height: editorColumn.height
+ Column {
+ id: editorColumn
+ spacing: 5
+ width: textColumn.width+10
+ Text {
+ text: root.editorType[index]
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Column {
+ id: textColumn
+ spacing: 5
+ anchors.horizontalCenter: parent.horizontalCenter
+ Repeater {
+ model: textComponents.length
+ delegate: textComponents[index]
+ }
+ }
+ }
+ }
+ }
+ }
+ Column {
+ spacing: 2
+ width: parent.width
+ Rectangle {
+ // button
+ height: 50; width: parent.width
+ color: mouseArea.pressed ? "black" : "lightgray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: root.mirror ? "Mirrored" : "Not mirrored"
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ property int index: 0
+ anchors.fill: parent
+ onClicked: root.mirror = !root.mirror
+ }
+ }
+ Rectangle {
+ // button
+ height: 50; width: parent.width
+ color: mouseArea2.pressed ? "black" : "gray"
+ Column {
+ anchors.centerIn: parent
+ Text {
+ text: {
+ if (root.horizontalAlignment == undefined)
+ return "Implict alignment";
+ switch (root.horizontalAlignment) {
+ case Text.AlignLeft:
+ return "Left alignment";
+ case Text.AlignRight:
+ return "Right alignment";
+ case Text.AlignHCenter:
+ return "Center alignment";
+ case Text.AlignJustify:
+ return "Justify alignment";
+ }
+ }
+ color: "white"
+ font.pixelSize: 16
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ text: "(click here to toggle)"
+ color: "white"
+ font.pixelSize: 10
+ font.italic: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ MouseArea {
+ id: mouseArea2
+ property int index: 0
+ anchors.fill: parent
+ onClicked: {
+ if (index < 0) {
+ root.horizontalAlignment = undefined;
+ } else {
+ root.horizontalAlignment = Math.pow(2, index);
+ }
+ index = (index + 2) % 5 - 1;
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: plainTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: styledTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ style: Text.Sunken
+ styleColor: "white"
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: richTextComponent
+ Text {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: italicRichTextComponent
+ Text {
+ width: 180
+ text: "<i>" + root.text[index] + "</i>"
+ font.pixelSize: 24
+ wrapMode: Text.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ textFormat: Text.RichText
+ property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3)
+ Rectangle {
+ z: -1
+ color: parent.backgroundColor
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: plainTextEdit
+ TextEdit {
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ cursorVisible: true
+ wrapMode: TextEdit.WordWrap
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.5, 0.5, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: italicTextEdit
+ TextEdit {
+ width: 180
+ text: "<i>" + root.text[index] + "<i>"
+ font.pixelSize: 24
+ cursorVisible: true
+ wrapMode: TextEdit.WordWrap
+ textFormat: TextEdit.RichText
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.5, 0.5, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+
+ Component {
+ id: textInput
+ Item {
+ width: 180
+ height: textInput.text.length > 20 ? 3*textInput.height : textInput.height
+ TextInput {
+ id: textInput
+ width: 180
+ text: root.text[index]
+ font.pixelSize: 24
+ cursorVisible: true
+ horizontalAlignment: root.horizontalAlignment
+ LayoutMirroring.enabled: root.mirror
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.6, 0.4, 0.2, 0.3)
+ anchors.fill: parent
+ }
+ Text {
+ text: root.description[index]
+ color: Qt.rgba(1,1,1,1.0)
+ anchors.centerIn: parent
+ Rectangle {
+ z: -1
+ color: Qt.rgba(0.3, 0, 0, 0.3)
+ anchors { fill: parent; margins: -3 }
+ }
+ }
+ Text {
+ color: "white"
+ text: shortText(parent.horizontalAlignment)
+ anchors { top: parent.top; right: parent.right; margins: 2 }
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/righttoleft/textalignment/textalignment.qmlproject b/examples/quick/righttoleft/textalignment/textalignment.qmlproject
new file mode 100644
index 0000000000..e4b5061364
--- /dev/null
+++ b/examples/quick/righttoleft/textalignment/textalignment.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "textalignment.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/shadereffects/content/Slider.qml b/examples/quick/shadereffects/content/Slider.qml
new file mode 100644
index 0000000000..ff5f628b14
--- /dev/null
+++ b/examples/quick/shadereffects/content/Slider.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property real value: bar.x / (foo.width - bar.width)
+ Item {
+ id: foo
+ width: parent.width - 4
+ height: 6
+ anchors.centerIn: parent
+
+ Rectangle {
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: bar.horizontalCenter
+ color: "blue"
+ radius: 3
+ }
+ Rectangle {
+ height: parent.height
+ anchors.left: bar.horizontalCenter
+ anchors.right: parent.right
+ color: "gray"
+ radius: 3
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ radius: 3
+ border.width: 2
+ border.color: "black"
+ }
+
+ Rectangle {
+ id: bar
+ y: -7
+ width: 20
+ height: 20
+ radius: 15
+ color: "white"
+ border.width: 2
+ border.color: "black"
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ drag.axis: Drag.XAxis
+ drag.minimumX: 0
+ drag.maximumX: foo.width - parent.width
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/shadereffects/content/face-smile.png b/examples/quick/shadereffects/content/face-smile.png
new file mode 100644
index 0000000000..3d66d72578
--- /dev/null
+++ b/examples/quick/shadereffects/content/face-smile.png
Binary files differ
diff --git a/examples/quick/shadereffects/content/qt-logo.png b/examples/quick/shadereffects/content/qt-logo.png
new file mode 100644
index 0000000000..7d3e97eb36
--- /dev/null
+++ b/examples/quick/shadereffects/content/qt-logo.png
Binary files differ
diff --git a/examples/quick/shadereffects/shadereffects.qml b/examples/quick/shadereffects/shadereffects.qml
new file mode 100644
index 0000000000..b820c8131e
--- /dev/null
+++ b/examples/quick/shadereffects/shadereffects.qml
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Image {
+ width: 320
+ height: 480
+/*!
+ \title QML Examples - Shader Effects
+ \example declarative/shadereffects
+ \image qml-shadereffects-example.png
+ \brief This is a shader effects example
+
+ This example demonstrates a couple of visual effects that you can perform
+ with shaders in QtQuick 2.0
+*/
+ source: "../snake/content/pics/background.png"
+
+ Flickable {
+ anchors.fill: parent
+ contentWidth: 640
+ contentHeight: 360
+
+ ShaderEffectSource {
+ id: theSource
+ sourceItem: theItem
+ smooth: true
+ }
+
+ function saturate(x) {
+ return Math.min(Math.max(x, 0), 1)
+ }
+
+ function sliderToColor(x) {
+ return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)),
+ saturate(Math.min(6 * x, 4 - 6 * x)),
+ saturate(Math.min(6 * x - 2, 6 - 6 * x)))
+ }
+
+ Grid {
+ anchors.centerIn: parent
+ columns: 3
+
+ Item {
+ id: theItem
+ width: 180
+ height: 180
+ ListView {
+ anchors.centerIn: parent
+ width: 160
+ height: 140
+ clip: true
+ snapMode: ListView.SnapOneItem
+ model: VisualItemModel {
+ Text {
+ width: 160
+ height: 140
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 120
+ font.family: "Times"
+ color: "blue"
+ text: "Qt"
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "content/qt-logo.png"
+ smooth: true
+ }
+ Image {
+ width: 160
+ height: 140
+ source: "content/face-smile.png"
+ smooth: true
+ }
+ }
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property real amplitude: 0.04 * wobbleSlider.value
+ property real frequency: 20
+ property real time: 0
+ NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
+ fragmentShader:
+ "uniform lowp float qt_Opacity;" +
+ "uniform highp float amplitude;" +
+ "uniform highp float frequency;" +
+ "uniform highp float time;" +
+ "uniform sampler2D source;" +
+ "varying highp vec2 qt_TexCoord0;" +
+ "void main() {" +
+ " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
+ " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
+ "}"
+ Slider {
+ id: wobbleSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant shadow: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(0.0, 1.0 / height)
+ property variant source: ShaderEffectSource {
+ smooth: true
+ sourceItem: ShaderEffect {
+ width: theItem.width
+ height: theItem.height
+ property variant delta: Qt.size(1.0 / width, 0.0)
+ property variant source: theSource
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+ + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+ + 0.2466 * texture2D(source, qt_TexCoord0)
+ + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+ + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity;
+ }"
+ }
+ }
+ property real angle: 0
+ property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle))
+ NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 }
+ property variant delta: Qt.size(offset.x / width, offset.y / height)
+ property real darkness: shadowSlider.value
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform highp vec2 offset;
+ uniform sampler2D source;
+ uniform sampler2D shadow;
+ uniform highp float darkness;
+ uniform highp vec2 delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 fg = texture2D(source, qt_TexCoord0);
+ lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta);
+ gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity;
+ }"
+ Slider {
+ id: shadowSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property variant delta: Qt.size(0.5 / width, 0.5 / height)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform highp vec2 delta;
+ uniform highp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta);
+ lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y));
+ lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y));
+ lowp vec4 br = texture2D(source, qt_TexCoord0 + delta);
+ lowp vec4 gx = (tl + bl) - (tr + br);
+ lowp vec4 gy = (tl + tr) - (bl + br);
+ gl_FragColor.xyz = vec3(0.);
+ gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity;
+ }"
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ property variant source: theSource
+ property color tint: sliderToColor(colorizeSlider.value)
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp vec4 tint;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 c = texture2D(source, qt_TexCoord0);
+ lowp float lo = min(min(c.x, c.y), c.z);
+ lowp float hi = max(max(c.x, c.y), c.z);
+ gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w);
+ }"
+ Slider {
+ id: colorizeSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ ShaderEffect {
+ width: 180
+ height: 180
+ mesh: Qt.size(10, 10)
+ property variant source: theSource
+ property real bend: 0
+ property real minimize: 0
+ property real side: genieSlider.value
+ SequentialAnimation on bend {
+ loops: Animation.Infinite
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1600 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ }
+ SequentialAnimation on minimize {
+ loops: Animation.Infinite
+ PauseAnimation { duration: 300 }
+ NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine }
+ PauseAnimation { duration: 1300 }
+ }
+ vertexShader: "
+ uniform highp mat4 qt_Matrix;
+ uniform highp float bend;
+ uniform highp float minimize;
+ uniform highp float side;
+ uniform highp float width;
+ uniform highp float height;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ qt_TexCoord0 = qt_MultiTexCoord0;
+ highp vec4 pos = qt_Vertex;
+ pos.y = mix(qt_Vertex.y, height, minimize);
+ highp float t = pos.y / height;
+ t = (3. - 2. * t) * t * t;
+ pos.x = mix(qt_Vertex.x, side * width, t * bend);
+ gl_Position = qt_Matrix * pos;
+ }"
+ Slider {
+ id: genieSlider
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 40
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/text/fonts/availableFonts.qml b/examples/quick/text/fonts/availableFonts.qml
new file mode 100644
index 0000000000..0b87259556
--- /dev/null
+++ b/examples/quick/text/fonts/availableFonts.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 480; height: 640; color: "steelblue"
+
+ ListView {
+ anchors.fill: parent; model: Qt.fontFamilies()
+
+ delegate: Item {
+ height: 40; width: ListView.view.width
+ Text {
+ anchors.centerIn: parent
+ text: modelData; font.family: modelData; font.pixelSize: 24; color: "white"
+ }
+ }
+ }
+}
diff --git a/examples/quick/text/fonts/banner.qml b/examples/quick/text/fonts/banner.qml
new file mode 100644
index 0000000000..6c9aa25fa1
--- /dev/null
+++ b/examples/quick/text/fonts/banner.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ property int pixelSize: screen.height * 1.25
+ property color textColor: "lightsteelblue"
+ property string text: "Hello world! "
+
+ width: 640; height: 320
+ color: "steelblue"
+
+ Row {
+ y: -screen.height / 4.5
+
+ NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite }
+ Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ }
+}
diff --git a/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf
new file mode 100644
index 0000000000..cf93f9651f
--- /dev/null
+++ b/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/examples/quick/text/fonts/fonts.qml b/examples/quick/text/fonts/fonts.qml
new file mode 100644
index 0000000000..78cef25eae
--- /dev/null
+++ b/examples/quick/text/fonts/fonts.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ property string myText: "The quick brown fox jumps over the lazy dog."
+
+ width: 800; height: 480
+ color: "steelblue"
+
+ FontLoader { id: fixedFont; name: "Courier" }
+ FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" }
+ FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
+
+ Column {
+ anchors { fill: parent; leftMargin: 10; rightMargin: 10 }
+ spacing: 15
+
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideRight
+ font.family: "Times"; font.pointSize: 42
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideLeft
+ font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase }
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideMiddle
+ font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase }
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideRight
+ font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps }
+ }
+ Text {
+ text: myText
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideLeft
+ font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize }
+ }
+ Text {
+ text: {
+ if (webFont.status == FontLoader.Ready) myText
+ else if (webFont.status == FontLoader.Loading) "Loading..."
+ else if (webFont.status == FontLoader.Error) "Error loading font"
+ }
+ color: "lightsteelblue"
+ width: parent.width
+ elide: Text.ElideMiddle
+ font.family: webFont.name; font.pointSize: 42
+ }
+ }
+}
diff --git a/examples/quick/text/fonts/hello.qml b/examples/quick/text/fonts/hello.qml
new file mode 100644
index 0000000000..d9479fb208
--- /dev/null
+++ b/examples/quick/text/fonts/hello.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ width: 800; height: 480
+ color: "black"
+
+ Item {
+ id: container
+ x: screen.width / 2; y: screen.height / 2
+
+ Text {
+ id: text
+ anchors.centerIn: parent
+ color: "white"
+ text: "Hello world!"
+ font.pixelSize: 60
+ smooth: true
+
+ SequentialAnimation on font.letterSpacing {
+ loops: Animation.Infinite;
+ NumberAnimation { from: 0; to: 150; easing.type: Easing.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)
+ }
+ }
+ }
+
+ SequentialAnimation on opacity {
+ loops: Animation.Infinite;
+ NumberAnimation { from: 1; to: 0; duration: 2600 }
+ PauseAnimation { duration: 400 }
+ }
+ }
+ }
+}
diff --git a/examples/quick/text/imgtag/TextWithImage.qml b/examples/quick/text/imgtag/TextWithImage.qml
new file mode 100644
index 0000000000..bc09aa2a52
--- /dev/null
+++ b/examples/quick/text/imgtag/TextWithImage.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Text {
+ width: parent.width
+ font.pointSize: 14
+ wrapMode: Text.WordWrap
+ textFormat: Text.StyledText
+ horizontalAlignment: main.hAlign
+
+ Rectangle {
+ border.color: "#efefef"
+ color: "transparent"
+ anchors.fill: parent
+ }
+}
diff --git a/examples/quick/text/imgtag/images/face-sad.png b/examples/quick/text/imgtag/images/face-sad.png
new file mode 100644
index 0000000000..24188b7985
--- /dev/null
+++ b/examples/quick/text/imgtag/images/face-sad.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/face-smile-big.png b/examples/quick/text/imgtag/images/face-smile-big.png
new file mode 100644
index 0000000000..d05e0bf21e
--- /dev/null
+++ b/examples/quick/text/imgtag/images/face-smile-big.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/face-smile.png b/examples/quick/text/imgtag/images/face-smile.png
new file mode 100644
index 0000000000..e5e1d1353c
--- /dev/null
+++ b/examples/quick/text/imgtag/images/face-smile.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/heart200.png b/examples/quick/text/imgtag/images/heart200.png
new file mode 100644
index 0000000000..cedd3ea608
--- /dev/null
+++ b/examples/quick/text/imgtag/images/heart200.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/qtlogo.png b/examples/quick/text/imgtag/images/qtlogo.png
new file mode 100644
index 0000000000..996719a4c6
--- /dev/null
+++ b/examples/quick/text/imgtag/images/qtlogo.png
Binary files differ
diff --git a/examples/quick/text/imgtag/images/starfish_2.png b/examples/quick/text/imgtag/images/starfish_2.png
new file mode 100644
index 0000000000..132c20ffd0
--- /dev/null
+++ b/examples/quick/text/imgtag/images/starfish_2.png
Binary files differ
diff --git a/examples/quick/text/imgtag/imgtag.qml b/examples/quick/text/imgtag/imgtag.qml
new file mode 100644
index 0000000000..9d181af2cb
--- /dev/null
+++ b/examples/quick/text/imgtag/imgtag.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 320; height: 480
+ focus: true
+
+ property var hAlign: Text.AlignLeft
+
+ Flickable {
+ anchors.fill: parent
+ contentWidth: parent.width
+ contentHeight: col.height + 20
+
+ Column {
+ id: col
+ x: 10; y: 10
+ spacing: 20
+ width: parent.width - 20
+
+ TextWithImage {
+ text: "This is a <b>happy</b> face<img src=\"images/face-smile.png\">"
+ }
+ TextWithImage {
+ text: "This is a <b>very<img src=\"images/face-smile-big.png\" align=\"middle\"/>happy</b> face aligned in the middle."
+ }
+ TextWithImage {
+ elide: Text.ElideRight
+ maximumLineCount: 2
+ text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis<img src=\"images/face-sad.png\" align=\"top\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis."
+ }
+ TextWithImage {
+ text: "This is a tiny<img src=\"images/face-smile.png\" width=\"15\" height=\"15\">happy face."
+ }
+ TextWithImage {
+ text: "This is a starfish<img src=\"images/starfish_2.png\" width=\"50\" height=\"50\" align=\"top\">aligned to the top and another one<img src=\"images/heart200.png\" width=\"50\" height=\"50\">aligned to the bottom."
+ }
+ TextWithImage {
+ text: "Qt logos<img src=\"images/qtlogo.png\" width=\"55\" height=\"60\" align=\"middle\"><img src=\"images/qtlogo.png\" width=\"37\" height=\"40\" align=\"middle\"><img src=\"images/qtlogo.png\" width=\"18\" height=\"20\" align=\"middle\">aligned in the middle with different sizes."
+ }
+ TextWithImage {
+ text: "Some hearts<img src=\"images/heart200.png\" width=\"20\" height=\"20\" align=\"bottom\"><img src=\"images/heart200.png\" width=\"30\" height=\"30\" align=\"bottom\"> <img src=\"images/heart200.png\" width=\"40\" height=\"40\"><img src=\"images/heart200.png\" width=\"50\" height=\"50\" align=\"bottom\">with different sizes."
+ }
+ TextWithImage {
+ text: "Resized image<img width=\"80\" height=\"76\" align=\"middle\" src=\"http://files.app4mobile.com/wp-content/uploads/2011/08/nokia-n9-price-specification-features-us-europe-india.jpg\">from the internet."
+ }
+ TextWithImage {
+ text: "Image<img align=\"middle\" src=\"http://qt.gitorious.org/images/sites/qt/logo.png\">from the internet."
+ }
+ TextWithImage {
+ height: 120
+ verticalAlignment: Text.AlignVCenter
+ text: "This is a <b>happy</b> face<img src=\"images/face-smile.png\"> with an explicit height."
+ }
+ }
+ }
+
+ Keys.onUpPressed: main.hAlign = Text.AlignHCenter
+ Keys.onLeftPressed: main.hAlign = Text.AlignLeft
+ Keys.onRightPressed: main.hAlign = Text.AlignRight
+}
diff --git a/examples/quick/text/styledtext-layout.qml b/examples/quick/text/styledtext-layout.qml
new file mode 100644
index 0000000000..4571330568
--- /dev/null
+++ b/examples/quick/text/styledtext-layout.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 320; height: 480
+ focus: true
+
+ property real offset: 0
+ property real margin: 10
+
+ Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft
+ Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter
+ Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight
+ Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify
+
+ Text {
+ id: myText
+ anchors.fill: parent
+ anchors.margins: 10
+ wrapMode: Text.WordWrap
+ font.family: "Times New Roman"
+ font.pixelSize: 13
+ textFormat: Text.StyledText
+ horizontalAlignment: Text.AlignJustify
+
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis <a href=\"www.nokia.com\">www.nokia.com</a>.<br/>Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.<br><ul type=\"bullet\"><li>Coffee<ol type=\"a\"><li>Espresso<li><b>Cappuccino</b><li><i>Flat White</i><li>Latte</ol><li>Juice<ol type=\"1\"><li>Orange</li><li>Apple</li><li>Pineapple</li><li>Tomato</li></ol></li></ul><p><font color=\"#434343\"><i>Proin consectetur <b>sapien</b> in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit."
+
+ onLineLaidOut: {
+ line.width = width / 2 - (2 * margin)
+ if (line.number === 30) {
+ main.offset = line.y
+ }
+ if (line.number >= 30) {
+ line.x = width / 2 + margin
+ line.y -= main.offset
+ }
+ if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) {
+ if (line.number < 30)
+ line.width = Math.min((rect.x - line.x), line.width)
+ else {
+ line.x = Math.max((rect.x + rect.width), width / 2 + margin)
+ line.width = Math.min((width - margin - line.x), line.width)
+ }
+ }
+ }
+
+ Item {
+ id: rect
+ x: 28; y: 20
+ width: 60; height: 60
+
+ Rectangle {
+ anchors { fill: parent; leftMargin: 2; rightMargin: 2 }
+ color: "lightsteelblue"; opacity: 0.3
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: rect
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1
+ onPositionChanged: myText.doLayout()
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/text/text.qml b/examples/quick/text/text.qml
new file mode 100644
index 0000000000..9bfd290059
--- /dev/null
+++ b/examples/quick/text/text.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared"
+
+Item {
+ height: 480
+ width: 480
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml"));
+ addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml"));
+ addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml"));
+ addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml"));
+ }
+ }
+}
diff --git a/examples/quick/text/text.qmlproject b/examples/quick/text/text.qmlproject
new file mode 100644
index 0000000000..c08d9b9a89
--- /dev/null
+++ b/examples/quick/text/text.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "text.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/text/textselection/pics/endHandle.png b/examples/quick/text/textselection/pics/endHandle.png
new file mode 100644
index 0000000000..1a4bc5d7a0
--- /dev/null
+++ b/examples/quick/text/textselection/pics/endHandle.png
Binary files differ
diff --git a/examples/quick/text/textselection/pics/endHandle.sci b/examples/quick/text/textselection/pics/endHandle.sci
new file mode 100644
index 0000000000..4f51f24278
--- /dev/null
+++ b/examples/quick/text/textselection/pics/endHandle.sci
@@ -0,0 +1,5 @@
+border.left: 0
+border.top: 6
+border.bottom: 6
+border.right: 6
+source: endHandle.png
diff --git a/examples/quick/text/textselection/pics/startHandle.png b/examples/quick/text/textselection/pics/startHandle.png
new file mode 100644
index 0000000000..deedcd5c91
--- /dev/null
+++ b/examples/quick/text/textselection/pics/startHandle.png
Binary files differ
diff --git a/examples/quick/text/textselection/pics/startHandle.sci b/examples/quick/text/textselection/pics/startHandle.sci
new file mode 100644
index 0000000000..f9eae204c1
--- /dev/null
+++ b/examples/quick/text/textselection/pics/startHandle.sci
@@ -0,0 +1,5 @@
+border.left: 6
+border.top: 6
+border.bottom: 6
+border.right: 0
+source: startHandle.png
diff --git a/examples/quick/text/textselection/textselection.qml b/examples/quick/text/textselection/textselection.qml
new file mode 100644
index 0000000000..7938ce5bf7
--- /dev/null
+++ b/examples/quick/text/textselection/textselection.qml
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Rectangle {
+ id: editor
+ color: "lightGrey"
+ width: 640; height: 480
+
+ Rectangle {
+ color: "white"
+ anchors.fill: parent
+ anchors.margins: 20
+
+ BorderImage {
+ id: startHandle
+ source: "pics/startHandle.sci"
+ opacity: 0.0
+ width: 10
+ x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width
+ y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY
+ height: edit.positionToRectangle(edit.selectionStart).height
+ }
+
+ BorderImage {
+ id: endHandle
+ source: "pics/endHandle.sci"
+ opacity: 0.0
+ width: 10
+ x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX
+ y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY
+ height: edit.positionToRectangle(edit.selectionEnd).height
+ }
+
+ Flickable {
+ id: flick
+
+ anchors.fill: parent
+ contentWidth: edit.paintedWidth
+ contentHeight: edit.paintedHeight
+ interactive: true
+ clip: true
+
+ function ensureVisible(r) {
+ if (contentX >= r.x)
+ contentX = r.x;
+ else if (contentX+width <= r.x+r.width)
+ contentX = r.x+r.width-width;
+ if (contentY >= r.y)
+ contentY = r.y;
+ else if (contentY+height <= r.y+r.height)
+ contentY = r.y+r.height-height;
+ }
+
+ TextEdit {
+ id: edit
+ width: flick.width
+ height: flick.height
+ focus: true
+ wrapMode: TextEdit.Wrap
+ textFormat: TextEdit.RichText
+
+ onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
+
+ text: "<h1>Text Selection</h1>"
+ +"<p>This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform."
+ +"<p><b>Press-and-hold</b> to select a word, then drag the selection handles."
+ +"<p><b>Drag outside the selection</b> to scroll the text."
+ +"<p><b>Click inside the selection</b> to cut/copy/paste/cancel selection."
+ +"<p>It's too whacky to let you paste if there is no current selection."
+
+ }
+ }
+
+ Item {
+ id: menu
+ opacity: 0.0
+ width: 100
+ height: 120
+ anchors.centerIn: parent
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ radius: 15
+ color: "#806080FF"
+ anchors.fill: parent
+ }
+
+ Column {
+ anchors.centerIn: parent
+ spacing: 8
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Cut" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { edit.cut(); editor.state = "" }
+ }
+ }
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Copy" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { edit.copy(); editor.state = "selection" }
+ }
+ }
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Paste" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" }
+ }
+ }
+
+ Rectangle {
+ border.width: 1
+ border.color: "darkBlue"
+ color: "#ff7090FF"
+ width: 60
+ height: 16
+
+ Text { anchors.centerIn: parent; text: "Deselect" }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ edit.cursorPosition = edit.selectionEnd;
+ edit.deselect();
+ editor.state = ""
+ }
+ }
+ }
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "selection"
+ PropertyChanges { target: startHandle; opacity: 1.0 }
+ PropertyChanges { target: endHandle; opacity: 1.0 }
+ },
+ State {
+ name: "menu"
+ PropertyChanges { target: startHandle; opacity: 0.5 }
+ PropertyChanges { target: endHandle; opacity: 0.5 }
+ PropertyChanges { target: menu; opacity: 1.0 }
+ }
+ ]
+}
diff --git a/examples/quick/threading/threadedlistmodel/dataloader.js b/examples/quick/threading/threadedlistmodel/dataloader.js
new file mode 100644
index 0000000000..4d2aab323d
--- /dev/null
+++ b/examples/quick/threading/threadedlistmodel/dataloader.js
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// ![0]
+WorkerScript.onMessage = function(msg) {
+ if (msg.action == 'appendCurrentTime') {
+ var data = {'time': new Date().toTimeString()};
+ msg.model.append(data);
+ msg.model.sync(); // updates the changes to the list
+ }
+}
+// ![0]
diff --git a/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject
new file mode 100644
index 0000000000..e7c8e69f14
--- /dev/null
+++ b/examples/quick/threading/threadedlistmodel/threadedlistmodel.qmlproject
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QmlProject 1.1
+
+Project {
+ mainFile: "timedisplay.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/threading/threadedlistmodel/timedisplay.qml b/examples/quick/threading/threadedlistmodel/timedisplay.qml
new file mode 100644
index 0000000000..48d0f659e5
--- /dev/null
+++ b/examples/quick/threading/threadedlistmodel/timedisplay.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// ![0]
+import QtQuick 2.0
+
+Rectangle {
+ color: "white"
+ width: 200
+ height: 300
+
+ ListView {
+ anchors.fill: parent
+ model: listModel
+ delegate: Component {
+ Text { text: time }
+ }
+
+ ListModel { id: listModel }
+
+ WorkerScript {
+ id: worker
+ source: "dataloader.js"
+ }
+
+ Timer {
+ id: timer
+ interval: 2000; repeat: true
+ running: true
+ triggeredOnStart: true
+
+ onTriggered: {
+ var msg = {'action': 'appendCurrentTime', 'model': listModel};
+ worker.sendMessage(msg);
+ }
+ }
+ }
+}
+// ![0]
diff --git a/examples/quick/threading/workerscript/workerscript.js b/examples/quick/threading/workerscript/workerscript.js
new file mode 100644
index 0000000000..f76471f920
--- /dev/null
+++ b/examples/quick/threading/workerscript/workerscript.js
@@ -0,0 +1,15 @@
+var lastx = 0;
+var lasty = 0;
+
+WorkerScript.onMessage = function(message) {
+ var ydiff = message.y - lasty;
+ var xdiff = message.x - lastx;
+
+ var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff);
+
+ lastx = message.x;
+ lasty = message.y;
+
+ WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} );
+}
+
diff --git a/examples/quick/threading/workerscript/workerscript.qml b/examples/quick/threading/workerscript/workerscript.qml
new file mode 100644
index 0000000000..7fced8166c
--- /dev/null
+++ b/examples/quick/threading/workerscript/workerscript.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 480; height: 320
+
+ WorkerScript {
+ id: myWorker
+ source: "workerscript.js"
+
+ onMessage: {
+ console.log("Moved " + messageObject.xmove + " along the X axis.");
+ console.log("Moved " + messageObject.ymove + " along the Y axis.");
+ console.log("Moved " + messageObject.move + " pixels.");
+ }
+ }
+
+ Rectangle {
+ width: 200; height: 200
+ anchors.left: parent.left; anchors.leftMargin: 20
+ color: "red"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } );
+ }
+ }
+
+ Rectangle {
+ width: 200; height: 200
+ anchors.right: parent.right; anchors.rightMargin: 20
+ color: "blue"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } );
+ }
+ }
+
+ Text {
+ text: "Click a Rectangle!"
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 }
+ }
+}
diff --git a/examples/quick/threading/workerscript/workerscript.qmlproject b/examples/quick/threading/workerscript/workerscript.qmlproject
new file mode 100644
index 0000000000..6d7a91feeb
--- /dev/null
+++ b/examples/quick/threading/workerscript/workerscript.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "workerscript.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/touchinteraction/flickable/content/Day.qml b/examples/quick/touchinteraction/flickable/content/Day.qml
new file mode 100644
index 0000000000..7fe625c305
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/Day.qml
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Component {
+ Item {
+ property variant stickies
+
+ id: page
+ width: ListView.view.width+40; height: ListView.view.height
+
+
+ Image {
+ source: "cork.jpg"
+ width: page.ListView.view.width
+ height: page.ListView.view.height
+ fillMode: Image.PreserveAspectCrop
+ clip: true
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: page.focus = false;
+ }
+
+ Text {
+ text: name; x: 15; y: 8; height: 40; width: 370
+ font.pixelSize: 18; font.bold: true; color: "white"
+ style: Text.Outline; styleColor: "black"
+ }
+
+ Repeater {
+ model: notes
+ Item {
+ id: stickyPage
+
+ property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100
+ property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50
+
+ x: randomX; y: randomY
+
+ rotation: -flickable.horizontalVelocity / 100;
+ Behavior on rotation {
+ SpringAnimation { spring: 2.0; damping: 0.15 }
+ }
+
+ Item {
+ id: sticky
+ scale: 0.7
+
+ Image {
+ id: stickyImage
+ x: 8 + -width * 0.6 / 2; y: -20
+ source: "note-yellow.png"
+ scale: 0.6; transformOrigin: Item.TopLeft
+ smooth: true
+ }
+
+ TextEdit {
+ id: myText
+ x: -104; y: 36; width: 215; height: 200
+ smooth: true
+ font.pixelSize: 24
+ readOnly: false
+ rotation: -8
+ text: noteText
+ }
+
+ Item {
+ x: stickyImage.x; y: -20
+ width: stickyImage.width * stickyImage.scale
+ height: stickyImage.height * stickyImage.scale
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ drag.target: stickyPage
+ drag.axis: Drag.XandYAxis
+ drag.minimumY: 0
+ drag.maximumY: page.height - 80
+ drag.minimumX: 100
+ drag.maximumX: page.width - 140
+ onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); }
+ }
+ }
+ }
+
+ Image {
+ x: -width / 2; y: -height * 0.5 / 2
+ source: "tack.png"
+ scale: 0.7; transformOrigin: Item.TopLeft
+ }
+
+ states: State {
+ name: "pressed"
+ when: mouse.pressed
+ PropertyChanges { target: sticky; rotation: 8; scale: 1 }
+ PropertyChanges { target: page; z: 8 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "rotation,scale"; duration: 200 }
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/examples/quick/touchinteraction/flickable/content/cork.jpg b/examples/quick/touchinteraction/flickable/content/cork.jpg
new file mode 100644
index 0000000000..160bc002bf
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/cork.jpg
Binary files differ
diff --git a/examples/quick/touchinteraction/flickable/content/note-yellow.png b/examples/quick/touchinteraction/flickable/content/note-yellow.png
new file mode 100644
index 0000000000..8ddecc8b03
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/note-yellow.png
Binary files differ
diff --git a/examples/quick/touchinteraction/flickable/content/tack.png b/examples/quick/touchinteraction/flickable/content/tack.png
new file mode 100644
index 0000000000..cef2d1cd23
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/content/tack.png
Binary files differ
diff --git a/examples/quick/touchinteraction/flickable/corkboards.qml b/examples/quick/touchinteraction/flickable/corkboards.qml
new file mode 100644
index 0000000000..dc3aa6b378
--- /dev/null
+++ b/examples/quick/touchinteraction/flickable/corkboards.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 800; height: 480
+ color: "#464646"
+
+ ListModel {
+ id: list
+
+ ListElement {
+ name: "Sunday"
+ notes: [
+ ListElement { noteText: "Lunch" },
+ ListElement { noteText: "Birthday Party" }
+ ]
+ }
+
+ ListElement {
+ name: "Monday"
+ notes: [
+ ListElement { noteText: "Pickup kids from\nschool\n4.30pm" },
+ ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" }
+ ]
+ }
+
+ ListElement {
+ name: "Tuesday"
+ notes: [
+ ListElement { noteText: "Walk dog" },
+ ListElement { noteText: "Buy newspaper" }
+ ]
+ }
+
+ ListElement {
+ name: "Wednesday"
+ notes: [ ListElement { noteText: "Cook dinner" } ]
+ }
+
+ ListElement {
+ name: "Thursday"
+ notes: [
+ ListElement { noteText: "Meeting\n5.30pm" },
+ ListElement { noteText: "Weed garden" }
+ ]
+ }
+
+ ListElement {
+ name: "Friday"
+ notes: [
+ ListElement { noteText: "More work" },
+ ListElement { noteText: "Grocery shopping" }
+ ]
+ }
+
+ ListElement {
+ name: "Saturday"
+ notes: [
+ ListElement { noteText: "Drink" },
+ ListElement { noteText: "Download Qt\nPlay with QML" }
+ ]
+ }
+ }
+
+ ListView {
+ id: flickable
+
+ anchors.fill: parent
+ focus: true
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem
+ model: list
+ delegate: Day { }
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
new file mode 100644
index 0000000000..db46473c05
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+
+Item {
+ id: root
+ height: 640
+ width: 320
+ Item {
+ id: startScreen
+ anchors.fill: parent
+ z: 1000
+ Image {
+ source: "content/title.png"
+ anchors.centerIn: parent
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {//Game Start
+ parent.visible = false;
+ }
+ }
+ }
+ Rectangle {
+ id: bg
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "DarkBlue" }
+ GradientStop { position: 0.8; color: "SkyBlue" }
+ GradientStop { position: 0.81; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ BearWhackParticleSystem {
+ id: particleSystem
+ anchors.fill: parent
+ running: !startScreen.visible
+ }
+
+ property int score: 0
+
+ Text {
+ anchors.right: parent.right
+ anchors.margins: 4
+ anchors.top: parent.top
+ color: "white"
+ function padded(num) {
+ var ret = num.toString();
+ while (ret.length < 6)
+ ret = "0" + ret;
+ return ret;
+ }
+ text: "Score: " + padded(score)
+ }
+ MultiPointTouchArea {
+ anchors.fill: parent
+ touchPoints: [//Support up to 4 touches at once?
+ AugmentedTouchPoint{ system: particleSystem },
+ AugmentedTouchPoint{ system: particleSystem },
+ AugmentedTouchPoint{ system: particleSystem },
+ AugmentedTouchPoint{ system: particleSystem }
+ ]
+ }
+ MouseArea{
+ anchors.fill: parent
+ id: ma
+ onPressedChanged: {
+ if (pressed) {
+ timer.restart();
+ sgoal.enabled = true;
+ particleSystem.explode(mouseX,mouseY);
+ }
+ }
+ Timer {
+ id: timer
+ interval: 100
+ running: false
+ repeat: false
+ onTriggered: sgoal.enabled = false
+ }
+ SpriteGoal {
+ id: sgoal
+ x: ma.mouseX - 16
+ y: ma.mouseY - 16
+ width: 32
+ height: 32
+ system: particleSystem
+ parent: particleSystem
+ goalState: "falling"
+ enabled: false
+ }
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
new file mode 100644
index 0000000000..aede1a8f4e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+TouchPoint {
+ id: container
+ property ParticleSystem system
+ onPressedChanged: {
+ if (pressed) {
+ timer.restart();
+ child.enabled = true;
+ system.explode(x,y);
+ }
+ }
+ property QtObject obj: Timer {
+ id: timer
+ interval: 100
+ running: false
+ repeat: false
+ onTriggered: child.enabled = false
+ }
+ property Item child: SpriteGoal {
+ enabled: false
+ x: container.area.x - 16
+ y: container.area.y - 16
+ width: container.area.width + 32
+ height: container.area.height + 32 //+32 so it doesn't have to hit the exact center
+ system: container.system
+ parent: container.system
+ goalState: "falling"
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear0.png b/examples/quick/touchinteraction/multipointtouch/content/Bear0.png
new file mode 100644
index 0000000000..64a02cec8e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear0.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear1.png b/examples/quick/touchinteraction/multipointtouch/content/Bear1.png
new file mode 100644
index 0000000000..3b88f3b32e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear1.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear2.png b/examples/quick/touchinteraction/multipointtouch/content/Bear2.png
new file mode 100644
index 0000000000..337b636070
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear2.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/Bear3.png b/examples/quick/touchinteraction/multipointtouch/content/Bear3.png
new file mode 100644
index 0000000000..f0e68590f4
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/Bear3.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/BearB.png b/examples/quick/touchinteraction/multipointtouch/content/BearB.png
new file mode 100644
index 0000000000..c9a84ae1d4
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/BearB.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
new file mode 100644
index 0000000000..bed03e99aa
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ id: particleSystem
+ function explode(x,y) {
+ fireEmitter.burst(100,x,y);
+ }
+
+ Emitter {
+ id: emitter
+ group: "bears"
+ width: parent.width
+ emitRate: 1
+ NumberAnimation on emitRate {
+ id: goFaster
+ from: 1
+ to: 16
+ running: particleSystem.running
+ loops: 1
+ duration: 60000 * 5
+ easing.type: Easing.Linear
+ }
+ lifeSpan: 4000 + 800*(16-emitRate)
+ maximumEmitted: 128
+ size: 64
+ speed: PointDirection{ y: 40 + 10 * emitter.emitRate }
+ }
+
+ Emitter {
+ id: fireEmitter
+ enabled: false
+ maximumEmitted: 6000
+ group: "flame"
+ emitRate: 1000
+ size: 16
+ endSize: 8
+ speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }}
+ lifeSpan: 400
+ }
+ Emitter {
+ id: heartEmitter
+ enabled: false
+ maximumEmitted: 6000
+ group: "hearts"
+ emitRate: 1000
+ size: 16
+ endSize: 8
+ speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;}
+ lifeSpan: 600
+ }
+ Emitter {
+ id: bloodEmitter
+ enabled: false
+ maximumEmitted: 6000
+ group: "blood"
+ emitRate: 1000
+ size: 16
+ endSize: 8
+ speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }}
+ lifeSpan: 600
+ }
+
+ Affector {
+ width: parent.width
+ height: 64
+ once: true
+ y: parent.height - 32
+ groups: "bears"
+ onAffectParticles: {
+ for (var i=0;i<particles.length; i++) {
+ if (particles[i].animationIndex != 0) {
+ score++;
+ bloodEmitter.burst(100, particles[i].x, particles[i].y);
+ } else {
+ score--;
+ heartEmitter.burst(100, particles[i].x, particles[i].y);
+ }
+ particles[i].update = 1.0;
+ particles[i].t -= 1000.0;
+ }
+ }
+ }
+ ImageParticle {
+ groups: ["flame"]
+ source: "blur-circle.png"
+ z: 4
+ colorVariation: 0.1
+ color: "#ffa24d"
+ alpha: 0.4
+ }
+ ImageParticle {
+ groups: ["blood"]
+ color: "red"
+ z: 2
+ source: "blur-circle3.png"
+ alpha: 0.2
+ }
+ ImageParticle {
+ groups: ["hearts"]
+ color: "#ff66AA"
+ z: 3
+ source: "heart-blur.png"
+ alpha: 0.4
+ autoRotation: true
+ }
+ ImageParticle {
+ groups: ["bears"]
+ z: 1
+ spritesInterpolate: false
+ sprites:[
+ Sprite{
+ name: "floating"
+ source: "Bear1.png"
+ frameCount: 9
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 80
+ to: {"still":0, "flailing":0}
+ },
+ Sprite{
+ name: "flailing"
+ source: "Bear2.png"
+ frameCount: 8
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 80
+ to: {"falling":1}
+ },
+ Sprite{
+ name: "falling"
+ source: "Bear3.png"
+ frameCount: 5
+ frameWidth: 256
+ frameHeight: 256
+ frameDuration: 80
+ to: {"falling":1}
+ }
+ ]
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml b/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml
new file mode 100644
index 0000000000..9788c5c665
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/ParticleFlame.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+ParticleSystem {
+ property alias color: img.color
+ property alias emitting: emitter.enabled
+ ImageParticle {
+ id: img
+ source: "blur-circle.png"
+ colorVariation: 0.1
+ color: "#ff521d"
+ alpha: 0
+ }
+ Emitter {
+ id: emitter
+ speedFromMovement: 20
+ emitRate: 80
+ lifeSpan: 1500
+ speed: PointDirection{ y: -90; yVariation: 50; }
+ acceleration: PointDirection{ xVariation: 100; yVariation: 90; }
+ size: 51
+ sizeVariation: 53
+ endSize: 64
+ }
+}
diff --git a/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png b/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png
new file mode 100644
index 0000000000..1b03cd0b2c
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/blur-circle.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png b/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png
new file mode 100644
index 0000000000..dbc39cb16e
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/blur-circle3.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png b/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png
new file mode 100644
index 0000000000..dbc38804ee
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/heart-blur.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/content/title.png b/examples/quick/touchinteraction/multipointtouch/content/title.png
new file mode 100644
index 0000000000..d630ea2643
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/content/title.png
Binary files differ
diff --git a/examples/quick/touchinteraction/multipointtouch/multiflame.qml b/examples/quick/touchinteraction/multipointtouch/multiflame.qml
new file mode 100644
index 0000000000..72a0ce21f8
--- /dev/null
+++ b/examples/quick/touchinteraction/multipointtouch/multiflame.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 360
+ height: 480
+ color: "black"
+
+ MultiPointTouchArea {
+ anchors.fill: parent
+ minimumTouchPoints: 1
+ maximumTouchPoints: 5
+ touchPoints: [
+ TouchPoint { id: touch1 },
+ TouchPoint { id: touch2 },
+ TouchPoint { id: touch11 },
+ TouchPoint { id: touch21 },
+ TouchPoint { id: touch31 }
+ ]
+ }
+
+ ParticleFlame {
+ color: "red"
+ x: touch1.x
+ y: touch1.y
+ emitting: touch1.pressed
+ }
+ ParticleFlame {
+ color: "green"
+ x: touch2.x
+ y: touch2.y
+ emitting: touch2.pressed
+ }
+ ParticleFlame {
+ color: "yellow"
+ x: touch11.x
+ y: touch11.y
+ emitting: touch11.pressed
+ }
+ ParticleFlame {
+ color: "blue"
+ x: touch21.x
+ y: touch21.y
+ emitting: touch21.pressed
+ }
+ ParticleFlame {
+ color: "violet"
+ x: touch31.x
+ y: touch31.y
+ emitting: touch31.pressed
+ }
+}
diff --git a/examples/quick/touchinteraction/pincharea/flickresize.qml b/examples/quick/touchinteraction/pincharea/flickresize.qml
new file mode 100644
index 0000000000..037766e4a0
--- /dev/null
+++ b/examples/quick/touchinteraction/pincharea/flickresize.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 640
+ height: 360
+ color: "gray"
+
+ Flickable {
+ id: flick
+ anchors.fill: parent
+ contentWidth: 500
+ contentHeight: 500
+
+ PinchArea {
+ width: Math.max(flick.contentWidth, flick.width)
+ height: Math.max(flick.contentHeight, flick.height)
+
+ property real initialWidth
+ property real initialHeight
+ onPinchStarted: {
+ initialWidth = flick.contentWidth
+ initialHeight = flick.contentHeight
+ }
+
+ onPinchUpdated: {
+ // adjust content pos due to drag
+ flick.contentX += pinch.previousCenter.x - pinch.center.x
+ flick.contentY += pinch.previousCenter.y - pinch.center.y
+
+ // resize content
+ flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
+ }
+
+ onPinchFinished: {
+ // Move its content within bounds.
+ flick.returnToBounds()
+ }
+
+ Rectangle {
+ width: flick.contentWidth
+ height: flick.contentHeight
+ color: "white"
+ Image {
+ anchors.fill: parent
+ source: "qt-logo.jpg"
+ MouseArea {
+ anchors.fill: parent
+ onDoubleClicked: {
+ flick.contentWidth = 500
+ flick.contentHeight = 500
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/touchinteraction/pincharea/qt-logo.jpg b/examples/quick/touchinteraction/pincharea/qt-logo.jpg
new file mode 100644
index 0000000000..4014b4659c
--- /dev/null
+++ b/examples/quick/touchinteraction/pincharea/qt-logo.jpg
Binary files differ
diff --git a/examples/quick/touchinteraction/touchinteraction.qml b/examples/quick/touchinteraction/touchinteraction.qml
new file mode 100644
index 0000000000..b4a930c495
--- /dev/null
+++ b/examples/quick/touchinteraction/touchinteraction.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared"
+
+Item {
+ height: 480
+ width: 320
+ LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Multipoint Flames", "Create multiple flames with multiple fingers", Qt.resolvedUrl("multipointtouch/multiflame.qml"));
+ addExample("Bear-Whack", "Use multiple touches to knock all the bears down", Qt.resolvedUrl("multipointtouch/bearwhack.qml"));
+ addExample("Flick Resize", "Manipulate images using pinch gestures", Qt.resolvedUrl("pincharea/flickresize.qml"));
+ }
+ }
+}
diff --git a/examples/quick/touchinteraction/touchinteraction.qmlproject b/examples/quick/touchinteraction/touchinteraction.qmlproject
new file mode 100644
index 0000000000..a9aa9d2e81
--- /dev/null
+++ b/examples/quick/touchinteraction/touchinteraction.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "touchinteraction.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/shared/Button.qml b/examples/shared/Button.qml
new file mode 100644
index 0000000000..a899a1410b
--- /dev/null
+++ b/examples/shared/Button.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property string text: "Button"
+ property string subText: "Just a button"
+ signal clicked
+
+ width: buttonLabel.width + 20; height: col.height + 12
+
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+ Column {
+ spacing: 2
+ id: col
+ Text {
+ id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24
+ }
+ Text {
+ id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12
+ }
+ }
+}
diff --git a/examples/shared/LauncherList.qml b/examples/shared/LauncherList.qml
new file mode 100644
index 0000000000..492290dc3e
--- /dev/null
+++ b/examples/shared/LauncherList.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+ListView {
+ //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"}
+ //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments
+ function addExample(name, desc, url)
+ {
+ myModel.append({"name":name, "description":desc, "url":url})
+ }
+ function hideExample()
+ {
+ ei.visible = false;
+ }
+
+ clip: true
+ delegate: SimpleLauncherDelegate{exampleItem: ei}
+ model: ListModel {id:myModel}
+ Item {
+ id: ei
+ visible: false
+ clip: true
+ property url exampleUrl
+ onExampleUrlChanged: visible = (exampleUrl == '' ? false : true);//Setting exampleUrl automatically shows example
+ anchors.fill: parent
+ anchors.bottomMargin: 40
+ Rectangle {
+ id: bg
+ anchors.fill: parent
+ color: "white"
+ }
+ MouseArea{
+ anchors.fill: parent
+ enabled: ei.visible
+ //Eats mouse events
+ }
+ Loader{
+ source: ei.exampleUrl
+ anchors.fill: parent
+ }
+ }
+ Rectangle {
+ id: bar
+ visible: ei.visible
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: 40
+ MouseArea{
+ anchors.fill: parent
+ enabled: ei.visible
+ //Eats mouse events
+ }
+ Image {
+ source: "images/back.png"
+ anchors.verticalCenter: parent.verticalCenter
+ x: 4
+ MouseArea {
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: ei.exampleUrl = "";
+ }
+ }
+ }
+}
diff --git a/examples/shared/README b/examples/shared/README
new file mode 100644
index 0000000000..bf16f238c7
--- /dev/null
+++ b/examples/shared/README
@@ -0,0 +1,11 @@
+These files are shared between multiple examples as a set of common and
+reusuable components. While they do demonstrate the building of reusable
+components in QML, they are not official examples themselves.
+Consequently they do not have entries in the Qt documentation, and are
+documented only through the code comments within the files. Developers
+new to QML are strongly encouraged to go through the official examples
+before delving into this directory.
+
+For most application use, see the Qt Quick Components project to find
+ready-made Components you can use in your own projects. Qt Declarative
+examples do not use them only to avoid external dependencies.
diff --git a/examples/shared/SimpleLauncherDelegate.qml b/examples/shared/SimpleLauncherDelegate.qml
new file mode 100644
index 0000000000..c3708fe259
--- /dev/null
+++ b/examples/shared/SimpleLauncherDelegate.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+
+Item {
+ id: container
+ property Item exampleItem
+ width: ListView.view.width
+ height: 64
+ Button {
+ anchors.fill: parent
+ text: name
+ subText: description
+ onClicked: exampleItem.exampleUrl = url;
+ }
+}
diff --git a/examples/shared/images/back.png b/examples/shared/images/back.png
new file mode 100644
index 0000000000..506ac42fcf
--- /dev/null
+++ b/examples/shared/images/back.png
Binary files differ
diff --git a/examples/shared/qmldir b/examples/shared/qmldir
new file mode 100644
index 0000000000..2f1e56aefb
--- /dev/null
+++ b/examples/shared/qmldir
@@ -0,0 +1,3 @@
+Button 2.0 Button.qml
+LauncherList 2.0 LauncherList.qml
+SimpleLauncherDelegate 2.0 SimpleLauncherDelegate.qml
diff --git a/examples/shared/shared.h b/examples/shared/shared.h
new file mode 100644
index 0000000000..e6d0130ec8
--- /dev/null
+++ b/examples/shared/shared.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QGuiApplication>
+#include <QQuickView>
+#define DECLARATIVE_EXAMPLE_MAIN(NAME) int main(int argc, char* argv[]) \
+{\
+ QGuiApplication app(argc,argv);\
+ QQuickView view;\
+ view.setSource(QUrl::fromLocalFile(#NAME ".qml"));\
+ view.show();\
+ return app.exec();\
+}
diff --git a/examples/shared/shared.pro b/examples/shared/shared.pro
new file mode 100644
index 0000000000..d6ce120f41
--- /dev/null
+++ b/examples/shared/shared.pro
@@ -0,0 +1,9 @@
+#just install the files, all QML for now
+TEMPLATE = aux
+
+qml.files = images \
+ LauncherList.qml \
+ SimpleLauncherDelegate.qml \
+ Button.qml
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/shared
+INSTALLS = qml
diff --git a/examples/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview1/PetsModel.qml
new file mode 100644
index 0000000000..f07613c968
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview1/PetsModel.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+//![0]
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+//![1]
+}
+//![1]
diff --git a/examples/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview1/dynamicview.qml
new file mode 100644
index 0000000000..1a9dd453ce
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview1/dynamicview.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+//![1]
+ Component {
+ id: dragDelegate
+
+ Rectangle {
+ id: content
+
+ anchors { left: parent.left; right: parent.right }
+ height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ radius: 2
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+ }
+ }
+//![1]
+//![2]
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: PetsModel {}
+ delegate: dragDelegate
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+//![2]
+}
+//![0]
diff --git a/examples/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview2/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview2/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview2/dynamicview.qml
new file mode 100644
index 0000000000..9e654a685c
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview2/dynamicview.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+//![0]
+ Component {
+ id: dragDelegate
+
+//![1]
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+//![1]
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+//![3]
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+//![3]
+ radius: 2
+//![4]
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+//![4]
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+//![2]
+ }
+ }
+//![2]
+ }
+//![0]
+
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: PetsModel {}
+ delegate: dragDelegate
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+}
diff --git a/examples/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview3/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview3/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview3/dynamicview.qml
new file mode 100644
index 0000000000..5a579f78d9
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview3/dynamicview.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![0]
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+ Component {
+ id: dragDelegate
+
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+//![0]
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+
+ radius: 2
+//![1]
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ Drag.hotSpot.x: width / 2
+ Drag.hotSpot.y: height / 2
+//![1]
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+//![2]
+ }
+//![3]
+ DropArea {
+ anchors { fill: parent; margins: 10 }
+
+ onEntered: {
+ visualModel.items.move(
+ drag.source.VisualDataModel.itemsIndex,
+ dragArea.VisualDataModel.itemsIndex)
+ }
+ }
+//![3]
+ }
+ }
+//![2]
+//![4]
+ VisualDataModel {
+ id: visualModel
+
+ model: PetsModel {}
+ delegate: dragDelegate
+ }
+
+ ListView {
+ id: view
+
+ anchors { fill: parent; margins: 2 }
+
+ model: visualModel
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+//![4]
+//![5]
+}
+//![5]
diff --git a/examples/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/tutorials/dynamicview/dynamicview4/ListSelector.qml
new file mode 100644
index 0000000000..c6b8287beb
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview4/ListSelector.qml
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: selector
+
+ property alias list: view.model
+ property alias selectedIndex: view.currentIndex
+ property alias label: labelText.text
+ property bool expanded
+
+ width: 100; height: labelText.implicitHeight + 26
+
+ Rectangle {
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; }
+
+ height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20)
+ Behavior on height { NumberAnimation { duration: 300 } }
+
+ radius: 2
+ border.width: 1
+ border.color: "yellow"
+ color: "yellow"
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: selector.expanded = !selector.expanded
+
+ Text {
+ id: labelText
+ anchors { left: parent.left; top: parent.top; margins: 2 }
+ }
+
+ Rectangle {
+ anchors {
+ left: parent.left; top: labelText.bottom;
+ right: parent.right; bottom: parent.bottom;
+ margins: 2
+ leftMargin: 10
+ }
+
+ radius: 2
+ color: "white"
+
+ ListView {
+ id: view
+
+ anchors.fill: parent
+
+ clip: true
+
+ delegate: Text {
+ anchors { left: parent.left; right: parent.right }
+ height: 20
+
+ verticalAlignment: Text.AlignVCenter
+
+ text: modelData
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ view.currentIndex = index
+ selector.expanded = !selector.expanded
+ }
+ }
+ }
+ highlight: Rectangle {
+ anchors { left: parent.left; right: parent.right }
+ height: 20
+ radius: 2
+
+ color: "yellow"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview4/PetsModel.qml
new file mode 100644
index 0000000000..4f2087d95e
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview4/PetsModel.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview4/dynamicview.qml
new file mode 100644
index 0000000000..9bd4e0c438
--- /dev/null
+++ b/examples/tutorials/dynamicview/dynamicview4/dynamicview.qml
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 300; height: 400
+
+ Component {
+ id: dragDelegate
+
+ MouseArea {
+ id: dragArea
+
+ property bool held: false
+
+ anchors { left: parent.left; right: parent.right }
+ height: content.height
+
+ enabled: visualModel.sortOrder == visualModel.lessThan.length
+
+ drag.target: held ? content : undefined
+ drag.axis: Drag.YAxis
+
+ onPressAndHold: held = true
+ onReleased: held = false
+
+ Rectangle {
+ id: content
+
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ width: dragArea.width; height: column.implicitHeight + 4
+
+ border.width: 1
+ border.color: "lightsteelblue"
+
+ color: dragArea.held ? "lightsteelblue" : "white"
+ Behavior on color { ColorAnimation { duration: 100 } }
+
+ radius: 2
+
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ Drag.hotSpot.x: width / 2
+ Drag.hotSpot.y: height / 2
+
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+
+ Column {
+ id: column
+ anchors { fill: parent; margins: 2 }
+
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ Text { text: 'Size: ' + size }
+ }
+ }
+
+ DropArea {
+ anchors { fill: parent; margins: 10 }
+
+ onEntered: {
+ visualModel.items.move(
+ drag.source.VisualDataModel.itemsIndex,
+ dragArea.VisualDataModel.itemsIndex)
+ }
+ }
+ }
+ }
+//![0]
+ VisualDataModel {
+ id: visualModel
+//![4]
+ property var lessThan: [
+ function(left, right) { return left.name < right.name },
+ function(left, right) { return left.type < right.type },
+ function(left, right) { return left.age < right.age },
+ function(left, right) {
+ if (left.size == "Small")
+ return true
+ else if (right.size == "Small")
+ return false
+ else if (left.size == "Medium")
+ return true
+ else
+ return false
+ }
+ ]
+//![4]
+//![6]
+
+ property int sortOrder: orderSelector.selectedIndex
+ onSortOrderChanged: items.setGroups(0, items.count, "unsorted")
+
+//![6]
+//![3]
+ function insertPosition(lessThan, item) {
+ var lower = 0
+ var upper = items.count
+ while (lower < upper) {
+ var middle = Math.floor(lower + (upper - lower) / 2)
+ var result = lessThan(item.model, items.get(middle).model);
+ if (result) {
+ upper = middle
+ } else {
+ lower = middle + 1
+ }
+ }
+ return lower
+ }
+
+ function sort(lessThan) {
+ while (unsortedItems.count > 0) {
+ var item = unsortedItems.get(0)
+ var index = insertPosition(lessThan, item)
+
+ item.groups = "items"
+ items.move(item.itemsIndex, index)
+ }
+ }
+//![3]
+
+//![1]
+ items.includeByDefault: false
+//![5]
+ groups: VisualDataGroup {
+ id: unsortedItems
+ name: "unsorted"
+
+ includeByDefault: true
+//![1]
+ onChanged: {
+ if (visualModel.sortOrder == visualModel.lessThan.length)
+ setGroups(0, count, "items")
+ else
+ visualModel.sort(visualModel.lessThan[visualModel.sortOrder])
+ }
+//![2]
+ }
+//![2]
+//![5]
+ model: PetsModel {}
+ delegate: dragDelegate
+ }
+//![0]
+ ListView {
+ id: view
+
+ anchors {
+ left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top;
+ margins: 2
+ }
+
+ model: visualModel
+
+ spacing: 4
+ cacheBuffer: 50
+ }
+
+ ListSelector {
+ id: orderSelector
+
+ anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 }
+
+ label: "Sort By"
+ list: [ "Name", "Type", "Age", "Size", "Custom" ]
+ }
+}
diff --git a/examples/tutorials/extending/chapter1-basics/app.qml b/examples/tutorials/extending/chapter1-basics/app.qml
new file mode 100644
index 0000000000..6f0c1d3a23
--- /dev/null
+++ b/examples/tutorials/extending/chapter1-basics/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: aPieChart.name
+ }
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/tutorials/extending/chapter1-basics/main.cpp b/examples/tutorials/extending/chapter1-basics/main.cpp
new file mode 100644
index 0000000000..ed9e412bd6
--- /dev/null
+++ b/examples/tutorials/extending/chapter1-basics/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter1-basics/piechart.cpp b/examples/tutorials/extending/chapter1-basics/piechart.cpp
new file mode 100644
index 0000000000..bc81d6a3a0
--- /dev/null
+++ b/examples/tutorials/extending/chapter1-basics/piechart.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+//![0]
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+//![0]
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+//![1]
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+//![1]
+
diff --git a/examples/tutorials/extending/chapter1-basics/piechart.h b/examples/tutorials/extending/chapter1-basics/piechart.h
new file mode 100644
index 0000000000..71a8786e7d
--- /dev/null
+++ b/examples/tutorials/extending/chapter1-basics/piechart.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+//![0]
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieChart : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QString m_name;
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter2-methods/app.qml b/examples/tutorials/extending/chapter2-methods/app.qml
new file mode 100644
index 0000000000..eee0933734
--- /dev/null
+++ b/examples/tutorials/extending/chapter2-methods/app.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ color: "red"
+
+ onChartCleared: console.log("The chart has been cleared")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: aPieChart.clearChart()
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to clear the chart"
+ }
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/tutorials/extending/chapter2-methods/main.cpp b/examples/tutorials/extending/chapter2-methods/main.cpp
new file mode 100644
index 0000000000..ed9e412bd6
--- /dev/null
+++ b/examples/tutorials/extending/chapter2-methods/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter2-methods/piechart.cpp b/examples/tutorials/extending/chapter2-methods/piechart.cpp
new file mode 100644
index 0000000000..71be74e943
--- /dev/null
+++ b/examples/tutorials/extending/chapter2-methods/piechart.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+void PieChart::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
+//![0]
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+
+ emit chartCleared();
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter2-methods/piechart.h b/examples/tutorials/extending/chapter2-methods/piechart.h
new file mode 100644
index 0000000000..7650d6e8d7
--- /dev/null
+++ b/examples/tutorials/extending/chapter2-methods/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+//![2]
+ Q_INVOKABLE void clearChart();
+
+signals:
+ void chartCleared();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter3-bindings/app.qml b/examples/tutorials/extending/chapter3-bindings/app.qml
new file mode 100644
index 0000000000..4ad929132c
--- /dev/null
+++ b/examples/tutorials/extending/chapter3-bindings/app.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ PieChart {
+ id: chartA
+ width: 100; height: 100
+ color: "red"
+ }
+
+ PieChart {
+ id: chartB
+ width: 100; height: 100
+ color: chartA.color
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { chartA.color = "blue" }
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to change the chart color"
+ }
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
new file mode 100644
index 0000000000..8ed66f8b66
--- /dev/null
+++ b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -0,0 +1,5 @@
+QT += qml quick
+
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
+ main.cpp
diff --git a/examples/tutorials/extending/chapter3-bindings/main.cpp b/examples/tutorials/extending/chapter3-bindings/main.cpp
new file mode 100644
index 0000000000..ed9e412bd6
--- /dev/null
+++ b/examples/tutorials/extending/chapter3-bindings/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+#include "piechart.h"
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/tutorials/extending/chapter3-bindings/piechart.cpp
new file mode 100644
index 0000000000..2a392125da
--- /dev/null
+++ b/examples/tutorials/extending/chapter3-bindings/piechart.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include <QPainter>
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QColor PieChart::color() const
+{
+ return m_color;
+}
+
+//![0]
+void PieChart::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update(); // repaint with the new color
+ emit colorChanged();
+ }
+}
+//![0]
+
+void PieChart::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
+void PieChart::clearChart()
+{
+ setColor(QColor(Qt::transparent));
+ update();
+}
diff --git a/examples/tutorials/extending/chapter3-bindings/piechart.h b/examples/tutorials/extending/chapter3-bindings/piechart.h
new file mode 100644
index 0000000000..77075b5727
--- /dev/null
+++ b/examples/tutorials/extending/chapter3-bindings/piechart.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QColor>
+#include <QtQuick/QQuickPaintedItem>
+
+//![0]
+class PieChart : public QQuickPaintedItem
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+ Q_INVOKABLE void clearChart();
+
+//![2]
+signals:
+ void colorChanged();
+//![2]
+
+private:
+ QString m_name;
+ QColor m_color;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/tutorials/extending/chapter4-customPropertyTypes/app.qml
new file mode 100644
index 0000000000..06490773f4
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ id: chart
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ pieSlice: PieSlice {
+ anchors.fill: parent
+ color: "red"
+ }
+ }
+
+ Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color)
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp
new file mode 100644
index 0000000000..537ea766fc
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+//![0]
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+
+//![1]
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+//![1]
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+
+//![2]
+}
+//![2]
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
new file mode 100644
index 0000000000..3cf9bdc00c
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+PieSlice *PieChart::pieSlice() const
+{
+ return m_pieSlice;
+}
+
+//![0]
+void PieChart::setPieSlice(PieSlice *pieSlice)
+{
+ m_pieSlice = pieSlice;
+ pieSlice->setParentItem(this);
+}
+//![0]
+
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h
new file mode 100644
index 0000000000..b89db5a2b1
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ PieSlice *pieSlice() const;
+ void setPieSlice(PieSlice *pieSlice);
+//![2]
+
+private:
+ QString m_name;
+ PieSlice *m_pieSlice;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
new file mode 100644
index 0000000000..654a46fc8d
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
+}
+
diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
new file mode 100644
index 0000000000..8fc445d471
--- /dev/null
+++ b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+};
+//![0]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter5-listproperties/app.qml b/examples/tutorials/extending/chapter5-listproperties/app.qml
new file mode 100644
index 0000000000..37b0626948
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/app.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Charts 1.0
+import QtQuick 2.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
new file mode 100644
index 0000000000..23eb222ea3
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
@@ -0,0 +1,7 @@
+QT += qml quick
+
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ main.cpp
diff --git a/examples/tutorials/extending/chapter5-listproperties/main.cpp b/examples/tutorials/extending/chapter5-listproperties/main.cpp
new file mode 100644
index 0000000000..59587733eb
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+#include <QtQuick/QQuickView>
+#include <QGuiApplication>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp
new file mode 100644
index 0000000000..910916508e
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+//![0]
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+//![0]
diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.h b/examples/tutorials/extending/chapter5-listproperties/piechart.h
new file mode 100644
index 0000000000..6c17bc1258
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/piechart.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+//![0]
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+//![2]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/tutorials/extending/chapter5-listproperties/pieslice.cpp
new file mode 100644
index 0000000000..5bca2d58d8
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/tutorials/extending/chapter5-listproperties/pieslice.h
new file mode 100644
index 0000000000..f6497fcbae
--- /dev/null
+++ b/examples/tutorials/extending/chapter5-listproperties/pieslice.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+//![0]
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+//![0]
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir
new file mode 100644
index 0000000000..72650d8243
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir
@@ -0,0 +1 @@
+plugin chartsplugin \ No newline at end of file
diff --git a/examples/tutorials/extending/chapter6-plugins/app.qml b/examples/tutorials/extending/chapter6-plugins/app.qml
new file mode 100644
index 0000000000..b6eac44e27
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/app.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.0
+import "ChartsPlugin" 1.0
+
+Item {
+ width: 300; height: 200
+
+ PieChart {
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ slices: [
+ PieSlice {
+ anchors.fill: parent
+ color: "red"
+ fromAngle: 0; angleSpan: 110
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "black"
+ fromAngle: 110; angleSpan: 50
+ },
+ PieSlice {
+ anchors.fill: parent
+ color: "blue"
+ fromAngle: 160; angleSpan: 100
+ }
+ ]
+ }
+}
+
diff --git a/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
new file mode 100644
index 0000000000..75f88b2eaa
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+
+DESTDIR = ChartsPlugin
+TARGET = chartsplugin
+
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
+
+HEADERS += piechart.h \
+ pieslice.h \
+ chartsplugin.h
+
+SOURCES += piechart.cpp \
+ pieslice.cpp \
+ chartsplugin.cpp
+
diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp
new file mode 100644
index 0000000000..0cead527b8
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "chartsplugin.h"
+//![0]
+#include "piechart.h"
+#include "pieslice.h"
+#include <qqml.h>
+
+void ChartsPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<PieChart>(uri, 1, 0, "PieChart");
+ qmlRegisterType<PieSlice>(uri, 1, 0, "PieSlice");
+}
+
+//![0]
+
diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h
new file mode 100644
index 0000000000..4db1b01987
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef CHARTSPLUGIN_H
+#define CHARTSPLUGIN_H
+
+//![0]
+#include <QQmlExtensionPlugin>
+
+class ChartsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "chartsplugin.json")
+
+public:
+ void registerTypes(const char *uri);
+};
+//![0]
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.json b/examples/tutorials/extending/chapter6-plugins/chartsplugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/tutorials/extending/chapter6-plugins/piechart.cpp
new file mode 100644
index 0000000000..b188e39d81
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/piechart.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "piechart.h"
+#include "pieslice.h"
+
+PieChart::PieChart(QQuickItem *parent)
+ : QQuickItem(parent)
+{
+}
+
+QString PieChart::name() const
+{
+ return m_name;
+}
+
+void PieChart::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QQmlListProperty<PieSlice> PieChart::slices()
+{
+ return QQmlListProperty<PieSlice>(this, 0, &PieChart::append_slice);
+}
+
+void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
+{
+ PieChart *chart = qobject_cast<PieChart *>(list->object);
+ if (chart) {
+ slice->setParentItem(chart);
+ chart->m_slices.append(slice);
+ }
+}
+
diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.h b/examples/tutorials/extending/chapter6-plugins/piechart.h
new file mode 100644
index 0000000000..2ee8108784
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/piechart.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIECHART_H
+#define PIECHART_H
+
+#include <QtQuick/QQuickItem>
+
+class PieSlice;
+
+class PieChart : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+public:
+ PieChart(QQuickItem *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QQmlListProperty<PieSlice> slices();
+
+private:
+ static void append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice);
+
+ QString m_name;
+ QList<PieSlice *> m_slices;
+};
+
+#endif
+
diff --git a/examples/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/tutorials/extending/chapter6-plugins/pieslice.cpp
new file mode 100644
index 0000000000..5bca2d58d8
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/pieslice.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "pieslice.h"
+
+#include <QPainter>
+
+PieSlice::PieSlice(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+{
+}
+
+QColor PieSlice::color() const
+{
+ return m_color;
+}
+
+void PieSlice::setColor(const QColor &color)
+{
+ m_color = color;
+}
+
+int PieSlice::fromAngle() const
+{
+ return m_fromAngle;
+}
+
+void PieSlice::setFromAngle(int angle)
+{
+ m_fromAngle = angle;
+}
+
+int PieSlice::angleSpan() const
+{
+ return m_angleSpan;
+}
+
+void PieSlice::setAngleSpan(int angle)
+{
+ m_angleSpan = angle;
+}
+
+void PieSlice::paint(QPainter *painter)
+{
+ QPen pen(m_color, 2);
+ painter->setPen(pen);
+ painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
+ painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
+}
+
diff --git a/examples/tutorials/extending/chapter6-plugins/pieslice.h b/examples/tutorials/extending/chapter6-plugins/pieslice.h
new file mode 100644
index 0000000000..8a636fb3e7
--- /dev/null
+++ b/examples/tutorials/extending/chapter6-plugins/pieslice.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PIESLICE_H
+#define PIESLICE_H
+
+#include <QtQuick/QQuickPaintedItem>
+#include <QColor>
+
+class PieSlice : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
+ Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+
+public:
+ PieSlice(QQuickItem *parent = 0);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ int fromAngle() const;
+ void setFromAngle(int angle);
+
+ int angleSpan() const;
+ void setAngleSpan(int span);
+
+ void paint(QPainter *painter);
+
+private:
+ QColor m_color;
+ int m_fromAngle;
+ int m_angleSpan;
+};
+
+#endif
+
diff --git a/examples/tutorials/extending/extending.pro b/examples/tutorials/extending/extending.pro
new file mode 100644
index 0000000000..967473fda0
--- /dev/null
+++ b/examples/tutorials/extending/extending.pro
@@ -0,0 +1,10 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ chapter1-basics \
+ chapter2-methods \
+ chapter3-bindings \
+ chapter4-customPropertyTypes \
+ chapter5-listproperties \
+ chapter6-plugins
+
diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
index c8538958ac..776af5629b 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
+++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp
@@ -49,6 +49,3 @@ void DialogPlugin::registerTypes(const char *uri)
qmlRegisterType<Directory>(uri, 1, 0, "Directory");
qmlRegisterType<File>(uri,1,0,"File");
}
-
-//FileDialog is the plugin name (same as the TARGET in the project file) and DialogPlugin is the plugin classs
-Q_EXPORT_PLUGIN2(FileDialog, DialogPlugin); \ No newline at end of file
diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
index 1aed6abc8e..fcaa210457 100644
--- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
+++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h
@@ -46,6 +46,7 @@
class DialogPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "dialogplugin.json")
public:
//registerTypes is inherited from QQmlExtensionPlugin
diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json b/examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json
@@ -0,0 +1 @@
+{}
diff --git a/examples/tutorials/helloworld/Cell.qml b/examples/tutorials/helloworld/Cell.qml
new file mode 100644
index 0000000000..7140dcb2c1
--- /dev/null
+++ b/examples/tutorials/helloworld/Cell.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+//![1]
+Item {
+ id: container
+//![4]
+ property alias cellColor: rectangle.color
+//![4]
+//![5]
+ signal clicked(color cellColor)
+//![5]
+
+ width: 40; height: 25
+//![1]
+
+//![2]
+ Rectangle {
+ id: rectangle
+ border.color: "white"
+ anchors.fill: parent
+ }
+//![2]
+
+//![3]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked(container.cellColor)
+ }
+//![3]
+}
+//![0]
diff --git a/examples/tutorials/helloworld/tutorial1.qml b/examples/tutorials/helloworld/tutorial1.qml
new file mode 100644
index 0000000000..f0eb42d696
--- /dev/null
+++ b/examples/tutorials/helloworld/tutorial1.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+//![3]
+import QtQuick 2.0
+//![3]
+
+//![1]
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+//![1]
+
+//![2]
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+//![2]
+}
+//![0]
diff --git a/examples/tutorials/helloworld/tutorial2.qml b/examples/tutorials/helloworld/tutorial2.qml
new file mode 100644
index 0000000000..c5c045aace
--- /dev/null
+++ b/examples/tutorials/helloworld/tutorial2.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+//![1]
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+//![1]
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/examples/tutorials/helloworld/tutorial3.qml b/examples/tutorials/helloworld/tutorial3.qml
new file mode 100644
index 0000000000..c804bfca1d
--- /dev/null
+++ b/examples/tutorials/helloworld/tutorial3.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+
+//![1]
+ MouseArea { id: mouseArea; anchors.fill: parent }
+//![1]
+
+//![2]
+ states: State {
+ name: "down"; when: mouseArea.pressed == true
+ PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
+ }
+//![2]
+
+//![3]
+ transitions: Transition {
+ from: ""; to: "down"; reversible: true
+ ParallelAnimation {
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad }
+ ColorAnimation { duration: 500 }
+ }
+ }
+//![3]
+ }
+
+ Grid {
+ id: colorPicker
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
+ rows: 2; columns: 3; spacing: 3
+
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame1/Block.qml b/examples/tutorials/samegame/samegame1/Block.qml
new file mode 100644
index 0000000000..32ef8c2bba
--- /dev/null
+++ b/examples/tutorials/samegame/samegame1/Block.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame1/Button.qml b/examples/tutorials/samegame/samegame1/Button.qml
new file mode 100644
index 0000000000..6d1d1268de
--- /dev/null
+++ b/examples/tutorials/samegame/samegame1/Button.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame1/samegame.qml b/examples/tutorials/samegame/samegame1/samegame.qml
new file mode 100644
index 0000000000..73e2cc31fd
--- /dev/null
+++ b/examples/tutorials/samegame/samegame1/samegame.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: console.log("This doesn't do anything yet...")
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/tutorials/samegame/samegame1/samegame1.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/tutorials/samegame/samegame1/samegame1.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/samegame/samegame2/Block.qml b/examples/tutorials/samegame/samegame2/Block.qml
new file mode 100644
index 0000000000..8056b39480
--- /dev/null
+++ b/examples/tutorials/samegame/samegame2/Block.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ Image {
+ id: img
+ anchors.fill: parent
+ source: "../shared/pics/redStone.png"
+ }
+}
diff --git a/examples/tutorials/samegame/samegame2/Button.qml b/examples/tutorials/samegame/samegame2/Button.qml
new file mode 100644
index 0000000000..248c20cf0f
--- /dev/null
+++ b/examples/tutorials/samegame/samegame2/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/tutorials/samegame/samegame2/samegame.js b/examples/tutorials/samegame/samegame2/samegame.js
new file mode 100644
index 0000000000..c749dc17b1
--- /dev/null
+++ b/examples/tutorials/samegame/samegame2/samegame.js
@@ -0,0 +1,63 @@
+//![0]
+var blockSize = 40;
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(background.width / blockSize);
+ maxRow = Math.floor(background.height / blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(background);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.x = column * blockSize;
+ dynamicObject.y = row * blockSize;
+ dynamicObject.width = blockSize;
+ dynamicObject.height = blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+//![0]
+
diff --git a/examples/tutorials/samegame/samegame2/samegame.qml b/examples/tutorials/samegame/samegame2/samegame.qml
new file mode 100644
index 0000000000..c50010e97d
--- /dev/null
+++ b/examples/tutorials/samegame/samegame2/samegame.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//![2]
+import "samegame.js" as SameGame
+//![2]
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 32
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+//![1]
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+//![1]
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
diff --git a/examples/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/tutorials/samegame/samegame2/samegame2.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/tutorials/samegame/samegame2/samegame2.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/samegame/samegame3/Block.qml b/examples/tutorials/samegame/samegame3/Block.qml
new file mode 100644
index 0000000000..9c41048fcb
--- /dev/null
+++ b/examples/tutorials/samegame/samegame3/Block.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: block
+
+ property int type: 0
+
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../shared/pics/blueStone.png";
+ else
+ return "../shared/pics/greenStone.png";
+ }
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame3/Button.qml b/examples/tutorials/samegame/samegame3/Button.qml
new file mode 100644
index 0000000000..248c20cf0f
--- /dev/null
+++ b/examples/tutorials/samegame/samegame3/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/tutorials/samegame/samegame3/Dialog.qml b/examples/tutorials/samegame/samegame3/Dialog.qml
new file mode 100644
index 0000000000..df1fa37d6a
--- /dev/null
+++ b/examples/tutorials/samegame/samegame3/Dialog.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ }
+
+ function hide() {
+ container.opacity = 0;
+ }
+
+ width: dialogText.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+
+ Text {
+ id: dialogText
+ anchors.centerIn: parent
+ text: ""
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: hide();
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame3/samegame.js b/examples/tutorials/samegame/samegame3/samegame.js
new file mode 100644
index 0000000000..df5bdfb049
--- /dev/null
+++ b/examples/tutorials/samegame/samegame3/samegame.js
@@ -0,0 +1,174 @@
+/* This script file handles the game logic */
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("Block.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+//![1]
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+//![1]
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].opacity = 0;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y += fallDist * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ var fallDist = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (var row = 0; row < maxRow; row++) {
+ var obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x -= fallDist * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![2]
+function victoryCheck() {
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1)))
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+}
+//![2]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
diff --git a/examples/tutorials/samegame/samegame3/samegame.qml b/examples/tutorials/samegame/samegame3/samegame.qml
new file mode 100644
index 0000000000..f14829ef63
--- /dev/null
+++ b/examples/tutorials/samegame/samegame3/samegame.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+import "samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+//![1]
+ Item {
+ id: gameCanvas
+
+ property int score: 0
+ property int blockSize: 40
+
+ width: parent.width - (parent.width % blockSize)
+ height: parent.height - (parent.height % blockSize)
+ anchors.centerIn: parent
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: SameGame.handleClick(mouse.x, mouse.y)
+ }
+ }
+//![1]
+ }
+
+//![2]
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+//![2]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: Who knows?"
+ }
+ }
+}
+//![0]
diff --git a/examples/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/tutorials/samegame/samegame3/samegame3.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/tutorials/samegame/samegame3/samegame3.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/tutorials/samegame/samegame4/content/BoomBlock.qml
new file mode 100644
index 0000000000..3786b9c0d1
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import Qt.labs.particles 1.0
+
+Item {
+ id: block
+
+ property int type: 0
+ property bool dying: false
+
+ //![1]
+ property bool spawned: false
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ //![1]
+
+ //![2]
+ Image {
+ id: img
+
+ anchors.fill: parent
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStone.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStone.png";
+ else
+ return "../../shared/pics/greenStone.png";
+ }
+ opacity: 0
+
+ Behavior on opacity {
+ NumberAnimation { properties:"opacity"; duration: 200 }
+ }
+ }
+ //![2]
+
+ //![3]
+ Particles {
+ id: particles
+
+ width: 1; height: 1
+ anchors.centerIn: parent
+
+ emissionRate: 0
+ lifeSpan: 700; lifeSpanDeviation: 600
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation: 30
+ source: {
+ if (type == 0)
+ return "../../shared/pics/redStar.png";
+ else if (type == 1)
+ return "../../shared/pics/blueStar.png";
+ else
+ return "../../shared/pics/greenStar.png";
+ }
+ }
+ //![3]
+
+ //![4]
+ states: [
+ State {
+ name: "AliveState"
+ when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"
+ when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+ //![4]
+}
diff --git a/examples/tutorials/samegame/samegame4/content/Button.qml b/examples/tutorials/samegame/samegame4/content/Button.qml
new file mode 100644
index 0000000000..248c20cf0f
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/content/Button.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: container
+
+ property string text: "Button"
+
+ signal clicked
+
+ width: buttonLabel.width + 20; height: buttonLabel.height + 5
+ border { width: 1; color: Qt.darker(activePalette.button) }
+ smooth: true
+ radius: 8
+
+ // color the button with a gradient
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: {
+ if (mouseArea.pressed)
+ return activePalette.dark
+ else
+ return activePalette.light
+ }
+ }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: container.clicked();
+ }
+
+ Text {
+ id: buttonLabel
+ anchors.centerIn: container
+ color: activePalette.buttonText
+ text: container.text
+ }
+}
diff --git a/examples/tutorials/samegame/samegame4/content/Dialog.qml b/examples/tutorials/samegame/samegame4/content/Dialog.qml
new file mode 100644
index 0000000000..984b3ddb6a
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/content/Dialog.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![0]
+Rectangle {
+ id: container
+//![0]
+
+//![1]
+ property string inputText: textInput.text
+ signal closed
+
+ function show(text) {
+ dialogText.text = text;
+ container.opacity = 1;
+ textInput.opacity = 0;
+ }
+
+ function showWithInput(text) {
+ show(text);
+ textInput.opacity = 1;
+ textInput.focus = true;
+ textInput.text = ""
+ }
+
+ function hide() {
+ textInput.focus = false;
+ container.opacity = 0;
+ container.closed();
+ }
+//![1]
+
+ width: dialogText.width + textInput.width + 20
+ height: dialogText.height + 20
+ opacity: 0
+ visible: opacity > 0
+
+ Text {
+ id: dialogText
+ anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 }
+ text: ""
+ }
+
+//![2]
+ TextInput {
+ id: textInput
+ anchors { verticalCenter: parent.verticalCenter; left: dialogText.right }
+ width: 80
+ text: ""
+
+ onAccepted: container.hide() // close dialog when Enter is pressed
+ }
+//![2]
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ if (textInput.text == "" && textInput.opacity > 0)
+ textInput.openSoftwareInputPanel();
+ else
+ hide();
+ }
+ }
+
+//![3]
+}
+//![3]
diff --git a/examples/tutorials/samegame/samegame4/content/samegame.js b/examples/tutorials/samegame/samegame4/content/samegame.js
new file mode 100755
index 0000000000..7bb7243914
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/content/samegame.js
@@ -0,0 +1,226 @@
+/* This script file handles the game logic */
+.import QtQuick.LocalStorage 2.0 as Sql
+
+var maxColumn = 10;
+var maxRow = 15;
+var maxIndex = maxColumn * maxRow;
+var board = new Array(maxIndex);
+var component;
+var scoresURL = "";
+var gameDuration;
+
+//Index function used instead of a 2D array
+function index(column, row) {
+ return column + (row * maxColumn);
+}
+
+function startNewGame() {
+ //Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
+ maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
+ maxIndex = maxRow * maxColumn;
+
+ //Close dialogs
+ nameInputDialog.hide();
+ dialog.hide();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ board[index(column, row)] = null;
+ createBlock(column, row);
+ }
+ }
+
+ gameDuration = new Date();
+}
+
+function createBlock(column, row) {
+ if (component == null)
+ component = Qt.createComponent("content/BoomBlock.qml");
+
+ // Note that if Block.qml was not a local file, component.status would be
+ // Loading and we should wait for the component's statusChanged() signal to
+ // know when the file is downloaded and ready before calling createObject().
+ if (component.status == Component.Ready) {
+ var dynamicObject = component.createObject(gameCanvas);
+ if (dynamicObject == null) {
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.x = column * gameCanvas.blockSize;
+ dynamicObject.y = row * gameCanvas.blockSize;
+ dynamicObject.width = gameCanvas.blockSize;
+ dynamicObject.height = gameCanvas.blockSize;
+ dynamicObject.spawned = true;
+ board[index(column, row)] = dynamicObject;
+ } else {
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound; //Set after a floodFill call to the number of blocks found
+var floodBoard; //Set to 1 if the floodFill reaches off that node
+
+function handleClick(xPos, yPos) {
+ var column = Math.floor(xPos / gameCanvas.blockSize);
+ var row = Math.floor(yPos / gameCanvas.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ //If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column, row, -1);
+ if (fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(column, row, type) {
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column, row)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; //Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown() {
+ //Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column, row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * gameCanvas.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * gameCanvas.blockSize;
+ board[index(column - fallDist, row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![3]
+function victoryCheck() {
+//![3]
+ //Award bonus points if no blocks left
+ var deservesBonus = true;
+ for (var column = maxColumn - 1; column >= 0; column--)
+ if (board[index(column, maxRow - 1)] != null)
+ deservesBonus = false;
+ if (deservesBonus)
+ gameCanvas.score += 500;
+
+//![4]
+ //Check whether game has finished
+ if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) {
+ gameDuration = new Date() - gameDuration;
+ nameInputDialog.showWithInput("You won! Please enter your name: ");
+ }
+}
+//![4]
+
+//only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type) {
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
+}
+
+//![2]
+function saveHighScore(name) {
+ if (scoresURL != "")
+ sendHighScore(name);
+
+ var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100);
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)];
+ db.transaction(function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ for (var i = 0; i < rs.rows.length; i++) {
+ r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n';
+ }
+ dialog.show(r);
+ });
+}
+//![2]
+
+//![1]
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000);
+ postman.open("POST", scoresURL, true);
+ postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
+//![1]
diff --git a/examples/tutorials/samegame/samegame4/highscores/README b/examples/tutorials/samegame/samegame4/highscores/README
new file mode 100644
index 0000000000..eaa00fae37
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/examples/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/tutorials/samegame/samegame4/highscores/score_data.xml
new file mode 100755
index 0000000000..c3fd90d9cf
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/examples/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/tutorials/samegame/samegame4/highscores/score_style.xsl
new file mode 100755
index 0000000000..670354c965
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/examples/tutorials/samegame/samegame4/highscores/scores.php b/examples/tutorials/samegame/samegame4/highscores/scores.php
new file mode 100755
index 0000000000..daf480e21b
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/highscores/scores.php
@@ -0,0 +1,31 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ $file = fopen("score_data.xml", "a");
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/examples/tutorials/samegame/samegame4/samegame.qml b/examples/tutorials/samegame/samegame4/samegame.qml
new file mode 100644
index 0000000000..c21b8de8bd
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/samegame.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/samegame.js" as SameGame
+
+Rectangle {
+ id: screen
+
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width
+ anchors { top: parent.top; bottom: toolBar.top }
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int blockSize: 40
+
+ anchors.centerIn: parent
+ width: parent.width - (parent.width % blockSize);
+ height: parent.height - (parent.height % blockSize);
+
+ MouseArea {
+ anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Dialog {
+ id: dialog
+ anchors.centerIn: parent
+ z: 100
+ }
+
+ //![0]
+ Dialog {
+ id: nameInputDialog
+ anchors.centerIn: parent
+ z: 100
+
+ onClosed: {
+ if (nameInputDialog.inputText != "")
+ SameGame.saveHighScore(nameInputDialog.inputText);
+ }
+ }
+ //![0]
+
+ Rectangle {
+ id: toolBar
+ width: parent.width; height: 30
+ color: activePalette.window
+ anchors.bottom: screen.bottom
+
+ Button {
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter }
+ text: "New Game"
+ onClicked: SameGame.startNewGame()
+ }
+
+ Text {
+ id: score
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: "Score: " + gameCanvas.score
+ }
+ }
+}
diff --git a/examples/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/tutorials/samegame/samegame4/samegame4.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/tutorials/samegame/samegame4/samegame4.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/samegame/shared/pics/background.jpg b/examples/tutorials/samegame/shared/pics/background.jpg
new file mode 100644
index 0000000000..903d395c8d
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/background.jpg
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/blueStar.png b/examples/tutorials/samegame/shared/pics/blueStar.png
new file mode 100644
index 0000000000..ff9588f80a
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/blueStar.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/blueStone.png b/examples/tutorials/samegame/shared/pics/blueStone.png
new file mode 100644
index 0000000000..20e43c75b6
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/blueStone.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/greenStar.png b/examples/tutorials/samegame/shared/pics/greenStar.png
new file mode 100644
index 0000000000..cd06854719
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/greenStar.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/greenStone.png b/examples/tutorials/samegame/shared/pics/greenStone.png
new file mode 100644
index 0000000000..b568a1900c
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/greenStone.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/redStar.png b/examples/tutorials/samegame/shared/pics/redStar.png
new file mode 100644
index 0000000000..0a4dffe583
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/redStar.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/redStone.png b/examples/tutorials/samegame/shared/pics/redStone.png
new file mode 100644
index 0000000000..36b09a2686
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/redStone.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/star.png b/examples/tutorials/samegame/shared/pics/star.png
new file mode 100644
index 0000000000..defbde53ca
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/star.png
Binary files differ
diff --git a/examples/tutorials/samegame/shared/pics/yellowStone.png b/examples/tutorials/samegame/shared/pics/yellowStone.png
new file mode 100644
index 0000000000..b1ce76212c
--- /dev/null
+++ b/examples/tutorials/samegame/shared/pics/yellowStone.png
Binary files differ
diff --git a/examples/tutorials/ui-components/dialcontrol/content/Dial.qml b/examples/tutorials/ui-components/dialcontrol/content/Dial.qml
new file mode 100644
index 0000000000..c61adee364
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/Dial.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: root
+ property real value : 0
+
+ width: 210; height: 210
+
+ Image { source: "background.png" }
+
+//! [needle_shadow]
+ Image {
+ x: 96
+ y: 35
+ source: "needle_shadow.png"
+ transform: Rotation {
+ origin.x: 9; origin.y: 67
+ angle: needleRotation.angle
+ }
+ }
+//! [needle_shadow]
+//! [needle]
+ Image {
+ id: needle
+ x: 98; y: 33
+ smooth: true
+ source: "needle.png"
+ transform: Rotation {
+ id: needleRotation
+ origin.x: 5; origin.y: 65
+ //! [needle angle]
+ angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ Behavior on angle {
+ SpringAnimation {
+ spring: 1.4
+ damping: .15
+ }
+ }
+ //! [needle angle]
+ }
+ }
+//! [needle]
+//! [overlay]
+ Image { x: 21; y: 18; source: "overlay.png" }
+//! [overlay]
+}
diff --git a/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml b/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml
new file mode 100644
index 0000000000..702b892d23
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Image {
+ source: "quit.png"
+ scale: quitMouse.pressed ? 0.8 : 1.0
+ smooth: quitMouse.pressed
+ MouseArea {
+ id: quitMouse
+ anchors.fill: parent
+ anchors.margins: -10
+ onClicked: Qt.quit()
+ }
+}
diff --git a/examples/tutorials/ui-components/dialcontrol/content/background.png b/examples/tutorials/ui-components/dialcontrol/content/background.png
new file mode 100644
index 0000000000..75d555d7ab
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/background.png
Binary files differ
diff --git a/examples/tutorials/ui-components/dialcontrol/content/needle.png b/examples/tutorials/ui-components/dialcontrol/content/needle.png
new file mode 100644
index 0000000000..2d19f75039
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/needle.png
Binary files differ
diff --git a/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png b/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png
new file mode 100644
index 0000000000..8d8a928cc5
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png
Binary files differ
diff --git a/examples/tutorials/ui-components/dialcontrol/content/overlay.png b/examples/tutorials/ui-components/dialcontrol/content/overlay.png
new file mode 100644
index 0000000000..3860a7b590
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/overlay.png
Binary files differ
diff --git a/examples/tutorials/ui-components/dialcontrol/content/quit.png b/examples/tutorials/ui-components/dialcontrol/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/content/quit.png
Binary files differ
diff --git a/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml b/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml
new file mode 100644
index 0000000000..d645b34aa4
--- /dev/null
+++ b/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [imports]
+import QtQuick 2.0
+import "content"
+//! [imports]
+
+//! [0]
+Rectangle {
+ color: "#545454"
+ width: 300; height: 300
+
+ // Dial with a slider to adjust it
+ Dial {
+ id: dial
+ anchors.centerIn: parent
+ value: slider.x * 100 / (container.width - 34)
+ }
+
+ Rectangle {
+ id: container
+ anchors { bottom: parent.bottom; left: parent.left
+ right: parent.right; leftMargin: 20; rightMargin: 20
+ bottomMargin: 10
+ }
+ height: 16
+
+ radius: 8
+ opacity: 0.7
+ smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "gray" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+
+ Rectangle {
+ id: slider
+ x: 1; y: 1; width: 30; height: 14
+ radius: 6
+ smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#424242" }
+ GradientStop { position: 1.0; color: "black" }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ anchors.margins: -16 // Increase mouse area a lot outside the slider
+ drag.target: parent; drag.axis: Drag.XAxis
+ drag.minimumX: 2; drag.maximumX: container.width - 32
+ }
+ }
+ }
+ QuitButton {
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.margins: 10
+ }
+}
+//! [0]
diff --git a/examples/tutorials/ui-components/flipable/content/5_heart.png b/examples/tutorials/ui-components/flipable/content/5_heart.png
new file mode 100644
index 0000000000..fb59d81453
--- /dev/null
+++ b/examples/tutorials/ui-components/flipable/content/5_heart.png
Binary files differ
diff --git a/examples/tutorials/ui-components/flipable/content/9_club.png b/examples/tutorials/ui-components/flipable/content/9_club.png
new file mode 100644
index 0000000000..2545001904
--- /dev/null
+++ b/examples/tutorials/ui-components/flipable/content/9_club.png
Binary files differ
diff --git a/examples/tutorials/ui-components/flipable/content/Card.qml b/examples/tutorials/ui-components/flipable/content/Card.qml
new file mode 100644
index 0000000000..6006ea14fc
--- /dev/null
+++ b/examples/tutorials/ui-components/flipable/content/Card.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: container
+
+ property alias source: frontImage.source
+ property bool flipped: true
+ property int xAxis: 0
+ property int yAxis: 0
+ property int angle: 0
+
+ width: front.width; height: front.height
+
+ front: Image { id: frontImage; smooth: true }
+ back: Image { source: "back.png"; smooth: true }
+
+ state: "back"
+
+ MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped }
+
+ transform: Rotation {
+ id: rotation; origin.x: container.width / 2; origin.y: container.height / 2
+ axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0
+ }
+
+ states: State {
+ name: "back"; when: container.flipped
+ PropertyChanges { target: rotation; angle: container.angle }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { target: rotation; properties: "angle"; duration: 600 }
+ SequentialAnimation {
+ NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 }
+ NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 }
+ }
+ }
+ }
+}
diff --git a/examples/tutorials/ui-components/flipable/content/back.png b/examples/tutorials/ui-components/flipable/content/back.png
new file mode 100644
index 0000000000..f715d7487e
--- /dev/null
+++ b/examples/tutorials/ui-components/flipable/content/back.png
Binary files differ
diff --git a/examples/tutorials/ui-components/flipable/flipable.qml b/examples/tutorials/ui-components/flipable/flipable.qml
new file mode 100644
index 0000000000..4af64afc53
--- /dev/null
+++ b/examples/tutorials/ui-components/flipable/flipable.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+
+ width: 480; height: 320
+ color: "darkgreen"
+
+ Row {
+ anchors.centerIn: parent; spacing: 30
+ Card { source: "content/9_club.png"; angle: 180; yAxis: 1 }
+ Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 }
+ }
+}
diff --git a/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml b/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml
new file mode 100644
index 0000000000..c9be8d7336
--- /dev/null
+++ b/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: progressbar
+
+ property int minimum: 0
+ property int maximum: 100
+ property int value: 0
+ property alias color: gradient1.color
+ property alias secondColor: gradient2.color
+
+ width: 250; height: 23
+ clip: true
+
+ BorderImage {
+ source: "background.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ Rectangle {
+ id: highlight
+
+ property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
+
+ width: highlight.widthDest
+ Behavior on width { SmoothedAnimation { velocity: 1200 } }
+
+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
+ radius: 1
+ gradient: Gradient {
+ GradientStop { id: gradient1; position: 0.0 }
+ GradientStop { id: gradient2; position: 1.0 }
+ }
+
+ }
+ Text {
+ anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ color: "white"
+ font.bold: true
+ text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
+ }
+}
diff --git a/examples/tutorials/ui-components/progressbar/content/background.png b/examples/tutorials/ui-components/progressbar/content/background.png
new file mode 100644
index 0000000000..9044226f85
--- /dev/null
+++ b/examples/tutorials/ui-components/progressbar/content/background.png
Binary files differ
diff --git a/examples/tutorials/ui-components/progressbar/main.qml b/examples/tutorials/ui-components/progressbar/main.qml
new file mode 100644
index 0000000000..367e4c1265
--- /dev/null
+++ b/examples/tutorials/ui-components/progressbar/main.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: main
+
+ width: 600; height: 405
+ color: "#edecec"
+
+ Flickable {
+ anchors.fill: parent
+ contentHeight: column.height + 20
+
+ Column {
+ id: column
+ x: 10; y: 10
+ spacing: 10
+
+ Repeater {
+ model: 25
+
+ ProgressBar {
+ property int r: Math.floor(Math.random() * 5000 + 1000)
+ width: main.width - 20
+
+ NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite }
+ ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite }
+ ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/tutorials/ui-components/scrollbar/ScrollBar.qml b/examples/tutorials/ui-components/scrollbar/ScrollBar.qml
new file mode 100644
index 0000000000..a3d0d3841c
--- /dev/null
+++ b/examples/tutorials/ui-components/scrollbar/ScrollBar.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: scrollBar
+
+ // The properties that define the scrollbar's state.
+ // position and pageSize are in the range 0.0 - 1.0. They are relative to the
+ // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
+ // of the height of the view.
+ // orientation can be either Qt.Vertical or Qt.Horizontal
+ property real position
+ property real pageSize
+ property variant orientation : Qt.Vertical
+
+ // A light, semi-transparent background
+ Rectangle {
+ id: background
+ anchors.fill: parent
+ radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
+ color: "white"
+ opacity: 0.3
+ }
+
+ // Size the bar to the required size, depending upon the orientation.
+ Rectangle {
+ x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
+ y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
+ width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
+ height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1)
+ color: "black"
+ opacity: 0.7
+ }
+}
diff --git a/examples/tutorials/ui-components/scrollbar/main.qml b/examples/tutorials/ui-components/scrollbar/main.qml
new file mode 100644
index 0000000000..a7d602b437
--- /dev/null
+++ b/examples/tutorials/ui-components/scrollbar/main.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 640
+ height: 480
+
+ // Create a flickable to view a large image.
+ Flickable {
+ id: view
+ anchors.fill: parent
+ contentWidth: picture.width
+ contentHeight: picture.height
+
+ Image {
+ id: picture
+ source: "pics/niagara_falls.jpg"
+ asynchronous: true
+ }
+
+ // Only show the scrollbars when the view is moving.
+ states: State {
+ name: "ShowBars"
+ when: view.movingVertically || view.movingHorizontally
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ PropertyChanges { target: horizontalScrollBar; opacity: 1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "opacity"; duration: 400 }
+ }
+ }
+
+ // Attach scrollbars to the right and bottom edges of the view.
+ ScrollBar {
+ id: verticalScrollBar
+ width: 12; height: view.height-12
+ anchors.right: view.right
+ opacity: 0
+ orientation: Qt.Vertical
+ position: view.visibleArea.yPosition
+ pageSize: view.visibleArea.heightRatio
+ }
+
+ ScrollBar {
+ id: horizontalScrollBar
+ width: view.width-12; height: 12
+ anchors.bottom: view.bottom
+ opacity: 0
+ orientation: Qt.Horizontal
+ position: view.visibleArea.xPosition
+ pageSize: view.visibleArea.widthRatio
+ }
+}
diff --git a/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg
new file mode 100644
index 0000000000..e625c0d3e6
--- /dev/null
+++ b/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg
Binary files differ
diff --git a/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject b/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/ui-components/searchbox/SearchBox.qml b/examples/tutorials/ui-components/searchbox/SearchBox.qml
new file mode 100644
index 0000000000..6f6f486412
--- /dev/null
+++ b/examples/tutorials/ui-components/searchbox/SearchBox.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: focusScope
+ width: 250; height: 28
+
+ BorderImage {
+ source: "images/lineedit-bg.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ BorderImage {
+ source: "images/lineedit-bg-focus.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ visible: parent.activeFocus ? true : false
+ }
+
+ Text {
+ id: typeSomething
+ anchors.fill: parent; anchors.leftMargin: 8
+ verticalAlignment: Text.AlignVCenter
+ text: "Type something..."
+ color: "gray"
+ font.italic: true
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); }
+ }
+
+ TextInput {
+ id: textInput
+ anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ focus: true
+ selectByMouse: true
+ }
+
+ Image {
+ id: clear
+ anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
+ source: "images/clear.png"
+ opacity: 0
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); }
+ }
+ }
+
+ states: State {
+ name: "hasText"; when: textInput.text != ''
+ PropertyChanges { target: typeSomething; opacity: 0 }
+ PropertyChanges { target: clear; opacity: 1 }
+ }
+
+ transitions: [
+ Transition {
+ from: ""; to: "hasText"
+ NumberAnimation { exclude: typeSomething; properties: "opacity" }
+ },
+ Transition {
+ from: "hasText"; to: ""
+ NumberAnimation { properties: "opacity" }
+ }
+ ]
+}
diff --git a/examples/tutorials/ui-components/searchbox/images/clear.png b/examples/tutorials/ui-components/searchbox/images/clear.png
new file mode 100644
index 0000000000..91eb270695
--- /dev/null
+++ b/examples/tutorials/ui-components/searchbox/images/clear.png
Binary files differ
diff --git a/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png
new file mode 100644
index 0000000000..bbfac38d2d
--- /dev/null
+++ b/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png
Binary files differ
diff --git a/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png b/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png
new file mode 100644
index 0000000000..9044226f85
--- /dev/null
+++ b/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png
Binary files differ
diff --git a/examples/tutorials/ui-components/searchbox/main.qml b/examples/tutorials/ui-components/searchbox/main.qml
new file mode 100644
index 0000000000..6e9731cf9c
--- /dev/null
+++ b/examples/tutorials/ui-components/searchbox/main.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 500; height: 250
+ color: "#edecec"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: page.focus = false;
+ }
+ Column {
+ anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
+ spacing: 10
+
+ SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true }
+ SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 }
+ SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 }
+ }
+}
diff --git a/examples/tutorials/ui-components/searchbox/searchbox.qmlproject b/examples/tutorials/ui-components/searchbox/searchbox.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/tutorials/ui-components/searchbox/searchbox.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/ui-components/slideswitch/content/Switch.qml b/examples/tutorials/ui-components/slideswitch/content/Switch.qml
new file mode 100644
index 0000000000..981fc16673
--- /dev/null
+++ b/examples/tutorials/ui-components/slideswitch/content/Switch.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+import QtQuick 2.0
+
+Item {
+ id: toggleswitch
+ width: background.width; height: background.height
+
+//![1]
+ property bool on: false
+//![1]
+
+//![2]
+ function toggle() {
+ if (toggleswitch.state == "on")
+ toggleswitch.state = "off";
+ else
+ toggleswitch.state = "on";
+ }
+//![2]
+
+//![3]
+ function releaseSwitch() {
+ if (knob.x == 1) {
+ if (toggleswitch.state == "off") return;
+ }
+ if (knob.x == 78) {
+ if (toggleswitch.state == "on") return;
+ }
+ toggle();
+ }
+//![3]
+
+//![4]
+ Image {
+ id: background
+ source: "background.png"
+ MouseArea { anchors.fill: parent; onClicked: toggle() }
+ }
+//![4]
+
+//![5]
+ Image {
+ id: knob
+ x: 1; y: 2
+ source: "knob.png"
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78
+ onClicked: toggle()
+ onReleased: releaseSwitch()
+ }
+ }
+//![5]
+
+//![6]
+ states: [
+ State {
+ name: "on"
+ PropertyChanges { target: knob; x: 78 }
+ PropertyChanges { target: toggleswitch; on: true }
+ },
+ State {
+ name: "off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: toggleswitch; on: false }
+ }
+ ]
+//![6]
+
+//![7]
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+//![7]
+}
+//![0]
diff --git a/examples/tutorials/ui-components/slideswitch/content/background.png b/examples/tutorials/ui-components/slideswitch/content/background.png
new file mode 100644
index 0000000000..d736815870
--- /dev/null
+++ b/examples/tutorials/ui-components/slideswitch/content/background.png
Binary files differ
diff --git a/examples/tutorials/ui-components/slideswitch/content/background.svg b/examples/tutorials/ui-components/slideswitch/content/background.svg
new file mode 100644
index 0000000000..f920d3e47a
--- /dev/null
+++ b/examples/tutorials/ui-components/slideswitch/content/background.svg
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]>
+<svg version="1.1"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+ x="0px" y="0px" width="130px" height="56px" viewBox="0 0 130 56" enable-background="new 0 0 130 56" xml:space="preserve">
+<defs>
+</defs>
+<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-37.5005" y1="-66" x2="-37.5005" y2="-121.9985" gradientTransform="matrix(1 0 0 -1 102.5 -66)">
+ <stop offset="0.0056" style="stop-color:#000000"/>
+ <stop offset="1" style="stop-color:#EAECEF"/>
+</linearGradient>
+<path fill="url(#SVGID_1_)" d="M101.998,55.998H28c-15.439,0-28-12.562-28-28C0,12.56,12.561,0,28,0h73.998
+ c15.439,0,28,12.559,28,27.998C129.998,43.438,117.438,55.998,101.998,55.998L101.998,55.998z"/>
+<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="-5.5" y1="-132.1338" x2="-69.5002" y2="-55.8613" gradientTransform="matrix(1 0 0 -1 102.5 -66)">
+ <stop offset="0.0056" style="stop-color:#000000"/>
+ <stop offset="1" style="stop-color:#828385"/>
+</linearGradient>
+<path fill="url(#SVGID_2_)" d="M127.999,27.998c0,14.359-11.642,26-26,26h-74c-14.359,0-26-11.641-26-26l0,0
+ c0-14.359,11.641-26,26-26h74C116.357,1.998,127.999,13.639,127.999,27.998L127.999,27.998z"/>
+</svg>
diff --git a/examples/tutorials/ui-components/slideswitch/content/knob.png b/examples/tutorials/ui-components/slideswitch/content/knob.png
new file mode 100644
index 0000000000..ee0a436f84
--- /dev/null
+++ b/examples/tutorials/ui-components/slideswitch/content/knob.png
Binary files differ
diff --git a/examples/tutorials/ui-components/slideswitch/content/knob.svg b/examples/tutorials/ui-components/slideswitch/content/knob.svg
new file mode 100644
index 0000000000..fb6933718e
--- /dev/null
+++ b/examples/tutorials/ui-components/slideswitch/content/knob.svg
@@ -0,0 +1,867 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ x="0px"
+ y="0px"
+ width="52px"
+ height="52px"
+ viewBox="0 0 52 52"
+ enable-background="new 0 0 52 52"
+ xml:space="preserve"
+ id="svg3883"
+ sodipodi:version="0.32"
+ inkscape:version="0.44.1"
+ sodipodi:docname="knob_on.svg"
+ sodipodi:docbase="/local/axel/embeddedwidgets/embeddedstories/skins/svgslideswitch/MetallicBrush"><metadata
+ id="metadata4200"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+ inkscape:window-height="640"
+ inkscape:window-width="937"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="8.3653846"
+ inkscape:cx="26.000002"
+ inkscape:cy="26"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:current-layer="svg3883" />
+<defs
+ id="defs3885">
+</defs>
+<linearGradient
+ id="SVGID_1_"
+ gradientUnits="userSpaceOnUse"
+ x1="-59.7866"
+ y1="-115.917"
+ x2="-93.2123"
+ y2="-76.0818"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#000000"
+ id="stop3888" />
+ <stop
+ offset="1"
+ style="stop-color:#EAECEF"
+ id="stop3890" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="26"
+ id="circle3892"
+ style="fill:url(#SVGID_1_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="26"
+ sodipodi:ry="26"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="-100.5"
+ y1="-96"
+ x2="-52.5"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3895" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3897" />
+ <stop
+ offset="0.6043"
+ style="stop-color:#E7EAED"
+ id="stop3899" />
+ <stop
+ offset="0.6751"
+ style="stop-color:#DEE4E7"
+ id="stop3901" />
+ <stop
+ offset="0.7358"
+ style="stop-color:#CFD9DD"
+ id="stop3903" />
+ <stop
+ offset="0.791"
+ style="stop-color:#B9CACF"
+ id="stop3905" />
+ <stop
+ offset="0.8425"
+ style="stop-color:#9EB6BD"
+ id="stop3907" />
+ <stop
+ offset="0.891"
+ style="stop-color:#7B9EA7"
+ id="stop3909" />
+ <stop
+ offset="0.9374"
+ style="stop-color:#53828C"
+ id="stop3911" />
+ <stop
+ offset="0.9809"
+ style="stop-color:#25626E"
+ id="stop3913" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3915" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="24"
+ id="circle3917"
+ style="fill:url(#SVGID_2_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="24"
+ sodipodi:ry="24"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_3_"
+ gradientUnits="userSpaceOnUse"
+ x1="-98.6328"
+ y1="-96"
+ x2="-54.3672"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3920" />
+ <stop
+ offset="0.073"
+ style="stop-color:#8FAECB"
+ id="stop3922" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3924" />
+ <stop
+ offset="0.5902"
+ style="stop-color:#E7E9ED"
+ id="stop3926" />
+ <stop
+ offset="0.618"
+ style="stop-color:#E4E7EB"
+ id="stop3928" />
+ <stop
+ offset="0.6697"
+ style="stop-color:#E0E4E9"
+ id="stop3930" />
+ <stop
+ offset="0.7211"
+ style="stop-color:#D4DCE1"
+ id="stop3932" />
+ <stop
+ offset="0.7722"
+ style="stop-color:#C0CFD5"
+ id="stop3934" />
+ <stop
+ offset="0.809"
+ style="stop-color:#ADC2C9"
+ id="stop3936" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3938" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="22.132999"
+ id="circle3940"
+ style="fill:url(#SVGID_3_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="22.132999"
+ sodipodi:ry="22.132999"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_4_"
+ gradientUnits="userSpaceOnUse"
+ x1="-96.7671"
+ y1="-96"
+ x2="-56.2324"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3943" />
+ <stop
+ offset="0.073"
+ style="stop-color:#86A7C4"
+ id="stop3945" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3947" />
+ <stop
+ offset="0.577"
+ style="stop-color:#E7EAED"
+ id="stop3949" />
+ <stop
+ offset="0.618"
+ style="stop-color:#E1E6EA"
+ id="stop3951" />
+ <stop
+ offset="0.6697"
+ style="stop-color:#DDE3E8"
+ id="stop3953" />
+ <stop
+ offset="0.7211"
+ style="stop-color:#D1DBE1"
+ id="stop3955" />
+ <stop
+ offset="0.7722"
+ style="stop-color:#BDCDD5"
+ id="stop3957" />
+ <stop
+ offset="0.809"
+ style="stop-color:#AAC0CA"
+ id="stop3959" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3961" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="20.267"
+ id="circle3963"
+ style="fill:url(#SVGID_4_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="20.267"
+ sodipodi:ry="20.267"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_5_"
+ gradientUnits="userSpaceOnUse"
+ x1="-94.8999"
+ y1="-96"
+ x2="-58.0996"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3966" />
+ <stop
+ offset="0.073"
+ style="stop-color:#7E9FBC"
+ id="stop3968" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3970" />
+ <stop
+ offset="0.5709"
+ style="stop-color:#E6E9ED"
+ id="stop3972" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DFE4E9"
+ id="stop3974" />
+ <stop
+ offset="0.6687"
+ style="stop-color:#DBE1E7"
+ id="stop3976" />
+ <stop
+ offset="0.7193"
+ style="stop-color:#CFD9E0"
+ id="stop3978" />
+ <stop
+ offset="0.7695"
+ style="stop-color:#BBCCD6"
+ id="stop3980" />
+ <stop
+ offset="0.809"
+ style="stop-color:#A6BECA"
+ id="stop3982" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3984" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="18.4"
+ id="circle3986"
+ style="fill:url(#SVGID_5_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="18.4"
+ sodipodi:ry="18.4"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_6_"
+ gradientUnits="userSpaceOnUse"
+ x1="-93.0332"
+ y1="-96"
+ x2="-59.9668"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3989" />
+ <stop
+ offset="0.073"
+ style="stop-color:#7697B4"
+ id="stop3991" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3993" />
+ <stop
+ offset="0.5636"
+ style="stop-color:#E6E9ED"
+ id="stop3995" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DCE2E8"
+ id="stop3997" />
+ <stop
+ offset="0.6687"
+ style="stop-color:#D8DFE6"
+ id="stop3999" />
+ <stop
+ offset="0.7193"
+ style="stop-color:#CCD7E0"
+ id="stop4001" />
+ <stop
+ offset="0.7695"
+ style="stop-color:#B8CAD5"
+ id="stop4003" />
+ <stop
+ offset="0.809"
+ style="stop-color:#A3BCCA"
+ id="stop4005" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4007" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="16.533001"
+ id="circle4009"
+ style="fill:url(#SVGID_6_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="16.533001"
+ sodipodi:ry="16.533001"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_7_"
+ gradientUnits="userSpaceOnUse"
+ x1="-91.167"
+ y1="-96"
+ x2="-61.833"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4012" />
+ <stop
+ offset="0.073"
+ style="stop-color:#6D8FAD"
+ id="stop4014" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4016" />
+ <stop
+ offset="0.5605"
+ style="stop-color:#E5E8EC"
+ id="stop4018" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DAE1E7"
+ id="stop4020" />
+ <stop
+ offset="0.6679"
+ style="stop-color:#D6DEE5"
+ id="stop4022" />
+ <stop
+ offset="0.7175"
+ style="stop-color:#CAD6DF"
+ id="stop4024" />
+ <stop
+ offset="0.7669"
+ style="stop-color:#B6C9D6"
+ id="stop4026" />
+ <stop
+ offset="0.809"
+ style="stop-color:#9FBACB"
+ id="stop4028" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4030" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="14.667"
+ id="circle4032"
+ style="fill:url(#SVGID_7_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="14.667"
+ sodipodi:ry="14.667"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_8_"
+ gradientUnits="userSpaceOnUse"
+ x1="-89.2998"
+ y1="-96"
+ x2="-63.7002"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4035" />
+ <stop
+ offset="0.073"
+ style="stop-color:#6587A5"
+ id="stop4037" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4039" />
+ <stop
+ offset="0.5588"
+ style="stop-color:#E4E8EC"
+ id="stop4041" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D8DFE7"
+ id="stop4043" />
+ <stop
+ offset="0.6675"
+ style="stop-color:#D4DCE5"
+ id="stop4045" />
+ <stop
+ offset="0.7167"
+ style="stop-color:#C8D5E0"
+ id="stop4047" />
+ <stop
+ offset="0.7657"
+ style="stop-color:#B4C8D6"
+ id="stop4049" />
+ <stop
+ offset="0.809"
+ style="stop-color:#9CB8CB"
+ id="stop4051" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4053" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="12.8"
+ id="circle4055"
+ style="fill:url(#SVGID_8_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="12.8"
+ sodipodi:ry="12.8"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_9_"
+ gradientUnits="userSpaceOnUse"
+ x1="-87.4331"
+ y1="-96"
+ x2="-65.5664"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4058" />
+ <stop
+ offset="0.073"
+ style="stop-color:#5D809D"
+ id="stop4060" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4062" />
+ <stop
+ offset="0.5567"
+ style="stop-color:#E3E7EC"
+ id="stop4064" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D5DDE6"
+ id="stop4066" />
+ <stop
+ offset="0.6671"
+ style="stop-color:#D1DAE4"
+ id="stop4068" />
+ <stop
+ offset="0.7159"
+ style="stop-color:#C5D3DF"
+ id="stop4070" />
+ <stop
+ offset="0.7645"
+ style="stop-color:#B1C6D6"
+ id="stop4072" />
+ <stop
+ offset="0.809"
+ style="stop-color:#98B5CB"
+ id="stop4074" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4076" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="10.933"
+ id="circle4078"
+ style="fill:url(#SVGID_9_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="10.933"
+ sodipodi:ry="10.933"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_10_"
+ gradientUnits="userSpaceOnUse"
+ x1="-85.5659"
+ y1="-96"
+ x2="-67.4336"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4081" />
+ <stop
+ offset="0.073"
+ style="stop-color:#547896"
+ id="stop4083" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4085" />
+ <stop
+ offset="0.5588"
+ style="stop-color:#E1E6EB"
+ id="stop4087" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D3DCE5"
+ id="stop4089" />
+ <stop
+ offset="0.6663"
+ style="stop-color:#CFD9E3"
+ id="stop4091" />
+ <stop
+ offset="0.7143"
+ style="stop-color:#C3D2DF"
+ id="stop4093" />
+ <stop
+ offset="0.7621"
+ style="stop-color:#AFC5D7"
+ id="stop4095" />
+ <stop
+ offset="0.809"
+ style="stop-color:#94B3CC"
+ id="stop4097" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4099" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="9.066"
+ id="circle4101"
+ style="fill:url(#SVGID_10_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="9.066"
+ sodipodi:ry="9.066"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_11_"
+ gradientUnits="userSpaceOnUse"
+ x1="-83.7002"
+ y1="-96"
+ x2="-69.2998"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4104" />
+ <stop
+ offset="0.073"
+ style="stop-color:#4C708E"
+ id="stop4106" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4108" />
+ <stop
+ offset="0.5625"
+ style="stop-color:#DEE4EA"
+ id="stop4110" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D0DAE4"
+ id="stop4112" />
+ <stop
+ offset="0.6663"
+ style="stop-color:#CCD7E2"
+ id="stop4114" />
+ <stop
+ offset="0.7143"
+ style="stop-color:#C0D0DE"
+ id="stop4116" />
+ <stop
+ offset="0.7621"
+ style="stop-color:#ACC3D6"
+ id="stop4118" />
+ <stop
+ offset="0.809"
+ style="stop-color:#91B1CC"
+ id="stop4120" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4122" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="7.1999998"
+ id="circle4124"
+ style="fill:url(#SVGID_11_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="7.1999998"
+ sodipodi:ry="7.1999998"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_12_"
+ gradientUnits="userSpaceOnUse"
+ x1="-81.833"
+ y1="-96"
+ x2="-71.167"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4127" />
+ <stop
+ offset="0.073"
+ style="stop-color:#446986"
+ id="stop4129" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4131" />
+ <stop
+ offset="0.5757"
+ style="stop-color:#D9E0E8"
+ id="stop4133" />
+ <stop
+ offset="0.618"
+ style="stop-color:#CED8E3"
+ id="stop4135" />
+ <stop
+ offset="0.6655"
+ style="stop-color:#CAD5E2"
+ id="stop4137" />
+ <stop
+ offset="0.7129"
+ style="stop-color:#BECEDD"
+ id="stop4139" />
+ <stop
+ offset="0.7601"
+ style="stop-color:#AAC1D6"
+ id="stop4141" />
+ <stop
+ offset="0.807"
+ style="stop-color:#8EB0CC"
+ id="stop4143" />
+ <stop
+ offset="0.809"
+ style="stop-color:#8DAFCC"
+ id="stop4145" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4147" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="5.3330002"
+ id="circle4149"
+ style="fill:url(#SVGID_12_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="5.3330002"
+ sodipodi:ry="5.3330002"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_13_"
+ gradientUnits="userSpaceOnUse"
+ x1="-79.9658"
+ y1="-96"
+ x2="-73.0342"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4152" />
+ <stop
+ offset="0.073"
+ style="stop-color:#3B617F"
+ id="stop4154" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4156" />
+ <stop
+ offset="0.6087"
+ style="stop-color:#CED9E3"
+ id="stop4158" />
+ <stop
+ offset="0.618"
+ style="stop-color:#CBD7E2"
+ id="stop4160" />
+ <stop
+ offset="0.6655"
+ style="stop-color:#C7D4E1"
+ id="stop4162" />
+ <stop
+ offset="0.7129"
+ style="stop-color:#BBCDDD"
+ id="stop4164" />
+ <stop
+ offset="0.7601"
+ style="stop-color:#A7C0D6"
+ id="stop4166" />
+ <stop
+ offset="0.807"
+ style="stop-color:#8BAECD"
+ id="stop4168" />
+ <stop
+ offset="0.809"
+ style="stop-color:#8AADCD"
+ id="stop4170" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4172" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="3.4660001"
+ id="circle4174"
+ style="fill:url(#SVGID_13_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="3.4660001"
+ sodipodi:ry="3.4660001"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_14_"
+ gradientUnits="userSpaceOnUse"
+ x1="-78.1001"
+ y1="-96"
+ x2="-74.9004"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4177" />
+ <stop
+ offset="0.073"
+ style="stop-color:#335977"
+ id="stop4179" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4181" />
+ <stop
+ offset="0.618"
+ style="stop-color:#C9D5E1"
+ id="stop4183" />
+ <stop
+ offset="0.6648"
+ style="stop-color:#C5D3E0"
+ id="stop4185" />
+ <stop
+ offset="0.7114"
+ style="stop-color:#B9CBDC"
+ id="stop4187" />
+ <stop
+ offset="0.758"
+ style="stop-color:#A5BFD6"
+ id="stop4189" />
+ <stop
+ offset="0.8042"
+ style="stop-color:#89ADCE"
+ id="stop4191" />
+ <stop
+ offset="0.809"
+ style="stop-color:#86ABCD"
+ id="stop4193" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4195" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="1.6"
+ id="circle4197"
+ style="fill:url(#SVGID_14_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="1.6"
+ sodipodi:ry="1.6"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+</svg> \ No newline at end of file
diff --git a/examples/tutorials/ui-components/slideswitch/slideswitch.qml b/examples/tutorials/ui-components/slideswitch/slideswitch.qml
new file mode 100644
index 0000000000..60a331407c
--- /dev/null
+++ b/examples/tutorials/ui-components/slideswitch/slideswitch.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ color: "white"
+ width: 400; height: 250
+
+//![0]
+ Switch { anchors.centerIn: parent; on: false }
+//![0]
+}
diff --git a/examples/tutorials/ui-components/spinner/content/Spinner.qml b/examples/tutorials/ui-components/spinner/content/Spinner.qml
new file mode 100644
index 0000000000..d7bbeb33ee
--- /dev/null
+++ b/examples/tutorials/ui-components/spinner/content/Spinner.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ property alias model: view.model
+ property alias delegate: view.delegate
+ property alias currentIndex: view.currentIndex
+ property real itemHeight: 30
+
+ source: "spinner-bg.png"
+ clip: true
+
+ PathView {
+ id: view
+ anchors.fill: parent
+
+ pathItemCount: height/itemHeight
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 }
+ dragMargin: view.width/2
+
+ path: Path {
+ startX: view.width/2; startY: -itemHeight/2
+ PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight }
+ }
+ }
+
+ Keys.onDownPressed: view.incrementCurrentIndex()
+ Keys.onUpPressed: view.decrementCurrentIndex()
+}
diff --git a/examples/tutorials/ui-components/spinner/content/spinner-bg.png b/examples/tutorials/ui-components/spinner/content/spinner-bg.png
new file mode 100644
index 0000000000..b3556f1f9f
--- /dev/null
+++ b/examples/tutorials/ui-components/spinner/content/spinner-bg.png
Binary files differ
diff --git a/examples/tutorials/ui-components/spinner/content/spinner-select.png b/examples/tutorials/ui-components/spinner/content/spinner-select.png
new file mode 100644
index 0000000000..95a17a1fe2
--- /dev/null
+++ b/examples/tutorials/ui-components/spinner/content/spinner-select.png
Binary files differ
diff --git a/examples/tutorials/ui-components/spinner/main.qml b/examples/tutorials/ui-components/spinner/main.qml
new file mode 100644
index 0000000000..7584c98396
--- /dev/null
+++ b/examples/tutorials/ui-components/spinner/main.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ width: 240; height: 320
+
+ Column {
+ y: 20; x: 20; spacing: 20
+
+ Spinner {
+ id: spinner
+ width: 200; height: 240
+ focus: true
+ model: 20
+ itemHeight: 30
+ delegate: Text { font.pixelSize: 25; text: index; height: 30 }
+ }
+
+ Text { text: "Current item index: " + spinner.currentIndex }
+ }
+}
diff --git a/examples/tutorials/ui-components/spinner/spinner.qmlproject b/examples/tutorials/ui-components/spinner/spinner.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/tutorials/ui-components/spinner/spinner.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tutorials/ui-components/tabwidget/TabWidget.qml b/examples/tutorials/ui-components/tabwidget/TabWidget.qml
new file mode 100644
index 0000000000..560ed1f58a
--- /dev/null
+++ b/examples/tutorials/ui-components/tabwidget/TabWidget.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: tabWidget
+
+ // Setting the default property to stack.children means any child items
+ // of the TabWidget are actually added to the 'stack' item's children.
+ // See the "Property Binding"
+ // documentation for details on default properties.
+ default property alias content: stack.children
+
+ property int current: 0
+
+ onCurrentChanged: setOpacities()
+ Component.onCompleted: setOpacities()
+
+ function setOpacities() {
+ for (var i = 0; i < stack.children.length; ++i) {
+ stack.children[i].opacity = (i == current ? 1 : 0)
+ }
+ }
+
+ Row {
+ id: header
+
+ Repeater {
+ model: stack.children.length
+ delegate: Rectangle {
+ width: tabWidget.width / stack.children.length; height: 36
+
+ Rectangle {
+ width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ color: "#acb2c2"
+ }
+ BorderImage {
+ anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
+ border { left: 7; right: 7 }
+ source: "tab.png"
+ visible: tabWidget.current == index
+ }
+ Text {
+ horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent
+ text: stack.children[index].title
+ elide: Text.ElideRight
+ font.bold: tabWidget.current == index
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: tabWidget.current = index
+ }
+ }
+ }
+ }
+
+ Item {
+ id: stack
+ width: tabWidget.width
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom
+ }
+}
diff --git a/examples/tutorials/ui-components/tabwidget/main.qml b/examples/tutorials/ui-components/tabwidget/main.qml
new file mode 100644
index 0000000000..df99c11b7d
--- /dev/null
+++ b/examples/tutorials/ui-components/tabwidget/main.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TabWidget {
+ id: tabs
+ width: 640; height: 480
+
+ Rectangle {
+ property string title: "Red"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#ff7f7f"
+ Text {
+ width: parent.width - 20
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Roses are red"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+
+ Rectangle {
+ property string title: "Green"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#7fff7f"
+ Text {
+ width: parent.width - 20
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Flower stems are green"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+
+ Rectangle {
+ property string title: "Blue"
+ anchors.fill: parent; color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#7f7fff"
+ Text {
+ width: parent.width - 20
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Violets are blue"
+ font.pixelSize: 20
+ wrapMode: Text.WordWrap
+ }
+ }
+ }
+}
diff --git a/examples/tutorials/ui-components/tabwidget/tab.png b/examples/tutorials/ui-components/tabwidget/tab.png
new file mode 100644
index 0000000000..ad8021605f
--- /dev/null
+++ b/examples/tutorials/ui-components/tabwidget/tab.png
Binary files differ
diff --git a/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject b/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject
new file mode 100644
index 0000000000..e5a8bf02ca
--- /dev/null
+++ b/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/window/Window.qml b/examples/window/Window.qml
new file mode 100644
index 0000000000..48478458c6
--- /dev/null
+++ b/examples/window/Window.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0 as Window
+
+Window.Window {
+ width: 640
+ height: 480
+ visible: true //It's false by default
+ property Component self
+ Component.onCompleted: self = Qt.createComponent("Window.qml")
+ Text{
+ text: "Hello World!"
+ anchors.centerIn: parent
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: self.createObject();
+ }
+}
diff --git a/examples/window/screen/screenInfo.qml b/examples/window/screen/screenInfo.qml
new file mode 100644
index 0000000000..54299ba4e0
--- /dev/null
+++ b/examples/window/screen/screenInfo.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0 as Window
+
+Item {
+ id: root
+ width: 400
+ height: 200
+ Item {
+ id: main
+ state: "orientation " + Window.Screen.orientation
+
+ property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation
+ property real baseWidth: landscapeWindow ? root.height : root.width
+ property real baseHeight: landscapeWindow ? root.width : root.height
+ property real rotationDelta: landscapeWindow ? -90 : 0
+
+ rotation: rotationDelta
+ width: main.baseWidth
+ height: main.baseHeight
+ anchors.centerIn: parent
+
+ Text {
+ text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation
+ anchors.centerIn:parent
+ }
+
+
+ states: [
+ State {
+ name: "orientation " + Qt.LandscapeOrientation
+ PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ },
+ State {
+ name: "orientation " + Qt.InvertedPortraitOrientation
+ PropertyChanges { target: main; rotation: 180 + rotationDelta; }
+ },
+ State {
+ name: "orientation " + Qt.InvertedLandscapeOrientation
+ PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth }
+ }
+ ]
+
+ transitions: Transition {
+ SequentialAnimation {
+ RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint }
+ NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint }
+ }
+ }
+ }
+}
diff --git a/examples/window/standalone.qml b/examples/window/standalone.qml
new file mode 100644
index 0000000000..335cf7b635
--- /dev/null
+++ b/examples/window/standalone.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0 as Window
+
+Item {
+ width: 640
+ height: 480
+ Text {
+ anchors.centerIn: parent
+ text: "First Window"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ Window.Window {
+ width: 640
+ height: 480
+ x: 640
+ y: 480
+ visible: true
+ color: "green"
+ Text {
+ anchors.centerIn: parent
+ text: "Second Window"
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+}
diff --git a/examples/window/window.cpp b/examples/window/window.cpp
new file mode 100644
index 0000000000..2112ab8f45
--- /dev/null
+++ b/examples/window/window.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
+#include <QtCore/QUrl>
+#include <QDebug>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(QUrl::fromLocalFile("Window.qml"));
+ if ( component.isReady() )
+ component.create();
+ else
+ qWarning() << component.errorString();
+ return app.exec();
+}
diff --git a/examples/window/window.pro b/examples/window/window.pro
new file mode 100644
index 0000000000..c4518418f6
--- /dev/null
+++ b/examples/window/window.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+CONFIG += qt
+QT += qml
+
+SOURCES += window.cpp
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp
new file mode 100644
index 0000000000..3c4d60bb89
--- /dev/null
+++ b/src/imports/folderlistmodel/fileinfothread.cpp
@@ -0,0 +1,280 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "fileinfothread_p.h"
+#include <qdiriterator.h>
+
+#include <QDebug>
+
+
+FileInfoThread::FileInfoThread(QObject *parent)
+ : QThread(parent),
+ abort(false),
+ watcher(0),
+ sortFlags(QDir::Name),
+ needUpdate(true),
+ folderUpdate(false),
+ sortUpdate(false),
+ showDirs(true),
+ showDirsFirst(false),
+ showDotDot(false),
+ showOnlyReadable(false)
+{
+ watcher = new QFileSystemWatcher(this);
+ connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
+ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
+ start(LowPriority);
+}
+
+FileInfoThread::~FileInfoThread()
+{
+ QMutexLocker locker(&mutex);
+ abort = true;
+ condition.wakeOne();
+ locker.unlock();
+ wait();
+}
+
+void FileInfoThread::clear()
+{
+ QMutexLocker locker(&mutex);
+ watcher->removePaths(watcher->files());
+ watcher->removePaths(watcher->directories());
+}
+
+void FileInfoThread::removePath(const QString &path)
+{
+ QMutexLocker locker(&mutex);
+ watcher->removePath(path);
+ currentPath.clear();
+}
+
+void FileInfoThread::setPath(const QString &path)
+{
+ Q_ASSERT(!path.isEmpty());
+
+ QMutexLocker locker(&mutex);
+ watcher->addPath(path);
+ currentPath = path;
+ needUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setRootPath(const QString &path)
+{
+ Q_ASSERT(!path.isEmpty());
+
+ QMutexLocker locker(&mutex);
+ rootPath = path;
+}
+
+void FileInfoThread::dirChanged(const QString &directoryPath)
+{
+ Q_UNUSED(directoryPath);
+ QMutexLocker locker(&mutex);
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setSortFlags(QDir::SortFlags flags)
+{
+ QMutexLocker locker(&mutex);
+ sortFlags = flags;
+ sortUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setNameFilters(const QStringList & filters)
+{
+ QMutexLocker locker(&mutex);
+ nameFilters = filters;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setShowDirs(bool showFolders)
+{
+ QMutexLocker locker(&mutex);
+ showDirs = showFolders;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setShowDirsFirst(bool showDirsFirst)
+{
+ QMutexLocker locker(&mutex);
+ showDirsFirst = showDirsFirst;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setShowDotDot(bool on)
+{
+ QMutexLocker locker(&mutex);
+ showDotDot = on;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::setShowOnlyReadable(bool on)
+{
+ QMutexLocker locker(&mutex);
+ showOnlyReadable = on;
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::updateFile(const QString &path)
+{
+ Q_UNUSED(path);
+ QMutexLocker locker(&mutex);
+ folderUpdate = true;
+ condition.wakeAll();
+}
+
+void FileInfoThread::run()
+{
+ forever {
+ bool updateFiles = false;
+ QMutexLocker locker(&mutex);
+ if (abort) {
+ return;
+ }
+ if (currentPath.isEmpty() || !needUpdate)
+ condition.wait(&mutex);
+
+ if (abort) {
+ return;
+ }
+
+ if (!currentPath.isEmpty()) {
+ updateFiles = true;
+ }
+ if (updateFiles)
+ getFileInfos(currentPath);
+ locker.unlock();
+ }
+}
+
+
+void FileInfoThread::getFileInfos(const QString &path)
+{
+ QDir::Filters filter;
+ filter = QDir::Files | QDir::NoDot | QDir::CaseSensitive;
+ if (showDirs)
+ filter = filter | QDir::AllDirs | QDir::Drives;
+ if ((path == rootPath) || !showDotDot)
+ filter = filter | QDir::NoDotDot;
+ if (showOnlyReadable)
+ filter = filter | QDir::Readable;
+ if (showDirsFirst)
+ sortFlags = sortFlags | QDir::DirsFirst;
+
+ QDir currentDir(path, QString(), sortFlags);
+ QFileInfoList fileInfoList;
+ QList<FileProperty> filePropertyList;
+
+ fileInfoList = currentDir.entryInfoList(nameFilters, filter, sortFlags);
+
+ if (!fileInfoList.isEmpty()) {
+ foreach (QFileInfo info, fileInfoList) {
+ //qDebug() << "Adding file : " << info.fileName() << "to list ";
+ filePropertyList << FileProperty(info);
+ }
+ if (folderUpdate) {
+ int fromIndex = 0;
+ int toIndex = currentFileList.size()-1;
+ findChangeRange(filePropertyList, fromIndex, toIndex);
+ folderUpdate = false;
+ currentFileList = filePropertyList;
+ //qDebug() << "emit directoryUpdated : " << fromIndex << " " << toIndex;
+ emit directoryUpdated(path, filePropertyList, fromIndex, toIndex);
+ } else {
+ currentFileList = filePropertyList;
+ if (sortUpdate) {
+ emit sortFinished(filePropertyList);
+ sortUpdate = false;
+ } else
+ emit directoryChanged(path, filePropertyList);
+ }
+ } else {
+ // The directory is empty
+ if (folderUpdate) {
+ int fromIndex = 0;
+ int toIndex = currentFileList.size()-1;
+ folderUpdate = false;
+ currentFileList.clear();
+ emit directoryUpdated(path, filePropertyList, fromIndex, toIndex);
+ } else {
+ currentFileList.clear();
+ emit directoryChanged(path, filePropertyList);
+ }
+ }
+ needUpdate = false;
+}
+
+void FileInfoThread::findChangeRange(const QList<FileProperty> &list, int &fromIndex, int &toIndex)
+{
+ if (currentFileList.size() == 0) {
+ fromIndex = 0;
+ toIndex = list.size();
+ return;
+ }
+
+ int i;
+ int listSize = list.size() < currentFileList.size() ? list.size() : currentFileList.size();
+ bool changeFound = false;
+
+ for (i=0; i < listSize; i++) {
+ if (list.at(i) != currentFileList.at(i)) {
+ changeFound = true;
+ break;
+ }
+ }
+
+ if (changeFound)
+ fromIndex = i;
+ else
+ fromIndex = i-1;
+
+ // For now I let the rest of the list be updated..
+ toIndex = list.size() > currentFileList.size() ? list.size() - 1 : currentFileList.size() - 1;
+}
diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h
new file mode 100644
index 0000000000..a5be6e6fcc
--- /dev/null
+++ b/src/imports/folderlistmodel/fileinfothread_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILEINFOTHREAD_P_H
+#define FILEINFOTHREAD_P_H
+
+#include <QThread>
+#include <QMutex>
+#include <QWaitCondition>
+#include <QFileSystemWatcher>
+#include <QFileInfo>
+#include <QDir>
+
+#include "fileproperty_p.h"
+
+class FileInfoThread : public QThread
+{
+ Q_OBJECT
+
+Q_SIGNALS:
+ void directoryChanged(const QString &directory, const QList<FileProperty> &list) const;
+ void directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex) const;
+ void sortFinished(const QList<FileProperty> &list) const;
+
+public:
+ FileInfoThread(QObject *parent = 0);
+ ~FileInfoThread();
+
+ void clear();
+ void removePath(const QString &path);
+ void setPath(const QString &path);
+ void setRootPath(const QString &path);
+ void setSortFlags(QDir::SortFlags flags);
+ void setNameFilters(const QStringList & nameFilters);
+ void setShowDirs(bool showFolders);
+ void setShowDirsFirst(bool showDirsFirst);
+ void setShowDotDot(bool on);
+ void setShowOnlyReadable(bool on);
+
+public Q_SLOTS:
+ void dirChanged(const QString &directoryPath);
+ void updateFile(const QString &path);
+
+protected:
+ void run();
+ void getFileInfos(const QString &path);
+ void findChangeRange(const QList<FileProperty> &list, int &fromIndex, int &toIndex);
+
+private:
+ QMutex mutex;
+ QWaitCondition condition;
+ volatile bool abort;
+
+ QFileSystemWatcher *watcher;
+ QList<FileProperty> currentFileList;
+ QDir::SortFlags sortFlags;
+ QString currentPath;
+ QString rootPath;
+ QStringList nameFilters;
+ bool needUpdate;
+ bool folderUpdate;
+ bool sortUpdate;
+ bool showDirs;
+ bool showDirsFirst;
+ bool showDotDot;
+ bool showOnlyReadable;
+};
+
+#endif // FILEINFOTHREAD_P_H
diff --git a/src/imports/folderlistmodel/fileproperty_p.h b/src/imports/folderlistmodel/fileproperty_p.h
new file mode 100644
index 0000000000..690581a9a3
--- /dev/null
+++ b/src/imports/folderlistmodel/fileproperty_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILEPROPERTY_P_H
+#define FILEPROPERTY_P_H
+
+#include <QFileInfo>
+#include <QDateTime>
+
+class FileProperty
+{
+public:
+ FileProperty(const QFileInfo &info)
+ {
+ mFileName = info.fileName();
+ mFilePath = info.filePath();
+ mBaseName = info.baseName();
+ mSize = info.size();
+ mSuffix = info.completeSuffix();
+ mIsDir = info.isDir();
+ mIsFile = info.isFile();
+ mLastModified = info.lastModified();
+ mLastRead = info.lastRead();
+ }
+ ~FileProperty()
+ {}
+
+ inline QString fileName() const { return mFileName; }
+ inline QString filePath() const { return mFilePath; }
+ inline QString baseName() const { return mBaseName; }
+ inline qint64 size() const { return mSize; }
+ inline QString suffix() const { return mSuffix; }
+ inline bool isDir() const { return mIsDir; }
+ inline bool isFile() const { return mIsFile; }
+ inline QDateTime lastModified() const { return mLastModified; }
+ inline QDateTime lastRead() const { return mLastRead; }
+
+ inline bool operator !=(const FileProperty &fileInfo) const {
+ return !operator==(fileInfo);
+ }
+ bool operator ==(const FileProperty &property) const {
+ return ((mFileName == property.mFileName) && (isDir() == property.isDir()));
+ }
+
+private:
+ QString mFileName;
+ QString mFilePath;
+ QString mBaseName;
+ QString mSuffix;
+ qint64 mSize;
+ bool mIsDir;
+ bool mIsFile;
+ QDateTime mLastModified;
+ QDateTime mLastRead;
+};
+#endif // FILEPROPERTY_P_H
diff --git a/src/imports/folderlistmodel/folderlistmodel.json b/src/imports/folderlistmodel/folderlistmodel.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/imports/folderlistmodel/folderlistmodel.json
@@ -0,0 +1 @@
+{}
diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro
index b4cfcea495..592d8375c8 100644
--- a/src/imports/folderlistmodel/folderlistmodel.pro
+++ b/src/imports/folderlistmodel/folderlistmodel.pro
@@ -2,10 +2,13 @@ TARGET = qmlfolderlistmodelplugin
TARGETPATH = Qt/labs/folderlistmodel
include(../qimportbase.pri)
-QT += widgets qml
+QT += qml
-SOURCES += qquickfolderlistmodel.cpp plugin.cpp
-HEADERS += qquickfolderlistmodel.h
+SOURCES += qquickfolderlistmodel.cpp plugin.cpp \
+ fileinfothread.cpp
+HEADERS += qquickfolderlistmodel.h \
+ fileproperty_p.h \
+ fileinfothread_p.h
DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index 78fc230fdc..bc904512a8 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
class QmlFolderListModelPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "folderlistmodel.json")
+
public:
virtual void registerTypes(const char *uri)
{
@@ -64,8 +66,3 @@ public:
QT_END_NAMESPACE
#include "plugin.moc"
-
-//![plugin export decl]
-Q_EXPORT_PLUGIN2(qmlfolderlistmodelplugin, QT_PREPEND_NAMESPACE(QmlFolderListModelPlugin));
-//![plugin export decl]
-
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 5621622cca..d68d7af6d4 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -41,25 +41,71 @@
//![code]
#include "qquickfolderlistmodel.h"
-#include <QDirModel>
+#include "fileinfothread_p.h"
+#include "fileproperty_p.h"
#include <QDebug>
#include <qqmlcontext.h>
-#ifndef QT_NO_DIRMODEL
-
QT_BEGIN_NAMESPACE
class QQuickFolderListModelPrivate
{
+ Q_DECLARE_PUBLIC(QQuickFolderListModel)
+
public:
- QQuickFolderListModelPrivate()
- : sortField(QQuickFolderListModel::Name), sortReversed(false), count(0), showDirs(true), showDots(false), showOnlyReadable(false), insideRefresh(false) {
+ QQuickFolderListModelPrivate(QQuickFolderListModel *q)
+ : q_ptr(q),
+ sortField(QQuickFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDots(false), showOnlyReadable(false)
+ {
nameFilters << QLatin1String("*");
}
- void updateSorting() {
- QDir::SortFlags flags = 0;
- switch(sortField) {
+
+ QQuickFolderListModel *q_ptr;
+ QUrl currentDir;
+ QUrl rootDir;
+ FileInfoThread fileInfoThread;
+ QList<FileProperty> data;
+ QHash<int, QByteArray> roleNames;
+ QQuickFolderListModel::SortField sortField;
+ QStringList nameFilters;
+ bool sortReversed;
+ bool showDirs;
+ bool showDirsFirst;
+ bool showDots;
+ bool showOnlyReadable;
+
+ ~QQuickFolderListModelPrivate() {}
+ void init();
+ void updateSorting();
+
+ // private slots
+ void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list);
+ void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex);
+ void _q_sortFinished(const QList<FileProperty> &list);
+};
+
+
+void QQuickFolderListModelPrivate::init()
+{
+ Q_Q(QQuickFolderListModel);
+ qRegisterMetaType<QList<FileProperty> >("QList<FileProperty>");
+ q->connect(&fileInfoThread, SIGNAL(directoryChanged(QString, QList<FileProperty>)),
+ q, SLOT(_q_directoryChanged(QString, QList<FileProperty>)));
+ q->connect(&fileInfoThread, SIGNAL(directoryUpdated(QString, QList<FileProperty>, int, int)),
+ q, SLOT(_q_directoryUpdated(QString, QList<FileProperty>, int, int)));
+ q->connect(&fileInfoThread, SIGNAL(sortFinished(QList<FileProperty>)),
+ q, SLOT(_q_sortFinished(QList<FileProperty>)));
+}
+
+
+void QQuickFolderListModelPrivate::updateSorting()
+{
+ Q_Q(QQuickFolderListModel);
+
+ QDir::SortFlags flags = 0;
+
+ switch (sortField) {
case QQuickFolderListModel::Unsorted:
flags |= QDir::Unsorted;
break;
@@ -75,26 +121,80 @@ public:
case QQuickFolderListModel::Type:
flags |= QDir::Type;
break;
- }
+ default:
+ break;
+ }
+
+ emit q->layoutAboutToBeChanged();
+
+ if (sortReversed)
+ flags |= QDir::Reversed;
+
+ fileInfoThread.setSortFlags(flags);
+}
+
+void QQuickFolderListModelPrivate::_q_directoryChanged(const QString &directory, const QList<FileProperty> &list)
+{
+ Q_Q(QQuickFolderListModel);
+ Q_UNUSED(directory);
+
+ data = list;
+ q->endResetModel();
+ emit q->rowCountChanged();
+ emit q->folderChanged();
+}
- if (sortReversed)
- flags |= QDir::Reversed;
- model.setSorting(flags);
+void QQuickFolderListModelPrivate::_q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex)
+{
+ Q_Q(QQuickFolderListModel);
+ Q_UNUSED(directory);
+
+ QModelIndex parent;
+ if (data.size() > list.size()) {
+ //File(s) removed. Since I do not know how many
+ //or where I need to update the whole list from the first item.
+ data = list;
+ q->beginRemoveRows(parent, fromIndex, toIndex);
+ q->endRemoveRows();
+ q->beginInsertRows(parent, fromIndex, list.size()-1);
+ q->endInsertRows();
+ emit q->rowCountChanged();
+ } else if (data.size() < list.size()) {
+ //qDebug() << "File added. FromIndex: " << fromIndex << " toIndex: " << toIndex << " list size: " << list.size();
+ //File(s) added. Calculate how many and insert
+ //from the first changed one.
+ toIndex = fromIndex + (list.size() - data.size()-1);
+ q->beginInsertRows(parent, fromIndex, toIndex);
+ q->endInsertRows();
+ data = list;
+ emit q->rowCountChanged();
+ QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
+ QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
+ emit q->dataChanged(modelIndexFrom, modelIndexTo);
+ } else {
+ //qDebug() << "File has been updated";
+ QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0);
+ QModelIndex modelIndexTo = q->createIndex(toIndex, 0);
+ data = list;
+ emit q->dataChanged(modelIndexFrom, modelIndexTo);
}
+}
+
+void QQuickFolderListModelPrivate::_q_sortFinished(const QList<FileProperty> &list)
+{
+ Q_Q(QQuickFolderListModel);
+
+ QModelIndex parent;
+ q->beginRemoveRows(parent, 0, data.size()-1);
+ data.clear();
+ q->endRemoveRows();
+
+ q->beginInsertRows(parent, 0, list.size()-1);
+ data = list;
+ q->endInsertRows();
+}
- QDirModel model;
- QUrl folder;
- QStringList nameFilters;
- QModelIndex folderIndex;
- QQuickFolderListModel::SortField sortField;
- bool sortReversed;
- int count;
- bool showDirs;
- bool showDots;
- bool showOnlyReadable;
- bool insideRefresh;
-};
/*!
\qmlclass FolderListModel QQuickFolderListModel
@@ -115,8 +215,14 @@ public:
Components access names and paths via the following roles:
\list
- \o fileName
- \o filePath
+ \o \c fileName
+ \o \c filePath
+ \o \c fileBaseName
+ \o \c fileSuffix
+ \o \c fileSize
+ \o \c fileModified
+ \o \c fileAccessed
+ \o \c fileIsDir
\endlist
Additionally a file entry can be differentiated from a folder entry via the
@@ -157,39 +263,62 @@ public:
*/
QQuickFolderListModel::QQuickFolderListModel(QObject *parent)
- : QAbstractListModel(parent)
+ : QAbstractListModel(parent), d_ptr(new QQuickFolderListModelPrivate(this))
{
- QHash<int, QByteArray> roles;
- roles[FileNameRole] = "fileName";
- roles[FilePathRole] = "filePath";
- setRoleNames(roles);
-
- d = new QQuickFolderListModelPrivate;
- 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(handleDataChanged(const QModelIndex&,const QModelIndex&)));
- connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh()));
- connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh()));
+ Q_D(QQuickFolderListModel);
+ d->roleNames[FileNameRole] = "fileName";
+ d->roleNames[FilePathRole] = "filePath";
+ d->roleNames[FileBaseNameRole] = "fileBaseName";
+ d->roleNames[FileSuffixRole] = "fileSuffix";
+ d->roleNames[FileSizeRole] = "fileSize";
+ d->roleNames[FileLastModifiedRole] = "fileModified";
+ d->roleNames[FileLastReadRole] = "fileAccessed";
+ d->roleNames[FileIsDirRole] = "fileIsDir";
+ setRoleNames(d->roleNames);
+
+ d->init();
}
QQuickFolderListModel::~QQuickFolderListModel()
{
- delete d;
}
QVariant QQuickFolderListModel::data(const QModelIndex &index, int role) const
{
+ Q_D(const QQuickFolderListModel);
QVariant rv;
- QModelIndex modelIndex = d->model.index(index.row(), 0, d->folderIndex);
- if (modelIndex.isValid()) {
- if (role == FileNameRole)
- rv = d->model.data(modelIndex, QDirModel::FileNameRole).toString();
- else if (role == FilePathRole)
- rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString());
+
+ if (index.row() >= d->data.size())
+ return rv;
+
+ switch (role)
+ {
+ case FileNameRole:
+ rv = d->data.at(index.row()).fileName();
+ break;
+ case FilePathRole:
+ rv = d->data.at(index.row()).filePath();
+ break;
+ case FileBaseNameRole:
+ rv = d->data.at(index.row()).baseName();
+ break;
+ case FileSuffixRole:
+ rv = d->data.at(index.row()).suffix();
+ break;
+ case FileSizeRole:
+ rv = d->data.at(index.row()).size();
+ break;
+ case FileLastModifiedRole:
+ rv = d->data.at(index.row()).lastModified().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastModified().time().toString();
+ break;
+ case FileLastReadRole:
+ rv = d->data.at(index.row()).lastRead().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastRead().time().toString();
+ break;
+ case FileIsDirRole:
+ rv = d->data.at(index.row()).isDir();
+ break;
+ default:
+ break;
}
return rv;
}
@@ -202,8 +331,14 @@ QVariant QQuickFolderListModel::data(const QModelIndex &index, int role) const
*/
int QQuickFolderListModel::rowCount(const QModelIndex &parent) const
{
+ Q_D(const QQuickFolderListModel);
Q_UNUSED(parent);
- return d->count;
+ return d->data.size();
+}
+
+QModelIndex QQuickFolderListModel::index(int row, int , const QModelIndex &) const
+{
+ return createIndex(row, 0);
}
/*!
@@ -219,46 +354,70 @@ int QQuickFolderListModel::rowCount(const QModelIndex &parent) const
*/
QUrl QQuickFolderListModel::folder() const
{
- return d->folder;
+ Q_D(const QQuickFolderListModel);
+ return d->currentDir;
}
void QQuickFolderListModel::setFolder(const QUrl &folder)
{
- if (folder == d->folder)
+ Q_D(QQuickFolderListModel);
+
+ if (folder == d->currentDir)
return;
- QModelIndex index = d->model.index(folder.toLocalFile()); // This can modify the filtering rules.
- if ((index.isValid() && d->model.isDir(index)) || folder.toLocalFile().isEmpty()) {
- d->folder = folder;
- QMetaObject::invokeMethod(this, "resetFiltering", Qt::QueuedConnection); // resetFiltering will invoke refresh().
- emit folderChanged();
+ QString resolvedPath = QDir::cleanPath(folder.path());
+
+ beginResetModel();
+
+ //Remove the old path for the file system watcher
+ if (!d->currentDir.isEmpty())
+ d->fileInfoThread.removePath(d->currentDir.path());
+
+ d->currentDir = folder;
+
+ QFileInfo info(resolvedPath);
+ if (!info.exists() || !info.isDir()) {
+ d->data.clear();
+ endResetModel();
+ emit rowCountChanged();
+ return;
}
+
+ d->fileInfoThread.setPath(resolvedPath);
+}
+
+
+/*!
+ \qmlproperty string QQuickFolderListModel::rootFolder
+
+ When the rootFolder is set, then this folder will
+ be threated as the root in the file system, so that
+ you can only travers sub folders from this rootFolder.
+*/
+QUrl QQuickFolderListModel::rootFolder() const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->rootDir;
}
-void QQuickFolderListModel::resetFiltering()
+void QQuickFolderListModel::setRootFolder(const QUrl &path)
{
- // ensure that we reset the filtering rules, because the QDirModel::index()
- // function isn't quite as const as it claims to be.
- QDir::Filters filt = d->model.filter();
+ Q_D(QQuickFolderListModel);
- if (d->showDirs)
- filt |= (QDir::AllDirs | QDir::Drives);
- else
- filt &= ~(QDir::AllDirs | QDir::Drives);
+ if (path.isEmpty())
+ return;
- if (d->showDots)
- filt &= ~QDir::NoDotAndDotDot;
- else
- filt |= QDir::NoDotAndDotDot;
+ QString resolvedPath = QDir::cleanPath(path.path());
- if (d->showOnlyReadable)
- filt |= QDir::Readable;
- else
- filt &= ~QDir::Readable;
+ QFileInfo info(resolvedPath);
+ if (!info.exists() || !info.isDir())
+ return;
- d->model.setFilter(filt); // this causes a refresh().
+ d->fileInfoThread.setRootPath(resolvedPath);
+ d->rootDir = path;
}
+
/*!
\qmlproperty url FolderListModel::parentFolder
@@ -266,7 +425,9 @@ void QQuickFolderListModel::resetFiltering()
*/
QUrl QQuickFolderListModel::parentFolder() const
{
- QString localFile = d->folder.toLocalFile();
+ Q_D(const QQuickFolderListModel);
+
+ QString localFile = d->currentDir.toLocalFile();
if (!localFile.isEmpty()) {
QDir dir(localFile);
#if defined(Q_OS_WIN)
@@ -277,10 +438,10 @@ QUrl QQuickFolderListModel::parentFolder() const
dir.cdUp();
localFile = dir.path();
} else {
- int pos = d->folder.path().lastIndexOf(QLatin1Char('/'));
+ int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/'));
if (pos == -1)
return QUrl();
- localFile = d->folder.path().left(pos);
+ localFile = d->currentDir.path().left(pos);
}
return QUrl::fromLocalFile(localFile);
}
@@ -303,13 +464,15 @@ QUrl QQuickFolderListModel::parentFolder() const
*/
QStringList QQuickFolderListModel::nameFilters() const
{
+ Q_D(const QQuickFolderListModel);
return d->nameFilters;
}
void QQuickFolderListModel::setNameFilters(const QStringList &filters)
{
+ Q_D(QQuickFolderListModel);
+ d->fileInfoThread.setNameFilters(filters);
d->nameFilters = filters;
- d->model.setNameFilters(d->nameFilters);
}
void QQuickFolderListModel::classBegin()
@@ -318,11 +481,10 @@ void QQuickFolderListModel::classBegin()
void QQuickFolderListModel::componentComplete()
{
- if (!d->folder.isValid() || d->folder.toLocalFile().isEmpty() || !QDir().exists(d->folder.toLocalFile()))
- setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
+ Q_D(QQuickFolderListModel);
- if (!d->folderIndex.isValid())
- QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
+ if (!d->currentDir.isValid() || d->currentDir.toLocalFile().isEmpty() || !QDir().exists(d->currentDir.toLocalFile()))
+ setFolder(QUrl(QLatin1String("file://")+QDir::currentPath()));
}
/*!
@@ -331,9 +493,9 @@ void QQuickFolderListModel::componentComplete()
The \a sortField property contains field to use for sorting. sortField
may be one of:
\list
- \o Unsorted - no sorting is applied. The order is system default.
+ \o Unsorted - no sorting is applied.
\o Name - sort by filename
- \o Time - sort by time modified
+ \o LastModified - sort by time modified
\o Size - sort by file size
\o Type - sort by file type (extension)
\endlist
@@ -342,17 +504,25 @@ void QQuickFolderListModel::componentComplete()
*/
QQuickFolderListModel::SortField QQuickFolderListModel::sortField() const
{
+ Q_D(const QQuickFolderListModel);
return d->sortField;
}
void QQuickFolderListModel::setSortField(SortField field)
{
+ Q_D(QQuickFolderListModel);
if (field != d->sortField) {
d->sortField = field;
d->updateSorting();
}
}
+int QQuickFolderListModel::roleFromString(const QString &roleName) const
+{
+ Q_D(const QQuickFolderListModel);
+ return d->roleNames.key(roleName.toLatin1(), -1);
+}
+
/*!
\qmlproperty bool FolderListModel::sortReversed
@@ -362,11 +532,14 @@ void QQuickFolderListModel::setSortField(SortField field)
*/
bool QQuickFolderListModel::sortReversed() const
{
+ Q_D(const QQuickFolderListModel);
return d->sortReversed;
}
void QQuickFolderListModel::setSortReversed(bool rev)
{
+ Q_D(QQuickFolderListModel);
+
if (rev != d->sortReversed) {
d->sortReversed = rev;
d->updateSorting();
@@ -382,91 +555,66 @@ void QQuickFolderListModel::setSortReversed(bool rev)
bool QQuickFolderListModel::isFolder(int index) const
{
if (index != -1) {
- QModelIndex idx = d->model.index(index, 0, d->folderIndex);
- if (idx.isValid())
- return d->model.isDir(idx);
+ QModelIndex idx = createIndex(index, 0);
+ if (idx.isValid()) {
+ QVariant var = data(idx, FileIsDirRole);
+ if (var.isValid())
+ return var.toBool();
+ }
}
return false;
}
-void QQuickFolderListModel::refresh()
-{
- if (d->insideRefresh)
- return;
- d->insideRefresh = true;
+/*!
+ \qmlproperty bool FolderListModel::showDirs
- d->folderIndex = QModelIndex();
- if (d->count) {
- emit beginRemoveRows(QModelIndex(), 0, d->count-1);
- d->count = 0;
- emit endRemoveRows();
- }
+ If true, directories are included in the model; otherwise only files
+ are included.
- d->folderIndex = d->model.index(d->folder.toLocalFile());
- int newcount = d->model.rowCount(d->folderIndex);
- if (newcount) {
- emit beginInsertRows(QModelIndex(), 0, newcount-1);
- d->count = newcount;
- emit endInsertRows();
- }
+ By default, this property is true.
- d->insideRefresh = false; // finished refreshing.
-}
+ Note that the nameFilters are not applied to directories.
-void QQuickFolderListModel::inserted(const QModelIndex &index, int start, int end)
+ \sa showDotAndDotDot
+*/
+bool QQuickFolderListModel::showDirs() const
{
- if (index == d->folderIndex) {
- emit beginInsertRows(QModelIndex(), start, end);
- d->count = d->model.rowCount(d->folderIndex);
- emit endInsertRows();
- }
+ Q_D(const QQuickFolderListModel);
+ return d->showDirs;
}
-void QQuickFolderListModel::removed(const QModelIndex &index, int start, int end)
+void QQuickFolderListModel::setShowDirs(bool on)
{
- if (index == d->folderIndex) {
- emit beginRemoveRows(QModelIndex(), start, end);
- d->count = d->model.rowCount(d->folderIndex);
- emit endRemoveRows();
- }
-}
+ Q_D(QQuickFolderListModel);
-void QQuickFolderListModel::handleDataChanged(const QModelIndex &start, const QModelIndex &end)
-{
- if (start.parent() == d->folderIndex)
- emit dataChanged(index(start.row(),0), index(end.row(),0));
+ d->fileInfoThread.setShowDirs(on);
+ d->showDirs = on;
}
/*!
- \qmlproperty bool FolderListModel::showDirs
+ \qmlproperty bool FolderListModel::showDirsFirst
- If true, directories are included in the model; otherwise only files
- are included.
+ If true, if directories are included in the model they will
+ always be shown first, then the files.
- By default, this property is true.
-
- Note that the nameFilters are not applied to directories.
+ By default, this property is false.
- \sa showDotAndDotDot
*/
-bool QQuickFolderListModel::showDirs() const
+bool QQuickFolderListModel::showDirsFirst() const
{
- return d->model.filter() & QDir::AllDirs;
+ Q_D(const QQuickFolderListModel);
+ return d->showDirsFirst;
}
-void QQuickFolderListModel::setShowDirs(bool on)
+void QQuickFolderListModel::setShowDirsFirst(bool on)
{
- if (!(d->model.filter() & QDir::AllDirs) == !on)
- return;
- if (on) {
- d->showDirs = true;
- d->model.setFilter(d->model.filter() | QDir::AllDirs | QDir::Drives);
- } else {
- d->showDirs = false;
- d->model.setFilter(d->model.filter() & ~(QDir::AllDirs | QDir::Drives));
- }
+ Q_D(QQuickFolderListModel);
+
+ d->fileInfoThread.setShowDirsFirst(on);
+ d->showDirsFirst = on;
}
+
/*!
\qmlproperty bool FolderListModel::showDotAndDotDot
@@ -479,19 +627,16 @@ void QQuickFolderListModel::setShowDirs(bool on)
*/
bool QQuickFolderListModel::showDotAndDotDot() const
{
- return !(d->model.filter() & QDir::NoDotAndDotDot);
+ Q_D(const QQuickFolderListModel);
+ return d->showDots;
}
void QQuickFolderListModel::setShowDotAndDotDot(bool on)
{
- if (!(d->model.filter() & QDir::NoDotAndDotDot) == on)
- return;
- if (on) {
- d->showDots = true;
- d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot);
- } else {
- d->showDots = false;
- d->model.setFilter(d->model.filter() | QDir::NoDotAndDotDot);
+ Q_D(QQuickFolderListModel);
+
+ if (on != d->showDots) {
+ d->fileInfoThread.setShowDotDot(on);
}
}
@@ -507,23 +652,46 @@ void QQuickFolderListModel::setShowDotAndDotDot(bool on)
*/
bool QQuickFolderListModel::showOnlyReadable() const
{
- return d->model.filter() & QDir::Readable;
+ Q_D(const QQuickFolderListModel);
+ return d->showOnlyReadable;
}
void QQuickFolderListModel::setShowOnlyReadable(bool on)
{
- if (!(d->model.filter() & QDir::Readable) == !on)
- return;
- if (on) {
- d->showOnlyReadable = true;
- d->model.setFilter(d->model.filter() | QDir::Readable);
- } else {
- d->showOnlyReadable = false;
- d->model.setFilter(d->model.filter() & ~QDir::Readable);
+ Q_D(QQuickFolderListModel);
+
+ if (on != d->showOnlyReadable) {
+ d->fileInfoThread.setShowOnlyReadable(on);
}
}
+/*!
+ \qmlmethod QVariant QQuickFolderListModel::get(int idx, const QString &property) const
+
+ Get the folder property for the given index. The following properties
+ are available.
+
+ \list
+ \o \c fileName
+ \o \c filePath
+ \o \c fileBaseName
+ \o \c fileSuffix
+ \o \c fileSize
+ \o \c fileModified
+ \o \c fileAccessed
+ \o \c fileIsDir
+ \endlist
+*/
+QVariant QQuickFolderListModel::get(int idx, const QString &property) const
+{
+ int role = roleFromString(property);
+ if (role >= 0 && idx >= 0)
+ return data(index(idx, 0), role);
+ else
+ return QVariant();
+}
+
+#include "moc_qquickfolderlistmodel.cpp"
+
//![code]
QT_END_NAMESPACE
-
-#endif // QT_NO_DIRMODEL
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
index 10af7c8075..830a30b146 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.h
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -47,8 +47,6 @@
#include <QUrl>
#include <QAbstractListModel>
-#ifndef QT_NO_DIRMODEL
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -68,14 +66,16 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus
//![class props]
Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(QUrl rootFolder READ rootFolder WRITE setRootFolder)
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 showDirsFirst READ showDirsFirst WRITE setShowDirsFirst)
Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
- Q_PROPERTY(int count READ count)
+ Q_PROPERTY(int count READ count NOTIFY rowCountChanged)
//![class props]
//![abslistmodel]
@@ -83,10 +83,20 @@ public:
QQuickFolderListModel(QObject *parent = 0);
~QQuickFolderListModel();
- enum Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2 };
-
- int rowCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
+ enum Roles {
+ FileNameRole = Qt::UserRole + 1,
+ FilePathRole = Qt::UserRole + 2,
+ FileBaseNameRole = Qt::UserRole + 3,
+ FileSuffixRole = Qt::UserRole + 4,
+ FileSizeRole = Qt::UserRole + 5,
+ FileLastModifiedRole = Qt::UserRole + 6,
+ FileLastReadRole = Qt::UserRole +7,
+ FileIsDirRole = Qt::UserRole + 8
+ };
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
//![abslistmodel]
//![count]
@@ -96,6 +106,8 @@ public:
//![prop funcs]
QUrl folder() const;
void setFolder(const QUrl &folder);
+ QUrl rootFolder() const;
+ void setRootFolder(const QUrl &path);
QUrl parentFolder() const;
@@ -111,49 +123,47 @@ public:
void setSortReversed(bool rev);
bool showDirs() const;
- void setShowDirs(bool);
+ void setShowDirs(bool showDirs);
+ bool showDirsFirst() const;
+ void setShowDirsFirst(bool showDirsFirst);
bool showDotAndDotDot() const;
- void setShowDotAndDotDot(bool);
+ void setShowDotAndDotDot(bool on);
bool showOnlyReadable() const;
- void setShowOnlyReadable(bool);
+ void setShowOnlyReadable(bool on);
//![prop funcs]
-//![isfolder]
Q_INVOKABLE bool isFolder(int index) const;
-//![isfolder]
+ Q_INVOKABLE QVariant get(int idx, const QString &property) const;
//![parserstatus]
virtual void classBegin();
virtual void componentComplete();
//![parserstatus]
+ int roleFromString(const QString &roleName) const;
+
//![notifier]
Q_SIGNALS:
void folderChanged();
+ void rowCountChanged() const;
//![notifier]
//![class end]
-private Q_SLOTS:
- void refresh();
- void resetFiltering();
- void inserted(const QModelIndex &index, int start, int end);
- void removed(const QModelIndex &index, int start, int end);
- void handleDataChanged(const QModelIndex &start, const QModelIndex &end);
+
private:
Q_DISABLE_COPY(QQuickFolderListModel)
- QQuickFolderListModelPrivate *d;
+ Q_DECLARE_PRIVATE(QQuickFolderListModel)
+ QScopedPointer<QQuickFolderListModelPrivate> d_ptr;
+
+ Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QList<FileProperty> &list))
+ Q_PRIVATE_SLOT(d_func(), void _q_directoryUpdated(const QString &directory, const QList<FileProperty> &list, int fromIndex, int toIndex))
+ Q_PRIVATE_SLOT(d_func(), void _q_sortFinished(const QList<FileProperty> &list))
};
//![class end]
QT_END_NAMESPACE
-//![qml decl]
-QML_DECLARE_TYPE(QQuickFolderListModel)
-//![qml decl]
-
QT_END_HEADER
-#endif // QT_NO_DIRMODEL
-
#endif // QQUICKFOLDERLISTMODEL_H
diff --git a/src/imports/gestures/gestures.json b/src/imports/gestures/gestures.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/imports/gestures/gestures.json
@@ -0,0 +1 @@
+{}
diff --git a/src/imports/localstorage/localstorage.json b/src/imports/localstorage/localstorage.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/imports/localstorage/localstorage.json
@@ -0,0 +1 @@
+{}
diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro
index c54bc564d9..fa1718dd68 100644
--- a/src/imports/localstorage/localstorage.pro
+++ b/src/imports/localstorage/localstorage.pro
@@ -6,10 +6,12 @@ QT += sql qml qml-private v8-private core-private
SOURCES += plugin.cpp
+OTHER_FILES += localstorage.json
+
DESTDIR = $$QT.qml.imports/$$TARGETPATH
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
qmldir.files += $$PWD/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-INSTALLS += target qmldir \ No newline at end of file
+INSTALLS += target qmldir
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 77e68877d4..7c55225ed1 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -651,6 +651,8 @@ static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
class QQmlLocalStoragePlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "localstorage.json")
+
public:
QQmlLocalStoragePlugin()
{
@@ -664,5 +666,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, QQmlLocalStoragePlugin);
diff --git a/src/imports/shaders/shaders.json b/src/imports/shaders/shaders.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/imports/shaders/shaders.json
@@ -0,0 +1 @@
+{}
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index 8ab745a7d2..6473d216c7 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -135,6 +135,8 @@ QT_BEGIN_NAMESPACE
class QTestQmlModule : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "testlib.json")
+
public:
virtual void registerTypes(const char *uri)
{
@@ -152,5 +154,3 @@ public:
QT_END_NAMESPACE
#include "main.moc"
-
-Q_EXPORT_PLUGIN2(qmltestplugin, QT_PREPEND_NAMESPACE(QTestQmlModule))
diff --git a/src/imports/testlib/testlib.json b/src/imports/testlib/testlib.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/imports/testlib/testlib.json
@@ -0,0 +1 @@
+{}
diff --git a/src/imports/testlib/testlib.pro b/src/imports/testlib/testlib.pro
index a4cb03466e..dfb23cea0c 100644
--- a/src/imports/testlib/testlib.pro
+++ b/src/imports/testlib/testlib.pro
@@ -7,7 +7,8 @@ CONFIG += qt plugin
QT += qml quick qmltest qmltest-private v8-private qml-private core-private testlib
SOURCES += main.cpp
-HEADERS +=
+
+OTHER_FILES += testlib.json
DESTDIR = $$QT.qml.imports/$$TARGETPATH
diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp
index 54a6d5e212..58253492e1 100644
--- a/src/imports/xmllistmodel/plugin.cpp
+++ b/src/imports/xmllistmodel/plugin.cpp
@@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE
class QmlXmlListModelPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "xmllistmodel.json")
+
public:
virtual void registerTypes(const char *uri)
{
@@ -61,5 +63,3 @@ public:
QT_END_NAMESPACE
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(qmlxmllistmodelplugin, QT_PREPEND_NAMESPACE(QmlXmlListModelPlugin));
diff --git a/src/imports/xmllistmodel/xmllistmodel.json b/src/imports/xmllistmodel/xmllistmodel.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/imports/xmllistmodel/xmllistmodel.json
@@ -0,0 +1 @@
+{}
diff --git a/src/plugins/accessible/quick/accessible.json b/src/plugins/accessible/quick/accessible.json
new file mode 100644
index 0000000000..845a45aa78
--- /dev/null
+++ b/src/plugins/accessible/quick/accessible.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "QQuickView", "QQuickItem" ]
+}
diff --git a/src/plugins/accessible/quick/main.cpp b/src/plugins/accessible/quick/main.cpp
index 783d4674da..6ff3d5db9e 100644
--- a/src/plugins/accessible/quick/main.cpp
+++ b/src/plugins/accessible/quick/main.cpp
@@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE
class AccessibleQuickFactory : public QAccessiblePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "accessible.json")
+
public:
AccessibleQuickFactory();
@@ -105,9 +108,8 @@ QAccessibleInterface *AccessibleQuickFactory::create(const QString &classname, Q
return 0;
}
-Q_EXPORT_STATIC_PLUGIN(AccessibleQuickFactory)
-Q_EXPORT_PLUGIN2(qtaccessiblequick, AccessibleQuickFactory)
-
QT_END_NAMESPACE
+#include "main.moc"
+
#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/quick/quick.pro b/src/plugins/accessible/quick/quick.pro
index ae6ec032da..213d2e889b 100644
--- a/src/plugins/accessible/quick/quick.pro
+++ b/src/plugins/accessible/quick/quick.pro
@@ -19,5 +19,7 @@ SOURCES += \
HEADERS += \
qaccessiblequickview.h \
qaccessiblequickitem.h
+
+OTHERFILES += accessible.json
}
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
index 014f964652..f0514134d1 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro
@@ -27,5 +27,7 @@ HEADERS += \
../shared/qqmlinspectorprotocol.h \
../shared/qmlinspectorconstants.h
+OTHER_FILES += qtquick2plugin.json
+
target.path += $$[QT_INSTALL_PLUGINS]/qmltooling
INSTALLS += target
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
index ea52788896..16dfaed597 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp
@@ -84,5 +84,3 @@ void QtQuick2Plugin::clientMessage(const QByteArray &message)
} // namespace QtQuick2
} // namespace QmlJSDebugger
-
-Q_EXPORT_PLUGIN2(qmldbg_qtquick2, QmlJSDebugger::QtQuick2::QtQuick2Plugin)
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h
index d78aac6ead..6c3f3d6943 100644
--- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h
@@ -55,6 +55,7 @@ class QtQuick2Plugin : public QObject, public QQmlInspectorInterface
{
Q_OBJECT
Q_DISABLE_COPY(QtQuick2Plugin)
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlInspectorInterface" FILE "qtquick2plugin.json")
Q_INTERFACES(QQmlInspectorInterface)
public:
diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json
new file mode 100644
index 0000000000..311847daa5
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json
@@ -0,0 +1,2 @@
+{}
+
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
index cb663dbc0c..0c5e196b18 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
+++ b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
@@ -14,5 +14,7 @@ SOURCES += \
HEADERS += \
qtcpserverconnection.h
+OTHER_FILES += qtcpserverconnection.json
+
target.path += $$[QT_INSTALL_PLUGINS]/qmltooling
INSTALLS += target
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
index 63a3297f37..1c5ec37512 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -193,7 +193,5 @@ void QTcpServerConnection::invalidPacket()
qWarning("QQmlDebugServer: Received a corrupted packet! Giving up ...");
}
-Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection)
-
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
index 74c6b95e56..e81c9f7f0f 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
@@ -54,9 +54,9 @@ class QTcpServerConnection : public QObject, public QQmlDebugServerConnection
Q_OBJECT
Q_DECLARE_PRIVATE(QTcpServerConnection)
Q_DISABLE_COPY(QTcpServerConnection)
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlDebugServerConnection" FILE "qtcpserverconnection.json")
Q_INTERFACES(QQmlDebugServerConnection)
-
public:
QTcpServerConnection();
~QTcpServerConnection();
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json
@@ -0,0 +1 @@
+{}
diff --git a/src/qml/debugger/qdebugmessageservice.cpp b/src/qml/debugger/qdebugmessageservice.cpp
index 2c52809e56..dcaa514cd7 100644
--- a/src/qml/debugger/qdebugmessageservice.cpp
+++ b/src/qml/debugger/qdebugmessageservice.cpp
@@ -42,6 +42,8 @@
#include "qdebugmessageservice_p.h"
#include "qqmldebugservice_p_p.h"
+#include <QDataStream>
+
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QDebugMessageService, qmlDebugMessageService)
diff --git a/src/qml/debugger/qqmldebugserverconnection_p.h b/src/qml/debugger/qqmldebugserverconnection_p.h
index c9092f1911..ab9e7bd73f 100644
--- a/src/qml/debugger/qqmldebugserverconnection_p.h
+++ b/src/qml/debugger/qqmldebugserverconnection_p.h
@@ -43,7 +43,7 @@
#define QQMLDEBUGSERVERCONNECTION_H
#include <QtQml/qtqmlglobal.h>
-#include <QtCore/QtPlugin>
+#include <private/qqmlglobal_p.h>
//
// W A R N I N G
@@ -76,7 +76,9 @@ public:
virtual bool waitForMessage() = 0;
};
-Q_DECLARE_INTERFACE(QQmlDebugServerConnection, "com.trolltech.Qt.QQmlDebugServerConnection/1.0")
+#define QQmlDebugServerConnection_iid "org.qt-project.Qt.QQmlDebugServerConnection"
+
+Q_DECLARE_INTERFACE(QQmlDebugServerConnection, QQmlDebugServerConnection_iid)
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlinspectorinterface_p.h b/src/qml/debugger/qqmlinspectorinterface_p.h
index 7f52dffa2e..5b015d36df 100644
--- a/src/qml/debugger/qqmlinspectorinterface_p.h
+++ b/src/qml/debugger/qqmlinspectorinterface_p.h
@@ -54,6 +54,7 @@
//
#include <QtQml/qtqmlglobal.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_HEADER
@@ -74,7 +75,9 @@ public:
virtual void clientMessage(const QByteArray &message) = 0;
};
-Q_DECLARE_INTERFACE(QQmlInspectorInterface, "com.trolltech.Qt.QQmlInspectorInterface/1.0")
+#define QQmlInspectorInterface_iid "org.qt-project.Qt.QQmlInspectorInterface"
+
+Q_DECLARE_INTERFACE(QQmlInspectorInterface, QQmlInspectorInterface_iid)
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp
index d6a0307836..2731d2046b 100644
--- a/src/qml/debugger/qqmlprofilerservice.cpp
+++ b/src/qml/debugger/qqmlprofilerservice.cpp
@@ -52,23 +52,10 @@
QT_BEGIN_NAMESPACE
+// instance will be set, unset in constructor. Allows static methods to be inlined.
+QQmlProfilerService *QQmlProfilerService::instance = 0;
Q_GLOBAL_STATIC(QQmlProfilerService, profilerInstance)
-QQmlBindingProfiler::QQmlBindingProfiler(const QString &url, int line, int column)
-{
- QQmlProfilerService::startRange(QQmlProfilerService::Binding);
- QQmlProfilerService::rangeLocation(QQmlProfilerService::Binding, url, line, column);
-}
-
-QQmlBindingProfiler::~QQmlBindingProfiler()
-{
- QQmlProfilerService::endRange(QQmlProfilerService::Binding);
-}
-
-void QQmlBindingProfiler::addDetail(const QString &details)
-{
- QQmlProfilerService::rangeData(QQmlProfilerService::Binding, details);
-}
// convert to a QByteArray that can be sent to the debug client
// use of QDataStream can skew results
@@ -106,12 +93,13 @@ QQmlProfilerService::QQmlProfilerService()
QQmlProfilerService::~QQmlProfilerService()
{
+ instance = 0;
}
void QQmlProfilerService::initialize()
{
// just make sure that the service is properly registered
- profilerInstance();
+ instance = profilerInstance();
}
bool QQmlProfilerService::startProfiling()
@@ -134,36 +122,6 @@ void QQmlProfilerService::addEvent(EventType t)
profilerInstance()->addEventImpl(t);
}
-void QQmlProfilerService::startRange(RangeType t)
-{
- profilerInstance()->startRangeImpl(t);
-}
-
-void QQmlProfilerService::rangeData(RangeType t, const QString &data)
-{
- profilerInstance()->rangeDataImpl(t, data);
-}
-
-void QQmlProfilerService::rangeData(RangeType t, const QUrl &data)
-{
- profilerInstance()->rangeDataImpl(t, data);
-}
-
-void QQmlProfilerService::rangeLocation(RangeType t, const QString &fileName, int line, int column)
-{
- profilerInstance()->rangeLocationImpl(t, fileName, line, column);
-}
-
-void QQmlProfilerService::rangeLocation(RangeType t, const QUrl &fileName, int line, int column)
-{
- profilerInstance()->rangeLocationImpl(t, fileName, line, column);
-}
-
-void QQmlProfilerService::endRange(RangeType t)
-{
- profilerInstance()->endRangeImpl(t);
-}
-
void QQmlProfilerService::animationFrame(qint64 delta)
{
profilerInstance()->animationFrameImpl(delta);
@@ -214,7 +172,7 @@ void QQmlProfilerService::addEventImpl(EventType event)
processMessage(ed);
}
-void QQmlProfilerService::startRangeImpl(RangeType range)
+void QQmlProfilerService::startRange(RangeType range)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -223,7 +181,7 @@ void QQmlProfilerService::startRangeImpl(RangeType range)
processMessage(rd);
}
-void QQmlProfilerService::rangeDataImpl(RangeType range, const QString &rData)
+void QQmlProfilerService::rangeData(RangeType range, const QString &rData)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -232,7 +190,7 @@ void QQmlProfilerService::rangeDataImpl(RangeType range, const QString &rData)
processMessage(rd);
}
-void QQmlProfilerService::rangeDataImpl(RangeType range, const QUrl &rData)
+void QQmlProfilerService::rangeData(RangeType range, const QUrl &rData)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -241,7 +199,7 @@ void QQmlProfilerService::rangeDataImpl(RangeType range, const QUrl &rData)
processMessage(rd);
}
-void QQmlProfilerService::rangeLocationImpl(RangeType range, const QString &fileName, int line, int column)
+void QQmlProfilerService::rangeLocation(RangeType range, const QString &fileName, int line, int column)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -250,7 +208,7 @@ void QQmlProfilerService::rangeLocationImpl(RangeType range, const QString &file
processMessage(rd);
}
-void QQmlProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileName, int line, int column)
+void QQmlProfilerService::rangeLocation(RangeType range, const QUrl &fileName, int line, int column)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
@@ -259,7 +217,7 @@ void QQmlProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileNam
processMessage(rd);
}
-void QQmlProfilerService::endRangeImpl(RangeType range)
+void QQmlProfilerService::endRange(RangeType range)
{
if (!QQmlDebugService::isDebuggingEnabled() || !m_enabled)
return;
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h
index a74ce10c74..7a708456ba 100644
--- a/src/qml/debugger/qqmlprofilerservice_p.h
+++ b/src/qml/debugger/qqmlprofilerservice_p.h
@@ -54,9 +54,11 @@
//
#include <private/qqmldebugservice_p.h>
+#include <QtQml/qtqmlglobal.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qmutex.h>
#include <QtCore/qvector.h>
+#include <QtCore/qstringbuilder.h>
QT_BEGIN_HEADER
@@ -83,13 +85,6 @@ Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE);
class QUrl;
class QQmlEngine;
-// RAII
-class Q_AUTOTEST_EXPORT QQmlBindingProfiler {
-public:
- QQmlBindingProfiler(const QString &url, int line, int column);
- ~QQmlBindingProfiler();
- void addDetail(const QString &details);
-};
class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService
{
@@ -132,12 +127,6 @@ public:
static bool stopProfiling();
static void sendStartedProfilingMessage();
static void addEvent(EventType);
- static void startRange(RangeType);
- static void rangeData(RangeType, const QString &);
- static void rangeData(RangeType, const QUrl &);
- static void rangeLocation(RangeType, const QString &, int, int);
- static void rangeLocation(RangeType, const QUrl &, int, int);
- static void endRange(RangeType);
static void animationFrame(qint64);
static void sendProfilingData();
@@ -154,14 +143,16 @@ private:
bool stopProfilingImpl();
void sendStartedProfilingMessageImpl();
void addEventImpl(EventType);
- void startRangeImpl(RangeType);
- void rangeDataImpl(RangeType, const QString &);
- void rangeDataImpl(RangeType, const QUrl &);
- void rangeLocationImpl(RangeType, const QString &, int, int);
- void rangeLocationImpl(RangeType, const QUrl &, int, int);
- void endRangeImpl(RangeType);
void animationFrameImpl(qint64);
+ void startRange(RangeType);
+ void rangeData(RangeType, const QString &);
+ void rangeData(RangeType, const QUrl &);
+ void rangeLocation(RangeType, const QString &, int, int);
+ void rangeLocation(RangeType, const QUrl &, int, int);
+ void endRange(RangeType);
+
+
bool profilingEnabled();
void setProfilingEnabled(bool enable);
void sendMessages();
@@ -173,6 +164,135 @@ private:
bool m_messageReceived;
QVector<QQmlProfilerData> m_data;
QMutex m_mutex;
+
+ static QQmlProfilerService *instance;
+
+ friend struct QQmlBindingProfiler;
+ friend struct QQmlHandlingSignalProfiler;
+ friend struct QQmlObjectCreatingProfiler;
+ friend struct QQmlCompilingProfiler;
+};
+
+//
+// RAII helper structs
+//
+
+struct QQmlBindingProfiler {
+ QQmlBindingProfiler(const QString &url, int line, int column)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ? instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Binding);
+ instance->rangeLocation(QQmlProfilerService::Binding, url, line, column);
+ }
+ }
+
+ ~QQmlBindingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Binding);
+ }
+
+ void addDetail(const QString &details)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(QQmlProfilerService::Binding,
+ details);
+ }
+\
+ bool enabled;
+};
+
+struct QQmlHandlingSignalProfiler {
+ QQmlHandlingSignalProfiler()
+ {
+ enabled = QQmlProfilerService::instance
+ ? QQmlProfilerService::instance->profilingEnabled() : false;
+ if (enabled) {
+ QQmlProfilerService::instance->startRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+ }
+
+ void setSignalInfo(const QString &name, const QString &expression)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::HandlingSignal,
+ name % QLatin1String(": ") % expression);
+ }
+
+ void setLocation(const QString &file, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::HandlingSignal, file, line, column);
+ }
+
+ ~QQmlHandlingSignalProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+
+ bool enabled;
+};
+
+struct QQmlObjectCreatingProfiler {
+ QQmlObjectCreatingProfiler()
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled)
+ instance->startRange(QQmlProfilerService::Creating);
+ }
+
+ void setTypeName(const QString &typeName)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::Creating, typeName);
+ }
+
+ void setLocation(const QUrl &url, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::Creating, url, line, column);
+ }
+
+ ~QQmlObjectCreatingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
+ }
+
+ bool enabled;
+};
+
+struct QQmlCompilingProfiler {
+ QQmlCompilingProfiler(const QString &name)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Compiling);
+ instance->rangeLocation(QQmlProfilerService::Compiling, name, 1, 1);
+ instance->rangeData(QQmlProfilerService::Compiling, name);
+ }
+ }
+
+ ~QQmlCompilingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Compiling);
+ }
+
+ bool enabled;
};
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qv8profilerservice.cpp b/src/qml/debugger/qv8profilerservice.cpp
index eba8b0feef..6473a2f4fb 100644
--- a/src/qml/debugger/qv8profilerservice.cpp
+++ b/src/qml/debugger/qv8profilerservice.cpp
@@ -187,6 +187,13 @@ void QV8ProfilerService::startProfiling(const QString &title)
v8::CpuProfiler::StartProfiling(v8title);
d->m_ongoing.append(title);
+
+ // indicate profiling started
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Started;
+
+ sendMessage(data);
}
void QV8ProfilerService::stopProfiling(const QString &title)
@@ -205,6 +212,13 @@ void QV8ProfilerService::stopProfiling(const QString &title)
// can happen at start
const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot();
d->printProfileTree(rootNode);
+ } else {
+ // indicate completion, even without data
+ QByteArray data;
+ QDataStream ds(&data, QIODevice::WriteOnly);
+ ds << (int)QV8ProfilerService::V8Complete;
+
+ sendMessage(data);
}
}
diff --git a/src/qml/debugger/qv8profilerservice_p.h b/src/qml/debugger/qv8profilerservice_p.h
index d408d9ed0e..b706d1762a 100644
--- a/src/qml/debugger/qv8profilerservice_p.h
+++ b/src/qml/debugger/qv8profilerservice_p.h
@@ -85,6 +85,7 @@ public:
V8Complete,
V8SnapshotChunk,
V8SnapshotComplete,
+ V8Started,
V8MaximumMessage
};
diff --git a/src/qml/qml/ftw/qfastmetabuilder.cpp b/src/qml/qml/ftw/qfastmetabuilder.cpp
index 9663c1e944..02f50911ea 100644
--- a/src/qml/qml/ftw/qfastmetabuilder.cpp
+++ b/src/qml/qml/ftw/qfastmetabuilder.cpp
@@ -42,6 +42,8 @@
#include "qfastmetabuilder_p.h"
#include <QtCore/qmetaobject.h>
+#include <private/qobject_p.h>
+#include <private/qmetaobject_p.h>
QT_BEGIN_NAMESPACE
@@ -50,65 +52,6 @@ struct QFastMetaBuilderHeader
int fieldCount;
};
-struct QMetaObjectPrivate
-{
- int revision;
- int className;
- int classInfoCount, classInfoData;
- int methodCount, methodData;
- int propertyCount, propertyData;
- int enumeratorCount, enumeratorData;
- int constructorCount, constructorData; //since revision 2
- int flags; //since revision 3
- int signalCount; //since revision 4
-};
-
-enum MetaObjectFlag {
- DynamicMetaObject = 0x01
-};
-
-enum PropertyFlags {
- Invalid = 0x00000000,
- Readable = 0x00000001,
- Writable = 0x00000002,
- Resettable = 0x00000004,
- EnumOrFlag = 0x00000008,
- StdCppSet = 0x00000100,
-// Override = 0x00000200,
- Constant = 0x00000400,
- Final = 0x00000800,
- Designable = 0x00001000,
- ResolveDesignable = 0x00002000,
- Scriptable = 0x00004000,
- ResolveScriptable = 0x00008000,
- Stored = 0x00010000,
- ResolveStored = 0x00020000,
- Editable = 0x00040000,
- ResolveEditable = 0x00080000,
- User = 0x00100000,
- ResolveUser = 0x00200000,
- Notify = 0x00400000,
- Revisioned = 0x00800000
-};
-
-enum MethodFlags {
- AccessPrivate = 0x00,
- AccessProtected = 0x01,
- AccessPublic = 0x02,
- AccessMask = 0x03, //mask
-
- MethodMethod = 0x00,
- MethodSignal = 0x04,
- MethodSlot = 0x08,
- MethodConstructor = 0x0c,
- MethodTypeMask = 0x0c,
-
- MethodCompatibility = 0x10,
- MethodCloned = 0x20,
- MethodScriptable = 0x40,
- MethodRevisioned = 0x80
-};
-
#define FMBHEADER_FIELD_COUNT 1
#define HEADER_FIELD_COUNT 14
@@ -175,7 +118,7 @@ QFastMetaBuilder::StringRef QFastMetaBuilder::init(int classNameLength,
int dataIndex = HEADER_FIELD_COUNT;
- p->revision = 4;
+ p->revision = 6;
p->className = 0;
// Class infos
@@ -364,6 +307,7 @@ void QFastMetaBuilder::fromData(QMetaObject *output, const QMetaObject *parent,
output->d.superdata = parent;
output->d.stringdata = data.constData() + header(data)->fieldCount * sizeof(uint);
output->d.data = fieldPointer(data);
+ output->d.extradata = 0;
}
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 6f552450ef..ca6b13e7f8 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -170,12 +170,18 @@ int QQmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
if (!m_expression)
return -1;
- if (QQmlDebugService::isDebuggingEnabled()) {
- QQmlProfilerService::startRange(QQmlProfilerService::HandlingSignal);
- QQmlProfilerService::rangeData(QQmlProfilerService::HandlingSignal, QLatin1String(m_signal.signature()) % QLatin1String(": ") % m_expression->expression());
- QQmlProfilerService::rangeLocation(QQmlProfilerService::HandlingSignal, m_expression->sourceFile(), m_expression->lineNumber(), m_expression->columnNumber());
+
+ if (QQmlDebugService::isDebuggingEnabled())
QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature()));
+
+ QQmlHandlingSignalProfiler prof;
+ if (prof.enabled) {
+ prof.setSignalInfo(QString::fromLatin1(m_signal.signature()),
+ m_expression->expression());
+ prof.setLocation(m_expression->sourceFile(), m_expression->lineNumber(),
+ m_expression->columnNumber());
}
+
m_isEvaluating = true;
if (!m_paramsValid) {
if (!m_signal.parameterTypes().isEmpty())
@@ -191,7 +197,6 @@ int QQmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
}
if (m_params) m_params->clearValues();
m_isEvaluating = false;
- QQmlProfilerService::endRange(QQmlProfilerService::HandlingSignal);
return -1;
} else {
return QObject::qt_metacall(c, id, a);
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index 65247e1e80..23c4adc7b4 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -3609,16 +3609,19 @@ bool QQmlCompiler::completeComponentBuild()
bool isSharable = false;
binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable);
- if (isSharable && !binding.property->isValueTypeSubProperty && !binding.property->isAlias /* See above re alias */ &&
+ if (isSharable && !binding.property->isAlias /* See above re alias */ &&
binding.property->type != qMetaTypeId<QQmlBinding*>()) {
binding.dataType = BindingReference::V8;
sharedBindings.append(b);
+
+ if (componentStats)
+ componentStats->componentStat.sharedBindings.append(b->value->location);
} else {
binding.dataType = BindingReference::QtScript;
- }
- if (componentStats)
- componentStats->componentStat.scriptBindings.append(b->value->location);
+ if (componentStats)
+ componentStats->componentStat.scriptBindings.append(b->value->location);
+ }
}
if (!sharedBindings.isEmpty()) {
@@ -3699,6 +3702,25 @@ void QQmlCompiler::dumpStats()
qWarning().nospace() << output.constData();
}
+ qWarning().nospace() << " Shared Bindings: " << stat.sharedBindings.count();
+ {
+ QByteArray output;
+ for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) {
+ if (0 == (ii % 10)) {
+ if (ii) output.append("\n");
+ output.append(" ");
+ }
+
+ output.append("(");
+ output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line));
+ output.append(":");
+ output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column));
+ output.append(") ");
+ }
+ if (!output.isEmpty())
+ qWarning().nospace() << output.constData();
+ }
+
qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count();
{
QByteArray output;
diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h
index 9b13b7e63b..3b6fdf1473 100644
--- a/src/qml/qml/qqmlcompiler_p.h
+++ b/src/qml/qml/qqmlcompiler_p.h
@@ -450,6 +450,7 @@ private:
int ids;
QList<QQmlScript::LocationSpan> scriptBindings;
+ QList<QQmlScript::LocationSpan> sharedBindings;
QList<QQmlScript::LocationSpan> optimizedBindings;
int objects;
};
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index e168f063c0..5dd8fc8ae9 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -51,6 +51,7 @@
#include "qqmlengine.h"
#include "qqmlbinding_p.h"
#include "qqmlbinding_p_p.h"
+#include "qqmlglobal_p.h"
#include "qqmlscript_p.h"
#include <private/qqmlprofilerservice_p.h>
#include <private/qqmlenginedebugservice_p.h>
@@ -738,14 +739,15 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context)
QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine);
- bool isRoot = enginePriv->inProgressCreations == 0;
+ if (enginePriv->inProgressCreations == 0) {
+ // only track root, since further ones might not be properly nested
+ profiler = new QQmlObjectCreatingProfiler();
+ }
+
enginePriv->inProgressCreations++;
state.errors.clear();
state.completePending = true;
- if (isRoot)
- QQmlProfilerService::startRange(QQmlProfilerService::Creating);
-
enginePriv->referenceScarceResources();
state.vme.init(context, cc, start, creationContext);
QObject *rv = state.vme.execute(&state.errors);
@@ -761,13 +763,12 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context)
if (!context->isInternal)
context->asQQmlContextPrivate()->instances.append(rv);
QQmlEngineDebugService::instance()->objectCreated(engine, rv);
- if (isRoot) {
- QQmlProfilerService::rangeData(QQmlProfilerService::Creating,
- buildTypeNameForDebug(rv->metaObject()));
+
+ if (profiler && profiler->enabled) {
+ profiler->setTypeName(buildTypeNameForDebug(rv->metaObject()));
QQmlData *data = QQmlData::get(rv);
Q_ASSERT(data);
- QQmlProfilerService::rangeLocation(QQmlProfilerService::Creating,
- cc->url, data->lineNumber, data->columnNumber);
+ profiler->setLocation(cc->url, data->lineNumber, data->columnNumber);
}
}
@@ -823,7 +824,8 @@ void QQmlComponentPrivate::completeCreate()
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
complete(ep, &state);
- QQmlProfilerService::endRange(QQmlProfilerService::Creating);
+ delete profiler;
+ profiler = 0;
}
}
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 731fb6a8a7..b03dd68936 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -62,6 +62,7 @@
#include "qqmlvme_p.h"
#include "qqmlerror.h"
#include "qqml.h"
+#include "../debugger/qqmlprofilerservice_p.h"
#include <QtCore/QString>
#include <QtCore/QStringList>
@@ -83,7 +84,7 @@ class Q_QML_PRIVATE_EXPORT QQmlComponentPrivate : public QObjectPrivate, public
Q_DECLARE_PUBLIC(QQmlComponent)
public:
- QQmlComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0) {}
+ QQmlComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0), profiler(0) {}
QObject *beginCreate(QQmlContextData *);
void completeCreate();
@@ -116,6 +117,7 @@ public:
QQmlEngine *engine;
QQmlGuardedContextData creationContext;
+ QQmlObjectCreatingProfiler *profiler;
void clear();
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 8cfe635543..ee5a0c954e 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -355,7 +355,8 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
QQmlEnginePrivate::~QQmlEnginePrivate()
{
- Q_ASSERT(inProgressCreations == 0);
+ if (inProgressCreations)
+ qWarning() << QQmlEngine::tr("There are still \"%1\" items in the process of being created at engine destruction.").arg(inProgressCreations);
while (cleanup) {
QQmlCleanup *c = cleanup;
@@ -965,13 +966,13 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
QQmlData *data = QQmlData::get(object);
if (data && data->deferredComponent) {
- if (QQmlDebugService::isDebuggingEnabled()) {
- QQmlProfilerService::startRange(QQmlProfilerService::Creating);
+ QQmlObjectCreatingProfiler prof;
+ if (prof.enabled) {
QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
- QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(object->metaObject()->className());
- QQmlProfilerService::rangeData(QQmlProfilerService::Creating, typeName);
+ prof.setTypeName(type ? type->qmlTypeName()
+ : QString::fromUtf8(object->metaObject()->className()));
if (data->outerContext)
- QQmlProfilerService::rangeLocation(QQmlProfilerService::Creating, data->outerContext->url, data->lineNumber, data->columnNumber);
+ prof.setLocation(data->outerContext->url, data->lineNumber, data->columnNumber);
}
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine);
@@ -982,7 +983,6 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
data->deferredComponent = 0;
QQmlComponentPrivate::complete(ep, &state);
- QQmlProfilerService::endRange(QQmlProfilerService::Creating);
}
}
@@ -1411,7 +1411,7 @@ void QQmlEngine::addImportPath(const QString& path)
imports \c com.mycompany.Feature will cause the QQmlEngine to look
in \c /opt/MyApp/lib/imports/com/mycompany/Feature/ for the components
provided by that module. A \c qmldir file is required for defining the
- type version mapping and possibly declarative extensions plugins.
+ type version mapping and possibly QML extensions plugins.
By default, the list contains the directory of the application executable,
paths specified in the \c QML_IMPORT_PATH environment variable,
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 3fbb80c280..ecdbf21d4b 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -78,13 +78,13 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression()
clearGuards();
}
-static QQmlJavaScriptExpression::VTable QDeclarativeExpressionPrivate_jsvtable = {
+static QQmlJavaScriptExpression::VTable QQmlExpressionPrivate_jsvtable = {
QQmlExpressionPrivate::expressionIdentifier,
QQmlExpressionPrivate::expressionChanged
};
QQmlExpressionPrivate::QQmlExpressionPrivate()
-: QQmlJavaScriptExpression(&QDeclarativeExpressionPrivate_jsvtable),
+: QQmlJavaScriptExpression(&QQmlExpressionPrivate_jsvtable),
expressionFunctionValid(true), expressionFunctionRewritten(false),
extractExpressionFromFunction(false), line(-1), dataRef(0)
{
diff --git a/src/qml/qml/qqmlextensioninterface.h b/src/qml/qml/qqmlextensioninterface.h
index 63ef1adc08..194319431d 100644
--- a/src/qml/qml/qqmlextensioninterface.h
+++ b/src/qml/qml/qqmlextensioninterface.h
@@ -66,8 +66,13 @@ public:
virtual void initializeEngine(QQmlEngine *engine, const char *uri) = 0;
};
+#define QQmlTypesExtensionInterface_iid "org.qt-project.Qt.QQmlTypesExtensionInterface"
+
Q_DECLARE_INTERFACE(QQmlTypesExtensionInterface, "org.qt-project.Qt.QQmlTypesExtensionInterface/1.0")
-Q_DECLARE_INTERFACE(QQmlExtensionInterface, "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface"
+
+Q_DECLARE_INTERFACE(QQmlExtensionInterface, QQmlExtensionInterface_iid)
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlimageprovider.h b/src/qml/qml/qqmlimageprovider.h
index d59cfc42ca..fe06925123 100644
--- a/src/qml/qml/qqmlimageprovider.h
+++ b/src/qml/qml/qqmlimageprovider.h
@@ -59,7 +59,7 @@ class Q_QML_EXPORT QQuickTextureFactory : public QObject
{
public:
QQuickTextureFactory();
- ~QQuickTextureFactory();
+ virtual ~QQuickTextureFactory();
virtual QSGTexture *createTexture(QQuickCanvas *canvas) const = 0;
virtual QSize textureSize() const = 0;
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index ee622ba048..834d4bbb97 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -376,17 +376,18 @@ void QQmlIncubationController::incubateFor(int msecs)
/*!
Incubate objects while the bool pointed to by \a flag is true, or until there are no
-more objects to incubate.
+more objects to incubate, or up to msecs if msecs is not zero.
Generally this method is used in conjunction with a thread or a UNIX signal that sets
the bool pointed to by \a flag to false when it wants incubation to be interrupted.
*/
-void QQmlIncubationController::incubateWhile(bool *flag)
+void QQmlIncubationController::incubateWhile(volatile bool *flag, int msecs)
{
if (!d || d->incubatorCount == 0)
return;
- QQmlVME::Interrupt i(flag);
+ QQmlVME::Interrupt i(flag, msecs * 1000000);
+ i.reset();
do {
QQmlIncubatorPrivate *p = (QQmlIncubatorPrivate*)d->incubatorList.first();
p->incubate(i);
diff --git a/src/qml/qml/qqmlincubator.h b/src/qml/qml/qqmlincubator.h
index 5d8ae7d6c3..2fb2aaf2f1 100644
--- a/src/qml/qml/qqmlincubator.h
+++ b/src/qml/qml/qqmlincubator.h
@@ -42,6 +42,7 @@
#ifndef QQMLINCUBATOR_H
#define QQMLINCUBATOR_H
+#include <QtQml/qtqmlglobal.h>
#include <QtQml/qqmlerror.h>
QT_BEGIN_HEADER
@@ -110,7 +111,7 @@ public:
int incubatingObjectCount() const;
void incubateFor(int msecs);
- void incubateWhile(bool *flag);
+ void incubateWhile(volatile bool *flag, int msecs=0);
protected:
virtual void incubatingObjectCountChanged(int);
diff --git a/src/qml/qml/qqmlinstruction.cpp b/src/qml/qml/qqmlinstruction.cpp
index 72f04c9d61..b37117e69b 100644
--- a/src/qml/qml/qqmlinstruction.cpp
+++ b/src/qml/qml/qqmlinstruction.cpp
@@ -190,7 +190,7 @@ void QQmlCompiledData::dump(QQmlInstruction *instr, int idx)
qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
break;
case QQmlInstruction::StoreSignal:
- qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value);
+ qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value;
break;
case QQmlInstruction::StoreImportedScript:
qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
@@ -199,7 +199,7 @@ void QQmlCompiledData::dump(QQmlInstruction *instr, int idx)
qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope << "\t" << instr->storeScriptString.bindingId;
break;
case QQmlInstruction::AssignSignalObject:
- qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << primitives.at(instr->assignSignalObject.signal);
+ qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal;
break;
case QQmlInstruction::AssignCustomType:
qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 4dc30f27ea..d684378832 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -524,7 +524,10 @@ v8::Handle<v8::Value> QQmlNumberExtension::fromLocaleString(const v8::Arguments&
static v8::Handle<v8::Value> locale_get_firstDayOfWeek(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
GET_LOCALE_DATA_RESOURCE(info.This());
- return v8::Integer::New(r->locale.firstDayOfWeek());
+ int fdow = int(r->locale.firstDayOfWeek());
+ if (fdow == 7)
+ fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date
+ return v8::Integer::New(fdow);
}
static v8::Handle<v8::Value> locale_get_measurementSystem(v8::Local<v8::String>, const v8::AccessorInfo &info)
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 9b132a4647..93c6aa1f00 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -50,6 +50,8 @@
#include <QtCore/qdebug.h>
+#include <ctype.h> // for toupper
+
Q_DECLARE_METATYPE(QJSValue)
Q_DECLARE_METATYPE(QQmlV8Handle);
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 095ee79867..a128cd9055 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -149,6 +149,7 @@ public:
bool hasOverride() const { return !(flags & IsValueTypeVirtual) &&
!(flags & HasAccessors) &&
overrideIndex >= 0; }
+ bool hasRevision() const { return !(flags & HasAccessors) && revision != 0; }
// Returns -1 if not a value type virtual property
inline int getValueTypeCoreIndex() const;
diff --git a/src/qml/qml/qqmlpropertyvalueinterceptor_p.h b/src/qml/qml/qqmlpropertyvalueinterceptor_p.h
index f8b8643a00..cf449c9eff 100644
--- a/src/qml/qml/qqmlpropertyvalueinterceptor_p.h
+++ b/src/qml/qml/qqmlpropertyvalueinterceptor_p.h
@@ -67,7 +67,10 @@ public:
virtual void setTarget(const QQmlProperty &property) = 0;
virtual void write(const QVariant &value) = 0;
};
-Q_DECLARE_INTERFACE(QQmlPropertyValueInterceptor, "com.trolltech.qml.QQmlPropertyValueInterceptor")
+
+#define QQmlPropertyValueInterceptor_iid "org.qt-project.Qt.QQmlPropertyValueInterceptor"
+
+Q_DECLARE_INTERFACE(QQmlPropertyValueInterceptor, QQmlPropertyValueInterceptor_iid)
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlpropertyvaluesource.h b/src/qml/qml/qqmlpropertyvaluesource.h
index 910b23877e..bbd3c2f594 100644
--- a/src/qml/qml/qqmlpropertyvaluesource.h
+++ b/src/qml/qml/qqmlpropertyvaluesource.h
@@ -58,7 +58,10 @@ public:
virtual ~QQmlPropertyValueSource();
virtual void setTarget(const QQmlProperty &) = 0;
};
-Q_DECLARE_INTERFACE(QQmlPropertyValueSource, "com.trolltech.qml.QQmlPropertyValueSource")
+
+#define QQmlPropertyValueSource_iid "org.qt-project.Qt.QQmlPropertyValueSource"
+
+Q_DECLARE_INTERFACE(QQmlPropertyValueSource, QQmlPropertyValueSource_iid)
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlrewrite.cpp b/src/qml/qml/qqmlrewrite.cpp
index 828f7bf641..72bd23955b 100644
--- a/src/qml/qml/qqmlrewrite.cpp
+++ b/src/qml/qml/qqmlrewrite.cpp
@@ -51,6 +51,45 @@ DEFINE_BOOL_CONFIG_OPTION(rewriteDump, QML_REWRITE_DUMP);
namespace QQmlRewrite {
+static void rewriteStringLiteral(AST::StringLiteral *ast, const QString *code, int startPosition, TextWriter *writer)
+{
+ const unsigned position = ast->firstSourceLocation().begin() - startPosition + 1;
+ const unsigned length = ast->literalToken.length - 2;
+ const QStringRef spell = code->midRef(position, length);
+ const int end = spell.size();
+ int index = 0;
+
+ while (index < end) {
+ const QChar ch = spell.at(index++);
+
+ if (index < end && ch == QLatin1Char('\\')) {
+ int pos = index;
+
+ // skip a possibly empty sequence of \r characters
+ while (pos < end && spell.at(pos) == QLatin1Char('\r'))
+ ++pos;
+
+ if (pos < end && spell.at(pos) == QLatin1Char('\n')) {
+ // This is a `\' followed by a newline terminator.
+ // In this case there's nothing to replace. We keep the code
+ // as it is and we resume the searching.
+ index = pos + 1; // refresh the index
+ }
+ } else if (ch == QLatin1Char('\r') || ch == QLatin1Char('\n')) {
+ const QString sep = ch == QLatin1Char('\r') ? QLatin1String("\\r") : QLatin1String("\\n");
+ const int pos = index - 1;
+ QString s = sep;
+
+ while (index < end && spell.at(index) == ch) {
+ s += sep;
+ ++index;
+ }
+
+ writer->replace(position + pos, index - pos, s);
+ }
+ }
+}
+
bool SharedBindingTester::isSharable(const QString &code)
{
Engine engine;
@@ -204,40 +243,7 @@ bool RewriteBinding::visit(AST::ExpressionStatement *ast)
bool RewriteBinding::visit(AST::StringLiteral *ast)
{
- /* When rewriting the code for bindings, we have to remove ILLEGAL JS tokens like newlines.
- They're still in multi-line strings, because the QML parser allows them, but we have to
- rewrite them to be JS compliant.
-
- For performance reasons, we don't go for total correctness. \r is only replaced if a
- \n was found (since most line endings are \n or \r\n) and QChar::LineSeparator is not
- even considered. QTBUG-24064.
-
- Note that rewriteSignalHandler has a function just like this one, for the same reason.
- */
-
- unsigned startOfString = ast->firstSourceLocation().begin() + 1 - _position;
- unsigned stringLength = ast->firstSourceLocation().length - 2;
-
- int lastIndex = -1;
- bool foundNewLine = false;
- QStringRef subStr(_code, startOfString, stringLength);
- while (true) {
- lastIndex = subStr.indexOf(QLatin1Char('\n'), lastIndex + 1);
- if (lastIndex == -1)
- break;
- foundNewLine = true;
- _writer->replace(startOfString+lastIndex, 1, QLatin1String("\\n"));
- }
-
- if (foundNewLine) {
- while (true) {
- lastIndex = subStr.indexOf(QLatin1Char('\r'), lastIndex + 1);
- if (lastIndex == -1)
- break;
- _writer->replace(startOfString+lastIndex, 1, QLatin1String("\\r"));
- }
- }
-
+ rewriteStringLiteral(ast, _code, _position, _writer);
return false;
}
@@ -361,6 +367,13 @@ void RewriteBinding::rewriteCaseStatements(AST::StatementList *statements, bool
}
}
+RewriteSignalHandler::RewriteSignalHandler()
+ : _writer(0)
+ , _code(0)
+ , _position(0)
+{
+}
+
void RewriteSignalHandler::accept(AST::Node *node)
{
AST::Node::acceptChild(node, this);
@@ -368,42 +381,10 @@ void RewriteSignalHandler::accept(AST::Node *node)
bool RewriteSignalHandler::visit(AST::StringLiteral *ast)
{
- unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
- _strStarts << startOfExpressionStatement + 1;
- _strLens << ast->firstSourceLocation().length - 2;
-
+ rewriteStringLiteral(ast, _code, _position, _writer);
return false;
}
-void RewriteSignalHandler::rewriteMultilineStrings(QString &code)
-{
- QList<int> replaceR, replaceN;
- for (int i=0; i < _strStarts.count(); i++) {
- QStringRef curSubstr = QStringRef(&code, _strStarts[i], _strLens[i]);
- int lastIndex = -1;
- while (true) {
- lastIndex = curSubstr.indexOf(QLatin1Char('\n'), lastIndex + 1);
- if (lastIndex == -1)
- break;
- replaceN << _strStarts[i]+lastIndex;
- }
-
- if (replaceN.count()) {
- while (true) {
- lastIndex = curSubstr.indexOf(QLatin1Char('\r'), lastIndex + 1);
- if (lastIndex == -1)
- break;
- replaceR << _strStarts[i]+lastIndex;
- }
- }
- }
- for (int ii = replaceN.count() - 1; ii >= 0; ii--)
- code.replace(replaceN[ii], 1, QLatin1String("\\n"));
- if (replaceR.count())
- for (int ii = replaceR.count() - 1; ii >= 0; ii--)
- code.replace(replaceR[ii], 1, QLatin1String("\\r"));
-}
-
QString RewriteSignalHandler::operator()(QQmlJS::AST::Node *node, const QString &code, const QString &name)
{
if (rewriteDump()) {
@@ -417,13 +398,15 @@ QString RewriteSignalHandler::operator()(QQmlJS::AST::Node *node, const QString
if (!expression && !statement)
return code;
- _strStarts.clear();
- _strLens.clear();
+ TextWriter w;
+ _writer = &w;
+ _code = &code;
+
_position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin();
accept(node);
QString rewritten = code;
- rewriteMultilineStrings(rewritten);
+ w.write(&rewritten);
rewritten = QStringLiteral("(function ") + name + QStringLiteral("() { ") + rewritten + QStringLiteral(" })");
diff --git a/src/qml/qml/qqmlrewrite_p.h b/src/qml/qml/qqmlrewrite_p.h
index e915d797df..1d69839878 100644
--- a/src/qml/qml/qqmlrewrite_p.h
+++ b/src/qml/qml/qqmlrewrite_p.h
@@ -126,11 +126,12 @@ private:
class RewriteSignalHandler: protected AST::Visitor
{
- QList<int> _strStarts;
- QList<int> _strLens;
+ TextWriter *_writer;
+ const QString *_code;
int _position;
public:
+ RewriteSignalHandler();
QString operator()(QQmlJS::AST::Node *node, const QString &code, const QString &name);
protected:
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index cde2885f0c..5cbb2f6943 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1578,13 +1578,12 @@ void QQmlTypeData::downloadProgressChanged(qreal p)
void QQmlTypeData::compile()
{
Q_ASSERT(m_compiledData == 0);
- QQmlProfilerService::startRange(QQmlProfilerService::Compiling);
m_compiledData = new QQmlCompiledData(typeLoader()->engine());
m_compiledData->url = finalUrl();
m_compiledData->name = finalUrlString();
- QQmlProfilerService::rangeLocation(QQmlProfilerService::Compiling, QUrl(m_compiledData->name),1,1);
- QQmlProfilerService::rangeData(QQmlProfilerService::Compiling, m_compiledData->name);
+
+ QQmlCompilingProfiler prof(m_compiledData->name);
QQmlCompiler compiler(&scriptParser._pool);
if (!compiler.compile(typeLoader()->engine(), this, m_compiledData)) {
@@ -1592,7 +1591,6 @@ void QQmlTypeData::compile()
m_compiledData->release();
m_compiledData = 0;
}
- QQmlProfilerService::endRange(QQmlProfilerService::Compiling);
}
void QQmlTypeData::resolveTypes()
diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h
index 8c8d4d079e..844f2cc98b 100644
--- a/src/qml/qml/qqmlvme_p.h
+++ b/src/qml/qml/qqmlvme_p.h
@@ -97,7 +97,7 @@ public:
class Interrupt {
public:
inline Interrupt();
- inline Interrupt(bool *runWhile);
+ inline Interrupt(volatile bool *runWhile, int nsecs=0);
inline Interrupt(int nsecs);
inline void reset();
@@ -105,13 +105,11 @@ public:
private:
enum Mode { None, Time, Flag };
Mode mode;
- union {
- struct {
- QElapsedTimer timer;
- int nsecs;
- };
- bool *runWhile;
+ struct {
+ QElapsedTimer timer;
+ int nsecs;
};
+ volatile bool *runWhile;
};
QQmlVME() : data(0), componentAttached(0) {}
@@ -202,23 +200,23 @@ private:
};
QQmlVME::Interrupt::Interrupt()
-: mode(None)
+ : mode(None), nsecs(0), runWhile(0)
{
}
-QQmlVME::Interrupt::Interrupt(bool *runWhile)
-: mode(Flag), runWhile(runWhile)
+QQmlVME::Interrupt::Interrupt(volatile bool *runWhile, int nsecs)
+ : mode(Flag), nsecs(nsecs), runWhile(runWhile)
{
}
QQmlVME::Interrupt::Interrupt(int nsecs)
-: mode(Time), nsecs(nsecs)
+ : mode(Time), nsecs(nsecs), runWhile(0)
{
}
void QQmlVME::Interrupt::reset()
{
- if (mode == Time)
+ if (mode == Time || nsecs)
timer.start();
}
@@ -229,7 +227,7 @@ bool QQmlVME::Interrupt::shouldInterrupt() const
} else if (mode == Time) {
return timer.nsecsElapsed() > nsecs;
} else if (mode == Flag) {
- return !*runWhile;
+ return !*runWhile || (nsecs && timer.nsecsElapsed() > nsecs);
} else {
return false;
}
diff --git a/src/qml/qml/qquickworkerscript.cpp b/src/qml/qml/qquickworkerscript.cpp
index f91aa28509..529f181e7a 100644
--- a/src/qml/qml/qquickworkerscript.cpp
+++ b/src/qml/qml/qquickworkerscript.cpp
@@ -202,7 +202,7 @@ QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
{
- initDeclarativeGlobalObject();
+ initQmlGlobalObject();
#define CALL_ONMESSAGE_SCRIPT \
"(function(object, message) { "\
"var isfunction = false; "\
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp
index c03292d74d..4fd84945fc 100644
--- a/src/qml/qml/v4/qv4bindings.cpp
+++ b/src/qml/qml/v4/qv4bindings.cpp
@@ -50,6 +50,7 @@
#include <private/qqmlprofilerservice_p.h>
#include <private/qqmlmetatype_p.h>
#include <private/qqmltrace_p.h>
+#include <private/qqmlstringconverters_p.h>
#include <QtQml/qqmlinfo.h>
#include <QtCore/qnumeric.h>
@@ -86,9 +87,11 @@ struct Register {
QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
QString *getstringptr() { return (QString *)typeDataPtr(); }
QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
+ QColor *getcolorptr() { return (QColor *)typeDataPtr(); }
const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
const QString *getstringptr() const { return (QString *)typeDataPtr(); }
const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
+ const QColor *getcolorptr() const { return (QColor *)typeDataPtr(); }
void *typeDataPtr() { return (void *)&data; }
void *typeMemory() { return (void *)data; }
@@ -112,6 +115,7 @@ struct Register {
inline void cleanup();
inline void cleanupString();
inline void cleanupUrl();
+ inline void cleanupColor();
inline void cleanupVariant();
inline void copy(const Register &other);
@@ -135,6 +139,8 @@ void Register::cleanup()
getstringptr()->~QString();
} else if (dataType == QUrlType) {
geturlptr()->~QUrl();
+ } else if (dataType == QColorType) {
+ getcolorptr()->~QColor();
} else if (dataType == QVariantType) {
getvariantptr()->~QVariant();
}
@@ -154,6 +160,12 @@ void Register::cleanupUrl()
setUndefined();
}
+void Register::cleanupColor()
+{
+ getcolorptr()->~QColor();
+ setUndefined();
+}
+
void Register::cleanupVariant()
{
getvariantptr()->~QVariant();
@@ -168,6 +180,8 @@ void Register::copy(const Register &other)
new (getstringptr()) QString(*other.getstringptr());
else if (other.dataType == QUrlType)
new (geturlptr()) QUrl(*other.geturlptr());
+ else if (other.dataType == QColorType)
+ new (getcolorptr()) QColor(*other.getcolorptr());
else if (other.dataType == QVariantType)
new (getvariantptr()) QVariant(*other.getvariantptr());
}
@@ -181,6 +195,8 @@ void Register::init(Type type)
new (getstringptr()) QString();
else if (dataType == QUrlType)
new (geturlptr()) QUrl();
+ else if (dataType == QColorType)
+ new (getcolorptr()) QColor();
else if (dataType == QVariantType)
new (getvariantptr()) QVariant();
}
@@ -256,7 +272,8 @@ void QV4Bindings::Binding::destroy()
int QV4Bindings::Binding::propertyIndex() const
{
- return property;
+ //mask out the type information set for value types
+ return property & 0xFF00FFFF;
}
QObject *QV4Bindings::Binding::object() const
@@ -662,6 +679,11 @@ inline quint32 QV4Bindings::toUint32(qreal n)
MARK_REGISTER(reg); \
}
+#define COLOR_REGISTER(reg) { \
+ registers[(reg)].settype(QColorType); \
+ MARK_REGISTER(reg); \
+}
+
#define VARIANT_REGISTER(reg) { \
registers[(reg)].settype(QVariantType); \
MARK_REGISTER(reg); \
@@ -1022,6 +1044,27 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
}
QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
+ QML_V4_BEGIN_INSTR(ConvertStringToColor, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QString tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ QColor *colorPtr = output.getcolorptr();
+ new (colorPtr) QColor(QQmlStringConverters::colorFromString(tmp));
+
+ COLOR_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
+
QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop)
{
const Register &src = registers[instr->unaryop.src];
@@ -1059,6 +1102,40 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
}
QML_V4_END_INSTR(ConvertUrlToString, unaryop)
+ QML_V4_BEGIN_INSTR(ConvertColorToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ // for compatibility with color behavior in v8, always true
+ output.setbool(true);
+ }
+ }
+ QML_V4_END_INSTR(ConvertColorToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertColorToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QColor tmp(*src.getcolorptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupColor();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ // to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
+ new (output.getstringptr()) QString(QVariant(tmp).toString());
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertColorToString, unaryop)
+
QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
{
const Register &src = registers[instr->unaryop.src];
diff --git a/src/qml/qml/v4/qv4bindings_p.h b/src/qml/qml/v4/qv4bindings_p.h
index 61d29a6f57..1824fa4ee9 100644
--- a/src/qml/qml/v4/qv4bindings_p.h
+++ b/src/qml/qml/v4/qv4bindings_p.h
@@ -96,6 +96,8 @@ private:
int index:30;
bool enabled:1;
bool updating:1;
+ // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24)
+ // propType and valueTypeIndex are only set if the property is a value type property
int property;
QObject *scope;
int line;
diff --git a/src/qml/qml/v4/qv4compiler.cpp b/src/qml/qml/v4/qv4compiler.cpp
index d61fd580c7..f8fe3b4b57 100644
--- a/src/qml/qml/v4/qv4compiler.cpp
+++ b/src/qml/qml/v4/qv4compiler.cpp
@@ -63,7 +63,7 @@ static bool qmlEnableV4 = true;
using namespace QQmlJS;
QV4CompilerPrivate::QV4CompilerPrivate()
-: _function(0) , _block(0) , _discarded(false)
+ : _function(0) , _block(0) , _discarded(false), registerCount(0)
{
}
@@ -75,6 +75,7 @@ void QV4CompilerPrivate::trace(int line, int column)
bytecode.clear();
this->currentReg = _function->tempCount;
+ this->registerCount = qMax(this->registerCount, this->currentReg);
foreach (IR::BasicBlock *bb, _function->basicBlocks) {
if (! bb->isTerminated() && (bb->index + 1) < _function->basicBlocks.size())
@@ -344,6 +345,9 @@ void QV4CompilerPrivate::visitName(IR::Name *e)
case QMetaType::QUrl:
regType = QUrlType;
break;
+ case QMetaType::QColor:
+ regType = QColorType;
+ break;
default:
if (propTy == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
@@ -581,6 +585,12 @@ void QV4CompilerPrivate::convertToBool(IR::Expr *expr, int reg)
gen(i);
} return;
+ case IR::ColorType: {
+ Instr::ConvertColorToBool i;
+ i.output = i.src = reg;
+ gen(i);
+ } return;
+
default:
discard();
break;
@@ -880,6 +890,7 @@ void QV4CompilerPrivate::visitMove(IR::Move *s)
case IR::RealType: opcode = V4Instr::ConvertRealToBool; break;
case IR::StringType: opcode = V4Instr::ConvertStringToBool; break;
case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break;
+ case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break;
default: break;
} // switch
} else if (targetTy == IR::IntType) {
@@ -908,6 +919,7 @@ void QV4CompilerPrivate::visitMove(IR::Move *s)
case IR::IntType: opcode = V4Instr::ConvertIntToString; break;
case IR::RealType: opcode = V4Instr::ConvertRealToString; break;
case IR::UrlType: opcode = V4Instr::ConvertUrlToString; break;
+ case IR::ColorType: opcode = V4Instr::ConvertColorToString; break;
default: break;
} // switch
} else if (targetTy == IR::UrlType) {
@@ -920,11 +932,17 @@ void QV4CompilerPrivate::visitMove(IR::Move *s)
case IR::BoolType: gen(V4Instr::ConvertBoolToString, convToString); sourceTy = IR::StringType; break;
case IR::IntType: gen(V4Instr::ConvertIntToString, convToString); sourceTy = IR::StringType; break;
case IR::RealType: gen(V4Instr::ConvertRealToString, convToString); sourceTy = IR::StringType; break;
+ case IR::ColorType: gen(V4Instr::ConvertColorToString, convToString); sourceTy = IR::StringType; break;
default: break;
} // switch
if (sourceTy == IR::StringType)
opcode = V4Instr::ConvertStringToUrl;
+ } else if (targetTy == IR::ColorType) {
+ switch (sourceTy) {
+ case IR::StringType: opcode = V4Instr::ConvertStringToColor; break;
+ default: break;
+ } // switch
}
if (opcode != V4Instr::Noop) {
V4Instr conv;
@@ -989,6 +1007,9 @@ void QV4CompilerPrivate::visitRet(IR::Ret *s)
case IR::UrlType:
test.regType = QMetaType::QUrl;
break;
+ case IR::ColorType:
+ test.regType = QMetaType::QColor;
+ break;
case IR::SGAnchorLineType:
test.regType = QQmlMetaType::QQuickAnchorLineMetaTypeId();
break;
@@ -1119,7 +1140,7 @@ bool QV4CompilerPrivate::compile(QQmlJS::AST::Node *node)
qerr << endl;
}
- if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF)
+ if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF || registerCount > 31)
return false;
return true;
diff --git a/src/qml/qml/v4/qv4compiler_p_p.h b/src/qml/qml/v4/qv4compiler_p_p.h
index 4b74a1d1c5..a9209d978f 100644
--- a/src/qml/qml/v4/qv4compiler_p_p.h
+++ b/src/qml/qml/v4/qv4compiler_p_p.h
@@ -231,6 +231,7 @@ private:
void discard() { _discarded = true; }
bool _discarded;
quint8 currentReg;
+ quint8 registerCount;
bool usedSubscriptionIdsChanged;
quint32 currentBlockMask;
diff --git a/src/qml/qml/v4/qv4instruction.cpp b/src/qml/qml/v4/qv4instruction.cpp
index 08b2570747..efbd2b2c1c 100644
--- a/src/qml/qml/v4/qv4instruction.cpp
+++ b/src/qml/qml/v4/qv4instruction.cpp
@@ -171,12 +171,21 @@ void Bytecode::dump(const V4Instr *i, int address) const
case V4Instr::ConvertStringToUrl:
INSTR_DUMP << "\t" << "ConvertStringToUrl" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
+ case V4Instr::ConvertStringToColor:
+ INSTR_DUMP << "\t" << "ConvertStringToColor" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
case V4Instr::ConvertUrlToBool:
INSTR_DUMP << "\t" << "ConvertUrlToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
case V4Instr::ConvertUrlToString:
INSTR_DUMP << "\t" << "ConvertUrlToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
+ case V4Instr::ConvertColorToBool:
+ INSTR_DUMP << "\t" << "ConvertColorToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertColorToString:
+ INSTR_DUMP << "\t" << "ConvertColorToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
case V4Instr::ResolveUrl:
INSTR_DUMP << "\t" << "ResolveUrl" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
diff --git a/src/qml/qml/v4/qv4instruction_p.h b/src/qml/qml/v4/qv4instruction_p.h
index 8150eedf54..964c95513f 100644
--- a/src/qml/qml/v4/qv4instruction_p.h
+++ b/src/qml/qml/v4/qv4instruction_p.h
@@ -92,8 +92,11 @@ QT_BEGIN_NAMESPACE
F(ConvertStringToInt, unaryop) \
F(ConvertStringToReal, unaryop) \
F(ConvertStringToUrl, unaryop) \
+ F(ConvertStringToColor, unaryop) \
F(ConvertUrlToBool, unaryop) \
F(ConvertUrlToString, unaryop) \
+ F(ConvertColorToBool, unaryop) \
+ F(ConvertColorToString, unaryop) \
F(ResolveUrl, unaryop) \
F(MathSinReal, unaryop) \
F(MathCosReal, unaryop) \
diff --git a/src/qml/qml/v4/qv4ir.cpp b/src/qml/qml/v4/qv4ir.cpp
index be822145a4..3b33898cd1 100644
--- a/src/qml/qml/v4/qv4ir.cpp
+++ b/src/qml/qml/v4/qv4ir.cpp
@@ -59,6 +59,7 @@ inline const char *typeName(Type t)
case VoidType: return "void";
case StringType: return "string";
case UrlType: return "url";
+ case ColorType: return "color";
case SGAnchorLineType: return "SGAnchorLine";
case AttachType: return "AttachType";
case ObjectType: return "object";
@@ -77,7 +78,7 @@ inline bool isNumberType(IR::Type ty)
inline bool isStringType(IR::Type ty)
{
- return ty == IR::StringType || ty == IR::UrlType;
+ return ty == IR::StringType || ty == IR::UrlType || ty == IR::ColorType;
}
IR::Type maxType(IR::Type left, IR::Type right)
diff --git a/src/qml/qml/v4/qv4ir_p.h b/src/qml/qml/v4/qv4ir_p.h
index 48a08adf9f..e80c7e2869 100644
--- a/src/qml/qml/v4/qv4ir_p.h
+++ b/src/qml/qml/v4/qv4ir_p.h
@@ -142,6 +142,7 @@ enum Type {
VoidType,
StringType,
UrlType,
+ ColorType,
SGAnchorLineType,
AttachType,
ObjectType,
diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp
index 1956be8e72..0efb2686df 100644
--- a/src/qml/qml/v4/qv4irbuilder.cpp
+++ b/src/qml/qml/v4/qv4irbuilder.cpp
@@ -70,6 +70,9 @@ static IR::Type irTypeFromVariantType(int t, QQmlEnginePrivate *engine, const QM
case QMetaType::QUrl:
return IR::UrlType;
+ case QMetaType::QColor:
+ return IR::ColorType;
+
default:
if (t == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
return IR::SGAnchorLineType;
@@ -438,7 +441,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
QQmlPropertyData *data = cache->property(name);
- if (data && data->revision != 0) {
+ if (data && data->hasRevision()) {
if (qmlVerboseCompiler())
qWarning() << "*** versioned symbol:" << name;
discard();
@@ -459,7 +462,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
QQmlPropertyData *data = cache->property(name);
- if (data && data->revision != 0) {
+ if (data && data->hasRevision()) {
if (qmlVerboseCompiler())
qWarning() << "*** versioned symbol:" << name;
discard();
@@ -610,7 +613,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast)
if (!data || data->isFunction())
return false; // Don't support methods (or non-existing properties ;)
- if (data->revision != 0) {
+ if (data->hasRevision()) {
if (qmlVerboseCompiler())
qWarning() << "*** versioned symbol:" << name;
discard();
diff --git a/src/qml/qml/v4/qv4program_p.h b/src/qml/qml/v4/qv4program_p.h
index b6b03e438b..d23cc6192f 100644
--- a/src/qml/qml/v4/qv4program_p.h
+++ b/src/qml/qml/v4/qv4program_p.h
@@ -96,6 +96,7 @@ enum QQmlRegisterType {
QStringType = FirstCleanupType,
QUrlType,
QVariantType,
+ QColorType
};
const char *QV4Program::data() const
diff --git a/src/qml/qml/v8/qjsconverter_p.h b/src/qml/qml/v8/qjsconverter_p.h
index 29fef3c700..d85f9aa0cf 100644
--- a/src/qml/qml/v8/qjsconverter_p.h
+++ b/src/qml/qml/v8/qjsconverter_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qjsengine.h b/src/qml/qml/v8/qjsengine.h
index 1521c752d4..fa2584bf81 100644
--- a/src/qml/qml/v8/qjsengine.h
+++ b/src/qml/qml/v8/qjsengine.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qjsengine_p.h b/src/qml/qml/v8/qjsengine_p.h
index ecd5f7cc86..9866aa84b9 100644
--- a/src/qml/qml/v8/qjsengine_p.h
+++ b/src/qml/qml/v8/qjsengine_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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
-** us via http://www.qt-project.org/.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qjsvalue.h b/src/qml/qml/v8/qjsvalue.h
index 30ea2e7345..209090ed47 100644
--- a/src/qml/qml/v8/qjsvalue.h
+++ b/src/qml/qml/v8/qjsvalue.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
@@ -25,7 +43,6 @@
#define QJSVALUE_H
#include <QtQml/qtqmlglobal.h>
-
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
#include <QtCore/qsharedpointer.h>
@@ -69,7 +86,7 @@ public:
QJSValue(const QString &value);
QJSValue(const QLatin1String &value);
#ifndef QT_NO_CAST_FROM_ASCII
- QT_ASCII_CAST_WARN_CONSTRUCTOR QJSValue(const char *str);
+ QT_ASCII_CAST_WARN QJSValue(const char *str);
#endif
QJSValue &operator=(const QJSValue &other);
diff --git a/src/qml/qml/v8/qjsvalue_impl_p.h b/src/qml/qml/v8/qjsvalue_impl_p.h
index cd33859c50..fbddcfa5ba 100644
--- a/src/qml/qml/v8/qjsvalue_impl_p.h
+++ b/src/qml/qml/v8/qjsvalue_impl_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qjsvalue_p.h b/src/qml/qml/v8/qjsvalue_p.h
index 3eccba64bd..acfe958cb6 100644
--- a/src/qml/qml/v8/qjsvalue_p.h
+++ b/src/qml/qml/v8/qjsvalue_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qjsvalueiterator.h b/src/qml/qml/v8/qjsvalueiterator.h
index c47f07d43b..3c1b450dd8 100644
--- a/src/qml/qml/v8/qjsvalueiterator.h
+++ b/src/qml/qml/v8/qjsvalueiterator.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
@@ -24,6 +42,7 @@
#ifndef QSCRIPTVALUEITERATOR_H
#define QSCRIPTVALUEITERATOR_H
+#include <QtQml/qtqmlglobal.h>
#include <QtQml/qjsvalue.h>
#include <QtCore/qscopedpointer.h>
diff --git a/src/qml/qml/v8/qjsvalueiterator_impl_p.h b/src/qml/qml/v8/qjsvalueiterator_impl_p.h
index 131296ecac..2c060b21a7 100644
--- a/src/qml/qml/v8/qjsvalueiterator_impl_p.h
+++ b/src/qml/qml/v8/qjsvalueiterator_impl_p.h
@@ -5,17 +5,35 @@
**
** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qjsvalueiterator_p.h b/src/qml/qml/v8/qjsvalueiterator_p.h
index 2a5bcdec22..f5f4c44441 100644
--- a/src/qml/qml/v8/qjsvalueiterator_p.h
+++ b/src/qml/qml/v8/qjsvalueiterator_p.h
@@ -5,17 +5,35 @@
**
** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 5284832ae1..7d7aaa2148 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1096,8 +1096,17 @@ v8::Handle<v8::Value> createQmlObject(const v8::Arguments &args)
V8THROW_ERROR("Qt.createQmlObject(): Component is not ready");
QObject *obj = component.beginCreate(effectiveContext);
- if (obj)
+ if (obj) {
QQmlData::get(obj, true)->setImplicitDestructible();
+
+ obj->setParent(parentArg);
+
+ QList<QQmlPrivate::AutoParentFunction> functions = QQmlMetaType::parentFunctions();
+ for (int ii = 0; ii < functions.count(); ++ii) {
+ if (QQmlPrivate::Parented == functions.at(ii)(obj, parentArg))
+ break;
+ }
+ }
component.completeCreate();
if (component.isError()) {
@@ -1107,14 +1116,6 @@ v8::Handle<v8::Value> createQmlObject(const v8::Arguments &args)
Q_ASSERT(obj);
- obj->setParent(parentArg);
-
- QList<QQmlPrivate::AutoParentFunction> functions = QQmlMetaType::parentFunctions();
- for (int ii = 0; ii < functions.count(); ++ii) {
- if (QQmlPrivate::Parented == functions.at(ii)(obj, parentArg))
- break;
- }
-
return v8engine->newQObject(obj);
}
diff --git a/src/qml/qml/v8/qscript_impl_p.h b/src/qml/qml/v8/qscript_impl_p.h
index fdbf2f0097..d4acc4502a 100644
--- a/src/qml/qml/v8/qscript_impl_p.h
+++ b/src/qml/qml/v8/qscript_impl_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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
-** us via http://www.qt-project.org/.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qscriptisolate_p.h b/src/qml/qml/v8/qscriptisolate_p.h
index 4afa74756f..77848557a4 100644
--- a/src/qml/qml/v8/qscriptisolate_p.h
+++ b/src/qml/qml/v8/qscriptisolate_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qscriptoriginalglobalobject_p.h b/src/qml/qml/v8/qscriptoriginalglobalobject_p.h
index 12321cc71a..e4661c1bf2 100644
--- a/src/qml/qml/v8/qscriptoriginalglobalobject_p.h
+++ b/src/qml/qml/v8/qscriptoriginalglobalobject_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qscriptshareddata_p.h b/src/qml/qml/v8/qscriptshareddata_p.h
index df95b26206..d3491c70ee 100644
--- a/src/qml/qml/v8/qscriptshareddata_p.h
+++ b/src/qml/qml/v8/qscriptshareddata_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qscripttools_p.h b/src/qml/qml/v8/qscripttools_p.h
index fcea205f61..d69e9c83ad 100644
--- a/src/qml/qml/v8/qscripttools_p.h
+++ b/src/qml/qml/v8/qscripttools_p.h
@@ -3,19 +3,37 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtScript module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index 4c2cce1525..8e8223fea1 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -75,12 +75,14 @@ static bool ObjectComparisonCallback(v8::Local<v8::Object> lhs, v8::Local<v8::Ob
if (lhs == rhs)
return true;
+ if (lhs.IsEmpty() || rhs.IsEmpty())
+ return false;
+
QV8ObjectResource *lhsr = static_cast<QV8ObjectResource*>(lhs->GetExternalResource());
QV8ObjectResource *rhsr = static_cast<QV8ObjectResource*>(rhs->GetExternalResource());
- Q_ASSERT(lhsr->engine == rhsr->engine);
-
if (lhsr && rhsr) {
+ Q_ASSERT(lhsr->engine == rhsr->engine);
QV8ObjectResource::ResourceType lhst = lhsr->resourceType();
QV8ObjectResource::ResourceType rhst = rhsr->resourceType();
@@ -874,7 +876,7 @@ void QV8Engine::ensurePerThreadIsolate()
perThreadEngineData.setLocalData(new ThreadData);
}
-void QV8Engine::initDeclarativeGlobalObject()
+void QV8Engine::initQmlGlobalObject()
{
v8::HandleScope handels;
v8::Context::Scope contextScope(m_context);
@@ -885,7 +887,7 @@ void QV8Engine::initDeclarativeGlobalObject()
void QV8Engine::setEngine(QQmlEngine *engine)
{
m_engine = engine;
- initDeclarativeGlobalObject();
+ initQmlGlobalObject();
}
void QV8Engine::setException(v8::Handle<v8::Value> value, v8::Handle<v8::Message> msg)
diff --git a/src/qml/qml/v8/qv8engine_impl_p.h b/src/qml/qml/v8/qv8engine_impl_p.h
index ebb21f851c..7173ae4c01 100644
--- a/src/qml/qml/v8/qv8engine_impl_p.h
+++ b/src/qml/qml/v8/qv8engine_impl_p.h
@@ -5,17 +5,35 @@
**
** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL-ONLY$
+** $QT_BEGIN_LICENSE:LGPL$
** 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.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
**
-** If you have questions regarding the use of this file, please contact
-** us via http://www.qt-project.org/.
**
** $QT_END_LICENSE$
**
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 22a8d7599f..bc57b27085 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -283,7 +283,7 @@ public:
inline void pop();
};
- void initDeclarativeGlobalObject();
+ void initQmlGlobalObject();
void setEngine(QQmlEngine *engine);
QQmlEngine *engine() { return m_engine; }
v8::Local<v8::Object> global() { return m_context->Global(); }
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index b84ae339be..78b2cb719c 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -513,7 +513,7 @@ v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject
if (!result)
return v8::Handle<v8::Value>();
- if (revisionMode == QV8QObjectWrapper::CheckRevision && result->revision != 0) {
+ if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) {
QQmlData *ddata = QQmlData::get(object);
if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result))
return v8::Handle<v8::Value>();
@@ -673,7 +673,7 @@ bool QV8QObjectWrapper::SetProperty(QV8Engine *engine, QObject *object, const QH
if (!result)
return false;
- if (revisionMode == QV8QObjectWrapper::CheckRevision && result->revision != 0) {
+ if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) {
QQmlData *ddata = QQmlData::get(object);
if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result))
return false;
diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri
index 9a3b24c328..b8b4e1104c 100644
--- a/src/quick/items/items.pri
+++ b/src/quick/items/items.pri
@@ -65,12 +65,14 @@ HEADERS += \
$$PWD/qquickimplicitsizeitem_p_p.h \
$$PWD/qquickspriteengine_p.h \
$$PWD/qquicksprite_p.h \
- $$PWD/qquickspriteimage_p.h \
+ $$PWD/qquickspritesequence_p.h \
+ $$PWD/qquickanimatedsprite_p.h \
$$PWD/qquickdrag_p.h \
$$PWD/qquickdroparea_p.h \
$$PWD/qquickmultipointtoucharea_p.h \
$$PWD/qquickitemview_p.h \
$$PWD/qquickitemview_p_p.h \
+ $$PWD/qquickitemviewtransition_p.h \
$$PWD/qquickscreen_p.h \
$$PWD/qquickwindowmodule_p.h \
$$PWD/qquickwindowmanager_p.h
@@ -116,12 +118,14 @@ SOURCES += \
$$PWD/qquickimplicitsizeitem.cpp \
$$PWD/qquickspriteengine.cpp \
$$PWD/qquicksprite.cpp \
- $$PWD/qquickspriteimage.cpp \
+ $$PWD/qquickspritesequence.cpp \
+ $$PWD/qquickanimatedsprite.cpp \
$$PWD/qquickaccessibleattached.cpp \
$$PWD/qquickdrag.cpp \
$$PWD/qquickdroparea.cpp \
$$PWD/qquickmultipointtoucharea.cpp \
$$PWD/qquickitemview.cpp \
+ $$PWD/qquickitemviewtransition.cpp \
$$PWD/qquickwindowmodule.cpp \
$$PWD/qquickscreen.cpp \
$$PWD/qquickwindowmanager.cpp
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
new file mode 100644
index 0000000000..618178fd1c
--- /dev/null
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -0,0 +1,613 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickanimatedsprite_p.h"
+#include "qquicksprite_p.h"
+#include "qquickspriteengine_p.h"
+#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgengine.h>
+#include <QtQuick/qsgtexturematerial.h>
+#include <QtQuick/qsgtexture.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QtQml/qqmlinfo.h>
+#include <QFile>
+#include <cmath>
+#include <qmath.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+static const char vertexShaderCode[] =
+ "attribute highp vec2 vTex;\n"
+ "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n"
+ "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n"
+ "uniform highp vec2 size;//w,h of element\n"
+ "\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "\n"
+ "void main() {\n"
+ " progress = animData.z;\n"
+ " //Calculate frame location in texture\n"
+ " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n"
+ " //Next frame is also passed, for interpolation\n"
+ " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n"
+ "\n"
+ " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n"
+ "}\n";
+
+static const char fragmentShaderCode[] =
+ "uniform sampler2D texture;\n"
+ "uniform lowp float qt_Opacity;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "void main() {\n"
+ " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n"
+ "}\n";
+
+class QQuickAnimatedSpriteMaterial : public QSGMaterial
+{
+public:
+ QQuickAnimatedSpriteMaterial();
+ ~QQuickAnimatedSpriteMaterial();
+ virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; }
+ virtual QSGMaterialShader *createShader() const;
+ virtual int compare(const QSGMaterial *other) const
+ {
+ return this - static_cast<const QQuickAnimatedSpriteMaterial *>(other);
+ }
+
+ QSGTexture *texture;
+
+ float animT;
+ float animX1;
+ float animY1;
+ float animX2;
+ float animY2;
+ float animW;
+ float animH;
+ float elementWidth;
+ float elementHeight;
+};
+
+QQuickAnimatedSpriteMaterial::QQuickAnimatedSpriteMaterial()
+ : texture(0)
+ , animT(0.0f)
+ , animX1(0.0f)
+ , animY1(0.0f)
+ , animX2(0.0f)
+ , animY2(0.0f)
+ , animW(1.0f)
+ , animH(1.0f)
+ , elementWidth(1.0f)
+ , elementHeight(1.0f)
+{
+ setFlag(Blending, true);
+}
+
+QQuickAnimatedSpriteMaterial::~QQuickAnimatedSpriteMaterial()
+{
+ delete texture;
+}
+
+class AnimatedSpriteMaterialData : public QSGMaterialShader
+{
+public:
+ AnimatedSpriteMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0)
+ {
+ }
+
+ void deactivate() {
+ QSGMaterialShader::deactivate();
+
+ for (int i=0; i<8; ++i) {
+ program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0);
+ }
+ }
+
+ virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *)
+ {
+ QQuickAnimatedSpriteMaterial *m = static_cast<QQuickAnimatedSpriteMaterial *>(newEffect);
+ m->texture->bind();
+
+ program()->setUniformValue(m_opacity_id, state.opacity());
+ program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT);
+ program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2);
+ program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight);
+
+ if (state.isMatrixDirty())
+ program()->setUniformValue(m_matrix_id, state.combinedMatrix());
+ }
+
+ virtual void initialize() {
+ m_matrix_id = program()->uniformLocation("qt_Matrix");
+ m_opacity_id = program()->uniformLocation("qt_Opacity");
+ m_animData_id = program()->uniformLocation("animData");
+ m_animPos_id = program()->uniformLocation("animPos");
+ m_size_id = program()->uniformLocation("size");
+ }
+
+ virtual const char *vertexShader() const { return vertexShaderCode; }
+ virtual const char *fragmentShader() const { return fragmentShaderCode; }
+
+ virtual char const *const *attributeNames() const {
+ static const char *attr[] = {
+ "vTex",
+ 0
+ };
+ return attr;
+ }
+
+ int m_matrix_id;
+ int m_opacity_id;
+ int m_animData_id;
+ int m_animPos_id;
+ int m_size_id;
+
+ static float chunkOfBytes[1024];
+};
+
+float AnimatedSpriteMaterialData::chunkOfBytes[1024];
+
+QSGMaterialShader *QQuickAnimatedSpriteMaterial::createShader() const
+{
+ return new AnimatedSpriteMaterialData;
+}
+
+struct AnimatedSpriteVertex {
+ float tx;
+ float ty;
+};
+
+struct AnimatedSpriteVertices {
+ AnimatedSpriteVertex v1;
+ AnimatedSpriteVertex v2;
+ AnimatedSpriteVertex v3;
+ AnimatedSpriteVertex v4;
+};
+
+/*!
+ \qmlclass AnimatedSprite QQuickAnimatedSprite
+ \inqmlmodule QtQuick 2
+ \inherits Item
+ \brief The AnimatedSprite element draws a sprite animation
+*/
+
+/*!
+ \qmlproperty bool QtQuick2::AnimatedSprite::running
+
+ Whether the sprite is animating or not.
+
+ Default is true
+*/
+
+/*!
+ \qmlproperty bool QtQuick2::AnimatedSprite::interpolate
+
+ If true, interpolation will occur between sprite frames to make the
+ animation appear smoother.
+
+ Default is true.
+*/
+
+/*!
+ \qmlproperty qreal QtQuick2::AnimatedSprite::frameRate
+
+ Frames per second to show in the animation. Values below 0 are invalid.
+
+ If frameRate is valid then it will be used to calculate the duration of the frames.
+ If not, and frameDuration is valid , then frameDuration will be used.
+*/
+
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::frameDuration
+
+ Duration of each frame of the animation. Values below 0 are invalid.
+
+ If frameRate is valid then it will be used to calculate the duration of the frames.
+ If not, and frameDuration is valid, then frameDuration will be used.
+*/
+
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::frameCount
+
+ Number of frames in this AnimatedSprite.
+*/
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::frameHeight
+
+ Height of a single frame in this AnimatedSprite.
+
+ May be omitted if it is the only sprite in the file.
+*/
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::frameWidth
+
+ Width of a single frame in this AnimatedSprite.
+
+ May be omitted if it is the only sprite in the file.
+*/
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::frameX
+
+ The X coordinate in the image file of the first frame of the AnimatedSprite.
+
+ May be omitted if the first frame starts in the upper left corner of the file.
+*/
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::frameY
+
+ The Y coordinate in the image file of the first frame of the AnimatedSprite.
+
+ May be omitted if the first frame starts in the upper left corner of the file.
+*/
+/*!
+ \qmlproperty url QtQuick2::AnimatedSprite::source
+
+ The image source for the animation.
+
+ If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames.
+ Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used.
+
+ If frameX and frameY are specified, the row of frames will be taken with that x/y coordinate as the upper left corner.
+*/
+
+/*!
+ \qmlproperty bool QtQuick2::AnimatedSprite::reverse
+
+ If true, then the animation will be played in reverse.
+
+ Default is false.
+*/
+
+/*!
+ \qmlproperty bool QtQuick2::AnimatedSprite::frameSync
+
+ If true, then the animation will have no duration. Instead, the animation will advance
+ one frame each time a frame is rendered to the screen. This syncronizes it with the painting
+ rate as opposed to elapsed time.
+
+ If frameSync is set to true, it overrides both frameRate and frameDuration.
+
+ Default is false.
+*/
+
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::loops
+
+ After playing the animation this many times, the animation will automatically stop. Negative values are invalid.
+
+ If this is set to AnimatedSprite.Infinite the animation will not stop playing on its own.
+
+ Default is AnimatedSprite.Infinite
+*/
+
+/*!
+ \qmlproperty bool QtQuick2::AnimatedSprite::paused
+
+ When paused, the current frame can be advanced manually.
+
+ Default is false.
+*/
+
+/*!
+ \qmlproperty int QtQuick2::AnimatedSprite::currentFrame
+
+ When paused, the current frame can be advanced manually by setting this property or calling advance().
+
+*/
+
+//TODO: Implicitly size element to size of sprite
+QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :
+ QQuickItem(parent)
+ , m_node(0)
+ , m_material(0)
+ , m_sprite(new QQuickSprite)
+ , m_spriteEngine(0)
+ , m_curFrame(0)
+ , m_pleaseReset(false)
+ , m_running(true)
+ , m_paused(false)
+ , m_interpolate(true)
+ , m_loops(-1)
+ , m_curLoop(0)
+ , m_pauseOffset(0)
+{
+ setFlag(ItemHasContents);
+ connect(this, SIGNAL(runningChanged(bool)),
+ this, SLOT(update()));
+}
+
+void QQuickAnimatedSprite::reloadImage()
+{
+ if (!isComponentComplete())
+ return;
+ createEngine();//### It's not as inefficient as it sounds, but it still sucks having to recreate the engine
+}
+
+void QQuickAnimatedSprite::componentComplete()
+{
+ createEngine();
+ QQuickItem::componentComplete();
+ if (m_running)
+ start();
+}
+
+void QQuickAnimatedSprite::start()
+{
+ if (m_running)
+ return;
+ m_curLoop = 0;
+ m_timestamp.start();
+ m_running = true;
+ emit runningChanged(true);
+ update();
+}
+
+void QQuickAnimatedSprite::stop()
+{
+ if (!m_running)
+ return;
+ m_running = false;
+ emit runningChanged(false);
+}
+
+void QQuickAnimatedSprite::advance(int frames)
+{
+ if (!frames)
+ return;
+ //TODO-C: May not work when running - only when paused
+ m_curFrame += frames;
+ while (m_curFrame < 0)
+ m_curFrame += m_sprite->frames();
+ m_curFrame = m_curFrame % m_sprite->frames();
+ emit currentFrameChanged(m_curFrame);
+}
+
+void QQuickAnimatedSprite::pause()
+{
+ if (m_paused)
+ return;
+ m_pauseOffset = m_timestamp.elapsed();
+ m_paused = true;
+ emit pausedChanged(true);
+}
+
+void QQuickAnimatedSprite::resume()
+{
+ if (!m_paused)
+ return;
+ m_pauseOffset = m_pauseOffset - m_timestamp.elapsed();
+ m_paused = false;
+ emit pausedChanged(false);
+}
+
+void QQuickAnimatedSprite::createEngine()
+{
+ if (m_spriteEngine)
+ delete m_spriteEngine;
+ QList<QQuickSprite*> spriteList;
+ spriteList << m_sprite;
+ m_spriteEngine = new QQuickSpriteEngine(QList<QQuickSprite*>(spriteList), this);
+ m_spriteEngine->startAssemblingImage();
+ reset();
+}
+
+static QSGGeometry::Attribute AnimatedSprite_Attributes[] = {
+ QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex
+};
+
+static QSGGeometry::AttributeSet AnimatedSprite_AttributeSet =
+{
+ 1, // Attribute Count
+ 2 * sizeof(float),
+ AnimatedSprite_Attributes
+};
+
+QSGGeometryNode* QQuickAnimatedSprite::buildNode()
+{
+ if (!m_spriteEngine) {
+ qmlInfo(this) << "No sprite engine...";
+ return 0;
+ } else if (m_spriteEngine->status() == QQuickPixmap::Null) {
+ m_spriteEngine->startAssemblingImage();
+ update();//Schedule another update, where we will check again
+ return 0;
+ } else if (m_spriteEngine->status() == QQuickPixmap::Loading) {
+ update();//Schedule another update, where we will check again
+ return 0;
+ }
+
+ m_material = new QQuickAnimatedSpriteMaterial();
+
+ QImage image = m_spriteEngine->assembledImage();
+ if (image.isNull())
+ return 0;
+ m_sheetSize = QSizeF(image.size());
+ m_material->texture = canvas()->createTextureFromImage(image);
+ m_material->texture->setFiltering(QSGTexture::Linear);
+ m_spriteEngine->start(0);
+ m_material->animT = 0;
+ m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width();
+ m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height();
+ m_material->animX2 = m_material->animX1;
+ m_material->animY2 = m_material->animY1;
+ m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width();
+ m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height();
+ m_material->elementWidth = width();
+ m_material->elementHeight = height();
+
+ int vCount = 4;
+ int iCount = 6;
+ QSGGeometry *g = new QSGGeometry(AnimatedSprite_AttributeSet, vCount, iCount);
+ g->setDrawingMode(GL_TRIANGLES);
+
+ AnimatedSpriteVertices *p = (AnimatedSpriteVertices *) g->vertexData();
+
+ p->v1.tx = 0;
+ p->v1.ty = 0;
+
+ p->v2.tx = 1.0;
+ p->v2.ty = 0;
+
+ p->v3.tx = 0;
+ p->v3.ty = 1.0;
+
+ p->v4.tx = 1.0;
+ p->v4.ty = 1.0;
+
+ quint16 *indices = g->indexDataAsUShort();
+ indices[0] = 0;
+ indices[1] = 1;
+ indices[2] = 2;
+ indices[3] = 1;
+ indices[4] = 3;
+ indices[5] = 2;
+
+
+ m_timestamp.start();
+ m_node = new QSGGeometryNode();
+ m_node->setGeometry(g);
+ m_node->setMaterial(m_material);
+ m_node->setFlag(QSGGeometryNode::OwnsMaterial);
+ return m_node;
+}
+
+void QQuickAnimatedSprite::reset()
+{
+ m_pleaseReset = true;
+}
+
+QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *, UpdatePaintNodeData *)
+{
+ if (m_pleaseReset) {
+ delete m_node;
+
+ m_node = 0;
+ m_material = 0;
+ m_pleaseReset = false;
+ }
+
+ prepareNextFrame();
+
+ if (m_running) {
+ update();
+ if (m_node)
+ m_node->markDirty(QSGNode::DirtyMaterial);
+ }
+
+ return m_node;
+}
+
+void QQuickAnimatedSprite::prepareNextFrame()
+{
+ if (m_node == 0)
+ m_node = buildNode();
+ if (m_node == 0) //error creating node
+ return;
+
+ uint timeInt = m_timestamp.elapsed() + m_pauseOffset;
+ qreal time = timeInt / 1000.;
+ m_material->elementHeight = height();
+ m_material->elementWidth = width();
+
+ double frameAt; //double just for modf
+ qreal progress;
+ if (!m_paused) {
+ //Advance State (keeps time for psuedostates)
+ m_spriteEngine->updateSprites(timeInt);
+
+ //Advance AnimatedSprite
+ qreal animT = m_spriteEngine->spriteStart()/1000.0;
+ qreal frameCount = m_spriteEngine->spriteFrames();
+ qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount;
+ if (frameDuration > 0) {
+ qreal frame = (time - animT)/(frameDuration / 1000.0);
+ frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation
+ progress = modf(frame,&frameAt);
+ if (m_curFrame > frameAt) //went around
+ m_curLoop++;
+ m_curFrame = frameAt;
+ } else {
+ m_curFrame++;
+ if (m_curFrame >= frameCount){
+ m_curFrame = 0;
+ m_curLoop++;
+ m_spriteEngine->advance();
+ }
+ frameAt = m_curFrame;
+ progress = 0;
+ }
+ if (m_loops > 0 && m_curLoop >= m_loops) {
+ frameAt = 0;
+ m_running = false;
+ }
+ } else {
+ frameAt = m_curFrame;
+ }
+ if (m_spriteEngine->sprite()->reverse())
+ frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt;
+ qreal y = m_spriteEngine->spriteY() / m_sheetSize.height();
+ qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width();
+ qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height();
+ qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width();
+ x1 += frameAt * w;
+ qreal x2 = x1;
+ if (frameAt < (m_spriteEngine->spriteFrames()-1))
+ x2 += w;
+
+ m_material->animX1 = x1;
+ m_material->animY1 = y;
+ m_material->animX2 = x2;
+ m_material->animY2 = y;
+ m_material->animW = w;
+ m_material->animH = h;
+ m_material->animT = m_interpolate ? progress : 0.0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
new file mode 100644
index 0000000000..708f94b7ec
--- /dev/null
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKANIMATEDSPRITE_P_H
+#define QQUICKANIMATEDSPRITE_P_H
+
+#include <QtQuick/QQuickItem>
+#include <private/qquicksprite_p.h>
+#include <QTime>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QSGContext;
+class QQuickSprite;
+class QQuickSpriteEngine;
+class QSGGeometryNode;
+class QQuickAnimatedSpriteMaterial;
+class Q_AUTOTEST_EXPORT QQuickAnimatedSprite : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged)
+ //###try to share similar spriteEngines for less overhead?
+ //These properties come out of QQuickSprite, since a SimpleSpriteImage is a renderer for a single sprite
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged)
+ Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged)
+ Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged)
+ //If frame height or width is not specified, it is assumed to be a single long row of square frames.
+ //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
+ Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
+ Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
+ Q_PROPERTY(int frameX READ frameX WRITE setFrameX NOTIFY frameXChanged)
+ Q_PROPERTY(int frameY READ frameY WRITE setFrameY NOTIFY frameYChanged)
+ //Precedence order: frameRate, frameDuration
+ Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged RESET resetFrameRate)
+ Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration)
+ //Extra Simple Sprite Stuff
+ Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged)
+ Q_PROPERTY(bool paused READ paused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged)
+
+ Q_ENUMS(LoopParameters)
+public:
+ explicit QQuickAnimatedSprite(QQuickItem *parent = 0);
+ enum LoopParameters {
+ Infinite = -1
+ };
+
+ bool running() const
+ {
+ return m_running;
+ }
+
+ bool interpolate() const
+ {
+ return m_interpolate;
+ }
+
+ QUrl source() const
+ {
+ return m_sprite->source();
+ }
+
+ bool reverse() const
+ {
+ return m_sprite->reverse();
+ }
+
+ bool frameSync() const
+ {
+ return m_sprite->frameSync();
+ }
+
+ int frameCount() const
+ {
+ return m_sprite->frames();
+ }
+
+ int frameHeight() const
+ {
+ return m_sprite->frameHeight();
+ }
+
+ int frameWidth() const
+ {
+ return m_sprite->frameWidth();
+ }
+
+ int frameX() const
+ {
+ return m_sprite->frameX();
+ }
+
+ int frameY() const
+ {
+ return m_sprite->frameY();
+ }
+
+ qreal frameRate() const
+ {
+ return m_sprite->frameRate();
+ }
+
+ int frameDuration() const
+ {
+ return m_sprite->frameDuration();
+ }
+
+ int loops() const
+ {
+ return m_loops;
+ }
+
+ bool paused() const
+ {
+ return m_paused;
+ }
+
+ int currentFrame() const
+ {
+ return m_curFrame;
+ }
+
+signals:
+
+ void pausedChanged(bool arg);
+ void runningChanged(bool arg);
+ void interpolateChanged(bool arg);
+
+ void sourceChanged(QUrl arg);
+
+ void reverseChanged(bool arg);
+
+ void frameSyncChanged(bool arg);
+
+ void frameCountChanged(int arg);
+
+ void frameHeightChanged(int arg);
+
+ void frameWidthChanged(int arg);
+
+ void frameXChanged(int arg);
+
+ void frameYChanged(int arg);
+
+ void frameRateChanged(qreal arg);
+
+ void frameDurationChanged(int arg);
+
+ void loopsChanged(int arg);
+
+ void currentFrameChanged(int arg);
+
+public slots:
+ void start();
+ void stop();
+ void restart() {stop(); start();}
+ void advance(int frames=1);
+ void pause();
+ void resume();
+
+ void setRunning(bool arg)
+ {
+ if (m_running != arg) {
+ if (m_running)
+ stop();
+ else
+ start();
+ }
+ }
+
+ void setPaused(bool arg)
+ {
+ if (m_paused != arg) {
+ if (m_paused)
+ resume();
+ else
+ pause();
+ }
+ }
+
+ void setInterpolate(bool arg)
+ {
+ if (m_interpolate != arg) {
+ m_interpolate = arg;
+ emit interpolateChanged(arg);
+ }
+ }
+
+ void setSource(QUrl arg)
+ {
+ if (m_sprite->m_source != arg) {
+ m_sprite->setSource(arg);
+ emit sourceChanged(arg);
+ }
+ }
+
+ void setReverse(bool arg)
+ {
+ if (m_sprite->m_reverse != arg) {
+ m_sprite->setReverse(arg);
+ emit reverseChanged(arg);
+ }
+ }
+
+ void setFrameSync(bool arg)
+ {
+ if (m_sprite->m_frameSync != arg) {
+ m_sprite->setFrameSync(arg);
+ emit frameSyncChanged(arg);
+ }
+ }
+
+ void setFrameCount(int arg)
+ {
+ if (m_sprite->m_frames != arg) {
+ m_sprite->setFrameCount(arg);
+ emit frameCountChanged(arg);
+ reloadImage();
+ }
+ }
+
+ void setFrameHeight(int arg)
+ {
+ if (m_sprite->m_frameHeight != arg) {
+ m_sprite->setFrameHeight(arg);
+ emit frameHeightChanged(arg);
+ reloadImage();
+ }
+ }
+
+ void setFrameWidth(int arg)
+ {
+ if (m_sprite->m_frameWidth != arg) {
+ m_sprite->setFrameWidth(arg);
+ emit frameWidthChanged(arg);
+ reloadImage();
+ }
+ }
+
+ void setFrameX(int arg)
+ {
+ if (m_sprite->m_frameX != arg) {
+ m_sprite->setFrameX(arg);
+ emit frameXChanged(arg);
+ reloadImage();
+ }
+ }
+
+ void setFrameY(int arg)
+ {
+ if (m_sprite->m_frameY != arg) {
+ m_sprite->setFrameY(arg);
+ emit frameYChanged(arg);
+ reloadImage();
+ }
+ }
+
+ void setFrameRate(qreal arg)
+ {
+ if (m_sprite->m_frameRate != arg) {
+ m_sprite->setFrameRate(arg);
+ emit frameRateChanged(arg);
+ }
+ }
+
+ void setFrameDuration(int arg)
+ {
+ if (m_sprite->m_frameDuration != arg) {
+ m_sprite->setFrameDuration(arg);
+ emit frameDurationChanged(arg);
+ }
+ }
+
+ void resetFrameRate()
+ {
+ setFrameRate(-1.0);
+ }
+
+ void resetFrameDuration()
+ {
+ setFrameDuration(-1);
+ }
+
+ void setLoops(int arg)
+ {
+ if (m_loops != arg) {
+ m_loops = arg;
+ emit loopsChanged(arg);
+ }
+ }
+
+ void setCurrentFrame(int arg) //TODO-C: Probably only works when paused
+ {
+ if (m_curFrame != arg) {
+ m_curFrame = arg;
+ emit currentFrameChanged(arg); //TODO-C Only emitted on manual advance!
+ }
+ }
+
+
+private slots:
+ void createEngine();
+protected:
+ void reset();
+ void componentComplete();
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+private:
+ void prepareNextFrame();
+ void reloadImage();
+ QSGGeometryNode* buildNode();
+ QSGGeometryNode *m_node;
+ QQuickAnimatedSpriteMaterial *m_material;
+ QQuickSprite* m_sprite;
+ QQuickSpriteEngine* m_spriteEngine;
+ QTime m_timestamp;
+ int m_curFrame;
+ bool m_pleaseReset;
+ bool m_running;
+ bool m_paused;
+ bool m_interpolate;
+ QSizeF m_sheetSize;
+ int m_loops;
+ int m_curLoop;
+ int m_pauseOffset;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKANIMATEDSPRITE_P_H
diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp
index 1e1db18723..92a422a56d 100644
--- a/src/quick/items/qquickcanvas.cpp
+++ b/src/quick/items/qquickcanvas.cpp
@@ -94,11 +94,10 @@ protected:
{
if (e->type() == QEvent::User) {
Q_ASSERT(m_eventSent);
-
- bool *amtp = m_canvas->windowManager->allowMainThreadProcessing();
+ volatile bool *amtp = m_canvas->windowManager->allowMainThreadProcessing();
while (incubatingObjectCount()) {
if (amtp)
- incubateWhile(amtp);
+ incubateWhile(amtp, 2);
else
incubateFor(5);
QCoreApplication::processEvents();
@@ -115,6 +114,8 @@ protected:
m_eventSent = true;
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
+ // If no animations are running, the renderer may be waiting
+ m_canvas->windowManager->wakeup();
}
private:
@@ -377,25 +378,36 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event)
QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonDblClick, p);
me.setTimestamp(event->timestamp());
me.setAccepted(false);
- deliverMouseEvent(&me);
- if (me.isAccepted()) {
- touchMouseId = p.id();
- event->setAccepted(true);
+ me.setCapabilities(event->device()->capabilities());
+ if (!mouseGrabberItem) {
+ if (deliverInitialMousePressEvent(rootItem, &me)) {
+ touchMouseId = p.id();
+ event->setAccepted(true);
+ }
+ } else {
+ deliverMouseEvent(&me);
+ if (me.isAccepted()) {
+ touchMouseId = p.id();
+ event->setAccepted(true);
+ }
}
}
QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonPress, p);
me.setTimestamp(event->timestamp());
me.setAccepted(false);
+ me.setCapabilities(event->device()->capabilities());
deliverMouseEvent(&me);
if (me.isAccepted()) {
touchMouseId = p.id();
event->setAccepted(true);
- break;
}
+ if (touchMouseId != -1)
+ break;
} else if (p.id() == touchMouseId) {
if (p.state() & Qt::TouchPointMoved) {
QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseMove, p);
me.setTimestamp(event->timestamp());
+ me.setCapabilities(event->device()->capabilities());
if (!mouseGrabberItem) {
if (lastMousePosition.isNull())
lastMousePosition = me.windowPos();
@@ -419,6 +431,7 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event)
return;
QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonRelease, p);
me.setTimestamp(event->timestamp());
+ me.setCapabilities(event->device()->capabilities());
deliverMouseEvent(&me);
mouseGrabberItem = 0;
}
@@ -746,6 +759,7 @@ QQuickCanvas::~QQuickCanvas()
QQuickItemPrivate *rootItemPrivate = QQuickItemPrivate::get(d->rootItem);
rootItemPrivate->removeFromDirtyList();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
delete d->incubationController; d->incubationController = 0;
delete d->rootItem; d->rootItem = 0;
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index e69d44303b..6300b0f2a7 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -163,8 +163,11 @@ public:
QQuickMouseEventEx(const QMouseEvent &event)
: QMouseEvent(event)
{
- if (extended(&event))
- setVelocity(extended(&event)->velocity());
+ const QQuickMouseEventEx *eventEx = extended(&event);
+ if (eventEx) {
+ setVelocity(eventEx->velocity());
+ setCapabilities(eventEx->capabilities());
+ }
}
static const QQuickMouseEventEx *extended(const QMouseEvent *e) {
@@ -186,8 +189,15 @@ public:
}
QVector2D velocity() const { return _velocity; }
+ void setCapabilities(QTouchDevice::Capabilities caps) {
+ setExtended();
+ _capabilities = caps;
+ }
+ QTouchDevice::Capabilities capabilities() const { return _capabilities; }
+
private:
QVector2D _velocity;
+ QTouchDevice::Capabilities _capabilities;
};
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index ef67549780..f75ca14989 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -977,7 +977,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
lastPosTime = currentTimestamp;
QQuickMouseEventEx *extended = QQuickMouseEventEx::extended(event);
if (q->yflick() && !rejectY) {
- if (extended) {
+ if (extended && extended->capabilities().testFlag(QTouchDevice::Velocity)) {
vData.addVelocitySample(extended->velocity().y(), maxVelocity);
} else {
qreal dy = event->localPos().y()-lastPos.y();
@@ -985,7 +985,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
}
}
if (q->xflick() && !rejectX) {
- if (extended) {
+ if (extended && extended->capabilities().testFlag(QTouchDevice::Velocity)) {
hData.addVelocitySample(extended->velocity().x(), maxVelocity);
} else {
qreal dx = event->localPos().x()-lastPos.x();
@@ -1022,7 +1022,8 @@ void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event)
qreal vVelocity = 0;
if (elapsed < 100 && vData.velocity != 0.) {
QQuickMouseEventEx *extended = QQuickMouseEventEx::extended(event);
- vVelocity = extended ? extended->velocity().y() : vData.velocity;
+ vVelocity = (extended && extended->capabilities().testFlag(QTouchDevice::Velocity))
+ ? extended->velocity().y() : vData.velocity;
}
if (vData.atBeginning || vData.atEnd) {
vVelocity /= 2;
@@ -1037,7 +1038,8 @@ void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event)
qreal hVelocity = 0;
if (elapsed < 100 && hData.velocity != 0.) {
QQuickMouseEventEx *extended = QQuickMouseEventEx::extended(event);
- hVelocity = extended ? extended->velocity().x() : hData.velocity;
+ hVelocity = (extended && extended->capabilities().testFlag(QTouchDevice::Velocity))
+ ? extended->velocity().x() : hData.velocity;
}
if (hData.atBeginning || hData.atEnd) {
hVelocity /= 2;
@@ -1771,8 +1773,11 @@ bool QQuickFlickable::sendMouseEvent(QMouseEvent *event)
QQuickMouseEventEx mouseEvent(event->type(), mapFromScene(event->windowPos()),
event->windowPos(), event->screenPos(),
event->button(), event->buttons(), event->modifiers());
- if (QQuickMouseEventEx::extended(event))
- mouseEvent.setVelocity(QQuickMouseEventEx::extended(event)->velocity());
+ QQuickMouseEventEx *eventEx = QQuickMouseEventEx::extended(event);
+ if (eventEx) {
+ mouseEvent.setVelocity(eventEx->velocity());
+ mouseEvent.setCapabilities(eventEx->capabilities());
+ }
mouseEvent.setTimestamp(event->timestamp());
mouseEvent.setAccepted(false);
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index a57d0ee778..45fbc9f93e 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -127,9 +127,6 @@ public:
return (x >= itemX() && x < itemX() + view->cellWidth() &&
y >= itemY() && y < itemY() + view->cellHeight());
}
- QQuickItemView *itemView() const {
- return view;
- }
QQuickGridView *view;
@@ -485,7 +482,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d
#endif
if (!(item = static_cast<FxGridItemSG*>(createItem(modelIndex, doBuffer))))
break;
- if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
+ if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
item->setPosition(colPos, rowPos);
item->item->setVisible(!doBuffer);
visibleItems.append(item);
@@ -523,7 +520,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d
if (!(item = static_cast<FxGridItemSG*>(createItem(visibleIndex-1, doBuffer))))
break;
--visibleIndex;
- if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
+ if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
item->setPosition(colPos, rowPos);
item->item->setVisible(!doBuffer);
visibleItems.prepend(item);
@@ -1586,10 +1583,11 @@ void QQuickGridView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::GridView::populate
- This property holds the transition to apply to items that are initially created for a
- view.
- This transition is applied to all the items that are created when:
+ This property holds the transition to apply to the items that are initially created
+ for a view.
+
+ It is applied to all items that are created when:
\list
\o The view is first created
@@ -1619,10 +1617,10 @@ void QQuickGridView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::GridView::add
- This property holds the transition to apply to items that are added within the view.
- The transition is applied to items that have been added to the visible area of the view. For
- example, here is a view that specifies such a transition:
+ This property holds the transition to apply to items that are added to the view.
+
+ For example, here is a view that specifies such a transition:
\code
GridView {
@@ -1636,8 +1634,8 @@ void QQuickGridView::setSnapMode(SnapMode mode)
Whenever an item is added to the above view, the item will be animated from the position (100,100)
to its final x,y position within the view, over one second. The transition only applies to
the new items that are added to the view; it does not apply to the items below that are
- displaced by the addition of the new items. To animate the displaced items, set the \l
- addDisplaced property.
+ displaced by the addition of the new items. To animate the displaced items, set the \l displaced
+ or \l addDisplaced properties.
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
@@ -1651,11 +1649,11 @@ void QQuickGridView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::GridView::addDisplaced
- This property holds the transition to apply to items in the view that are displaced by other
- items that have been added to the view.
- The transition is applied to items that are currently visible and have been displaced by newly
- added items. For example, here is a view that specifies such a transition:
+ This property holds the transition to apply to items within the view that are displaced by
+ the addition of other items to the view.
+
+ For example, here is a view that specifies such a transition:
\code
GridView {
@@ -1673,6 +1671,11 @@ void QQuickGridView::setSnapMode(SnapMode mode)
the new item that has been added to the view; to animate the added items, set the \l add
property.
+ If an item is displaced by multiple types of operations at the same time, it is not defined as to
+ whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally,
+ if it is not necessary to specify different transitions depending on whether an item is displaced
+ by an add, move or remove operation, consider setting the \l displaced property instead.
+
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
@@ -1680,15 +1683,15 @@ void QQuickGridView::setSnapMode(SnapMode mode)
populated, or when the view's \l model changes. In those cases, the \l populate transition is
applied instead.
- \sa add, populate, ViewTransition
+ \sa displaced, add, populate, ViewTransition
*/
/*!
\qmlproperty Transition QtQuick2::GridView::move
- This property holds the transition to apply to items in the view that are moved by a move
- operation.
- The transition is applied to items that are moving within the view or are moving
- into the view as a result of a move operation in the view's model. For example:
+ This property holds the transition to apply to items in the view that are being moved due
+ to a move operation in the view's \l model.
+
+ For example, here is a view that specifies such a transition:
\code
GridView {
@@ -1699,10 +1702,11 @@ void QQuickGridView::setSnapMode(SnapMode mode)
}
\endcode
- Whenever an item is moved within the above view, the item will be animated to its new position in
- the view over one second. The transition only applies to the items that are the subject of the
- move operation in the model; it does not apply to the items below them that are displaced by
- the move operation. To animate the displaced items, set the \l moveDisplaced property.
+ Whenever the \l model performs a move operation to move a particular set of indexes, the
+ respective items in the view will be animated to their new positions in the view over one
+ second. The transition only applies to the items that are the subject of the move operation
+ in the model; it does not apply to items below them that are displaced by the move operation.
+ To animate the displaced items, set the \l displaced or \l moveDisplaced properties.
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
@@ -1712,11 +1716,11 @@ void QQuickGridView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::GridView::moveDisplaced
- This property holds the transition to apply to items in the view that are displaced by a
- move operation in the view.
- The transition is applied to items that are currently visible and have been displaced following
- a move operation in the view's model. For example, here is a view that specifies such a transition:
+ This property holds the transition to apply to items that are displaced by a move operation in
+ the view's \l model.
+
+ For example, here is a view that specifies such a transition:
\code
GridView {
@@ -1727,25 +1731,31 @@ void QQuickGridView::setSnapMode(SnapMode mode)
}
\endcode
- Whenever an item moves within (or moves into) the above view, all items beneath it are
- displaced, causing them to move upwards (or sideways, if horizontally orientated) within the
- view. As this displacement occurs, the items' movement to their new x,y positions within the
- view will be animated by a NumberAnimation over one second, as specified. This transition is
- not applied to the item that are actually the subject of the move operation; to animate the
- moved items, set the \l move property.
+ Whenever the \l model performs a move operation to move a particular set of indexes, the items
+ between the source and destination indexes of the move operation are displaced, causing them
+ to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this
+ displacement occurs, the items' movement to their new x,y positions within the view will be
+ animated by a NumberAnimation over one second, as specified. This transition is not applied to
+ the items that are the actual subjects of the move operation; to animate the moved items, set
+ the \l move property.
+
+ If an item is displaced by multiple types of operations at the same time, it is not defined as to
+ whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally,
+ if it is not necessary to specify different transitions depending on whether an item is displaced
+ by an add, move or remove operation, consider setting the \l displaced property instead.
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
- \sa move, ViewTransition
+ \sa displaced, move, ViewTransition
*/
/*!
\qmlproperty Transition QtQuick2::GridView::remove
+
This property holds the transition to apply to items that are removed from the view.
- The transition is applied to items that have been removed from the visible area of the view. For
- example:
+ For example, here is a view that specifies such a transition:
\code
GridView {
@@ -1762,8 +1772,8 @@ void QQuickGridView::setSnapMode(SnapMode mode)
Whenever an item is removed from the above view, the item will be animated to the position (100,100)
over one second, and in parallel will also change its opacity to 0. The transition
only applies to the items that are removed from the view; it does not apply to the items below
- them that are displaced by the removal of the items. To animate the displaced items, set the \l
- removeDisplaced property.
+ them that are displaced by the removal of the items. To animate the displaced items, set the
+ \l displaced or \l removeDisplaced properties.
Note that by the time the transition is applied, the item has already been removed from the
model; any references to the model data for the removed index will not be valid.
@@ -1779,11 +1789,11 @@ void QQuickGridView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::GridView::removeDisplaced
+
This property holds the transition to apply to items in the view that are displaced by the
removal of other items in the view.
- The transition is applied to items that are currently visible and have been displaced by
- the removal of items. For example, here is a view that specifies such a transition:
+ For example, here is a view that specifies such a transition:
\code
GridView {
@@ -1801,11 +1811,53 @@ void QQuickGridView::setSnapMode(SnapMode mode)
the item that has actually been removed from the view; to animate the removed items, set the
\l remove property.
+ If an item is displaced by multiple types of operations at the same time, it is not defined as to
+ whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally,
+ if it is not necessary to specify different transitions depending on whether an item is displaced
+ by an add, move or remove operation, consider setting the \l displaced property instead.
+
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
- \sa remove, ViewTransition
+ \sa displaced, remove, ViewTransition
*/
+
+/*!
+ \qmlproperty Transition QtQuick2::GridView::displaced
+ This property holds the generic transition to apply to items that have been displaced by
+ any model operation that affects the view.
+
+ This is a convenience for specifying a generic transition for items that are displaced
+ by add, move or remove operations, without having to specify the individual addDisplaced,
+ moveDisplaced and removeDisplaced properties. For example, here is a view that specifies
+ a displaced transition:
+
+ \code
+ GridView {
+ ...
+ displaced: Transition {
+ NumberAnimation { properties: "x,y"; duration: 1000 }
+ }
+ }
+ \endcode
+
+ When any item is added, moved or removed within the above view, the items below it are
+ displaced, causing them to move down (or sideways, if horizontally orientated) within the
+ view. As this displacement occurs, the items' movement to their new x,y positions within
+ the view will be animated by a NumberAnimation over one second, as specified.
+
+ If a view specifies this generic displaced transition as well as a specific addDisplaced,
+ moveDisplaced or removeDisplaced transition, the more specific transition will be used
+ instead of the generic displaced transition when the relevant operation occurs, providing that
+ the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled}
+ to false). If it has indeed been disabled, the generic displaced transition is applied instead.
+
+ For more details and examples on how to use view transitions, see the ViewTransition
+ documentation.
+
+ \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition
+*/
+
void QQuickGridView::viewportMoved()
{
Q_D(QQuickGridView);
@@ -2109,10 +2161,12 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
FxViewItem *item = visibleItems.at(i);
if (item->index != -1 && item->index >= modelIndex) {
item->index += count;
- if (change.isMove())
- transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false);
- else
- transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, false);
+ if (transitioner) {
+ if (change.isMove())
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false);
+ else
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, false);
+ }
}
}
@@ -2143,7 +2197,8 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
insertResult->changedFirstItem = true;
if (!change.isMove()) {
addedItems->append(item);
- transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true);
+ if (transitioner)
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true);
}
insertResult->sizeChangesBeforeVisiblePos += rowSize();
}
@@ -2176,11 +2231,12 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
if (change.isMove()) {
// we know this is a move target, since move displaced items that are
// shuffled into view due to a move would be added in refill()
- if (canTransition(FxViewItemTransitionManager::MoveTransition, true) && newItem)
+ if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true))
movingIntoView->append(MovedItem(item, change.moveKey(item->index)));
} else {
addedItems->append(item);
- transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true);
+ if (transitioner)
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true);
}
insertResult->sizeChangesAfterVisiblePos += rowSize();
@@ -2201,6 +2257,9 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult)
{
+ if (!transitioner)
+ return;
+
int markerItemIndex = -1;
for (int i=0; i<visibleItems.count(); i++) {
if (visibleItems[i]->index == afterModelIndex) {
@@ -2228,7 +2287,7 @@ void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
qreal origColPos = gridItem->rowPos();
int indexDiff = gridItem->index - countItemsRemoved;
gridItem->setPosition((indexDiff % columns) * colSize(), (indexDiff / columns) * rowSize());
- transitionNextReposition(gridItem, FxViewItemTransitionManager::RemoveTransition, false);
+ transitioner->transitionNextReposition(gridItem, QQuickItemViewTransitioner::RemoveTransition, false);
gridItem->setPosition(origRowPos, origColPos);
}
}
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 357c72cc71..77808a61d9 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -1627,7 +1627,7 @@ void QQuickItemPrivate::setAccessibleFlagAndListener()
\inmodule QtQuick
- All visual items in Qt Declarative inherit from QQuickItem. Although QQuickItem
+ All visual items in Qt Quick inherit from QQuickItem. Although QQuickItem
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.
@@ -1646,7 +1646,7 @@ void QQuickItemPrivate::setAccessibleFlagAndListener()
\ingroup qml-basic-visual-elements
\brief The Item is the most basic of all visual items in QML.
- All visual items in Qt Declarative inherit from Item. Although Item
+ All visual items in Qt Quick 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.
@@ -2122,7 +2122,7 @@ QQuickItem *QQuickItemPrivate::InitializationState::getFocusScope(QQuickItem *it
{
if (!focusScope) {
QQuickItem *fs = item->parentItem();
- while (!fs->isFocusScope())
+ while (fs->parentItem() && !fs->isFocusScope())
fs = fs->parentItem();
focusScope = fs;
}
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 8adb80e88b..03fc66eadb 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -830,8 +830,8 @@ private:
Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const
{
- return extra.flag()?Qt::LeftButton:Qt::MouseButton(0) |
- (extra.isAllocated()?extra->acceptedMouseButtons:Qt::MouseButtons(0));
+ return ((extra.flag() ? Qt::LeftButton : Qt::MouseButton(0)) |
+ (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons(0)));
}
QSGContext *QQuickItemPrivate::sceneGraphContext() const
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
index 1316a3d84a..32f1047e51 100644
--- a/src/quick/items/qquickitemanimation.cpp
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -551,6 +551,8 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
delete data;
}
+ animator->setDuration(d->duration);
+ animator->setEasingCurve(d->easing);
return initInstance(animator);
}
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 64b84d35dd..3d23f7b03a 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -61,6 +61,7 @@
#include "qquickvisualdatamodel_p.h"
#include "qquickgridview_p.h"
#include "qquickpathview_p.h"
+#include "qquickitemviewtransition_p.h"
#include <private/qquickpath_p.h>
#include <private/qquickpathinterpolator_p.h>
#include "qquickpositioners_p.h"
@@ -77,7 +78,8 @@
#include <QtQuick/private/qquickcanvasitem_p.h>
#include <QtQuick/private/qquickcontext2d_p.h>
#include "qquicksprite_p.h"
-#include "qquickspriteimage_p.h"
+#include "qquickspritesequence_p.h"
+#include "qquickanimatedsprite_p.h"
#include "qquickdrag_p.h"
#include "qquickdroparea_p.h"
#include "qquickmultipointtoucharea_p.h"
@@ -200,7 +202,9 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickCanvasItem>("QtQuick", 2, 0, "Canvas");
qmlRegisterType<QQuickSprite>("QtQuick", 2, 0, "Sprite");
- qmlRegisterType<QQuickSpriteImage>("QtQuick", 2, 0, "SpriteImage");
+ qmlRegisterType<QQuickAnimatedSprite>("QtQuick", 2, 0, "AnimatedSprite");
+ qmlRegisterType<QQuickSpriteSequence>("QtQuick", 2, 0, "SpriteSequence");
+ qmlRegisterType<QQuickSpriteSequence>("QtQuick", 2, 0, "SpriteImage");//Deprecation in progress
qmlRegisterType<QQuickParentChange>(uri, major, minor,"ParentChange");
qmlRegisterType<QQuickAnchorChanges>(uri, major, minor,"AnchorChanges");
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 418b3196ed..516cf0c1bb 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -46,20 +46,12 @@ QT_BEGIN_NAMESPACE
FxViewItem::FxViewItem(QQuickItem *i, bool own)
- : item(i), ownItem(own), index(-1), releaseAfterTransition(false)
- , transition(0)
- , nextTransitionType(FxViewItemTransitionManager::NoTransition)
- , isTransitionTarget(false)
- , nextTransitionToSet(false)
+ : QQuickViewItem(i), ownItem(own), releaseAfterTransition(false)
{
}
FxViewItem::~FxViewItem()
{
- if (transition)
- transition->m_item = 0;
- delete transition;
-
if (ownItem && item) {
item->setParentItem(0);
item->deleteLater();
@@ -67,273 +59,6 @@ FxViewItem::~FxViewItem()
}
}
-qreal FxViewItem::itemX() const
-{
- if (nextTransitionType != FxViewItemTransitionManager::NoTransition)
- return nextTransitionToSet ? nextTransitionTo.x() : item->x();
- else if (transition && transition->isActive())
- return transition->m_toPos.x();
- else
- return item->x();
-}
-
-qreal FxViewItem::itemY() const
-{
- // If item is transitioning to some pos, return that dest pos.
- // If item was redirected to some new pos before the current transition finished,
- // return that new pos.
- if (nextTransitionType != FxViewItemTransitionManager::NoTransition)
- return nextTransitionToSet ? nextTransitionTo.y() : item->y();
- else if (transition && transition->isActive())
- return transition->m_toPos.y();
- else
- return item->y();
-}
-
-void FxViewItem::setVisible(bool visible)
-{
- if (!visible && transitionScheduledOrRunning())
- return;
- item->setVisible(visible);
-}
-
-void FxViewItem::setNextTransition(FxViewItemTransitionManager::TransitionType type, bool isTargetItem)
-{
- // Don't reset nextTransitionToSet - once it is set, it cannot be changed
- // until the animation finishes since the itemX() and itemY() may be used
- // to calculate positions for transitions for other items in the view.
- nextTransitionType = type;
- isTransitionTarget = isTargetItem;
-}
-
-bool FxViewItem::transitionScheduledOrRunning() const
-{
- return (transition && transition->isActive())
- || nextTransitionType != FxViewItemTransitionManager::NoTransition;
-}
-
-bool FxViewItem::prepareTransition(const QRectF &viewBounds)
-{
- bool doTransition = false;
-
- switch (nextTransitionType) {
- case FxViewItemTransitionManager::NoTransition:
- {
- return false;
- }
- case FxViewItemTransitionManager::PopulateTransition:
- {
- return true;
- }
- case FxViewItemTransitionManager::AddTransition:
- case FxViewItemTransitionManager::RemoveTransition:
- // For Add targets, do transition if item is moving into visible area
- // For Remove targets, do transition if item is currently in visible area
- if (isTransitionTarget) {
- doTransition = (nextTransitionType == FxViewItemTransitionManager::AddTransition)
- ? viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))
- : viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height()));
- if (!doTransition)
- item->setPos(nextTransitionTo);
- } else {
- if (viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height()))
- || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))) {
- doTransition = (nextTransitionTo != item->pos());
- } else {
- item->setPos(nextTransitionTo);
- }
- }
- break;
- case FxViewItemTransitionManager::MoveTransition:
- // do transition if moving from or into visible area
- if (nextTransitionTo != item->pos()) {
- doTransition = viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height()))
- || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()));
- if (!doTransition)
- item->setPos(nextTransitionTo);
- }
- break;
- }
-
- if (!doTransition)
- resetTransitionData();
- return doTransition;
-}
-
-void FxViewItem::startTransition()
-{
- if (nextTransitionType == FxViewItemTransitionManager::NoTransition)
- return;
-
- if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) {
- delete transition;
- transition = new FxViewItemTransitionManager;
- }
-
- // if item is not already moving somewhere, set it to not move anywhere
- // so that removed items do not move to the default (0,0)
- if (!nextTransitionToSet)
- moveTo(item->pos());
-
- transition->startTransition(this, nextTransitionType, nextTransitionTo, isTransitionTarget);
- nextTransitionType = FxViewItemTransitionManager::NoTransition;
-}
-
-void FxViewItem::stopTransition()
-{
- if (transition) {
- transition->cancel();
- delete transition;
- transition = 0;
- }
- resetTransitionData();
- finishedTransition();
-}
-
-void FxViewItem::finishedTransition()
-{
- nextTransitionToSet = false;
- nextTransitionTo = QPointF();
-
- if (releaseAfterTransition) {
- QQuickItemViewPrivate *vp = static_cast<QQuickItemViewPrivate*>(QObjectPrivate::get(itemView()));
- vp->releasePendingTransition.removeOne(this);
- vp->releaseItem(this);
- }
-}
-
-void FxViewItem::resetTransitionData()
-{
- nextTransitionType = FxViewItemTransitionManager::NoTransition;
- isTransitionTarget = false;
- nextTransitionTo = QPointF();
- nextTransitionToSet = false;
-}
-
-bool FxViewItem::isPendingRemoval() const
-{
- if (nextTransitionType == FxViewItemTransitionManager::RemoveTransition)
- return isTransitionTarget;
- if (transition && transition->isActive() && transition->m_type == FxViewItemTransitionManager::RemoveTransition)
- return transition->m_isTarget;
- return false;
-}
-
-void FxViewItem::moveTo(const QPointF &pos)
-{
- if (transitionScheduledOrRunning()) {
- nextTransitionTo = pos;
- nextTransitionToSet = true;
- } else {
- item->setPos(pos);
- }
-}
-
-
-FxViewItemTransitionManager::FxViewItemTransitionManager()
- : m_active(false), m_item(0), m_type(FxViewItemTransitionManager::NoTransition), m_isTarget(false)
-{
-}
-
-FxViewItemTransitionManager::~FxViewItemTransitionManager()
-{
-}
-
-bool FxViewItemTransitionManager::isActive() const
-{
- return m_active;
-}
-
-void FxViewItemTransitionManager::startTransition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, const QPointF &to, bool isTargetItem)
-{
- if (!item) {
- qWarning("startTransition(): invalid item");
- return;
- }
-
- QQuickItemViewPrivate *vp = static_cast<QQuickItemViewPrivate*>(QObjectPrivate::get(item->itemView()));
-
- QQuickTransition *trans = 0;
- switch (type) {
- case NoTransition:
- break;
- case PopulateTransition:
- trans = vp->populateTransition;
- break;
- case AddTransition:
- trans = isTargetItem ? vp->addTransition : vp->addDisplacedTransition;
- break;
- case MoveTransition:
- trans = isTargetItem ? vp->moveTransition : vp->moveDisplacedTransition;
- break;
- case RemoveTransition:
- trans = isTargetItem ? vp->removeTransition : vp->removeDisplacedTransition;
- break;
- }
-
- if (!trans) {
- qWarning("QQuickItemView: invalid view transition!");
- return;
- }
-
- m_active = true;
- m_item = item;
- m_toPos = to;
- m_type = type;
- m_isTarget = isTargetItem;
-
- QQuickViewTransitionAttached *attached =
- static_cast<QQuickViewTransitionAttached*>(qmlAttachedPropertiesObject<QQuickViewTransitionAttached>(trans));
- if (attached) {
- attached->m_index = item->index;
- attached->m_item = item->item;
- attached->m_destination = to;
- switch (type) {
- case NoTransition:
- break;
- case PopulateTransition:
- case AddTransition:
- attached->m_targetIndexes = vp->addTransitionIndexes;
- attached->m_targetItems = vp->addTransitionTargets;
- break;
- case MoveTransition:
- attached->m_targetIndexes = vp->moveTransitionIndexes;
- attached->m_targetItems = vp->moveTransitionTargets;
- break;
- case RemoveTransition:
- attached->m_targetIndexes = vp->removeTransitionIndexes;
- attached->m_targetItems = vp->removeTransitionTargets;
- break;
- }
- emit attached->indexChanged();
- emit attached->itemChanged();
- emit attached->destinationChanged();
- emit attached->targetIndexesChanged();
- emit attached->targetItemsChanged();
- }
-
- QQuickStateOperation::ActionList actions;
- actions << QQuickAction(item->item, QLatin1String("x"), QVariant(to.x()));
- actions << QQuickAction(item->item, QLatin1String("y"), QVariant(to.y()));
-
- QQuickTransitionManager::transition(actions, trans, item->item);
-}
-
-void FxViewItemTransitionManager::finished()
-{
- QQuickTransitionManager::finished();
-
- m_active = false;
-
- if (m_item)
- m_item->finishedTransition();
- m_item = 0;
- m_toPos.setX(0);
- m_toPos.setY(0);
- m_type = NoTransition;
- m_isTarget = false;
-}
-
QQuickItemViewChangeSet::QQuickItemViewChangeSet()
: active(false)
@@ -412,363 +137,6 @@ void QQuickItemViewChangeSet::reset()
currentRemoved = false;
}
-
-QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent)
- : QObject(parent), m_index(-1), m_item(0)
-{
-}
-/*!
- \qmlclass ViewTransition QQuickViewTransitionAttached
- \inqmlmodule QtQuick 2
- \ingroup qml-view-elements
- \brief The ViewTransition attached property provides details on items under transition in a view.
-
- With ListView and GridView, it is possible to specify transitions that should be applied whenever
- the items in the view change as a result of modifications to the view's model. They both have the
- following properties that can be set to the appropriate transitions to be run for various
- operations:
-
- \list
- \o \c add and \c addDisplaced - the transitions to run when items are added to the view
- \o \c remove and \c removeDisplaced - the transitions to run when items are removed from the view
- \o \c move and \c moveDisplaced - the transitions to run when items are moved within the view
- (i.e. as a result of a move operation in the model)
- \o \c populate - the transition to run when a view is created, or when the model changes
- \endlist
-
- Such view transitions additionally have access to a ViewTransition attached property that
- provides details of the items that are under transition and the operation that triggered the
- transition. Since view transitions are run once per item, these details can be used to customise
- each transition for each individual item.
-
- The ViewTransition attached property provides the following properties specific to the item to
- which the transition is applied:
-
- \list
- \o ViewTransition.item - the item that is under transition
- \o ViewTransition.index - the index of this item
- \o ViewTransition.destination - the (x,y) point to which this item is moving for the relevant view operation
- \endlist
-
- In addition, ViewTransition provides properties specific to the items which are the target
- of the operation that triggered the transition:
-
- \list
- \o ViewTransition.targetIndexes - the indexes of the target items
- \o ViewTransition.targetItems - the target items themselves
- \endlist
-
- View transitions can be written without referring to any of the attributes listed
- above. These attributes merely provide extra details that are useful for customising view
- transitions.
-
- Following is an introduction to view transitions and the ways in which the ViewTransition
- attached property can be used to augment view transitions.
-
-
- \section2 View transitions: a simple example
-
- Here is a basic example of the use of view transitions. The view below specifies transitions for
- the \c add and \c addDisplaced properties, which will be run when items are added to the view:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0
-
- When the space key is pressed, adding an item to the model, the new item will fade in and
- increase in scale over 400 milliseconds as it is added to the view. Also, any item that is
- displaced by the addition of a new item will animate to its new position in the view over
- 400 milliseconds, as specified by the \c addDisplaced transition.
-
- If five items were inserted in succession at index 0, the effect would be this:
-
- \image viewtransitions-basic.gif
-
- Notice that the NumberAnimation objects above do not need to specify a \c target to animate
- the appropriate item. Also, the NumberAnimation in the \c addTransition does not need to specify
- the \c to value to move the item to its correct position in the view. This is because the view
- implicitly sets the \c target and \c to values with the correct item and final item position
- values if these properties are not explicitly defined.
-
- At its simplest, a view transition may just animate an item to its new position following a
- view operation, just as the \c addDisplaced transition does above, or animate some item properties,
- as in the \c add transition above. Additionally, a view transition may make use of the
- ViewTransition attached property to customise animation behavior for different items. Following
- are some examples of how this can be achieved.
-
-
- \section2 Using the ViewTransition attached property
-
- As stated, the various ViewTransition properties provide details specific to the individual item
- being transitioned as well as the operation that triggered the transition. In the animation above,
- five items are inserted in succession at index 0. When the fifth and final insertion takes place,
- adding "Item 4" to the view, the \c add transition is run once (for the inserted item) and the
- \c addDisplaced transition is run four times (once for each of the four existing items in the view).
-
- At this point, if we examined the \c addDisplaced transition that was run for the bottom displaced
- item ("Item 0"), the ViewTransition property values provided to this transition would be as follows:
-
- \table
- \header
- \o Property
- \o Value
- \o Explanation
- \row
- \o ViewTransition.item
- \o "Item 0" delegate instance
- \o The "Item 0" \l Rectangle object itself
- \row
- \o ViewTransition.index
- \o \c int value of 4
- \o The index of "Item 0" within the model following the add operation
- \row
- \o ViewTransition.destination
- \o \l point value of (0, 120)
- \o The position that "Item 0" is moving to
- \row
- \o ViewTransition.targetIndexes
- \o \c int array, just contains the integer "0" (zero)
- \o The index of "Item 4", the new item added to the view
- \row
- \o ViewTransition.targetItems
- \o object array, just contains the "Item 4" delegate instance
- \o The "Item 4" \l Rectangle object - the new item added to the view
- \endtable
-
- The ViewTransition.targetIndexes and ViewTransition.targetItems lists provide the items and
- indexes of all delegate instances that are the targets of the relevant operation. For an add
- operation, these are all the items that are added into the view; for a remove, these are all
- the items removed from the view, and so on. (Note these lists will only contain references to
- items that have been created within the view or its cached items; targets that are not within
- the visible area of the view or within the item cache will not be accessible.)
-
- So, while the ViewTransition.item, ViewTransition.index and ViewTransition.destination values
- vary for each individual transition that is run, the ViewTransition.targetIndexes and
- ViewTransition.targetItems values are the same for every \c add and \c addDisplaced transition
- that is triggered by a particular add operation.
-
-
- \section3 Delaying animations based on index
-
- Since each view transition is run once for each item affected by the transition, the ViewTransition
- properties can be used within a transition to define custom behavior for each item's transition.
- For example, the ListView in the previous example could use this information to create a ripple-type
- effect on the movement of the displaced items.
-
- This can be achieved by modifying the \c addDisplaced transition so that it delays the animation of
- each displaced item based on the difference between its index (provided by ViewTransition.index)
- and the first removed index (provided by ViewTransition.targetIndexes):
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml 0
-
- Each displaced item delays its animation by an additional 100 milliseconds, producing a subtle
- ripple-type effect when items are displaced by the add, like this:
-
- \image viewtransitions-delayedbyindex.gif
-
-
- \section3 Animating items to intermediate positions
-
- The ViewTransition.item property gives a reference to the item to which the transition is being
- applied. This can be used to access any of the item's attributes, custom \c property values,
- and so on.
-
- Below is a modification of the \c addDisplaced transition from the previous example. It adds a
- ParallelAnimation with nested NumberAnimation objects that reference ViewTransition.item to access
- each item's \c x and \c y values at the start of their transitions. This allows each item to
- animate to an intermediate position relative to its starting point for the transition, before
- animating to its final position in the view:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml 0
-
- Now, a displaced item will first move to a position of (20, 50) relative to its starting
- position, and then to its final, correct position in the view:
-
- \image viewtransitions-intermediatemove.gif
-
- Since the final NumberAnimation does not specify a \c to value, the view implicitly sets this
- value to the item's final position in the view, and so this last animation will move this item
- to the correct place. If the transition requires the final position of the item for some calculation,
- this is accessible through ViewTransition.destination.
-
- Instead of using multiple NumberAnimations, you could use a PathAnimation to animate an item over
- a curved path. For example, the \c add transition in the previous example could be augmented with
- a PathAnimation as follows: to animate newly added items along a path:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml 0
-
- This animates newly added items along a path. Notice that each path is specified relative to
- each item's final destination point, so that items inserted at different indexes start their
- paths from different positions:
-
- \image viewtransitions-pathanim.gif
-
-
- \section2 Handling interrupted animations
-
- A view transition may be interrupted at any time if a different view transition needs to be
- applied while the original transition is in progress. For example, say Item A is inserted at index 0
- and undergoes an "add" transition; then, Item B is inserted at index 0 in quick succession before
- Item A's transition has finished. Since Item B is inserted before Item A, it will displace Item
- A, causing the view to interrupt Item A's "add" transition mid-way and start an "addDisplaced"
- transition on Item A instead.
-
- For simple animations that simply animate an item's movement to its final destination, this
- interruption is unlikely to require additional consideration. However, if a transition changes other
- properties, this interruption may cause unwanted side effects. Consider the first example on this
- page, repeated below for convenience:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0
-
- If multiple items are added in rapid succession, without waiting for a previous transition
- to finish, this is the result:
-
- \image viewtransitions-interruptedbad.gif
-
- Each newly added item undergoes an \c add transition, but before the transition can finish,
- another item is added, displacing the previously added item. Because of this, the \c add
- transition on the previously added item is interrupted and an \c addDisplaced transition is
- started on the item instead. Due to the interruption, the \c opacity and \c scale animations
- have not completed, thus producing items with opacity and scale that are below 1.0.
-
- To fix this, the \c addDisplaced transition should additionally ensure the item properties are
- set to the end values specified in the \c add transition, effectively resetting these values
- whenever an item is displaced. In this case, it means setting the item opacity and scale to 1.0:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml 0
-
- Now, when an item's \c add transition is interrupted, its opacity and scale are animated to 1.0
- upon displacement, avoiding the erroneous visual effects from before:
-
- \image viewtransitions-interruptedgood.gif
-
- The same principle applies to any combination of view transitions. An added item may be moved
- before its add transition finishes, or a moved item may be removed before its moved transition
- finishes, and so on; so, the rule of thumb is that every transition should handle the same set of
- properties.
-
-
- \section2 Restrictions regarding ScriptAction
-
- When a view transition is initialized, any property bindings that refer to the ViewTransition
- attached property are evaluated in preparation for the transition. Due to the nature of the
- internal construction of a view transition, the attributes of the ViewTransition attached
- property are only valid for the relevant item when the transition is initialized, and may not be
- valid when the transition is actually run.
-
- Therefore, a ScriptAction within a view transition should not refer to the ViewTransition
- attached property, as it may not refer to the expected values at the time that the ScriptAction
- is actually invoked. Consider the following example:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml 0
-
- When the space key is pressed, three items are moved from index 5 to index 1. For each moved
- item, the \c moveTransition sequence presumably animates the item's color to "yellow", then
- animates it to its final position, then changes the item color back to "lightsteelblue" using a
- ScriptAction. However, when run, the transition does not produce the intended result:
-
- \image viewtransitions-scriptactionbad.gif
-
- Only the last moved item is returned to the "lightsteelblue" color; the others remain yellow. This
- is because the ScriptAction is not run until after the transition has already been initialized, by
- which time the ViewTransition.item value has changed to refer to a different item; the item that
- the script had intended to refer to is not the one held by ViewTransition.item at the time the
- ScriptAction is actually invoked.
-
- In this instance, to avoid this issue, the view could set the property using a PropertyAction
- instead:
-
- \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml 0
-
- When the transition is initialized, the PropertyAction \c target will be set to the respective
- ViewTransition.item for the transition and will later run with the correct item target as
- expected.
- */
-
-/*!
- \qmlattachedproperty list QtQuick2::ViewTransition::index
-
- This attached property holds the index of the item that is being
- transitioned.
-
- Note that if the item is being moved, this property holds the index that
- the item is moving to, not from.
-*/
-
-/*!
- \qmlattachedproperty list QtQuick2::ViewTransition::item
-
- This attached property holds the the item that is being transitioned.
-
- \warning This item should not be kept and referred to outside of the transition
- as it may become invalid as the view changes.
-*/
-
-/*!
- \qmlattachedproperty list QtQuick2::ViewTransition::destination
-
- This attached property holds the final destination position for the transitioned
- item within the view.
-
- This property value is a \l point with \c x and \c y properties.
-*/
-
-/*!
- \qmlattachedproperty list QtQuick2::ViewTransition::targetIndexes
-
- This attached property holds a list of the indexes of the items in view
- that are the target of the relevant operation.
-
- The targets are the items that are the subject of the operation. For
- an add operation, these are the items being added; for a remove, these
- are the items being removed; for a move, these are the items being
- moved.
-
- For example, if the transition was triggered by an insert operation
- that added two items at index 1 and 2, this targetIndexes list would
- have the value [1,2].
-
- \note The targetIndexes list only contains the indexes of items that are actually
- in view, or will be in the view once the relevant operation completes.
-
- \sa QtQuick2::ViewTransition::targetIndexes
-*/
-
-/*!
- \qmlattachedproperty list QtQuick2::ViewTransition::targetItems
-
- This attached property holds the list of items in view that are the
- target of the relevant operation.
-
- The targets are the items that are the subject of the operation. For
- an add operation, these are the items being added; for a remove, these
- are the items being removed; for a move, these are the items being
- moved.
-
- For example, if the transition was triggered by an insert operation
- that added two items at index 1 and 2, this targetItems list would
- contain these two items.
-
- \note The targetItems list only contains items that are actually
- in view, or will be in the view once the relevant operation completes.
-
- \warning The objects in this list should not be kept and referred to
- outside of the transition as the items may become invalid. The targetItems
- are only valid when the Transition is initially created; this also means
- they should not be used by ScriptAction objects in the Transition, which are
- not evaluated until the transition is run.
-
- \sa QtQuick2::ViewTransition::targetIndexes
-*/
-QQmlListProperty<QObject> QQuickViewTransitionAttached::targetItems()
-{
- return QQmlListProperty<QObject>(this, m_targetItems);
-}
-
-QQuickViewTransitionAttached *QQuickViewTransitionAttached::qmlAttachedProperties(QObject *obj)
-{
- return new QQuickViewTransitionAttached(obj);
-}
-
-
//-----------------------------------
QQuickItemView::QQuickItemView(QQuickFlickablePrivate &dd, QQuickItem *parent)
@@ -867,9 +235,9 @@ void QQuickItemView::setModel(const QVariant &model)
}
d->updateViewport();
- if (d->populateTransition) {
+ if (d->transitioner && d->transitioner->populateTransition) {
d->forceLayout = true;
- d->usePopulateTransition = true;
+ d->transitioner->setPopulateTransitionEnabled(true);
polish();
}
}
@@ -1228,14 +596,15 @@ void QQuickItemView::setHighlightMoveDuration(int duration)
QQuickTransition *QQuickItemView::populateTransition() const
{
Q_D(const QQuickItemView);
- return d->populateTransition;
+ return d->transitioner ? d->transitioner->populateTransition : 0;
}
void QQuickItemView::setPopulateTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->populateTransition != transition) {
- d->populateTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->populateTransition != transition) {
+ d->transitioner->populateTransition = transition;
emit populateTransitionChanged();
}
}
@@ -1243,14 +612,15 @@ void QQuickItemView::setPopulateTransition(QQuickTransition *transition)
QQuickTransition *QQuickItemView::addTransition() const
{
Q_D(const QQuickItemView);
- return d->addTransition;
+ return d->transitioner ? d->transitioner->addTransition : 0;
}
void QQuickItemView::setAddTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->addTransition != transition) {
- d->addTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->addTransition != transition) {
+ d->transitioner->addTransition = transition;
emit addTransitionChanged();
}
}
@@ -1258,14 +628,15 @@ void QQuickItemView::setAddTransition(QQuickTransition *transition)
QQuickTransition *QQuickItemView::addDisplacedTransition() const
{
Q_D(const QQuickItemView);
- return d->addDisplacedTransition;
+ return d->transitioner ? d->transitioner->addDisplacedTransition : 0;
}
void QQuickItemView::setAddDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->addDisplacedTransition != transition) {
- d->addDisplacedTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->addDisplacedTransition != transition) {
+ d->transitioner->addDisplacedTransition = transition;
emit addDisplacedTransitionChanged();
}
}
@@ -1273,14 +644,15 @@ void QQuickItemView::setAddDisplacedTransition(QQuickTransition *transition)
QQuickTransition *QQuickItemView::moveTransition() const
{
Q_D(const QQuickItemView);
- return d->moveTransition;
+ return d->transitioner ? d->transitioner->moveTransition : 0;
}
void QQuickItemView::setMoveTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->moveTransition != transition) {
- d->moveTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->moveTransition != transition) {
+ d->transitioner->moveTransition = transition;
emit moveTransitionChanged();
}
}
@@ -1288,14 +660,15 @@ void QQuickItemView::setMoveTransition(QQuickTransition *transition)
QQuickTransition *QQuickItemView::moveDisplacedTransition() const
{
Q_D(const QQuickItemView);
- return d->moveDisplacedTransition;
+ return d->transitioner ? d->transitioner->moveDisplacedTransition : 0;
}
void QQuickItemView::setMoveDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->moveDisplacedTransition != transition) {
- d->moveDisplacedTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->moveDisplacedTransition != transition) {
+ d->transitioner->moveDisplacedTransition = transition;
emit moveDisplacedTransitionChanged();
}
}
@@ -1303,14 +676,15 @@ void QQuickItemView::setMoveDisplacedTransition(QQuickTransition *transition)
QQuickTransition *QQuickItemView::removeTransition() const
{
Q_D(const QQuickItemView);
- return d->removeTransition;
+ return d->transitioner ? d->transitioner->removeTransition : 0;
}
void QQuickItemView::setRemoveTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->removeTransition != transition) {
- d->removeTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->removeTransition != transition) {
+ d->transitioner->removeTransition = transition;
emit removeTransitionChanged();
}
}
@@ -1318,18 +692,35 @@ void QQuickItemView::setRemoveTransition(QQuickTransition *transition)
QQuickTransition *QQuickItemView::removeDisplacedTransition() const
{
Q_D(const QQuickItemView);
- return d->removeDisplacedTransition;
+ return d->transitioner ? d->transitioner->removeDisplacedTransition : 0;
}
void QQuickItemView::setRemoveDisplacedTransition(QQuickTransition *transition)
{
Q_D(QQuickItemView);
- if (d->removeDisplacedTransition != transition) {
- d->removeDisplacedTransition = transition;
+ d->createTransitioner();
+ if (d->transitioner->removeDisplacedTransition != transition) {
+ d->transitioner->removeDisplacedTransition = transition;
emit removeDisplacedTransitionChanged();
}
}
+QQuickTransition *QQuickItemView::displacedTransition() const
+{
+ Q_D(const QQuickItemView);
+ return d->transitioner ? d->transitioner->displacedTransition : 0;
+}
+
+void QQuickItemView::setDisplacedTransition(QQuickTransition *transition)
+{
+ Q_D(QQuickItemView);
+ d->createTransitioner();
+ if (d->transitioner->displacedTransition != transition) {
+ d->transitioner->displacedTransition = transition;
+ emit displacedTransitionChanged();
+ }
+}
+
void QQuickItemViewPrivate::positionViewAtIndex(int index, int mode)
{
Q_Q(QQuickItemView);
@@ -1464,64 +855,6 @@ void QQuickItemViewPrivate::applyPendingChanges()
layout();
}
-bool QQuickItemViewPrivate::canTransition(FxViewItemTransitionManager::TransitionType type, bool asTarget) const
-{
- switch (type) {
- case FxViewItemTransitionManager::NoTransition:
- break;
- case FxViewItemTransitionManager::PopulateTransition:
- return usePopulateTransition
- && populateTransition && populateTransition->enabled();
- case FxViewItemTransitionManager::AddTransition:
- if (asTarget)
- return addTransition && addTransition->enabled();
- else
- return addDisplacedTransition && addDisplacedTransition->enabled();
- case FxViewItemTransitionManager::MoveTransition:
- if (asTarget)
- return moveTransition && moveTransition->enabled();
- else
- return moveDisplacedTransition && moveDisplacedTransition->enabled();
- case FxViewItemTransitionManager::RemoveTransition:
- if (asTarget)
- return removeTransition && removeTransition->enabled();
- else
- return removeDisplacedTransition && removeDisplacedTransition->enabled();
- }
- return false;
-}
-
-bool QQuickItemViewPrivate::hasItemTransitions() const
-{
- return canTransition(FxViewItemTransitionManager::PopulateTransition, true)
- || canTransition(FxViewItemTransitionManager::AddTransition, true)
- || canTransition(FxViewItemTransitionManager::AddTransition, false)
- || canTransition(FxViewItemTransitionManager::MoveTransition, true)
- || canTransition(FxViewItemTransitionManager::MoveTransition, false)
- || canTransition(FxViewItemTransitionManager::RemoveTransition, true)
- || canTransition(FxViewItemTransitionManager::RemoveTransition, false);
-}
-
-void QQuickItemViewPrivate::transitionNextReposition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, bool isTarget)
-{
- bool matchedTransition = false;
- if (type == FxViewItemTransitionManager::AddTransition) {
- // don't run add transitions for added items while populating
- matchedTransition = !usePopulateTransition && canTransition(type, isTarget);
- } else {
- matchedTransition = canTransition(type, isTarget);
- }
-
- if (matchedTransition) {
- item->setNextTransition(type, isTarget);
- } else {
- // the requested transition type is not valid, but the item is scheduled/in another
- // transition, so cancel it to allow the item to move directly to the correct pos
- if (item->transitionScheduledOrRunning())
- item->stopTransition();
- }
-}
-
int QQuickItemViewPrivate::findMoveKeyIndex(QQuickChangeSet::MoveKey key, const QVector<QQuickChangeSet::Remove> &changes) const
{
for (int i=0; i<changes.count(); i++) {
@@ -1582,8 +915,8 @@ void QQuickItemViewPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &
// start new transitions
bool prevDisableLayout = disableLayout;
if (!disableLayout) {
- FxViewItem *actualItem = hasItemTransitions() ? visibleItem(currentIndex) : 0;
- if (actualItem && actualItem->transition && actualItem->transition->isRunning())
+ FxViewItem *actualItem = transitioner ? visibleItem(currentIndex) : 0;
+ if (actualItem && actualItem->transitionRunning())
disableLayout = true;
}
updateHighlight();
@@ -1601,7 +934,7 @@ void QQuickItemView::destroyRemoved()
it != d->visibleItems.end();) {
FxViewItem *item = *it;
if (item->index == -1 && item->attached->delayRemove() == false) {
- if (d->canTransition(FxViewItemTransitionManager::RemoveTransition, true)) {
+ if (d->transitioner && d->transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, true)) {
// don't remove from visibleItems until next layout()
d->runDelayedRemoveTransition = true;
QObject::disconnect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()));
@@ -1625,7 +958,8 @@ void QQuickItemView::modelUpdated(const QQuickChangeSet &changeSet, bool reset)
{
Q_D(QQuickItemView);
if (reset) {
- d->usePopulateTransition = true;
+ if (d->transitioner)
+ d->transitioner->setPopulateTransitionEnabled(true);
d->moveReason = QQuickItemViewPrivate::SetIndex;
d->regenerate();
if (d->highlight && d->currentItem) {
@@ -1635,7 +969,7 @@ void QQuickItemView::modelUpdated(const QQuickChangeSet &changeSet, bool reset)
}
d->moveReason = QQuickItemViewPrivate::Other;
emit countChanged();
- if (d->populateTransition) {
+ if (d->transitioner && d->transitioner->populateTransition) {
d->forceLayout = true;
polish();
}
@@ -1935,7 +1269,8 @@ void QQuickItemView::componentComplete()
d->updateFooter();
d->updateViewport();
d->setPosition(d->contentStartOffset());
- d->usePopulateTransition = true;
+ if (d->transitioner)
+ d->transitioner->setPopulateTransitionEnabled(true);
if (d->isValid()) {
d->refill();
@@ -1971,19 +1306,23 @@ QQuickItemViewPrivate::QQuickItemViewPrivate()
, highlightRangeStart(0), highlightRangeEnd(0)
, highlightMoveDuration(150)
, headerComponent(0), header(0), footerComponent(0), footer(0)
- , populateTransition(0)
- , addTransition(0), addDisplacedTransition(0)
- , moveTransition(0), moveDisplacedTransition(0)
- , removeTransition(0), removeDisplacedTransition(0)
+ , transitioner(0)
, minExtent(0), maxExtent(0)
, ownModel(false), wrap(false)
, disableLayout(false), inViewportMoved(false), forceLayout(false), currentIndexCleared(false)
, haveHighlightRange(false), autoHighlight(true), highlightRangeStartValid(false), highlightRangeEndValid(false)
, fillCacheBuffer(false), inRequest(false), requestedAsync(false)
- , usePopulateTransition(false), runDelayedRemoveTransition(false)
+ , runDelayedRemoveTransition(false)
{
}
+QQuickItemViewPrivate::~QQuickItemViewPrivate()
+{
+ if (transitioner)
+ transitioner->setChangeListener(0);
+ delete transitioner;
+}
+
bool QQuickItemViewPrivate::isValid() const
{
return model && model->count() && model->isValid();
@@ -2161,6 +1500,12 @@ void QQuickItemViewPrivate::clear()
createHighlight();
trackedItem = 0;
+ if (requestedIndex >= 0 && requestedAsync) {
+ if (model)
+ model->cancel(requestedIndex);
+ requestedIndex = -1;
+ }
+
markExtentsDirty();
itemCount = 0;
}
@@ -2260,15 +1605,17 @@ void QQuickItemViewPrivate::layout()
if (!isValid() && !visibleItems.count()) {
clear();
setPosition(contentStartOffset());
- usePopulateTransition = false;
+ if (transitioner)
+ transitioner->setPopulateTransitionEnabled(false);
return;
}
- if (runDelayedRemoveTransition && canTransition(FxViewItemTransitionManager::RemoveTransition, false)) {
+ if (runDelayedRemoveTransition && transitioner
+ && transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, false)) {
// assume that any items moving now are moving due to the remove - if they schedule
// a different transition, that will override this one anyway
for (int i=0; i<visibleItems.count(); i++)
- transitionNextReposition(visibleItems[i], FxViewItemTransitionManager::RemoveTransition, false);
+ transitioner->transitionNextReposition(visibleItems[i], QQuickItemViewTransitioner::RemoveTransition, false);
}
ChangeResult insertionPosChanges;
@@ -2282,9 +1629,9 @@ void QQuickItemViewPrivate::layout()
}
forceLayout = false;
- if (canTransition(FxViewItemTransitionManager::PopulateTransition, true)) {
+ if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) {
for (int i=0; i<visibleItems.count(); i++)
- transitionNextReposition(visibleItems.at(i), FxViewItemTransitionManager::PopulateTransition, true);
+ transitioner->transitionNextReposition(visibleItems.at(i), QQuickItemViewTransitioner::PopulateTransition, true);
}
layoutVisibleItems();
@@ -2303,11 +1650,11 @@ void QQuickItemViewPrivate::layout()
updateViewport();
updateUnrequestedPositions();
- if (hasItemTransitions()) {
+ if (transitioner) {
// items added in the last refill() may need to be transitioned in - e.g. a remove
// causes items to slide up into view
- if (canTransition(FxViewItemTransitionManager::MoveTransition, false)
- || canTransition(FxViewItemTransitionManager::RemoveTransition, false)) {
+ if (transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, false)
+ || transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, false)) {
translateAndTransitionItemsAfter(lastIndexInView, insertionPosChanges, removalPosChanges);
}
@@ -2317,8 +1664,7 @@ void QQuickItemViewPrivate::layout()
for (QList<FxViewItem*>::Iterator it = releasePendingTransition.begin();
it != releasePendingTransition.end(); ) {
FxViewItem *item = *it;
- if ( (item->transition && item->transition->isActive())
- || prepareNonVisibleItemTransition(item, viewBounds)) {
+ if (item->transitionRunning() || prepareNonVisibleItemTransition(item, viewBounds)) {
++it;
} else {
releaseItem(item);
@@ -2327,11 +1673,12 @@ void QQuickItemViewPrivate::layout()
}
for (int i=0; i<visibleItems.count(); i++)
- visibleItems[i]->startTransition();
+ visibleItems[i]->startTransition(transitioner);
for (int i=0; i<releasePendingTransition.count(); i++)
- releasePendingTransition[i]->startTransition();
+ releasePendingTransition[i]->startTransition(transitioner);
+ transitioner->setPopulateTransitionEnabled(false);
}
- usePopulateTransition = false;
+
runDelayedRemoveTransition = false;
}
@@ -2434,7 +1781,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
// for each item that was moved directly into the view as a result of a move(),
// find the index it was moved from in order to set its initial position, so that we
// can transition it from this "original" position to its new position in the view
- if (canTransition(FxViewItemTransitionManager::MoveTransition, true)) {
+ if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) {
for (int i=0; i<movingIntoView.count(); i++) {
int fromIndex = findMoveKeyIndex(movingIntoView[i].moveKey, removals);
if (fromIndex >= 0) {
@@ -2442,7 +1789,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
repositionItemAt(movingIntoView[i].item, fromIndex, -totalInsertionResult->sizeChangesAfterVisiblePos);
else
repositionItemAt(movingIntoView[i].item, fromIndex, totalInsertionResult->sizeChangesAfterVisiblePos);
- transitionNextReposition(movingIntoView[i].item, FxViewItemTransitionManager::MoveTransition, true);
+ transitioner->transitionNextReposition(movingIntoView[i].item, QQuickItemViewTransitioner::MoveTransition, true);
}
}
}
@@ -2506,10 +1853,12 @@ bool QQuickItemViewPrivate::applyRemovalChange(const QQuickChangeSet::Remove &re
} else if (item->index >= removal.index + removal.count) {
// after removed items
item->index -= removal.count;
- if (removal.isMove())
- transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false);
- else
- transitionNextReposition(item, FxViewItemTransitionManager::RemoveTransition, false);
+ if (transitioner) {
+ if (removal.isMove())
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false);
+ else
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::RemoveTransition, false);
+ }
++it;
} else {
// removed item
@@ -2543,7 +1892,8 @@ void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QQuickChangeSet::
}
if (removal.isMove()) {
currentChanges.removedItems.insert(removal.moveKey(item->index), item);
- transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, true);
+ if (transitioner)
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, true);
} else {
// track item so it is released later
currentChanges.removedItems.insertMulti(QQuickChangeSet::MoveKey(), item);
@@ -2591,16 +1941,24 @@ void QQuickItemViewPrivate::repositionFirstItem(FxViewItem *prevVisibleItemsFirs
}
}
+void QQuickItemViewPrivate::createTransitioner()
+{
+ if (!transitioner) {
+ transitioner = new QQuickItemViewTransitioner;
+ transitioner->setChangeListener(this);
+ }
+}
+
void QQuickItemViewPrivate::prepareVisibleItemTransitions()
{
Q_Q(QQuickItemView);
- if (!hasItemTransitions())
+ if (!transitioner)
return;
- addTransitionIndexes.clear();
- addTransitionTargets.clear();
- moveTransitionIndexes.clear();
- moveTransitionTargets.clear();
+ transitioner->addTransitionIndexes.clear();
+ transitioner->addTransitionTargets.clear();
+ transitioner->moveTransitionIndexes.clear();
+ transitioner->moveTransitionTargets.clear();
QRectF viewBounds(0, position(), q->width(), q->height());
for (int i=0; i<visibleItems.count(); i++) {
@@ -2609,18 +1967,18 @@ void QQuickItemViewPrivate::prepareVisibleItemTransitions()
continue;
if (visibleItems[i]->isTransitionTarget) {
switch (visibleItems[i]->nextTransitionType) {
- case FxViewItemTransitionManager::NoTransition:
+ case QQuickItemViewTransitioner::NoTransition:
break;
- case FxViewItemTransitionManager::PopulateTransition:
- case FxViewItemTransitionManager::AddTransition:
- addTransitionIndexes.append(visibleItems[i]->index);
- addTransitionTargets.append(visibleItems[i]->item);
+ case QQuickItemViewTransitioner::PopulateTransition:
+ case QQuickItemViewTransitioner::AddTransition:
+ transitioner->addTransitionIndexes.append(visibleItems[i]->index);
+ transitioner->addTransitionTargets.append(visibleItems[i]->item);
break;
- case FxViewItemTransitionManager::MoveTransition:
- moveTransitionIndexes.append(visibleItems[i]->index);
- moveTransitionTargets.append(visibleItems[i]->item);
+ case QQuickItemViewTransitioner::MoveTransition:
+ transitioner->moveTransitionIndexes.append(visibleItems[i]->index);
+ transitioner->moveTransitionTargets.append(visibleItems[i]->item);
break;
- case FxViewItemTransitionManager::RemoveTransition:
+ case QQuickItemViewTransitioner::RemoveTransition:
// removed targets won't be in visibleItems, handle these
// in prepareNonVisibleItemTransition()
break;
@@ -2631,10 +1989,13 @@ void QQuickItemViewPrivate::prepareVisibleItemTransitions()
void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QQuickChangeSet::MoveKey, FxViewItem *> *removedItems)
{
- removeTransitionIndexes.clear();
- removeTransitionTargets.clear();
+ if (!transitioner)
+ return;
- if (canTransition(FxViewItemTransitionManager::RemoveTransition, true)) {
+ transitioner->removeTransitionIndexes.clear();
+ transitioner->removeTransitionTargets.clear();
+
+ if (transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, true)) {
for (QHash<QQuickChangeSet::MoveKey, FxViewItem *>::Iterator it = removedItems->begin();
it != removedItems->end(); ) {
bool isRemove = it.key().moveId < 0;
@@ -2642,7 +2003,7 @@ void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QQuickChangeSet::Move
FxViewItem *item = *it;
item->releaseAfterTransition = true;
releasePendingTransition.append(item);
- transitionNextReposition(item, FxViewItemTransitionManager::RemoveTransition, true);
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::RemoveTransition, true);
it = removedItems->erase(it);
} else {
++it;
@@ -2658,18 +2019,21 @@ bool QQuickItemViewPrivate::prepareNonVisibleItemTransition(FxViewItem *item, co
// removed, or moved to outside of the view, as well as those that are
// displaced to a position outside of the view due to an insert or move.
- if (item->nextTransitionType == FxViewItemTransitionManager::MoveTransition)
+ if (!transitioner)
+ return false;
+
+ if (item->nextTransitionType == QQuickItemViewTransitioner::MoveTransition)
repositionItemAt(item, item->index, 0);
if (!item->prepareTransition(viewBounds))
return false;
if (item->isTransitionTarget) {
- if (item->nextTransitionType == FxViewItemTransitionManager::MoveTransition) {
- moveTransitionIndexes.append(item->index);
- moveTransitionTargets.append(item->item);
- } else if (item->nextTransitionType == FxViewItemTransitionManager::RemoveTransition) {
- removeTransitionIndexes.append(item->index);
- removeTransitionTargets.append(item->item);
+ if (item->nextTransitionType == QQuickItemViewTransitioner::MoveTransition) {
+ transitioner->moveTransitionIndexes.append(item->index);
+ transitioner->moveTransitionTargets.append(item->item);
+ } else if (item->nextTransitionType == QQuickItemViewTransitioner::RemoveTransition) {
+ transitioner->removeTransitionIndexes.append(item->index);
+ transitioner->removeTransitionTargets.append(item->item);
}
}
@@ -2677,6 +2041,15 @@ bool QQuickItemViewPrivate::prepareNonVisibleItemTransition(FxViewItem *item, co
return true;
}
+void QQuickItemViewPrivate::viewItemTransitionFinished(QQuickViewItem *i)
+{
+ FxViewItem *item = static_cast<FxViewItem *>(i);
+ if (item->releaseAfterTransition) {
+ releasePendingTransition.removeOne(item);
+ releaseItem(item);
+ }
+}
+
/*
This may return 0 if the item is being created asynchronously.
When the item becomes available, refill() will be called and the item
@@ -2768,21 +2141,23 @@ void QQuickItemView::destroyingItem(QQuickItem *item)
d->unrequestedItems.remove(item);
}
-void QQuickItemViewPrivate::releaseItem(FxViewItem *item)
+bool QQuickItemViewPrivate::releaseItem(FxViewItem *item)
{
Q_Q(QQuickItemView);
if (!item || !model)
- return;
+ return true;
if (trackedItem == item)
trackedItem = 0;
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
- if (model->release(item->item) == 0) {
+ QQuickVisualModel::ReleaseFlags flags = model->release(item->item);
+ if (flags == 0) {
// item was not destroyed, and we no longer reference it.
item->item->setVisible(false);
unrequestedItems.insert(item->item, model->indexOf(item->item, q));
}
delete item;
+ return flags != QQuickVisualModel::Referenced;
}
QQuickItem *QQuickItemViewPrivate::createHighlightItem()
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 01a6ee28ec..f252fb58f1 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -48,7 +48,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Qml)
+QT_MODULE(Quick)
class QQuickChangeSet;
@@ -83,6 +83,7 @@ class Q_AUTOTEST_EXPORT QQuickItemView : public QQuickFlickable
Q_PROPERTY(QQuickTransition *moveDisplaced READ moveDisplacedTransition WRITE setMoveDisplacedTransition NOTIFY moveDisplacedTransitionChanged)
Q_PROPERTY(QQuickTransition *remove READ removeTransition WRITE setRemoveTransition NOTIFY removeTransitionChanged)
Q_PROPERTY(QQuickTransition *removeDisplaced READ removeDisplacedTransition WRITE setRemoveDisplacedTransition NOTIFY removeDisplacedTransitionChanged)
+ Q_PROPERTY(QQuickTransition *displaced READ displacedTransition WRITE setDisplacedTransition NOTIFY displacedTransitionChanged)
Q_PROPERTY(QQmlComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
@@ -151,6 +152,9 @@ public:
QQuickTransition *removeDisplacedTransition() const;
void setRemoveDisplacedTransition(QQuickTransition *transition);
+ QQuickTransition *displacedTransition() const;
+ void setDisplacedTransition(QQuickTransition *transition);
+
QQmlComponent *highlight() const;
void setHighlight(QQmlComponent *);
@@ -211,6 +215,7 @@ signals:
void moveDisplacedTransitionChanged();
void removeTransitionChanged();
void removeDisplacedTransitionChanged();
+ void displacedTransitionChanged();
void highlightChanged();
void highlightItemChanged();
@@ -324,53 +329,9 @@ public:
QString m_nextSection;
};
-class QQuickViewTransitionAttached : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int index READ index NOTIFY indexChanged)
- Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged)
- Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged)
-
- Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged)
- Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
-
-public:
- QQuickViewTransitionAttached(QObject *parent);
-
- int index() const { return m_index; }
- QQuickItem *item() const { return m_item; }
- QPointF destination() const { return m_destination; }
-
- QList<int> targetIndexes() const { return m_targetIndexes; }
- QQmlListProperty<QObject> targetItems();
-
- static QQuickViewTransitionAttached *qmlAttachedProperties(QObject *);
-
-signals:
- void indexChanged();
- void itemChanged();
- void destinationChanged();
-
- void targetIndexesChanged();
- void targetItemsChanged();
-
-private:
- friend class FxViewItemTransitionManager;
- int m_index;
- QQuickItem *m_item;
- QPointF m_destination;
-
- QList<int> m_targetIndexes;
- QList<QObject *> m_targetItems;
-};
-
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QQuickViewTransitionAttached)
-QML_DECLARE_TYPEINFO(QQuickViewTransitionAttached, QML_HAS_ATTACHED_PROPERTIES)
-
QT_END_HEADER
#endif // QQUICKITEMVIEW_P_H
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index a4892e8972..80dacc0cb4 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -43,10 +43,10 @@
#define QQUICKITEMVIEW_P_P_H
#include "qquickitemview_p.h"
+#include "qquickitemviewtransition_p.h"
#include "qquickflickable_p_p.h"
#include "qquickvisualdatamodel_p.h"
#include "qquickvisualitemmodel_p.h"
-#include <private/qquicktransitionmanager_p_p.h>
#include <private/qquickchangeset_p.h>
@@ -54,58 +54,15 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
+QT_MODULE(Quick)
-class FxViewItem;
-class FxViewItemTransitionManager : public QQuickTransitionManager
-{
-public:
- enum TransitionType {
- NoTransition,
- PopulateTransition,
- AddTransition,
- MoveTransition,
- RemoveTransition
- };
-
- FxViewItemTransitionManager();
- ~FxViewItemTransitionManager();
-
- bool isActive() const;
- void startTransition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, const QPointF &to, bool isTargetItem);
-
- bool m_active;
- FxViewItem *m_item;
- QPointF m_toPos;
- FxViewItemTransitionManager::TransitionType m_type;
- bool m_isTarget;
-
-protected:
- virtual void finished();
-};
-
-
-class FxViewItem
+class FxViewItem : public QQuickViewItem
{
public:
FxViewItem(QQuickItem *, bool own);
virtual ~FxViewItem();
- qreal itemX() const;
- qreal itemY() const;
-
- void setVisible(bool visible);
-
- void setNextTransition(FxViewItemTransitionManager::TransitionType, bool isTargetItem);
- bool transitionScheduledOrRunning() const;
- bool isPendingRemoval() const;
-
- bool prepareTransition(const QRectF &viewBounds);
- void startTransition();
- void stopTransition();
- void finishedTransition();
-
// these are positions and sizes along the current direction of scrolling/flicking
virtual qreal position() const = 0;
virtual qreal endPosition() const = 0;
@@ -113,23 +70,10 @@ public:
virtual qreal sectionSize() const = 0;
virtual bool contains(qreal x, qreal y) const = 0;
- virtual QQuickItemView *itemView() const = 0;
- QQuickItem *item;
+ QQuickItemViewAttached *attached;
bool ownItem;
- int index;
bool releaseAfterTransition;
- QQuickItemViewAttached *attached;
-
- FxViewItemTransitionManager *transition;
- QPointF nextTransitionTo;
- FxViewItemTransitionManager::TransitionType nextTransitionType;
- bool isTransitionTarget;
- bool nextTransitionToSet;
-
-protected:
- void moveTo(const QPointF &pos);
- void resetTransitionData();
};
@@ -155,11 +99,12 @@ public:
};
-class QQuickItemViewPrivate : public QQuickFlickablePrivate
+class QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener
{
Q_DECLARE_PUBLIC(QQuickItemView)
public:
QQuickItemViewPrivate();
+ ~QQuickItemViewPrivate();
struct ChangeResult {
QQmlNullableValue<qreal> visiblePos;
@@ -225,7 +170,7 @@ public:
void mirrorChange();
FxViewItem *createItem(int modelIndex, bool asynchronous = false);
- virtual void releaseItem(FxViewItem *item);
+ virtual bool releaseItem(FxViewItem *item);
QQuickItem *createHighlightItem();
QQuickItem *createComponentItem(QQmlComponent *component, bool receiveItemGeometryChanges, bool createDefault = false);
@@ -243,13 +188,12 @@ public:
void repositionFirstItem(FxViewItem *prevVisibleItemsFirst, qreal prevVisibleItemsFirstPos,
FxViewItem *prevFirstVisible, ChangeResult *insertionResult, ChangeResult *removalResult);
+ void createTransitioner();
void prepareVisibleItemTransitions();
void prepareRemoveTransitions(QHash<QQuickChangeSet::MoveKey, FxViewItem *> *removedItems);
bool prepareNonVisibleItemTransition(FxViewItem *item, const QRectF &viewBounds);
+ virtual void viewItemTransitionFinished(QQuickViewItem *item);
- bool canTransition(FxViewItemTransitionManager::TransitionType type, bool asTarget) const;
- bool hasItemTransitions() const;
- void transitionNextReposition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, bool isTarget);
int findMoveKeyIndex(QQuickChangeSet::MoveKey key, const QVector<QQuickChangeSet::Remove> &changes) const;
void checkVisible() const;
@@ -281,7 +225,6 @@ public:
FxViewItem *requestedItem;
QQuickItemViewChangeSet currentChanges;
- // XXX split into struct
QQmlComponent *highlightComponent;
FxViewItem *highlight;
int highlightRange; // enum value
@@ -294,27 +237,13 @@ public:
QQmlComponent *footerComponent;
FxViewItem *footer;
- QQuickTransition *populateTransition;
- QQuickTransition *addTransition;
- QQuickTransition *addDisplacedTransition;
- QQuickTransition *moveTransition;
- QQuickTransition *moveDisplacedTransition;
- QQuickTransition *removeTransition;
- QQuickTransition *removeDisplacedTransition;
-
- QList<int> addTransitionIndexes;
- QList<int> moveTransitionIndexes;
- QList<int> removeTransitionIndexes;
- QList<QObject *> addTransitionTargets;
- QList<QObject *> moveTransitionTargets;
- QList<QObject *> removeTransitionTargets;
-
struct MovedItem {
FxViewItem *item;
QQuickChangeSet::MoveKey moveKey;
MovedItem(FxViewItem *i, QQuickChangeSet::MoveKey k)
: item(i), moveKey(k) {}
};
+ QQuickItemViewTransitioner *transitioner;
QList<FxViewItem *> releasePendingTransition;
mutable qreal minExtent;
@@ -333,7 +262,6 @@ public:
bool fillCacheBuffer : 1;
bool inRequest : 1;
bool requestedAsync : 1;
- bool usePopulateTransition : 1;
bool runDelayedRemoveTransition : 1;
protected:
diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp
new file mode 100644
index 0000000000..54375bf4ff
--- /dev/null
+++ b/src/quick/items/qquickitemviewtransition.cpp
@@ -0,0 +1,876 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickitemviewtransition_p.h"
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquicktransition_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static QList<int> qquickitemviewtransition_emptyIndexes = QList<int>();
+static QList<QObject *> qquickitemviewtransition_emptyTargets = QList<QObject *>();
+
+
+class QQuickItemViewTransitionJob : public QQuickTransitionManager
+{
+public:
+ QQuickItemViewTransitionJob();
+ ~QQuickItemViewTransitionJob();
+
+ void startTransition(QQuickViewItem *item, QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem);
+
+ QQuickItemViewTransitioner *m_transitioner;
+ QQuickViewItem *m_item;
+ QPointF m_toPos;
+ QQuickItemViewTransitioner::TransitionType m_type;
+ bool m_isTarget;
+
+protected:
+ virtual void finished();
+};
+
+
+QQuickItemViewTransitionJob::QQuickItemViewTransitionJob()
+ : m_transitioner(0)
+ , m_item(0)
+ , m_type(QQuickItemViewTransitioner::NoTransition)
+ , m_isTarget(false)
+{
+}
+
+QQuickItemViewTransitionJob::~QQuickItemViewTransitionJob()
+{
+ if (m_transitioner)
+ m_transitioner->runningJobs.remove(this);
+}
+
+void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem)
+{
+ if (type == QQuickItemViewTransitioner::NoTransition)
+ return;
+ if (!item) {
+ qWarning("startTransition(): invalid item");
+ return;
+ }
+ if (!transitioner) {
+ qWarning("startTransition(): invalid transitioner");
+ return;
+ }
+
+ QQuickTransition *trans = transitioner->transitionObject(type, isTargetItem);
+ if (!trans) {
+ qWarning("QQuickItemView: invalid view transition!");
+ return;
+ }
+
+ m_item = item;
+ m_transitioner = transitioner;
+ m_toPos = to;
+ m_type = type;
+ m_isTarget = isTargetItem;
+
+ QQuickViewTransitionAttached *attached =
+ static_cast<QQuickViewTransitionAttached*>(qmlAttachedPropertiesObject<QQuickViewTransitionAttached>(trans));
+ if (attached) {
+ attached->m_index = item->index;
+ attached->m_item = item->item;
+ attached->m_destination = to;
+ attached->m_targetIndexes = m_transitioner->targetIndexes(type);
+ attached->m_targetItems = m_transitioner->targetItems(type);
+ emit attached->indexChanged();
+ emit attached->itemChanged();
+ emit attached->destinationChanged();
+ emit attached->targetIndexesChanged();
+ emit attached->targetItemsChanged();
+ }
+
+ QQuickStateOperation::ActionList actions;
+ actions << QQuickAction(item->item, QLatin1String("x"), QVariant(to.x()));
+ actions << QQuickAction(item->item, QLatin1String("y"), QVariant(to.y()));
+
+ m_transitioner->runningJobs << this;
+ QQuickTransitionManager::transition(actions, trans, item->item);
+}
+
+void QQuickItemViewTransitionJob::finished()
+{
+ QQuickTransitionManager::finished();
+
+ if (m_transitioner)
+ m_transitioner->finishedTransition(this, m_item);
+
+ m_item = 0;
+ m_toPos.setX(0);
+ m_toPos.setY(0);
+ m_type = QQuickItemViewTransitioner::NoTransition;
+ m_isTarget = false;
+}
+
+
+QQuickItemViewTransitioner::QQuickItemViewTransitioner()
+ : populateTransition(0)
+ , addTransition(0), addDisplacedTransition(0)
+ , moveTransition(0), moveDisplacedTransition(0)
+ , removeTransition(0), removeDisplacedTransition(0)
+ , displacedTransition(0)
+ , changeListener(0)
+ , usePopulateTransition(false)
+{
+}
+
+QQuickItemViewTransitioner::~QQuickItemViewTransitioner()
+{
+ for (QSet<QQuickItemViewTransitionJob *>::iterator it = runningJobs.begin(); it != runningJobs.end(); ++it)
+ (*it)->m_transitioner = 0;
+}
+
+bool QQuickItemViewTransitioner::canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const
+{
+ if (!asTarget
+ && type != QQuickItemViewTransitioner::NoTransition && type != QQuickItemViewTransitioner::PopulateTransition
+ && displacedTransition && displacedTransition->enabled()) {
+ return true;
+ }
+
+ switch (type) {
+ case QQuickItemViewTransitioner::NoTransition:
+ break;
+ case QQuickItemViewTransitioner::PopulateTransition:
+ return usePopulateTransition
+ && populateTransition && populateTransition->enabled();
+ case QQuickItemViewTransitioner::AddTransition:
+ if (asTarget)
+ return addTransition && addTransition->enabled();
+ else
+ return addDisplacedTransition && addDisplacedTransition->enabled();
+ case QQuickItemViewTransitioner::MoveTransition:
+ if (asTarget)
+ return moveTransition && moveTransition->enabled();
+ else
+ return moveDisplacedTransition && moveDisplacedTransition->enabled();
+ case QQuickItemViewTransitioner::RemoveTransition:
+ if (asTarget)
+ return removeTransition && removeTransition->enabled();
+ else
+ return removeDisplacedTransition && removeDisplacedTransition->enabled();
+ }
+ return false;
+}
+
+void QQuickItemViewTransitioner::transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget)
+{
+ bool matchedTransition = false;
+ if (type == QQuickItemViewTransitioner::AddTransition) {
+ // don't run add transitions for added items while populating
+ if (usePopulateTransition)
+ matchedTransition = false;
+ else
+ matchedTransition = canTransition(type, isTarget);
+ } else {
+ matchedTransition = canTransition(type, isTarget);
+ }
+
+ if (matchedTransition) {
+ item->setNextTransition(type, isTarget);
+ } else {
+ // the requested transition type is not valid, but the item is scheduled/in another
+ // transition, so cancel it to allow the item to move directly to the correct pos
+ if (item->transitionScheduledOrRunning())
+ item->stopTransition();
+ }
+}
+
+QQuickTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget)
+{
+ if (type == QQuickItemViewTransitioner::NoTransition)
+ return 0;
+
+ if (type == PopulateTransition)
+ asTarget = true; // no separate displaced transition
+
+ QQuickTransition *trans = 0;
+ switch (type) {
+ case NoTransition:
+ break;
+ case PopulateTransition:
+ trans = populateTransition;
+ break;
+ case AddTransition:
+ trans = asTarget ? addTransition : addDisplacedTransition;
+ break;
+ case MoveTransition:
+ trans = asTarget ? moveTransition : moveDisplacedTransition;
+ break;
+ case RemoveTransition:
+ trans = asTarget ? removeTransition : removeDisplacedTransition;
+ break;
+ }
+
+ if (!asTarget && (!trans || !trans->enabled()))
+ trans = displacedTransition;
+ if (trans && trans->enabled())
+ return trans;
+ return 0;
+}
+
+const QList<int> &QQuickItemViewTransitioner::targetIndexes(QQuickItemViewTransitioner::TransitionType type) const
+{
+ switch (type) {
+ case QQuickItemViewTransitioner::NoTransition:
+ break;
+ case QQuickItemViewTransitioner::PopulateTransition:
+ case QQuickItemViewTransitioner::AddTransition:
+ return addTransitionIndexes;
+ case QQuickItemViewTransitioner::MoveTransition:
+ return moveTransitionIndexes;
+ case QQuickItemViewTransitioner::RemoveTransition:
+ return removeTransitionIndexes;
+ }
+
+ return qquickitemviewtransition_emptyIndexes;
+}
+
+const QList<QObject *> &QQuickItemViewTransitioner::targetItems(QQuickItemViewTransitioner::TransitionType type) const
+{
+ switch (type) {
+ case QQuickItemViewTransitioner::NoTransition:
+ break;
+ case QQuickItemViewTransitioner::PopulateTransition:
+ case QQuickItemViewTransitioner::AddTransition:
+ return addTransitionTargets;
+ case QQuickItemViewTransitioner::MoveTransition:
+ return moveTransitionTargets;
+ case QQuickItemViewTransitioner::RemoveTransition:
+ return removeTransitionTargets;
+ }
+
+ return qquickitemviewtransition_emptyTargets;
+}
+
+void QQuickItemViewTransitioner::finishedTransition(QQuickItemViewTransitionJob *job, QQuickViewItem *item)
+{
+ if (!runningJobs.contains(job))
+ return;
+ runningJobs.remove(job);
+ if (item) {
+ item->finishedTransition();
+ if (changeListener)
+ changeListener->viewItemTransitionFinished(item);
+ }
+}
+
+
+QQuickViewItem::QQuickViewItem(QQuickItem *i)
+ : item(i)
+ , transition(0)
+ , nextTransitionType(QQuickItemViewTransitioner::NoTransition)
+ , index(-1)
+ , isTransitionTarget(false)
+ , nextTransitionToSet(false)
+{
+}
+
+QQuickViewItem::~QQuickViewItem()
+{
+ delete transition;
+}
+
+qreal QQuickViewItem::itemX() const
+{
+ if (nextTransitionType != QQuickItemViewTransitioner::NoTransition)
+ return nextTransitionToSet ? nextTransitionTo.x() : item->x();
+ else if (transition && transition->isRunning())
+ return transition->m_toPos.x();
+ else
+ return item->x();
+}
+
+qreal QQuickViewItem::itemY() const
+{
+ // If item is transitioning to some pos, return that dest pos.
+ // If item was redirected to some new pos before the current transition finished,
+ // return that new pos.
+ if (nextTransitionType != QQuickItemViewTransitioner::NoTransition)
+ return nextTransitionToSet ? nextTransitionTo.y() : item->y();
+ else if (transition && transition->isRunning())
+ return transition->m_toPos.y();
+ else
+ return item->y();
+}
+
+void QQuickViewItem::moveTo(const QPointF &pos)
+{
+ if (transitionScheduledOrRunning()) {
+ nextTransitionTo = pos;
+ nextTransitionToSet = true;
+ } else {
+ item->setPos(pos);
+ }
+}
+
+void QQuickViewItem::setVisible(bool visible)
+{
+ if (!visible && transitionScheduledOrRunning())
+ return;
+ item->setVisible(visible);
+}
+
+bool QQuickViewItem::transitionScheduledOrRunning() const
+{
+ return (transition && transition->isRunning())
+ || nextTransitionType != QQuickItemViewTransitioner::NoTransition;
+}
+
+bool QQuickViewItem::transitionRunning() const
+{
+ return (transition && transition->isRunning());
+}
+
+bool QQuickViewItem::isPendingRemoval() const
+{
+ if (nextTransitionType == QQuickItemViewTransitioner::RemoveTransition)
+ return isTransitionTarget;
+ if (transition && transition->isRunning() && transition->m_type == QQuickItemViewTransitioner::RemoveTransition)
+ return transition->m_isTarget;
+ return false;
+}
+
+bool QQuickViewItem::prepareTransition(const QRectF &viewBounds)
+{
+ bool doTransition = false;
+
+ // If item is not already moving somewhere, set it to not move anywhere.
+ // This ensures that removed targets don't transition to the default (0,0) and that
+ // items set for other transition types only transition if they actually move somewhere.
+ if (nextTransitionType != QQuickItemViewTransitioner::NoTransition && !nextTransitionToSet)
+ moveTo(item->pos());
+
+ // For move transitions (both target and displaced) and displaced transitions of other
+ // types, only run the transition if the item is actually moving to another position.
+
+ switch (nextTransitionType) {
+ case QQuickItemViewTransitioner::NoTransition:
+ {
+ return false;
+ }
+ case QQuickItemViewTransitioner::PopulateTransition:
+ {
+ return true;
+ }
+ case QQuickItemViewTransitioner::AddTransition:
+ case QQuickItemViewTransitioner::RemoveTransition:
+ if (viewBounds.isNull()) {
+ if (isTransitionTarget)
+ doTransition = true;
+ else
+ doTransition = transitionWillChangePosition();
+ } else if (isTransitionTarget) {
+ // For Add targets, do transition if item is moving into visible area
+ // For Remove targets, do transition if item is currently in visible area
+ doTransition = (nextTransitionType == QQuickItemViewTransitioner::AddTransition)
+ ? viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))
+ : viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height()));
+ if (!doTransition)
+ item->setPos(nextTransitionTo);
+ } else {
+ if (viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height()))
+ || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))) {
+ doTransition = transitionWillChangePosition();
+ } else {
+ item->setPos(nextTransitionTo);
+ }
+ }
+ break;
+ case QQuickItemViewTransitioner::MoveTransition:
+ // do transition if moving from or into visible area
+ if (transitionWillChangePosition()) {
+ doTransition = viewBounds.isNull()
+ || viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height()))
+ || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()));
+ if (!doTransition)
+ item->setPos(nextTransitionTo);
+ }
+ break;
+ }
+
+ if (!doTransition)
+ resetTransitionData();
+ return doTransition;
+}
+
+void QQuickViewItem::startTransition(QQuickItemViewTransitioner *transitioner)
+{
+ if (nextTransitionType == QQuickItemViewTransitioner::NoTransition)
+ return;
+
+ if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) {
+ delete transition;
+ transition = new QQuickItemViewTransitionJob;
+ }
+
+ // if item is not already moving somewhere, set it to not move anywhere
+ // so that removed items do not move to the default (0,0)
+ if (!nextTransitionToSet)
+ moveTo(item->pos());
+
+ transition->startTransition(this, transitioner, nextTransitionType, nextTransitionTo, isTransitionTarget);
+ nextTransitionType = QQuickItemViewTransitioner::NoTransition;
+}
+
+void QQuickViewItem::stopTransition()
+{
+ if (transition) {
+ transition->cancel();
+ delete transition;
+ transition = 0;
+ }
+ resetTransitionData();
+ finishedTransition();
+}
+
+void QQuickViewItem::setNextTransition(QQuickItemViewTransitioner::TransitionType type, bool isTargetItem)
+{
+ // Don't reset nextTransitionToSet - once it is set, it cannot be changed
+ // until the animation finishes since the itemX() and itemY() may be used
+ // to calculate positions for transitions for other items in the view.
+ nextTransitionType = type;
+ isTransitionTarget = isTargetItem;
+}
+
+bool QQuickViewItem::transitionWillChangePosition() const
+{
+ if (transitionRunning() && transition->m_toPos != nextTransitionTo)
+ return true;
+ return nextTransitionTo != item->pos();
+}
+
+void QQuickViewItem::finishedTransition()
+{
+ nextTransitionToSet = false;
+ nextTransitionTo = QPointF();
+}
+
+void QQuickViewItem::resetTransitionData()
+{
+ nextTransitionType = QQuickItemViewTransitioner::NoTransition;
+ isTransitionTarget = false;
+ nextTransitionTo = QPointF();
+ nextTransitionToSet = false;
+}
+
+
+QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent)
+ : QObject(parent), m_item(0), m_index(-1)
+{
+}
+/*!
+ \qmlclass ViewTransition QQuickViewTransitionAttached
+ \inqmlmodule QtQuick 2
+ \ingroup qml-view-elements
+ \brief The ViewTransition attached property provides details on items under transition in a view.
+
+ With ListView and GridView, it is possible to specify transitions that should be applied whenever
+ the items in the view change as a result of modifications to the view's model. They both have the
+ following properties that can be set to the appropriate transitions to be run for various
+ operations:
+
+ \list
+ \o \c populate - the transition to run when a view is created, or when the model changes
+ \o \c add - the transition to apply to items that are added to the view
+ \o \c remove - the transition to apply to items that are removed from the view
+ \o \c move - the transition to apply to items that are moved within the view (i.e. as a result
+ of a move operation in the model)
+ \o \c displaced - the generic transition to be applied to any items that are displaced by an
+ add, move or remove operation
+ \o \c addDisplaced, \c removeDisplaced and \c moveDisplaced - the transitions to be applied when
+ items are displaced by add, move, or remove operations, respectively (these override the
+ generic displaced transition if specified)
+ \endlist
+
+ For the \l Row, \l Column, \l Grid and \l Flow positioner elements, which operate with collections of child
+ items rather than data models, the following properties are used instead:
+
+ \list
+ \o \c add - the transition to apply to items that are created for the positioner, added to
+ or reparented to the positioner, or items that have become \l {Item::}{visible}
+ \o \c move - the transition to apply to items that have moved within the positioner, including
+ when they are displaced due to the addition or removal of other items, or when items are otherwise
+ rearranged within the positioner, or when items are repositioned due to the resizing of other
+ items in the positioner
+ \endlist
+
+ View transitions have access to a ViewTransition attached property that
+ provides details of the items that are under transition and the operation that triggered the
+ transition. Since view transitions are run once per item, these details can be used to customise
+ each transition for each individual item.
+
+ The ViewTransition attached property provides the following properties specific to the item to
+ which the transition is applied:
+
+ \list
+ \o ViewTransition.item - the item that is under transition
+ \o ViewTransition.index - the index of this item
+ \o ViewTransition.destination - the (x,y) point to which this item is moving for the relevant view operation
+ \endlist
+
+ In addition, ViewTransition provides properties specific to the items which are the target
+ of the operation that triggered the transition:
+
+ \list
+ \o ViewTransition.targetIndexes - the indexes of the target items
+ \o ViewTransition.targetItems - the target items themselves
+ \endlist
+
+ (Note that for the \l Row, \l Column, \l Grid and \l Flow positioner elements, the \c move transition only
+ provides these two additional details when the transition is triggered by the addition of items
+ to a positioner.)
+
+ View transitions can be written without referring to any of the attributes listed
+ above. These attributes merely provide extra details that are useful for customising view
+ transitions.
+
+ Following is an introduction to view transitions and the ways in which the ViewTransition
+ attached property can be used to augment view transitions.
+
+
+ \section2 View transitions: a simple example
+
+ Here is a basic example of the use of view transitions. The view below specifies transitions for
+ the \c add and \c displaced properties, which will be run when items are added to the view:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0
+
+ When the space key is pressed, adding an item to the model, the new item will fade in and
+ increase in scale over 400 milliseconds as it is added to the view. Also, any item that is
+ displaced by the addition of a new item will animate to its new position in the view over
+ 400 milliseconds, as specified by the \c displaced transition.
+
+ If five items were inserted in succession at index 0, the effect would be this:
+
+ \image viewtransitions-basic.gif
+
+ Notice that the NumberAnimation objects above do not need to specify a \c target to animate
+ the appropriate item. Also, the NumberAnimation in the \c addTransition does not need to specify
+ the \c to value to move the item to its correct position in the view. This is because the view
+ implicitly sets the \c target and \c to values with the correct item and final item position
+ values if these properties are not explicitly defined.
+
+ At its simplest, a view transition may just animate an item to its new position following a
+ view operation, just as the \c displaced transition does above, or animate some item properties,
+ as in the \c add transition above. Additionally, a view transition may make use of the
+ ViewTransition attached property to customise animation behavior for different items. Following
+ are some examples of how this can be achieved.
+
+
+ \section2 Using the ViewTransition attached property
+
+ As stated, the various ViewTransition properties provide details specific to the individual item
+ being transitioned as well as the operation that triggered the transition. In the animation above,
+ five items are inserted in succession at index 0. When the fifth and final insertion takes place,
+ adding "Item 4" to the view, the \c add transition is run once (for the inserted item) and the
+ \c displaced transition is run four times (once for each of the four existing items in the view).
+
+ At this point, if we examined the \c displaced transition that was run for the bottom displaced
+ item ("Item 0"), the ViewTransition property values provided to this transition would be as follows:
+
+ \table
+ \header
+ \o Property
+ \o Value
+ \o Explanation
+ \row
+ \o ViewTransition.item
+ \o "Item 0" delegate instance
+ \o The "Item 0" \l Rectangle object itself
+ \row
+ \o ViewTransition.index
+ \o \c int value of 4
+ \o The index of "Item 0" within the model following the add operation
+ \row
+ \o ViewTransition.destination
+ \o \l point value of (0, 120)
+ \o The position that "Item 0" is moving to
+ \row
+ \o ViewTransition.targetIndexes
+ \o \c int array, just contains the integer "0" (zero)
+ \o The index of "Item 4", the new item added to the view
+ \row
+ \o ViewTransition.targetItems
+ \o object array, just contains the "Item 4" delegate instance
+ \o The "Item 4" \l Rectangle object - the new item added to the view
+ \endtable
+
+ The ViewTransition.targetIndexes and ViewTransition.targetItems lists provide the items and
+ indexes of all delegate instances that are the targets of the relevant operation. For an add
+ operation, these are all the items that are added into the view; for a remove, these are all
+ the items removed from the view, and so on. (Note these lists will only contain references to
+ items that have been created within the view or its cached items; targets that are not within
+ the visible area of the view or within the item cache will not be accessible.)
+
+ So, while the ViewTransition.item, ViewTransition.index and ViewTransition.destination values
+ vary for each individual transition that is run, the ViewTransition.targetIndexes and
+ ViewTransition.targetItems values are the same for every \c add and \c displaced transition
+ that is triggered by a particular add operation.
+
+
+ \section3 Delaying animations based on index
+
+ Since each view transition is run once for each item affected by the transition, the ViewTransition
+ properties can be used within a transition to define custom behavior for each item's transition.
+ For example, the ListView in the previous example could use this information to create a ripple-type
+ effect on the movement of the displaced items.
+
+ This can be achieved by modifying the \c displaced transition so that it delays the animation of
+ each displaced item based on the difference between its index (provided by ViewTransition.index)
+ and the first removed index (provided by ViewTransition.targetIndexes):
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml 0
+
+ Each displaced item delays its animation by an additional 100 milliseconds, producing a subtle
+ ripple-type effect when items are displaced by the add, like this:
+
+ \image viewtransitions-delayedbyindex.gif
+
+
+ \section3 Animating items to intermediate positions
+
+ The ViewTransition.item property gives a reference to the item to which the transition is being
+ applied. This can be used to access any of the item's attributes, custom \c property values,
+ and so on.
+
+ Below is a modification of the \c displaced transition from the previous example. It adds a
+ ParallelAnimation with nested NumberAnimation objects that reference ViewTransition.item to access
+ each item's \c x and \c y values at the start of their transitions. This allows each item to
+ animate to an intermediate position relative to its starting point for the transition, before
+ animating to its final position in the view:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml 0
+
+ Now, a displaced item will first move to a position of (20, 50) relative to its starting
+ position, and then to its final, correct position in the view:
+
+ \image viewtransitions-intermediatemove.gif
+
+ Since the final NumberAnimation does not specify a \c to value, the view implicitly sets this
+ value to the item's final position in the view, and so this last animation will move this item
+ to the correct place. If the transition requires the final position of the item for some calculation,
+ this is accessible through ViewTransition.destination.
+
+ Instead of using multiple NumberAnimations, you could use a PathAnimation to animate an item over
+ a curved path. For example, the \c add transition in the previous example could be augmented with
+ a PathAnimation as follows: to animate newly added items along a path:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml 0
+
+ This animates newly added items along a path. Notice that each path is specified relative to
+ each item's final destination point, so that items inserted at different indexes start their
+ paths from different positions:
+
+ \image viewtransitions-pathanim.gif
+
+
+ \section2 Handling interrupted animations
+
+ A view transition may be interrupted at any time if a different view transition needs to be
+ applied while the original transition is in progress. For example, say Item A is inserted at index 0
+ and undergoes an "add" transition; then, Item B is inserted at index 0 in quick succession before
+ Item A's transition has finished. Since Item B is inserted before Item A, it will displace Item
+ A, causing the view to interrupt Item A's "add" transition mid-way and start a "displaced"
+ transition on Item A instead.
+
+ For simple animations that simply animate an item's movement to its final destination, this
+ interruption is unlikely to require additional consideration. However, if a transition changes other
+ properties, this interruption may cause unwanted side effects. Consider the first example on this
+ page, repeated below for convenience:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0
+
+ If multiple items are added in rapid succession, without waiting for a previous transition
+ to finish, this is the result:
+
+ \image viewtransitions-interruptedbad.gif
+
+ Each newly added item undergoes an \c add transition, but before the transition can finish,
+ another item is added, displacing the previously added item. Because of this, the \c add
+ transition on the previously added item is interrupted and a \c displaced transition is
+ started on the item instead. Due to the interruption, the \c opacity and \c scale animations
+ have not completed, thus producing items with opacity and scale that are below 1.0.
+
+ To fix this, the \c displaced transition should additionally ensure the item properties are
+ set to the end values specified in the \c add transition, effectively resetting these values
+ whenever an item is displaced. In this case, it means setting the item opacity and scale to 1.0:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml 0
+
+ Now, when an item's \c add transition is interrupted, its opacity and scale are animated to 1.0
+ upon displacement, avoiding the erroneous visual effects from before:
+
+ \image viewtransitions-interruptedgood.gif
+
+ The same principle applies to any combination of view transitions. An added item may be moved
+ before its add transition finishes, or a moved item may be removed before its moved transition
+ finishes, and so on; so, the rule of thumb is that every transition should handle the same set of
+ properties.
+
+
+ \section2 Restrictions regarding ScriptAction
+
+ When a view transition is initialized, any property bindings that refer to the ViewTransition
+ attached property are evaluated in preparation for the transition. Due to the nature of the
+ internal construction of a view transition, the attributes of the ViewTransition attached
+ property are only valid for the relevant item when the transition is initialized, and may not be
+ valid when the transition is actually run.
+
+ Therefore, a ScriptAction within a view transition should not refer to the ViewTransition
+ attached property, as it may not refer to the expected values at the time that the ScriptAction
+ is actually invoked. Consider the following example:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml 0
+
+ When the space key is pressed, three items are moved from index 5 to index 1. For each moved
+ item, the \c moveTransition sequence presumably animates the item's color to "yellow", then
+ animates it to its final position, then changes the item color back to "lightsteelblue" using a
+ ScriptAction. However, when run, the transition does not produce the intended result:
+
+ \image viewtransitions-scriptactionbad.gif
+
+ Only the last moved item is returned to the "lightsteelblue" color; the others remain yellow. This
+ is because the ScriptAction is not run until after the transition has already been initialized, by
+ which time the ViewTransition.item value has changed to refer to a different item; the item that
+ the script had intended to refer to is not the one held by ViewTransition.item at the time the
+ ScriptAction is actually invoked.
+
+ In this instance, to avoid this issue, the view could set the property using a PropertyAction
+ instead:
+
+ \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml 0
+
+ When the transition is initialized, the PropertyAction \c target will be set to the respective
+ ViewTransition.item for the transition and will later run with the correct item target as
+ expected.
+ */
+
+/*!
+ \qmlattachedproperty list QtQuick2::ViewTransition::index
+
+ This attached property holds the index of the item that is being
+ transitioned.
+
+ Note that if the item is being moved, this property holds the index that
+ the item is moving to, not from.
+*/
+
+/*!
+ \qmlattachedproperty list QtQuick2::ViewTransition::item
+
+ This attached property holds the the item that is being transitioned.
+
+ \warning This item should not be kept and referred to outside of the transition
+ as it may become invalid as the view changes.
+*/
+
+/*!
+ \qmlattachedproperty list QtQuick2::ViewTransition::destination
+
+ This attached property holds the final destination position for the transitioned
+ item within the view.
+
+ This property value is a \l point with \c x and \c y properties.
+*/
+
+/*!
+ \qmlattachedproperty list QtQuick2::ViewTransition::targetIndexes
+
+ This attached property holds a list of the indexes of the items in view
+ that are the target of the relevant operation.
+
+ The targets are the items that are the subject of the operation. For
+ an add operation, these are the items being added; for a remove, these
+ are the items being removed; for a move, these are the items being
+ moved.
+
+ For example, if the transition was triggered by an insert operation
+ that added two items at index 1 and 2, this targetIndexes list would
+ have the value [1,2].
+
+ \note The targetIndexes list only contains the indexes of items that are actually
+ in view, or will be in the view once the relevant operation completes.
+
+ \sa QtQuick2::ViewTransition::targetIndexes
+*/
+
+/*!
+ \qmlattachedproperty list QtQuick2::ViewTransition::targetItems
+
+ This attached property holds the list of items in view that are the
+ target of the relevant operation.
+
+ The targets are the items that are the subject of the operation. For
+ an add operation, these are the items being added; for a remove, these
+ are the items being removed; for a move, these are the items being
+ moved.
+
+ For example, if the transition was triggered by an insert operation
+ that added two items at index 1 and 2, this targetItems list would
+ contain these two items.
+
+ \note The targetItems list only contains items that are actually
+ in view, or will be in the view once the relevant operation completes.
+
+ \warning The objects in this list should not be kept and referred to
+ outside of the transition as the items may become invalid. The targetItems
+ are only valid when the Transition is initially created; this also means
+ they should not be used by ScriptAction objects in the Transition, which are
+ not evaluated until the transition is run.
+
+ \sa QtQuick2::ViewTransition::targetIndexes
+*/
+QQmlListProperty<QObject> QQuickViewTransitionAttached::targetItems()
+{
+ return QQmlListProperty<QObject>(this, m_targetItems);
+}
+
+QQuickViewTransitionAttached *QQuickViewTransitionAttached::qmlAttachedProperties(QObject *obj)
+{
+ return new QQuickViewTransitionAttached(obj);
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
new file mode 100644
index 0000000000..3fb43d6b96
--- /dev/null
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKITEMVIEWTRANSITION_P_P_H
+#define QQUICKITEMVIEWTRANSITION_P_P_H
+
+#include <private/qquicktransitionmanager_p_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Quick)
+
+class QQuickItem;
+class QQuickViewItem;
+class QQuickItemViewTransitionJob;
+
+
+class QQuickItemViewTransitionChangeListener
+{
+public:
+ QQuickItemViewTransitionChangeListener() {}
+ virtual ~QQuickItemViewTransitionChangeListener() {}
+
+ virtual void viewItemTransitionFinished(QQuickViewItem *item) = 0;
+};
+
+
+class QQuickItemViewTransitioner
+{
+public:
+ enum TransitionType {
+ NoTransition,
+ PopulateTransition,
+ AddTransition,
+ MoveTransition,
+ RemoveTransition
+ };
+
+ QQuickItemViewTransitioner();
+ virtual ~QQuickItemViewTransitioner();
+
+ bool canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const;
+ void transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget);
+
+ QQuickTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget);
+ const QList<int> &targetIndexes(QQuickItemViewTransitioner::TransitionType type) const;
+ const QList<QObject *> &targetItems(QQuickItemViewTransitioner::TransitionType type) const;
+
+ inline void setPopulateTransitionEnabled(bool b) { usePopulateTransition = b; }
+ inline void setChangeListener(QQuickItemViewTransitionChangeListener *obj) { changeListener = obj; }
+
+ QSet<QQuickItemViewTransitionJob *> runningJobs;
+
+ QList<int> addTransitionIndexes;
+ QList<int> moveTransitionIndexes;
+ QList<int> removeTransitionIndexes;
+ QList<QObject *> addTransitionTargets;
+ QList<QObject *> moveTransitionTargets;
+ QList<QObject *> removeTransitionTargets;
+
+ QQuickTransition *populateTransition;
+ QQuickTransition *addTransition;
+ QQuickTransition *addDisplacedTransition;
+ QQuickTransition *moveTransition;
+ QQuickTransition *moveDisplacedTransition;
+ QQuickTransition *removeTransition;
+ QQuickTransition *removeDisplacedTransition;
+ QQuickTransition *displacedTransition;
+
+private:
+ friend class QQuickItemViewTransitionJob;
+
+ QQuickItemViewTransitionChangeListener *changeListener;
+ bool usePopulateTransition;
+
+ void finishedTransition(QQuickItemViewTransitionJob *job, QQuickViewItem *item);
+};
+
+
+/*
+ An item in a view, that can be transitioned using QQuickViewTransitionJob.
+ */
+class QQuickViewItem
+{
+public:
+ QQuickViewItem(QQuickItem *i);
+ virtual ~QQuickViewItem();
+
+ qreal itemX() const;
+ qreal itemY() const;
+
+ void moveTo(const QPointF &pos);
+ void setVisible(bool visible);
+
+ bool transitionScheduledOrRunning() const;
+ bool transitionRunning() const;
+ bool isPendingRemoval() const;
+
+ bool prepareTransition(const QRectF &viewBounds);
+ void startTransition(QQuickItemViewTransitioner *transitioner);
+ void stopTransition();
+
+ QPointF nextTransitionTo;
+ QQuickItem *item;
+ QQuickItemViewTransitionJob *transition;
+ QQuickItemViewTransitioner::TransitionType nextTransitionType;
+ int index;
+ bool isTransitionTarget;
+ bool nextTransitionToSet;
+
+private:
+ friend class QQuickItemViewTransitioner;
+ friend class QQuickItemViewTransitionJob;
+ void setNextTransition(QQuickItemViewTransitioner::TransitionType, bool isTargetItem);
+ bool transitionWillChangePosition() const;
+ void finishedTransition();
+ void resetTransitionData();
+};
+
+
+class QQuickViewTransitionAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged)
+ Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged)
+
+ Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
+
+public:
+ QQuickViewTransitionAttached(QObject *parent);
+
+ int index() const { return m_index; }
+ QQuickItem *item() const { return m_item; }
+ QPointF destination() const { return m_destination; }
+
+ QList<int> targetIndexes() const { return m_targetIndexes; }
+ QQmlListProperty<QObject> targetItems();
+
+ static QQuickViewTransitionAttached *qmlAttachedProperties(QObject *);
+
+signals:
+ void indexChanged();
+ void itemChanged();
+ void destinationChanged();
+
+ void targetIndexesChanged();
+ void targetItemsChanged();
+
+private:
+ friend class QQuickItemViewTransitionJob;
+ QPointF m_destination;
+ QList<int> m_targetIndexes;
+ QList<QObject *> m_targetItems;
+
+ QQuickItem *m_item;
+ int m_index;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickViewTransitionAttached)
+QML_DECLARE_TYPEINFO(QQuickViewTransitionAttached, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // QQUICKITEMVIEWTRANSITION_P_P_H
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index beb607dde5..5e9a685cf5 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -93,7 +93,7 @@ public:
virtual FxViewItem *newViewItem(int index, QQuickItem *item);
virtual void initializeViewItem(FxViewItem *item);
- virtual void releaseItem(FxViewItem *item);
+ virtual bool releaseItem(FxViewItem *item);
virtual void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer);
virtual void repositionPackageItemAt(QQuickItem *item, int index);
virtual void resetFirstItemPosition(qreal pos = 0.0);
@@ -236,7 +236,7 @@ void QQuickViewSection::setLabelPositioning(int l)
class FxListItemSG : public FxViewItem
{
public:
- FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, own), section(0), view(v) {
+ FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, own), view(v) {
attached = static_cast<QQuickListViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(item));
if (attached)
static_cast<QQuickListViewAttached*>(attached)->setView(view);
@@ -244,12 +244,21 @@ public:
~FxListItemSG() {}
+ inline QQuickItem *section() const {
+ return attached ? static_cast<QQuickListViewAttached*>(attached)->m_sectionItem : 0;
+ }
+ void setSection(QQuickItem *s) {
+ if (!attached)
+ attached = static_cast<QQuickListViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(item));
+ static_cast<QQuickListViewAttached*>(attached)->m_sectionItem = s;
+ }
+
qreal position() const {
- if (section) {
+ if (section()) {
if (view->orientation() == QQuickListView::Vertical)
- return section->y();
+ return section()->y();
else
- return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section->width()-section->x() : section->x());
+ return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section()->width()-section()->x() : section()->x());
} else {
return itemPosition();
}
@@ -261,8 +270,8 @@ public:
return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -item->width()-itemX() : itemX());
}
qreal size() const {
- if (section)
- return (view->orientation() == QQuickListView::Vertical ? item->height()+section->height() : item->width()+section->width());
+ if (section())
+ return (view->orientation() == QQuickListView::Vertical ? item->height()+section()->height() : item->width()+section()->width());
else
return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width());
}
@@ -270,8 +279,8 @@ public:
return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width());
}
qreal sectionSize() const {
- if (section)
- return (view->orientation() == QQuickListView::Vertical ? section->height() : section->width());
+ if (section())
+ return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width());
return 0.0;
}
qreal endPosition() const {
@@ -285,14 +294,14 @@ public:
}
void setPosition(qreal pos) {
// position the section immediately even if there is a transition
- if (section) {
+ if (section()) {
if (view->orientation() == QQuickListView::Vertical) {
- section->setY(pos);
+ section()->setY(pos);
} else {
if (view->effectiveLayoutDirection() == Qt::RightToLeft)
- section->setX(-section->width()-pos);
+ section()->setX(-section()->width()-pos);
else
- section->setX(pos);
+ section()->setX(pos);
}
}
moveTo(pointForPosition(pos));
@@ -307,27 +316,23 @@ public:
return (x >= itemX() && x < itemX() + item->width() &&
y >= itemY() && y < itemY() + item->height());
}
- QQuickItemView *itemView() const {
- return view;
- }
- QQuickItem *section;
QQuickListView *view;
private:
QPointF pointForPosition(qreal pos) const {
if (view->orientation() == QQuickListView::Vertical) {
- if (section)
- pos += section->height();
+ if (section())
+ pos += section()->height();
return QPointF(itemX(), pos);
} else {
if (view->effectiveLayoutDirection() == Qt::RightToLeft) {
- if (section)
- pos += section->width();
+ if (section())
+ pos += section()->width();
return QPointF(-item->width() - pos, itemY());
} else {
- if (section)
- pos += section->width();
+ if (section())
+ pos += section()->width();
return QPointF(pos, itemY());
}
}
@@ -566,25 +571,31 @@ void QQuickListViewPrivate::initializeViewItem(FxViewItem *item)
}
}
-void QQuickListViewPrivate::releaseItem(FxViewItem *item)
+bool QQuickListViewPrivate::releaseItem(FxViewItem *item)
{
- if (item) {
- FxListItemSG* listItem = static_cast<FxListItemSG*>(item);
- if (listItem->section) {
- int i = 0;
- do {
- if (!sectionCache[i]) {
- sectionCache[i] = listItem->section;
- sectionCache[i]->setVisible(false);
- listItem->section = 0;
- break;
- }
- ++i;
- } while (i < sectionCacheSize);
- delete listItem->section;
- }
+ if (!item || !model)
+ return true;
+
+ QQuickListViewAttached *att = static_cast<QQuickListViewAttached*>(item->attached);
+
+ bool released = QQuickItemViewPrivate::releaseItem(item);
+ if (released && att && att->m_sectionItem) {
+ // We hold no more references to this item
+ int i = 0;
+ do {
+ if (!sectionCache[i]) {
+ sectionCache[i] = att->m_sectionItem;
+ sectionCache[i]->setVisible(false);
+ att->m_sectionItem = 0;
+ break;
+ }
+ ++i;
+ } while (i < sectionCacheSize);
+ delete att->m_sectionItem;
+ att->m_sectionItem = 0;
}
- QQuickItemViewPrivate::releaseItem(item);
+
+ return released;
}
bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool doBuffer)
@@ -629,7 +640,7 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d
#endif
if (!(item = static_cast<FxListItemSG*>(createItem(modelIndex, doBuffer))))
break;
- if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
+ if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
item->setPosition(pos);
item->item->setVisible(!doBuffer);
pos += item->size() + spacing;
@@ -649,7 +660,7 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d
break;
--visibleIndex;
visiblePos -= item->size() + spacing;
- if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
+ if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems()
item->setPosition(visiblePos);
item->item->setVisible(!doBuffer);
visibleItems.prepend(item);
@@ -944,18 +955,18 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem)
if (listItem->attached->m_prevSection != listItem->attached->m_section
&& (sectionCriteria->labelPositioning() & QQuickViewSection::InlineLabels
|| (listItem->index == 0 && sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart))) {
- if (!listItem->section) {
+ if (!listItem->section()) {
qreal pos = listItem->position();
- listItem->section = getSectionItem(listItem->attached->m_section);
+ listItem->setSection(getSectionItem(listItem->attached->m_section));
listItem->setPosition(pos);
} else {
- QQmlContext *context = QQmlEngine::contextForObject(listItem->section)->parentContext();
+ QQmlContext *context = QQmlEngine::contextForObject(listItem->section())->parentContext();
context->setContextProperty(QLatin1String("section"), listItem->attached->m_section);
}
- } else if (listItem->section) {
+ } else if (listItem->section()) {
qreal pos = listItem->position();
- releaseSectionItem(listItem->section);
- listItem->section = 0;
+ releaseSectionItem(listItem->section());
+ listItem->setSection(0);
listItem->setPosition(pos);
}
}
@@ -972,7 +983,7 @@ void QQuickListViewPrivate::updateStickySections()
QQuickItem *lastSectionItem = 0;
int index = 0;
while (index < visibleItems.count()) {
- if (QQuickItem *section = static_cast<FxListItemSG *>(visibleItems.at(index))->section) {
+ if (QQuickItem *section = static_cast<FxListItemSG *>(visibleItems.at(index))->section()) {
// Find the current section header and last visible section header
// and hide them if they will overlap a static section header.
qreal sectionPos = orient == QQuickListView::Vertical ? section->y() : section->x();
@@ -1173,9 +1184,9 @@ void QQuickListViewPrivate::initializeCurrentItem()
if (currentItem) {
FxListItemSG *listItem = static_cast<FxListItemSG *>(currentItem);
- // don't reposition the item if it's about to be transitioned to another position
+ // don't reposition the item if it is already in the visibleItems list
FxViewItem *actualItem = visibleItem(currentIndex);
- if ((!actualItem || !actualItem->transitionScheduledOrRunning())) {
+ if (!actualItem) {
if (currentIndex == visibleIndex - 1 && visibleItems.count()) {
// We can calculate exact postion in this case
listItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing);
@@ -1186,12 +1197,6 @@ void QQuickListViewPrivate::initializeCurrentItem()
}
}
- // Avoid showing section delegate twice. We still need the section heading so that
- // currentItem positioning works correctly.
- // This is slightly sub-optimal, but section heading caching minimizes the impact.
- if (listItem->section)
- listItem->section->setVisible(false);
-
if (visibleItems.isEmpty())
averageSize = listItem->size();
}
@@ -2245,10 +2250,11 @@ void QQuickListView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::ListView::populate
- This property holds the transition to apply to items that are initially created for a
- view.
- This transition is applied to all the items that are created when:
+ This property holds the transition to apply to the items that are initially created
+ for a view.
+
+ It is applied to all items that are created when:
\list
\o The view is first created
@@ -2278,10 +2284,10 @@ void QQuickListView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::ListView::add
- This property holds the transition to apply to items that are added within the view.
- The transition is applied to items that have been added to the visible area of the view. For
- example, here is a view that specifies such a transition:
+ This property holds the transition to apply to items that are added to the view.
+
+ For example, here is a view that specifies such a transition:
\code
ListView {
@@ -2295,8 +2301,8 @@ void QQuickListView::setSnapMode(SnapMode mode)
Whenever an item is added to the above view, the item will be animated from the position (100,100)
to its final x,y position within the view, over one second. The transition only applies to
the new items that are added to the view; it does not apply to the items below that are
- displaced by the addition of the new items. To animate the displaced items, set the \l
- addDisplaced property.
+ displaced by the addition of the new items. To animate the displaced items, set the \l displaced
+ or \l addDisplaced properties.
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
@@ -2310,11 +2316,11 @@ void QQuickListView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::ListView::addDisplaced
- This property holds the transition to apply to items in the view that are displaced by other
- items that have been added to the view.
- The transition is applied to items that are currently visible and have been displaced by newly
- added items. For example, here is a view that specifies such a transition:
+ This property holds the transition to apply to items within the view that are displaced by
+ the addition of other items to the view.
+
+ For example, here is a view that specifies such a transition:
\code
ListView {
@@ -2332,6 +2338,11 @@ void QQuickListView::setSnapMode(SnapMode mode)
the new item that has been added to the view; to animate the added items, set the \l add
property.
+ If an item is displaced by multiple types of operations at the same time, it is not defined as to
+ whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally,
+ if it is not necessary to specify different transitions depending on whether an item is displaced
+ by an add, move or remove operation, consider setting the \l displaced property instead.
+
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
@@ -2339,16 +2350,16 @@ void QQuickListView::setSnapMode(SnapMode mode)
populated, or when the view's \l model changes. In those cases, the \l populate transition is
applied instead.
- \sa add, populate, ViewTransition
+ \sa displaced, add, populate, ViewTransition
*/
/*!
\qmlproperty Transition QtQuick2::ListView::move
- This property holds the transition to apply to items in the view that are moved by a move
- operation.
- The transition is applied to items that are moving within the view or are moving
- into the view as a result of a move operation in the view's model. For example:
+ This property holds the transition to apply to items in the view that are being moved due
+ to a move operation in the view's \l model.
+
+ For example, here is a view that specifies such a transition:
\code
ListView {
@@ -2359,10 +2370,11 @@ void QQuickListView::setSnapMode(SnapMode mode)
}
\endcode
- Whenever an item is moved within the above view, the item will be animated to its new position in
- the view over one second. The transition only applies to the items that are the subject of the
- move operation in the model; it does not apply to the items below them that are displaced by
- the move operation. To animate the displaced items, set the \l moveDisplaced property.
+ Whenever the \l model performs a move operation to move a particular set of indexes, the
+ respective items in the view will be animated to their new positions in the view over one
+ second. The transition only applies to the items that are the subject of the move operation
+ in the model; it does not apply to items below them that are displaced by the move operation.
+ To animate the displaced items, set the \l displaced or \l moveDisplaced properties.
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
@@ -2372,11 +2384,11 @@ void QQuickListView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::ListView::moveDisplaced
- This property holds the transition to apply to items in the view that are displaced by a
- move operation in the view.
- The transition is applied to items that are currently visible and have been displaced following
- a move operation in the view's model. For example, here is a view that specifies such a transition:
+ This property holds the transition to apply to items that are displaced by a move operation in
+ the view's \l model.
+
+ For example, here is a view that specifies such a transition:
\code
ListView {
@@ -2387,25 +2399,31 @@ void QQuickListView::setSnapMode(SnapMode mode)
}
\endcode
- Whenever an item moves within (or moves into) the above view, all items beneath it are
- displaced, causing them to move upwards (or sideways, if horizontally orientated) within the
- view. As this displacement occurs, the items' movement to their new x,y positions within the
- view will be animated by a NumberAnimation over one second, as specified. This transition is
- not applied to the item that are actually the subject of the move operation; to animate the
- moved items, set the \l move property.
+ Whenever the \l model performs a move operation to move a particular set of indexes, the items
+ between the source and destination indexes of the move operation are displaced, causing them
+ to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this
+ displacement occurs, the items' movement to their new x,y positions within the view will be
+ animated by a NumberAnimation over one second, as specified. This transition is not applied to
+ the items that are the actual subjects of the move operation; to animate the moved items, set
+ the \l move property.
+
+ If an item is displaced by multiple types of operations at the same time, it is not defined as to
+ whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally,
+ if it is not necessary to specify different transitions depending on whether an item is displaced
+ by an add, move or remove operation, consider setting the \l displaced property instead.
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
- \sa move, ViewTransition
+ \sa displaced, move, ViewTransition
*/
/*!
\qmlproperty Transition QtQuick2::ListView::remove
+
This property holds the transition to apply to items that are removed from the view.
- The transition is applied to items that have been removed from the visible area of the view. For
- example:
+ For example, here is a view that specifies such a transition:
\code
ListView {
@@ -2422,8 +2440,8 @@ void QQuickListView::setSnapMode(SnapMode mode)
Whenever an item is removed from the above view, the item will be animated to the position (100,100)
over one second, and in parallel will also change its opacity to 0. The transition
only applies to the items that are removed from the view; it does not apply to the items below
- them that are displaced by the removal of the items. To animate the displaced items, set the \l
- removeDisplaced property.
+ them that are displaced by the removal of the items. To animate the displaced items, set the
+ \l displaced or \l removeDisplaced properties.
Note that by the time the transition is applied, the item has already been removed from the
model; any references to the model data for the removed index will not be valid.
@@ -2439,11 +2457,11 @@ void QQuickListView::setSnapMode(SnapMode mode)
/*!
\qmlproperty Transition QtQuick2::ListView::removeDisplaced
+
This property holds the transition to apply to items in the view that are displaced by the
removal of other items in the view.
- The transition is applied to items that are currently visible and have been displaced by
- the removal of items. For example, here is a view that specifies such a transition:
+ For example, here is a view that specifies such a transition:
\code
ListView {
@@ -2461,12 +2479,52 @@ void QQuickListView::setSnapMode(SnapMode mode)
the item that has actually been removed from the view; to animate the removed items, set the
\l remove property.
+ If an item is displaced by multiple types of operations at the same time, it is not defined as to
+ whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally,
+ if it is not necessary to specify different transitions depending on whether an item is displaced
+ by an add, move or remove operation, consider setting the \l displaced property instead.
+
For more details and examples on how to use view transitions, see the ViewTransition
documentation.
- \sa remove, ViewTransition
+ \sa displaced, remove, ViewTransition
*/
+/*!
+ \qmlproperty Transition QtQuick2::ListView::displaced
+ This property holds the generic transition to apply to items that have been displaced by
+ any model operation that affects the view.
+
+ This is a convenience for specifying the generic transition to be applied to any items
+ that are displaced by an add, move or remove operation, without having to specify the
+ individual addDisplaced, moveDisplaced and removeDisplaced properties. For example, here
+ is a view that specifies a displaced transition:
+
+ \code
+ ListView {
+ ...
+ displaced: Transition {
+ NumberAnimation { properties: "x,y"; duration: 1000 }
+ }
+ }
+ \endcode
+
+ When any item is added, moved or removed within the above view, the items below it are
+ displaced, causing them to move down (or sideways, if horizontally orientated) within the
+ view. As this displacement occurs, the items' movement to their new x,y positions within
+ the view will be animated by a NumberAnimation over one second, as specified.
+
+ If a view specifies this generic displaced transition as well as a specific addDisplaced,
+ moveDisplaced or removeDisplaced transition, the more specific transition will be used
+ instead of the generic displaced transition when the relevant operation occurs, providing that
+ the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled}
+ to false). If it has indeed been disabled, the generic displaced transition is applied instead.
+
+ For more details and examples on how to use view transitions, see the ViewTransition
+ documentation.
+
+ \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition
+*/
void QQuickListView::viewportMoved()
{
@@ -2729,7 +2787,8 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
insertResult->changedFirstItem = true;
if (!change.isMove()) {
addedItems->append(item);
- transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true);
+ if (transitioner)
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true);
}
insertResult->sizeChangesBeforeVisiblePos += item->size() + spacing;
pos -= item->size() + spacing;
@@ -2755,11 +2814,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
if (change.isMove()) {
// we know this is a move target, since move displaced items that are
// shuffled into view due to a move would be added in refill()
- if (canTransition(FxViewItemTransitionManager::MoveTransition, true) && newItem)
+ if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true))
movingIntoView->append(MovedItem(item, change.moveKey(item->index)));
} else {
addedItems->append(item);
- transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true);
+ if (transitioner)
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true);
}
insertResult->sizeChangesAfterVisiblePos += item->size() + spacing;
pos += item->size() + spacing;
@@ -2771,10 +2831,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQuickChangeSet::Insert &
FxViewItem *item = visibleItems.at(index);
if (item->index != -1)
item->index += count;
- if (change.isMove())
- transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false);
- else
- transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, false);
+ if (transitioner) {
+ if (change.isMove())
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false);
+ else
+ transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, false);
+ }
}
updateVisibleIndex();
@@ -2786,6 +2848,9 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
{
Q_UNUSED(insertionResult);
+ if (!transitioner)
+ return;
+
int markerItemIndex = -1;
for (int i=0; i<visibleItems.count(); i++) {
if (visibleItems[i]->index == afterModelIndex) {
@@ -2805,7 +2870,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
if (!listItem->transitionScheduledOrRunning()) {
qreal pos = listItem->position();
listItem->setPosition(pos - sizeRemoved);
- transitionNextReposition(listItem, FxViewItemTransitionManager::RemoveTransition, false);
+ transitioner->transitionNextReposition(listItem, QQuickItemViewTransitioner::RemoveTransition, false);
listItem->setPosition(pos);
}
}
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index 239647a954..ef989ba839 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -181,7 +181,7 @@ class QQuickListViewAttached : public QQuickItemViewAttached
public:
QQuickListViewAttached(QObject *parent)
- : QQuickItemViewAttached(parent), m_view(0) {}
+ : QQuickItemViewAttached(parent), m_view(0), m_sectionItem(0) {}
~QQuickListViewAttached() {}
Q_PROPERTY(QQuickListView *view READ view NOTIFY viewChanged)
@@ -198,6 +198,7 @@ Q_SIGNALS:
public:
QQmlGuard<QQuickListView> m_view;
+ QQuickItem *m_sectionItem;
};
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index 739f74d69a..e1d0457916 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -109,8 +109,11 @@ QQuickBasePositioner::QQuickBasePositioner(QQuickBasePositionerPrivate &dd, Posi
QQuickBasePositioner::~QQuickBasePositioner()
{
Q_D(QQuickBasePositioner);
+ delete d->transitioner;
for (int i = 0; i < positionedItems.count(); ++i)
d->unwatchChanges(positionedItems.at(i).item);
+ for (int i = 0; i < unpositionedItems.count(); ++i)
+ d->unwatchChanges(unpositionedItems.at(i).item);
positionedItems.clear();
}
@@ -140,31 +143,36 @@ void QQuickBasePositioner::setSpacing(qreal s)
QQuickTransition *QQuickBasePositioner::move() const
{
Q_D(const QQuickBasePositioner);
- return d->moveTransition;
+ return d->transitioner ? d->transitioner->displacedTransition : 0;
}
void QQuickBasePositioner::setMove(QQuickTransition *mt)
{
Q_D(QQuickBasePositioner);
- if (mt == d->moveTransition)
+ if (!d->transitioner)
+ d->transitioner = new QQuickItemViewTransitioner;
+ if (mt == d->transitioner->displacedTransition)
return;
- d->moveTransition = mt;
+
+ d->transitioner->displacedTransition = mt;
emit moveChanged();
}
QQuickTransition *QQuickBasePositioner::add() const
{
Q_D(const QQuickBasePositioner);
- return d->addTransition;
+ return d->transitioner ? d->transitioner->addTransition : 0;
}
void QQuickBasePositioner::setAdd(QQuickTransition *add)
{
Q_D(QQuickBasePositioner);
- if (add == d->addTransition)
+ if (!d->transitioner)
+ d->transitioner = new QQuickItemViewTransitioner;
+ if (add == d->transitioner->addTransition)
return;
- d->addTransition = add;
+ d->transitioner->addTransition = add;
emit addChanged();
}
@@ -187,6 +195,9 @@ void QQuickBasePositioner::itemChange(ItemChange change, const ItemChangeData &v
if (idx >= 0) {
d->unwatchChanges(child);
positionedItems.remove(idx);
+ } else if ((idx = unpositionedItems.find(posItem)) >= 0) {
+ d->unwatchChanges(child);
+ unpositionedItems.remove(idx);
}
d->setPositioningDirty();
}
@@ -213,6 +224,7 @@ void QQuickBasePositioner::prePositioning()
for (int ii = 0; ii < unpositionedItems.count(); ii++)
oldItems.append(unpositionedItems[ii]);
unpositionedItems.clear();
+ int addedIndex = -1;
for (int ii = 0; ii < children.count(); ++ii) {
QQuickItem *child = children.at(ii);
@@ -224,9 +236,22 @@ void QQuickBasePositioner::prePositioning()
posItem.isNew = true;
if (!childPrivate->explicitVisible || !child->width() || !child->height()) {
posItem.isVisible = false;
+ posItem.index = -1;
unpositionedItems.append(posItem);
} else {
+ posItem.index = positionedItems.count();
positionedItems.append(posItem);
+
+ if (d->transitioner) {
+ if (addedIndex < 0)
+ addedIndex = posItem.index;
+ PositionedItem *theItem = &positionedItems[positionedItems.count()-1];
+
+ d->transitioner->transitionNextReposition(theItem,
+ QQuickItemViewTransitioner::AddTransition, true);
+ d->transitioner->addTransitionIndexes << posItem.index;
+ d->transitioner->addTransitionTargets << posItem.item;
+ }
}
} else {
PositionedItem *item = &oldItems[wIdx];
@@ -234,75 +259,93 @@ void QQuickBasePositioner::prePositioning()
// i.e. their positioning is not affected if an ancestor is hidden.
if (!childPrivate->explicitVisible || !child->width() || !child->height()) {
item->isVisible = false;
+ item->index = -1;
unpositionedItems.append(*item);
} else if (!item->isVisible) {
+ // item changed from non-visible to visible, treat it as a "new" item
item->isVisible = true;
item->isNew = true;
+ item->index = positionedItems.count();
positionedItems.append(*item);
+
+ if (d->transitioner) {
+ if (addedIndex < 0)
+ addedIndex = item->index;
+ d->transitioner->transitionNextReposition(&positionedItems[positionedItems.count()-1],
+ QQuickItemViewTransitioner::AddTransition, true);
+ d->transitioner->addTransitionIndexes << item->index;
+ d->transitioner->addTransitionTargets << item->item;
+ }
} else {
item->isNew = false;
+ item->index = positionedItems.count();
positionedItems.append(*item);
}
}
}
+
+ if (d->transitioner) {
+ for (int i=0; i<positionedItems.count(); i++) {
+ if (!positionedItems[i].isNew) {
+ if (addedIndex >= 0) {
+ d->transitioner->transitionNextReposition(&positionedItems[i], QQuickItemViewTransitioner::AddTransition, false);
+ } else {
+ // just queue the item for a move-type displace - if the item hasn't
+ // moved anywhere, it won't be transitioned anyway
+ d->transitioner->transitionNextReposition(&positionedItems[i], QQuickItemViewTransitioner::MoveTransition, false);
+ }
+ }
+ }
+ }
+
QSizeF contentSize(0,0);
reportConflictingAnchors();
if (!d->anchorConflict) {
doPositioning(&contentSize);
updateAttachedProperties();
}
- if (!d->addActions.isEmpty() || !d->moveActions.isEmpty())
- finishApplyTransitions();
+
+ if (d->transitioner) {
+ QRectF viewBounds;
+ for (int i=0; i<positionedItems.count(); i++) {
+ if (positionedItems[i].prepareTransition(viewBounds))
+ positionedItems[i].startTransition(d->transitioner);
+ }
+ d->transitioner->addTransitionIndexes.clear();
+ d->transitioner->addTransitionTargets.clear();
+ }
+
d->doingPositioning = false;
+
//Set implicit size to the size of its children
setImplicitSize(contentSize.width(), contentSize.height());
}
-void QQuickBasePositioner::positionX(qreal x, const PositionedItem &target)
+void QQuickBasePositioner::positionItem(qreal x, qreal y, PositionedItem *target)
{
Q_D(QQuickBasePositioner);
- if (d->type == Horizontal || d->type == Both) {
- if (target.isNew) {
- if (!d->addTransition || !d->addTransition->enabled())
- target.item->setX(x);
- else
- d->addActions << QQuickAction(target.item, QLatin1String("x"), QVariant(x));
- } else if (x != target.item->x()) {
- if (!d->moveTransition || !d->moveTransition->enabled())
- target.item->setX(x);
- else
- d->moveActions << QQuickAction(target.item, QLatin1String("x"), QVariant(x));
- }
+ if ( (target->itemX() != x || target->itemY() != y)
+ && d->type == Both) {
+ target->moveTo(QPointF(x, y));
}
}
-void QQuickBasePositioner::positionY(qreal y, const PositionedItem &target)
+void QQuickBasePositioner::positionItemX(qreal x, PositionedItem *target)
{
Q_D(QQuickBasePositioner);
- if (d->type == Vertical || d->type == Both) {
- if (target.isNew) {
- if (!d->addTransition || !d->addTransition->enabled())
- target.item->setY(y);
- else
- d->addActions << QQuickAction(target.item, QLatin1String("y"), QVariant(y));
- } else if (y != target.item->y()) {
- if (!d->moveTransition || !d->moveTransition->enabled())
- target.item->setY(y);
- else
- d->moveActions << QQuickAction(target.item, QLatin1String("y"), QVariant(y));
- }
+ if (target->itemX() != x
+ && (d->type == Horizontal || d->type == Both)) {
+ target->moveTo(QPointF(x, target->itemY()));
}
}
-void QQuickBasePositioner::finishApplyTransitions()
+void QQuickBasePositioner::positionItemY(qreal y, PositionedItem *target)
{
Q_D(QQuickBasePositioner);
- // 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();
+ if (target->itemY() != y
+ && (d->type == Vertical || d->type == Both)) {
+ target->moveTo(QPointF(target->itemX(), y));
+ }
}
QQuickPositionerAttached *QQuickBasePositioner::qmlAttachedProperties(QObject *obj)
@@ -496,30 +539,42 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
/*!
\qmlproperty Transition QtQuick2::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.
+ This property holds the transition to be run for items that are added to this
+ positioner. For a positioner, this applies to:
- For a positioner, adding an item 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 changed its \l visible property
- from false to true, and thus is now visible.
+ \list
+ \o Items that are created or reparented as a child of the positioner
+ \o Child items that change their \l visible property from false to true, and thus
+ are now visible
+ \endlist
- \sa move
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being added. See the \l ViewTransition documentation for more details
+ and examples on using these transitions.
+
+ \sa move, ViewTransition, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Column::move
- This property holds the transition to apply to any item that has moved
- within the positioner. Positioner transitions will only affect
- the position (x, y) of items.
+ This property holds the transition to run for items that have moved within the
+ positioner. For a positioner, this applies to:
+
+ \list
+ \o Child items that move when they are displaced due to the addition, removal or
+ rearrangement of other items in the positioner
+ \o Child items that are repositioned due to the resizing of other items in the positioner
+ \endlist
+
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being moved. Note, however, that for this move transition, the
+ ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when
+ this transition is triggered by the addition of other items in the positioner; in other
+ cases, these lists will be empty.
- This transition is applied to items that are displaced as a result of the
- addition or removal of other items in the positioner, or when items move due to
- a move operation in a related model, or when items resize themselves.
+ See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty real QtQuick2::Column::spacing
@@ -540,11 +595,8 @@ void QQuickColumn::doPositioning(QSizeF *contentSize)
qreal voffset = 0;
for (int ii = 0; ii < positionedItems.count(); ++ii) {
- const PositionedItem &child = positionedItems.at(ii);
-
- if (child.item->y() != voffset)
- positionY(voffset, child);
-
+ PositionedItem &child = positionedItems[ii];
+ positionItemY(voffset, &child);
contentSize->setWidth(qMax(contentSize->width(), child.item->width()));
voffset += child.item->height();
@@ -620,42 +672,42 @@ void QQuickColumn::reportConflictingAnchors()
/*!
\qmlproperty Transition QtQuick2::Row::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.
+ This property holds the transition to be run for items that are added to this
+ positioner. For a positioner, this applies to:
- For a positioner, adding an item 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 changed its \l visible property
- from false to true, and thus is now visible.
+ \list
+ \o Items that are created or reparented as a child of the positioner
+ \o Child items that change their \l visible property from false to true, and thus
+ are now visible
+ \endlist
+
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being added. See the \l ViewTransition documentation for more details
+ and examples on using these transitions.
- \sa move
+ \sa move, ViewTransition, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Row::move
- This property holds the transition to apply to any item that has moved
- within the positioner. Positioner transitions will only affect
- the position (x, y) of items.
-
- This transition is applied to items that are displaced as a result of the
- addition or removal of other items in the positioner, or when items move due to
- a move operation in a related model, or when items resize themselves.
-
- \qml
- Row {
- id: positioner
- move: Transition {
- NumberAnimation {
- properties: "x"
- duration: 1000
- }
- }
- }
- \endqml
+ This property holds the transition to run for items that have moved within the
+ positioner. For a positioner, this applies to:
+
+ \list
+ \o Child items that move when they are displaced due to the addition, removal or
+ rearrangement of other items in the positioner
+ \o Child items that are repositioned due to the resizing of other items in the positioner
+ \endlist
- \sa add, {qml/positioners}{Positioners example}
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being moved. Note, however, that for this move transition, the
+ ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when
+ this transition is triggered by the addition of other items in the positioner; in other
+ cases, these lists will be empty.
+
+ See the \l ViewTransition documentation for more details and examples on using these transitions.
+
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty real QtQuick2::Row::spacing
@@ -731,11 +783,10 @@ void QQuickRow::doPositioning(QSizeF *contentSize)
QList<qreal> hoffsets;
for (int ii = 0; ii < positionedItems.count(); ++ii) {
- const PositionedItem &child = positionedItems.at(ii);
+ PositionedItem &child = positionedItems[ii];
if (d->isLeftToRight()) {
- if (child.item->x() != hoffset)
- positionX(hoffset, child);
+ positionItemX(hoffset, &child);
} else {
hoffsets << hoffset;
}
@@ -762,10 +813,9 @@ void QQuickRow::doPositioning(QSizeF *contentSize)
int acc = 0;
for (int ii = 0; ii < positionedItems.count(); ++ii) {
- const PositionedItem &child = positionedItems.at(ii);
+ PositionedItem &child = positionedItems[ii];
hoffset = end - hoffsets[acc++] - child.item->width();
- if (child.item->x() != hoffset)
- positionX(hoffset, child);
+ positionItemX(hoffset, &child);
}
}
@@ -834,41 +884,42 @@ void QQuickRow::reportConflictingAnchors()
/*!
\qmlproperty Transition QtQuick2::Grid::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.
+ This property holds the transition to be run for items that are added to this
+ positioner. For a positioner, this applies to:
- For a positioner, adding an item 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 changed its \l visible property
- from false to true, and thus is now visible.
+ \list
+ \o Items that are created or reparented as a child of the positioner
+ \o Child items that change their \l visible property from false to true, and thus
+ are now visible
+ \endlist
+
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being added. See the \l ViewTransition documentation for more details
+ and examples on using these transitions.
- \sa move
+ \sa move, ViewTransition, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Grid::move
- This property holds the transition to apply to any item that has moved
- within the positioner. Positioner transitions will only affect
- the position (x, y) of items.
+ This property holds the transition to run for items that have moved within the
+ positioner. For a positioner, this applies to:
- This transition is applied to items that are displaced as a result of the
- addition or removal of other items in the positioner, or when items move due to
- a move operation in a related model, or when items resize themselves.
+ \list
+ \o Child items that move when they are displaced due to the addition, removal or
+ rearrangement of other items in the positioner
+ \o Child items that are repositioned due to the resizing of other items in the positioner
+ \endlist
- \qml
- Grid {
- move: Transition {
- NumberAnimation {
- properties: "x,y"
- duration: 1000
- }
- }
- }
- \endqml
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being moved. Note, however, that for this move transition, the
+ ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when
+ this transition is triggered by the addition of other items in the positioner; in other
+ cases, these lists will be empty.
+
+ See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty qreal QtQuick2::Grid::spacing
@@ -1155,14 +1206,11 @@ void QQuickGrid::doPositioning(QSizeF *contentSize)
int curRow =0;
int curCol =0;
for (int i = 0; i < positionedItems.count(); ++i) {
- const PositionedItem &child = positionedItems.at(i);
+ PositionedItem &child = positionedItems[i];
qreal childXOffset = xoffset;
if (!d->isLeftToRight())
childXOffset -= child.item->width();
- if ((child.item->x() != childXOffset) || (child.item->y() != yoffset)) {
- positionX(childXOffset, child);
- positionY(yoffset, child);
- }
+ positionItem(childXOffset, yoffset, &child);
if (m_flow == LeftToRight) {
if (d->isLeftToRight())
@@ -1249,42 +1297,42 @@ void QQuickGrid::reportConflictingAnchors()
/*!
\qmlproperty Transition QtQuick2::Flow::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.
+ This property holds the transition to be run for items that are added to this
+ positioner. For a positioner, this applies to:
+
+ \list
+ \o Items that are created or reparented as a child of the positioner
+ \o Child items that change their \l visible property from false to true, and thus
+ are now visible
+ \endlist
- For a positioner, adding an item 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 changed its \l visible property
- from false to true, and thus is now visible.
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being added. See the \l ViewTransition documentation for more details
+ and examples on using these transitions.
- \sa move
+ \sa move, ViewTransition, {declarative/positioners}{Positioners example}
*/
/*!
\qmlproperty Transition QtQuick2::Flow::move
- This property holds the transition to apply to any item that has moved
- within the positioner. Positioner transitions will only affect
- the position (x, y) of items.
-
- This transition is applied to items that are displaced as a result of the
- addition or removal of other items in the positioner, or when items move due to
- a move operation in a related model, or when items resize themselves.
-
- \qml
- Flow {
- id: positioner
- move: Transition {
- NumberAnimation {
- properties: "x,y"
- ease: "easeOutBounce"
- }
- }
- }
- \endqml
+ This property holds the transition to run for items that have moved within the
+ positioner. For a positioner, this applies to:
+
+ \list
+ \o Child items that move when they are displaced due to the addition, removal or
+ rearrangement of other items in the positioner
+ \o Child items that are repositioned due to the resizing of other items in the positioner
+ \endlist
+
+ The transition can use the \l ViewTransition property to access more details about
+ the item that is being moved. Note, however, that for this move transition, the
+ ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when
+ this transition is triggered by the addition of other items in the positioner; in other
+ cases, these lists will be empty.
+
+ See the \l ViewTransition documentation for more details and examples on using these transitions.
- \sa add, {qml/positioners}{Positioners example}
+ \sa add, ViewTransition, {qml/positioners}{Positioners example}
*/
/*!
\qmlproperty real QtQuick2::Flow::spacing
@@ -1409,7 +1457,7 @@ void QQuickFlow::doPositioning(QSizeF *contentSize)
QList<qreal> hoffsets;
for (int i = 0; i < positionedItems.count(); ++i) {
- const PositionedItem &child = positionedItems.at(i);
+ PositionedItem &child = positionedItems[i];
if (d->flow == LeftToRight) {
if (widthValid() && hoffset && hoffset + child.item->width() > width()) {
@@ -1426,13 +1474,11 @@ void QQuickFlow::doPositioning(QSizeF *contentSize)
}
if (d->isLeftToRight()) {
- if (child.item->x() != hoffset)
- positionX(hoffset, child);
+ positionItem(hoffset, voffset, &child);
} else {
hoffsets << hoffset;
+ positionItemY(voffset, &child);
}
- if (child.item->y() != voffset)
- positionY(voffset, child);
contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width()));
contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height()));
@@ -1457,10 +1503,9 @@ void QQuickFlow::doPositioning(QSizeF *contentSize)
end = contentSize->width();
int acc = 0;
for (int i = 0; i < positionedItems.count(); ++i) {
- const PositionedItem &child = positionedItems.at(i);
+ PositionedItem &child = positionedItems[i];
hoffset = end - hoffsets[acc++] - child.item->width();
- if (child.item->x() != hoffset)
- positionX(hoffset, child);
+ positionItemX(hoffset, &child);
}
}
diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h
index a2ad572c0e..8921bfa39b 100644
--- a/src/quick/items/qquickpositioners_p.h
+++ b/src/quick/items/qquickpositioners_p.h
@@ -43,6 +43,7 @@
#define QQUICKPOSITIONERS_P_H
#include "qquickimplicitsizeitem_p.h"
+#include "qquickitemviewtransition_p.h"
#include <QtQuick/private/qquickstate_p.h>
#include <private/qpodvector_p.h>
@@ -96,6 +97,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBasePositioner : public QQuickImplicitSizeIte
Q_PROPERTY(QQuickTransition *add READ add WRITE setAdd NOTIFY addChanged)
public:
enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
+
QQuickBasePositioner(PositionerType, QQuickItem *parent);
~QQuickBasePositioner();
@@ -116,7 +118,6 @@ protected:
QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent);
virtual void componentComplete();
virtual void itemChange(ItemChange, const ItemChangeData &);
- void finishApplyTransitions();
virtual void updatePolish();
@@ -131,19 +132,22 @@ protected Q_SLOTS:
protected:
virtual void doPositioning(QSizeF *contentSize)=0;
virtual void reportConflictingAnchors()=0;
- class PositionedItem {
+
+ class PositionedItem : public QQuickViewItem
+ {
public :
- PositionedItem(QQuickItem *i) : item(i), isNew(false), isVisible(true) {}
+ PositionedItem(QQuickItem *i) : QQuickViewItem(i), isNew(false), isVisible(true) {}
bool operator==(const PositionedItem &other) const { return other.item == item; }
- QQuickItem *item;
+
bool isNew;
bool isVisible;
};
QPODVector<PositionedItem,8> positionedItems;
QPODVector<PositionedItem,8> unpositionedItems;//Still 'in' the positioner, just not positioned
- void positionX(qreal,const PositionedItem &target);
- void positionY(qreal,const PositionedItem &target);
+ void positionItem(qreal x, qreal y, PositionedItem *target);
+ void positionItemX(qreal, PositionedItem *target);
+ void positionItemY(qreal, PositionedItem *target);
private:
Q_DISABLE_COPY(QQuickBasePositioner)
diff --git a/src/quick/items/qquickpositioners_p_p.h b/src/quick/items/qquickpositioners_p_p.h
index 39ca806b5e..21fa67574b 100644
--- a/src/quick/items/qquickpositioners_p_p.h
+++ b/src/quick/items/qquickpositioners_p_p.h
@@ -66,6 +66,8 @@
QT_BEGIN_NAMESPACE
+class QQuickItemViewTransitioner;
+
class QQuickBasePositionerPrivate : public QQuickImplicitSizeItemPrivate, public QQuickItemChangeListener
{
Q_DECLARE_PUBLIC(QQuickBasePositioner)
@@ -73,7 +75,7 @@ class QQuickBasePositionerPrivate : public QQuickImplicitSizeItemPrivate, public
public:
QQuickBasePositionerPrivate()
: spacing(0), type(QQuickBasePositioner::None)
- , moveTransition(0), addTransition(0), positioningDirty(false)
+ , transitioner(0), positioningDirty(false)
, doingPositioning(false), anchorConflict(false), layoutDirection(Qt::LeftToRight)
{
}
@@ -87,12 +89,7 @@ public:
qreal spacing;
QQuickBasePositioner::PositionerType type;
- QQuickTransition *moveTransition;
- QQuickTransition *addTransition;
- QQuickStateOperation::ActionList addActions;
- QQuickStateOperation::ActionList moveActions;
- QQuickTransitionManager addTransitionManager;
- QQuickTransitionManager moveTransitionManager;
+ QQuickItemViewTransitioner *transitioner;
void watchChanges(QQuickItem *other);
void unwatchChanges(QQuickItem* other);
diff --git a/src/quick/items/qquicksprite.cpp b/src/quick/items/qquicksprite.cpp
index 817a6b411a..e0535ed77e 100644
--- a/src/quick/items/qquicksprite.cpp
+++ b/src/quick/items/qquicksprite.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -145,7 +145,7 @@ QT_BEGIN_NAMESPACE
will repeat itself after completing.
*/
/*!
- \qmlproperty int QtQuick2::Sprite::frames
+ \qmlproperty int QtQuick2::Sprite::frameCount
Number of frames in this sprite.
*/
diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h
index 7c5c20bb50..85e3ed8b16 100644
--- a/src/quick/items/qquicksprite_p.h
+++ b/src/quick/items/qquicksprite_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -48,6 +48,7 @@
#include <QQmlListProperty>
#include <QtQuick/private/qquickpixmapcache_p.h>
#include "qquickspriteengine_p.h"
+#include <QDebug>
QT_BEGIN_HEADER
@@ -60,7 +61,8 @@ class QQuickSprite : public QQuickStochasticState
//Renderers have to query this hint when advancing frames
Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged)
Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged)
- Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged)
+ Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY frameCountChanged)
+ Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged)
//If frame height or width is not specified, it is assumed to be a single long row of square frames.
//Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
@@ -101,6 +103,11 @@ public:
return m_frames;
}
+ int frameCount() const
+ {
+ return m_frames;
+ }
+
int frameX() const
{
return m_frameX;
@@ -158,7 +165,7 @@ signals:
void reverseChanged(bool arg);
- void framesChanged(int arg);
+ void frameCountChanged(int arg);
void frameXChanged(int arg);
@@ -211,9 +218,15 @@ public slots:
void setFrames(int arg)
{
+ qWarning() << "Sprite::frames has been renamed Sprite::frameCount";
+ setFrameCount(arg);
+ }
+
+ void setFrameCount(int arg)
+ {
if (m_frames != arg) {
m_frames = arg;
- emit framesChanged(arg);
+ emit frameCountChanged(arg);
}
}
@@ -278,7 +291,8 @@ private slots:
private:
friend class QQuickImageParticle;
- friend class QQuickSpriteImage;
+ friend class QQuickSpriteSequence;
+ friend class QQuickAnimatedSprite;
friend class QQuickSpriteEngine;
friend class QQuickStochasticEngine;
int m_generatedCount;
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index 5a78472b45..1c35688c29 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 751b75f231..3763509462 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp
new file mode 100644
index 0000000000..ce0a246748
--- /dev/null
+++ b/src/quick/items/qquickspritesequence.cpp
@@ -0,0 +1,482 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickspritesequence_p.h"
+#include "qquicksprite_p.h"
+#include "qquickspriteengine_p.h"
+#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgengine.h>
+#include <QtQuick/qsgtexturematerial.h>
+#include <QtQuick/qsgtexture.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QtQml/qqmlinfo.h>
+#include <QFile>
+#include <cmath>
+#include <qmath.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+static const char vertexShaderCode[] =
+ "attribute highp vec2 vTex;\n"
+ "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n"
+ "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n"
+ "uniform highp vec2 size;//w,h of element\n"
+ "\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "\n"
+ "void main() {\n"
+ " progress = animData.z;\n"
+ " //Calculate frame location in texture\n"
+ " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n"
+ " //Next frame is also passed, for interpolation\n"
+ " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n"
+ "\n"
+ " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n"
+ "}\n";
+
+static const char fragmentShaderCode[] =
+ "uniform sampler2D texture;\n"
+ "uniform lowp float qt_Opacity;\n"
+ "\n"
+ "varying highp vec4 fTexS;\n"
+ "varying lowp float progress;\n"
+ "\n"
+ "void main() {\n"
+ " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n"
+ "}\n";
+
+class QQuickSpriteSequenceMaterial : public QSGMaterial
+{
+public:
+ QQuickSpriteSequenceMaterial();
+ ~QQuickSpriteSequenceMaterial();
+ virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; }
+ virtual QSGMaterialShader *createShader() const;
+ virtual int compare(const QSGMaterial *other) const
+ {
+ return this - static_cast<const QQuickSpriteSequenceMaterial *>(other);
+ }
+
+ QSGTexture *texture;
+
+ float animT;
+ float animX1;
+ float animY1;
+ float animX2;
+ float animY2;
+ float animW;
+ float animH;
+ float elementWidth;
+ float elementHeight;
+};
+
+QQuickSpriteSequenceMaterial::QQuickSpriteSequenceMaterial()
+ : animT(0.0f)
+ , animX1(0.0f)
+ , animY1(0.0f)
+ , animX2(0.0f)
+ , animY2(0.0f)
+ , animW(1.0f)
+ , animH(1.0f)
+ , elementWidth(1.0f)
+ , elementHeight(1.0f)
+{
+ setFlag(Blending, true);
+}
+
+QQuickSpriteSequenceMaterial::~QQuickSpriteSequenceMaterial()
+{
+ delete texture;
+}
+
+class SpriteSequenceMaterialData : public QSGMaterialShader
+{
+public:
+ SpriteSequenceMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0)
+ {
+ }
+
+ void deactivate() {
+ QSGMaterialShader::deactivate();
+
+ for (int i=0; i<8; ++i) {
+ program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0);
+ }
+ }
+
+ virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *)
+ {
+ QQuickSpriteSequenceMaterial *m = static_cast<QQuickSpriteSequenceMaterial *>(newEffect);
+ m->texture->bind();
+
+ program()->setUniformValue(m_opacity_id, state.opacity());
+ program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT);
+ program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2);
+ program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight);
+
+ if (state.isMatrixDirty())
+ program()->setUniformValue(m_matrix_id, state.combinedMatrix());
+ }
+
+ virtual void initialize() {
+ m_matrix_id = program()->uniformLocation("qt_Matrix");
+ m_opacity_id = program()->uniformLocation("qt_Opacity");
+ m_animData_id = program()->uniformLocation("animData");
+ m_animPos_id = program()->uniformLocation("animPos");
+ m_size_id = program()->uniformLocation("size");
+ }
+
+ virtual const char *vertexShader() const { return vertexShaderCode; }
+ virtual const char *fragmentShader() const { return fragmentShaderCode; }
+
+ virtual char const *const *attributeNames() const {
+ static const char *attr[] = {
+ "vTex",
+ 0
+ };
+ return attr;
+ }
+
+ int m_matrix_id;
+ int m_opacity_id;
+ int m_animData_id;
+ int m_animPos_id;
+ int m_size_id;
+
+ static float chunkOfBytes[1024];
+};
+
+float SpriteSequenceMaterialData::chunkOfBytes[1024];
+
+QSGMaterialShader *QQuickSpriteSequenceMaterial::createShader() const
+{
+ return new SpriteSequenceMaterialData;
+}
+
+struct SpriteVertex {
+ float tx;
+ float ty;
+};
+
+struct SpriteVertices {
+ SpriteVertex v1;
+ SpriteVertex v2;
+ SpriteVertex v3;
+ SpriteVertex v4;
+};
+
+/*!
+ \qmlclass SpriteSequence QQuickSpriteSequence
+ \inqmlmodule QtQuick 2
+ \inherits Item
+ \brief The SpriteSequence element draws a sprite animation
+
+*/
+/*!
+ \qmlproperty bool QtQuick2::SpriteSequence::running
+
+ Whether the sprite is animating or not.
+
+ Default is true
+*/
+/*!
+ \qmlproperty bool QtQuick2::SpriteSequence::interpolate
+
+ If true, interpolation will occur between sprite frames to make the
+ animation appear smoother.
+
+ Default is true.
+*/
+/*!
+ \qmlproperty string QtQuick2::SpriteSequence::goalSprite
+
+ The name of the Sprite which is currently animating.
+*/
+/*!
+ \qmlproperty string QtQuick2::SpriteSequence::goalSprite
+
+ The name of the Sprite which the animation should move to.
+
+ Sprite states have defined durations and transitions between them, setting goalState
+ will cause it to disregard any path weightings (including 0) and head down the path
+ which will reach the goalState quickest (fewest animations). It will pass through
+ intermediate states on that path, and animate them for their duration.
+
+ If it is possible to return to the goalState from the starting point of the goalState
+ it will continue to do so until goalState is set to "" or an unreachable state.
+*/
+/*! \qmlmethod void QtQuick2::SpriteSequence::jumpTo(string sprite)
+
+ This function causes the sprite to jump to the specified state immediately, intermediate
+ states are not played.
+*/
+/*!
+ \qmlproperty list<Sprite> QtQuick2::SpriteSequence::sprites
+
+ The sprite or sprites to draw. Sprites will be scaled to the size of this element.
+*/
+
+//TODO: Implicitly size element to size of first sprite?
+QQuickSpriteSequence::QQuickSpriteSequence(QQuickItem *parent) :
+ QQuickItem(parent)
+ , m_node(0)
+ , m_material(0)
+ , m_spriteEngine(0)
+ , m_curFrame(0)
+ , m_pleaseReset(false)
+ , m_running(true)
+ , m_interpolate(true)
+ , m_curStateIdx(0)
+{
+ setFlag(ItemHasContents);
+ connect(this, SIGNAL(runningChanged(bool)),
+ this, SLOT(update()));
+}
+
+void QQuickSpriteSequence::jumpTo(const QString &sprite)
+{
+ if (!m_spriteEngine)
+ return;
+ m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true);
+}
+
+void QQuickSpriteSequence::setGoalSprite(const QString &sprite)
+{
+ if (m_goalState != sprite){
+ m_goalState = sprite;
+ emit goalSpriteChanged(sprite);
+ m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite));
+ }
+}
+
+QQmlListProperty<QQuickSprite> QQuickSpriteSequence::sprites()
+{
+ return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
+}
+
+void QQuickSpriteSequence::createEngine()
+{
+ //TODO: delay until component complete
+ if (m_spriteEngine)
+ delete m_spriteEngine;
+ if (m_sprites.count())
+ m_spriteEngine = new QQuickSpriteEngine(m_sprites, this);
+ else
+ m_spriteEngine = 0;
+ reset();
+}
+
+static QSGGeometry::Attribute SpriteSequence_Attributes[] = {
+ QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex
+};
+
+static QSGGeometry::AttributeSet SpriteSequence_AttributeSet =
+{
+ 1, // Attribute Count
+ 2 * sizeof(float),
+ SpriteSequence_Attributes
+};
+
+QSGGeometryNode* QQuickSpriteSequence::buildNode()
+{
+ if (!m_spriteEngine) {
+ qmlInfo(this) << "No sprite engine...";
+ return 0;
+ } else if (m_spriteEngine->status() == QQuickPixmap::Null) {
+ m_spriteEngine->startAssemblingImage();
+ update();//Schedule another update, where we will check again
+ return 0;
+ } else if (m_spriteEngine->status() == QQuickPixmap::Loading) {
+ update();//Schedule another update, where we will check again
+ return 0;
+ }
+
+ m_material = new QQuickSpriteSequenceMaterial();
+
+ QImage image = m_spriteEngine->assembledImage();
+ if (image.isNull())
+ return 0;
+ m_sheetSize = QSizeF(image.size());
+ m_material->texture = canvas()->createTextureFromImage(image);
+ m_material->texture->setFiltering(QSGTexture::Linear);
+ m_spriteEngine->start(0);
+ m_material->animT = 0;
+ m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width();
+ m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height();
+ m_material->animX2 = m_material->animX1;
+ m_material->animY2 = m_material->animY1;
+ m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width();
+ m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height();
+ m_material->elementWidth = width();
+ m_material->elementHeight = height();
+ m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name();
+ emit currentSpriteChanged(m_curState);
+
+ int vCount = 4;
+ int iCount = 6;
+ QSGGeometry *g = new QSGGeometry(SpriteSequence_AttributeSet, vCount, iCount);
+ g->setDrawingMode(GL_TRIANGLES);
+
+ SpriteVertices *p = (SpriteVertices *) g->vertexData();
+
+ p->v1.tx = 0;
+ p->v1.ty = 0;
+
+ p->v2.tx = 1.0;
+ p->v2.ty = 0;
+
+ p->v3.tx = 0;
+ p->v3.ty = 1.0;
+
+ p->v4.tx = 1.0;
+ p->v4.ty = 1.0;
+
+ quint16 *indices = g->indexDataAsUShort();
+ indices[0] = 0;
+ indices[1] = 1;
+ indices[2] = 2;
+ indices[3] = 1;
+ indices[4] = 3;
+ indices[5] = 2;
+
+
+ m_timestamp.start();
+ m_node = new QSGGeometryNode();
+ m_node->setGeometry(g);
+ m_node->setMaterial(m_material);
+ m_node->setFlag(QSGGeometryNode::OwnsMaterial);
+ return m_node;
+}
+
+void QQuickSpriteSequence::reset()
+{
+ m_pleaseReset = true;
+}
+
+QSGNode *QQuickSpriteSequence::updatePaintNode(QSGNode *, UpdatePaintNodeData *)
+{
+ if (m_pleaseReset) {
+ delete m_node;
+
+ m_node = 0;
+ m_material = 0;
+ m_pleaseReset = false;
+ }
+
+ prepareNextFrame();
+
+ if (m_running) {
+ update();
+ if (m_node)
+ m_node->markDirty(QSGNode::DirtyMaterial);
+ }
+
+ return m_node;
+}
+
+void QQuickSpriteSequence::prepareNextFrame()
+{
+ if (m_node == 0)
+ m_node = buildNode();
+ if (m_node == 0) //error creating node
+ return;
+
+ uint timeInt = m_timestamp.elapsed();
+ qreal time = timeInt / 1000.;
+ m_material->elementHeight = height();
+ m_material->elementWidth = width();
+
+ //Advance State
+ m_spriteEngine->updateSprites(timeInt);
+ if (m_curStateIdx != m_spriteEngine->curState()) {
+ m_curStateIdx = m_spriteEngine->curState();
+ m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name();
+ emit currentSpriteChanged(m_curState);
+ m_curFrame= -1;
+ }
+
+ //Advance Sprite
+ qreal animT = m_spriteEngine->spriteStart()/1000.0;
+ qreal frameCount = m_spriteEngine->spriteFrames();
+ qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount;
+ double frameAt;
+ qreal progress;
+ if (frameDuration > 0) {
+ qreal frame = (time - animT)/(frameDuration / 1000.0);
+ frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation
+ progress = modf(frame,&frameAt);
+ } else {
+ m_curFrame++;
+ if (m_curFrame >= frameCount){
+ m_curFrame = 0;
+ m_spriteEngine->advance();
+ }
+ frameAt = m_curFrame;
+ progress = 0;
+ }
+ if (m_spriteEngine->sprite()->reverse())
+ frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt;
+ qreal y = m_spriteEngine->spriteY() / m_sheetSize.height();
+ qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width();
+ qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height();
+ qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width();
+ x1 += frameAt * w;
+ qreal x2 = x1;
+ if (frameAt < (frameCount-1))
+ x2 += w;
+
+ m_material->animX1 = x1;
+ m_material->animY1 = y;
+ m_material->animX2 = x2;
+ m_material->animY2 = y;
+ m_material->animW = w;
+ m_material->animH = h;
+ m_material->animT = m_interpolate ? progress : 0.0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h
new file mode 100644
index 0000000000..a2f9e4139a
--- /dev/null
+++ b/src/quick/items/qquickspritesequence_p.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSPRITESEQUENCE_P_H
+#define QQUICKSPRITESEQUENCE_P_H
+
+#include <QtQuick/QQuickItem>
+#include <QTime>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QSGContext;
+class QQuickSprite;
+class QQuickSpriteEngine;
+class QSGGeometryNode;
+class QQuickSpriteSequenceMaterial;
+class Q_AUTOTEST_EXPORT QQuickSpriteSequence : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged)
+ Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged)
+ Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged)
+ //###try to share similar spriteEngines for less overhead?
+ Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
+ Q_CLASSINFO("DefaultProperty", "sprites")
+
+public:
+ explicit QQuickSpriteSequence(QQuickItem *parent = 0);
+
+ QQmlListProperty<QQuickSprite> sprites();
+
+ bool running() const
+ {
+ return m_running;
+ }
+
+ bool interpolate() const
+ {
+ return m_interpolate;
+ }
+
+ QString goalSprite() const
+ {
+ return m_goalState;
+ }
+
+ QString currentSprite() const
+ {
+ return m_curState;
+ }
+
+signals:
+
+ void runningChanged(bool arg);
+ void interpolateChanged(bool arg);
+ void goalSpriteChanged(QString arg);
+ void currentSpriteChanged(QString arg);
+
+public slots:
+
+ void jumpTo(const QString &sprite);
+ void setGoalSprite(const QString &sprite);
+
+ void setRunning(bool arg)
+ {
+ if (m_running != arg) {
+ m_running = arg;
+ emit runningChanged(arg);
+ }
+ }
+
+ void setInterpolate(bool arg)
+ {
+ if (m_interpolate != arg) {
+ m_interpolate = arg;
+ emit interpolateChanged(arg);
+ }
+ }
+
+private slots:
+ void createEngine();
+protected:
+ void reset();
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+private:
+ void prepareNextFrame();
+ QSGGeometryNode* buildNode();
+ QSGGeometryNode *m_node;
+ QQuickSpriteSequenceMaterial *m_material;
+ QList<QQuickSprite*> m_sprites;
+ QQuickSpriteEngine* m_spriteEngine;
+ QTime m_timestamp;
+ int m_curFrame;
+ bool m_pleaseReset;
+ bool m_running;
+ bool m_interpolate;
+ QString m_goalState;
+ QString m_curState;
+ int m_curStateIdx;
+ QSizeF m_sheetSize;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKSPRITESEQUENCE_P_H
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index 037a48ceed..668c7c07d7 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -132,8 +132,7 @@ void QQuickParentChangePrivate::doChange(QQuickItem *targetParent, QQuickItem *s
if (ok) {
//qDebug() << x << y << rotation << scale;
- target->setX(x);
- target->setY(y);
+ target->setPos(QPointF(x, y));
target->setRotation(target->rotation() + rotation);
target->setScale(target->scale() * scale);
}
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 7aa4276f8d..36b902ff8c 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -72,21 +72,32 @@ QT_BEGIN_NAMESPACE
const QChar QQuickTextPrivate::elideChar = QChar(0x2026);
QQuickTextPrivate::QQuickTextPrivate()
- : lineHeight(1)
- , elideLayout(0), textLine(0), doc(0)
+ : elideLayout(0), textLine(0)
#if defined(Q_OS_MAC)
, layoutThread(0), paintingThread(0)
#endif
, color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000)
- , lineCount(1), maximumLineCount(INT_MAX), multilengthEos(-1), minimumPixelSize(12), minimumPointSize(12), nbActiveDownloads(0)
- , hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop), elideMode(QQuickText::ElideNone)
+ , lineCount(1), multilengthEos(-1)
+ , elideMode(QQuickText::ElideNone), hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop)
, format(QQuickText::AutoText), wrapMode(QQuickText::NoWrap)
- , lineHeightMode(QQuickText::ProportionalHeight), style(QQuickText::Normal)
- , fontSizeMode(QQuickText::FixedSize), updateType(UpdatePaintNode)
+ , style(QQuickText::Normal)
+ , updateType(UpdatePaintNode)
, maximumLineCountValid(false), updateOnComponentComplete(true), richText(false)
, styledText(false), singleline(false), internalWidthUpdate(false), requireImplicitWidth(false)
, truncated(false), hAlignImplicit(true), rightToLeftText(false)
- , layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false)
+ , layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false), formatModifiesFontSize(false)
+{
+}
+
+QQuickTextPrivate::ExtraData::ExtraData()
+ : lineHeight(1.0)
+ , doc(0)
+ , minimumPixelSize(12)
+ , minimumPointSize(12)
+ , nbActiveDownloads(0)
+ , maximumLineCount(INT_MAX)
+ , lineHeightMode(QQuickText::ProportionalHeight)
+ , fontSizeMode(QQuickText::FixedSize)
{
}
@@ -299,12 +310,24 @@ void QQuickTextPrivate::updateLayout()
if (!richText) {
if (textHasChanged) {
if (styledText && !text.isEmpty()) {
- QQuickStyledText::parse(text, layout, imgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid);
+ layout.setFont(font);
+ // needs temporary bool because formatModifiesFontSize is in a bit-field
+ bool fontSizeModified = false;
+ QQuickStyledText::parse(text, layout, imgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid, &fontSizeModified);
+ formatModifiesFontSize = fontSizeModified;
} else {
layout.clearAdditionalFormats();
- multilengthEos = text.indexOf(QLatin1Char('\x9c'));
- QString tmp = multilengthEos != -1 ? text.mid(0, multilengthEos) : text;
- tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ QString tmp = text;
+ multilengthEos = tmp.indexOf(QLatin1Char('\x9c'));
+ if (multilengthEos != -1) {
+ tmp = tmp.mid(0, multilengthEos);
+ tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ } else if (tmp.contains(QLatin1Char('\n'))) {
+ // Replace always does a detach. Checking for the new line character first
+ // means iterating over those items again if found but prevents a realloc
+ // otherwise.
+ tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ }
layout.setText(tmp);
}
textHasChanged = false;
@@ -312,10 +335,10 @@ void QQuickTextPrivate::updateLayout()
} else {
ensureDoc();
QTextBlockFormat::LineHeightTypes type;
- type = lineHeightMode == QQuickText::FixedHeight ? QTextBlockFormat::FixedHeight : QTextBlockFormat::ProportionalHeight;
+ type = lineHeightMode() == QQuickText::FixedHeight ? QTextBlockFormat::FixedHeight : QTextBlockFormat::ProportionalHeight;
QTextBlockFormat blockFormat;
- blockFormat.setLineHeight((lineHeightMode == QQuickText::FixedHeight ? lineHeight : lineHeight * 100), type);
- for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next()) {
+ blockFormat.setLineHeight((lineHeightMode() == QQuickText::FixedHeight ? lineHeight() : lineHeight() * 100), type);
+ for (QTextBlock it = extra->doc->begin(); it != extra->doc->end(); it = it.next()) {
QTextCursor cursor(it);
cursor.mergeBlockFormat(blockFormat);
}
@@ -334,13 +357,13 @@ void QQuickText::imageDownloadFinished()
{
Q_D(QQuickText);
- (d->nbActiveDownloads)--;
+ (d->extra->nbActiveDownloads)--;
// when all the remote images have been downloaded,
// if one of the sizes was not specified at parsing time
// we use the implicit size from pixmapcache and re-layout.
- if (d->nbActiveDownloads == 0) {
+ if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) {
bool needToUpdateLayout = false;
foreach (QQuickStyledTextImgTag *img, d->visibleImgTags) {
if (!img->size.isValid()) {
@@ -375,7 +398,7 @@ void QQuickTextPrivate::updateSize()
return;
}
- QFontMetrics fm(font);
+ QFontMetricsF fm(font);
if (text.isEmpty()) {
qreal fontHeight = fm.height();
q->setImplicitSize(0, fontHeight);
@@ -388,23 +411,23 @@ void QQuickTextPrivate::updateSize()
qreal naturalWidth = 0;
- int dy = q->height();
- QSize size(0, 0);
- QSize previousSize = layedOutTextRect.size();
+ qreal dy = q->height();
+ QSizeF size(0, 0);
+ QSizeF previousSize = layedOutTextRect.size();
#if defined(Q_OS_MAC)
layoutThread = QThread::currentThread();
#endif
//setup instance of QTextLayout for all cases other than richtext
if (!richText) {
- QRect textRect = setupTextLayout(&naturalWidth);
+ QRectF textRect = setupTextLayout(&naturalWidth);
layedOutTextRect = textRect;
size = textRect.size();
dy -= size.height();
} else {
singleline = false; // richtext can't elide or be optimized for single-line case
ensureDoc();
- doc->setDefaultFont(font);
+ extra->doc->setDefaultFont(font);
QQuickText::HAlignment horizontalAlignment = q->effectiveHAlign();
if (rightToLeftText) {
if (horizontalAlignment == QQuickText::AlignLeft)
@@ -416,21 +439,21 @@ void QQuickTextPrivate::updateSize()
option.setAlignment((Qt::Alignment)int(horizontalAlignment | vAlign));
option.setWrapMode(QTextOption::WrapMode(wrapMode));
option.setUseDesignMetrics(true);
- doc->setDefaultTextOption(option);
+ extra->doc->setDefaultTextOption(option);
if (requireImplicitWidth && q->widthValid()) {
- doc->setTextWidth(-1);
- naturalWidth = doc->idealWidth();
+ extra->doc->setTextWidth(-1);
+ naturalWidth = extra->doc->idealWidth();
}
if (wrapMode != QQuickText::NoWrap && q->widthValid())
- doc->setTextWidth(q->width());
+ extra->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();
- QSize dsize = doc->size().toSize();
- layedOutTextRect = QRect(QPoint(0,0), dsize);
- size = QSize(int(doc->idealWidth()),dsize.height());
+ extra->doc->setTextWidth(extra->doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
+ dy -= extra->doc->size().height();
+ QSizeF dsize = extra->doc->size();
+ layedOutTextRect = QRectF(QPointF(0,0), dsize);
+ size = QSizeF(extra->doc->idealWidth(),dsize.height());
}
- int yoff = 0;
+ qreal yoff = 0;
if (q->heightValid()) {
if (vAlign == QQuickText::AlignBottom)
@@ -570,8 +593,8 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height,
textLine->setWidth(q->width());
else
textLine->setWidth(INT_MAX);
- if (lineHeight != 1.0)
- textLine->setHeight((lineHeightMode == QQuickText::FixedHeight) ? lineHeight : line.height() * lineHeight);
+ if (lineHeight() != 1.0)
+ textLine->setHeight((lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight());
emit q->lineLaidOut(textLine);
@@ -590,24 +613,43 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height,
#endif
}
-QString QQuickTextPrivate::elidedText(int lineWidth, const QTextLine &line, QTextLine *nextLine) const
+void QQuickTextPrivate::elideFormats(
+ const int start, const int length, int offset, QList<QTextLayout::FormatRange> *elidedFormats)
+{
+ const int end = start + length;
+ QList<QTextLayout::FormatRange> formats = layout.additionalFormats();
+ for (int i = 0; i < formats.count(); ++i) {
+ QTextLayout::FormatRange format = formats.at(i);
+ const int formatLength = qMin(format.start + format.length, end) - qMax(format.start, start);
+ if (formatLength > 0) {
+ format.start = qMax(offset, format.start - start + offset);
+ format.length = formatLength;
+ elidedFormats->append(format);
+ }
+ }
+}
+
+QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine) const
{
if (nextLine) {
nextLine->setLineWidth(INT_MAX);
return layout.engine()->elidedText(
Qt::TextElideMode(elideMode),
- lineWidth,
+ QFixed::fromReal(lineWidth),
0,
line.textStart(),
line.textLength() + nextLine->textLength());
} else {
QString elideText = layout.text().mid(line.textStart(), line.textLength());
- elideText[elideText.length() - 1] = elideChar;
- // Appending the elide character may push the line over the maximum width
- // in which case the elided text will need to be elided.
- QFontMetricsF metrics(layout.font());
- if (metrics.width(elideChar) + line.naturalTextWidth() >= lineWidth)
- elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth);
+ if (!styledText) {
+ // QFontMetrics won't help eliding styled text.
+ elideText[elideText.length() - 1] = elideChar;
+ // Appending the elide character may push the line over the maximum width
+ // in which case the elided text will need to be elided.
+ QFontMetricsF metrics(layout.font());
+ if (metrics.width(elideChar) + line.naturalTextWidth() >= lineWidth)
+ elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth);
+ }
return elideText;
}
}
@@ -619,7 +661,7 @@ QString QQuickTextPrivate::elidedText(int lineWidth, const QTextLine &line, QTex
already absolutely positioned horizontally).
*/
-QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
+QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
{
Q_Q(QQuickText);
layout.setCacheEnabled(true);
@@ -647,7 +689,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
// Layout to determine the implicit width.
layout.beginLayout();
- for (int i = 0; i < maximumLineCount; ++i) {
+ for (int i = 0; i < maximumLineCount(); ++i) {
QTextLine line = layout.createLine();
if (!line.isValid())
break;
@@ -658,30 +700,31 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
}
QFontMetrics fm(font);
- qreal height = (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : fm.height() * lineHeight;
+ qreal height = (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : fm.height() * lineHeight();
return QRect(0, 0, 0, height);
}
- const int lineWidth = q->widthValid() ? q->width() : INT_MAX;
+ const qreal lineWidth = q->widthValid() ? q->width() : FLT_MAX;
+ const qreal maxHeight = q->heightValid() ? q->height() : FLT_MAX;
+
const bool customLayout = isLineLaidOutConnected();
const bool wasTruncated = truncated;
- const bool singlelineElide = !styledText && elideMode != QQuickText::ElideNone && q->widthValid();
- const bool multilineElide = !styledText
- && elideMode == QQuickText::ElideRight
+ const bool singlelineElide = elideMode != QQuickText::ElideNone && q->widthValid();
+ const bool multilineElide = elideMode == QQuickText::ElideRight
&& q->widthValid()
&& (q->heightValid() || maximumLineCountValid);
const bool canWrap = wrapMode != QQuickText::NoWrap && q->widthValid();
- const bool horizontalFit = fontSizeMode & QQuickText::HorizontalFit && q->widthValid();
- const bool verticalFit = fontSizeMode & QQuickText::VerticalFit
+ const bool horizontalFit = fontSizeMode() & QQuickText::HorizontalFit && q->widthValid();
+ const bool verticalFit = fontSizeMode() & QQuickText::VerticalFit
&& (q->heightValid() || (maximumLineCountValid && canWrap));
const bool pixelSize = font.pixelSize() != -1;
QString layoutText = layout.text();
int largeFont = pixelSize ? font.pixelSize() : font.pointSize();
- int smallFont = fontSizeMode != QQuickText::FixedSize
- ? qMin(pixelSize ? minimumPixelSize : minimumPointSize, largeFont)
+ int smallFont = fontSizeMode() != QQuickText::FixedSize
+ ? qMin(pixelSize ? minimumPixelSize() : minimumPointSize(), largeFont)
: largeFont;
int scaledFontSize = largeFont;
@@ -695,6 +738,8 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
qreal height = 0;
QString elideText;
bool once = true;
+ int elideStart = 0;
+ int elideEnd = 0;
*naturalWidth = 0;
@@ -712,12 +757,14 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
}
layout.beginLayout();
+
bool wrapped = false;
bool truncateHeight = false;
truncated = false;
elide = false;
int characterCount = 0;
int unwrappedLineCount = 1;
+ int maxLineCount = maximumLineCount();
height = 0;
br = QRectF();
line = layout.createLine();
@@ -732,7 +779,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
// Elide the previous line if the accumulated height of the text exceeds the height
// of the element.
- if (multilineElide && height > q->height() && visibleCount > 1) {
+ if (multilineElide && height > maxHeight && visibleCount > 1) {
elide = true;
if (eos != -1) // There's an abbreviated string available, skip the rest as it's
break; // all going to be discarded.
@@ -747,13 +794,16 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
elideText = layoutText.at(line.textStart() - 1) != QChar::LineSeparator
? elidedText(lineWidth, previousLine, &line)
: elidedText(lineWidth, previousLine);
+ elideStart = previousLine.textStart();
+ // elideEnd isn't required for right eliding.
+
// The previous line is the last one visible so move the current one off somewhere
// out of the way and back everything up one line.
line.setLineWidth(0);
line.setPosition(QPointF(FLT_MAX, FLT_MAX));
line = previousLine;
--visibleCount;
- height -= (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : previousLine.height() * lineHeight;
+ height -= (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : previousLine.height() * lineHeight();
break;
}
@@ -770,10 +820,12 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
height = preLayoutHeight;
elideText = layout.engine()->elidedText(
Qt::TextElideMode(elideMode),
- lineWidth,
+ QFixed::fromReal(lineWidth),
0,
line.textStart(),
line.textLength());
+ elideStart = line.textStart();
+ elideEnd = elideStart + line.textLength();
} else {
br = br.united(line.naturalTextRect());
}
@@ -787,7 +839,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
// Stop if the maximum number of lines has been reached and elide the last line
// if enabled.
- if (visibleCount == maximumLineCount) {
+ if (visibleCount == maxLineCount) {
truncated = true;
characterCount = nextLine.textStart() + nextLine.textLength();
@@ -799,6 +851,8 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
elideText = wrappedLine
? elidedText(lineWidth, line, &nextLine)
: elidedText(lineWidth, line);
+ elideStart = line.textStart();
+ // elideEnd isn't required for right eliding.
} else {
br = br.united(line.naturalTextRect());
}
@@ -821,13 +875,13 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
if (requireImplicitWidth
&& characterCount < layoutText.length()
- && unwrappedLineCount < maximumLineCount) {
+ && unwrappedLineCount < maxLineCount) {
// Use a new layout to get the maximum width for the remaining text. Using a
// different layout excludes the truncated text from rendering.
QTextLayout widthLayout(layoutText.mid(characterCount), scaledFont);
widthLayout.setTextOption(layout.textOption());
- for (; unwrappedLineCount <= maximumLineCount; ++unwrappedLineCount) {
+ for (; unwrappedLineCount <= maxLineCount; ++unwrappedLineCount) {
QTextLine line = widthLayout.createLine();
if (!line.isValid())
break;
@@ -870,7 +924,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
}
if (verticalFit) {
- if (truncateHeight || (q->heightValid() && unelidedRect.height() > q->height())) {
+ if (truncateHeight || unelidedRect.height() > maxHeight) {
largeFont = scaledFontSize - 1;
scaledFontSize = (smallFont + largeFont + 1) / 2;
if (smallFont > largeFont)
@@ -891,6 +945,33 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
if (elide) {
if (!elideLayout)
elideLayout = new QTextLayout;
+ if (styledText) {
+ QList<QTextLayout::FormatRange> formats;
+ switch (elideMode) {
+ case QQuickText::ElideRight:
+ elideFormats(elideStart, elideText.length() - 1, 0, &formats);
+ break;
+ case QQuickText::ElideLeft:
+ elideFormats(elideEnd - elideText.length() + 1, elideText.length() - 1, 1, &formats);
+ break;
+ case QQuickText::ElideMiddle: {
+ const int index = elideText.indexOf(elideChar);
+ if (index != -1) {
+ elideFormats(elideStart, index, 0, &formats);
+ elideFormats(
+ elideEnd - elideText.length() + index + 1,
+ elideText.length() - index - 1,
+ index + 1,
+ &formats);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ elideLayout->setAdditionalFormats(formats);
+ }
+
elideLayout->setFont(layout.font());
elideLayout->setTextOption(layout.textOption());
elideLayout->setText(elideText);
@@ -928,7 +1009,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth)
if (truncated != wasTruncated)
emit q->truncatedChanged();
- return QRect(qRound(br.x()), qRound(br.y()), qCeil(br.width()), qCeil(br.height()));
+ return br;
}
void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height)
@@ -938,7 +1019,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
if (imgTags.isEmpty()) {
line.setPosition(QPointF(line.position().x(), height));
- height += (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : line.height() * lineHeight;
+ height += (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight();
return;
}
@@ -957,7 +1038,9 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
image->pix = new QQuickPixmap(qmlEngine(q), url, image->size);
if (image->pix->isLoading()) {
image->pix->connectFinished(q, SLOT(imageDownloadFinished()));
- nbActiveDownloads++;
+ if (!extra.isAllocated() || !extra->nbActiveDownloads)
+ extra.value().nbActiveDownloads = 0;
+ extra->nbActiveDownloads++;
} else if (image->pix->isReady()) {
if (!image->size.isValid()) {
image->size = image->pix->implicitSize();
@@ -990,7 +1073,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
}
line.setPosition(QPointF(line.position().x(), height + textTop));
- height += (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : totalLineHeight * lineHeight;
+ height += (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : totalLineHeight * lineHeight();
}
/*!
@@ -998,12 +1081,12 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
*/
void QQuickTextPrivate::ensureDoc()
{
- if (!doc) {
+ if (!extra.isAllocated() || !extra->doc) {
Q_Q(QQuickText);
- doc = new QQuickTextDocumentWithImageResources(q);
- doc->setDocumentMargin(0);
- doc->setBaseUrl(q->baseUrl());
- FAST_CONNECT(doc, SIGNAL(imagesLoaded()), q, SLOT(q_imagesLoaded()));
+ extra.value().doc = new QQuickTextDocumentWithImageResources(q);
+ extra->doc->setDocumentMargin(0);
+ extra->doc->setBaseUrl(q->baseUrl());
+ FAST_CONNECT(extra->doc, SIGNAL(imagesLoaded()), q, SLOT(q_imagesLoaded()));
}
}
@@ -1253,8 +1336,13 @@ void QQuickText::setFont(const QFont &font)
d->font.setPointSizeF(size/2.0);
}
- if (oldFont != d->font)
+ if (oldFont != d->font) {
+ // if the format changes the size of the text
+ // with headings or <font> tag, we need to re-parse
+ if (d->formatModifiesFontSize)
+ d->textHasChanged = true;
d->updateLayout();
+ }
emit fontChanged(d->sourceFont);
}
@@ -1285,8 +1373,8 @@ void QQuickText::setText(const QString &n)
if (isComponentComplete()) {
if (d->richText) {
d->ensureDoc();
- d->doc->setText(n);
- d->rightToLeftText = d->doc->toPlainText().isRightToLeft();
+ d->extra->doc->setText(n);
+ d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft();
} else {
d->rightToLeftText = d->text.isRightToLeft();
}
@@ -1550,11 +1638,6 @@ void QQuickTextPrivate::mirrorChange()
}
}
-QTextDocument *QQuickTextPrivate::textDocument()
-{
- return doc;
-}
-
QQuickText::VAlignment QQuickText::vAlign() const
{
Q_D(const QQuickText);
@@ -1647,7 +1730,7 @@ bool QQuickText::truncated() const
int QQuickText::maximumLineCount() const
{
Q_D(const QQuickText);
- return d->maximumLineCount;
+ return d->maximumLineCount();
}
void QQuickText::setMaximumLineCount(int lines)
@@ -1655,8 +1738,8 @@ void QQuickText::setMaximumLineCount(int lines)
Q_D(QQuickText);
d->maximumLineCountValid = lines==INT_MAX ? false : true;
- if (d->maximumLineCount != lines) {
- d->maximumLineCount = lines;
+ if (d->maximumLineCount() != lines) {
+ d->extra.value().maximumLineCount = lines;
d->updateLayout();
emit maximumLineCountChanged();
}
@@ -1758,8 +1841,8 @@ void QQuickText::setTextFormat(TextFormat format)
if (isComponentComplete()) {
if (!wasRich && d->richText) {
d->ensureDoc();
- d->doc->setText(d->text);
- d->rightToLeftText = d->doc->toPlainText().isRightToLeft();
+ d->extra->doc->setText(d->text);
+ d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft();
} else {
d->rightToLeftText = d->text.isRightToLeft();
}
@@ -1812,7 +1895,7 @@ void QQuickText::setElideMode(QQuickText::TextElideMode mode)
d->elideMode = mode;
d->updateLayout();
- emit elideModeChanged(d->elideMode);
+ emit elideModeChanged(mode);
}
/*!
@@ -1854,8 +1937,10 @@ void QQuickText::setBaseUrl(const QUrl &url)
if (baseUrl() != url) {
d->baseUrl = url;
- if (d->doc)
- d->doc->setBaseUrl(url);
+ if (d->richText) {
+ d->ensureDoc();
+ d->extra->doc->setBaseUrl(url);
+ }
if (d->styledText) {
d->textHasChanged = true;
qDeleteAll(d->imgTags);
@@ -1879,7 +1964,7 @@ QRectF QQuickText::boundingRect() const
{
Q_D(const QQuickText);
- QRect rect = d->layedOutTextRect;
+ QRectF rect = d->layedOutTextRect;
if (d->style != Normal)
rect.adjust(-1, 0, 1, 2);
@@ -1897,7 +1982,7 @@ QRectF QQuickText::boundingRect() const
break;
}
- return QRectF(rect);
+ return rect;
}
/*! \internal */
@@ -1914,7 +1999,7 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo
bool leftAligned = effectiveHAlign() == QQuickText::AlignLeft;
bool wrapped = d->wrapMode != QQuickText::NoWrap;
bool elide = d->elideMode != QQuickText::ElideNone;
- bool scaleFont = d->fontSizeMode != QQuickText::FixedSize && (widthValid() || heightValid());
+ bool scaleFont = d->fontSizeMode() != QQuickText::FixedSize && (widthValid() || heightValid());
if ((!widthChanged && !heightChanged) || d->internalWidthUpdate)
goto geomChangeDone;
@@ -1935,7 +2020,7 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo
if (d->elideMode == QQuickText::ElideRight && wrapped && newGeometry.height() > oldGeometry.height() && !scaleFont) {
if (!d->truncated)
goto geomChangeDone; // Multiline eliding not affected if we're not currently truncated and we get higher.
- if (d->maximumLineCountValid && d->lineCount == d->maximumLineCount)
+ if (d->maximumLineCountValid && d->lineCount == d->maximumLineCount())
goto geomChangeDone; // Multiline eliding not affected if we're already at max line count and we get higher.
}
@@ -2002,7 +2087,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data
if (d->richText) {
d->ensureDoc();
- node->addTextDocument(bounds.topLeft(), d->doc, color, d->style, styleColor, linkColor);
+ node->addTextDocument(bounds.topLeft(), d->extra->doc, color, d->style, styleColor, linkColor);
} else if (d->elideMode == QQuickText::ElideNone || bounds.width() > 0.) {
node->addTextLayout(QPoint(0, bounds.y()), &d->layout, color, d->style, styleColor, linkColor);
if (d->elideLayout)
@@ -2062,17 +2147,17 @@ qreal QQuickText::contentHeight() const
qreal QQuickText::lineHeight() const
{
Q_D(const QQuickText);
- return d->lineHeight;
+ return d->lineHeight();
}
void QQuickText::setLineHeight(qreal lineHeight)
{
Q_D(QQuickText);
- if ((d->lineHeight == lineHeight) || (lineHeight < 0.0))
+ if ((d->lineHeight() == lineHeight) || (lineHeight < 0.0))
return;
- d->lineHeight = lineHeight;
+ d->extra.value().lineHeight = lineHeight;
d->updateLayout();
emit lineHeightChanged(lineHeight);
}
@@ -2092,16 +2177,16 @@ void QQuickText::setLineHeight(qreal lineHeight)
QQuickText::LineHeightMode QQuickText::lineHeightMode() const
{
Q_D(const QQuickText);
- return d->lineHeightMode;
+ return d->lineHeightMode();
}
void QQuickText::setLineHeightMode(LineHeightMode mode)
{
Q_D(QQuickText);
- if (mode == d->lineHeightMode)
+ if (mode == d->lineHeightMode())
return;
- d->lineHeightMode = mode;
+ d->extra.value().lineHeightMode = mode;
d->updateLayout();
emit lineHeightModeChanged(mode);
@@ -2135,18 +2220,18 @@ void QQuickText::setLineHeightMode(LineHeightMode mode)
QQuickText::FontSizeMode QQuickText::fontSizeMode() const
{
Q_D(const QQuickText);
- return d->fontSizeMode;
+ return d->fontSizeMode();
}
void QQuickText::setFontSizeMode(FontSizeMode mode)
{
Q_D(QQuickText);
- if (d->fontSizeMode == mode)
+ if (d->fontSizeMode() == mode)
return;
polish();
- d->fontSizeMode = mode;
+ d->extra.value().fontSizeMode = mode;
emit fontSizeModeChanged();
}
@@ -2163,18 +2248,18 @@ void QQuickText::setFontSizeMode(FontSizeMode mode)
int QQuickText::minimumPixelSize() const
{
Q_D(const QQuickText);
- return d->minimumPixelSize;
+ return d->minimumPixelSize();
}
void QQuickText::setMinimumPixelSize(int size)
{
Q_D(QQuickText);
- if (d->minimumPixelSize == size)
+ if (d->minimumPixelSize() == size)
return;
- if (d->fontSizeMode != FixedSize && (widthValid() || heightValid()))
+ if (d->fontSizeMode() != FixedSize && (widthValid() || heightValid()))
polish();
- d->minimumPixelSize = size;
+ d->extra.value().minimumPixelSize = size;
emit minimumPixelSizeChanged();
}
@@ -2191,18 +2276,18 @@ void QQuickText::setMinimumPixelSize(int size)
int QQuickText::minimumPointSize() const
{
Q_D(const QQuickText);
- return d->minimumPointSize;
+ return d->minimumPointSize();
}
void QQuickText::setMinimumPointSize(int size)
{
Q_D(QQuickText);
- if (d->minimumPointSize == size)
+ if (d->minimumPointSize() == size)
return;
- if (d->fontSizeMode != FixedSize && (widthValid() || heightValid()))
+ if (d->fontSizeMode() != FixedSize && (widthValid() || heightValid()))
polish();
- d->minimumPointSize = size;
+ d->extra.value().minimumPointSize = size;
emit minimumPointSizeChanged();
}
@@ -2212,7 +2297,9 @@ void QQuickText::setMinimumPointSize(int size)
int QQuickText::resourcesLoading() const
{
Q_D(const QQuickText);
- return d->doc ? d->doc->resourcesLoading() : 0;
+ if (d->richText && d->extra.isAllocated() && d->extra->doc)
+ return d->extra->doc->resourcesLoading();
+ return 0;
}
/*! \internal */
@@ -2222,8 +2309,8 @@ void QQuickText::componentComplete()
if (d->updateOnComponentComplete) {
if (d->richText) {
d->ensureDoc();
- d->doc->setText(d->text);
- d->rightToLeftText = d->doc->toPlainText().isRightToLeft();
+ d->extra->doc->setText(d->text);
+ d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft();
} else {
d->rightToLeftText = d->text.isRightToLeft();
}
@@ -2270,15 +2357,21 @@ void QQuickText::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickText);
+ QString link;
if (d->isLinkActivatedConnected()) {
if (d->styledText)
- d->activeLink = d->anchorAt(event->localPos());
- else if (d->richText && d->doc)
- d->activeLink = d->doc->documentLayout()->anchorAt(event->localPos());
+ link = d->anchorAt(event->localPos());
+ else if (d->richText) {
+ d->ensureDoc();
+ link = d->extra->doc->documentLayout()->anchorAt(event->localPos());
+ }
}
- if (d->activeLink.isEmpty())
+ if (link.isEmpty()) {
event->setAccepted(false);
+ } else {
+ d->extra.value().activeLink = link;
+ }
// ### may malfunction if two of the same links are clicked & dragged onto each other)
@@ -2298,12 +2391,14 @@ void QQuickText::mouseReleaseEvent(QMouseEvent *event)
if (d->isLinkActivatedConnected()) {
if (d->styledText)
link = d->anchorAt(event->localPos());
- else if (d->richText && d->doc)
- link = d->doc->documentLayout()->anchorAt(event->localPos());
+ else if (d->richText) {
+ d->ensureDoc();
+ link = d->extra->doc->documentLayout()->anchorAt(event->localPos());
+ }
}
- if (!link.isEmpty() && d->activeLink == link)
- emit linkActivated(d->activeLink);
+ if (!link.isEmpty() && d->extra.isAllocated() && d->extra->activeLink == link)
+ emit linkActivated(d->extra->activeLink);
else
event->setAccepted(false);
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index 0f8c93a9e3..0425c37406 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -60,6 +60,7 @@
#include <QtGui/qabstracttextdocumentlayout.h>
#include <QtGui/qtextlayout.h>
#include <private/qquickstyledtext_p.h>
+#include <private/qlazilyallocated_p.h>
QT_BEGIN_NAMESPACE
@@ -79,17 +80,30 @@ public:
bool determineHorizontalAlignment();
bool setHAlign(QQuickText::HAlignment, bool forceAlign = false);
void mirrorChange();
- QTextDocument *textDocument();
bool isLineLaidOutConnected();
void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height);
- QString elidedText(int lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const;
- QRect layedOutTextRect;
+ QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const;
+ void elideFormats(int start, int length, int offset, QList<QTextLayout::FormatRange> *elidedFormats);
- qreal lineHeight;
+ QRectF layedOutTextRect;
+
+ struct ExtraData {
+ ExtraData();
+
+ qreal lineHeight;
+ QQuickTextDocumentWithImageResources *doc;
+ QString activeLink;
+ int minimumPixelSize;
+ int minimumPointSize;
+ int nbActiveDownloads;
+ int maximumLineCount;
+ QQuickText::LineHeightMode lineHeightMode;
+ QQuickText::FontSizeMode fontSizeMode;
+ };
+ QLazilyAllocated<ExtraData> extra;
QString text;
- QString activeLink;
QUrl baseUrl;
QFont font;
QFont sourceFont;
@@ -99,7 +113,6 @@ public:
QTextLayout layout;
QTextLayout *elideLayout;
QQuickTextLine *textLine;
- QQuickTextDocumentWithImageResources *doc;
#if defined(Q_OS_MAC)
QList<QRectF> linesRects;
@@ -112,11 +125,7 @@ public:
QRgb styleColor;
int lineCount;
- int maximumLineCount;
int multilengthEos;
- int minimumPixelSize;
- int minimumPointSize;
- int nbActiveDownloads;
enum UpdateType {
UpdateNone,
@@ -124,14 +133,12 @@ public:
UpdatePaintNode
};
+ QQuickText::TextElideMode elideMode;
QQuickText::HAlignment hAlign;
QQuickText::VAlignment vAlign;
- QQuickText::TextElideMode elideMode;
QQuickText::TextFormat format;
QQuickText::WrapMode wrapMode;
- QQuickText::LineHeightMode lineHeightMode;
QQuickText::TextStyle style;
- QQuickText::FontSizeMode fontSizeMode;
UpdateType updateType;
bool maximumLineCountValid:1;
@@ -148,6 +155,7 @@ public:
bool layoutTextElided:1;
bool textHasChanged:1;
bool needToUpdateLayout:1;
+ bool formatModifiesFontSize:1;
static const QChar elideChar;
@@ -155,14 +163,18 @@ public:
void ensureDoc();
- QRect setupTextLayout(qreal *const naturalWidth);
+ QRectF setupTextLayout(qreal *const naturalWidth);
void setupCustomLineGeometry(QTextLine &line, qreal &height, int lineOffset = 0);
bool isLinkActivatedConnected();
QString anchorAt(const QPointF &pos);
- static inline QQuickTextPrivate *get(QQuickText *t) {
- return t->d_func();
- }
+ inline qreal lineHeight() const { return extra.isAllocated() ? extra->lineHeight : 1.0; }
+ inline int maximumLineCount() const { return extra.isAllocated() ? extra->maximumLineCount : INT_MAX; }
+ inline QQuickText::LineHeightMode lineHeightMode() const { return extra.isAllocated() ? extra->lineHeightMode : QQuickText::ProportionalHeight; }
+ inline QQuickText::FontSizeMode fontSizeMode() const { return extra.isAllocated() ? extra->fontSizeMode : QQuickText::FixedSize; }
+ inline int minimumPixelSize() const { return extra.isAllocated() ? extra->minimumPixelSize : 12; }
+ inline int minimumPointSize() const { return extra.isAllocated() ? extra->minimumPointSize : 12; }
+ static inline QQuickTextPrivate *get(QQuickText *t) { return t->d_func(); }
};
class QQuickPixmap;
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index a763626410..9a61312910 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -97,13 +97,17 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
}
QQuickTextControlPrivate::QQuickTextControlPrivate()
- : doc(0), cursorOn(false), cursorIsFocusIndicator(false),
+ : doc(0),
+ preeditCursor(0),
interactionFlags(Qt::TextEditorInteraction),
+ cursorOn(false),
+ cursorIsFocusIndicator(false),
mousePressed(false),
- lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false),
+ lastSelectionState(false),
+ ignoreAutomaticScrollbarAdjustement(false),
overwriteMode(false),
acceptRichText(true),
- preeditCursor(0), hideCursor(false),
+ hideCursor(false),
hasFocus(false),
isEnabled(true),
hadSelectionOnMousePress(false),
@@ -298,7 +302,6 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString &
doc = document;
clearDocument = false;
} else {
- palette = QGuiApplication::palette();
doc = new QTextDocument(q);
}
_q_documentLayoutChanged();
@@ -631,18 +634,6 @@ QQuickTextControl::~QQuickTextControl()
{
}
-void QQuickTextControl::setView(QObject *view)
-{
- Q_D(QQuickTextControl);
- d->contextObject = view;
-}
-
-QObject *QQuickTextControl::view() const
-{
- Q_D(const QQuickTextControl);
- return d->contextObject;
-}
-
QTextDocument *QQuickTextControl::document() const
{
Q_D(const QQuickTextControl);
@@ -1418,7 +1409,7 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, cons
Q_UNUSED(e);
- if (contextObject && isPreediting()) {
+ if (isPreediting()) {
QTextLayout *layout = cursor.block().layout();
int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position();
@@ -1908,81 +1899,12 @@ QString QQuickTextControl::toHtml() const
}
#endif
-QPalette QQuickTextControl::palette() const
-{
- Q_D(const QQuickTextControl);
- return d->palette;
-}
-
-void QQuickTextControl::setPalette(const QPalette &pal)
-{
- Q_D(QQuickTextControl);
- d->palette = pal;
-}
-
bool QQuickTextControl::cursorOn() const
{
Q_D(const QQuickTextControl);
return d->cursorOn;
}
-QAbstractTextDocumentLayout::PaintContext QQuickTextControl::getPaintContext() const
-{
- Q_D(const QQuickTextControl);
-
- QAbstractTextDocumentLayout::PaintContext ctx;
-
- ctx.palette = d->palette;
- if (d->cursorOn && d->isEnabled) {
- if (d->hideCursor)
- ctx.cursorPosition = -1;
- else if (d->preeditCursor != 0)
- ctx.cursorPosition = - (d->preeditCursor + 2);
- else
- ctx.cursorPosition = d->cursor.position();
- }
-
- if (d->cursor.hasSelection()) {
- QAbstractTextDocumentLayout::Selection selection;
- selection.cursor = d->cursor;
- if (0 && d->cursorIsFocusIndicator) {
-#if 0
- // ###
- QStyleOption opt;
- opt.palette = ctx.palette;
- QStyleHintReturnVariant ret;
- QStyle *style = QGuiApplication::style();
- if (widget)
- style = widget->style();
- style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret);
- selection.format = qvariant_cast<QTextFormat>(ret.variant).toCharFormat();
-#endif
- } else {
- QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive;
- selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight));
- selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText));
- if (fullWidthSelection)
- selection.format.setProperty(QTextFormat::FullWidthSelection, true);
- }
- ctx.selections.append(selection);
- }
-
- return ctx;
-}
-
-void QQuickTextControl::drawContents(QPainter *p, const QRectF &rect)
-{
- Q_D(QQuickTextControl);
- p->save();
- QAbstractTextDocumentLayout::PaintContext ctx = getPaintContext();
- if (rect.isValid())
- p->setClipRect(rect, Qt::IntersectClip);
- ctx.clip = rect;
-
- d->doc->documentLayout()->draw(p, ctx);
- p->restore();
-}
-
int QQuickTextControl::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
{
Q_D(const QQuickTextControl);
diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h
index e7beefdaa3..97ecdc4c6e 100644
--- a/src/quick/items/qquicktextcontrol_p.h
+++ b/src/quick/items/qquicktextcontrol_p.h
@@ -90,9 +90,6 @@ public:
explicit QQuickTextControl(QTextDocument *doc, QObject *parent = 0);
virtual ~QQuickTextControl();
- void setView(QObject *view);
- QObject *view() const;
-
QTextDocument *document() const;
void setTextCursor(const QTextCursor &cursor);
@@ -127,9 +124,6 @@ public:
qreal textWidth() const;
QSizeF size() const;
- void setIgnoreUnusedNavigationEvents(bool ignore);
- bool ignoreUnusedNavigationEvents() const;
-
void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
bool canPaste() const;
@@ -178,16 +172,10 @@ Q_SIGNALS:
void linkHovered(const QString &);
public:
- // control properties
- QPalette palette() const;
- void setPalette(const QPalette &pal);
-
virtual void processEvent(QEvent *e, const QMatrix &matrix);
void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF());
// control methods
- void drawContents(QPainter *painter, const QRectF &rect = QRectF());
-
void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h
index daf2f8ca82..44bc00221b 100644
--- a/src/quick/items/qquicktextcontrol_p_p.h
+++ b/src/quick/items/qquicktextcontrol_p_p.h
@@ -132,49 +132,40 @@ public:
bool isPreediting() const;
void commitPreedit();
- QTextDocument *doc;
- bool cursorOn;
- QTextCursor cursor;
- bool cursorIsFocusIndicator;
- QTextCharFormat lastCharFormat;
-
- Qt::TextInteractionFlags interactionFlags;
-
- QBasicTimer cursorBlinkTimer;
- QBasicTimer trippleClickTimer;
QPointF trippleClickPoint;
+ QPointF mousePressPos;
- bool mousePressed;
-
- QPoint mousePressPos;
-
- QPointer<QObject> contextObject;
-
- bool lastSelectionState;
-
- bool ignoreAutomaticScrollbarAdjustement;
+ QTextCharFormat lastCharFormat;
+ QTextDocument *doc;
+ QTextCursor cursor;
QTextCursor selectedWordOnDoubleClick;
QTextCursor selectedBlockOnTrippleClick;
+ QString tentativeCommit;
+ QString highlightedAnchor; // Anchor below cursor
+ QString anchorOnMousePress;
+ QString linkToCopy;
- bool overwriteMode;
- bool acceptRichText;
+ QBasicTimer cursorBlinkTimer;
+ QBasicTimer trippleClickTimer;
int preeditCursor;
- bool hideCursor; // used to hide the cursor in the preedit area
- QString tentativeCommit;
-
- QPalette palette;
- bool hasFocus;
- bool isEnabled;
- QString highlightedAnchor; // Anchor below cursor
- QString anchorOnMousePress;
- bool hadSelectionOnMousePress;
+ Qt::TextInteractionFlags interactionFlags;
- bool wordSelectionEnabled;
+ bool cursorOn : 1;
+ bool cursorIsFocusIndicator : 1;
+ bool mousePressed : 1;
+ bool lastSelectionState : 1;
+ bool ignoreAutomaticScrollbarAdjustement : 1;
+ bool overwriteMode : 1;
+ bool acceptRichText : 1;
+ bool hideCursor : 1; // used to hide the cursor in the preedit area
+ bool hasFocus : 1;
+ bool isEnabled : 1;
+ bool hadSelectionOnMousePress : 1;
+ bool wordSelectionEnabled : 1;
- QString linkToCopy;
void _q_copyLink();
void _q_updateBlock(const QTextBlock &);
void _q_documentLayoutChanged();
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 6eed95767b..a9bff73bd9 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -399,9 +399,6 @@ void QQuickTextEdit::setColor(const QColor &color)
return;
d->color = color;
- QPalette pal = d->control->palette();
- pal.setColor(QPalette::Text, color);
- d->control->setPalette(pal);
updateDocument();
emit colorChanged(d->color);
}
@@ -424,9 +421,6 @@ void QQuickTextEdit::setSelectionColor(const QColor &color)
return;
d->selectionColor = color;
- QPalette pal = d->control->palette();
- pal.setColor(QPalette::Highlight, color);
- d->control->setPalette(pal);
updateDocument();
emit selectionColorChanged(d->selectionColor);
}
@@ -449,9 +443,6 @@ void QQuickTextEdit::setSelectedTextColor(const QColor &color)
return;
d->selectedTextColor = color;
- QPalette pal = d->control->palette();
- pal.setColor(QPalette::HighlightedText, color);
- d->control->setPalette(pal);
updateDocument();
emit selectedTextColorChanged(d->selectedTextColor);
}
@@ -741,10 +732,10 @@ QRectF QQuickTextEdit::positionToRectangle(int pos) const
Position 0 is before the first character, position 1 is after the first character
but before the second, and so on until position \l {text}.length, which is after all characters.
*/
-int QQuickTextEdit::positionAt(int x, int y) const
+int QQuickTextEdit::positionAt(qreal x, qreal y) const
{
Q_D(const QQuickTextEdit);
- int r = d->document->documentLayout()->hitTest(QPoint(x,y-d->yoff), Qt::FuzzyHit);
+ int r = d->document->documentLayout()->hitTest(QPointF(x,y-d->yoff), Qt::FuzzyHit);
QTextCursor cursor = d->control->textCursor();
if (r > cursor.position()) {
// The cursor position includes positions within the preedit text, but only positions in the
@@ -1299,10 +1290,10 @@ Qt::TextInteractionFlags QQuickTextEdit::textInteractionFlags() const
automatically when it changes. The width of the delegate is unaffected by changes in the
cursor rectangle.
*/
-QRect QQuickTextEdit::cursorRectangle() const
+QRectF QQuickTextEdit::cursorRectangle() const
{
Q_D(const QQuickTextEdit);
- return d->control->cursorRect().toRect().translated(0,d->yoff);
+ return d->control->cursorRect().translated(0, d->yoff);
}
bool QQuickTextEdit::event(QEvent *event)
@@ -1634,10 +1625,8 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
QRectF bounds = boundingRect();
- QColor selectionColor = d->control->palette().color(QPalette::Highlight);
- QColor selectedTextColor = d->control->palette().color(QPalette::HighlightedText);
node->addTextDocument(bounds.topLeft(), d->document, d->color, QQuickText::Normal, QColor(),
- selectionColor, selectedTextColor, selectionStart(),
+ d->selectionColor, d->selectedTextColor, selectionStart(),
selectionEnd() - 1); // selectionEnd() returns first char after
// selection
@@ -1756,31 +1745,21 @@ void QQuickTextEditPrivate::init()
document = new QQuickTextDocumentWithImageResources(q);
control = new QQuickTextControl(document, q);
- control->setView(q);
control->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable);
control->setAcceptRichText(false);
control->setCursorIsFocusIndicator(true);
- // QQuickTextControl follows the default text color
- // defined by the platform, declarative text
- // should be black by default
- QPalette pal = control->palette();
- if (pal.color(QPalette::Text) != color) {
- pal.setColor(QPalette::Text, color);
- control->setPalette(pal);
- }
-
- QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateDocument()));
- QObject::connect(control, SIGNAL(updateCursorRequest()), q, SLOT(updateCursor()));
- 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()));
- QObject::connect(control, SIGNAL(cursorRectangleChanged()), q, SLOT(moveCursorDelegate()));
- QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
+ FAST_CONNECT(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateDocument()));
+ FAST_CONNECT(control, SIGNAL(updateCursorRequest()), q, SLOT(updateCursor()));
+ FAST_CONNECT(control, SIGNAL(textChanged()), q, SLOT(q_textChanged()));
+ FAST_CONNECT(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
+ FAST_CONNECT(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers()));
+ FAST_CONNECT(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
+ FAST_CONNECT(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
+ FAST_CONNECT(control, SIGNAL(cursorRectangleChanged()), q, SLOT(moveCursorDelegate()));
+ FAST_CONNECT(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
#ifndef QT_NO_CLIPBOARD
- QObject::connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
+ FAST_CONNECT(QGuiApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
#endif
FAST_CONNECT(document, SIGNAL(undoAvailable(bool)), q, SIGNAL(canUndoChanged()));
FAST_CONNECT(document, SIGNAL(redoAvailable(bool)), q, SIGNAL(canRedoChanged()));
@@ -1884,11 +1863,11 @@ void QQuickTextEdit::updateSize()
} else {
d->document->setTextWidth(-1);
}
- QFontMetrics fm = QFontMetrics(d->font);
- int dy = height();
- dy -= (int)d->document->size().height();
+ QFontMetricsF fm(d->font);
+ qreal dy = height();
+ dy -= d->document->size().height();
- int nyoff;
+ qreal nyoff;
if (heightValid()) {
if (d->vAlign == AlignBottom)
nyoff = dy;
@@ -1904,7 +1883,7 @@ void QQuickTextEdit::updateSize()
setBaselineOffset(fm.ascent() + d->yoff + d->textMargin);
//### need to comfirm cost of always setting these
- int newWidth = qCeil(d->document->idealWidth());
+ qreal newWidth = d->document->idealWidth();
if (!widthValid() && d->document->textWidth() != newWidth)
d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug)
// ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed.
@@ -1913,13 +1892,13 @@ void QQuickTextEdit::updateSize()
iWidth = newWidth;
else if (d->requireImplicitWidth)
iWidth = naturalWidth;
- qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height();
+ qreal newHeight = d->document->isEmpty() ? fm.height() : d->document->size().height();
if (iWidth > -1)
setImplicitSize(iWidth, newHeight);
else
setImplicitHeight(newHeight);
- QSize size(newWidth, newHeight);
+ QSizeF size(newWidth, newHeight);
if (d->contentSize != size) {
d->contentSize = size;
emit contentSizeChanged();
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index 4dcb7f48d6..b28ec9d7d7 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -79,7 +79,7 @@ class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
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 cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
+ Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
@@ -212,7 +212,7 @@ public:
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
Qt::TextInteractionFlags textInteractionFlags() const;
- QRect cursorRectangle() const;
+ QRectF cursorRectangle() const;
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
@@ -224,7 +224,7 @@ public:
void resetBaseUrl();
Q_INVOKABLE QRectF positionToRectangle(int) const;
- Q_INVOKABLE int positionAt(int x, int y) const;
+ Q_INVOKABLE int positionAt(qreal x, qreal y) const;
Q_INVOKABLE void moveCursorSelection(int pos);
Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index 3004d5b833..055b5c7929 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -68,15 +68,17 @@ class QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
public:
QQuickTextEditPrivate()
- : color("black"), hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop),
- documentDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
- persistentSelection(false), requireImplicitWidth(false), selectByMouse(false), canPaste(false),
- canPasteValid(false), hAlignImplicit(true), rightToLeftText(false),
- textCached(false),
- textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0),
- format(QQuickTextEdit::PlainText), document(0), wrapMode(QQuickTextEdit::NoWrap),
- mouseSelectionMode(QQuickTextEdit::SelectCharacters),
- lineCount(0), yoff(0), inputMethodHints(Qt::ImhNone), updateType(UpdatePaintNode)
+ : color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
+ , textMargin(0.0), yoff(0), font(sourceFont), cursorComponent(0), cursor(0), document(0), control(0)
+ , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
+ , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
+ , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
+ , mouseSelectionMode(QQuickTextEdit::SelectCharacters), inputMethodHints(Qt::ImhNone)
+ , updateType(UpdatePaintNode)
+ , documentDirty(true), dirty(false), richText(false), cursorVisible(false)
+ , focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
+ , selectByMouse(false), canPaste(false), canPasteValid(false), hAlignImplicit(true)
+ , rightToLeftText(false), textCached(false)
{
}
@@ -92,17 +94,42 @@ public:
void mirrorChange();
qreal getImplicitWidth() const;
+ QColor color;
+ QColor selectionColor;
+ QColor selectedTextColor;
+
+ QSizeF contentSize;
+
+ qreal textMargin;
+ qreal yoff;
+
QString text;
QUrl baseUrl;
- QFont font;
QFont sourceFont;
- QColor color;
- QColor selectionColor;
- QColor selectedTextColor;
- QString style;
- QColor styleColor;
+ QFont font;
+
+ QQmlComponent* cursorComponent;
+ QQuickItem* cursor;
+ QQuickTextDocumentWithImageResources *document;
+ QQuickTextControl *control;
+
+ int lastSelectionStart;
+ int lastSelectionEnd;
+ int lineCount;
+
+ enum UpdateType {
+ UpdateNone,
+ UpdateOnlyPreprocess,
+ UpdatePaintNode
+ };
+
QQuickTextEdit::HAlignment hAlign;
QQuickTextEdit::VAlignment vAlign;
+ QQuickTextEdit::TextFormat format;
+ QQuickTextEdit::WrapMode wrapMode;
+ QQuickTextEdit::SelectionMode mouseSelectionMode;
+ Qt::InputMethodHints inputMethodHints;
+ UpdateType updateType;
bool documentDirty : 1;
bool dirty : 1;
@@ -117,28 +144,6 @@ public:
bool hAlignImplicit:1;
bool rightToLeftText:1;
bool textCached:1;
-
- qreal textMargin;
- int lastSelectionStart;
- int lastSelectionEnd;
- QQmlComponent* cursorComponent;
- QQuickItem* cursor;
- QQuickTextEdit::TextFormat format;
- QQuickTextDocumentWithImageResources *document;
- QQuickTextControl *control;
- QQuickTextEdit::WrapMode wrapMode;
- QQuickTextEdit::SelectionMode mouseSelectionMode;
- int lineCount;
- int yoff;
- QSize contentSize;
- Qt::InputMethodHints inputMethodHints;
-
- enum UpdateType {
- UpdateNone,
- UpdateOnlyPreprocess,
- UpdatePaintNode
- };
- UpdateType updateType;
};
QT_END_NAMESPACE
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index ab5afa334d..1a93345aa2 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -677,7 +677,7 @@ void QQuickTextInput::setCursorPosition(int cp)
cursor rectangle.
*/
-QRect QQuickTextInput::cursorRectangle() const
+QRectF QQuickTextInput::cursorRectangle() const
{
Q_D(const QQuickTextInput);
@@ -688,12 +688,8 @@ QRect QQuickTextInput::cursorRectangle() const
c = 0;
QTextLine l = d->m_textLayout.lineForTextPosition(c);
if (!l.isValid())
- return QRect();
- return QRect(
- qRound(l.cursorToX(c) - d->hscroll),
- qRound(l.y() - d->vscroll),
- 1,
- qCeil(l.height()));
+ return QRectF();
+ return QRectF(l.cursorToX(c) - d->hscroll, l.y() - d->vscroll, 1, l.height());
}
/*!
@@ -1368,7 +1364,7 @@ void QQuickTextInput::positionAt(QQmlV8Function *args) const
args->returnValue(v8::Int32::New(pos));
}
-int QQuickTextInputPrivate::positionAt(int x, int y, QTextLine::CursorPosition position) const
+int QQuickTextInputPrivate::positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const
{
x += hscroll;
y += vscroll;
@@ -1432,7 +1428,7 @@ void QQuickTextInput::mouseDoubleClickEvent(QMouseEvent *event)
d->selectWordAtPos(cursor);
event->setAccepted(true);
if (!d->hasPendingTripleClick()) {
- d->tripleClickStartPoint = event->localPos().toPoint();
+ d->tripleClickStartPoint = event->localPos();
d->tripleClickTimer.start();
}
} else {
@@ -1617,15 +1613,15 @@ void QQuickTextInputPrivate::updateHorizontalScroll()
Q_Q(QQuickTextInput);
QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + m_preeditCursor);
const int preeditLength = m_textLayout.preeditAreaText().length();
- const int width = qMax(0, qFloor(q->width()));
- int widthUsed = currentLine.isValid() ? qRound(currentLine.naturalTextWidth()) : 0;
+ const qreal width = qMax<qreal>(0, q->width());
+ qreal widthUsed = currentLine.isValid() ? currentLine.naturalTextWidth() : 0;
int previousScroll = hscroll;
if (!autoScroll || widthUsed <= width || m_echoMode == QQuickTextInput::NoEcho) {
hscroll = 0;
} else {
Q_ASSERT(currentLine.isValid());
- int cix = qRound(currentLine.cursorToX(m_cursor + preeditLength));
+ qreal cix = currentLine.cursorToX(m_cursor + preeditLength);
if (cix - hscroll >= width) {
// text doesn't fit, cursor is to the right of br (scroll right)
hscroll = cix - width;
@@ -1640,7 +1636,7 @@ void QQuickTextInputPrivate::updateHorizontalScroll()
if (preeditLength > 0) {
// check to ensure long pre-edit text doesn't push the cursor
// off to the left
- cix = qRound(currentLine.cursorToX(m_cursor + qMax(0, m_preeditCursor - 1)));
+ cix = currentLine.cursorToX(m_cursor + qMax(0, m_preeditCursor - 1));
if (cix < hscroll)
hscroll = cix;
}
@@ -1653,9 +1649,9 @@ void QQuickTextInputPrivate::updateVerticalScroll()
{
Q_Q(QQuickTextInput);
const int preeditLength = m_textLayout.preeditAreaText().length();
- const int height = qMax(0, qFloor(q->height()));
- int heightUsed = boundingRect.height();
- int previousScroll = vscroll;
+ const qreal height = qMax<qreal>(0, q->height());
+ qreal heightUsed = boundingRect.height();
+ qreal previousScroll = vscroll;
if (!autoScroll || heightUsed <= height) {
// text fits in br; use vscroll for alignment
@@ -1674,8 +1670,8 @@ void QQuickTextInputPrivate::updateVerticalScroll()
} else {
QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + preeditLength);
QRectF r = currentLine.isValid() ? currentLine.rect() : QRectF();
- int top = qFloor(r.top());
- int bottom = qCeil(r.bottom());
+ qreal top = r.top();
+ int bottom = r.bottom();
if (bottom - vscroll >= height) {
// text doesn't fit, cursor is to the below the br (scroll down)
@@ -1692,7 +1688,7 @@ void QQuickTextInputPrivate::updateVerticalScroll()
// check to ensure long pre-edit text doesn't push the cursor
// off the top
currentLine = m_textLayout.lineForTextPosition(m_cursor + qMax(0, m_preeditCursor - 1));
- top = currentLine.isValid() ? qRound(currentLine.rect().top()) : 0;
+ top = currentLine.isValid() ? currentLine.rect().top() : 0;
if (top < vscroll)
vscroll = top;
}
@@ -1742,11 +1738,11 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
node->deleteContent();
node->setMatrix(QMatrix4x4());
- QPoint offset = QPoint(0,0);
+ QPointF offset(0, 0);
if (d->autoScroll && d->m_textLayout.lineCount() > 0) {
- QFontMetrics fm = QFontMetrics(d->font);
+ QFontMetricsF fm(d->font);
// the y offset is there to keep the baseline constant in case we have script changes in the text.
- offset = -QPoint(d->hscroll, d->vscroll + qRound(d->m_textLayout.lineAt(0).ascent()) - fm.ascent());
+ offset = -QPoint(d->hscroll, d->vscroll + d->m_textLayout.lineAt(0).ascent() - fm.ascent());
} else {
offset = -QPoint(d->hscroll, d->vscroll);
}
@@ -2732,7 +2728,7 @@ void QQuickTextInputPrivate::updateLayout()
updateType = UpdatePaintNode;
q->update();
- q->setImplicitSize(qCeil(boundingRect.width()), qCeil(boundingRect.height()));
+ q->setImplicitSize(boundingRect.width(), boundingRect.height());
if (previousRect != boundingRect)
emit q->contentSizeChanged();
diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h
index 8961dbc3e1..011af65bff 100644
--- a/src/quick/items/qquicktextinput_p.h
+++ b/src/quick/items/qquicktextinput_p.h
@@ -76,7 +76,7 @@ class Q_AUTOTEST_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
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 cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
+ Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
Q_PROPERTY(QQmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
@@ -195,7 +195,7 @@ public:
int cursorPosition() const;
void setCursorPosition(int cp);
- QRect cursorRectangle() const;
+ QRectF cursorRectangle() const;
int selectionStart() const;
int selectionEnd() const;
diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h
index 2575694888..9a59b44549 100644
--- a/src/quick/items/qquicktextinput_p_p.h
+++ b/src/quick/items/qquicktextinput_p_p.h
@@ -77,14 +77,14 @@ class Q_AUTOTEST_EXPORT QQuickTextInputPrivate : public QQuickImplicitSizeItemPr
Q_DECLARE_PUBLIC(QQuickTextInput)
public:
QQuickTextInputPrivate()
- : cursorItem(0)
+ : hscroll(0)
+ , vscroll(0)
+ , cursorItem(0)
, textNode(0)
, m_maskData(0)
, color(QRgb(0xFF000000))
, selectionColor(QRgb(0xFF000080))
, selectedTextColor(QRgb(0xFFFFFFFF))
- , hscroll(0)
- , vscroll(0)
, m_cursor(0)
, m_preeditCursor(0)
, m_blinkPeriod(0)
@@ -179,6 +179,9 @@ public:
QQmlGuard<QValidator> m_validator;
#endif
+ qreal hscroll;
+ qreal vscroll;
+
QTextLayout m_textLayout;
QString m_text;
QString m_inputMask;
@@ -203,8 +206,6 @@ public:
#endif
int lastSelectionStart;
int lastSelectionEnd;
- int hscroll;
- int vscroll;
int m_cursor;
int m_preeditCursor;
int m_blinkPeriod; // 0 for non-blinking cursor
@@ -295,7 +296,7 @@ public:
int selectionStart() const { return hasSelectedText() ? m_selstart : -1; }
int selectionEnd() const { return hasSelectedText() ? m_selend : -1; }
- int positionAt(int x, int y, QTextLine::CursorPosition position) const;
+ int positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const;
int positionAt(const QPointF &point, QTextLine::CursorPosition position = QTextLine::CursorBetweenCharacters) const {
return positionAt(point.x(), point.y(), position);
}
diff --git a/src/quick/items/qquickvisualadaptormodel_p.h b/src/quick/items/qquickvisualadaptormodel_p.h
index 93de4b1126..cf6dabe237 100644
--- a/src/quick/items/qquickvisualadaptormodel_p.h
+++ b/src/quick/items/qquickvisualadaptormodel_p.h
@@ -121,7 +121,9 @@ public:
virtual QObject *proxiedObject() = 0;
};
-Q_DECLARE_INTERFACE(QQuickVisualAdaptorModelProxyInterface, "com.trolltech.qml.QQuickVisualAdaptorModelProxyInterface")
+#define QQuickVisualAdaptorModelProxyInterface_iid "org.qt-project.Qt.QQuickVisualAdaptorModelProxyInterface"
+
+Q_DECLARE_INTERFACE(QQuickVisualAdaptorModelProxyInterface, QQuickVisualAdaptorModelProxyInterface_iid)
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickvisualdatamodel.cpp b/src/quick/items/qquickvisualdatamodel.cpp
index 07ad3660be..70f8897b2d 100644
--- a/src/quick/items/qquickvisualdatamodel.cpp
+++ b/src/quick/items/qquickvisualdatamodel.cpp
@@ -450,6 +450,41 @@ QQuickVisualDataModel::ReleaseFlags QQuickVisualDataModel::release(QQuickItem *i
return stat;
}
+// Cancel a requested async item
+void QQuickVisualDataModel::cancel(int index)
+{
+ Q_D(QQuickVisualDataModel);
+ if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
+ qWarning() << "VisualDataModel::cancel: index out range" << index << d->m_compositor.count(d->m_compositorGroup);
+ return;
+ }
+
+ Compositor::iterator it = d->m_compositor.find(d->m_compositorGroup, index);
+ QQuickVisualDataModelItem *cacheItem = it->inCache() ? d->m_cache.at(it.cacheIndex) : 0;
+ if (cacheItem) {
+ if (cacheItem->incubationTask) {
+ delete cacheItem->incubationTask->incubatingContext;
+ cacheItem->incubationTask->incubatingContext = 0;
+ d->releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask = 0;
+ }
+ if (cacheItem->object && !cacheItem->isObjectReferenced()) {
+ d->destroy(cacheItem->object);
+ if (QQuickPackage *package = qobject_cast<QQuickPackage *>(cacheItem->object))
+ d->emitDestroyingPackage(package);
+ else if (QQuickItem *item = qobject_cast<QQuickItem *>(cacheItem->object))
+ d->emitDestroyingItem(item);
+ cacheItem->object = 0;
+ }
+ if (!cacheItem->isReferenced()) {
+ d->m_compositor.clearFlags(Compositor::Cache, it.cacheIndex, 1, Compositor::CacheFlag);
+ d->m_cache.removeAt(it.cacheIndex);
+ delete cacheItem;
+ Q_ASSERT(d->m_cache.count() == d->m_compositor.count(Compositor::Cache));
+ }
+ }
+}
+
void QQuickVisualDataModelPrivate::group_append(
QQmlListProperty<QQuickVisualDataGroup> *property, QQuickVisualDataGroup *group)
{
@@ -708,8 +743,10 @@ void QQuickVisualDataModelPrivate::incubatorStatusChanged(QVDMIncubationTask *in
incubationTask->incubatingContext = 0;
if (!cacheItem->isReferenced()) {
int cidx = m_cache.indexOf(cacheItem);
- m_compositor.clearFlags(Compositor::Cache, cidx, 1, Compositor::CacheFlag);
- m_cache.removeAt(cidx);
+ if (cidx >= 0) {
+ m_compositor.clearFlags(Compositor::Cache, cidx, 1, Compositor::CacheFlag);
+ m_cache.removeAt(cidx);
+ }
delete cacheItem;
Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache));
}
diff --git a/src/quick/items/qquickvisualdatamodel_p.h b/src/quick/items/qquickvisualdatamodel_p.h
index ee90d528f4..535374be09 100644
--- a/src/quick/items/qquickvisualdatamodel_p.h
+++ b/src/quick/items/qquickvisualdatamodel_p.h
@@ -106,6 +106,7 @@ public:
bool isValid() const { return delegate() != 0; }
QQuickItem *item(int index, bool asynchronous=false);
ReleaseFlags release(QQuickItem *item);
+ void cancel(int index);
virtual QString stringValue(int index, const QString &role);
virtual void setWatchedRoles(QList<QByteArray> roles);
diff --git a/src/quick/items/qquickvisualitemmodel_p.h b/src/quick/items/qquickvisualitemmodel_p.h
index 9f90a29125..bf56195c66 100644
--- a/src/quick/items/qquickvisualitemmodel_p.h
+++ b/src/quick/items/qquickvisualitemmodel_p.h
@@ -69,6 +69,7 @@ public:
virtual bool isValid() const = 0;
virtual QQuickItem *item(int index, bool asynchronous=false) = 0;
virtual ReleaseFlags release(QQuickItem *item) = 0;
+ virtual void cancel(int) {}
virtual QString stringValue(int, const QString &) = 0;
virtual void setWatchedRoles(QList<QByteArray> roles) = 0;
diff --git a/src/quick/items/qquickwindowmanager.cpp b/src/quick/items/qquickwindowmanager.cpp
index 55f11bf4c0..5de8ad1279 100644
--- a/src/quick/items/qquickwindowmanager.cpp
+++ b/src/quick/items/qquickwindowmanager.cpp
@@ -48,8 +48,8 @@
#include <QtCore/private/qabstractanimation_p.h>
#include <QtGui/QOpenGLContext>
-#include <QtGui/QPlatformIntegration>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qplatformintegration_qpa.h>
#include <QtQml/private/qqmlglobal_p.h>
@@ -145,6 +145,10 @@ DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP);
//#define THREAD_DEBUG
+QQuickWindowManager::~QQuickWindowManager()
+{
+}
+
class QQuickRenderThreadSingleContextWindowManager : public QThread, public QQuickWindowManager
{
Q_OBJECT
@@ -165,7 +169,6 @@ public:
, shouldExit(false)
, hasExited(false)
, isDeferredUpdatePosted(false)
- , runToReleaseResources(false)
, canvasToGrab(0)
{
sg->moveToThread(this);
@@ -176,13 +179,10 @@ public:
connect(animationDriver, SIGNAL(stopped()), this, SLOT(animationStopped()));
}
- ~QQuickRenderThreadSingleContextWindowManager()
- {
- releaseResources();
- }
-
QSGContext *sceneGraphContext() const { return sg; }
+ void releaseResources() { }
+
void show(QQuickCanvas *canvas);
void hide(QQuickCanvas *canvas);
@@ -193,6 +193,7 @@ public:
void resize(QQuickCanvas *canvas, const QSize &size);
void handleDeferredUpdate();
void maybeUpdate(QQuickCanvas *canvas);
+ void wakeup();
void startRendering();
void stopRendering();
@@ -201,10 +202,8 @@ public:
void sync(bool guiAlreadyLocked);
void initialize();
- void releaseResources();
- void releaseResourcesInThread();
- bool *allowMainThreadProcessing() { return &allowMainThreadProcessingFlag; }
+ volatile bool *allowMainThreadProcessing() { return &allowMainThreadProcessingFlag; }
bool event(QEvent *);
@@ -245,7 +244,7 @@ private:
QMutex mutex;
QWaitCondition condition;
- bool allowMainThreadProcessingFlag;
+ volatile bool allowMainThreadProcessingFlag;
int isGuiLocked;
uint animationRunning: 1;
@@ -258,7 +257,6 @@ private:
uint shouldExit : 1;
uint hasExited : 1;
uint isDeferredUpdatePosted : 1;
- uint runToReleaseResources : 1;
QQuickCanvas *canvasToGrab;
QImage grabContent;
@@ -291,29 +289,26 @@ class QQuickTrivialWindowManager : public QObject, public QQuickWindowManager
{
public:
QQuickTrivialWindowManager();
- ~QQuickTrivialWindowManager()
- {
- releaseResources();
- }
void show(QQuickCanvas *canvas);
void hide(QQuickCanvas *canvas);
void canvasDestroyed(QQuickCanvas *canvas);
- void releaseResources();
void initializeGL();
void renderCanvas(QQuickCanvas *canvas);
void paint(QQuickCanvas *canvas);
QImage grab(QQuickCanvas *canvas);
void resize(QQuickCanvas *canvas, const QSize &size);
+ void wakeup();
void maybeUpdate(QQuickCanvas *canvas);
- bool *allowMainThreadProcessing();
+ void releaseResources() { }
+
+ volatile bool *allowMainThreadProcessing();
QSGContext *sceneGraphContext() const;
- QQuickCanvas *masterCanvas() const;
bool event(QEvent *);
@@ -564,18 +559,10 @@ void QQuickRenderThreadSingleContextWindowManager::run()
#ifdef THREAD_DEBUG
printf("QML Rendering Thread Started\n");
#endif
- lock();
-
- if (runToReleaseResources) {
- releaseResourcesInThread();
- runToReleaseResources = false;
- unlock();
- return;
- }
-
- if (!gl)
- initialize();
+ lock();
+ Q_ASSERT(!gl);
+ initialize();
// Wake GUI as it is waiting for the GL context to have appeared, as
// an indication that the render thread is now running.
wake();
@@ -772,6 +759,12 @@ void QQuickRenderThreadSingleContextWindowManager::run()
m_removed_windows << m_rendered_windows.keys();
handleRemovedWindows();
+ sg->invalidate();
+
+ gl->doneCurrent();
+ delete gl;
+ gl = 0;
+
#ifdef THREAD_DEBUG
printf(" RenderThread: render loop exited... Good Night!\n");
#endif
@@ -790,59 +783,6 @@ void QQuickRenderThreadSingleContextWindowManager::run()
#endif
}
-void QQuickRenderThreadSingleContextWindowManager::releaseResourcesInThread()
-{
-#ifdef THREAD_DEBUG
- printf(" RenderThread: releasing resources...\n");
-#endif
- QQuickCanvas *canvas = masterCanvas();
- QWindow *tmpSurface = 0;
-
- if (canvas) {
- gl->makeCurrent(canvas);
- } else {
- tmpSurface = new QWindow();
- tmpSurface->setSurfaceType(QSurface::OpenGLSurface);
- tmpSurface->resize(4, 4);
- tmpSurface->create();
- gl->makeCurrent(tmpSurface);
- }
-
- sg->invalidate();
- gl->doneCurrent();
- delete gl;
- gl = 0;
-
- if (tmpSurface)
- delete tmpSurface;
-
- wake();
-}
-
-void QQuickRenderThreadSingleContextWindowManager::releaseResources()
-{
-#ifdef THREAD_DEBUG
- printf("GUI: releasing resources\n");
-#endif
-
- lockInGui();
- if (!isRunning() && gl) {
- runToReleaseResources = true;
- start();
-
- while (isRunning()) {
- wait();
- }
- }
-#ifdef THREAD_DEBUG
- else {
- printf("GUI: render thread running not releasing resources...\n");
- }
-#endif
- unlockInGui();
-
-}
-
bool QQuickRenderThreadSingleContextWindowManager::event(QEvent *e)
{
Q_ASSERT(QThread::currentThread() == qApp->thread());
@@ -1074,6 +1014,7 @@ void QQuickRenderThreadSingleContextWindowManager::startRendering()
animationTimer = -1;
}
+
}
@@ -1190,6 +1131,14 @@ void QQuickRenderThreadSingleContextWindowManager::maybeUpdate(QQuickCanvas *)
}
+void QQuickRenderThreadSingleContextWindowManager::wakeup()
+{
+ lockInGui();
+ if (isRenderBlocked)
+ wake();
+ unlockInGui();
+}
+
QQuickTrivialWindowManager::QQuickTrivialWindowManager()
: gl(0)
, eventPending(false)
@@ -1216,46 +1165,17 @@ void QQuickTrivialWindowManager::hide(QQuickCanvas *canvas)
m_windows.remove(canvas);
QQuickCanvasPrivate *cd = QQuickCanvasPrivate::get(canvas);
cd->cleanupNodesOnShutdown();
-}
-
-void QQuickTrivialWindowManager::canvasDestroyed(QQuickCanvas *canvas)
-{
- hide(canvas);
-}
-
-void QQuickTrivialWindowManager::releaseResources()
-{
- if (m_windows.size() == 0 && gl) {
- QQuickCanvas *canvas = masterCanvas();
- QWindow *tmpSurface = 0;
-
- if (canvas) {
- gl->makeCurrent(canvas);
- } else {
- tmpSurface = new QWindow();
- tmpSurface->setSurfaceType(QSurface::OpenGLSurface);
- tmpSurface->resize(4, 4);
- tmpSurface->create();
- gl->makeCurrent(tmpSurface);
- }
+ if (m_windows.size() == 0) {
sg->invalidate();
delete gl;
gl = 0;
-
- delete tmpSurface;
}
}
-QQuickCanvas *QQuickTrivialWindowManager::masterCanvas() const
+void QQuickTrivialWindowManager::canvasDestroyed(QQuickCanvas *canvas)
{
- // Find a "proper surface" to bind...
- for (QHash<QQuickCanvas *, CanvasData>::const_iterator it = m_windows.constBegin();
- it != m_windows.constEnd(); ++it) {
- if (it.key()->visible())
- return it.key();
- }
- return 0;
+ hide(canvas);
}
void QQuickTrivialWindowManager::renderCanvas(QQuickCanvas *canvas)
@@ -1265,20 +1185,30 @@ void QQuickTrivialWindowManager::renderCanvas(QQuickCanvas *canvas)
CanvasData &data = const_cast<CanvasData &>(m_windows[canvas]);
- QQuickCanvas *window = canvas->visible() ? canvas : masterCanvas();
+ QQuickCanvas *masterCanvas = 0;
+ if (!canvas->visible()) {
+ // Find a "proper surface" to bind...
+ for (QHash<QQuickCanvas *, CanvasData>::const_iterator it = m_windows.constBegin();
+ it != m_windows.constEnd() && !masterCanvas; ++it) {
+ if (it.key()->visible())
+ masterCanvas = it.key();
+ }
+ } else {
+ masterCanvas = canvas;
+ }
- if (!window)
+ if (!masterCanvas)
return;
if (!gl) {
gl = new QOpenGLContext();
- gl->setFormat(window->requestedFormat());
+ gl->setFormat(masterCanvas->requestedFormat());
gl->create();
- if (!gl->makeCurrent(window))
+ if (!gl->makeCurrent(masterCanvas))
qWarning("QQuickCanvas: makeCurrent() failed...");
sg->initialize(gl);
} else {
- gl->makeCurrent(window);
+ gl->makeCurrent(masterCanvas);
}
bool alsoSwap = data.updatePending;
@@ -1348,9 +1278,11 @@ void QQuickTrivialWindowManager::maybeUpdate(QQuickCanvas *canvas)
}
}
+void QQuickTrivialWindowManager::wakeup()
+{
+}
-
-bool *QQuickTrivialWindowManager::allowMainThreadProcessing()
+volatile bool *QQuickTrivialWindowManager::allowMainThreadProcessing()
{
return 0;
}
diff --git a/src/quick/items/qquickwindowmanager_p.h b/src/quick/items/qquickwindowmanager_p.h
index ed972b5c76..9372e90f5e 100644
--- a/src/quick/items/qquickwindowmanager_p.h
+++ b/src/quick/items/qquickwindowmanager_p.h
@@ -52,6 +52,8 @@ class QSGContext;
class QQuickWindowManager
{
public:
+ virtual ~QQuickWindowManager();
+
virtual void show(QQuickCanvas *canvas) = 0;
virtual void hide(QQuickCanvas *canvas) = 0;
@@ -62,8 +64,9 @@ public:
virtual void resize(QQuickCanvas *canvas, const QSize &size) = 0;
virtual void maybeUpdate(QQuickCanvas *canvas) = 0;
+ virtual void wakeup() = 0;
- virtual bool *allowMainThreadProcessing() = 0;
+ virtual volatile bool *allowMainThreadProcessing() = 0;
virtual QSGContext *sceneGraphContext() const = 0;
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index 6faeb96da0..4c9620748a 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index e0da37d22c..72fd2b32bd 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickage.cpp b/src/quick/particles/qquickage.cpp
index 307fb58577..9f24cba3cc 100644
--- a/src/quick/particles/qquickage.cpp
+++ b/src/quick/particles/qquickage.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickage_p.h b/src/quick/particles/qquickage_p.h
index 60fc0bd98d..2ec8faae4b 100644
--- a/src/quick/particles/qquickage_p.h
+++ b/src/quick/particles/qquickage_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickangledirection.cpp b/src/quick/particles/qquickangledirection.cpp
index 48fc5a8273..a3bd45e0bf 100644
--- a/src/quick/particles/qquickangledirection.cpp
+++ b/src/quick/particles/qquickangledirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qquickangledirection_p.h"
+#include <stdlib.h>
#include <cmath>
QT_BEGIN_NAMESPACE
const qreal CONV = 0.017453292519943295;
diff --git a/src/quick/particles/qquickangledirection_p.h b/src/quick/particles/qquickangledirection_p.h
index 4f86fec5f4..84633cd40e 100644
--- a/src/quick/particles/qquickangledirection_p.h
+++ b/src/quick/particles/qquickangledirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickcumulativedirection.cpp b/src/quick/particles/qquickcumulativedirection.cpp
index 4f4a2cc46e..d7c4094297 100644
--- a/src/quick/particles/qquickcumulativedirection.cpp
+++ b/src/quick/particles/qquickcumulativedirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickcumulativedirection_p.h b/src/quick/particles/qquickcumulativedirection_p.h
index 38663572fb..e1675a18d8 100644
--- a/src/quick/particles/qquickcumulativedirection_p.h
+++ b/src/quick/particles/qquickcumulativedirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickcustomaffector.cpp b/src/quick/particles/qquickcustomaffector.cpp
index 7c991c7352..acec98192d 100644
--- a/src/quick/particles/qquickcustomaffector.cpp
+++ b/src/quick/particles/qquickcustomaffector.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickcustomaffector_p.h b/src/quick/particles/qquickcustomaffector_p.h
index e831dbce1d..1266830f94 100644
--- a/src/quick/particles/qquickcustomaffector_p.h
+++ b/src/quick/particles/qquickcustomaffector_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickdirection.cpp b/src/quick/particles/qquickdirection.cpp
index da022fe4f5..4127d06be0 100644
--- a/src/quick/particles/qquickdirection.cpp
+++ b/src/quick/particles/qquickdirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickdirection_p.h b/src/quick/particles/qquickdirection_p.h
index 22e2278b46..651865a1f5 100644
--- a/src/quick/particles/qquickdirection_p.h
+++ b/src/quick/particles/qquickdirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickellipseextruder.cpp b/src/quick/particles/qquickellipseextruder.cpp
index 3b80810773..3eb547fd2f 100644
--- a/src/quick/particles/qquickellipseextruder.cpp
+++ b/src/quick/particles/qquickellipseextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qquickellipseextruder_p.h"
+#include <stdlib.h>
#include <cmath>
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/quick/particles/qquickellipseextruder_p.h b/src/quick/particles/qquickellipseextruder_p.h
index 00b151eae2..c2d0c634ab 100644
--- a/src/quick/particles/qquickellipseextruder_p.h
+++ b/src/quick/particles/qquickellipseextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickfriction.cpp b/src/quick/particles/qquickfriction.cpp
index 57de3d9eac..d37d109f48 100644
--- a/src/quick/particles/qquickfriction.cpp
+++ b/src/quick/particles/qquickfriction.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickfriction_p.h b/src/quick/particles/qquickfriction_p.h
index b79e57a047..3b06710529 100644
--- a/src/quick/particles/qquickfriction_p.h
+++ b/src/quick/particles/qquickfriction_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgravity.cpp b/src/quick/particles/qquickgravity.cpp
index 2ab3a299f1..cf4f35eb72 100644
--- a/src/quick/particles/qquickgravity.cpp
+++ b/src/quick/particles/qquickgravity.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgravity_p.h b/src/quick/particles/qquickgravity_p.h
index 807b315255..a738fd3ef3 100644
--- a/src/quick/particles/qquickgravity_p.h
+++ b/src/quick/particles/qquickgravity_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgroupgoal.cpp b/src/quick/particles/qquickgroupgoal.cpp
index 926768d27a..0d7f15a9e1 100644
--- a/src/quick/particles/qquickgroupgoal.cpp
+++ b/src/quick/particles/qquickgroupgoal.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickgroupgoal_p.h b/src/quick/particles/qquickgroupgoal_p.h
index 483d45fc50..f553badbd6 100644
--- a/src/quick/particles/qquickgroupgoal_p.h
+++ b/src/quick/particles/qquickgroupgoal_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickimageparticle.cpp b/src/quick/particles/qquickimageparticle.cpp
index bf576b0a54..7f87dabe7d 100644
--- a/src/quick/particles/qquickimageparticle.cpp
+++ b/src/quick/particles/qquickimageparticle.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -1237,6 +1237,9 @@ void QQuickImageParticle::clearShadows()
//Only call if you need to, may initialize the whole array first time
QQuickParticleData* QQuickImageParticle::getShadowDatum(QQuickParticleData* datum)
{
+ //Will return datum if the datum is a sentinel or uninitialized, to centralize that one check
+ if (datum->systemIndex == -1)
+ return datum;
QQuickParticleGroupData* gd = m_system->groupData[datum->group];
if (!m_shadowData.contains(datum->group)) {
QVector<QQuickParticleData*> data;
@@ -1339,6 +1342,10 @@ void QQuickImageParticle::finishBuildParticleNodes()
}
}
}
+#ifdef Q_OS_WIN
+ if (perfLevel < Deformable) //QTBUG-24540 , point sprite 'extension' isn't working on windows.
+ perfLevel = Deformable;
+#endif
if (perfLevel >= Colored && !m_color.isValid())
m_color = QColor(Qt::white);//Hidden default, but different from unset
diff --git a/src/quick/particles/qquickimageparticle_p.h b/src/quick/particles/qquickimageparticle_p.h
index 401f4609b0..dca524bcab 100644
--- a/src/quick/particles/qquickimageparticle_p.h
+++ b/src/quick/particles/qquickimageparticle_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickitemparticle.cpp b/src/quick/particles/qquickitemparticle.cpp
index 571ca7f8a5..91ef06fcb2 100644
--- a/src/quick/particles/qquickitemparticle.cpp
+++ b/src/quick/particles/qquickitemparticle.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickitemparticle_p.h b/src/quick/particles/qquickitemparticle_p.h
index d02659889e..c7b8a2661e 100644
--- a/src/quick/particles/qquickitemparticle_p.h
+++ b/src/quick/particles/qquickitemparticle_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicklineextruder.cpp b/src/quick/particles/qquicklineextruder.cpp
index c98ce8d76b..f555de3f72 100644
--- a/src/quick/particles/qquicklineextruder.cpp
+++ b/src/quick/particles/qquicklineextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include "qquicklineextruder_p.h"
+#include <stdlib.h>
#include <cmath>
/*!
diff --git a/src/quick/particles/qquicklineextruder_p.h b/src/quick/particles/qquicklineextruder_p.h
index 1f65f8d808..6f2b2493a6 100644
--- a/src/quick/particles/qquicklineextruder_p.h
+++ b/src/quick/particles/qquicklineextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickmaskextruder.cpp b/src/quick/particles/qquickmaskextruder.cpp
index 5c27cc7678..50b71749c0 100644
--- a/src/quick/particles/qquickmaskextruder.cpp
+++ b/src/quick/particles/qquickmaskextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickmaskextruder_p.h b/src/quick/particles/qquickmaskextruder_p.h
index 94b30720c1..8b6c3f0b2d 100644
--- a/src/quick/particles/qquickmaskextruder_p.h
+++ b/src/quick/particles/qquickmaskextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleaffector.cpp b/src/quick/particles/qquickparticleaffector.cpp
index 6a5a4f3304..0005af86af 100644
--- a/src/quick/particles/qquickparticleaffector.cpp
+++ b/src/quick/particles/qquickparticleaffector.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleaffector_p.h b/src/quick/particles/qquickparticleaffector_p.h
index b5126fb0db..4147488f87 100644
--- a/src/quick/particles/qquickparticleaffector_p.h
+++ b/src/quick/particles/qquickparticleaffector_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleemitter.cpp b/src/quick/particles/qquickparticleemitter.cpp
index 1625f1498a..0f7f3817f2 100644
--- a/src/quick/particles/qquickparticleemitter.cpp
+++ b/src/quick/particles/qquickparticleemitter.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleemitter_p.h b/src/quick/particles/qquickparticleemitter_p.h
index bb010a13e9..70adcff34c 100644
--- a/src/quick/particles/qquickparticleemitter_p.h
+++ b/src/quick/particles/qquickparticleemitter_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticleextruder.cpp b/src/quick/particles/qquickparticleextruder.cpp
index f5605ef4d4..279f7c05f3 100644
--- a/src/quick/particles/qquickparticleextruder.cpp
+++ b/src/quick/particles/qquickparticleextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qquickparticleextruder_p.h"
+#include <stdlib.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/particles/qquickparticleextruder_p.h b/src/quick/particles/qquickparticleextruder_p.h
index da59bca044..e24950e4e8 100644
--- a/src/quick/particles/qquickparticleextruder_p.h
+++ b/src/quick/particles/qquickparticleextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlegroup.cpp b/src/quick/particles/qquickparticlegroup.cpp
index c4b230f5e9..9a165074a1 100644
--- a/src/quick/particles/qquickparticlegroup.cpp
+++ b/src/quick/particles/qquickparticlegroup.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlegroup_p.h b/src/quick/particles/qquickparticlegroup_p.h
index 774eb8df86..8889187558 100644
--- a/src/quick/particles/qquickparticlegroup_p.h
+++ b/src/quick/particles/qquickparticlegroup_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlepainter.cpp b/src/quick/particles/qquickparticlepainter.cpp
index b9f745edd8..f46f2f2235 100644
--- a/src/quick/particles/qquickparticlepainter.cpp
+++ b/src/quick/particles/qquickparticlepainter.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlepainter_p.h b/src/quick/particles/qquickparticlepainter_p.h
index ffa80d73dd..ebe76d98ea 100644
--- a/src/quick/particles/qquickparticlepainter_p.h
+++ b/src/quick/particles/qquickparticlepainter_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlesmodule.cpp b/src/quick/particles/qquickparticlesmodule.cpp
index f9b45f960e..e83cde3cd1 100644
--- a/src/quick/particles/qquickparticlesmodule.cpp
+++ b/src/quick/particles/qquickparticlesmodule.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlesmodule_p.h b/src/quick/particles/qquickparticlesmodule_p.h
index 6d16f00c15..b7cf09919e 100644
--- a/src/quick/particles/qquickparticlesmodule_p.h
+++ b/src/quick/particles/qquickparticlesmodule_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlesystem.cpp b/src/quick/particles/qquickparticlesystem.cpp
index 6dc6d21812..4fd6108f2f 100644
--- a/src/quick/particles/qquickparticlesystem.cpp
+++ b/src/quick/particles/qquickparticlesystem.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickparticlesystem_p.h b/src/quick/particles/qquickparticlesystem_p.h
index 387219f720..f70cc5af94 100644
--- a/src/quick/particles/qquickparticlesystem_p.h
+++ b/src/quick/particles/qquickparticlesystem_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickpointattractor.cpp b/src/quick/particles/qquickpointattractor.cpp
index 3772e2d050..7cb8c32671 100644
--- a/src/quick/particles/qquickpointattractor.cpp
+++ b/src/quick/particles/qquickpointattractor.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickpointattractor_p.h b/src/quick/particles/qquickpointattractor_p.h
index 30a666d196..85b7a9aa30 100644
--- a/src/quick/particles/qquickpointattractor_p.h
+++ b/src/quick/particles/qquickpointattractor_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickpointdirection.cpp b/src/quick/particles/qquickpointdirection.cpp
index 79c3365f86..e35eb4854c 100644
--- a/src/quick/particles/qquickpointdirection.cpp
+++ b/src/quick/particles/qquickpointdirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qquickpointdirection_p.h"
+#include <stdlib.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/particles/qquickpointdirection_p.h b/src/quick/particles/qquickpointdirection_p.h
index e66014653f..7b18e6d8d7 100644
--- a/src/quick/particles/qquickpointdirection_p.h
+++ b/src/quick/particles/qquickpointdirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickrectangleextruder.cpp b/src/quick/particles/qquickrectangleextruder.cpp
index 777d0f66f0..ad2207ca9a 100644
--- a/src/quick/particles/qquickrectangleextruder.cpp
+++ b/src/quick/particles/qquickrectangleextruder.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qquickrectangleextruder_p.h"
+#include <stdlib.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/particles/qquickrectangleextruder_p.h b/src/quick/particles/qquickrectangleextruder_p.h
index 055058c1be..1d4f8cc439 100644
--- a/src/quick/particles/qquickrectangleextruder_p.h
+++ b/src/quick/particles/qquickrectangleextruder_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickspritegoal.cpp b/src/quick/particles/qquickspritegoal.cpp
index 4f9518d97e..95d913cafa 100644
--- a/src/quick/particles/qquickspritegoal.cpp
+++ b/src/quick/particles/qquickspritegoal.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickspritegoal_p.h b/src/quick/particles/qquickspritegoal_p.h
index 44b022ffee..2b6b4f28fc 100644
--- a/src/quick/particles/qquickspritegoal_p.h
+++ b/src/quick/particles/qquickspritegoal_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicktargetdirection.cpp b/src/quick/particles/qquicktargetdirection.cpp
index 3f24a252d9..695684dfde 100644
--- a/src/quick/particles/qquicktargetdirection.cpp
+++ b/src/quick/particles/qquicktargetdirection.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicktargetdirection_p.h b/src/quick/particles/qquicktargetdirection_p.h
index cc5b65e66f..0e0e942ca8 100644
--- a/src/quick/particles/qquicktargetdirection_p.h
+++ b/src/quick/particles/qquicktargetdirection_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicktrailemitter.cpp b/src/quick/particles/qquicktrailemitter.cpp
index e5317567fe..32f8763599 100644
--- a/src/quick/particles/qquicktrailemitter.cpp
+++ b/src/quick/particles/qquicktrailemitter.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquicktrailemitter_p.h b/src/quick/particles/qquicktrailemitter_p.h
index f68dd05441..0b63a444ec 100644
--- a/src/quick/particles/qquicktrailemitter_p.h
+++ b/src/quick/particles/qquicktrailemitter_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickturbulence.cpp b/src/quick/particles/qquickturbulence.cpp
index db77e8d328..18ecc6a4cd 100644
--- a/src/quick/particles/qquickturbulence.cpp
+++ b/src/quick/particles/qquickturbulence.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickturbulence_p.h b/src/quick/particles/qquickturbulence_p.h
index f453140cd2..cd5535c387 100644
--- a/src/quick/particles/qquickturbulence_p.h
+++ b/src/quick/particles/qquickturbulence_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickv8particledata.cpp b/src/quick/particles/qquickv8particledata.cpp
index 3a387d8f01..8e50e41091 100644
--- a/src/quick/particles/qquickv8particledata.cpp
+++ b/src/quick/particles/qquickv8particledata.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickv8particledata_p.h b/src/quick/particles/qquickv8particledata_p.h
index 9b4a4435cc..21ec6458c1 100644
--- a/src/quick/particles/qquickv8particledata_p.h
+++ b/src/quick/particles/qquickv8particledata_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickwander.cpp b/src/quick/particles/qquickwander.cpp
index ec86323e53..3e7cf33a64 100644
--- a/src/quick/particles/qquickwander.cpp
+++ b/src/quick/particles/qquickwander.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/particles/qquickwander_p.h b/src/quick/particles/qquickwander_p.h
index d71e55dd5f..bb418f7912 100644
--- a/src/quick/particles/qquickwander_p.h
+++ b/src/quick/particles/qquickwander_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQuick module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index b9eec27e82..5c14bd5bc7 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -777,9 +777,9 @@ QSGClipNode::~QSGClipNode()
Sets whether this clip node has a rectangular clip to \a rectHint.
This is an optimization hint which means that the renderer can
- use scissoring instead of stencil, which is significnatly faster.
+ use scissoring instead of stencil, which is significantly faster.
- When this hint is and it is applicable, the clip region will be
+ When this hint is set and it is applicable, the clip region will be
generated from clipRect() rather than geometry().
*/
@@ -791,7 +791,7 @@ void QSGClipNode::setIsRectangular(bool rectHint)
/*!
- \fn void QSGClipNode::clipRect() const
+ \fn QRectF QSGClipNode::clipRect() const
Returns the clip rect of this node.
*/
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.cpp b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
index 0697fbe630..ee9fd9fbbb 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode_p.h b/src/quick/scenegraph/coreapi/qsgrendernode_p.h
index a2f2be828e..45636cc796 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrendernode_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index dcb1e5b8be..92045c55f4 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -45,6 +45,7 @@
#include <QtQuick/private/qsgdistancefieldutil_p.h>
#include <QtQuick/private/qsgdistancefieldglyphnode_p.h>
#include <private/qrawfont_p.h>
+#include <private/qdistancefield_p.h>
#include <QtGui/qguiapplication.h>
#include <qdir.h>
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index e38a4eef6a..10276c17f8 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -238,7 +238,7 @@ void QSGContext::renderNextFrame(QSGRenderer *renderer, GLuint fboId)
*/
QSGRectangleNode *QSGContext::createRectangleNode()
{
- return new QSGDefaultRectangleNode(this);
+ return new QSGDefaultRectangleNode;
}
/*!
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index d5f84553ba..b8a66fd0c0 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -71,7 +71,6 @@ struct QSGAdaptionPluginData
~QSGAdaptionPluginData()
{
- delete factory;
}
bool tried;
@@ -102,15 +101,15 @@ QSGAdaptionPluginData *contextFactory()
if (!device.isEmpty()) {
plugin->factory = qobject_cast<QSGContextFactoryInterface*>(loader()->instance(device));
plugin->deviceName = device;
- }
#ifndef QT_NO_DEBUG
- if (!device.isEmpty()) {
- qWarning("Could not create scene graph context for device '%s'"
- " - check that plugins are installed correctly in %s",
- qPrintable(device),
- qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath)));
- }
+ if (!plugin->factory) {
+ qWarning("Could not create scene graph context for device '%s'"
+ " - check that plugins are installed correctly in %s",
+ qPrintable(device),
+ qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath)));
+ }
#endif
+ }
#endif // QT_NO_LIBRARY || QT_NO_SETTINGS
}
diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h
index fa90873dc6..d0d8ea143b 100644
--- a/src/quick/scenegraph/qsgcontextplugin_p.h
+++ b/src/quick/scenegraph/qsgcontextplugin_p.h
@@ -62,7 +62,7 @@ struct Q_QUICK_EXPORT QSGContextFactoryInterface : public QFactoryInterface
};
#define QSGContextFactoryInterface_iid \
- "com.trolltech.Qt.QSGContextFactoryInterface"
+ "org.qt-project.Qt.QSGContextFactoryInterface"
Q_DECLARE_INTERFACE(QSGContextFactoryInterface, QSGContextFactoryInterface_iid)
class Q_QUICK_EXPORT QSGContextPlugin : public QObject, public QSGContextFactoryInterface
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index 73dcad6a47..05d076ec1e 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -41,6 +41,7 @@
#include "qsgdefaultdistancefieldglyphcache_p.h"
+#include <QtGui/private/qdistancefield_p.h>
#include <QtQuick/private/qsgdistancefieldutil_p.h>
#include <qopenglfunctions.h>
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
index 334bd4346f..18cac36550 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
@@ -54,7 +54,7 @@
QT_BEGIN_NAMESPACE
-QSGDefaultRectangleNode::QSGDefaultRectangleNode(QSGContext *context)
+QSGDefaultRectangleNode::QSGDefaultRectangleNode()
: m_border(0)
, m_radius(0)
, m_pen_width(0)
@@ -62,7 +62,6 @@ QSGDefaultRectangleNode::QSGDefaultRectangleNode(QSGContext *context)
, m_gradient_is_opaque(true)
, m_dirty_geometry(false)
, m_default_geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
- , m_context(context)
{
setGeometry(&m_default_geometry);
setMaterial(&m_fill_material);
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
index 2a0aa05b90..faa2b6a43c 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
@@ -57,7 +57,7 @@ class QSGContext;
class QSGDefaultRectangleNode : public QSGRectangleNode
{
public:
- QSGDefaultRectangleNode(QSGContext *context);
+ QSGDefaultRectangleNode();
~QSGDefaultRectangleNode();
virtual void setRect(const QRectF &rect);
@@ -95,8 +95,6 @@ private:
uint m_material_type : 2; // Only goes up to 3
QSGGeometry m_default_geometry;
-
- QSGContext *m_context;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index 30b4a2f9b8..c66b82c16e 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -233,7 +233,11 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const
}
QRgb c1 = m_color.rgba();
QRgb c2 = other->m_color.rgba();
- return int(c2 < c1) - int(c1 < c2);
+ if (c1 != c2)
+ return int(c2 < c1) - int(c1 < c2);
+ int t0 = m_texture ? m_texture->textureId : -1;
+ int t1 = other->m_texture ? other->m_texture->textureId : -1;
+ return t0 - t1;
}
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
index 799d354400..46bd141909 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
@@ -90,7 +90,7 @@ QSGSharedDistanceFieldGlyphCache::QSGSharedDistanceFieldGlyphCache(const QByteAr
this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
Qt::DirectConnection);
connect(sharedGraphicsCache, SIGNAL(itemsUpdated(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
- this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
+ this, SLOT(reportItemsUpdated(QByteArray,void*,QSize,QVector<quint32>,QVector<QPoint>)),
Qt::DirectConnection);
connect(sharedGraphicsCache, SIGNAL(itemsInvalidated(QByteArray,QVector<quint32>)),
this, SLOT(reportItemsInvalidated(QByteArray,QVector<quint32>)),
@@ -542,9 +542,38 @@ void QSGSharedDistanceFieldGlyphCache::processPendingGlyphs()
}
void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &cacheId,
- void *bufferId, const QSize &bufferSize,
- const QVector<quint32> &itemIds,
- const QVector<QPoint> &positions)
+ void *bufferId,
+ const QSize &bufferSize,
+ const QVector<quint32> &itemIds,
+ const QVector<QPoint> &positions)
+{
+ bool requestedItemsInList = false;
+ {
+ QMutexLocker locker(&m_pendingGlyphsMutex);
+ if (m_cacheId != cacheId)
+ return;
+
+#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG)
+ qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsAvailable() called for %s (%d glyphs, bufferSize: %dx%d)",
+ cacheId.constData(), itemIds.size(), bufferSize.width(), bufferSize.height());
+#endif
+
+ for (int i=0; i<itemIds.size(); ++i) {
+ if (m_requestedGlyphsThatHaveNotBeenReturned.contains(itemIds.at(i))) {
+ requestedItemsInList = true;
+ break;
+ }
+ }
+ }
+
+ if (requestedItemsInList)
+ reportItemsUpdated(cacheId, bufferId, bufferSize, itemIds, positions);
+}
+
+void QSGSharedDistanceFieldGlyphCache::reportItemsUpdated(const QByteArray &cacheId,
+ void *bufferId, const QSize &bufferSize,
+ const QVector<quint32> &itemIds,
+ const QVector<QPoint> &positions)
{
{
QMutexLocker locker(&m_pendingGlyphsMutex);
@@ -554,7 +583,7 @@ void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &ca
Q_ASSERT(itemIds.size() == positions.size());
#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG)
- qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsAvailable() called for %s (%d glyphs, bufferSize: %dx%d)",
+ qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsUpdated() called for %s (%d glyphs, bufferSize: %dx%d)",
cacheId.constData(), itemIds.size(), bufferSize.width(), bufferSize.height());
#endif
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
index 851f72d6a7..3052f20813 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h
@@ -78,6 +78,8 @@ private Q_SLOTS:
void reportItemsAvailable(const QByteArray &cacheId,
void *bufferId, const QSize &bufferSize,
const QVector<quint32> &itemIds, const QVector<QPoint> &positions);
+ void reportItemsUpdated(const QByteArray &cacheId, void *bufferId, const QSize &bufferSize,
+ const QVector<quint32> &itemIds, const QVector<QPoint> &positions);
void reportItemsInvalidated(const QByteArray &cacheId, const QVector<quint32> &itemIds);
private:
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index dae4a3b8a8..f5fa18f87a 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -64,7 +64,6 @@ HEADERS += \
$$PWD/qsgdefaultimagenode_p.h \
$$PWD/qsgdefaultrectanglenode_p.h \
$$PWD/qsgflashnode_p.h \
- $$PWD/qsgpathsimplifier_p.h \
$$PWD/qsgshareddistancefieldglyphcache_p.h
SOURCES += \
@@ -79,7 +78,6 @@ SOURCES += \
$$PWD/qsgdefaultimagenode.cpp \
$$PWD/qsgdefaultrectanglenode.cpp \
$$PWD/qsgflashnode.cpp \
- $$PWD/qsgpathsimplifier.cpp \
$$PWD/qsgshareddistancefieldglyphcache.cpp
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
index caca610fe2..76fdf97d80 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
@@ -41,8 +41,6 @@
#include "qsgdistancefieldutil_p.h"
-#include <qmath.h>
-#include <private/qsgpathsimplifier_p.h>
#include <private/qsgadaptationlayer_p.h>
#include <QtGui/private/qopenglengineshadersource_p.h>
#include <QtQuick/private/qsgcontext_p.h>
@@ -64,718 +62,6 @@ static float defaultAntialiasingSpreadFunc(float glyphScale)
return range / glyphScale;
}
-namespace
-{
- enum FillHDir
- {
- LeftToRight,
- RightToLeft
- };
-
- enum FillVDir
- {
- TopDown,
- BottomUp
- };
-
- enum FillClip
- {
- NoClip,
- Clip
- };
-}
-
-template <FillClip clip, FillHDir dir>
-inline void fillLine(qint32 *, int, int, int, qint32, qint32)
-{
-}
-
-template <>
-inline void fillLine<Clip, LeftToRight>(qint32 *line, int width, int lx, int rx, qint32 d, qint32 dd)
-{
- int fromX = qMax(0, lx >> 8);
- int toX = qMin(width, rx >> 8);
- int x = toX - fromX;
- if (x <= 0)
- return;
- qint32 val = d + (((fromX << 8) + 0xff - lx) * dd >> 8);
- line += fromX;
- do {
- *line = abs(val) < abs(*line) ? val : *line;
- val += dd;
- ++line;
- } while (--x);
-}
-
-template <>
-inline void fillLine<Clip, RightToLeft>(qint32 *line, int width, int lx, int rx, qint32 d, qint32 dd)
-{
- int fromX = qMax(0, lx >> 8);
- int toX = qMin(width, rx >> 8);
- int x = toX - fromX;
- if (x <= 0)
- return;
- qint32 val = d + (((toX << 8) + 0xff - rx) * dd >> 8);
- line += toX;
- do {
- val -= dd;
- --line;
- *line = abs(val) < abs(*line) ? val : *line;
- } while (--x);
-}
-
-template <>
-inline void fillLine<NoClip, LeftToRight>(qint32 *line, int, int lx, int rx, qint32 d, qint32 dd)
-{
- int fromX = lx >> 8;
- int toX = rx >> 8;
- int x = toX - fromX;
- if (x <= 0)
- return;
- qint32 val = d + ((~lx & 0xff) * dd >> 8);
- line += fromX;
- do {
- *line = abs(val) < abs(*line) ? val : *line;
- val += dd;
- ++line;
- } while (--x);
-}
-
-template <>
-inline void fillLine<NoClip, RightToLeft>(qint32 *line, int, int lx, int rx, qint32 d, qint32 dd)
-{
- int fromX = lx >> 8;
- int toX = rx >> 8;
- int x = toX - fromX;
- if (x <= 0)
- return;
- qint32 val = d + ((~rx & 0xff) * dd >> 8);
- line += toX;
- do {
- val -= dd;
- --line;
- *line = abs(val) < abs(*line) ? val : *line;
- } while (--x);
-}
-
-template <FillClip clip, FillVDir vDir, FillHDir hDir>
-inline void fillLines(qint32 *bits, int width, int height, int upperY, int lowerY,
- int &lx, int ldx, int &rx, int rdx, qint32 &d, qint32 ddy, qint32 ddx)
-{
- Q_UNUSED(height);
- Q_ASSERT(upperY < lowerY);
- int y = lowerY - upperY;
- if (vDir == TopDown) {
- qint32 *line = bits + upperY * width;
- do {
- fillLine<clip, hDir>(line, width, lx, rx, d, ddx);
- lx += ldx;
- d += ddy;
- rx += rdx;
- line += width;
- } while (--y);
- } else {
- qint32 *line = bits + lowerY * width;
- do {
- lx -= ldx;
- d -= ddy;
- rx -= rdx;
- line -= width;
- fillLine<clip, hDir>(line, width, lx, rx, d, ddx);
- } while (--y);
- }
-}
-
-template <FillClip clip>
-void drawTriangle(qint32 *bits, int width, int height, const QPoint *center,
- const QPoint *v1, const QPoint *v2, qint32 value)
-{
- const int y1 = clip == Clip ? qBound(0, v1->y() >> 8, height) : v1->y() >> 8;
- const int y2 = clip == Clip ? qBound(0, v2->y() >> 8, height) : v2->y() >> 8;
- const int yC = clip == Clip ? qBound(0, center->y() >> 8, height) : center->y() >> 8;
-
- const int v1Frac = clip == Clip ? (y1 << 8) + 0xff - v1->y() : ~v2->y() & 0xff;
- const int v2Frac = clip == Clip ? (y2 << 8) + 0xff - v2->y() : ~v1->y() & 0xff;
- const int centerFrac = clip == Clip ? (yC << 8) + 0xff - center->y() : ~center->y() & 0xff;
-
- int dx1 = 0, x1 = 0, dx2 = 0, x2 = 0;
- qint32 dd1, d1, dd2, d2;
- if (v1->y() != center->y()) {
- dx1 = ((v1->x() - center->x()) << 8) / (v1->y() - center->y());
- x1 = center->x() + centerFrac * (v1->x() - center->x()) / (v1->y() - center->y());
- }
- if (v2->y() != center->y()) {
- dx2 = ((v2->x() - center->x()) << 8) / (v2->y() - center->y());
- x2 = center->x() + centerFrac * (v2->x() - center->x()) / (v2->y() - center->y());
- }
-
- const qint32 div = (v2->x() - center->x()) * (v1->y() - center->y())
- - (v2->y() - center->y()) * (v1->x() - center->x());
- const qint32 dd = div ? qint32((qint64(value * (v1->y() - v2->y())) << 8) / div) : 0;
-
- if (y2 < yC) {
- if (y1 < yC) {
- // Center at the bottom.
- if (y2 < y1) {
- // y2 < y1 < yC
- // Long right edge.
- d1 = centerFrac * value / (v1->y() - center->y());
- dd1 = ((value << 8) / (v1->y() - center->y()));
- fillLines<clip, BottomUp, LeftToRight>(bits, width, height, y1, yC, x1, dx1,
- x2, dx2, d1, dd1, dd);
- dx1 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y());
- x1 = v1->x() + v1Frac * (v1->x() - v2->x()) / (v1->y() - v2->y());
- fillLines<clip, BottomUp, LeftToRight>(bits, width, height, y2, y1, x1, dx1,
- x2, dx2, value, 0, dd);
- } else {
- // y1 <= y2 < yC
- // Long left edge.
- d2 = centerFrac * value / (v2->y() - center->y());
- dd2 = ((value << 8) / (v2->y() - center->y()));
- fillLines<clip, BottomUp, RightToLeft>(bits, width, height, y2, yC, x1, dx1,
- x2, dx2, d2, dd2, dd);
- if (y1 != y2) {
- dx2 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y());
- x2 = v2->x() + v2Frac * (v1->x() - v2->x()) / (v1->y() - v2->y());
- fillLines<clip, BottomUp, RightToLeft>(bits, width, height, y1, y2, x1, dx1,
- x2, dx2, value, 0, dd);
- }
- }
- } else {
- // y2 < yC <= y1
- // Center to the right.
- int dx = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y());
- int xUp, xDn;
- xUp = xDn = v2->x() + (clip == Clip ? (yC << 8) + 0xff - v2->y()
- : (center->y() | 0xff) - v2->y())
- * (v1->x() - v2->x()) / (v1->y() - v2->y());
- fillLines<clip, BottomUp, LeftToRight>(bits, width, height, y2, yC, xUp, dx,
- x2, dx2, value, 0, dd);
- if (yC != y1)
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, yC, y1, xDn, dx,
- x1, dx1, value, 0, dd);
- }
- } else {
- if (y1 < yC) {
- // y1 < yC <= y2
- // Center to the left.
- int dx = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y());
- int xUp, xDn;
- xUp = xDn = v1->x() + (clip == Clip ? (yC << 8) + 0xff - v1->y()
- : (center->y() | 0xff) - v1->y())
- * (v1->x() - v2->x()) / (v1->y() - v2->y());
- fillLines<clip, BottomUp, RightToLeft>(bits, width, height, y1, yC, x1, dx1,
- xUp, dx, value, 0, dd);
- if (yC != y2)
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, yC, y2, x2, dx2,
- xDn, dx, value, 0, dd);
- } else {
- // Center at the top.
- if (y2 < y1) {
- // yC <= y2 < y1
- // Long right edge.
- if (yC != y2) {
- d2 = centerFrac * value / (v2->y() - center->y());
- dd2 = ((value << 8) / (v2->y() - center->y()));
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, yC, y2, x2, dx2,
- x1, dx1, d2, dd2, dd);
- }
- dx2 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y());
- x2 = v2->x() + v2Frac * (v1->x() - v2->x()) / (v1->y() - v2->y());
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, y2, y1, x2, dx2,
- x1, dx1, value, 0, dd);
- } else {
- // Long left edge.
- // yC <= y1 <= y2
- if (yC != y1) {
- d1 = centerFrac * value / (v1->y() - center->y());
- dd1 = ((value << 8) / (v1->y() - center->y()));
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, yC, y1, x2, dx2,
- x1, dx1, d1, dd1, dd);
- }
- if (y1 != y2) {
- dx1 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y());
- x1 = v1->x() + v1Frac * (v1->x() - v2->x()) / (v1->y() - v2->y());
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, y1, y2, x2, dx2,
- x1, dx1, value, 0, dd);
- }
- }
- }
- }
-}
-
-template <FillClip clip>
-void drawRectangle(qint32 *bits, int width, int height,
- const QPoint *int1, const QPoint *center1, const QPoint *ext1,
- const QPoint *int2, const QPoint *center2, const QPoint *ext2,
- qint32 extValue)
-{
- if (center1->y() > center2->y()) {
- qSwap(center1, center2);
- qSwap(int1, ext2);
- qSwap(ext1, int2);
- extValue = -extValue;
- }
-
- Q_ASSERT(ext1->x() - center1->x() == center1->x() - int1->x());
- Q_ASSERT(ext1->y() - center1->y() == center1->y() - int1->y());
- Q_ASSERT(ext2->x() - center2->x() == center2->x() - int2->x());
- Q_ASSERT(ext2->y() - center2->y() == center2->y() - int2->y());
-
- const int yc1 = clip == Clip ? qBound(0, center1->y() >> 8, height) : center1->y() >> 8;
- const int yc2 = clip == Clip ? qBound(0, center2->y() >> 8, height) : center2->y() >> 8;
- const int yi1 = clip == Clip ? qBound(0, int1->y() >> 8, height) : int1->y() >> 8;
- const int yi2 = clip == Clip ? qBound(0, int2->y() >> 8, height) : int2->y() >> 8;
- const int ye1 = clip == Clip ? qBound(0, ext1->y() >> 8, height) : ext1->y() >> 8;
- const int ye2 = clip == Clip ? qBound(0, ext2->y() >> 8, height) : ext2->y() >> 8;
-
- const int center1Frac = clip == Clip ? (yc1 << 8) + 0xff - center1->y() : ~center1->y() & 0xff;
- const int center2Frac = clip == Clip ? (yc2 << 8) + 0xff - center2->y() : ~center2->y() & 0xff;
- const int int1Frac = clip == Clip ? (yi1 << 8) + 0xff - int1->y() : ~int1->y() & 0xff;
- const int ext1Frac = clip == Clip ? (ye1 << 8) + 0xff - ext1->y() : ~ext1->y() & 0xff;
-
- int dxC = 0, dxE = 0; // cap slope, edge slope
- qint32 ddC = 0;
- if (ext1->y() != int1->y()) {
- dxC = ((ext1->x() - int1->x()) << 8) / (ext1->y() - int1->y());
- ddC = (extValue << 9) / (ext1->y() - int1->y());
- }
- if (ext1->y() != ext2->y())
- dxE = ((ext1->x() - ext2->x()) << 8) / (ext1->y() - ext2->y());
-
- const qint32 div = (ext1->x() - int1->x()) * (ext2->y() - int1->y())
- - (ext1->y() - int1->y()) * (ext2->x() - int1->x());
- const qint32 dd = div ? qint32((qint64(extValue * (ext2->y() - ext1->y())) << 9) / div) : 0;
-
- int xe1, xe2, xc1, xc2;
- qint32 d;
-
- qint32 intValue = -extValue;
-
- if (center2->x() < center1->x()) {
- // Leaning to the right. '/'
- if (int1->y() < ext2->y()) {
- // Mostly vertical.
- Q_ASSERT(ext1->y() != ext2->y());
- xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- if (ye1 != yi1) {
- xc2 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc2 += (ye1 - yc1) * dxC;
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye1, yi1, xe1, dxE,
- xc2, dxC, extValue, 0, dd);
- }
- if (yi1 != ye2)
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, yi1, ye2, xe1, dxE,
- xe2, dxE, extValue, 0, dd);
- if (ye2 != yi2) {
- xc1 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc1 += (ye2 - yc2) * dxC;
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, ye2, yi2, xc1, dxC,
- xe2, dxE, intValue, 0, dd);
- }
- } else {
- // Mostly horizontal.
- Q_ASSERT(ext1->y() != int1->y());
- xc1 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc2 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc1 += (ye2 - yc2) * dxC;
- xc2 += (ye1 - yc1) * dxC;
- if (ye1 != ye2) {
- xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye1, ye2, xe1, dxE,
- xc2, dxC, extValue, 0, dd);
- }
- if (ye2 != yi1) {
- d = (clip == Clip ? (ye2 << 8) + 0xff - center2->y()
- : (ext2->y() | 0xff) - center2->y())
- * 2 * extValue / (ext1->y() - int1->y());
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye2, yi1, xc1, dxC,
- xc2, dxC, d, ddC, dd);
- }
- if (yi1 != yi2) {
- xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi1, yi2, xc1, dxC,
- xe2, dxE, intValue, 0, dd);
- }
- }
- } else {
- // Leaning to the left. '\'
- if (ext1->y() < int2->y()) {
- // Mostly vertical.
- Q_ASSERT(ext1->y() != ext2->y());
- xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- if (yi1 != ye1) {
- xc1 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc1 += (yi1 - yc1) * dxC;
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi1, ye1, xc1, dxC,
- xe2, dxE, intValue, 0, dd);
- }
- if (ye1 != yi2)
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, ye1, yi2, xe1, dxE,
- xe2, dxE, intValue, 0, dd);
- if (yi2 != ye2) {
- xc2 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc2 += (yi2 - yc2) * dxC;
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, yi2, ye2, xe1, dxE,
- xc2, dxC, extValue, 0, dd);
- }
- } else {
- // Mostly horizontal.
- Q_ASSERT(ext1->y() != int1->y());
- xc1 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc2 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y());
- xc1 += (yi1 - yc1) * dxC;
- xc2 += (yi2 - yc2) * dxC;
- if (yi1 != yi2) {
- xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi1, yi2, xc1, dxC,
- xe2, dxE, intValue, 0, dd);
- }
- if (yi2 != ye1) {
- d = (clip == Clip ? (yi2 << 8) + 0xff - center2->y()
- : (int2->y() | 0xff) - center2->y())
- * 2 * extValue / (ext1->y() - int1->y());
- fillLines<clip, TopDown, RightToLeft>(bits, width, height, yi2, ye1, xc1, dxC,
- xc2, dxC, d, ddC, dd);
- }
- if (ye1 != ye2) {
- xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y());
- fillLines<clip, TopDown, LeftToRight>(bits, width, height, ye1, ye2, xe1, dxE,
- xc2, dxC, extValue, 0, dd);
- }
- }
- }
-}
-
-static void drawPolygons(qint32 *bits, int width, int height, const QPoint *vertices,
- const quint32 *indices, int indexCount, qint32 value)
-{
- Q_ASSERT(indexCount != 0);
- Q_ASSERT(height <= 128);
- QVarLengthArray<quint8, 16> scans[128];
- int first = 0;
- for (int i = 1; i < indexCount; ++i) {
- quint32 idx1 = indices[i - 1];
- quint32 idx2 = indices[i];
- Q_ASSERT(idx1 != quint32(-1));
- if (idx2 == quint32(-1)) {
- idx2 = indices[first];
- Q_ASSERT(idx2 != quint32(-1));
- first = ++i;
- }
- const QPoint *v1 = &vertices[idx1];
- const QPoint *v2 = &vertices[idx2];
- if (v2->y() < v1->y())
- qSwap(v1, v2);
- int fromY = qMax(0, v1->y() >> 8);
- int toY = qMin(height, v2->y() >> 8);
- if (fromY >= toY)
- continue;
- int dx = ((v2->x() - v1->x()) << 8) / (v2->y() - v1->y());
- int x = v1->x() + ((fromY << 8) + 0xff - v1->y()) * (v2->x() - v1->x()) / (v2->y() - v1->y());
- for (int y = fromY; y < toY; ++y) {
- quint32 c = quint32(x >> 8);
- if (c < quint32(width))
- scans[y].append(quint8(c));
- x += dx;
- }
- }
- for (int i = 0; i < height; ++i) {
- quint8 *scanline = scans[i].data();
- int size = scans[i].size();
- for (int j = 1; j < size; ++j) {
- int k = j;
- quint8 value = scanline[k];
- for (; k != 0 && value < scanline[k - 1]; --k)
- scanline[k] = scanline[k - 1];
- scanline[k] = value;
- }
- qint32 *line = bits + i * width;
- int j = 0;
- for (; j + 1 < size; j += 2) {
- for (quint8 x = scanline[j]; x < scanline[j + 1]; ++x)
- line[x] = value;
- }
- if (j < size) {
- for (int x = scanline[j]; x < width; ++x)
- line[x] = value;
- }
- }
-}
-
-static QImage makeDistanceField(int imgSize, const QPainterPath &path, int dfScale, int offs)
-{
- QImage image(imgSize, imgSize, QImage::Format_Indexed8);
-
- if (path.isEmpty()) {
- image.fill(0);
- return image;
- }
-
- QTransform transform;
- transform.translate(offs, offs);
- transform.scale(qreal(1) / dfScale, qreal(1) / dfScale);
-
- QDataBuffer<quint32> pathIndices(0);
- QDataBuffer<QPoint> pathVertices(0);
- qSimplifyPath(path, pathVertices, pathIndices, transform);
-
- const qint32 interiorColor = -0x7f80; // 8:8 signed format, -127.5
- const qint32 exteriorColor = 0x7f80; // 8:8 signed format, 127.5
-
- QScopedArrayPointer<qint32> bits(new qint32[imgSize * imgSize]);
- for (int i = 0; i < imgSize * imgSize; ++i)
- bits[i] = exteriorColor;
-
- const qreal angleStep = qreal(15 * 3.141592653589793238 / 180);
- const QPoint rotation(qRound(cos(angleStep) * 0x4000),
- qRound(sin(angleStep) * 0x4000)); // 2:14 signed
-
- const quint32 *indices = pathIndices.data();
- QVarLengthArray<QPoint> normals;
- QVarLengthArray<QPoint> vertices;
- QVarLengthArray<bool> isConvex;
- QVarLengthArray<bool> needsClipping;
-
- drawPolygons(bits.data(), imgSize, imgSize, pathVertices.data(), indices, pathIndices.size(),
- interiorColor);
-
- int index = 0;
-
- while (index < pathIndices.size()) {
- normals.clear();
- vertices.clear();
- needsClipping.clear();
-
- // Find end of polygon.
- int end = index;
- while (indices[end] != quint32(-1))
- ++end;
-
- // Calculate vertex normals.
- for (int next = index, prev = end - 1; next < end; prev = next++) {
- quint32 fromVertexIndex = indices[prev];
- quint32 toVertexIndex = indices[next];
-
- const QPoint &from = pathVertices.at(fromVertexIndex);
- const QPoint &to = pathVertices.at(toVertexIndex);
-
- QPoint n(to.y() - from.y(), from.x() - to.x());
- if (n.x() == 0 && n.y() == 0)
- continue;
- int scale = qRound((offs << 16) / sqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16
- n.rx() = n.x() * scale >> 8;
- n.ry() = n.y() * scale >> 8;
- normals.append(n);
- QPoint v(to.x() + 0x7f, to.y() + 0x7f);
- vertices.append(v);
- needsClipping.append((to.x() < offs << 8) || (to.x() >= (imgSize - offs) << 8)
- || (to.y() < offs << 8) || (to.y() >= (imgSize - offs) << 8));
- }
-
- isConvex.resize(normals.count());
- for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) {
- isConvex[prev] = normals.at(prev).x() * normals.at(next).y()
- - normals.at(prev).y() * normals.at(next).x() < 0;
- }
-
- // Draw quads.
- for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) {
- QPoint n = normals.at(next);
- QPoint intPrev = vertices.at(prev);
- QPoint extPrev = vertices.at(prev);
- QPoint intNext = vertices.at(next);
- QPoint extNext = vertices.at(next);
-
- extPrev.rx() -= n.x();
- extPrev.ry() -= n.y();
- intPrev.rx() += n.x();
- intPrev.ry() += n.y();
- extNext.rx() -= n.x();
- extNext.ry() -= n.y();
- intNext.rx() += n.x();
- intNext.ry() += n.y();
-
- if (needsClipping[prev] || needsClipping[next]) {
- drawRectangle<Clip>(bits.data(), imgSize, imgSize,
- &intPrev, &vertices.at(prev), &extPrev,
- &intNext, &vertices.at(next), &extNext,
- exteriorColor);
- } else {
- drawRectangle<NoClip>(bits.data(), imgSize, imgSize,
- &intPrev, &vertices.at(prev), &extPrev,
- &intNext, &vertices.at(next), &extNext,
- exteriorColor);
- }
-
- if (isConvex.at(prev)) {
- QPoint p = extPrev;
- if (needsClipping[prev]) {
- for (;;) {
- QPoint rn((n.x() * rotation.x() - n.y() * rotation.y()) >> 14,
- (n.y() * rotation.x() + n.x() * rotation.y()) >> 14);
- n = rn;
- if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() <= 0) {
- p.rx() = vertices.at(prev).x() - normals.at(prev).x();
- p.ry() = vertices.at(prev).y() - normals.at(prev).y();
- drawTriangle<Clip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &extPrev, &p, exteriorColor);
- break;
- }
-
- p.rx() = vertices.at(prev).x() - n.x();
- p.ry() = vertices.at(prev).y() - n.y();
- drawTriangle<Clip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &extPrev, &p, exteriorColor);
- extPrev = p;
- }
- } else {
- for (;;) {
- QPoint rn((n.x() * rotation.x() - n.y() * rotation.y()) >> 14,
- (n.y() * rotation.x() + n.x() * rotation.y()) >> 14);
- n = rn;
- if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() <= 0) {
- p.rx() = vertices.at(prev).x() - normals.at(prev).x();
- p.ry() = vertices.at(prev).y() - normals.at(prev).y();
- drawTriangle<NoClip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &extPrev, &p, exteriorColor);
- break;
- }
-
- p.rx() = vertices.at(prev).x() - n.x();
- p.ry() = vertices.at(prev).y() - n.y();
- drawTriangle<NoClip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &extPrev, &p, exteriorColor);
- extPrev = p;
- }
- }
- } else {
- QPoint p = intPrev;
- if (needsClipping[prev]) {
- for (;;) {
- QPoint rn((n.x() * rotation.x() + n.y() * rotation.y()) >> 14,
- (n.y() * rotation.x() - n.x() * rotation.y()) >> 14);
- n = rn;
- if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() >= 0) {
- p.rx() = vertices.at(prev).x() + normals.at(prev).x();
- p.ry() = vertices.at(prev).y() + normals.at(prev).y();
- drawTriangle<Clip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &p, &intPrev, interiorColor);
- break;
- }
-
- p.rx() = vertices.at(prev).x() + n.x();
- p.ry() = vertices.at(prev).y() + n.y();
- drawTriangle<Clip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &p, &intPrev, interiorColor);
- intPrev = p;
- }
- } else {
- for (;;) {
- QPoint rn((n.x() * rotation.x() + n.y() * rotation.y()) >> 14,
- (n.y() * rotation.x() - n.x() * rotation.y()) >> 14);
- n = rn;
- if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() >= 0) {
- p.rx() = vertices.at(prev).x() + normals.at(prev).x();
- p.ry() = vertices.at(prev).y() + normals.at(prev).y();
- drawTriangle<NoClip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &p, &intPrev, interiorColor);
- break;
- }
-
- p.rx() = vertices.at(prev).x() + n.x();
- p.ry() = vertices.at(prev).y() + n.y();
- drawTriangle<NoClip>(bits.data(), imgSize, imgSize, &vertices.at(prev),
- &p, &intPrev, interiorColor);
- intPrev = p;
- }
- }
- }
- }
-
- index = end + 1;
- }
-
- const qint32 *inLine = bits.data();
- uchar *outLine = image.bits();
- int padding = image.bytesPerLine() - image.width();
- for (int y = 0; y < imgSize; ++y) {
- for (int x = 0; x < imgSize; ++x, ++inLine, ++outLine)
- *outLine = uchar((0x7f80 - *inLine) >> 8);
- outLine += padding;
- }
-
- return image;
-}
-
-bool qt_fontHasNarrowOutlines(const QRawFont &f)
-{
- QRawFont font = f;
- font.setPixelSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE);
- Q_ASSERT(font.isValid());
-
- QVector<quint32> glyphIndices = font.glyphIndexesForString(QLatin1String("O"));
- if (glyphIndices.size() < 1)
- return false;
-
- QImage im = font.alphaMapForGlyph(glyphIndices.at(0), QRawFont::PixelAntialiasing);
- if (im.isNull())
- return false;
-
- int minHThick = 999;
- int minVThick = 999;
-
- int thick = 0;
- bool in = false;
- int y = (im.height() + 1) / 2;
- for (int x = 0; x < im.width(); ++x) {
- int a = qAlpha(im.pixel(x, y));
- if (a > 127) {
- in = true;
- ++thick;
- } else if (in) {
- in = false;
- minHThick = qMin(minHThick, thick);
- thick = 0;
- }
- }
-
- thick = 0;
- in = false;
- int x = (im.width() + 1) / 2;
- for (int y = 0; y < im.height(); ++y) {
- int a = qAlpha(im.pixel(x, y));
- if (a > 127) {
- in = true;
- ++thick;
- } else if (in) {
- in = false;
- minVThick = qMin(minVThick, thick);
- thick = 0;
- }
- }
-
- return minHThick == 1 || minVThick == 1;
-}
-
-QImage qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution)
-{
- QRawFont renderFont = font;
- renderFont.setPixelSize(QT_DISTANCEFIELD_BASEFONTSIZE(doubleResolution) * QT_DISTANCEFIELD_SCALE(doubleResolution));
-
- QPainterPath path = renderFont.pathForGlyph(glyph);
- path.translate(-path.boundingRect().topLeft());
- path.setFillRule(Qt::WindingFill);
-
- QImage im = makeDistanceField(QT_DISTANCEFIELD_TILESIZE(doubleResolution),
- path,
- QT_DISTANCEFIELD_SCALE(doubleResolution),
- QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution));
- return im;
-}
-
QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager(QSGContext *c)
: sgCtx(c)
, m_threshold_func(defaultThresholdFunc)
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
index cf805e7ff6..49391a737c 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
@@ -48,33 +48,9 @@
QT_BEGIN_NAMESPACE
-#define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54
-#define QT_DISTANCEFIELD_DEFAULT_TILESIZE 64
-#define QT_DISTANCEFIELD_DEFAULT_SCALE 16
-#define QT_DISTANCEFIELD_DEFAULT_RADIUS 80
-#define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000
-
-#define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \
- QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE)
-#define QT_DISTANCEFIELD_TILESIZE(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_TILESIZE * 2 : \
- QT_DISTANCEFIELD_DEFAULT_TILESIZE)
-#define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \
- QT_DISTANCEFIELD_DEFAULT_SCALE)
-#define QT_DISTANCEFIELD_RADIUS(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_RADIUS / 2 : \
- QT_DISTANCEFIELD_DEFAULT_RADIUS)
-
-
typedef float (*ThresholdFunc)(float glyphScale);
typedef float (*AntialiasingSpreadFunc)(float glyphScale);
-bool qt_fontHasNarrowOutlines(const QRawFont &f);
-QImage qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution);
-
-
class QOpenGLShaderProgram;
class QSGDistanceFieldGlyphCache;
class QSGContext;
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index 5dd4dad6e4..24b92fa98f 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -497,6 +497,8 @@ void QSGPlainTexture::bind()
? m_image
: m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ updateBindOptions(m_dirty_bind_options);
+
#ifdef QT_OPENGL_ES
swizzleBGRAToRGBA(&tmp);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmp.constBits());
@@ -513,7 +515,6 @@ void QSGPlainTexture::bind()
m_texture_size = QSize(w, h);
m_texture_rect = QRectF(0, 0, 1, 1);
- updateBindOptions(m_dirty_bind_options);
m_dirty_bind_options = false;
}
diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h
index 24b0b4e2f8..2b2b2a84ec 100644
--- a/src/quick/util/qquickanimationcontroller_p.h
+++ b/src/quick/util/qquickanimationcontroller_p.h
@@ -49,7 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
+QT_MODULE(Quick)
class QQuickAnimationControllerPrivate;
class Q_AUTOTEST_EXPORT QQuickAnimationController : public QObject, public QQmlParserStatus
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 85e155f081..aae5306aa7 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -762,6 +762,8 @@ void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
data->nextUnreferenced = m_unreferencedPixmaps;
data->prevUnreferencedPtr = &m_unreferencedPixmaps;
+ if (!m_destroying) // the texture factories may have been cleaned up already.
+ m_unreferencedCost += data->cost();
m_unreferencedPixmaps = data;
if (m_unreferencedPixmaps->nextUnreferenced) {
@@ -772,8 +774,6 @@ void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
if (!m_lastUnreferencedPixmap)
m_lastUnreferencedPixmap = data;
- m_unreferencedCost += data->cost();
-
shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit
if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying)
@@ -810,8 +810,10 @@ void QQuickPixmapStore::shrinkCache(int remove)
data->prevUnreferencedPtr = 0;
data->prevUnreferenced = 0;
- remove -= data->cost();
- m_unreferencedCost -= data->cost();
+ if (!m_destroying) {
+ remove -= data->cost();
+ m_unreferencedCost -= data->cost();
+ }
data->removeFromCache();
delete data;
}
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index 87d447169c..8462166dec 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -69,6 +69,8 @@
QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT int qt_defaultDpi();
+
class QQuickStyledTextPrivate
{
public:
@@ -85,9 +87,10 @@ public:
QList<QQuickStyledTextImgTag*> &imgTags,
const QUrl &baseUrl,
QQmlContext *context,
- bool preloadImages)
+ bool preloadImages,
+ bool *fontSizeModified)
: text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), baseUrl(baseUrl), hasNewLine(false), nbImages(0), updateImagePositions(false)
- , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), context(context)
+ , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), fontSizeModified(fontSizeModified), context(context)
{
}
@@ -103,7 +106,7 @@ public:
void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut);
QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
QStringRef parseValue(const QChar *&ch, const QString &textIn);
-
+ void setFontSize(int size, QTextCharFormat &format);
inline void skipSpace(const QChar *&ch) {
while (ch->isSpace() && !ch->isNull())
@@ -126,6 +129,7 @@ public:
bool prependSpace;
bool hasSpace;
bool preloadImages;
+ bool *fontSizeModified;
QQmlContext *context;
static const QChar lessThan;
@@ -160,8 +164,9 @@ QQuickStyledText::QQuickStyledText(const QString &string, QTextLayout &layout,
QList<QQuickStyledTextImgTag*> &imgTags,
const QUrl &baseUrl,
QQmlContext *context,
- bool preloadImages)
- : d(new QQuickStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages))
+ bool preloadImages,
+ bool *fontSizeModified)
+ : d(new QQuickStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified))
{
}
@@ -174,11 +179,12 @@ void QQuickStyledText::parse(const QString &string, QTextLayout &layout,
QList<QQuickStyledTextImgTag*> &imgTags,
const QUrl &baseUrl,
QQmlContext *context,
- bool preloadImages)
+ bool preloadImages,
+ bool *fontSizeModified)
{
if (string.isEmpty())
return;
- QQuickStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages);
+ QQuickStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified);
styledText.d->parse();
}
@@ -298,6 +304,20 @@ void QQuickStyledTextPrivate::appendText(const QString &textIn, int start, int l
hasNewLine = false;
}
+//
+// Calculates and sets the correct font size in points
+// depending on the size multiplier and base font.
+//
+void QQuickStyledTextPrivate::setFontSize(int size, QTextCharFormat &format)
+{
+ static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
+ if (baseFont.pointSizeF() != -1)
+ format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]);
+ else
+ format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]);
+ *fontSizeModified = true;
+}
+
bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format)
{
skipSpace(ch);
@@ -353,12 +373,11 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
} else if (char0 == QLatin1Char('h') && tagLength == 2) {
int level = tag.at(1).digitValue();
if (level >= 1 && level <= 6) {
- static const qreal scaling[] = { 2.0, 1.5, 1.2, 1.0, 0.8, 0.7 };
if (!hasNewLine)
textOut.append(QChar::LineSeparator);
hasSpace = true;
prependSpace = false;
- format.setFontPointSize(baseFont.pointSize() * scaling[level - 1]);
+ setFontSize(7 - level, format);
format.setFontWeight(QFont::Bold);
return true;
}
@@ -550,10 +569,8 @@ bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QStrin
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]);
- }
+ if (size >= 1 && size <= 7)
+ setFontSize(size, format);
}
} while (!ch->isNull() && !attr.first.isEmpty());
diff --git a/src/quick/util/qquickstyledtext_p.h b/src/quick/util/qquickstyledtext_p.h
index bfc7ffe7ed..4e0f9eaaaf 100644
--- a/src/quick/util/qquickstyledtext_p.h
+++ b/src/quick/util/qquickstyledtext_p.h
@@ -85,14 +85,16 @@ public:
QList<QQuickStyledTextImgTag*> &imgTags,
const QUrl &baseUrl,
QQmlContext *context,
- bool preloadImages);
+ bool preloadImages,
+ bool *fontSizeModified);
private:
QQuickStyledText(const QString &string, QTextLayout &layout,
QList<QQuickStyledTextImgTag*> &imgTags,
const QUrl &baseUrl,
QQmlContext *context,
- bool preloadImages);
+ bool preloadImages,
+ bool *fontSizeModified);
~QQuickStyledText();
QQuickStyledTextPrivate *d;
diff --git a/tests/auto/host.pro b/tests/auto/host.pro
index 6bc8753fb0..0a96ef0413 100644
--- a/tests/auto/host.pro
+++ b/tests/auto/host.pro
@@ -1,4 +1,9 @@
TEMPLATE=subdirs
-SUBDIRS=\
- headersclean \
+
+# FIXME
+# This test is crrently broken:
+#SUBDIRS=\
+ #headersclean \
+
+SUBDIRS=
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
index 0d11213cb4..81fe3d5943 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
@@ -12,4 +12,4 @@ include (../../../shared/util.pri)
CONFIG += parallel_test declarative_debug
-QT += qml-private testlib
+QT += core-private v8-private qml-private testlib
diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
index a2cac08a21..c5992a4403 100644
--- a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
+++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
@@ -91,6 +91,7 @@ public:
QList<QByteArray> snapshotMessages;
signals:
+ void started();
void complete();
void snapshot();
@@ -158,6 +159,9 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message)
case QV8ProfilerService::V8SnapshotComplete:
emit snapshot();
break;
+ case QV8ProfilerService::V8Started:
+ emit started();
+ break;
default:
QString failMessage = QString("Unknown message type: %1").arg(messageType);
QFAIL(qPrintable(failMessage));
@@ -208,6 +212,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
m_client->stopProfiling("");
QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
"No trace received in time.");
@@ -225,6 +231,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
QFAIL(qPrintable(failMsg));
}
m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
m_client->stopProfiling("");
QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
"No trace received in time.");
@@ -236,6 +244,8 @@ void tst_QV8ProfilerService::nonBlockingConnect()
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
m_client->stopProfiling("");
QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
"No trace received in time.");
@@ -257,6 +267,8 @@ void tst_QV8ProfilerService::profileOnExit()
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->startProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
"No trace received in time.");
@@ -270,6 +282,8 @@ void tst_QV8ProfilerService::console()
m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(started())),
+ "No start signal received in time.");
QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
"No trace received in time.");
QVERIFY(!m_client->traceMessages.isEmpty());
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 7a62a71df1..bcfbcbdbf0 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -19,6 +19,7 @@ PUBLICTESTS += \
qqmlinfo \
qqmllistreference \
qqmllocale \
+ qqmlmetaobject \
qqmlmoduleplugin \
qqmlqt \
qqmltranslation \
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index 2d764317c5..dfc88fb78c 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -96,10 +96,11 @@ void tst_qmlmin::initTestCase()
// Add invalid files (i.e. files with syntax errors)
invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/property.4.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/empty.qml";
- invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/missingObject.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml";
diff --git a/tests/auto/qml/qqmlcomponent/data/createParentReference.qml b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
new file mode 100644
index 0000000000..daa5d3c167
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ width: 100
+ height: 100
+
+ function createChild() {
+ Qt.createQmlObject("import QtQuick 2.0;" +
+ "Item { width: parent.width; }", root);
+ }
+}
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index d277952f22..603c091a03 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -71,6 +71,7 @@ private slots:
void qmlCreateObject();
void qmlCreateObjectWithProperties();
void qmlIncubateObject();
+ void qmlCreateParentReference();
private:
QQmlEngine engine;
@@ -181,6 +182,37 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties()
delete testBindingThisObj;
}
+static QStringList warnings;
+static void msgHandler(QtMsgType, const char *warning)
+{
+ warnings << QString::fromUtf8(warning);
+}
+
+void tst_qqmlcomponent::qmlCreateParentReference()
+{
+ QQmlEngine engine;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ warnings.clear();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ QQmlComponent component(&engine, testFileUrl("createParentReference.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(object, "createChild"));
+ delete object;
+
+ qInstallMsgHandler(old);
+
+ engine.setOutputWarningsToStandardError(false);
+ QCOMPARE(engine.outputWarningsToStandardError(), false);
+
+ QCOMPARE(warnings.count(), 0);
+}
+
QTEST_MAIN(tst_qqmlcomponent)
#include "tst_qqmlcomponent.moc"
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
new file mode 100644
index 0000000000..7a4f434665
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
@@ -0,0 +1,5 @@
+.import Qt.test 1.0 as QObjectModuleApi
+
+function testFunc() {
+ return QObjectModuleApi.qobjectTestProperty
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
new file mode 100644
index 0000000000..b3e545dd7c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+import "importModuleApi.js" as Script
+
+Item {
+ property variant testValue: 5
+
+ Component.onCompleted: {
+ testValue = Script.testFunc();
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml
new file mode 100644
index 0000000000..f84ba8c722
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ Component.onCompleted: {
+ var o = Qt.createQmlObject("import QtQuick 2.0; \
+ \
+ Item { \
+ property bool b: true; \
+ }", root, "Instance")
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml
new file mode 100644
index 0000000000..690b7cf216
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml
@@ -0,0 +1,5 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ onUnnamedArgumentSignal: setString('pass ' + a + ' ' + c)
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml
new file mode 100644
index 0000000000..0e1e728a86
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+
+MyQmlObject {
+ onSignalWithGlobalName: setString('pass ' + parseInt("5"))
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 154e6f019c..1d68e8ae13 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -180,6 +180,7 @@ public:
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
+ void unnamedArgumentSignal(int a, qreal, QString c);
void stringChanged();
void urlChanged();
void objectChanged();
@@ -188,6 +189,7 @@ signals:
void signalWithUnknownType(const MyQmlObject::MyType &arg);
void signalWithVariant(const QVariant &arg);
void signalWithQJSValue(const QJSValue &arg);
+ void signalWithGlobalName(int parseInt);
void intChanged();
public slots:
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index af219c8826..676557a81c 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -376,6 +376,27 @@ void tst_qqmlecmascript::signalAssignment()
QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
delete object;
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->unnamedArgumentSignal(19, 10.25, "Hello world!");
+ QEXPECT_FAIL("", "QTBUG-24481", Continue);
+ QCOMPARE(object->string(), QString("pass 19 Hello world!"));
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->signalWithGlobalName(19);
+ QCOMPARE(object->string(), QString("pass 5"));
+ delete object;
+ }
}
void tst_qqmlecmascript::methods()
@@ -1570,8 +1591,6 @@ void tst_qqmlecmascript::compileInvalidBinding()
{
// QTBUG-23387: ensure that invalid bindings don't cause a crash.
QQmlComponent component(&engine, testFileUrl("v8bindingException.qml"));
- QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
@@ -3248,6 +3267,13 @@ void tst_qqmlecmascript::importScripts_data()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(18));
+
+ QTest::newRow("import module api into js import")
+ << testFileUrl("jsimport/testImportModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(20));
}
void tst_qqmlecmascript::importScripts()
@@ -5287,12 +5313,21 @@ void tst_qqmlecmascript::qtbug_21864()
void tst_qqmlecmascript::rewriteMultiLineStrings()
{
- // QTBUG-23387
- QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QTRY_COMPARE(o->property("test").toBool(), true);
- delete o;
+ {
+ // QTBUG-23387
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QTRY_COMPARE(o->property("test").toBool(), true);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+ }
}
void tst_qqmlecmascript::qobjectConnectionListExceptionHandling()
diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
index 07b89af0a3..d076f038d3 100644
--- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
+++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
@@ -499,9 +499,9 @@ void tst_qqmlinstruction::dump()
<< "24\t\tSTORE_OBJECT\t\t21"
<< "25\t\tSTORE_VARIANT_OBJECT\t22"
<< "26\t\tSTORE_INTERFACE\t\t23"
- << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\""
+ << "27\t\tSTORE_SIGNAL\t\t2\t3"
<< "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4"
- << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\""
+ << "29\t\tASSIGN_SIGNAL_OBJECT\t4"
<< "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
<< "31\t\tSTORE_BINDING\t26\t3\t2"
<< "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4"
diff --git a/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt
new file mode 100644
index 0000000000..cf772e881e
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/signal.5.errors.txt
@@ -0,0 +1 @@
+4:27:Expected token `identifier'
diff --git a/tests/auto/qml/qqmllanguage/data/signal.5.qml b/tests/auto/qml/qqmllanguage/data/signal.5.qml
new file mode 100644
index 0000000000..63921cb2ca
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/signal.5.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+QtObject {
+ signal mySignal(string)
+}
+
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index e9898bd039..e7294f090c 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -67,7 +67,8 @@ public:
};
QT_BEGIN_NAMESPACE
-Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
+#define MyInterface_iid "org.qt-project.Qt.Test.MyInterface"
+Q_DECLARE_INTERFACE(MyInterface, MyInterface_iid);
QT_END_NAMESPACE
QML_DECLARE_INTERFACE(MyInterface);
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 379c32d4b8..266cd2a52d 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -354,6 +354,7 @@ void tst_qqmllanguage::errors_data()
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("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false;
+ QTest::newRow("signal.5") << "signal.5.qml" << "signal.5.errors.txt" << false;
QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false;
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index af1a81847b..46435fb8fc 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -68,6 +68,8 @@ private slots:
void dayName();
void standaloneDayName_data();
void standaloneDayName();
+ void firstDayOfWeek_data();
+ void firstDayOfWeek();
void weekDays_data();
void weekDays();
void uiLanguages_data();
@@ -154,7 +156,6 @@ void tst_qqmllocale::addPropertyData(const QString &l)
LOCALE_PROP(QString,negativeSign),
LOCALE_PROP(QString,positiveSign),
LOCALE_PROP(QString,exponential),
- LOCALE_PROP(int,firstDayOfWeek),
LOCALE_PROP(int,measurementSystem),
LOCALE_PROP(int,textDirection),
{ 0, QVariant() }
@@ -426,6 +427,41 @@ void tst_qqmllocale::standaloneDayName()
delete obj;
}
+void tst_qqmllocale::firstDayOfWeek_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qqmllocale::firstDayOfWeek()
+{
+ QFETCH(QString, locale);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("firstDayOfWeek");
+ QVERIFY(val.type() == QVariant::Int);
+
+ int day = int(QLocale(locale).firstDayOfWeek());
+ if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
+ day = 0;
+ QCOMPARE(day, val.toInt());
+
+ delete obj;
+}
+
void tst_qqmllocale::weekDays_data()
{
QTest::addColumn<QString>("locale");
diff --git a/tests/auto/qml/qqmlmetaobject/data/method.1.qml b/tests/auto/qml/qqmlmetaobject/data/method.1.qml
new file mode 100644
index 0000000000..a021881743
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/method.1.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ function testFunction() { return 19; }
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/method.2.qml b/tests/auto/qml/qqmlmetaobject/data/method.2.qml
new file mode 100644
index 0000000000..d514955f47
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/method.2.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ function testFunction(foo) { return 19; }
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/method.3.qml b/tests/auto/qml/qqmlmetaobject/data/method.3.qml
new file mode 100644
index 0000000000..d6d19758c9
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/method.3.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ function testFunction(foo, bar, baz) { return 19; }
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml
new file mode 100644
index 0000000000..8903bbb3e9
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.MyQmlObject.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+import QtQuick 2.0
+
+QtObject {
+ property MyQmlObject test: MyQmlObject {}
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml
new file mode 100644
index 0000000000..20c42b5851
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.QtObject.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property QtObject test: QtObject {}
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml
new file mode 100644
index 0000000000..cae1ae6696
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.2.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+QtObject {
+ id: me
+ property alias test: me
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml
new file mode 100644
index 0000000000..86422ae367
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.3.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+Text {
+ id: me
+ font.family: "Arial"
+ property alias test: me.font.family
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.alias.qml b/tests/auto/qml/qqmlmetaobject/data/property.alias.qml
new file mode 100644
index 0000000000..33a4a1c5b0
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.alias.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+QtObject {
+ objectName: "Joe"
+ id: me
+ property alias test: me.objectName
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.bool.qml b/tests/auto/qml/qqmlmetaobject/data/property.bool.qml
new file mode 100644
index 0000000000..9459cb6394
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.bool.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ default property bool test: true
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.color.qml b/tests/auto/qml/qqmlmetaobject/data/property.color.qml
new file mode 100644
index 0000000000..7451a27101
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.color.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ default property color test: "#ff0000"
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.date.qml b/tests/auto/qml/qqmlmetaobject/data/property.date.qml
new file mode 100644
index 0000000000..05fcb2516c
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.date.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property date test: "2012-02-07"
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.int.qml b/tests/auto/qml/qqmlmetaobject/data/property.int.qml
new file mode 100644
index 0000000000..ae419d08cb
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.int.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property int test: 19
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml
new file mode 100644
index 0000000000..602762cba2
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.list.MyQmlObject.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+import QtQuick 2.0
+
+QtObject {
+ property list<MyQmlObject> test: [ MyQmlObject {} ]
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml b/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml
new file mode 100644
index 0000000000..e774d70b42
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.list.QtObject.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property list<QtObject> test: [ QtObject {} ]
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.real.qml b/tests/auto/qml/qqmlmetaobject/data/property.real.qml
new file mode 100644
index 0000000000..de2baf5be2
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.real.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property real test: 21
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.string.qml b/tests/auto/qml/qqmlmetaobject/data/property.string.qml
new file mode 100644
index 0000000000..2a625c4fe4
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.string.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ default property string test: "dog"
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.url.qml b/tests/auto/qml/qqmlmetaobject/data/property.url.qml
new file mode 100644
index 0000000000..c820c82515
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.url.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property url test: "http://foo.bar"
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.var.qml b/tests/auto/qml/qqmlmetaobject/data/property.var.qml
new file mode 100644
index 0000000000..9ea9245317
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.var.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ property var test: [5, true, "ciao"]
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/property.variant.qml b/tests/auto/qml/qqmlmetaobject/data/property.variant.qml
new file mode 100644
index 0000000000..edffa173c4
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/property.variant.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ default property variant test: "12,34"
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.1.qml b/tests/auto/qml/qqmlmetaobject/data/signal.1.qml
new file mode 100644
index 0000000000..113130f3cc
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.1.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ signal testSignal
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.2.qml b/tests/auto/qml/qqmlmetaobject/data/signal.2.qml
new file mode 100644
index 0000000000..db860cc7cd
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.2.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ signal testSignal(string foo)
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.3.qml b/tests/auto/qml/qqmlmetaobject/data/signal.3.qml
new file mode 100644
index 0000000000..4d04041f8f
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.3.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ signal testSignal(int foo, bool bar, real baz)
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.4.qml b/tests/auto/qml/qqmlmetaobject/data/signal.4.qml
new file mode 100644
index 0000000000..ad9b002176
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.4.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ signal testSignal(variant foo, var bar)
+}
diff --git a/tests/auto/qml/qqmlmetaobject/data/signal.5.qml b/tests/auto/qml/qqmlmetaobject/data/signal.5.qml
new file mode 100644
index 0000000000..b848bb5cb5
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/data/signal.5.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+ signal testSignal(color foo, date bar, url baz)
+}
diff --git a/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro b/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro
new file mode 100644
index 0000000000..b87a7cd8bd
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/qqmlmetaobject.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qqmlmetaobject
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlmetaobject.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += qml testlib
diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
new file mode 100644
index 0000000000..6cadc3524b
--- /dev/null
+++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
@@ -0,0 +1,364 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include "../../shared/util.h"
+
+Q_DECLARE_METATYPE(QMetaMethod::MethodType)
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+};
+QML_DECLARE_TYPE(MyQmlObject)
+
+class tst_QQmlMetaObject : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+
+ void property_data();
+ void property();
+ void method_data();
+ void method();
+
+private:
+ MyQmlObject myQmlObject;
+};
+
+void tst_QQmlMetaObject::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
+}
+
+void tst_QQmlMetaObject::property_data()
+{
+ QTest::addColumn<QString>("testFile");
+ QTest::addColumn<QByteArray>("cppTypeName");
+ QTest::addColumn<int>("cppType");
+ QTest::addColumn<bool>("isDefault");
+ QTest::addColumn<QVariant>("expectedValue");
+ QTest::addColumn<bool>("isWritable");
+ QTest::addColumn<QVariant>("newValue");
+
+ QTest::newRow("int") << "property.int.qml"
+ << QByteArray("int") << int(QMetaType::Int)
+ << false // default
+ << QVariant(19) << true << QVariant(42);
+ QTest::newRow("bool") << "property.bool.qml"
+ << QByteArray("bool") << int(QMetaType::Bool)
+ << true // default
+ << QVariant(true) << true << QVariant(false);
+ QTest::newRow("real") << "property.real.qml"
+ << QByteArray("double") << int(QMetaType::Double)
+ << false // default
+ << QVariant(double(21))
+ << true // writable
+ << QVariant(double(37));
+ QTest::newRow("string") << "property.string.qml"
+ << QByteArray("QString") << int(QMetaType::QString)
+ << true // default
+ << QVariant(QString::fromLatin1("dog"))
+ << true // writable
+ << QVariant(QString::fromLatin1("food"));
+ QTest::newRow("url") << "property.url.qml"
+ << QByteArray("QUrl") << int(QMetaType::QUrl)
+ << false // default
+ << QVariant(QUrl("http://foo.bar"))
+ << true //writable
+ << QVariant(QUrl("http://bar.baz"));
+ QTest::newRow("color") << "property.color.qml"
+ << QByteArray("QColor") << int(QMetaType::QColor)
+ << true // default
+ << QVariant(QColor("#ff0000"))
+ << true // writable
+ << QVariant(QColor("#00ff00"));
+ QTest::newRow("date") << "property.date.qml"
+ << QByteArray("QDateTime") << int(QMetaType::QDateTime)
+ << false // default
+ << QVariant(QDateTime(QDate(2012, 2, 7)))
+ << true // writable
+ << QVariant(QDateTime(QDate(2010, 7, 2)));
+ QTest::newRow("variant") << "property.variant.qml"
+ << QByteArray("QVariant") << int(QMetaType::QVariant)
+ << true // default
+ << QVariant(QPointF(12, 34))
+ << true // writable
+ << QVariant(QSizeF(45, 67));
+ QTest::newRow("var") << "property.var.qml"
+ << QByteArray("QVariant") << int(QMetaType::QVariant)
+ << false // default
+ << QVariant(QVariantList() << 5 << true << "ciao")
+ << true // writable
+ << QVariant(QVariantList() << 17.0);
+ QTest::newRow("QtObject") << "property.QtObject.qml"
+ << QByteArray("QObject*") << int(QMetaType::QObjectStar)
+ << false // default
+ << QVariant()
+ << true // writable
+ << QVariant::fromValue(static_cast<QObject*>(this));
+ QTest::newRow("list<QtObject>") << "property.list.QtObject.qml"
+ << QByteArray("QQmlListProperty<QObject>")
+ << qMetaTypeId<QQmlListProperty<QObject> >()
+ << false // default
+ << QVariant()
+ << false // writable
+ << QVariant();
+ QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml"
+ << QByteArray("MyQmlObject*") << qMetaTypeId<MyQmlObject*>()
+ << false // default
+ << QVariant()
+ << true // writable
+ << QVariant::fromValue(&myQmlObject);
+ QTest::newRow("list<MyQmlObject>") << "property.list.MyQmlObject.qml"
+ << QByteArray("QQmlListProperty<MyQmlObject>")
+ << qMetaTypeId<QQmlListProperty<MyQmlObject> >()
+ << false // default
+ << QVariant()
+ << false // writable
+ << QVariant();
+ QTest::newRow("alias") << "property.alias.qml"
+ << QByteArray("QString") << int(QMetaType::QString)
+ << false // default
+ << QVariant(QString::fromLatin1("Joe"))
+ << true // writable
+ << QVariant(QString::fromLatin1("Bob"));
+ QTest::newRow("alias-2") << "property.alias.2.qml"
+ << QByteArray("QObject*") << int(QMetaType::QObjectStar)
+ << false // default
+ << QVariant()
+ << false // writable
+ << QVariant();
+ QTest::newRow("alias-3") << "property.alias.3.qml"
+ << QByteArray("QString") << int(QMetaType::QString)
+ << false // default
+ << QVariant(QString::fromLatin1("Arial"))
+ << true // writable
+ << QVariant(QString::fromLatin1("Helvetica"));
+}
+
+void tst_QQmlMetaObject::property()
+{
+ QFETCH(QString, testFile);
+ QFETCH(QByteArray, cppTypeName);
+ QFETCH(int, cppType);
+ QFETCH(bool, isDefault);
+ QFETCH(QVariant, expectedValue);
+ QFETCH(bool, isWritable);
+ QFETCH(QVariant, newValue);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl(testFile));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ const QMetaObject *mo = object->metaObject();
+ QVERIFY(mo->superClass() != 0);
+ QVERIFY(QByteArray(mo->className()).contains("_QML_"));
+ QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount());
+ QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1);
+
+ QMetaProperty prop = mo->property(mo->propertyOffset());
+ QCOMPARE(prop.name(), "test");
+
+ QCOMPARE(QByteArray(prop.typeName()), cppTypeName);
+ QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue);
+ QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue);
+ if (prop.userType() < QMetaType::User)
+ QCOMPARE(prop.type(), QVariant::Type(cppType));
+ QCOMPARE(prop.userType(), cppType);
+
+ QVERIFY(!prop.isConstant());
+ QVERIFY(!prop.isDesignable());
+ QVERIFY(!prop.isEnumType());
+ QVERIFY(!prop.isFinal());
+ QVERIFY(!prop.isFlagType());
+ QVERIFY(prop.isReadable());
+ QVERIFY(!prop.isResettable());
+ QVERIFY(prop.isScriptable());
+ QVERIFY(!prop.isStored());
+ QVERIFY(!prop.isUser());
+ QVERIFY(prop.isValid());
+ QCOMPARE(prop.isWritable(), isWritable);
+
+ QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount());
+ QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0));
+ if (isDefault) {
+ QMetaClassInfo info = mo->classInfo(mo->classInfoOffset());
+ QCOMPARE(info.name(), "DefaultProperty");
+ QCOMPARE(info.value(), "test");
+ }
+
+ QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount());
+ QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal
+
+ QVERIFY(prop.notifySignalIndex() != -1);
+ QMetaMethod signal = prop.notifySignal();
+ QCOMPARE(signal.methodType(), QMetaMethod::Signal);
+ QCOMPARE(signal.signature(), "testChanged()");
+ QCOMPARE(signal.access(), QMetaMethod::Protected);
+ QCOMPARE(signal.parameterTypes(), QList<QByteArray>());
+ QCOMPARE(signal.parameterNames(), QList<QByteArray>());
+ QCOMPARE(signal.tag(), "");
+ QCOMPARE(signal.typeName(), "");
+
+ QSignalSpy changedSpy(object, SIGNAL(testChanged()));
+ QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater()));
+
+ if (expectedValue.isValid())
+ QCOMPARE(prop.read(object), expectedValue);
+ else
+ QVERIFY(prop.read(object).isValid());
+ QCOMPARE(changedSpy.count(), 0);
+
+ if (isWritable) {
+ QVERIFY(prop.write(object, newValue));
+ QCOMPARE(changedSpy.count(), 1);
+ QCOMPARE(prop.read(object), newValue);
+ } else {
+ QVERIFY(!prop.write(object, prop.read(object)));
+ QCOMPARE(changedSpy.count(), 0);
+ }
+
+ delete object;
+}
+
+void tst_QQmlMetaObject::method_data()
+{
+ QTest::addColumn<QString>("testFile");
+ QTest::addColumn<QString>("signature");
+ QTest::addColumn<QMetaMethod::MethodType>("methodType");
+ QTest::addColumn<QString>("returnTypeName");
+ QTest::addColumn<QList<QByteArray> >("parameterTypeNames");
+ QTest::addColumn<QList<QByteArray> >("parameterNames");
+
+ QTest::newRow("testFunction()") << "method.1.qml"
+ << "testFunction()"
+ << QMetaMethod::Slot
+ << "QVariant"
+ << QList<QByteArray>()
+ << QList<QByteArray>();
+ QTest::newRow("testFunction(foo)") << "method.2.qml"
+ << "testFunction(QVariant)"
+ << QMetaMethod::Slot
+ << "QVariant"
+ << (QList<QByteArray>() << "QVariant")
+ << (QList<QByteArray>() << "foo");
+ QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml"
+ << "testFunction(QVariant,QVariant,QVariant)"
+ << QMetaMethod::Slot
+ << "QVariant"
+ << (QList<QByteArray>() << "QVariant" << "QVariant" << "QVariant")
+ << (QList<QByteArray>() << "foo" << "bar" << "baz");
+ QTest::newRow("testSignal") << "signal.1.qml"
+ << "testSignal()"
+ << QMetaMethod::Signal
+ << ""
+ << QList<QByteArray>()
+ << QList<QByteArray>();
+ QTest::newRow("testSignal(string foo)") << "signal.2.qml"
+ << "testSignal(QString)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "QString")
+ << (QList<QByteArray>() << "foo");
+ QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml"
+ << "testSignal(int,bool,qreal)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "int" << "bool" << "qreal")
+ << (QList<QByteArray>() << "foo" << "bar" << "baz");
+ QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml"
+ << "testSignal(QVariant,QVariant)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "QVariant" << "QVariant")
+ << (QList<QByteArray>() << "foo" << "bar");
+ QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml"
+ << "testSignal(QColor,QDateTime,QUrl)"
+ << QMetaMethod::Signal
+ << ""
+ << (QList<QByteArray>() << "QColor" << "QDateTime" << "QUrl")
+ << (QList<QByteArray>() << "foo" << "bar" << "baz");
+}
+
+void tst_QQmlMetaObject::method()
+{
+ QFETCH(QString, testFile);
+ QFETCH(QString, signature);
+ QFETCH(QMetaMethod::MethodType, methodType);
+ QFETCH(QString, returnTypeName);
+ QFETCH(QList<QByteArray>, parameterTypeNames);
+ QFETCH(QList<QByteArray>, parameterNames);
+
+ QCOMPARE(parameterTypeNames.size(), parameterNames.size());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl(testFile));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ const QMetaObject *mo = object->metaObject();
+ QVERIFY(mo->superClass() != 0);
+ QVERIFY(QByteArray(mo->className()).contains("_QML_"));
+ QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount());
+ QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1);
+
+ QMetaMethod method = mo->method(mo->methodOffset());
+ QCOMPARE(method.methodType(), methodType);
+ QCOMPARE(QString::fromUtf8(method.signature()), signature);
+ QCOMPARE(method.access(), QMetaMethod::Protected);
+ QCOMPARE(method.parameterTypes(), parameterTypeNames);
+ QCOMPARE(method.parameterNames(), parameterNames);
+ QCOMPARE(method.tag(), "");
+ QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_QQmlMetaObject)
+
+#include "tst_qqmlmetaobject.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/empty.json b/tests/auto/qml/qqmlmoduleplugin/empty.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/empty.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
index 53696b3598..03065b2f27 100644
--- a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
@@ -66,6 +66,8 @@ private:
class MyPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
MyPlugin()
{
@@ -80,5 +82,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
index f62b8addd4..e2ff43dffe 100644
--- a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
@@ -66,6 +66,8 @@ private:
class MyPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
MyPlugin()
{
@@ -80,5 +82,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
index 470aa7a37c..5a91852d22 100644
--- a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
@@ -65,6 +65,8 @@ private:
class MyPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
MyPlugin()
{
@@ -79,5 +81,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
index eec8e3f3af..66c59fde81 100644
--- a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
@@ -56,6 +56,8 @@ public:
class MyMixedPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
MyMixedPlugin()
{
@@ -69,5 +71,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
index 8645028317..a3142ef9b3 100644
--- a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
@@ -56,6 +56,8 @@ public:
class MyMixedPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
MyMixedPlugin()
{
@@ -69,5 +71,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
index 1217df4d0e..a2262f15d6 100644
--- a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
@@ -46,6 +46,8 @@
class MyPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
void registerTypes(const char *uri)
{
@@ -54,5 +56,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
index e0257fe249..a5fc6c1d37 100644
--- a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
@@ -65,6 +65,8 @@ private:
class MyPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "../empty.json")
+
public:
MyPlugin()
{
@@ -79,5 +81,3 @@ public:
};
#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml b/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml
new file mode 100644
index 0000000000..0ffa5eb666
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/nonValueTypeComparison.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+Item {
+ property variant somepoint: Qt.point(1,2)
+ property variant randomjsobj: {"some": 1, "thing": 2}
+ property bool test1: somepoint != randomjsobj
+
+ property variant similar: {"x":1, "y":2}
+ property bool test2: somepoint != similar
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 695dbe4147..0aa223e733 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -93,6 +93,7 @@ private slots:
void returnValues();
void varAssignment();
void bindingsSpliceCorrectly();
+ void nonValueTypeComparison();
private:
QQmlEngine engine;
@@ -950,7 +951,6 @@ void tst_qqmlvaluetypes::autoBindingRemoval()
delete object;
}
- /*
{
QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -975,6 +975,8 @@ void tst_qqmlvaluetypes::autoBindingRemoval()
{
QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
@@ -992,7 +994,6 @@ void tst_qqmlvaluetypes::autoBindingRemoval()
delete object;
}
-*/
}
// Test that property value sources assign to value types
@@ -1301,6 +1302,18 @@ void tst_qqmlvaluetypes::bindingsSpliceCorrectly()
}
}
+void tst_qqmlvaluetypes::nonValueTypeComparison()
+{
+ QQmlComponent component(&engine, testFileUrl("nonValueTypeComparison.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qqmlvaluetypes)
#include "tst_qqmlvaluetypes.moc"
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index a6d90cf688..3761929362 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -170,8 +170,8 @@ void tst_qquickfolderlistmodel::refresh()
flm->setProperty("sortReversed", true);
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
+ QTRY_COMPARE(removeStart, 0);
+ QTRY_COMPARE(removeEnd, count-1); // wait for refresh
}
QTEST_MAIN(tst_qquickfolderlistmodel)
diff --git a/tests/auto/qml/v4/data/colorType.qml b/tests/auto/qml/v4/data/colorType.qml
new file mode 100644
index 0000000000..f6a98a4a3e
--- /dev/null
+++ b/tests/auto/qml/v4/data/colorType.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+QtObject {
+ property bool useMyColor: true
+ property color myColor: "red"
+ property color myOtherColor: "green"
+
+ property color test1: useMyColor ? myColor : myOtherColor
+ property color test2: useMyColor ? "red" : "green"
+ property color test3: useMyColor ? myColor : "green"
+
+ property bool test4: !myColor ? false : true
+
+ property bool test5: myColor != "red"
+ property bool test6: myColor == "#ff0000"
+ property bool test7: myColor != "#00ff00"
+}
+
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
index 559abf7388..4e3e71f717 100644
--- a/tests/auto/qml/v4/tst_v4.cpp
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -45,6 +45,7 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtCore/qdebug.h>
+#include <QtGui/qcolor.h>
#include <private/qv4compiler_p.h>
@@ -73,6 +74,7 @@ private slots:
void stringComparison();
void unaryMinus();
void unaryPlus();
+ void colorType();
private:
QQmlEngine engine;
@@ -348,6 +350,22 @@ void tst_v4::unaryPlus()
delete o;
}
+void tst_v4::colorType()
+{
+ QQmlComponent component(&engine, testFileUrl("colorType.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").value<QColor>(), QColor("red"));
+ QCOMPARE(o->property("test2").value<QColor>(), QColor("red"));
+ QCOMPARE(o->property("test3").value<QColor>(), QColor("red"));
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ delete o;
+}
+
QTEST_MAIN(tst_v4)
#include "tst_v4.moc"
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index 24a60cb08a..482053e158 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -88,33 +88,27 @@ tst_examples::tst_examples()
// Add files to exclude here
excludedFiles << "doc/src/snippets/qml/listmodel.qml"; //Just a ListModel, no root QQuickItem
- // Add directories you want excluded here
- excludedDirs << "examples/qml/text/fonts"; // QTBUG-21415
+ // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/)
+ excludedDirs << "shared"; //Not an example
+ excludedDirs << "qtquick/text/fonts"; // QTBUG-21415
excludedDirs << "doc/src/snippets/qml/path"; //No root QQuickItem
-
- // Not run in QQuickView
- excludedDirs << "examples/qml/qtquick1";
+ excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir
// These snippets are not expected to run on their own.
excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
excludedDirs << "doc/src/snippets/qml/qtbinding";
excludedDirs << "doc/src/snippets/qml/imports";
- excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
- excludedDirs << "doc/src/snippets/qtquick1/imports";
#ifdef QT_NO_WEBKIT
- excludedDirs << "examples/qml/modelviews/webview";
- excludedDirs << "examples/qml/webbrowser";
+ excludedDirs << "qtquick/modelviews/webview";
+ excludedDirs << "demos/webbrowser";
excludedDirs << "doc/src/snippets/qml/webview";
- excludedDirs << "doc/src/snippets/qtquick1/webview";
#endif
#ifdef QT_NO_XMLPATTERNS
- excludedDirs << "examples/qml/xml/xmldata";
- excludedDirs << "examples/qml/twitter";
- excludedDirs << "examples/qml/flickr";
- excludedDirs << "examples/qml/photoviewer";
+ excludedDirs << "demos/twitter";
+ excludedDirs << "demos/flickr";
+ excludedDirs << "demos/photoviewer";
#endif
}
@@ -230,12 +224,10 @@ void tst_examples::sgexamples_data()
{
QTest::addColumn<QString>("file");
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/qml/";
- QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only qml tutorials since modularization
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
QStringList files;
files << findQmlFiles(QDir(examples));
- files << findQmlFiles(QDir(tutorials));
foreach (const QString &file, files)
QTest::newRow(qPrintable(file)) << file;
diff --git a/tests/auto/quick/qquickanchors/data/stretch.qml b/tests/auto/quick/qquickanchors/data/stretch.qml
new file mode 100644
index 0000000000..64e23e30b5
--- /dev/null
+++ b/tests/auto/quick/qquickanchors/data/stretch.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400; height: 400
+
+ Rectangle {
+ id: rect1
+ x: 20; y: 20;
+ height: 360; width: 360;
+
+ Rectangle {
+ id: rect2; objectName: "stretcher"
+ anchors.verticalCenter: rect1.verticalCenter
+ anchors.bottom: rect3.top
+ anchors.horizontalCenter: rect1.horizontalCenter
+ anchors.left: rect3.left
+ }
+
+ Rectangle {
+ id: rect3
+ x: 160; y: 230
+ width: 10
+ height: 10
+ }
+
+ Rectangle {
+ id: rect4; objectName: "stretcher2"
+ anchors.verticalCenter: rect1.verticalCenter
+ anchors.top: rect5.top
+ }
+
+ Rectangle {
+ id: rect5
+ x: 160; y: 130
+ width: 10
+ height: 10
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
index 749b11f919..dd1f9f77ae 100644
--- a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -83,6 +83,7 @@ private slots:
void fillRTL();
void margins();
void marginsRTL();
+ void stretch();
};
void tst_qquickanchors::basicAnchors()
@@ -472,6 +473,10 @@ void tst_qquickanchors::fill()
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 30.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 40.0);
QCOMPARE(rect->x(), 0.0 + 10.0);
QCOMPARE(rect->y(), 0.0 + 30.0);
QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
@@ -481,6 +486,10 @@ void tst_qquickanchors::fill()
rectPrivate->anchors()->setRightMargin(0.0);
rectPrivate->anchors()->setBottomMargin(0.0);
rectPrivate->anchors()->setTopMargin(10.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 0.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 0.0);
QCOMPARE(rect->x(), 0.0 + 20.0);
QCOMPARE(rect->y(), 0.0 + 10.0);
QCOMPARE(rect->width(), 200.0 - 20.0);
@@ -523,11 +532,15 @@ void tst_qquickanchors::centerIn()
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), 30.0);
QCOMPARE(rect->x(), 75.0 + 10);
QCOMPARE(rect->y(), 75.0 + 30);
//Alter Offsets (tests QTBUG-6631)
rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), -20.0);
+ QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), -10.0);
QCOMPARE(rect->x(), 75.0 - 20.0);
QCOMPARE(rect->y(), 75.0 - 10.0);
@@ -623,6 +636,11 @@ void tst_qquickanchors::margins()
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->margins(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 6.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 10.0);
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 6.0);
QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
@@ -631,6 +649,12 @@ void tst_qquickanchors::margins()
rectPrivate->anchors()->setTopMargin(0.0);
rectPrivate->anchors()->setMargins(20.0);
+ QCOMPARE(rectPrivate->anchors()->margins(), 20.0);
+ QEXPECT_FAIL("","QTBUG-24515", Continue);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 0.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 20.0);
QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
@@ -663,6 +687,23 @@ void tst_qquickanchors::marginsRTL()
delete view;
}
+void tst_qquickanchors::stretch()
+{
+ QQuickView *view = new QQuickView(testFileUrl("stretch.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher"));
+ QCOMPARE(rect->x(), 160.0);
+ QCOMPARE(rect->y(), 130.0);
+ QCOMPARE(rect->width(), 40.0);
+ QCOMPARE(rect->height(), 100.0);
+
+ QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher2"));
+ QCOMPARE(rect2->y(), 130.0);
+ QCOMPARE(rect2->height(), 100.0);
+
+ delete view;
+}
QTEST_MAIN(tst_qquickanchors)
diff --git a/tests/auto/quick/qquickanimatedsprite/data/basic.qml b/tests/auto/quick/qquickanimatedsprite/data/basic.qml
new file mode 100644
index 0000000000..2dd20630d9
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/data/basic.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ AnimatedSprite {
+ objectName: "sprite"
+ loops: 3
+ source: "squarefacesprite.png"
+ frameCount: 6
+ frameDuration: 120
+ width: 160
+ height: 160
+ }
+}
diff --git a/tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.png b/tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.png
new file mode 100644
index 0000000000..f9a5d5fcce
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/data/squarefacesprite.png
Binary files differ
diff --git a/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
new file mode 100644
index 0000000000..3c20ccea66
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickanimatedsprite
+SOURCES += tst_qquickanimatedsprite.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
new file mode 100644
index 0000000000..37625cfed6
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+#include <QtQuick/qquickview.h>
+#include <private/qquickanimatedsprite_p.h>
+
+class tst_qquickanimatedsprite : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanimatedsprite(){}
+
+private slots:
+ void test_properties();
+};
+
+void tst_qquickanimatedsprite::test_properties()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("basic.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickAnimatedSprite* sprite = canvas->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(sprite->running());
+ QVERIFY(!sprite->paused());
+ QVERIFY(sprite->interpolate());
+ QCOMPARE(sprite->loops(), 3);
+
+ sprite->setRunning(false);
+ QVERIFY(!sprite->running());
+ sprite->setInterpolate(false);
+ QVERIFY(!sprite->interpolate());
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickanimatedsprite)
+
+#include "tst_qquickanimatedsprite.moc"
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 108bce64f9..dd010999b4 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -44,9 +44,10 @@
#include <QtQuick/qquickview.h>
#include <QtQml/private/qanimationgroupjob_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquickanimation_p.h>
-#include <QtQuick/private/qquicktransition_p.h>
#include <QtQuick/private/qquickitemanimation_p.h>
+#include <QtQuick/private/qquickitemanimation_p_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
+#include <QtQuick/private/qquickanimation_p.h>
#include <QtQuick/private/qquickpathinterpolator_p.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QEasingCurve>
@@ -105,6 +106,7 @@ private slots:
void pauseBindingBug();
void pauseBug();
void loopingBug();
+ void anchorBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -1314,6 +1316,19 @@ void tst_qquickanimations::loopingBug()
delete obj;
}
+//QTBUG-24532
+void tst_qquickanimations::anchorBug()
+{
+ QQuickAnchorAnimation animation;
+ animation.setDuration(5000);
+ animation.setEasing(QEasingCurve(QEasingCurve::InOutBack));
+ animation.start();
+ animation.pause();
+
+ QCOMPARE(animation.qtAnimation()->duration(), 5000);
+ QCOMPARE(static_cast<QQuickBulkValueAnimator*>(animation.qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutBack));
+}
+
QTEST_MAIN(tst_qquickanimations)
#include "tst_qquickanimations.moc"
diff --git a/tests/auto/quick/qquickdroparea/qquickdroparea.pro b/tests/auto/quick/qquickdroparea/qquickdroparea.pro
index 5ae8d222c4..41bcaacf79 100644
--- a/tests/auto/quick/qquickdroparea/qquickdroparea.pro
+++ b/tests/auto/quick/qquickdroparea/qquickdroparea.pro
@@ -7,3 +7,5 @@ SOURCES += tst_qquickdroparea.cpp
CONFIG += parallel_test
QT += core-private gui-private qml-private quick-private network testlib
+
+mac: CONFIG += insignificant_test # QTBUG-24588
diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
index ed7a0aa0fa..38fb02d085 100644
--- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
+++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
@@ -48,6 +48,7 @@
#include <QtQml/qqmlexpression.h>
#include <QtGui/qwindowsysteminterface_qpa.h>
+#include <QtGui/qplatformdrag_qpa.h>
template <typename T> static T evaluate(QObject *scope, const QString &expression)
{
@@ -193,14 +194,14 @@ void tst_QQuickDropArea::containsDrag_external()
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
@@ -208,13 +209,13 @@ void tst_QQuickDropArea::containsDrag_external()
evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
@@ -222,13 +223,13 @@ void tst_QQuickDropArea::containsDrag_external()
evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50));
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50), Qt::CopyAction);
}
void tst_QQuickDropArea::keys_internal()
@@ -363,80 +364,80 @@ void tst_QQuickDropArea::keys_external()
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
evaluate<void>(dropArea, "keys = \"text/x-blue\"");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
evaluate<void>(dropArea, "keys = \"text/x-red\"");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
evaluate<void>(dropArea, "keys = \"text/x-green\"");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
evaluate<void>(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
data.removeFormat("text/x-red");
data.removeFormat("text/x-blue");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
evaluate<void>(dropArea, "keys = []");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
data.setData("text/x-red", "red");
data.setData("text/x-blue", "blue");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
}
void tst_QQuickDropArea::source_internal()
@@ -589,7 +590,7 @@ void tst_QQuickDropArea::position_external()
QMimeData data;
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
@@ -600,7 +601,7 @@ void tst_QQuickDropArea::position_external()
QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50), Qt::CopyAction);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
@@ -611,7 +612,7 @@ void tst_QQuickDropArea::position_external()
QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25), Qt::CopyAction);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
@@ -621,7 +622,7 @@ void tst_QQuickDropArea::position_external()
QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25));
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25), Qt::CopyAction);
}
void tst_QQuickDropArea::drop_internal()
@@ -886,7 +887,7 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -894,7 +895,7 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -902,7 +903,7 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -920,7 +921,7 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -931,7 +932,7 @@ void tst_QQuickDropArea::simultaneousDrags()
// external then internal.
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -965,7 +966,7 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
@@ -1061,7 +1062,7 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1071,7 +1072,7 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1081,7 +1082,7 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1101,7 +1102,7 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1109,7 +1110,7 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
- QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50));
+ QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction);
}
QTEST_MAIN(tst_QQuickDropArea)
diff --git a/tests/auto/quick/qquickgridview/data/displacedTransitions.qml b/tests/auto/quick/qquickgridview/data/displacedTransitions.qml
new file mode 100644
index 0000000000..d9353c0639
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/displacedTransitions.qml
@@ -0,0 +1,138 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ Text {
+ text: index
+ }
+ Text {
+ x: 40
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ y: 20
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ y: 40
+ id: textNumber
+ objectName: "textNumber"
+ text: number
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == displaced_transitionVia)
+ model_displaced_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == addDisplaced_transitionVia)
+ model_addDisplaced_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == moveDisplaced_transitionVia)
+ model_moveDisplaced_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == removeDisplaced_transitionVia)
+ model_removeDisplaced_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ objectName: "grid"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ model: testModel
+ delegate: myDelegate
+
+ displaced: useDisplaced ? displaced : null
+ addDisplaced: useAddDisplaced ? addDisplaced : null
+ moveDisplaced: useMoveDisplaced ? moveDisplaced : null
+ removeDisplaced: useRemoveDisplaced ? removeDisplaced : null
+
+ Transition {
+ id: displaced
+ enabled: displacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+
+ Transition {
+ id: addDisplaced
+ enabled: addDisplacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+
+ Transition {
+ id: moveDisplaced
+ enabled: moveDisplacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+
+ Transition {
+ id: removeDisplaced
+ enabled: removeDisplacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+}
+
diff --git a/tests/auto/quick/qquickgridview/data/multipleTransitions.qml b/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
index 45b86e22cf..909ec3a0b7 100644
--- a/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
@@ -10,7 +10,7 @@ Rectangle {
// interrupting transitions will still produce the correct result)
property int timeBetweenActions: duration / 2
- property int duration: 100
+ property int duration: 300
property int count: grid.count
@@ -46,6 +46,8 @@ Rectangle {
property bool runningAddDisplaced: false
property bool runningMoveTargets: false
property bool runningMoveDisplaced: false
+ property bool runningRemoveTargets: false
+ property bool runningRemoveDisplaced: false
objectName: "grid"
width: 240
@@ -103,6 +105,30 @@ Rectangle {
ScriptAction { script: grid.runningMoveDisplaced = false }
}
}
+
+ remove: Transition {
+ id: removeTargets
+ SequentialAnimation {
+ ScriptAction { script: grid.runningRemoveTargets = true }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration }
+ }
+ ScriptAction { script: grid.runningRemoveTargets = false }
+ }
+ }
+
+ removeDisplaced: Transition {
+ id: removeDisplaced
+ SequentialAnimation {
+ ScriptAction { script: grid.runningRemoveDisplaced = true }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration }
+ }
+ ScriptAction { script: grid.runningRemoveDisplaced = false }
+ }
+ }
}
Rectangle {
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index d156ed0957..c0f2b02a7e 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -138,6 +138,8 @@ private slots:
void moveTransitions_data();
void removeTransitions();
void removeTransitions_data();
+ void displacedTransitions();
+ void displacedTransitions_data();
void multipleTransitions();
void multipleTransitions_data();
@@ -1272,6 +1274,8 @@ void tst_QQuickGridView::moved_data()
void tst_QQuickGridView::multipleChanges()
{
+ QSKIP("QTBUG-24523");
+
QFETCH(int, startCount);
QFETCH(QList<ListChange>, changes);
QFETCH(int, newCount);
@@ -2037,10 +2041,10 @@ void tst_QQuickGridView::componentChanges()
QTRY_VERIFY(gridView);
QQmlComponent component(canvas->engine());
- component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+ component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
QQmlComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+ delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged()));
QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged()));
@@ -4555,6 +4559,215 @@ void tst_QQuickGridView::removeTransitions_data()
<< 18 << 3 << ListRange();
}
+void tst_QQuickGridView::displacedTransitions()
+{
+ QFETCH(bool, useDisplaced);
+ QFETCH(bool, displacedEnabled);
+ QFETCH(bool, useAddDisplaced);
+ QFETCH(bool, addDisplacedEnabled);
+ QFETCH(bool, useMoveDisplaced);
+ QFETCH(bool, moveDisplacedEnabled);
+ QFETCH(bool, useRemoveDisplaced);
+ QFETCH(bool, removeDisplacedEnabled);
+ QFETCH(ListChange, change);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_displaced_transitionVia;
+ QaimModel model_addDisplaced_transitionVia;
+ QaimModel model_moveDisplaced_transitionVia;
+ QaimModel model_removeDisplaced_transitionVia;
+
+ QPointF displaced_transitionVia(-50, -100);
+ QPointF addDisplaced_transitionVia(-150, 100);
+ QPointF moveDisplaced_transitionVia(50, -100);
+ QPointF removeDisplaced_transitionVia(150, 100);
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
+ ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
+ ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
+ ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia);
+ ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia);
+ ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia);
+ ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia);
+ ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia);
+ ctxt->setContextProperty("useDisplaced", useDisplaced);
+ ctxt->setContextProperty("displacedEnabled", displacedEnabled);
+ ctxt->setContextProperty("useAddDisplaced", useAddDisplaced);
+ ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled);
+ ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced);
+ ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled);
+ ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced);
+ ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled);
+ canvas->setSource(testFileUrl("displacedTransitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+ gridview->setProperty("displaceTransitionsDone", false);
+
+ switch (change.type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > targetItemData;
+ for (int i=change.index; i<change.index + change.count; ++i)
+ targetItemData << qMakePair(QString("new item %1").arg(i), QString::number(i));
+ model.insertItems(change.index, targetItemData);
+ QTRY_COMPARE(model.count(), gridview->count());
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(change.index, change.count);
+ QTRY_COMPARE(model.count(), gridview->count());
+ break;
+ case ListChange::Moved:
+ model.moveItems(change.index, change.to, change.count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ case ListChange::SetContentY:
+ break;
+ }
+ if ((useDisplaced && displacedEnabled)
+ || (useAddDisplaced && addDisplacedEnabled)
+ || (useMoveDisplaced && moveDisplacedEnabled)
+ || (useRemoveDisplaced && removeDisplacedEnabled)) {
+ QTRY_VERIFY(gridview->property("displaceTransitionsDone").toBool());
+ }
+
+ if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
+ model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced");
+ else
+ QCOMPARE(model_addDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled)
+ model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced");
+ else
+ QCOMPARE(model_moveDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled)
+ model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced");
+ else
+ QCOMPARE(model_removeDisplaced_transitionVia.count(), 0);
+
+ if (useDisplaced && displacedEnabled
+ && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled))
+ || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled))
+ || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) {
+ model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced");
+ } else {
+ QCOMPARE(model_displaced_transitionVia.count(), 0);
+ }
+
+ // verify all items moved to the correct final positions
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i < model.count() && i < items.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::displacedTransitions_data()
+{
+ QTest::addColumn<bool>("useDisplaced");
+ QTest::addColumn<bool>("displacedEnabled");
+ QTest::addColumn<bool>("useAddDisplaced");
+ QTest::addColumn<bool>("addDisplacedEnabled");
+ QTest::addColumn<bool>("useMoveDisplaced");
+ QTest::addColumn<bool>("moveDisplacedEnabled");
+ QTest::addColumn<bool>("useRemoveDisplaced");
+ QTest::addColumn<bool>("removeDisplacedEnabled");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("no displaced transitions at all")
+ << false << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("just displaced")
+ << true << true
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("just displaced (not enabled)")
+ << true << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("displaced + addDisplaced")
+ << true << true
+ << true << true
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("displaced + addDisplaced (not enabled)")
+ << true << true
+ << true << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 17);
+
+ QTest::newRow("displaced + moveDisplaced")
+ << true << true
+ << false << false
+ << true << true
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + moveDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << true << false
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + removeDisplaced")
+ << true << true
+ << false << false
+ << false << false
+ << true << true
+ << ListChange::remove(0, 1) << ListRange(1, 18);
+
+ QTest::newRow("displaced + removeDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 18);
+
+
+ QTest::newRow("displaced + add, should use generic displaced for a remove")
+ << true << true
+ << true << true
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 18);
+}
+
void tst_QQuickGridView::multipleTransitions()
{
// Tests that if you interrupt a transition in progress with another action that
@@ -4563,12 +4776,15 @@ void tst_QQuickGridView::multipleTransitions()
QFETCH(int, initialCount);
QFETCH(qreal, contentY);
QFETCH(QList<ListChange>, changes);
+ QFETCH(bool, rippleAddDisplaced);
// add transitions on the left, moves on the right
QPointF addTargets_transitionFrom(-50, -50);
QPointF addDisplaced_transitionFrom(-50, 50);
QPointF moveTargets_transitionFrom(50, -50);
QPointF moveDisplaced_transitionFrom(50, 50);
+ QPointF removeTargets_transitionTo(-100, 300);
+ QPointF removeDisplaced_transitionFrom(100, 300);
QmlListModel model;
for (int i = 0; i < initialCount; i++)
@@ -4581,8 +4797,12 @@ void tst_QQuickGridView::multipleTransitions()
ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
+ ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo);
+ ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom);
+ ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced);
canvas->setSource(testFileUrl("multipleTransitions.qml"));
canvas->show();
+ QTest::qWaitForWindowShown(canvas);
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
@@ -4590,6 +4810,11 @@ void tst_QQuickGridView::multipleTransitions()
QVERIFY(contentItem != 0);
QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
QList<QPair<QString, QString> > targetItems;
@@ -4681,18 +4906,21 @@ void tst_QQuickGridView::multipleTransitions_data()
QTest::addColumn<int>("initialCount");
QTest::addColumn<qreal>("contentY");
QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<bool>("rippleAddDisplaced");
// the added item and displaced items should move to final dest correctly
QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::move(0, 3, 1)
- );
+ << ListChange::insert(0, 1)
+ << ListChange::move(0, 3, 1)
+ )
+ << false;
// items affected by the add should change from move to add transition
QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
<< ListChange::move(1, 10, 3)
<< ListChange::insert(0, 1)
- );
+ )
+ << false;
// items should be placed correctly if you trigger a transition then refill for that index
QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
@@ -4700,7 +4928,14 @@ void tst_QQuickGridView::multipleTransitions_data()
<< ListChange::setContentY(160.0)
<< ListChange::setContentY(0.0)
<< ListChange::insert(0, 1)
- );
+ )
+ << false;
+
+ QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(1, 1)
+ << ListChange::remove(1, 1)
+ )
+ << true;
}
void tst_QQuickGridView::cacheBuffer()
diff --git a/tests/auto/quick/qquicklistview/data/displacedTransitions.qml b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
new file mode 100644
index 0000000000..cc7892e930
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/displacedTransitions.qml
@@ -0,0 +1,128 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == displaced_transitionVia)
+ model_displaced_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == addDisplaced_transitionVia)
+ model_addDisplaced_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == moveDisplaced_transitionVia)
+ model_moveDisplaced_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == removeDisplaced_transitionVia)
+ model_removeDisplaced_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ displaced: useDisplaced ? displaced : null
+ addDisplaced: useAddDisplaced ? addDisplaced : null
+ moveDisplaced: useMoveDisplaced ? moveDisplaced : null
+ removeDisplaced: useRemoveDisplaced ? removeDisplaced : null
+
+ Transition {
+ id: displaced
+ enabled: displacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: list; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+
+ Transition {
+ id: addDisplaced
+ enabled: addDisplacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: list; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+
+ Transition {
+ id: moveDisplaced
+ enabled: moveDisplacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: list; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+
+ Transition {
+ id: removeDisplaced
+ enabled: removeDisplacedEnabled
+ SequentialAnimation {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+ PropertyAction { target: list; property: "displaceTransitionsDone"; value: true }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+}
+
diff --git a/tests/auto/quick/qquicklistview/data/multipleTransitions.qml b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
index 50ffbc53c3..8264b42b64 100644
--- a/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
@@ -10,7 +10,7 @@ Rectangle {
// interrupting transitions will still produce the correct result)
property int timeBetweenActions: duration / 2
- property int duration: 100
+ property int duration: 300
property int count: list.count
@@ -45,6 +45,8 @@ Rectangle {
property bool runningAddDisplaced: false
property bool runningMoveTargets: false
property bool runningMoveDisplaced: false
+ property bool runningRemoveTargets: false
+ property bool runningRemoveDisplaced: false
objectName: "list"
focus: true
@@ -70,6 +72,7 @@ Rectangle {
id: addDisplaced
SequentialAnimation {
ScriptAction { script: list.runningAddDisplaced = true }
+ PauseAnimation { duration: rippleAddDisplaced ? addDisplaced.ViewTransition.index * root.duration/10 : 0 }
ParallelAnimation {
NumberAnimation { properties: "x"; from: addDisplaced_transitionFrom.x; duration: root.duration }
NumberAnimation { properties: "y"; from: addDisplaced_transitionFrom.y; duration: root.duration }
@@ -101,6 +104,30 @@ Rectangle {
ScriptAction { script: list.runningMoveDisplaced = false }
}
}
+
+ remove: Transition {
+ id: removeTargets
+ SequentialAnimation {
+ ScriptAction { script: list.runningRemoveTargets = true }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration }
+ }
+ ScriptAction { script: list.runningRemoveTargets = false }
+ }
+ }
+
+ removeDisplaced: Transition {
+ id: removeDisplaced
+ SequentialAnimation {
+ ScriptAction { script: list.runningRemoveDisplaced = true }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration }
+ }
+ ScriptAction { script: list.runningRemoveDisplaced = false }
+ }
+ }
}
Rectangle {
diff --git a/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
new file mode 100644
index 0000000000..f4679b5af0
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/sectionpropertychange.qml
@@ -0,0 +1,92 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 320; height: 480
+
+ Rectangle {
+ id: groupButtons
+ width: 300; height: 30
+ color: "yellow"
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: "swap"
+ }
+ anchors {
+ top: parent.top
+ horizontalCenter: parent.horizontalCenter
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: switchGroups()
+ }
+ }
+
+ function switchGroups() {
+ if ("title" === myListView.groupBy)
+ myListView.groupBy = "genre"
+ else
+ myListView.groupBy = "title"
+ }
+
+ Component.onCompleted: {
+ myListView.model = generateModel(myListView)
+ }
+
+ ListView {
+ id: myListView
+ objectName: "list"
+
+ clip: true
+ property string groupBy: "title"
+
+ anchors {
+ top: groupButtons.bottom
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+
+ delegate: Item {
+ objectName: "wrapper"
+ height: 50
+ width: 320
+ Text { id: t; text: model.title }
+ Text { text: model.author; font.pixelSize: 10; anchors.top: t.bottom }
+ Text { text: parent.y; anchors.right: parent.right }
+ }
+
+ onGroupByChanged: {
+ model.move(0,1,1)
+ section.property = groupBy
+ }
+
+ section {
+ criteria: ViewSection.FullString
+ delegate: Rectangle { width: 320; height: 25; color: "lightblue"
+ objectName: "sect"
+ Text {text: section }
+ Text { text: parent.y; anchors.right: parent.right }
+ }
+ property: "title"
+ }
+ }
+
+ function generateModel(theParent)
+ {
+ var books = [
+ { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love" },
+ { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs" }
+ ];
+
+ var model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", theParent);
+
+ for (var i = 0; i < books.length; ++i) {
+ var book = books[i];
+ model.append(book);
+ }
+ return model;
+ }
+
+}
+
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index bcac5917d6..9195aab632 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -51,7 +51,6 @@
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickvisualitemmodel_p.h>
#include <QtQml/private/qquicklistmodel_p.h>
-#include <QtQuick/private/qquickchangeset_p.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
#include "../shared/visualtestutil.h"
@@ -126,6 +125,7 @@ private slots:
void qAbstractItemModel_sections();
void sectionsPositioning();
void sectionsDelegate();
+ void sectionPropertyChange();
void cacheBuffer();
void positionViewAtIndex();
void resetModel();
@@ -179,6 +179,8 @@ private slots:
void moveTransitions_data();
void removeTransitions();
void removeTransitions_data();
+ void displacedTransitions();
+ void displacedTransitions_data();
void multipleTransitions();
void multipleTransitions_data();
@@ -491,6 +493,7 @@ void tst_QQuickListView::inserted_more()
canvas->setSource(testFileUrl("listviewtest.qml"));
canvas->show();
qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -644,6 +647,7 @@ void tst_QQuickListView::insertBeforeVisible()
canvas->setSource(testFileUrl("listviewtest.qml"));
canvas->show();
qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -734,6 +738,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
canvas->setSource(source);
canvas->show();
qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -923,6 +928,7 @@ void tst_QQuickListView::removed_more(const QUrl &source)
canvas->setSource(source);
canvas->show();
qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -1144,6 +1150,7 @@ void tst_QQuickListView::moved(const QUrl &source)
canvas->setSource(source);
canvas->show();
qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -1370,6 +1377,7 @@ void tst_QQuickListView::multipleChanges()
canvas->setSource(testFileUrl("listviewtest.qml"));
canvas->show();
qApp->processEvents();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -2090,9 +2098,9 @@ void tst_QQuickListView::sectionsPositioning()
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
model.removeItem(5);
QTRY_COMPARE(listview->count(), model.count());
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ for (int i = 1; i < 3; ++i) {
+ QQuickItem *item = findVisibleChild(contentItem,
+ "sect_" + QString::number(i));
QVERIFY(item);
QTRY_COMPARE(item->y(), qreal(i*20*6));
}
@@ -2130,6 +2138,52 @@ void tst_QQuickListView::sectionsPositioning()
delete canvas;
}
+void tst_QQuickListView::sectionPropertyChange()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("sectionpropertychange.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < 2; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(25. + i*75.));
+ }
+
+ delete canvas;
+}
+
void tst_QQuickListView::currentIndex_delayedItemCreation()
{
QFETCH(bool, setCurrentToZero);
@@ -4814,6 +4868,7 @@ void tst_QQuickListView::populateTransitions()
canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
canvas->setSource(testFileUrl("populateTransitions.qml"));
canvas->show();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QVERIFY(listview);
@@ -4951,6 +5006,7 @@ void tst_QQuickListView::addTransitions()
ctxt->setContextProperty("testObject", testObject);
canvas->setSource(testFileUrl("addTransitions.qml"));
canvas->show();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -5145,6 +5201,7 @@ void tst_QQuickListView::moveTransitions()
ctxt->setContextProperty("testObject", testObject);
canvas->setSource(testFileUrl("moveTransitions.qml"));
canvas->show();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -5347,6 +5404,7 @@ void tst_QQuickListView::removeTransitions()
ctxt->setContextProperty("testObject", testObject);
canvas->setSource(testFileUrl("removeTransitions.qml"));
canvas->show();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -5508,20 +5566,235 @@ void tst_QQuickListView::removeTransitions_data()
<< 17 << 3 << ListRange();
}
+void tst_QQuickListView::displacedTransitions()
+{
+ QFETCH(bool, useDisplaced);
+ QFETCH(bool, displacedEnabled);
+ QFETCH(bool, useAddDisplaced);
+ QFETCH(bool, addDisplacedEnabled);
+ QFETCH(bool, useMoveDisplaced);
+ QFETCH(bool, moveDisplacedEnabled);
+ QFETCH(bool, useRemoveDisplaced);
+ QFETCH(bool, removeDisplacedEnabled);
+ QFETCH(ListChange, change);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_displaced_transitionVia;
+ QaimModel model_addDisplaced_transitionVia;
+ QaimModel model_moveDisplaced_transitionVia;
+ QaimModel model_removeDisplaced_transitionVia;
+
+ QPointF displaced_transitionVia(-50, -100);
+ QPointF addDisplaced_transitionVia(-150, 100);
+ QPointF moveDisplaced_transitionVia(50, -100);
+ QPointF removeDisplaced_transitionVia(150, 100);
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject(canvas);
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia);
+ ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia);
+ ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia);
+ ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia);
+ ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia);
+ ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia);
+ ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia);
+ ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia);
+ ctxt->setContextProperty("useDisplaced", useDisplaced);
+ ctxt->setContextProperty("displacedEnabled", displacedEnabled);
+ ctxt->setContextProperty("useAddDisplaced", useAddDisplaced);
+ ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled);
+ ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced);
+ ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled);
+ ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced);
+ ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled);
+ canvas->setSource(testFileUrl("displacedTransitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+ listview->setProperty("displaceTransitionsDone", false);
+
+ switch (change.type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > targetItemData;
+ for (int i=change.index; i<change.index + change.count; ++i)
+ targetItemData << qMakePair(QString("new item %1").arg(i), QString::number(i));
+ model.insertItems(change.index, targetItemData);
+ QTRY_COMPARE(model.count(), listview->count());
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(change.index, change.count);
+ QTRY_COMPARE(model.count(), listview->count());
+ break;
+ case ListChange::Moved:
+ model.moveItems(change.index, change.to, change.count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ case ListChange::SetContentY:
+ break;
+ }
+ if ((useDisplaced && displacedEnabled)
+ || (useAddDisplaced && addDisplacedEnabled)
+ || (useMoveDisplaced && moveDisplacedEnabled)
+ || (useRemoveDisplaced && removeDisplacedEnabled)) {
+ QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool());
+ }
+
+ if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled)
+ model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced");
+ else
+ QCOMPARE(model_addDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled)
+ model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced");
+ else
+ QCOMPARE(model_moveDisplaced_transitionVia.count(), 0);
+ if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled)
+ model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced");
+ else
+ QCOMPARE(model_removeDisplaced_transitionVia.count(), 0);
+
+ if (useDisplaced && displacedEnabled
+ && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled))
+ || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled))
+ || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) {
+ model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced");
+ } else {
+ QCOMPARE(model_displaced_transitionVia.count(), 0);
+ }
+
+ // verify all items moved to the correct final positions
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i < model.count() && i < items.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), i * 20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::displacedTransitions_data()
+{
+ QTest::addColumn<bool>("useDisplaced");
+ QTest::addColumn<bool>("displacedEnabled");
+ QTest::addColumn<bool>("useAddDisplaced");
+ QTest::addColumn<bool>("addDisplacedEnabled");
+ QTest::addColumn<bool>("useMoveDisplaced");
+ QTest::addColumn<bool>("moveDisplacedEnabled");
+ QTest::addColumn<bool>("useRemoveDisplaced");
+ QTest::addColumn<bool>("removeDisplacedEnabled");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("no displaced transitions at all")
+ << false << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("just displaced")
+ << true << true
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("just displaced (not enabled)")
+ << true << false
+ << false << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("displaced + addDisplaced")
+ << true << true
+ << true << true
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("displaced + addDisplaced (not enabled)")
+ << true << true
+ << true << false
+ << false << false
+ << false << false
+ << ListChange::insert(0, 1) << ListRange(0, 15);
+
+ QTest::newRow("displaced + moveDisplaced")
+ << true << true
+ << false << false
+ << true << true
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + moveDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << true << false
+ << false << false
+ << ListChange::move(0, 10, 1) << ListRange(1, 10);
+
+ QTest::newRow("displaced + removeDisplaced")
+ << true << true
+ << false << false
+ << false << false
+ << true << true
+ << ListChange::remove(0, 1) << ListRange(1, 16);
+
+ QTest::newRow("displaced + removeDisplaced (not enabled)")
+ << true << true
+ << false << false
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 16);
+
+
+ QTest::newRow("displaced + add, should use generic displaced for a remove")
+ << true << true
+ << true << true
+ << false << false
+ << true << false
+ << ListChange::remove(0, 1) << ListRange(1, 16);
+}
+
void tst_QQuickListView::multipleTransitions()
{
+ QSKIP("QTBUG-24523");
+
// Tests that if you interrupt a transition in progress with another action that
// cancels the previous transition, the resulting items are still placed correctly.
QFETCH(int, initialCount);
QFETCH(qreal, contentY);
QFETCH(QList<ListChange>, changes);
+ QFETCH(bool, rippleAddDisplaced);
- // add transitions on the left, moves on the right
QPointF addTargets_transitionFrom(-50, -50);
QPointF addDisplaced_transitionFrom(-50, 50);
QPointF moveTargets_transitionFrom(50, -50);
QPointF moveDisplaced_transitionFrom(50, 50);
+ QPointF removeTargets_transitionTo(-100, 300);
+ QPointF removeDisplaced_transitionFrom(100, 300);
QmlListModel model;
for (int i = 0; i < initialCount; i++)
@@ -5536,8 +5809,12 @@ void tst_QQuickListView::multipleTransitions()
ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
+ ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo);
+ ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom);
+ ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced);
canvas->setSource(testFileUrl("multipleTransitions.qml"));
canvas->show();
+ QTest::qWaitForWindowShown(canvas);
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
@@ -5545,6 +5822,11 @@ void tst_QQuickListView::multipleTransitions()
QVERIFY(contentItem != 0);
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
QList<QPair<QString, QString> > targetItems;
@@ -5604,20 +5886,9 @@ void tst_QQuickListView::multipleTransitions()
}
QCOMPARE(listview->count(), model.count());
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QQmlExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
// verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i < model.count() && i < items.count(); ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
QTRY_COMPARE(item->x(), 0.0);
@@ -5636,18 +5907,21 @@ void tst_QQuickListView::multipleTransitions_data()
QTest::addColumn<int>("initialCount");
QTest::addColumn<qreal>("contentY");
QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<bool>("rippleAddDisplaced");
// the added item and displaced items should move to final dest correctly
QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
<< ListChange::insert(0, 1)
<< ListChange::move(0, 3, 1)
- );
+ )
+ << false;
// items affected by the add should change from move to add transition
QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
<< ListChange::move(1, 10, 3)
<< ListChange::insert(0, 1)
- );
+ )
+ << false;
// items should be placed correctly if you trigger a transition then refill for that index
QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
@@ -5655,7 +5929,14 @@ void tst_QQuickListView::multipleTransitions_data()
<< ListChange::setContentY(80.0)
<< ListChange::setContentY(0.0)
<< ListChange::insert(0, 1)
- );
+ )
+ << false;
+
+ QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(1, 1)
+ << ListChange::remove(1, 1)
+ )
+ << true;
}
QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
diff --git a/tests/auto/quick/qquickpositioners/data/transitions.qml b/tests/auto/quick/qquickpositioners/data/transitions.qml
new file mode 100644
index 0000000000..54f5705c68
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/data/transitions.qml
@@ -0,0 +1,196 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 500
+
+ property int duration: 50
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ function checkPos(x, y, name) {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+
+ Transition {
+ id: targetTransition
+ enabled: enableAddTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ root.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ root.targetTrans_targetItems.push(root.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: root.targetTransitionsDone += 1 }
+ }
+ }
+
+ Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ root.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ root.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ root.displacedTrans_targetItems.push(root.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: root.displaceTransitionsDone += 1 }
+ }
+
+ }
+
+ Row {
+ objectName: "row"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+
+ Column {
+ objectName: "column"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+
+ Grid {
+ objectName: "grid"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.y }
+ }
+
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+
+ Flow {
+ objectName: "flow"
+
+ property int count: children.length - 1 // omit Repeater
+
+ x: 50; y: 50
+ width: 400; height: 400
+ Repeater {
+ objectName: "repeater"
+ Rectangle {
+ property string nameData: name
+ objectName: "wrapper"
+ width: 30 + index*5
+ height: 30 + index*5
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text { objectName: "name"; text: name }
+ Text { text: parent.parent.x + " " + parent.parent.y }
+ }
+ onXChanged: root.checkPos(x, y, name)
+ onYChanged: root.checkPos(x, y, name)
+ }
+ }
+
+ add: targetTransition
+ move: displaced
+ }
+}
+
diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
index 56fe465901..563379652b 100644
--- a/tests/auto/quick/qquickpositioners/qquickpositioners.pro
+++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
@@ -2,6 +2,7 @@ CONFIG += testcase
TARGET = tst_qquickpositioners
SOURCES += tst_qquickpositioners.cpp
+include (../shared/util.pri)
include (../../shared/util.pri)
macx:CONFIG -= app_bundle
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index ecc4c80b2a..8f517a4fe3 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -47,8 +47,13 @@
#include <QtQuick/private/qquicktransition_p.h>
#include <private/qquickitem_p.h>
#include <qqmlexpression.h>
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
#include "../../shared/util.h"
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
class tst_qquickpositioners : public QQmlDataTest
{
Q_OBJECT
@@ -88,11 +93,145 @@ private slots:
void test_attachedproperties();
void test_attachedproperties_data();
void test_attachedproperties_dynamic();
+ void addTransitions_row();
+ void addTransitions_row_data();
+ void addTransitions_column();
+ void addTransitions_column_data();
+ void addTransitions_grid();
+ void addTransitions_grid_data();
+ void addTransitions_flow();
+ void addTransitions_flow_data();
+ void moveTransitions_row();
+ void moveTransitions_row_data();
+ void moveTransitions_column();
+ void moveTransitions_column_data();
+ void moveTransitions_grid();
+ void moveTransitions_grid_data();
+ void moveTransitions_flow();
+ void moveTransitions_flow_data();
private:
QQuickView *createView(const QString &filename, bool wait=true);
+
+ void addTransitions(const QString &positionerObjectName);
+ void addTransitions_data();
+ void moveTransitions(const QString &positionerObjectName);
+ void moveTransitions_data();
+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
+ void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
+ void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
+ void checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize);
};
+void tst_qquickpositioners::addTransitions_row()
+{
+ addTransitions("row");
+}
+
+void tst_qquickpositioners::addTransitions_row_data()
+{
+ addTransitions_data();
+}
+
+void tst_qquickpositioners::addTransitions_column()
+{
+ addTransitions("column");
+}
+
+void tst_qquickpositioners::addTransitions_column_data()
+{
+ addTransitions_data();
+}
+
+void tst_qquickpositioners::addTransitions_grid()
+{
+ addTransitions("grid");
+}
+
+void tst_qquickpositioners::addTransitions_grid_data()
+{
+ // don't use addTransitions_data() because grid displaces items differently
+ // (adding items further down the grid can cause displace transitions at
+ // previous indexes, since grid is auto-resized to tightly fit all of its items)
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9);
+ QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7);
+
+ QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9);
+ QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9);
+}
+
+void tst_qquickpositioners::addTransitions_flow()
+{
+ addTransitions("flow");
+}
+
+void tst_qquickpositioners::addTransitions_flow_data()
+{
+ addTransitions_data();
+}
+
+void tst_qquickpositioners::moveTransitions_row()
+{
+ moveTransitions("row");
+}
+
+void tst_qquickpositioners::moveTransitions_row_data()
+{
+ moveTransitions_data();
+}
+
+void tst_qquickpositioners::moveTransitions_column()
+{
+ moveTransitions("column");
+}
+
+void tst_qquickpositioners::moveTransitions_column_data()
+{
+ moveTransitions_data();
+}
+
+void tst_qquickpositioners::moveTransitions_grid()
+{
+ moveTransitions("grid");
+}
+
+void tst_qquickpositioners::moveTransitions_grid_data()
+{
+ // don't use moveTransitions_data() because grid displaces items differently
+ // (removing items further down the grid can cause displace transitions at
+ // previous indexes, since grid is auto-resized to tightly fit all of its items)
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9);
+ QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7);
+
+ QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9);
+ QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6);
+}
+
+void tst_qquickpositioners::moveTransitions_flow()
+{
+ moveTransitions("flow");
+}
+
+void tst_qquickpositioners::moveTransitions_flow_data()
+{
+ moveTransitions_data();
+}
+
tst_qquickpositioners::tst_qquickpositioners()
{
}
@@ -370,6 +509,285 @@ void tst_qquickpositioners::test_horizontal_animated_disabled()
delete canvas;
}
+void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, insertionIndex);
+ QFETCH(int, insertionCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QPointF targetItems_transitionFrom(-50, -50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = QQuickViewTestUtil::createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("enableAddTransition", true);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFile("transitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ QQuickItem *positioner = canvas->rootObject()->findChild<QQuickItem*>(positionerObjectName);
+ QVERIFY(positioner);
+ positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
+
+ QList<QPair<QString, QString> > targetData;
+ QList<int> targetIndexes;
+ for (int i=0; i<model.count(); i++) {
+ targetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
+
+ // check initial add transition
+ // (positioners run the add transition on all items that are initially created for the view)
+ QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), initialItemCount);
+ QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), 0);
+ model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems);
+
+ model_targetItems_transitionFrom.clear();
+ canvas->rootObject()->setProperty("targetTransitionsDone", 0);
+ canvas->rootObject()->setProperty("targetTrans_items", QVariantMap());
+ canvas->rootObject()->setProperty("targetTrans_targetIndexes", QVariantList());
+ canvas->rootObject()->setProperty("targetTrans_targetItems", QVariantList());
+
+ // do insertion
+ targetData.clear();
+ targetIndexes.clear();
+ for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
+ targetData << qMakePair(QString("New item %1").arg(i), QString(""));
+ targetIndexes << i;
+ }
+ model.insertItems(insertionIndex, targetData);
+ QTRY_COMPARE(model.count(), positioner->property("count").toInt());
+
+ targetItems = findItems<QQuickItem>(positioner, "wrapper", targetIndexes);
+
+ QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), targetData.count());
+ QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
+ matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(canvas->rootObject()->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ checkItemPositions(positioner, &model, 5.0); // XXX fetch from qml?
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::addTransitions_data()
+{
+ // If this data changes, update addTransitions_grid_data() also
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(5, 9);
+ QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange();
+
+ QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(5, 9);
+ QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange();
+}
+
+void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(ListChange, change);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ QPointF targetItems_transitionFrom(-50, -50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = QQuickViewTestUtil::createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("enableAddTransition", false);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFile("transitions.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ QQuickItem *positioner = canvas->rootObject()->findChild<QQuickItem*>(positionerObjectName);
+ QVERIFY(positioner);
+ positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
+ QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+
+ switch (change.type) {
+ case ListChange::Removed:
+ model.removeItems(change.index, change.count);
+ QTRY_COMPARE(model.count(), positioner->property("count").toInt());
+ break;
+ case ListChange::Moved:
+ model.moveItems(change.index, change.to, change.count);
+ QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+ break;
+ case ListChange::Inserted:
+ case ListChange::SetCurrent:
+ case ListChange::SetContentY:
+ QVERIFY(false);
+ break;
+ }
+
+ QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count());
+ QCOMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), 0);
+
+ // check the target and displaced items were animated
+ QCOMPARE(model_targetItems_transitionFrom.count(), 0);
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ QCOMPARE(canvas->rootObject()->property("targetTrans_items").toMap().count(), 0);
+ QCOMPARE(canvas->rootObject()->property("targetTrans_targetIndexes").toList().count(), 0);
+ QCOMPARE(canvas->rootObject()->property("targetTrans_targetItems").toList().count(), 0);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes;
+ if (change.type == ListChange::Inserted)
+ displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count);
+ else if (change.type == ListChange::Moved)
+ displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, change.index, change.to, change.count);
+ else if (change.type == ListChange::Removed)
+ displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count);
+ else
+ QVERIFY(false);
+ matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes);
+
+ QVariantList listOfEmptyIntLists;
+ for (int i=0; i<displacedIndexes.count(); i++)
+ listOfEmptyIntLists << QVariant::fromValue(QList<int>());
+ QCOMPARE(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), listOfEmptyIntLists);
+ QVariantList listOfEmptyObjectLists;
+ for (int i=0; i<displacedIndexes.count(); i++)
+ listOfEmptyObjectLists.insert(listOfEmptyObjectLists.count(), QVariantList());
+ QCOMPARE(canvas->rootObject()->property("displacedTrans_targetItems").toList(), listOfEmptyObjectLists);
+ }
+
+ checkItemPositions(positioner, &model, 5.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::moveTransitions_data()
+{
+ // If this data changes, update moveTransitions_grid_data() also
+
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<ListChange>("change");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9);
+ QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(5, 9);
+ QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange();
+
+ QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9);
+ QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(7, 9);
+ QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange();
+}
+
+
+void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize)
+{
+ QVERIFY(model->count() > 0);
+ qreal padding = 0;
+ qreal currentSize = 30;
+ qreal rowX = 0;
+ qreal rowY = 0;
+
+ for (int i=0; i<model->count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(positioner, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QCOMPARE(item->width(), currentSize);
+ QCOMPARE(item->height(), currentSize);
+
+ if (qobject_cast<QQuickRow*>(positioner)) {
+ QCOMPARE(item->x(), (i * 30.0) + padding);
+ QCOMPARE(item->y(), 0.0);
+ } else if (qobject_cast<QQuickColumn*>(positioner)) {
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), (i * 30.0) + padding);
+ } else if (qobject_cast<QQuickGrid*>(positioner)) {
+ int columns = 4;
+ int rows = qCeil(model->count() / qreal(columns));
+ int lastMatchingRowIndex = (rows * columns) - (columns - i%columns);
+ if (lastMatchingRowIndex >= model->count())
+ lastMatchingRowIndex -= columns;
+ if (i % columns > 0) {
+ QQuickItem *finalAlignedRowItem = findItem<QQuickItem>(positioner, "wrapper", lastMatchingRowIndex);
+ QVERIFY(finalAlignedRowItem);
+ QCOMPARE(item->x(), finalAlignedRowItem->x());
+ } else {
+ QCOMPARE(item->x(), 0.0);
+ }
+ if (i / columns > 0) {
+ QQuickItem *prevRowLastItem = findItem<QQuickItem>(positioner, "wrapper", (i/columns * columns) - 1);
+ QVERIFY(prevRowLastItem);
+ QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height());
+ } else {
+ QCOMPARE(item->y(), 0.0);
+ }
+ } else if (qobject_cast<QQuickFlow*>(positioner)) {
+ if (rowX + item->width() > positioner->width()) {
+ QQuickItem *prevItem = findItem<QQuickItem>(positioner, "wrapper", i-1);
+ QVERIFY(prevItem);
+ rowX = 0;
+ rowY = prevItem->y() + prevItem->height();
+ }
+ QCOMPARE(item->x(), rowX);
+ QCOMPARE(item->y(), rowY);
+ rowX += item->width();
+ } else {
+ QVERIFY2(false, "Unknown positioner type");
+ }
+ QQuickText *name = findItem<QQuickText>(positioner, "name", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model->name(i));
+
+ padding += i * incrementalSize;
+ currentSize += incrementalSize;
+ }
+}
+
void tst_qquickpositioners::test_vertical()
{
QQuickView *canvas = createView(testFile("vertical.qml"));
@@ -1466,6 +1884,43 @@ QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait
return canvas;
}
+void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
+{
+ for (int i=0; i<indexLists.count(); i++) {
+ QSet<int> current = indexLists[i].value<QList<int> >().toSet();
+ if (current != expectedIndexes.toSet())
+ qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
+ QCOMPARE(current, expectedIndexes.toSet());
+ }
+}
+
+void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
+{
+ for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
+ QVERIFY(it.value().type() == QVariant::Int);
+ QString name = it.key();
+ int itemIndex = it.value().toInt();
+ QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ if (model.name(itemIndex) != name)
+ qDebug() << itemIndex;
+ QCOMPARE(model.name(itemIndex), name);
+ }
+ QCOMPARE(items.count(), expectedIndexes.count());
+}
+
+void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
+{
+ for (int i=0; i<itemLists.count(); i++) {
+ QVERIFY(itemLists[i].type() == QVariant::List);
+ QVariantList current = itemLists[i].toList();
+ for (int j=0; j<current.count(); j++) {
+ QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
+ QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ }
+ QCOMPARE(current.count(), expectedItems.count());
+ }
+}
QTEST_MAIN(tst_qquickpositioners)
diff --git a/tests/auto/quick/qquickspritesequence/data/advance.qml b/tests/auto/quick/qquickspritesequence/data/advance.qml
new file mode 100644
index 0000000000..5866dcbfac
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/data/advance.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ SpriteSequence {
+ objectName: "sprite"
+ sprites: [Sprite {
+ name: "firstState"
+ source: "squarefacesprite.png"
+ frameCount: 3
+ frameSync: true
+ to: {"secondState":1}
+ }, Sprite {
+ name: "secondState"
+ source: "squarefacesprite.png"
+ frameCount: 6
+ frameSync: true
+ } ]
+ width: 160
+ height: 160
+ }
+}
diff --git a/tests/auto/quick/qquickspritesequence/data/basic.qml b/tests/auto/quick/qquickspritesequence/data/basic.qml
new file mode 100644
index 0000000000..5eb7475f11
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/data/basic.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ SpriteSequence {
+ objectName: "sprite"
+ sprites: Sprite {
+ name: "happy"
+ source: "squarefacesprite.png"
+ frameCount: 6
+ frameDuration: 120
+ }
+ width: 160
+ height: 160
+ }
+}
diff --git a/tests/auto/quick/qquickspritesequence/data/squarefacesprite.png b/tests/auto/quick/qquickspritesequence/data/squarefacesprite.png
new file mode 100644
index 0000000000..f9a5d5fcce
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/data/squarefacesprite.png
Binary files differ
diff --git a/tests/auto/quick/qquickspritesequence/qquickspritesequence.pro b/tests/auto/quick/qquickspritesequence/qquickspritesequence.pro
new file mode 100644
index 0000000000..3dabd065a0
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/qquickspritesequence.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickspritesequence
+SOURCES += tst_qquickspritesequence.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp
new file mode 100644
index 0000000000..8469a949c6
--- /dev/null
+++ b/tests/auto/quick/qquickspritesequence/tst_qquickspritesequence.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+#include <QtQuick/qquickview.h>
+#include <private/qquickspritesequence_p.h>
+
+class tst_qquickspritesequence : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickspritesequence(){}
+
+private slots:
+ void test_properties();
+ void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine
+};
+
+void tst_qquickspritesequence::test_properties()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("basic.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteSequence* sprite = canvas->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(sprite->running());
+ QVERIFY(sprite->interpolate());
+
+ sprite->setRunning(false);
+ QVERIFY(!sprite->running());
+ sprite->setInterpolate(false);
+ QVERIFY(!sprite->interpolate());
+
+ delete canvas;
+}
+
+void tst_qquickspritesequence::test_framerateAdvance()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("advance.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteSequence* sprite = canvas->rootObject()->findChild<QQuickSpriteSequence*>("sprite");
+ QVERIFY(sprite);
+
+ QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickspritesequence)
+
+#include "tst_qquickspritesequence.moc"
diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
index 86874b84fd..35ce724a64 100644
--- a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
+++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
@@ -88,68 +88,69 @@ void tst_qquickstyledtext::textOutput_data()
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("output");
QTest::addColumn<FormatList>("formats");
-
- QTest::newRow("bold") << "<b>bold</b>" << "bold" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("italic") << "<i>italic</i>" << "italic" << (FormatList() << Format(Format::Italic, 0, 6));
- QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9));
- QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6));
- QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9));
- QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("missing </b>") << "<b>text" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("nested") << "<b>text <i>italic</i> bold</b>" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5));
- QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6));
- QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text" << (FormatList() << Format(0, 0, 8));
- QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text" << (FormatList() << Format(0, 0, 8));
- QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text" << (FormatList() << Format(0, 0, 4));
- QTest::newRow("font empty") << "<font>text</font>" << "text" << FormatList();
- QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text" << FormatList();
- QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "" << FormatList();
- QTest::newRow("extra close") << "<b>text</b></b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("extra space") << "<b >text</b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("entities") << "&lt;b&gt;this &amp; that&lt;/b&gt;" << "<b>this & that</b>" << FormatList();
- QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("paragraph") << "text<p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("paragraph closed") << "text<p>more text</p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("paragraph closed bold") << "<b>text<p>more text</p>more text</b>" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24));
- QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("empty") << "" << "" << FormatList();
- QTest::newRow("unknown tag") << "<a href='#'><foo>underline</foo></a> not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9));
- QTest::newRow("ordered list") << "<ol><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList();
- QTest::newRow("ordered list closed") << "<ol><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list alpha") << "<ol type=\"a\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list upper alpha") << "<ol type=\"A\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list roman") << "<ol type=\"i\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list upper roman") << "<ol type=\"I\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list bad") << "<ol type=\"z\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list") << "<ul><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList();
- QTest::newRow("unordered list closed") << "<ul><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list disc") << "<ul type=\"disc\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list square") << "<ul type=\"square\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("header close") << "<h1>head</h1>more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h0") << "<h0>head" << "head" << FormatList();
- QTest::newRow("h1") << "<h1>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h2") << "<h2>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h3") << "<h3>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h4") << "<h4>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h5") << "<h5>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h6") << "<h6>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h7") << "<h7>head" << "head" << FormatList();
- QTest::newRow("pre") << "normal<pre>pre text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9));
- QTest::newRow("pre lb") << "normal<pre>pre\n text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10));
- QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList();
- QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList();
- QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList();
- QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList();
- QTest::newRow("space after newline") << "text<br/> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("space after paragraph") << "text<p> more text</p> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("space in header") << "<h1> head</h1> " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("space before bold") << "this is <b>bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4));
- QTest::newRow("space leading bold") << "this is<b> bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5));
- QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5));
- QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList();
+ QTest::addColumn<bool>("modifiesFontSize");
+
+ QTest::newRow("bold") << "<b>bold</b>" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("italic") << "<i>italic</i>" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)) << false;
+ QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
+ QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)) << false;
+ QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
+ QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("missing </b>") << "<b>text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("nested") << "<b>text <i>italic</i> bold</b>" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)) << false;
+ QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)) << false;
+ QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text" << (FormatList() << Format(0, 0, 8)) << false;
+ QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text" << (FormatList() << Format(0, 0, 8)) << false;
+ QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text" << (FormatList() << Format(0, 0, 4)) << true;
+ QTest::newRow("font empty") << "<font>text</font>" << "text" << FormatList() << false;
+ QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text" << FormatList() << false;
+ QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "" << FormatList() << false;
+ QTest::newRow("extra close") << "<b>text</b></b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("extra space") << "<b >text</b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false;
+ QTest::newRow("entities") << "&lt;b&gt;this &amp; that&lt;/b&gt;" << "<b>this & that</b>" << FormatList() << false;
+ QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("paragraph") << "text<p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("paragraph closed") << "text<p>more text</p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("paragraph closed bold") << "<b>text<p>more text</p>more text</b>" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)) << false;
+ QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("empty") << "" << "" << FormatList() << false;
+ QTest::newRow("unknown tag") << "<a href='#'><foo>underline</foo></a> not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)) << false;
+ QTest::newRow("ordered list") << "<ol><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false;
+ QTest::newRow("ordered list closed") << "<ol><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list alpha") << "<ol type=\"a\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list upper alpha") << "<ol type=\"A\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list roman") << "<ol type=\"i\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list upper roman") << "<ol type=\"I\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("ordered list bad") << "<ol type=\"z\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list") << "<ul><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false;
+ QTest::newRow("unordered list closed") << "<ul><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list disc") << "<ul type=\"disc\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list square") << "<ul type=\"square\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false;
+ QTest::newRow("header close") << "<h1>head</h1>more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h0") << "<h0>head" << "head" << FormatList() << false;
+ QTest::newRow("h1") << "<h1>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h2") << "<h2>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h3") << "<h3>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h4") << "<h4>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h5") << "<h5>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h6") << "<h6>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("h7") << "<h7>head" << "head" << FormatList() << false;
+ QTest::newRow("pre") << "normal<pre>pre text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)) << false;
+ QTest::newRow("pre lb") << "normal<pre>pre\n text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)) << false;
+ QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList() << false;
+ QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList() << false;
+ QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList() << false;
+ QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList() << false;
+ QTest::newRow("space after newline") << "text<br/> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("space after paragraph") << "text<p> more text</p> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false;
+ QTest::newRow("space in header") << "<h1> head</h1> " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)) << true;
+ QTest::newRow("space before bold") << "this is <b>bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)) << false;
+ QTest::newRow("space leading bold") << "this is<b> bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)) << false;
+ QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)) << false;
+ QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList() << false;
}
void tst_qquickstyledtext::textOutput()
@@ -157,10 +158,12 @@ void tst_qquickstyledtext::textOutput()
QFETCH(QString, input);
QFETCH(QString, output);
QFETCH(FormatList, formats);
+ QFETCH(bool, modifiesFontSize);
QTextLayout layout;
QList<QQuickStyledTextImgTag*> imgTags;
- QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false);
+ bool fontSizeModified = false;
+ QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
QCOMPARE(layout.text(), output);
@@ -177,6 +180,7 @@ void tst_qquickstyledtext::textOutput()
QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
}
+ QCOMPARE(fontSizeModified, modifiesFontSize);
}
diff --git a/tests/auto/quick/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
index 20f7535365..84f7ce8d50 100644
--- a/tests/auto/quick/qquicktext/data/fontSizeMode.qml
+++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
@@ -19,6 +19,4 @@ Item {
font.pixelSize: 30
font.family: "Helvetica"
}
-
- TextInput { focus: true; objectName: "input" }
}
diff --git a/tests/auto/quick/qquicktext/data/multilengthStrings.qml b/tests/auto/quick/qquicktext/data/multilengthStrings.qml
index d26576eacd..6b9dc71fbc 100644
--- a/tests/auto/quick/qquicktext/data/multilengthStrings.qml
+++ b/tests/auto/quick/qquicktext/data/multilengthStrings.qml
@@ -7,7 +7,7 @@ Item {
Text {
id: myText
objectName: "myText"
- width: 100
+ width: 60
font.pixelSize: 15
font.family: "Helvetica"
}
diff --git a/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
index 0da9bc353a..21f1b20619 100644
--- a/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
+++ b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
@@ -7,7 +7,7 @@ Item {
Text {
id: myText
objectName: "myText"
- width: 100
+ width: 60
height: 36
font.pixelSize: 15
font.family: "Helvetica"
diff --git a/tests/auto/quick/qquicktext/data/multilineelide.qml b/tests/auto/quick/qquicktext/data/multilineelide.qml
index f3bb65775b..ffca0d638a 100644
--- a/tests/auto/quick/qquicktext/data/multilineelide.qml
+++ b/tests/auto/quick/qquicktext/data/multilineelide.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
Text {
- width: 200; height: 200
+ width: 200
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: 3
diff --git a/tests/auto/quick/qquicktext/data/pixelFontSizes.qml b/tests/auto/quick/qquicktext/data/pixelFontSizes.qml
new file mode 100644
index 0000000000..e3d81b682e
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/pixelFontSizes.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 200
+
+ property variant pixelSize: 6
+
+ Text {
+ objectName: "text"
+ font.pixelSize: parent.pixelSize
+ text: "This is<br/>a font<br/> size test."
+ }
+
+ Text {
+ x: 200
+ objectName: "textWithTag"
+ font.pixelSize: parent.pixelSize
+ text: "This is <h4>a font</h4> size test."
+ }
+}
diff --git a/tests/auto/quick/qquicktext/data/pointFontSizes.qml b/tests/auto/quick/qquicktext/data/pointFontSizes.qml
new file mode 100644
index 0000000000..6feb8fecf8
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/pointFontSizes.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 200
+
+ property variant pointSize: 6
+
+ Text {
+ objectName: "text"
+ font.pointSize: parent.pointSize
+ text: "This is<br/>a font<br/> size test."
+ }
+
+ Text {
+ x: 200
+ objectName: "textWithTag"
+ font.pointSize: parent.pointSize
+ text: "This is <h4>a font</h4> size test."
+ }
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 754395dba1..54b5a04466 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -58,6 +58,8 @@
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+Q_DECLARE_METATYPE(QQuickText::TextFormat)
+
class tst_qquicktext : public QQmlDataTest
{
Q_OBJECT
@@ -69,6 +71,7 @@ private slots:
void width();
void wrap();
void elide();
+ void multilineElide_data();
void multilineElide();
void textFormat();
@@ -122,6 +125,8 @@ private slots:
void fontSizeModeMultiline();
void multilengthStrings_data();
void multilengthStrings();
+ void fontFormatSizes_data();
+ void fontFormatSizes();
private:
QStringList standard;
@@ -293,11 +298,10 @@ void tst_qquicktext::width()
layout.endLayout();
- metricWidth = qCeil(layout.boundingRect().width());
+ metricWidth = layout.boundingRect().width();
} else {
QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = qCeil(metricWidth);
+ metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
}
QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
@@ -325,8 +329,9 @@ void tst_qquicktext::width()
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->extra.isAllocated());
- QTextDocument *doc = textPrivate->textDocument();
+ QTextDocument *doc = textPrivate->extra->doc;
QVERIFY(doc != 0);
QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
@@ -438,10 +443,12 @@ void tst_qquicktext::elide()
QCOMPARE(textObject->elideMode(), m);
QCOMPARE(textObject->width(), 100.);
+ if (m != QQuickText::ElideNone && !standard.at(i).contains('\n'))
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+
delete textObject;
}
- // richtext - does nothing
for (int i = 0; i < richText.size(); i++)
{
QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
@@ -452,23 +459,41 @@ void tst_qquicktext::elide()
QCOMPARE(textObject->elideMode(), m);
QCOMPARE(textObject->width(), 100.);
+ if (m != QQuickText::ElideNone && standard.at(i).contains("<br>"))
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+
delete textObject;
}
}
}
+void tst_qquicktext::multilineElide_data()
+{
+ QTest::addColumn<QQuickText::TextFormat>("format");
+ QTest::newRow("plain") << QQuickText::PlainText;
+ QTest::newRow("styled") << QQuickText::StyledText;
+}
+
void tst_qquicktext::multilineElide()
{
+ QFETCH(QQuickText::TextFormat, format);
QQuickView *canvas = createView(testFile("multilineelide.qml"));
QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
QVERIFY(myText != 0);
+ myText->setTextFormat(format);
QCOMPARE(myText->lineCount(), 3);
QCOMPARE(myText->truncated(), true);
qreal lineHeight = myText->contentHeight() / 3.;
+ // Set a valid height greater than the truncated content height and ensure the line count is
+ // unchanged.
+ myText->setHeight(200);
+ QCOMPARE(myText->lineCount(), 3);
+ QCOMPARE(myText->truncated(), true);
+
// reduce size and ensure fewer lines are drawn
myText->setHeight(lineHeight * 2);
QCOMPARE(myText->lineCount(), 2);
@@ -670,19 +695,20 @@ void tst_qquicktext::horizontalAlignment_RightToLeft()
// implicitly aligned rich text should follow the reading direction of text
QCOMPARE(text->hAlign(), QQuickText::AlignRight);
QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
+ QVERIFY(textPrivate->extra.isAllocated());
+ QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft);
// explicitly left aligned rich text
text->setHAlign(QQuickText::AlignLeft);
QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight);
+ QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignRight);
// explicitly right aligned rich text
text->setHAlign(QQuickText::AlignRight);
QCOMPARE(text->hAlign(), QQuickText::AlignRight);
QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
+ QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft);
text->setText(textString);
text->setTextFormat(QQuickText::PlainText);
@@ -1616,8 +1642,7 @@ void tst_qquicktext::lineLaidOut()
QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
QVERIFY(textPrivate != 0);
- QTextDocument *doc = textPrivate->textDocument();
- QVERIFY(doc == 0);
+ QVERIFY(!textPrivate->extra.isAllocated());
#if defined(Q_OS_MAC)
QVERIFY(myText->lineCount() == textPrivate->linesRects.count());
@@ -1835,17 +1860,15 @@ void tst_qquicktext::imgTagsError()
void tst_qquicktext::fontSizeMode_data()
{
QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("canElide");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true;
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << false;
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog";
+ QTest::newRow("styled") << "<b>The quick red fox jumped over the lazy brown dog</b>";
}
void tst_qquicktext::fontSizeMode()
{
QFETCH(QString, text);
- QFETCH(bool, canElide);
- QQuickView *canvas = createView(testFile("fontSizeMode.qml"));
+ QScopedPointer<QQuickView> canvas(createView(testFile("fontSizeMode.qml")));
canvas->show();
QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
@@ -1873,29 +1896,27 @@ void tst_qquicktext::fontSizeMode()
QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
QVERIFY(horizontalFitHeight <= myText->height() + 2);
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::VerticalFit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1905,29 +1926,27 @@ void tst_qquicktext::fontSizeMode()
QVERIFY(verticalFitHeight <= myText->height() + 2);
QVERIFY(verticalFitHeight > originalHeight);
- if (canElide) {
- // Elide won't affect the height of a single line with VerticalFit but will crop the width.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ // Elide won't affect the height of a single line with VerticalFit but will crop the width.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::Fit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1935,29 +1954,27 @@ void tst_qquicktext::fontSizeMode()
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setWrapMode(QQuickText::Wrap);
@@ -1977,17 +1994,15 @@ void tst_qquicktext::fontSizeMode()
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::VerticalFit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -1998,17 +2013,15 @@ void tst_qquicktext::fontSizeMode()
QVERIFY(verticalFitHeight <= myText->height() + 2);
QVERIFY(verticalFitHeight < originalHeight);
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::Fit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2016,17 +2029,15 @@ void tst_qquicktext::fontSizeMode()
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setMaximumLineCount(2);
@@ -2043,17 +2054,15 @@ void tst_qquicktext::fontSizeMode()
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::VerticalFit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2064,17 +2073,15 @@ void tst_qquicktext::fontSizeMode()
QVERIFY(verticalFitHeight <= myText->height() + 2);
QVERIFY(verticalFitHeight < originalHeight);
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::Fit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2082,33 +2089,29 @@ void tst_qquicktext::fontSizeMode()
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
}
void tst_qquicktext::fontSizeModeMultiline_data()
{
QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("canElide");
- QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true;
- QTest::newRow("richtext") << "<b>The quick red fox jumped<br/> over the lazy brown dog</b>" << false;
+ QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog";
+ QTest::newRow("styledtext") << "<b>The quick red fox jumped<br/> over the lazy brown dog</b>";
}
void tst_qquicktext::fontSizeModeMultiline()
{
QFETCH(QString, text);
- QFETCH(bool, canElide);
- QQuickView *canvas = createView(testFile("fontSizeMode.qml"));
+ QScopedPointer<QQuickView> canvas(createView(testFile("fontSizeMode.qml")));
canvas->show();
QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
@@ -2138,31 +2141,29 @@ void tst_qquicktext::fontSizeModeMultiline()
QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
QVERIFY(horizontalFitHeight > myText->height());
- if (canElide) {
- // Right eliding will remove the last line
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QCOMPARE(myText->lineCount(), 1);
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- // Left or middle eliding wont have any effect.
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ // Right eliding will remove the last line
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QCOMPARE(myText->lineCount(), 1);
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ // Left or middle eliding wont have any effect.
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::VerticalFit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2172,30 +2173,28 @@ void tst_qquicktext::fontSizeModeMultiline()
QVERIFY(verticalFitWidth <= myText->width() + 2);
QVERIFY(verticalFitHeight <= myText->height() + 2);
- if (canElide) {
- // Elide will have no effect.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ // Elide will have no effect.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::Fit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2203,29 +2202,27 @@ void tst_qquicktext::fontSizeModeMultiline()
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setWrapMode(QQuickText::Wrap);
@@ -2245,17 +2242,15 @@ void tst_qquicktext::fontSizeModeMultiline()
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- if (canElide) {
- // Text will be elided vertically with HorizontalFit
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
+ // Text will be elided vertically with HorizontalFit
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::VerticalFit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2266,17 +2261,15 @@ void tst_qquicktext::fontSizeModeMultiline()
QVERIFY(verticalFitHeight <= myText->height() + 2);
QVERIFY(verticalFitHeight < originalHeight);
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::Fit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2284,17 +2277,15 @@ void tst_qquicktext::fontSizeModeMultiline()
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setMaximumLineCount(2);
@@ -2311,17 +2302,15 @@ void tst_qquicktext::fontSizeModeMultiline()
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::VerticalFit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2332,17 +2321,15 @@ void tst_qquicktext::fontSizeModeMultiline()
QVERIFY(verticalFitHeight <= myText->height() + 2);
QVERIFY(verticalFitHeight < originalHeight);
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
myText->setFontSizeMode(QQuickText::Fit);
QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
@@ -2350,17 +2337,15 @@ void tst_qquicktext::fontSizeModeMultiline()
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
}
void tst_qquicktext::multilengthStrings_data()
@@ -2414,9 +2399,6 @@ void tst_qquicktext::multilengthStrings()
QCOMPARE(myText->contentWidth(), mediumWidth);
QCOMPARE(myText->contentHeight(), mediumHeight);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue);
-#endif
QCOMPARE(myText->truncated(), true);
myText->setSize(QSizeF(shortWidth, shortHeight));
@@ -2427,6 +2409,76 @@ void tst_qquicktext::multilengthStrings()
QCOMPARE(myText->truncated(), true);
}
+void tst_qquicktext::fontFormatSizes_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("textWithTag");
+ QTest::addColumn<bool>("fontIsBigger");
+
+ QTest::newRow("fs1") << "Hello world!" << "Hello <font size=\"1\">world</font>!" << false;
+ QTest::newRow("fs2") << "Hello world!" << "Hello <font size=\"2\">world</font>!" << false;
+ QTest::newRow("fs3") << "Hello world!" << "Hello <font size=\"3\">world</font>!" << false;
+ QTest::newRow("fs4") << "Hello world!" << "Hello <font size=\"4\">world</font>!" << true;
+ QTest::newRow("fs5") << "Hello world!" << "Hello <font size=\"5\">world</font>!" << true;
+ QTest::newRow("fs6") << "Hello world!" << "Hello <font size=\"6\">world</font>!" << true;
+ QTest::newRow("fs7") << "Hello world!" << "Hello <font size=\"7\">world</font>!" << true;
+ QTest::newRow("h1") << "This is<br/>a font<br/> size test." << "This is <h1>a font</h1> size test." << true;
+ QTest::newRow("h2") << "This is<br/>a font<br/> size test." << "This is <h2>a font</h2> size test." << true;
+ QTest::newRow("h3") << "This is<br/>a font<br/> size test." << "This is <h3>a font</h3> size test." << true;
+ QTest::newRow("h4") << "This is<br/>a font<br/> size test." << "This is <h4>a font</h4> size test." << true;
+ QTest::newRow("h5") << "This is<br/>a font<br/> size test." << "This is <h5>a font</h5> size test." << false;
+ QTest::newRow("h6") << "This is<br/>a font<br/> size test." << "This is <h6>a font</h6> size test." << false;
+}
+
+void tst_qquicktext::fontFormatSizes()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, textWithTag);
+ QFETCH(bool, fontIsBigger);
+
+ QQuickView *view = new QQuickView;
+ {
+ view->setSource(testFileUrl("pointFontSizes.qml"));
+ view->show();
+
+ QQuickText *qtext = view->rootObject()->findChild<QQuickText*>("text");
+ QQuickText *qtextWithTag = view->rootObject()->findChild<QQuickText*>("textWithTag");
+ QVERIFY(qtext != 0);
+ QVERIFY(qtextWithTag != 0);
+
+ qtext->setText(text);
+ qtextWithTag->setText(textWithTag);
+
+ for (int size = 6; size < 100; size += 4) {
+ view->rootObject()->setProperty("pointSize", size);
+ if (fontIsBigger)
+ QVERIFY(qtext->height() <= qtextWithTag->height());
+ else
+ QVERIFY(qtext->height() >= qtextWithTag->height());
+ }
+ }
+
+ {
+ view->setSource(testFileUrl("pixelFontSizes.qml"));
+ QQuickText *qtext = view->rootObject()->findChild<QQuickText*>("text");
+ QQuickText *qtextWithTag = view->rootObject()->findChild<QQuickText*>("textWithTag");
+ QVERIFY(qtext != 0);
+ QVERIFY(qtextWithTag != 0);
+
+ qtext->setText(text);
+ qtextWithTag->setText(textWithTag);
+
+ for (int size = 6; size < 100; size += 4) {
+ view->rootObject()->setProperty("pixelSize", size);
+ if (fontIsBigger)
+ QVERIFY(qtext->height() <= qtextWithTag->height());
+ else
+ QVERIFY(qtext->height() >= qtextWithTag->height());
+ }
+ }
+ delete view;
+}
+
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 314a523602..85a9033dd7 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -461,10 +461,10 @@ void tst_qquicktextedit::width()
layout.endLayout();
- qreal metricWidth = ceil(layout.boundingRect().width());
+ qreal metricWidth = layout.boundingRect().width();
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(metricWidth));
+ QCOMPARE(textEditObject->width(), metricWidth);
}
for (int i = 0; i < richText.size(); i++)
@@ -475,7 +475,7 @@ void tst_qquicktextedit::width()
if (requiresUnhintedMetrics)
document.setUseDesignMetrics(true);
- int documentWidth = ceil(document.idealWidth());
+ qreal documentWidth = document.idealWidth();
QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
QQmlComponent texteditComponent(&engine);
@@ -483,7 +483,7 @@ void tst_qquicktextedit::width()
QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(documentWidth));
+ QCOMPARE(textEditObject->width(), documentWidth);
}
}
@@ -903,10 +903,7 @@ void tst_qquicktextedit::color()
QVERIFY(textEditObject);
QVERIFY(textEditPrivate);
QVERIFY(textEditPrivate->control);
-
- QPalette pal = textEditPrivate->control->palette();
QCOMPARE(textEditPrivate->color, QColor("black"));
- QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text));
}
//test normal
for (int i = 0; i < colorStrings.size(); i++)
@@ -1846,8 +1843,8 @@ void tst_qquicktextedit::cursorDelegate()
//Test Delegate gets moved
for (int i=0; i<= textEditObject->text().length(); i++) {
textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
}
// Clear preedit text;
QInputMethodEvent event;
@@ -1861,8 +1858,8 @@ void tst_qquicktextedit::cursorDelegate()
QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
QTest::qWait(50);
QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
// Test delegate gets moved on mouse drag
textEditObject->setCursorPosition(0);
@@ -1872,27 +1869,27 @@ void tst_qquicktextedit::cursorDelegate()
QGuiApplication::sendEvent(&view, &mv);
QTest::mouseRelease(&view, Qt::LeftButton, 0, point2);
QTest::qWait(50);
- QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QTRY_COMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
textEditObject->setReadOnly(true);
textEditObject->setCursorPosition(0);
QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
QTest::qWait(50);
QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
textEditObject->setCursorPosition(0);
QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
QTest::qWait(50);
QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
textEditObject->setCursorPosition(0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());
//Test Delegate gets deleted
textEditObject->setCursorDelegate(0);
QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
@@ -2585,14 +2582,14 @@ void tst_qquicktextedit::cursorRectangleSize()
qApp->sendEvent(qApp->focusObject(), &event);
QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
- QRect cursorRectFromItem = textEdit->cursorRectangle();
+ QRectF cursorRectFromItem = textEdit->cursorRectangle();
QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
// item and input query cursor rectangles match
- QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect());
+ QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
// item cursor rectangle and positionToRectangle calculations match
- QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
+ QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle);
// item-canvas transform and input item transform match
QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 4141fea26f..bdd18d620e 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -2341,12 +2341,12 @@ void tst_qquicktextinput::cursorDelegate()
//Test Delegate gets moved
for (int i=0; i<= textInputObject->text().length(); i++) {
textInputObject->setCursorPosition(i);
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
}
textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x());
+ QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y());
//Test Delegate gets deleted
textInputObject->setCursorDelegate(0);
QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
@@ -2404,9 +2404,6 @@ void tst_qquicktextinput::cursorVisible()
QCOMPARE(spy.count(), 7);
}
-static QRect round(const QRectF &r) {
- return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); }
-
void tst_qquicktextinput::cursorRectangle()
{
@@ -2430,7 +2427,7 @@ void tst_qquicktextinput::cursorRectangle()
input.setWidth(line.cursorToX(5, QTextLine::Leading));
input.setHeight(qCeil(line.height() * 3 / 2));
- QRect r;
+ QRectF r;
// some tolerance for different fonts.
#ifdef Q_OS_LINUX
@@ -2445,28 +2442,28 @@ void tst_qquicktextinput::cursorRectangle()
QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
// Check the cursor rectangle remains within the input bounding rect when auto scrolling.
- QVERIFY(r.left() < input.width());
+ QVERIFY(r.left() < input.width() + error);
QVERIFY(r.right() >= input.width() - error);
for (int i = 6; i < text.length(); ++i) {
input.setCursorPosition(i);
QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
for (int i = text.length() - 2; i >= 0; --i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
- QCOMPARE(r.top(), 0);
+ QCOMPARE(r.top(), 0.);
QVERIFY(r.right() >= 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
// Check position with word wrap.
@@ -2478,24 +2475,24 @@ void tst_qquicktextinput::cursorRectangle()
QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(r.top(), 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(r.top(), 0.);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
input.setCursorPosition(6);
r = input.cursorRectangle();
- QCOMPARE(r.left(), 0);
+ QCOMPARE(r.left(), 0.);
QVERIFY(r.top() > line.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(6)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(6), r);
for (int i = 7; i < text.length(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.top() > line.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
// Check vertical scrolling with word wrap.
@@ -2506,40 +2503,40 @@ void tst_qquicktextinput::cursorRectangle()
QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(r.top(), 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(round(input.positionToRectangle(i))), r);
+ QCOMPARE(r.top(), 0.);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
input.setCursorPosition(6);
r = input.cursorRectangle();
- QCOMPARE(r.left(), 0);
+ QCOMPARE(r.left(), 0.);
QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(6)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(6), r);
for (int i = 7; i < text.length(); ++i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
for (int i = text.length() - 2; i >= 6; --i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
for (int i = 5; i >= 0; --i) {
input.setCursorPosition(i);
r = input.cursorRectangle();
- QCOMPARE(r.top(), 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
+ QCOMPARE(r.top(), 0.);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r);
+ QCOMPARE(input.positionToRectangle(i), r);
}
input.setText("Hi!");
@@ -3228,14 +3225,14 @@ void tst_qquicktextinput::cursorRectangleSize()
qApp->sendEvent(qApp->focusObject(), &event);
QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
- QRect cursorRectFromItem = textInput->cursorRectangle();
+ QRectF cursorRectFromItem = textInput->cursorRectangle();
QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition());
// item and input query cursor rectangles match
- QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect());
+ QCOMPARE(cursorRectFromItem, cursorRectFromQuery);
// item cursor rectangle and positionToRectangle calculations match
- QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
+ QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle);
// item-canvas transform and input item transform match
QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 6fba193790..4065dbf508 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -8,7 +8,7 @@ PUBLICTESTS += \
qquickpixmapcache
# This test requires the qtconcurrent module
-!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qqmlpixmapcache
+!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qquickpixmapcache
PRIVATETESTS += \
qquickanimations \
@@ -25,16 +25,21 @@ PRIVATETESTS += \
qquickxmllistmodel
# This test requires the xmlpatterns module
-!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qqmlxmllistmodel
+!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qquickxmllistmodel
+
+# FIXME
+# qquickdroparea is disabled because it depends on changes that
+# have not been merged from qtbase/master to qtbase/api_changes yet:
+ #qquickdroparea \
QUICKTESTS = \
qquickaccessible \
qquickanchors \
qquickanimatedimage \
+ qquickanimatedsprite \
qquickborderimage \
qquickcanvas \
qquickdrag \
- qquickdroparea \
qquickflickable \
qquickflipable \
qquickfocusscope \
@@ -52,7 +57,7 @@ QUICKTESTS = \
qquickpositioners \
qquickrepeater \
qquickshadereffect \
- qquickspriteimage \
+ qquickspritesequence \
qquicktext \
qquicktextedit \
qquicktextinput \
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index e940727789..6ab754cff6 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -174,6 +174,8 @@ namespace QQuickViewTestUtil
};
}
+Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*)
+Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange)
Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)
Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange)
diff --git a/tests/benchmarks/qml/script/data/enums.qml b/tests/benchmarks/qml/script/data/enums.qml
index 8450b15732..f2da9b068e 100644
--- a/tests/benchmarks/qml/script/data/enums.qml
+++ b/tests/benchmarks/qml/script/data/enums.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/benchmarks/qml/script/data/namespacedEnums.qml b/tests/benchmarks/qml/script/data/namespacedEnums.qml
index e49bf7e1ad..0f24112d7c 100644
--- a/tests/benchmarks/qml/script/data/namespacedEnums.qml
+++ b/tests/benchmarks/qml/script/data/namespacedEnums.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/benchmarks/qml/script/data/scriptCall.qml b/tests/benchmarks/qml/script/data/scriptCall.qml
index 420f621dfc..b4a49b1908 100644
--- a/tests/benchmarks/qml/script/data/scriptCall.qml
+++ b/tests/benchmarks/qml/script/data/scriptCall.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the Declarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml b/tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml
new file mode 100644
index 0000000000..37ef64efef
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_heavyArgsAccess.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ onMySignalWithArgs: {
+ var a = 0;
+ for (var i = 0; i < 10000; ++i)
+ a += n;
+ return a;
+ }
+}
diff --git a/tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml b/tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml
new file mode 100644
index 0000000000..610fcd001a
--- /dev/null
+++ b/tests/benchmarks/qml/script/data/signal_heavyIdAccess.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt.test 1.0
+
+TestObject {
+ id: obj
+ property real inc: 3
+
+ onMySignalWithArgs: {
+ var a = 0;
+ for (var i = 0; i < 10000; ++i)
+ a += obj.inc;
+ return a;
+ }
+}
diff --git a/tests/benchmarks/qml/script/script.pro b/tests/benchmarks/qml/script/script.pro
index 88e8d9b33d..1f836a84f1 100644
--- a/tests/benchmarks/qml/script/script.pro
+++ b/tests/benchmarks/qml/script/script.pro
@@ -1,10 +1,11 @@
CONFIG += testcase
TEMPLATE = app
TARGET = tst_script
-QT += qml qml-private testlib v8-private core-private
macx:CONFIG -= app_bundle
CONFIG += release
SOURCES += tst_script.cpp
+QT += core-private gui-private v8-private qml-private quick-private testlib
+
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/benchmarks/qml/script/tst_script.cpp b/tests/benchmarks/qml/script/tst_script.cpp
index 204fb945eb..e7418d5fc0 100644
--- a/tests/benchmarks/qml/script/tst_script.cpp
+++ b/tests/benchmarks/qml/script/tst_script.cpp
@@ -43,10 +43,9 @@
#include <QQmlEngine>
#include <QQmlComponent>
#include <private/qqmlengine_p.h>
-#include <private/qdeclarativeobjectscriptclass_p.h>
#include <private/qquickrectangle_p.h>
-#include <QScriptEngine>
-#include <QScriptValue>
+#include <QJSEngine>
+#include <QJSValue>
class tst_script : public QObject
{
@@ -58,10 +57,13 @@ private slots:
void initTestCase();
void property_js();
- void property_getter();
void property_getter_js();
- void property_getter_qobject();
- void property_getter_qmetaproperty();
+#if 0
+ //no native functions for now
+ void property_getter();
+ void property_getter_qobject();
+ void property_getter_qmetaproperty();
+#endif
void property_qobject();
void property_qmlobject();
@@ -69,12 +71,18 @@ private slots:
void setproperty_qmlobject();
void function_js();
+#if 0
+ //no native functions for now
void function_cpp();
+#endif
void function_qobject();
void function_qmlobject();
void function_args_js();
+#if 0
+ //no native functions for now
void function_args_cpp();
+#endif
void function_args_qobject();
void function_args_qmlobject();
@@ -82,6 +90,8 @@ private slots:
void signal_qml();
void signal_args();
void signal_unusedArgs();
+ void signal_heavyArgsAccess();
+ void signal_heavyIdAccess();
void slot_simple();
void slot_simple_js();
@@ -144,7 +154,7 @@ TestObject::TestObject(QObject *parent)
{
}
-int TestObject::x()
+int TestObject::x()
{
return m_x++;
}
@@ -166,14 +176,14 @@ void tst_script::initTestCase()
void tst_script::property_js()
{
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue v = engine.newObject();
+ QJSValue v = engine.newObject();
v.setProperty(QLatin1String("x"), 10);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -181,23 +191,24 @@ void tst_script::property_js()
}
}
-static QScriptValue property_getter_method(QScriptContext *, QScriptEngine *engine)
+#if 0
+static QJSValue property_getter_method(QScriptContext *, QJSEngine *engine)
{
static int x = 0;
- return QScriptValue(engine,x++);
+ return QJSValue(engine,x++);
}
void tst_script::property_getter()
{
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method),
- QScriptValue::PropertyGetter);
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method),
+ QJSValue::PropertyGetter);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -206,44 +217,44 @@ void tst_script::property_getter()
}
static TestObject *property_getter_qobject_object = 0;
-static QScriptValue property_getter_qobject_method(QScriptContext *, QScriptEngine *)
+static QJSValue property_getter_qobject_method(QScriptContext *, QJSEngine *)
{
static int idx = -1;
- if (idx == -1)
+ if (idx == -1)
idx = TestObject::staticMetaObject.indexOfProperty("x");
int value = 0;
void *args[] = { &value, 0 };
QMetaObject::metacall(property_getter_qobject_object, QMetaObject::ReadProperty, idx, args);
- return QScriptValue(value);
+ return QJSValue(value);
}
-static QScriptValue property_getter_qmetaproperty_method(QScriptContext *, QScriptEngine *)
+static QJSValue property_getter_qmetaproperty_method(QScriptContext *, QJSEngine *)
{
static int idx = -1;
- if (idx == -1)
+ if (idx == -1)
idx = TestObject::staticMetaObject.indexOfProperty("x");
int value = 0;
value = property_getter_qobject_object->metaObject()->property(idx).read(property_getter_qobject_object).toInt();
- return QScriptValue(value);
+ return QJSValue(value);
}
void tst_script::property_getter_qobject()
{
- QScriptEngine engine;
+ QJSEngine engine;
TestObject to;
property_getter_qobject_object = &to;
- QScriptValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method),
- QScriptValue::PropertyGetter);
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method),
+ QJSValue::PropertyGetter);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -254,17 +265,17 @@ void tst_script::property_getter_qobject()
void tst_script::property_getter_qmetaproperty()
{
- QScriptEngine engine;
+ QJSEngine engine;
TestObject to;
property_getter_qobject_object = &to;
- QScriptValue v = engine.newObject();
- v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method),
- QScriptValue::PropertyGetter);
+ QJSValue v = engine.newObject();
+ v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method),
+ QJSValue::PropertyGetter);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -272,17 +283,17 @@ void tst_script::property_getter_qmetaproperty()
}
property_getter_qobject_object = 0;
}
-
+#endif
void tst_script::property_getter_js()
{
- QScriptEngine engine;
-
- QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call();
+ QJSEngine engine;
+
+ QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call();
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -292,14 +303,14 @@ void tst_script::property_getter_js()
void tst_script::property_qobject()
{
- QScriptEngine engine;
+ QJSEngine engine;
TestObject to;
- QScriptValue v = engine.newQObject(&to);
+ QJSValue v = engine.newQObject(&to);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -311,14 +322,15 @@ void tst_script::property_qmlobject()
{
QQmlEngine qmlengine;
- QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
- QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
-
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine->evaluate(PROPERTY_PROGRAM).call(engine->globalObject(), args);
+ QJSValue prog = qmlengine.evaluate(PROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -335,14 +347,14 @@ void tst_script::property_qmlobject()
void tst_script::setproperty_js()
{
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue v = engine.newObject();
+ QJSValue v = engine.newObject();
v.setProperty(QLatin1String("x"), 0);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -354,14 +366,16 @@ void tst_script::setproperty_qmlobject()
{
QQmlEngine qmlengine;
- QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
- QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine->evaluate(SETPROPERTY_PROGRAM).call(engine->globalObject(), args);
+ QJSValue prog = qmlengine.evaluate(SETPROPERTY_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -380,13 +394,13 @@ void tst_script::setproperty_qmlobject()
void tst_script::function_js()
{
- QScriptEngine engine;
-
- QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call();
+ QJSEngine engine;
+
+ QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call();
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -394,39 +408,41 @@ void tst_script::function_js()
}
}
-static QScriptValue function_method(QScriptContext *, QScriptEngine *)
+#if 0
+static QJSValue function_method(QScriptContext *, QJSEngine *)
{
static int x = 0;
- return QScriptValue(x++);
+ return QJSValue(x++);
}
void tst_script::function_cpp()
{
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue v = engine.newObject();
+ QJSValue v = engine.newObject();
v.setProperty(QLatin1String("method"), engine.newFunction(function_method));
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
prog.call();
QBENCHMARK {
prog.call();
}
}
+#endif
void tst_script::function_qobject()
{
- QScriptEngine engine;
+ QJSEngine engine;
TestObject to;
- QScriptValue v = engine.newQObject(&to);
+ QJSValue v = engine.newQObject(&to);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -438,14 +454,16 @@ void tst_script::function_qmlobject()
{
QQmlEngine qmlengine;
- QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
- QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine->evaluate(FUNCTION_PROGRAM).call(engine->globalObject(), args);
+ QJSValue prog = qmlengine.evaluate(FUNCTION_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -464,13 +482,13 @@ void tst_script::function_qmlobject()
void tst_script::function_args_js()
{
- QScriptEngine engine;
-
- QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call();
+ QJSEngine engine;
- QScriptValueList args;
+ QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call();
+
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -478,39 +496,41 @@ void tst_script::function_args_js()
}
}
-static QScriptValue function_args_method(QScriptContext *ctxt, QScriptEngine *)
+#if 0
+static QJSValue function_args_method(QScriptContext *ctxt, QJSEngine *)
{
static int x = 0;
- return QScriptValue(ctxt->argument(0).toNumber() + x++);
+ return QJSValue(ctxt->argument(0).toNumber() + x++);
}
void tst_script::function_args_cpp()
{
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue v = engine.newObject();
+ QJSValue v = engine.newObject();
v.setProperty(QLatin1String("methodArgs"), engine.newFunction(function_args_method));
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
prog.call();
QBENCHMARK {
prog.call();
}
}
+#endif
void tst_script::function_args_qobject()
{
- QScriptEngine engine;
+ QJSEngine engine;
TestObject to;
- QScriptValue v = engine.newQObject(&to);
+ QJSValue v = engine.newQObject(&to);
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args);
+ QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -522,14 +542,16 @@ void tst_script::function_args_qmlobject()
{
QQmlEngine qmlengine;
- QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine);
TestObject to;
- QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to);
+ QV8Engine *engine = QQmlEnginePrivate::getV8Engine(&qmlengine);
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+ QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to));
- QScriptValueList args;
+ QJSValueList args;
args << v;
- QScriptValue prog = engine->evaluate(FUNCTION_ARGS_PROGRAM).call(engine->globalObject(), args);
+ QJSValue prog = qmlengine.evaluate(FUNCTION_ARGS_PROGRAM).call(args);
prog.call();
QBENCHMARK {
@@ -593,6 +615,34 @@ void tst_script::signal_unusedArgs()
delete object;
}
+void tst_script::signal_heavyArgsAccess()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_heavyArgsAccess.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignalWithArgs(11);
+ }
+
+ delete object;
+}
+
+void tst_script::signal_heavyIdAccess()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, TEST_FILE("signal_heavyIdAccess.qml"));
+ TestObject *object = qobject_cast<TestObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QBENCHMARK {
+ object->emitMySignalWithArgs(11);
+ }
+
+ delete object;
+}
+
void tst_script::slot_simple()
{
QQmlEngine engine;
@@ -685,9 +735,9 @@ void tst_script::block()
void tst_script::global_property_js()
{
- QScriptEngine engine;
+ QJSEngine engine;
- QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM);
+ QJSValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM);
prog.call();
QBENCHMARK {
@@ -699,8 +749,7 @@ void tst_script::global_property_qml()
{
QQmlEngine qmlengine;
- QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine);
- QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM);
+ QJSValue prog = qmlengine.evaluate(GLOBALPROPERTY_PROGRAM);
prog.call();
QBENCHMARK {
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 2c12941d07..cea29158f9 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -133,7 +133,7 @@ public:
};
/* When we dump a QMetaObject, we want to list all the types it is exported as.
- To do this, we need to find the QDeclarativeTypes associated with this
+ To do this, we need to find the QQmlTypes associated with this
QMetaObject.
*/
static QHash<QByteArray, QSet<const QQmlType *> > qmlTypesByCppName;
diff --git a/tools/qmlprofiler/profileclient.cpp b/tools/qmlprofiler/profileclient.cpp
index 5871aa29af..85287464cf 100644
--- a/tools/qmlprofiler/profileclient.cpp
+++ b/tools/qmlprofiler/profileclient.cpp
@@ -103,10 +103,10 @@ void ProfileClient::stateChanged(State status)
}
-class DeclarativeProfileClientPrivate
+class QmlProfileClientPrivate
{
public:
- DeclarativeProfileClientPrivate()
+ QmlProfileClientPrivate()
: inProgressRanges(0)
, maximumTime(0)
{
@@ -122,26 +122,26 @@ public:
qint64 maximumTime;
};
-DeclarativeProfileClient::DeclarativeProfileClient(
+QmlProfileClient::QmlProfileClient(
QQmlDebugConnection *client)
: ProfileClient(QLatin1String("CanvasFrameRate"), client),
- d(new DeclarativeProfileClientPrivate)
+ d(new QmlProfileClientPrivate)
{
}
-DeclarativeProfileClient::~DeclarativeProfileClient()
+QmlProfileClient::~QmlProfileClient()
{
delete d;
}
-void DeclarativeProfileClient::clearData()
+void QmlProfileClient::clearData()
{
::memset(d->rangeCount, 0,
QQmlProfilerService::MaximumRangeType * sizeof(int));
ProfileClient::clearData();
}
-void DeclarativeProfileClient::sendRecordingStatus()
+void QmlProfileClient::sendRecordingStatus()
{
QByteArray ba;
QDataStream stream(&ba, QIODevice::WriteOnly);
@@ -149,7 +149,7 @@ void DeclarativeProfileClient::sendRecordingStatus()
sendMessage(ba);
}
-void DeclarativeProfileClient::messageReceived(const QByteArray &data)
+void QmlProfileClient::messageReceived(const QByteArray &data)
{
QByteArray rwData = data;
QDataStream stream(&rwData, QIODevice::ReadOnly);
diff --git a/tools/qmlprofiler/profileclient.h b/tools/qmlprofiler/profileclient.h
index fd581c59c4..8aa4e67982 100644
--- a/tools/qmlprofiler/profileclient.h
+++ b/tools/qmlprofiler/profileclient.h
@@ -83,13 +83,13 @@ protected:
bool m_enabled;
};
-class DeclarativeProfileClient : public ProfileClient
+class QmlProfileClient : public ProfileClient
{
Q_OBJECT
public:
- DeclarativeProfileClient(QQmlDebugConnection *client);
- ~DeclarativeProfileClient();
+ QmlProfileClient(QQmlDebugConnection *client);
+ ~QmlProfileClient();
public slots:
void clearData();
@@ -107,7 +107,7 @@ protected:
virtual void messageReceived(const QByteArray &);
private:
- class DeclarativeProfileClientPrivate *d;
+ class QmlProfileClientPrivate *d;
};
class V8ProfileClient : public ProfileClient
diff --git a/tools/qmlprofiler/profiledata.cpp b/tools/qmlprofiler/profiledata.cpp
index 96d7520844..6082f4aa94 100644
--- a/tools/qmlprofiler/profiledata.cpp
+++ b/tools/qmlprofiler/profiledata.cpp
@@ -50,7 +50,7 @@
using namespace Constants;
-DeclarativeEvent::DeclarativeEvent()
+QmlEvent::QmlEvent()
{
eventType = QQmlProfilerService::MaximumRangeType;
eventId = -1;
@@ -64,7 +64,7 @@ DeclarativeEvent::DeclarativeEvent()
isBindingLoop = false;
}
-DeclarativeEvent::~DeclarativeEvent()
+QmlEvent::~QmlEvent()
{
qDeleteAll(parentHash.values());
parentHash.clear();
@@ -72,7 +72,7 @@ DeclarativeEvent::~DeclarativeEvent()
childrenHash.clear();
}
-DeclarativeEvent &DeclarativeEvent::operator=(const DeclarativeEvent &ref)
+QmlEvent &QmlEvent::operator=(const QmlEvent &ref)
{
if (this == &ref)
return *this;
@@ -96,14 +96,14 @@ DeclarativeEvent &DeclarativeEvent::operator=(const DeclarativeEvent &ref)
parentHash.clear();
foreach (const QString &key, ref.parentHash.keys()) {
parentHash.insert(key,
- new DeclarativeEventSub(ref.parentHash.value(key)));
+ new QmlEventSub(ref.parentHash.value(key)));
}
qDeleteAll(childrenHash.values());
childrenHash.clear();
foreach (const QString &key, ref.childrenHash.keys()) {
childrenHash.insert(key,
- new DeclarativeEventSub(ref.childrenHash.value(key)));
+ new QmlEventSub(ref.childrenHash.value(key)));
}
return *this;
@@ -157,21 +157,21 @@ V8Event &V8Event::operator=(const V8Event &ref)
}
// endtimedata
-struct DeclarativeEventEndTime {
+struct QmlEventEndTime {
qint64 endTime;
int startTimeIndex;
- DeclarativeEvent *description;
+ QmlEvent *description;
};
// starttimedata
-struct DeclarativeEventStartTime{
+struct QmlEventStartTime{
qint64 startTime;
qint64 length;
qint64 level;
int endTimeIndex;
qint64 nestingLevel;
qint64 nestingDepth;
- DeclarativeEvent *description;
+ QmlEvent *description;
// animation-related data
int frameRate;
@@ -180,31 +180,31 @@ struct DeclarativeEventStartTime{
int bindingLoopHead;
};
-struct DeclarativeEventTypeCount {
+struct QmlEventTypeCount {
QList <int> eventIds;
int nestingCount;
};
// used by quicksort
-bool compareEndTimes(const DeclarativeEventEndTime &t1,
- const DeclarativeEventEndTime &t2)
+bool compareEndTimes(const QmlEventEndTime &t1,
+ const QmlEventEndTime &t2)
{
return t1.endTime < t2.endTime;
}
-bool compareStartTimes(const DeclarativeEventStartTime &t1,
- const DeclarativeEventStartTime &t2)
+bool compareStartTimes(const QmlEventStartTime &t1,
+ const QmlEventStartTime &t2)
{
return t1.startTime < t2.startTime;
}
-bool compareStartIndexes(const DeclarativeEventEndTime &t1,
- const DeclarativeEventEndTime &t2)
+bool compareStartIndexes(const QmlEventEndTime &t1,
+ const QmlEventEndTime &t2)
{
return t1.startTimeIndex < t2.startTimeIndex;
}
-QString declarativeEventType(QQmlProfilerService::RangeType typeEnum)
+QString qmlEventType(QQmlProfilerService::RangeType typeEnum)
{
switch (typeEnum) {
case QQmlProfilerService::Painting:
@@ -227,7 +227,7 @@ QString declarativeEventType(QQmlProfilerService::RangeType typeEnum)
}
}
-QQmlProfilerService::RangeType declarativeEventType(const QString &typeString)
+QQmlProfilerService::RangeType qmlEventType(const QString &typeString)
{
if (typeString == QLatin1String(TYPE_PAINTING_STR)) {
return QQmlProfilerService::Painting;
@@ -250,7 +250,7 @@ QQmlProfilerService::RangeType declarativeEventType(const QString &typeString)
}
}
-QString getHashStringForDeclarativeEvent(
+QString getHashStringForQmlEvent(
EventLocation location,
QQmlProfilerService::RangeType eventType)
{
@@ -265,31 +265,31 @@ class ProfileDataPrivate
public:
// convenience functions
- void clearDeclarativeRootEvent();
+ void clearQmlRootEvent();
void clearV8RootEvent();
// Stored data
- DeclarativeEventHash m_eventDescriptions;
- QList<DeclarativeEventEndTime> m_endTimeSortedList;
- QList<DeclarativeEventStartTime> m_startTimeSortedList;
+ QmlEventHash m_eventDescriptions;
+ QList<QmlEventEndTime> m_endTimeSortedList;
+ QList<QmlEventStartTime> m_startTimeSortedList;
void collectV8Statistics();
V8Events m_v8EventList;
QHash<int, V8Event *> m_v8parents;
- DeclarativeEvent m_qmlRootEvent;
+ QmlEvent m_qmlRootEvent;
V8Event m_v8RootEvent;
QString m_rootEventName;
QString m_rootEventDesc;
- QHash<int, DeclarativeEventTypeCount *> m_typeCounts;
+ QHash<int, QmlEventTypeCount *> m_typeCounts;
qint64 m_traceEndTime;
qint64 m_traceStartTime;
qint64 m_qmlMeasuredTime;
qint64 m_v8MeasuredTime;
- DeclarativeEventStartTime *m_lastFrameEvent;
+ QmlEventStartTime *m_lastFrameEvent;
qint64 m_maximumAnimationCount;
qint64 m_minimumAnimationCount;
@@ -309,7 +309,7 @@ ProfileData::ProfileData(QObject *parent) :
d->m_v8MeasuredTime = 0;
d->m_rootEventName = tr("<program>");
d->m_rootEventDesc = tr("Main Program");
- d->clearDeclarativeRootEvent();
+ d->clearQmlRootEvent();
d->clearV8RootEvent();
d->m_lastFrameEvent = 0;
d->m_maximumAnimationCount = 0;
@@ -334,10 +334,10 @@ void ProfileData::clear()
d->m_v8parents.clear();
- d->clearDeclarativeRootEvent();
+ d->clearQmlRootEvent();
d->clearV8RootEvent();
- foreach (DeclarativeEventTypeCount *typeCount, d->m_typeCounts.values())
+ foreach (QmlEventTypeCount *typeCount, d->m_typeCounts.values())
delete typeCount;
d->m_typeCounts.clear();
@@ -354,14 +354,14 @@ void ProfileData::clear()
emit dataClear();
}
-DeclarativeEvents ProfileData::getDeclarativeEvents() const
+QmlEvents ProfileData::getQmlEvents() const
{
return d->m_eventDescriptions.values();
}
-DeclarativeEvent *ProfileData::declarativeEvent(int eventId) const
+QmlEvent *ProfileData::qmlEvent(int eventId) const
{
- foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *event, d->m_eventDescriptions.values()) {
if (event->eventId == eventId)
return event;
}
@@ -382,7 +382,7 @@ const V8Events& ProfileData::getV8Events() const
return d->m_v8EventList;
}
-void ProfileData::addDeclarativeEvent(
+void ProfileData::addQmlEvent(
QQmlProfilerService::RangeType type, qint64 startTime, qint64 length,
const QStringList &data, const EventLocation &location)
{
@@ -417,18 +417,18 @@ void ProfileData::addDeclarativeEvent(
// generate hash
if (eventLocation.filename.isEmpty()) {
displayName = tr("<bytecode>");
- eventHashStr = getHashStringForDeclarativeEvent(eventLocation, type);
+ eventHashStr = getHashStringForQmlEvent(eventLocation, type);
} else {
const QString filePath = QUrl(eventLocation.filename).path();
displayName = filePath.mid(filePath.lastIndexOf(QChar('/')) + 1) + colon + QString::number(eventLocation.line);
- eventHashStr = getHashStringForDeclarativeEvent(eventLocation, type);
+ eventHashStr = getHashStringForQmlEvent(eventLocation, type);
}
- DeclarativeEvent *newEvent;
+ QmlEvent *newEvent;
if (d->m_eventDescriptions.contains(eventHashStr)) {
newEvent = d->m_eventDescriptions[eventHashStr];
} else {
- newEvent = new DeclarativeEvent;
+ newEvent = new QmlEvent;
newEvent->displayname = displayName;
newEvent->location = eventLocation;
newEvent->eventHashStr = eventHashStr;
@@ -437,12 +437,12 @@ void ProfileData::addDeclarativeEvent(
d->m_eventDescriptions.insert(eventHashStr, newEvent);
}
- DeclarativeEventEndTime endTimeData;
+ QmlEventEndTime endTimeData;
endTimeData.endTime = startTime + length;
endTimeData.description = newEvent;
endTimeData.startTimeIndex = d->m_startTimeSortedList.count();
- DeclarativeEventStartTime startTimeData;
+ QmlEventStartTime startTimeData;
startTimeData.startTime = startTime;
startTimeData.length = length;
startTimeData.description = newEvent;
@@ -537,11 +537,11 @@ void ProfileData::addFrameEvent(qint64 time, int framerate, int animationcount)
displayName = tr("<Animation Update>");
eventHashStr = displayName;
- DeclarativeEvent *newEvent;
+ QmlEvent *newEvent;
if (d->m_eventDescriptions.contains(eventHashStr)) {
newEvent = d->m_eventDescriptions[eventHashStr];
} else {
- newEvent = new DeclarativeEvent;
+ newEvent = new QmlEvent;
newEvent->displayname = displayName;
newEvent->eventHashStr = eventHashStr;
newEvent->eventType = QQmlProfilerService::Painting;
@@ -558,12 +558,12 @@ void ProfileData::addFrameEvent(qint64 time, int framerate, int animationcount)
d->m_lastFrameEvent->startTime + d->m_lastFrameEvent->length;
}
- DeclarativeEventEndTime endTimeData;
+ QmlEventEndTime endTimeData;
endTimeData.endTime = time + length;
endTimeData.description = newEvent;
endTimeData.startTimeIndex = d->m_startTimeSortedList.count();
- DeclarativeEventStartTime startTimeData;
+ QmlEventStartTime startTimeData;
startTimeData.startTime = time;
startTimeData.length = length;
startTimeData.description = newEvent;
@@ -645,7 +645,7 @@ void ProfileData::complete()
postProcess();
}
-void ProfileDataPrivate::clearDeclarativeRootEvent()
+void ProfileDataPrivate::clearQmlRootEvent()
{
m_qmlRootEvent.displayname = m_rootEventName;
m_qmlRootEvent.location = EventLocation();
@@ -692,7 +692,7 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
double totalTime = 0;
// clear existing statistics
- foreach (DeclarativeEvent *eventDescription,
+ foreach (QmlEvent *eventDescription,
d->m_eventDescriptions.values()) {
eventDescription->calls = 0;
// maximum possible value
@@ -707,12 +707,12 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
}
// create root event for statistics
- d->clearDeclarativeRootEvent();
+ d->clearQmlRootEvent();
// compute parent-child relationship and call count
- QHash<int, DeclarativeEvent*> lastParent;
+ QHash<int, QmlEvent*> lastParent;
for (index = fromIndex; index <= toIndex; index++) {
- DeclarativeEvent *eventDescription =
+ QmlEvent *eventDescription =
d->m_startTimeSortedList[index].description;
if (d->m_startTimeSortedList[index].startTime > endTime ||
@@ -736,36 +736,36 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
int level = d->m_startTimeSortedList[index].level;
- DeclarativeEvent *parentEvent = &d->m_qmlRootEvent;
+ QmlEvent *parentEvent = &d->m_qmlRootEvent;
if (level > MIN_LEVEL && lastParent.contains(level-1)) {
parentEvent = lastParent[level-1];
}
if (!eventDescription->parentHash.contains(parentEvent->eventHashStr)) {
- DeclarativeEventSub *newParentEvent =
- new DeclarativeEventSub(parentEvent);
+ QmlEventSub *newParentEvent =
+ new QmlEventSub(parentEvent);
newParentEvent->calls = 1;
newParentEvent->duration = duration;
eventDescription->parentHash.insert(parentEvent->eventHashStr,
newParentEvent);
} else {
- DeclarativeEventSub *newParentEvent =
+ QmlEventSub *newParentEvent =
eventDescription->parentHash.value(parentEvent->eventHashStr);
newParentEvent->duration += duration;
newParentEvent->calls++;
}
if (!parentEvent->childrenHash.contains(eventDescription->eventHashStr)) {
- DeclarativeEventSub *newChildEvent =
- new DeclarativeEventSub(eventDescription);
+ QmlEventSub *newChildEvent =
+ new QmlEventSub(eventDescription);
newChildEvent->calls = 1;
newChildEvent->duration = duration;
parentEvent->childrenHash.insert(eventDescription->eventHashStr,
newChildEvent);
} else {
- DeclarativeEventSub *newChildEvent =
+ QmlEventSub *newChildEvent =
parentEvent->childrenHash.value(eventDescription->eventHashStr);
newChildEvent->duration += duration;
newChildEvent->calls++;
@@ -788,29 +788,29 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime)
d->m_qmlRootEvent.calls = 1;
// insert into list
- DeclarativeEvent *listedRootEvent =
+ QmlEvent *listedRootEvent =
d->m_eventDescriptions.value(d->m_rootEventName);
if (!listedRootEvent) {
- listedRootEvent = new DeclarativeEvent;
+ listedRootEvent = new QmlEvent;
d->m_eventDescriptions.insert(d->m_rootEventName, listedRootEvent);
}
*listedRootEvent = d->m_qmlRootEvent;
// compute percentages
- foreach (DeclarativeEvent *binding, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *binding, d->m_eventDescriptions.values()) {
binding->percentOfTime = binding->duration * 100.0 / totalTime;
binding->timePerCall = binding->calls > 0 ?
double(binding->duration) / binding->calls : 0;
}
// compute median time
- QHash < DeclarativeEvent* , QList<qint64> > durationLists;
+ QHash < QmlEvent* , QList<qint64> > durationLists;
for (index = fromIndex; index <= toIndex; index++) {
- DeclarativeEvent *desc = d->m_startTimeSortedList[index].description;
+ QmlEvent *desc = d->m_startTimeSortedList[index].description;
qint64 len = d->m_startTimeSortedList[index].length;
durationLists[desc].append(len);
}
- QMutableHashIterator < DeclarativeEvent* , QList<qint64> > iter(durationLists);
+ QMutableHashIterator < QmlEvent* , QList<qint64> > iter(durationLists);
while (iter.hasNext()) {
iter.next();
if (!iter.value().isEmpty()) {
@@ -824,16 +824,16 @@ void ProfileData::prepareForDisplay()
{
// generate numeric ids
int ndx = 0;
- foreach (DeclarativeEvent *binding, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *binding, d->m_eventDescriptions.values()) {
binding->eventId = ndx++;
}
// collect type counts
- foreach (const DeclarativeEventStartTime &eventStartData,
+ foreach (const QmlEventStartTime &eventStartData,
d->m_startTimeSortedList) {
int typeNumber = eventStartData.description->eventType;
if (!d->m_typeCounts.contains(typeNumber)) {
- d->m_typeCounts[typeNumber] = new DeclarativeEventTypeCount;
+ d->m_typeCounts[typeNumber] = new QmlEventTypeCount;
d->m_typeCounts[typeNumber]->nestingCount = 0;
}
if (eventStartData.nestingLevel >
@@ -853,9 +853,9 @@ void ProfileData::sortStartTimes()
// assuming startTimes is partially sorted
// identify blocks of events and sort them with quicksort
- QList<DeclarativeEventStartTime>::iterator itFrom =
+ QList<QmlEventStartTime>::iterator itFrom =
d->m_startTimeSortedList.end() - 2;
- QList<DeclarativeEventStartTime>::iterator itTo =
+ QList<QmlEventStartTime>::iterator itTo =
d->m_startTimeSortedList.end() - 1;
while (itFrom != d->m_startTimeSortedList.begin() &&
@@ -899,9 +899,9 @@ void ProfileData::sortEndTimes()
if (d->m_endTimeSortedList.count() < 2)
return;
- QList<DeclarativeEventEndTime>::iterator itFrom =
+ QList<QmlEventEndTime>::iterator itFrom =
d->m_endTimeSortedList.begin();
- QList<DeclarativeEventEndTime>::iterator itTo =
+ QList<QmlEventEndTime>::iterator itTo =
d->m_endTimeSortedList.begin() + 1;
while (itTo != d->m_endTimeSortedList.end() &&
@@ -1074,7 +1074,7 @@ void ProfileData::computeLevels()
void ProfileData::reloadDetails()
{
// request binding/signal details from the AST
- foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *event, d->m_eventDescriptions.values()) {
if (event->eventType != QQmlProfilerService::Binding &&
event->eventType != QQmlProfilerService::HandlingSignal)
continue;
@@ -1095,22 +1095,22 @@ void ProfileData::reloadDetails()
void ProfileData::findBindingLoops(qint64 startTime, qint64 endTime)
{
// first clear existing data
- foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) {
+ foreach (QmlEvent *event, d->m_eventDescriptions.values()) {
event->isBindingLoop = false;
- foreach (DeclarativeEventSub *parentEvent, event->parentHash.values())
+ foreach (QmlEventSub *parentEvent, event->parentHash.values())
parentEvent->inLoopPath = false;
- foreach (DeclarativeEventSub *childEvent, event->childrenHash.values())
+ foreach (QmlEventSub *childEvent, event->childrenHash.values())
childEvent->inLoopPath = false;
}
- QList <DeclarativeEvent *> stackRefs;
- QList <DeclarativeEventStartTime *> stack;
+ QList <QmlEvent *> stackRefs;
+ QList <QmlEventStartTime *> stack;
int fromIndex = findFirstIndex(startTime);
int toIndex = findLastIndex(endTime);
for (int i = 0; i < d->m_startTimeSortedList.count(); i++) {
- DeclarativeEvent *currentEvent = d->m_startTimeSortedList[i].description;
- DeclarativeEventStartTime *inTimeEvent = &d->m_startTimeSortedList[i];
+ QmlEvent *currentEvent = d->m_startTimeSortedList[i].description;
+ QmlEventStartTime *inTimeEvent = &d->m_startTimeSortedList[i];
inTimeEvent->bindingLoopHead = -1;
// managing call stack
@@ -1130,15 +1130,15 @@ void ProfileData::findBindingLoops(qint64 startTime, qint64 endTime)
// for the statistics
currentEvent->isBindingLoop = true;
for (int j = stackRefs.indexOf(currentEvent); j < stackRefs.count()-1; j++) {
- DeclarativeEventSub *nextEventSub = stackRefs[j]->childrenHash.value(stackRefs[j+1]->eventHashStr);
+ QmlEventSub *nextEventSub = stackRefs[j]->childrenHash.value(stackRefs[j+1]->eventHashStr);
nextEventSub->inLoopPath = true;
- DeclarativeEventSub *prevEventSub = stackRefs[j+1]->parentHash.value(stackRefs[j]->eventHashStr);
+ QmlEventSub *prevEventSub = stackRefs[j+1]->parentHash.value(stackRefs[j]->eventHashStr);
prevEventSub->inLoopPath = true;
}
}
// use crossed references to find index in starttimesortedlist
- DeclarativeEventStartTime *head = stack[stackRefs.indexOf(currentEvent)];
+ QmlEventStartTime *head = stack[stackRefs.indexOf(currentEvent)];
inTimeEvent->bindingLoopHead = d->m_endTimeSortedList[head->endTimeIndex].startTimeIndex;
d->m_startTimeSortedList[inTimeEvent->bindingLoopHead].bindingLoopHead = i;
}
@@ -1149,7 +1149,7 @@ void ProfileData::rewriteDetailsString(
QQmlProfilerService::RangeType eventType,
const EventLocation &location, const QString &newString)
{
- QString eventHashStr = getHashStringForDeclarativeEvent(location,
+ QString eventHashStr = getHashStringForQmlEvent(location,
eventType);
Q_ASSERT(d->m_eventDescriptions.contains(eventHashStr));
d->m_eventDescriptions.value(eventHashStr)->details = newString;
@@ -1293,7 +1293,7 @@ qint64 ProfileData::traceDuration() const
return traceEndTime() - traceStartTime();
}
-qint64 ProfileData::declarativeMeasuredTime() const
+qint64 ProfileData::qmlMeasuredTime() const
{
return d->m_qmlMeasuredTime;
}
@@ -1336,14 +1336,14 @@ bool ProfileData::save(const QString &filename)
stream.writeStartElement("eventData");
stream.writeAttribute("totalTime", QString::number(d->m_qmlMeasuredTime));
- foreach (const DeclarativeEvent *eventData, d->m_eventDescriptions.values()) {
+ foreach (const QmlEvent *eventData, d->m_eventDescriptions.values()) {
stream.writeStartElement("event");
stream.writeAttribute("index",
QString::number(
d->m_eventDescriptions.keys().indexOf(
eventData->eventHashStr)));
stream.writeTextElement("displayname", eventData->displayname);
- stream.writeTextElement("type", declarativeEventType(eventData->eventType));
+ stream.writeTextElement("type", qmlEventType(eventData->eventType));
if (!eventData->location.filename.isEmpty()) {
stream.writeTextElement("filename", eventData->location.filename);
stream.writeTextElement("line",
@@ -1357,7 +1357,7 @@ bool ProfileData::save(const QString &filename)
stream.writeEndElement(); // eventData
stream.writeStartElement("eventList");
- foreach (const DeclarativeEventStartTime &rangedEvent,
+ foreach (const QmlEventStartTime &rangedEvent,
d->m_startTimeSortedList) {
stream.writeStartElement("range");
stream.writeAttribute("startTime", QString::number(rangedEvent.startTime));
@@ -1453,8 +1453,8 @@ void ProfileData::load()
bool readingQmlEvents = false;
bool readingV8Events = false;
- QHash <int, DeclarativeEvent *> descriptionBuffer;
- DeclarativeEvent *currentEvent = 0;
+ QHash <int, QmlEvent *> descriptionBuffer;
+ QmlEvent *currentEvent = 0;
QHash <int, V8Event *> v8eventBuffer;
QHash <int, QString> childrenIndexes;
QHash <int, QString> childrenTimes;
@@ -1519,7 +1519,7 @@ void ProfileData::load()
}
if (elementName == "range") {
- DeclarativeEventStartTime rangedEvent;
+ QmlEventStartTime rangedEvent;
QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("startTime"))
rangedEvent.startTime = attributes.value("startTime").
@@ -1538,7 +1538,7 @@ void ProfileData::load()
if (attributes.hasAttribute("eventIndex")) {
int ndx = attributes.value("eventIndex").toString().toInt();
if (!descriptionBuffer.value(ndx))
- descriptionBuffer[ndx] = new DeclarativeEvent;
+ descriptionBuffer[ndx] = new QmlEvent;
rangedEvent.description = descriptionBuffer.value(ndx);
}
rangedEvent.endTimeIndex = d->m_endTimeSortedList.length();
@@ -1549,7 +1549,7 @@ void ProfileData::load()
startTimesAreSorted = false;
d->m_startTimeSortedList << rangedEvent;
- DeclarativeEventEndTime endTimeEvent;
+ QmlEventEndTime endTimeEvent;
endTimeEvent.endTime = rangedEvent.startTime + rangedEvent.length;
endTimeEvent.startTimeIndex = d->m_startTimeSortedList.length()-1;
endTimeEvent.description = rangedEvent.description;
@@ -1563,7 +1563,7 @@ void ProfileData::load()
if (attributes.hasAttribute("index")) {
int ndx = attributes.value("index").toString().toInt();
if (!descriptionBuffer.value(ndx))
- descriptionBuffer[ndx] = new DeclarativeEvent;
+ descriptionBuffer[ndx] = new QmlEvent;
currentEvent = descriptionBuffer[ndx];
} else {
currentEvent = 0;
@@ -1585,7 +1585,7 @@ void ProfileData::load()
break;
}
if (elementName == "type") {
- currentEvent->eventType = declarativeEventType(readData);
+ currentEvent->eventType = qmlEventType(readData);
break;
}
if (elementName == "filename") {
@@ -1720,8 +1720,8 @@ void ProfileData::load()
d->m_v8MeasuredTime = cumulatedV8Time;
// move the buffered data to the details cache
- foreach (DeclarativeEvent *desc, descriptionBuffer.values()) {
- desc->eventHashStr = getHashStringForDeclarativeEvent(
+ foreach (QmlEvent *desc, descriptionBuffer.values()) {
+ desc->eventHashStr = getHashStringForQmlEvent(
desc->location, desc->eventType);;
d->m_eventDescriptions[desc->eventHashStr] = desc;
}
@@ -1731,7 +1731,7 @@ void ProfileData::load()
qSort(d->m_startTimeSortedList.begin(),
d->m_startTimeSortedList.end(), compareStartTimes);
for (int i = 0; i< d->m_startTimeSortedList.length(); i++) {
- DeclarativeEventStartTime startTimeData = d->m_startTimeSortedList[i];
+ QmlEventStartTime startTimeData = d->m_startTimeSortedList[i];
d->m_endTimeSortedList[startTimeData.endTimeIndex].startTimeIndex = i;
}
qSort(d->m_endTimeSortedList.begin(),
diff --git a/tools/qmlprofiler/profiledata.h b/tools/qmlprofiler/profiledata.h
index 4dd12f7fd3..f5d726916c 100644
--- a/tools/qmlprofiler/profiledata.h
+++ b/tools/qmlprofiler/profiledata.h
@@ -47,11 +47,11 @@
#include <QtCore/QObject>
#include <QtCore/QHash>
-struct DeclarativeEvent;
+struct QmlEvent;
struct V8Event;
-typedef QHash<QString, DeclarativeEvent *> DeclarativeEventHash;
-typedef QList<DeclarativeEvent *> DeclarativeEvents;
+typedef QHash<QString, QmlEvent *> QmlEventHash;
+typedef QList<QmlEvent *> QmlEvents;
typedef QList<V8Event *> V8Events;
struct EventLocation
@@ -64,32 +64,32 @@ struct EventLocation
int column;
};
-struct DeclarativeEventSub {
- DeclarativeEventSub(DeclarativeEvent *from)
+struct QmlEventSub {
+ QmlEventSub(QmlEvent *from)
: reference(from), duration(0), calls(0), inLoopPath(false)
{}
- DeclarativeEventSub(DeclarativeEventSub *from)
+ QmlEventSub(QmlEventSub *from)
: reference(from->reference), duration(from->duration),
calls(from->calls), inLoopPath(from->inLoopPath)
{}
- DeclarativeEvent *reference;
+ QmlEvent *reference;
qint64 duration;
qint64 calls;
bool inLoopPath;
};
-struct DeclarativeEvent
+struct QmlEvent
{
- DeclarativeEvent();
- ~DeclarativeEvent();
+ QmlEvent();
+ ~QmlEvent();
QString displayname;
QString eventHashStr;
QString details;
EventLocation location;
QQmlProfilerService::RangeType eventType;
- QHash <QString, DeclarativeEventSub *> parentHash;
- QHash <QString, DeclarativeEventSub *> childrenHash;
+ QHash <QString, QmlEventSub *> parentHash;
+ QHash <QString, QmlEventSub *> childrenHash;
qint64 duration;
qint64 calls;
qint64 minTime;
@@ -100,7 +100,7 @@ struct DeclarativeEvent
int eventId;
bool isBindingLoop;
- DeclarativeEvent &operator=(const DeclarativeEvent &ref);
+ QmlEvent &operator=(const QmlEvent &ref);
};
struct V8EventSub {
@@ -143,8 +143,8 @@ public:
explicit ProfileData(QObject *parent = 0);
~ProfileData();
- DeclarativeEvents getDeclarativeEvents() const;
- DeclarativeEvent *declarativeEvent(int eventId) const;
+ QmlEvents getQmlEvents() const;
+ QmlEvent *qmlEvent(int eventId) const;
const V8Events& getV8Events() const;
V8Event *v8Event(int eventId) const;
@@ -184,7 +184,7 @@ public:
Q_INVOKABLE qint64 traceStartTime() const;
Q_INVOKABLE qint64 traceEndTime() const;
Q_INVOKABLE qint64 traceDuration() const;
- Q_INVOKABLE qint64 declarativeMeasuredTime() const;
+ Q_INVOKABLE qint64 qmlMeasuredTime() const;
Q_INVOKABLE qint64 v8MeasuredTime() const;
void showErrorDialog(const QString &st ) const;
@@ -205,7 +205,7 @@ signals:
public slots:
void clear();
- void addDeclarativeEvent(QQmlProfilerService::RangeType type,
+ void addQmlEvent(QQmlProfilerService::RangeType type,
qint64 startTime, qint64 length,
const QStringList &data,
const EventLocation &location);
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 855ede711c..0b10ec0b15 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -89,10 +89,10 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
m_port(3768),
m_verbose(false),
m_quitAfterSave(false),
- m_declarativeProfilerClient(&m_connection),
+ m_qmlProfilerClient(&m_connection),
m_v8profilerClient(&m_connection),
m_connectionAttempts(0),
- m_declarativeDataReady(false),
+ m_qmlDataReady(false),
m_v8DataReady(false)
{
m_connectTimer.setInterval(1000);
@@ -102,14 +102,14 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
connect(&m_connection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged(QAbstractSocket::SocketState)));
connect(&m_connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
- connect(&m_declarativeProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled()));
- connect(&m_declarativeProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged()));
- connect(&m_declarativeProfilerClient, SIGNAL(range(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)),
- &m_profileData, SLOT(addDeclarativeEvent(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)));
- connect(&m_declarativeProfilerClient, SIGNAL(traceFinished(qint64)), &m_profileData, SLOT(setTraceEndTime(qint64)));
- connect(&m_declarativeProfilerClient, SIGNAL(traceStarted(qint64)), &m_profileData, SLOT(setTraceStartTime(qint64)));
- connect(&m_declarativeProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profileData, SLOT(addFrameEvent(qint64,int,int)));
- connect(&m_declarativeProfilerClient, SIGNAL(complete()), this, SLOT(declarativeComplete()));
+ connect(&m_qmlProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled()));
+ connect(&m_qmlProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged()));
+ connect(&m_qmlProfilerClient, SIGNAL(range(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)),
+ &m_profileData, SLOT(addQmlEvent(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)));
+ connect(&m_qmlProfilerClient, SIGNAL(traceFinished(qint64)), &m_profileData, SLOT(setTraceEndTime(qint64)));
+ connect(&m_qmlProfilerClient, SIGNAL(traceStarted(qint64)), &m_profileData, SLOT(setTraceStartTime(qint64)));
+ connect(&m_qmlProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profileData, SLOT(addFrameEvent(qint64,int,int)));
+ connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete()));
connect(&m_v8profilerClient, SIGNAL(enabledChanged()), this, SLOT(profilerClientEnabled()));
connect(&m_v8profilerClient, SIGNAL(range(int,QString,QString,int,double,double)),
@@ -157,7 +157,7 @@ bool QmlProfilerApplication::parseArguments()
return false;
}
} else if (arg == QLatin1String("-fromStart")) {
- m_declarativeProfilerClient.setRecording(true);
+ m_qmlProfilerClient.setRecording(true);
m_v8profilerClient.setRecording(true);
} else if (arg == QLatin1String("-help") || arg == QLatin1String("-h") || arg == QLatin1String("/h") || arg == QLatin1String("/?")) {
return false;
@@ -232,19 +232,19 @@ void QmlProfilerApplication::userCommand(const QString &command)
printCommands();
} else if (cmd == Constants::CMD_RECORD
|| cmd == Constants::CMD_RECORD2) {
- m_declarativeProfilerClient.setRecording(
- !m_declarativeProfilerClient.isRecording());
+ m_qmlProfilerClient.setRecording(
+ !m_qmlProfilerClient.isRecording());
m_v8profilerClient.setRecording(!m_v8profilerClient.isRecording());
- m_declarativeDataReady = false;
+ m_qmlDataReady = false;
m_v8DataReady = false;
} else if (cmd == Constants::CMD_QUIT
|| cmd == Constants::CMD_QUIT2) {
print(QLatin1String("Quit"));
- if (m_declarativeProfilerClient.isRecording()) {
+ if (m_qmlProfilerClient.isRecording()) {
m_quitAfterSave = true;
- m_declarativeDataReady = false;
+ m_qmlDataReady = false;
m_v8DataReady = false;
- m_declarativeProfilerClient.setRecording(false);
+ m_qmlProfilerClient.setRecording(false);
m_v8profilerClient.setRecording(false);
} else {
quit();
@@ -304,7 +304,7 @@ void QmlProfilerApplication::connected()
"(type 'help'' to show list of commands).")
).arg(m_hostName).arg((m_port)));
QString recordingStatus(QLatin1String("Recording Status: %1"));
- if (!m_declarativeProfilerClient.isRecording() &&
+ if (!m_qmlProfilerClient.isRecording() &&
!m_v8profilerClient.isRecording())
recordingStatus = recordingStatus.arg(QLatin1String("Off"));
else
@@ -340,7 +340,7 @@ void QmlProfilerApplication::processFinished()
if (m_process->exitStatus() == QProcess::NormalExit) {
logStatus(QString("Process exited (%1).").arg(m_process->exitCode()));
- if (m_declarativeProfilerClient.isRecording()) {
+ if (m_qmlProfilerClient.isRecording()) {
logError("Process exited while recording, last trace is lost!");
exit(2);
} else {
@@ -357,7 +357,7 @@ void QmlProfilerApplication::traceClientEnabled()
logStatus("Trace client is attached.");
// blocked server is waiting for recording message from both clients
// once the last one is connected, both messages should be sent
- m_declarativeProfilerClient.sendRecordingStatus();
+ m_qmlProfilerClient.sendRecordingStatus();
m_v8profilerClient.sendRecordingStatus();
}
@@ -367,7 +367,7 @@ void QmlProfilerApplication::profilerClientEnabled()
// blocked server is waiting for recording message from both clients
// once the last one is connected, both messages should be sent
- m_declarativeProfilerClient.sendRecordingStatus();
+ m_qmlProfilerClient.sendRecordingStatus();
m_v8profilerClient.sendRecordingStatus();
}
@@ -384,7 +384,7 @@ void QmlProfilerApplication::traceFinished()
void QmlProfilerApplication::recordingChanged()
{
- if (m_declarativeProfilerClient.isRecording()) {
+ if (m_qmlProfilerClient.isRecording()) {
print(QLatin1String("Recording is on."));
} else {
print(QLatin1String("Recording is off."));
@@ -411,22 +411,22 @@ void QmlProfilerApplication::logStatus(const QString &status)
err << status << endl;
}
-void QmlProfilerApplication::declarativeComplete()
+void QmlProfilerApplication::qmlComplete()
{
- m_declarativeDataReady = true;
+ m_qmlDataReady = true;
if (m_v8profilerClient.state() != QQmlDebugClient::Enabled ||
m_v8DataReady) {
m_profileData.complete();
// once complete is sent, reset the flag
- m_declarativeDataReady = false;
+ m_qmlDataReady = false;
}
}
void QmlProfilerApplication::v8Complete()
{
m_v8DataReady = true;
- if (m_declarativeProfilerClient.state() != QQmlDebugClient::Enabled ||
- m_declarativeDataReady) {
+ if (m_qmlProfilerClient.state() != QQmlDebugClient::Enabled ||
+ m_qmlDataReady) {
m_profileData.complete();
// once complete is sent, reset the flag
m_v8DataReady = false;
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index 5bedb46cff..3937db7e5f 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -80,7 +80,7 @@ private slots:
void logError(const QString &error);
void logStatus(const QString &status);
- void declarativeComplete();
+ void qmlComplete();
void v8Complete();
private:
@@ -104,13 +104,13 @@ private:
bool m_quitAfterSave;
QQmlDebugConnection m_connection;
- DeclarativeProfileClient m_declarativeProfilerClient;
+ QmlProfileClient m_qmlProfilerClient;
V8ProfileClient m_v8profilerClient;
ProfileData m_profileData;
QTimer m_connectTimer;
uint m_connectionAttempts;
- bool m_declarativeDataReady;
+ bool m_qmlDataReady;
bool m_v8DataReady;
};