summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/anchors/anchor-changes.qml46
-rw-r--r--examples/declarative/animation/animation.qml55
-rw-r--r--examples/declarative/aspectratio/face_fit.qml24
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml26
-rw-r--r--examples/declarative/aspectratio/pics/face.pngbin0 -> 905 bytes
-rw-r--r--examples/declarative/aspectratio/scale_and_crop.qml19
-rw-r--r--examples/declarative/aspectratio/scale_and_sidecrop.qml20
-rw-r--r--examples/declarative/aspectratio/scale_to_fit.qml20
-rw-r--r--examples/declarative/aspectratio/scale_to_fit_simple.qml19
-rw-r--r--examples/declarative/behaviours/MyRect.qml13
-rw-r--r--examples/declarative/behaviours/test.qml98
-rw-r--r--examples/declarative/border-image/MyBorderImage.qml36
-rw-r--r--examples/declarative/border-image/animated.qml54
-rw-r--r--examples/declarative/border-image/borders.qml18
-rw-r--r--examples/declarative/border-image/bw.pngbin0 -> 1357 bytes
-rw-r--r--examples/declarative/border-image/colors-round.sci7
-rw-r--r--examples/declarative/border-image/colors-stretch.sci5
-rw-r--r--examples/declarative/border-image/colors.pngbin0 -> 1655 bytes
-rw-r--r--examples/declarative/border-image/example.qml31
-rw-r--r--examples/declarative/clock/Clock.qml80
-rw-r--r--examples/declarative/clock/background.pngbin0 -> 46895 bytes
-rw-r--r--examples/declarative/clock/display.qml7
-rw-r--r--examples/declarative/clock/hour.pngbin0 -> 391 bytes
-rw-r--r--examples/declarative/clock/minute.pngbin0 -> 445 bytes
-rw-r--r--examples/declarative/clock/second.pngbin0 -> 345 bytes
-rw-r--r--examples/declarative/connections/connections.qml31
-rw-r--r--examples/declarative/declarative.pro4
-rw-r--r--examples/declarative/dial/DialLibrary/Dial.qml38
-rw-r--r--examples/declarative/dial/DialLibrary/background.pngbin0 -> 35876 bytes
-rw-r--r--examples/declarative/dial/DialLibrary/needle.pngbin0 -> 342 bytes
-rw-r--r--examples/declarative/dial/DialLibrary/needle_shadow.pngbin0 -> 632 bytes
-rw-r--r--examples/declarative/dial/DialLibrary/overlay.pngbin0 -> 3564 bytes
-rw-r--r--examples/declarative/dial/dial.qml33
-rw-r--r--examples/declarative/dynamic/DynRect.qml9
-rw-r--r--examples/declarative/dynamic/dynamic.js57
-rw-r--r--examples/declarative/dynamic/dynamic.qml35
-rw-r--r--examples/declarative/dynamic/star.pngbin0 -> 262 bytes
-rw-r--r--examples/declarative/easing/easing.qml94
-rw-r--r--examples/declarative/effects/pic.jpgbin0 -> 7016 bytes
-rw-r--r--examples/declarative/effects/test.qml75
-rw-r--r--examples/declarative/extending/adding/adding.pro11
-rw-r--r--examples/declarative/extending/adding/adding.qrc5
-rw-r--r--examples/declarative/extending/adding/example.qml8
-rw-r--r--examples/declarative/extending/adding/main.cpp22
-rw-r--r--examples/declarative/extending/adding/person.cpp30
-rw-r--r--examples/declarative/extending/adding/person.h27
-rw-r--r--examples/declarative/extending/attached/attached.pro13
-rw-r--r--examples/declarative/extending/attached/attached.qrc5
-rw-r--r--examples/declarative/extending/attached/birthdayparty.cpp45
-rw-r--r--examples/declarative/extending/attached/birthdayparty.h45
-rw-r--r--examples/declarative/extending/attached/example.qml29
-rw-r--r--examples/declarative/extending/attached/main.cpp44
-rw-r--r--examples/declarative/extending/attached/person.cpp83
-rw-r--r--examples/declarative/extending/attached/person.h67
-rw-r--r--examples/declarative/extending/binding/binding.pro15
-rw-r--r--examples/declarative/extending/binding/binding.qrc5
-rw-r--r--examples/declarative/extending/binding/birthdayparty.cpp66
-rw-r--r--examples/declarative/extending/binding/birthdayparty.h61
-rw-r--r--examples/declarative/extending/binding/example.qml37
-rw-r--r--examples/declarative/extending/binding/happybirthday.cpp47
-rw-r--r--examples/declarative/extending/binding/happybirthday.h32
-rw-r--r--examples/declarative/extending/binding/main.cpp45
-rw-r--r--examples/declarative/extending/binding/person.cpp103
-rw-r--r--examples/declarative/extending/binding/person.h75
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.cpp23
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h29
-rw-r--r--examples/declarative/extending/coercion/coercion.pro13
-rw-r--r--examples/declarative/extending/coercion/coercion.qrc5
-rw-r--r--examples/declarative/extending/coercion/example.qml15
-rw-r--r--examples/declarative/extending/coercion/main.cpp30
-rw-r--r--examples/declarative/extending/coercion/person.cpp46
-rw-r--r--examples/declarative/extending/coercion/person.h41
-rw-r--r--examples/declarative/extending/default/birthdayparty.cpp23
-rw-r--r--examples/declarative/extending/default/birthdayparty.h30
-rw-r--r--examples/declarative/extending/default/default.pro13
-rw-r--r--examples/declarative/extending/default/default.qrc5
-rw-r--r--examples/declarative/extending/default/example.qml14
-rw-r--r--examples/declarative/extending/default/main.cpp30
-rw-r--r--examples/declarative/extending/default/person.cpp42
-rw-r--r--examples/declarative/extending/default/person.h39
-rw-r--r--examples/declarative/extending/extended/example.qml7
-rw-r--r--examples/declarative/extending/extended/extended.pro11
-rw-r--r--examples/declarative/extending/extended/extended.qrc5
-rw-r--r--examples/declarative/extending/extended/lineedit.cpp66
-rw-r--r--examples/declarative/extending/extended/lineedit.h34
-rw-r--r--examples/declarative/extending/extended/main.cpp22
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.cpp23
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.h28
-rw-r--r--examples/declarative/extending/grouped/example.qml33
-rw-r--r--examples/declarative/extending/grouped/grouped.pro13
-rw-r--r--examples/declarative/extending/grouped/grouped.qrc5
-rw-r--r--examples/declarative/extending/grouped/main.cpp40
-rw-r--r--examples/declarative/extending/grouped/person.cpp83
-rw-r--r--examples/declarative/extending/grouped/person.h69
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp25
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h35
-rw-r--r--examples/declarative/extending/properties/example.qml15
-rw-r--r--examples/declarative/extending/properties/main.cpp26
-rw-r--r--examples/declarative/extending/properties/person.cpp28
-rw-r--r--examples/declarative/extending/properties/person.h25
-rw-r--r--examples/declarative/extending/properties/properties.pro13
-rw-r--r--examples/declarative/extending/properties/properties.qrc5
-rw-r--r--examples/declarative/extending/signal/birthdayparty.cpp51
-rw-r--r--examples/declarative/extending/signal/birthdayparty.h52
-rw-r--r--examples/declarative/extending/signal/example.qml32
-rw-r--r--examples/declarative/extending/signal/main.cpp45
-rw-r--r--examples/declarative/extending/signal/person.cpp83
-rw-r--r--examples/declarative/extending/signal/person.h67
-rw-r--r--examples/declarative/extending/signal/signal.pro13
-rw-r--r--examples/declarative/extending/signal/signal.qrc5
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp61
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h57
-rw-r--r--examples/declarative/extending/valuesource/example.qml36
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.cpp42
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.h36
-rw-r--r--examples/declarative/extending/valuesource/main.cpp45
-rw-r--r--examples/declarative/extending/valuesource/person.cpp83
-rw-r--r--examples/declarative/extending/valuesource/person.h67
-rw-r--r--examples/declarative/extending/valuesource/valuesource.pro15
-rw-r--r--examples/declarative/extending/valuesource/valuesource.qrc5
-rw-r--r--examples/declarative/fillmode/face.pngbin0 -> 905 bytes
-rw-r--r--examples/declarative/fillmode/fillmode.qml42
-rw-r--r--examples/declarative/flowview/flickr.qml46
-rw-r--r--examples/declarative/flowview/flowview.qml147
-rw-r--r--examples/declarative/flowview/rect.qml4
-rw-r--r--examples/declarative/focusscope/test.qml76
-rw-r--r--examples/declarative/focusscope/test2.qml40
-rw-r--r--examples/declarative/focusscope/test3.qml50
-rw-r--r--examples/declarative/follow/follow.qml73
-rw-r--r--examples/declarative/follow/pong.qml69
-rw-r--r--examples/declarative/fonts/fonts.qml66
-rw-r--r--examples/declarative/fonts/fonts/Fontin-Bold.ttfbin0 -> 30916 bytes
-rw-r--r--examples/declarative/layouts/Button.qml20
-rw-r--r--examples/declarative/layouts/add.pngbin0 -> 1577 bytes
-rw-r--r--examples/declarative/layouts/del.pngbin0 -> 1661 bytes
-rw-r--r--examples/declarative/layouts/layouts.qml25
-rw-r--r--examples/declarative/layouts/positioners.qml51
-rw-r--r--examples/declarative/listview/content/MediaButton.qml39
-rw-r--r--examples/declarative/listview/content/pics/button-pressed.pngbin0 -> 571 bytes
-rw-r--r--examples/declarative/listview/content/pics/button.pngbin0 -> 564 bytes
-rw-r--r--examples/declarative/listview/content/pics/fruit-salad.jpgbin0 -> 17952 bytes
-rw-r--r--examples/declarative/listview/content/pics/hamburger.jpgbin0 -> 8572 bytes
-rw-r--r--examples/declarative/listview/content/pics/lemonade.jpgbin0 -> 6645 bytes
-rw-r--r--examples/declarative/listview/content/pics/moreDown.pngbin0 -> 217 bytes
-rw-r--r--examples/declarative/listview/content/pics/moreUp.pngbin0 -> 212 bytes
-rw-r--r--examples/declarative/listview/content/pics/pancakes.jpgbin0 -> 9163 bytes
-rw-r--r--examples/declarative/listview/content/pics/vegetable-soup.jpgbin0 -> 8639 bytes
-rw-r--r--examples/declarative/listview/dummydata/MyPetsModel.qml61
-rw-r--r--examples/declarative/listview/dummydata/Recipes.qml90
-rw-r--r--examples/declarative/listview/highlight.qml57
-rw-r--r--examples/declarative/listview/itemlist.qml57
-rw-r--r--examples/declarative/listview/listview.qml82
-rw-r--r--examples/declarative/listview/recipes.qml132
-rw-r--r--examples/declarative/listview/sections.qml71
-rw-r--r--examples/declarative/loader/Browser.qml113
-rw-r--r--examples/declarative/loader/Button.qml16
-rw-r--r--examples/declarative/loader/images/fileopen.pngbin0 -> 953 bytes
-rw-r--r--examples/declarative/loader/images/up.pngbin0 -> 662 bytes
-rw-r--r--examples/declarative/loader/loader.pro9
-rw-r--r--examples/declarative/loader/loader.qml10
-rw-r--r--examples/declarative/loader/loader.qrc9
-rw-r--r--examples/declarative/loader/main.cpp212
-rw-r--r--examples/declarative/minehunt/Description.qml34
-rw-r--r--examples/declarative/minehunt/Explosion.qml29
-rw-r--r--examples/declarative/minehunt/main.cpp309
-rw-r--r--examples/declarative/minehunt/minehunt.pro9
-rw-r--r--examples/declarative/minehunt/minehunt.qml187
-rw-r--r--examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpgbin0 -> 30730 bytes
-rw-r--r--examples/declarative/minehunt/pics/back.pngbin0 -> 558 bytes
-rw-r--r--examples/declarative/minehunt/pics/bomb-color.pngbin0 -> 284 bytes
-rw-r--r--examples/declarative/minehunt/pics/bomb.pngbin0 -> 535 bytes
-rw-r--r--examples/declarative/minehunt/pics/face-sad.pngbin0 -> 14844 bytes
-rw-r--r--examples/declarative/minehunt/pics/face-smile-big.pngbin0 -> 13810 bytes
-rw-r--r--examples/declarative/minehunt/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/minehunt/pics/flag-color.pngbin0 -> 219 bytes
-rw-r--r--examples/declarative/minehunt/pics/flag.pngbin0 -> 196 bytes
-rw-r--r--examples/declarative/minehunt/pics/front.pngbin0 -> 580 bytes
-rw-r--r--examples/declarative/minehunt/pics/star.pngbin0 -> 2677 bytes
-rw-r--r--examples/declarative/modules/builtin-version.qml3
-rw-r--r--examples/declarative/modules/installed-qualified.qml6
-rw-r--r--examples/declarative/modules/installed-version.qml9
-rw-r--r--examples/declarative/modules/installed.qml4
-rw-r--r--examples/declarative/modules/lib/com/nokia/Foo/Bar.qml5
-rw-r--r--examples/declarative/modules/lib/com/nokia/Foo/Bar17.qml5
-rw-r--r--examples/declarative/modules/lib/com/nokia/Foo/Baz.qml5
-rw-r--r--examples/declarative/modules/lib/com/nokia/Foo/qmldir6
-rw-r--r--examples/declarative/modules/local-qualified.qml9
-rw-r--r--examples/declarative/modules/local.qml4
-rw-r--r--examples/declarative/modules/remote-qualified.qml6
-rw-r--r--examples/declarative/modules/remote-zipped.qml6
-rw-r--r--examples/declarative/modules/wrong-installed-version.qml4
-rw-r--r--examples/declarative/modules/wrong-installed.qml5
-rw-r--r--examples/declarative/modules/wrong-local-qualified.qml6
-rw-r--r--examples/declarative/modules/wrong-local.qml8
-rw-r--r--examples/declarative/modules/zipped-qualified.qml7
-rw-r--r--examples/declarative/modules/zipped.qml7
-rw-r--r--examples/declarative/mouseregion/mouse.qml40
-rw-r--r--examples/declarative/scrollbar/ScrollBar.qml31
-rw-r--r--examples/declarative/scrollbar/display.qml59
-rw-r--r--examples/declarative/scrollbar/pics/niagara_falls.jpgbin0 -> 604121 bytes
-rw-r--r--examples/declarative/slideswitch/Switch.qml58
-rw-r--r--examples/declarative/slideswitch/background.svg23
-rw-r--r--examples/declarative/slideswitch/display.qml10
-rw-r--r--examples/declarative/slideswitch/knob.svg867
-rw-r--r--examples/declarative/smooth/GradientRect.qml25
-rw-r--r--examples/declarative/smooth/MyRect.qml21
-rw-r--r--examples/declarative/smooth/rect-painting.qml64
-rw-r--r--examples/declarative/snow/ImageBatch.qml72
-rw-r--r--examples/declarative/snow/Loading.qml8
-rw-r--r--examples/declarative/snow/create.js12
-rw-r--r--examples/declarative/snow/pics/loading.pngbin0 -> 761 bytes
-rw-r--r--examples/declarative/snow/snow.qml69
-rw-r--r--examples/declarative/states/states.qml48
-rw-r--r--examples/declarative/states/transitions.qml68
-rw-r--r--examples/declarative/support/contact.cpp83
-rw-r--r--examples/declarative/support/contact.h141
-rw-r--r--examples/declarative/support/contactmodel.cpp159
-rw-r--r--examples/declarative/support/contactmodel.h55
-rw-r--r--examples/declarative/support/support.pro12
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/Removebutton.qml11
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml36
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2/RemoveButton.qml20
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2a/RemoveButton.qml22
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/3/RemoveButton.qml41
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml107
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml114
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml114
-rw-r--r--examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml59
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml32
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml112
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml35
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml112
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml35
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml114
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml34
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml120
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml39
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml49
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml61
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml144
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml116
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml52
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml58
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml145
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml120
-rw-r--r--examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml59
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml46
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml124
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml137
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml31
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml59
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml60
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml48
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml58
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml145
-rw-r--r--examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml119
-rwxr-xr-xexamples/declarative/tutorials/contacts/shared/contactGenSQL.pl82
-rw-r--r--examples/declarative/tutorials/contacts/shared/contacts.sqlitebin0 -> 86016 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/email.txt7
-rw-r--r--examples/declarative/tutorials/contacts/shared/english-f.txt143
-rw-r--r--examples/declarative/tutorials/contacts/shared/english-m.txt130
-rw-r--r--examples/declarative/tutorials/contacts/shared/english-s.txt1003
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/cancel.pngbin0 -> 1038 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/email.pngbin0 -> 977 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/new.pngbin0 -> 688 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/ok.pngbin0 -> 655 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/phone.pngbin0 -> 624 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/search.pngbin0 -> 635 bytes
-rw-r--r--examples/declarative/tutorials/contacts/shared/pics/trash.pngbin0 -> 989 bytes
-rw-r--r--examples/declarative/tutorials/helloworld/t1/tutorial1.qml16
-rw-r--r--examples/declarative/tutorials/helloworld/t2/Cell.qml18
-rw-r--r--examples/declarative/tutorials/helloworld/t2/tutorial2.qml29
-rw-r--r--examples/declarative/tutorials/helloworld/t3/Cell.qml17
-rw-r--r--examples/declarative/tutorials/helloworld/t3/tutorial3.qml56
-rw-r--r--examples/declarative/velocity/Day.qml112
-rw-r--r--examples/declarative/velocity/cork.jpgbin0 -> 88766 bytes
-rw-r--r--examples/declarative/velocity/sticky.pngbin0 -> 15319 bytes
-rw-r--r--examples/declarative/velocity/tack.pngbin0 -> 7282 bytes
-rw-r--r--examples/declarative/velocity/velocity.qml115
-rw-r--r--examples/declarative/webview/autosize.qml61
-rw-r--r--examples/declarative/webview/content/FieldText.qml163
-rw-r--r--examples/declarative/webview/content/SpinSquare.qml26
-rw-r--r--examples/declarative/webview/content/pics/cancel.pngbin0 -> 1038 bytes
-rw-r--r--examples/declarative/webview/content/pics/ok.pngbin0 -> 655 bytes
-rw-r--r--examples/declarative/webview/evalandattach.html31
-rw-r--r--examples/declarative/webview/evalandattach.qml54
-rw-r--r--examples/declarative/webview/inline-html.qml14
-rw-r--r--examples/declarative/webview/newwindows.html3
-rw-r--r--examples/declarative/webview/newwindows.qml28
-rw-r--r--examples/declarative/webview/qml-in-html.qml32
-rw-r--r--examples/declarative/webview/transparent.qml13
-rw-r--r--examples/declarative/xmldata/daringfireball.qml60
-rw-r--r--examples/declarative/xmldata/yahoonews.qml106
-rw-r--r--examples/examples.pro1
294 files changed, 13051 insertions, 0 deletions
diff --git a/examples/declarative/anchors/anchor-changes.qml b/examples/declarative/anchors/anchor-changes.qml
new file mode 100644
index 0000000..8996439
--- /dev/null
+++ b/examples/declarative/anchors/anchor-changes.qml
@@ -0,0 +1,46 @@
+import Qt 4.6
+
+Item {
+ id: Window
+ width: 200; height: 450
+
+ Rectangle {
+ id: TitleBar; color: "Gray"
+ anchors.top: parent.top; height: 50
+ width: parent.width
+ }
+
+ Rectangle {
+ id: StatusBar; color: "Gray"
+ height: 50; anchors.bottom: parent.bottom
+ width: parent.width
+ }
+
+ Rectangle {
+ id: Content
+ anchors.top: TitleBar.bottom; anchors.bottom: StatusBar.top
+ width: parent.width
+
+ Text { text: "Top"; anchors.top: parent.top }
+ Text { text: "Bottom"; anchors.bottom: parent.bottom }
+ }
+
+ MouseRegion {
+ anchors.fill: Content
+ onPressed: Window.state = "FullScreen"
+ onReleased: Window.state = ""
+ }
+
+ states : State {
+ name: "FullScreen"
+ //! [0]
+ AnchorChanges {
+ target: Content; top: Window.top; bottom: Window.bottom
+ }
+ //! [0]
+ }
+
+ transitions : Transition {
+ NumberAnimation { properties: "y,height" }
+ }
+}
diff --git a/examples/declarative/animation/animation.qml b/examples/declarative/animation/animation.qml
new file mode 100644
index 0000000..ccfe164
--- /dev/null
+++ b/examples/declarative/animation/animation.qml
@@ -0,0 +1,55 @@
+import Qt 4.6
+
+Rectangle {
+ width: 400
+ height: 200
+ color: "white"
+ Rectangle {
+ width: 40
+ height: 40
+ y: 80
+ color: "#FF0000"
+ radius: 10
+ // Animate the x property. Setting repeat to true makes the
+ // animation repeat indefinitely, otherwise it would only run once.
+ x: SequentialAnimation {
+ running: true
+ repeat: true
+ // Move from 0 to 360 in 500ms, using the easeInOutQuad easing function
+ NumberAnimation {
+ from: 0
+ to: 360
+ easing: "easeInOutQuad"
+ duration: 500
+ }
+ // Then pause for 200ms
+ PauseAnimation {
+ duration: 200
+ }
+ // Then move back to 0 in 2 seconds, using the easeInOutElastic easing function
+ NumberAnimation {
+ from: 360
+ to: 0
+ easing: "easeInOutElastic"
+ duration: 2000
+ }
+ }
+ // Alternate color between red and green
+ color: SequentialAnimation {
+ running: true
+ repeat: true
+ ColorAnimation {
+ property: "color"
+ from: "#FF0000"
+ to: "#00FF00"
+ duration: 5000
+ }
+ ColorAnimation {
+ property: "color"
+ from: "#00FF00"
+ to: "#FF0000"
+ duration: 5000
+ }
+ }
+ }
+}
diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml
new file mode 100644
index 0000000..4573160
--- /dev/null
+++ b/examples/declarative/aspectratio/face_fit.qml
@@ -0,0 +1,24 @@
+import Qt 4.6
+
+// Here, we implement a hybrid of the "scale to fit" and "scale and crop"
+// behaviours which will crop up to 25% from *one* dimension if necessary
+// to fully scale the other. This is a realistic algorithm, for example
+// when the edges of the image contain less vital information than the
+// center - such as a face.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: Image.width
+ height: Image.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: Image
+ source: "pics/face.png"
+ x: (parent.width-width*scale)/2
+ y: (parent.height-height*scale)/2
+ scale: Math.max(Math.min(parent.width/width*1.333,parent.height/height),
+ Math.min(parent.width/width,parent.height/height*1.333))
+ }
+}
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml
new file mode 100644
index 0000000..2768150
--- /dev/null
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -0,0 +1,26 @@
+import Qt 4.6
+
+// Here, we extend the "face_fit" example with animation to show how truly
+// diverse and usage-specific behaviours are made possible by NOT putting a
+// hard-coded aspect ratio feature into the Image primitive.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: Image.width
+ height: Image.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: Image
+ source: "pics/face.png"
+ x: (parent.width-width*scale)/2
+ y: (parent.height-height*scale)/2
+ scale: Follow {
+ source: Math.max(Math.min(Image.parent.width/Image.width*1.333,Image.parent.height/Image.height),
+ Math.min(Image.parent.width/Image.width,Image.parent.height/Image.height*1.333))
+ spring: 1
+ damping: 0.05
+ }
+ }
+}
diff --git a/examples/declarative/aspectratio/pics/face.png b/examples/declarative/aspectratio/pics/face.png
new file mode 100644
index 0000000..9623b1a
--- /dev/null
+++ b/examples/declarative/aspectratio/pics/face.png
Binary files differ
diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml
new file mode 100644
index 0000000..75080b4
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_and_crop.qml
@@ -0,0 +1,19 @@
+import Qt 4.6
+
+// Here, we implement "Scale and Crop" behaviour.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: Image.width
+ height: Image.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: Image
+ source: "pics/face.png"
+ x: (parent.width-width*scale)/2
+ y: (parent.height-height*scale)/2
+ scale: Math.max(parent.width/width,parent.height/height)
+ }
+}
diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml
new file mode 100644
index 0000000..a6bd2c8
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+// Here, we implement a variant of "Scale and Crop" behaviour, where we
+// crop the sides if necessary to fully fit vertically, but not the reverse.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: Image.width
+ height: Image.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: Image
+ source: "pics/face.png"
+ x: (parent.width-width*scale)/2
+ y: (parent.height-height*scale)/2
+ scale: parent.height/height
+ }
+}
diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml
new file mode 100644
index 0000000..744abce
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_to_fit.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+// Here, we implement "Scale to Fit" behaviour "manually", rather
+// than using the preserveAspect property.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: Image.width
+ height: Image.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: Image
+ source: "pics/face.png"
+ x: (parent.width-width*scale)/2
+ y: (parent.height-height*scale)/2
+ scale: Math.min(parent.width/width,parent.height/height)
+ }
+}
diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml
new file mode 100644
index 0000000..4ee06ba
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml
@@ -0,0 +1,19 @@
+import Qt 4.6
+
+// Here, we implement "Scale to Fit" behaviour, using the
+// preserveAspect property.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: Image.width
+ height: Image.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: Image
+ source: "pics/face.png"
+ fillMode: "PreserveAspect"
+ anchors.fill: parent
+ }
+}
diff --git a/examples/declarative/behaviours/MyRect.qml b/examples/declarative/behaviours/MyRect.qml
new file mode 100644
index 0000000..fca1f70
--- /dev/null
+++ b/examples/declarative/behaviours/MyRect.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+Rectangle {
+ radius: 15
+ border.color: "black"
+ width: 100
+ height: 100
+ id: Page
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { bluerect.parent = Page; bluerect.x=0 }
+ }
+}
diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml
new file mode 100644
index 0000000..1dd0658
--- /dev/null
+++ b/examples/declarative/behaviours/test.qml
@@ -0,0 +1,98 @@
+import Qt 4.6
+
+Rectangle {
+ color: "lightsteelblue"
+ width: 800
+ height: 600
+ id: Page
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { bluerect.parent = Page; bluerect.x = mouseX; }
+ }
+ MyRect {
+ color: "green"
+ x: 200
+ y: 200
+ }
+ MyRect {
+ color: "red"
+ x: 400
+ y: 200
+ }
+ MyRect {
+ color: "yellow"
+ x: 400
+ y: 400
+ }
+ MyRect {
+ color: "orange"
+ x: 400
+ y: 500
+ }
+ MyRect {
+ color: "pink"
+ x: 400
+ y: 0
+ }
+ MyRect {
+ color: "lightsteelblue"
+ x: 100
+ y: 500
+ }
+ MyRect {
+ color: "black"
+ x: 0
+ y: 200
+ }
+ MyRect {
+ color: "white"
+ x: 400
+ y: 0
+ }
+ Rectangle {
+ color: "blue"
+ x: 0
+ y: 0
+ width: 100
+ height: 100
+ id: bluerect
+ x: Behavior {
+ SequentialAnimation {
+ NumberAnimation {
+ target: bluerect
+ properties: "y"
+ from: 0
+ to: 10
+ easing: "easeOutBounce(amplitude:30)"
+ duration: 250
+ }
+ NumberAnimation {
+ target: bluerect
+ properties: "y"
+ from: 10
+ to: 0
+ easing: "easeOutBounce(amplitude:30)"
+ duration: 250
+ }
+ }
+ NumberAnimation { duration: 500 }
+ }
+ parent: Behavior {
+ SequentialAnimation {
+ NumberAnimation {
+ target: bluerect
+ properties: "opacity"
+ to: 0
+ duration: 150
+ }
+ PropertyAction {}
+ NumberAnimation {
+ target: bluerect
+ properties: "opacity"
+ to: 1
+ duration: 150
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/border-image/MyBorderImage.qml b/examples/declarative/border-image/MyBorderImage.qml
new file mode 100644
index 0000000..f9531df
--- /dev/null
+++ b/examples/declarative/border-image/MyBorderImage.qml
@@ -0,0 +1,36 @@
+import Qt 4.6
+
+Item {
+ property var horizontalMode : "Stretch"
+ property var verticalMode : "Stretch"
+ property string source
+ property int minWidth
+ property int minHeight
+ property int maxWidth
+ property int maxHeight
+ property int margin
+
+ id: Container
+ width: 240; height: 240
+ BorderImage {
+ x: Container.width / 2 - width / 2
+ y: Container.height / 2 - height / 2
+ width: SequentialAnimation {
+ running: true; repeat: true
+ NumberAnimation { from: Container.minWidth; to: Container.maxWidth; duration: 2000; easing: "easeInOutQuad"}
+ NumberAnimation { from: Container.maxWidth; to: Container.minWidth; duration: 2000; easing: "easeInOutQuad" }
+ }
+ height: SequentialAnimation {
+ running: true; repeat: true
+ NumberAnimation { from: Container.minHeight; to: Container.maxHeight; duration: 2000; easing: "easeInOutQuad"}
+ NumberAnimation { from: Container.maxHeight; to: Container.minHeight; duration: 2000; easing: "easeInOutQuad" }
+ }
+ source: Container.source
+ horizontalTileMode: Container.horizontalMode
+ verticalTileMode: Container.verticalMode
+ border.top: Container.margin
+ border.left: Container.margin
+ border.bottom: Container.margin
+ border.right: Container.margin
+ }
+}
diff --git a/examples/declarative/border-image/animated.qml b/examples/declarative/border-image/animated.qml
new file mode 100644
index 0000000..2fe2ea9
--- /dev/null
+++ b/examples/declarative/border-image/animated.qml
@@ -0,0 +1,54 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ color: "white"
+ width: 1030; height: 540
+
+ MyBorderImage {
+ x: 20; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "colors.png"; margin: 30
+ }
+ MyBorderImage {
+ x: 270; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "colors.png"; margin: 30
+ horizontalMode: "Repeat"; verticalMode: "Repeat"
+ }
+ MyBorderImage {
+ x: 520; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "colors.png"; margin: 30
+ horizontalMode: "Stretch"; verticalMode: "Repeat"
+ }
+ MyBorderImage {
+ x: 770; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "colors.png"; margin: 30
+ horizontalMode: "Round"; verticalMode: "Round"
+ }
+ MyBorderImage {
+ x: 20; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "bw.png"; margin: 10
+ }
+ MyBorderImage {
+ x: 270; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "bw.png"; margin: 10
+ horizontalMode: "Repeat"; verticalMode: "Repeat"
+ }
+ MyBorderImage {
+ x: 520; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "bw.png"; margin: 10
+ horizontalMode: "Stretch"; verticalMode: "Repeat"
+ }
+ MyBorderImage {
+ x: 770; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "bw.png"; margin: 10
+ horizontalMode: "Round"; verticalMode: "Round"
+ }
+}
diff --git a/examples/declarative/border-image/borders.qml b/examples/declarative/border-image/borders.qml
new file mode 100644
index 0000000..73758f2
--- /dev/null
+++ b/examples/declarative/border-image/borders.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ color: "white"
+ width: 520; height: 280
+
+ BorderImage {
+ x: 20; y: 20; width: 230; height: 240
+ smooth: true
+ source: "colors-stretch.sci"
+ }
+ BorderImage {
+ x: 270; y: 20; width: 230; height: 240
+ smooth: true
+ source: "colors-round.sci"
+ }
+}
diff --git a/examples/declarative/border-image/bw.png b/examples/declarative/border-image/bw.png
new file mode 100644
index 0000000..486eaae
--- /dev/null
+++ b/examples/declarative/border-image/bw.png
Binary files differ
diff --git a/examples/declarative/border-image/colors-round.sci b/examples/declarative/border-image/colors-round.sci
new file mode 100644
index 0000000..3784e10
--- /dev/null
+++ b/examples/declarative/border-image/colors-round.sci
@@ -0,0 +1,7 @@
+gridLeft:30
+gridTop:30
+gridRight:30
+gridBottom:30
+horizontalTileRule:Round
+verticalTileRule:Round
+imageFile:colors.png
diff --git a/examples/declarative/border-image/colors-stretch.sci b/examples/declarative/border-image/colors-stretch.sci
new file mode 100644
index 0000000..c693599
--- /dev/null
+++ b/examples/declarative/border-image/colors-stretch.sci
@@ -0,0 +1,5 @@
+gridLeft:30
+gridTop:30
+gridRight:30
+gridBottom:30
+imageFile:colors.png
diff --git a/examples/declarative/border-image/colors.png b/examples/declarative/border-image/colors.png
new file mode 100644
index 0000000..dfb62f3
--- /dev/null
+++ b/examples/declarative/border-image/colors.png
Binary files differ
diff --git a/examples/declarative/border-image/example.qml b/examples/declarative/border-image/example.qml
new file mode 100644
index 0000000..87d3f37
--- /dev/null
+++ b/examples/declarative/border-image/example.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ color: "white"
+ width: 520; height: 280
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 50
+//! [0]
+ BorderImage {
+ width: 180; height: 180
+ border.left: 30; border.top: 30
+ border.right: 30; border.bottom: 30
+ horizontalTileMode: "Stretch"
+ verticalTileMode: "Stretch"
+ source: "colors.png"
+ }
+
+ BorderImage {
+ width: 180; height: 180
+ border.left: 30; border.top: 30
+ border.right: 30; border.bottom: 30
+ horizontalTileMode: "Round"
+ verticalTileMode: "Round"
+ source: "colors.png"
+ }
+//! [0]
+ }
+}
diff --git a/examples/declarative/clock/Clock.qml b/examples/declarative/clock/Clock.qml
new file mode 100644
index 0000000..e152be3
--- /dev/null
+++ b/examples/declarative/clock/Clock.qml
@@ -0,0 +1,80 @@
+import Qt 4.6
+
+Item {
+ id: Clock
+ width: 200; height: 200
+ property var time
+ property var hours
+ property var minutes
+ property var seconds
+ onTimeChanged: {
+ var date = new Date;
+ hours = date.getHours();
+ minutes = date.getMinutes();
+ seconds = date.getSeconds();
+ }
+ Timer {
+ interval: 100; running: true; repeat: true; triggeredOnStart: true
+ onTriggered: Clock.time = new Date()
+ }
+
+ Image { source: "background.png" }
+ Image {
+ x: 95
+ y: 54
+ source: "hour.png"
+ smooth: true
+ transform: Rotation {
+ id: HourRotation
+ origin.x: 4; origin.y: 45
+ angle: 0
+ angle: Follow {
+ spring: 2
+ damping: .2
+ source: Clock.hours * 50 * 3 + Clock.minutes / 2
+ }
+ }
+ }
+ Image {
+ x: 95
+ y: 30
+ source: "minute.png"
+ smooth: true
+ transform: Rotation {
+ id: MinuteRotation
+ origin.x: 4; origin.y: 70
+ angle: 0
+ angle: Follow {
+ spring: 2
+ damping: .2
+ source: Clock.minutes * 6
+ }
+ }
+ }
+ Image {
+ x: 96
+ y: 40
+ source: "second.png"
+ smooth: true
+ transform: Rotation {
+ id: SecondRotation
+ origin.x: 2; origin.y: 60
+ angle: 0
+ angle: Follow {
+ spring: 5
+ damping: .25
+ modulus: 360
+ source: Clock.seconds * 6
+ }
+ }
+ }
+
+ Rectangle {
+ x: 93
+ y: 94
+ width: 11
+ height: 11
+ radius: 5
+ color: "black"
+ }
+}
diff --git a/examples/declarative/clock/background.png b/examples/declarative/clock/background.png
new file mode 100644
index 0000000..a885950
--- /dev/null
+++ b/examples/declarative/clock/background.png
Binary files differ
diff --git a/examples/declarative/clock/display.qml b/examples/declarative/clock/display.qml
new file mode 100644
index 0000000..59f4763
--- /dev/null
+++ b/examples/declarative/clock/display.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Rectangle {
+ width: childrenRect.width
+ height: childrenRect.height
+ Clock { id: Clock }
+}
diff --git a/examples/declarative/clock/hour.png b/examples/declarative/clock/hour.png
new file mode 100644
index 0000000..603466b
--- /dev/null
+++ b/examples/declarative/clock/hour.png
Binary files differ
diff --git a/examples/declarative/clock/minute.png b/examples/declarative/clock/minute.png
new file mode 100644
index 0000000..0207405
--- /dev/null
+++ b/examples/declarative/clock/minute.png
Binary files differ
diff --git a/examples/declarative/clock/second.png b/examples/declarative/clock/second.png
new file mode 100644
index 0000000..bfcef68
--- /dev/null
+++ b/examples/declarative/clock/second.png
Binary files differ
diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml
new file mode 100644
index 0000000..521cc01
--- /dev/null
+++ b/examples/declarative/connections/connections.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+
+Rectangle {
+ id: rect
+ color: "blue"
+ width: 40
+ height: 30
+ Rectangle {
+ id: dot
+ color: "red"
+ width: 3
+ height: 3
+ x: rect.width/2
+ y: rect.height/2
+ }
+ MouseRegion {
+ id: mr
+ anchors.fill: rect
+ }
+ Connection {
+ sender: mr
+ signal: "clicked(mouse)"
+ script: {
+
+ color="green";
+ dot.x = mouse.x-1;
+ dot.y = mouse.y-1;
+
+ }
+ }
+}
diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro
new file mode 100644
index 0000000..3083800
--- /dev/null
+++ b/examples/declarative/declarative.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+CONFIG = ordered
+
+SUBDIRS += minehunt \
diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml
new file mode 100644
index 0000000..f53b25e
--- /dev/null
+++ b/examples/declarative/dial/DialLibrary/Dial.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Item {
+ id: Root
+ property real value : 0
+
+ width: 210; height: 210
+
+ Image { id: Background; source: "background.png" }
+
+ Image {
+ x: 93
+ y: 35
+ source: "needle_shadow.png"
+ transform: Rotation {
+ origin.x: 11; origin.y: 67
+ angle: NeedleRotation.angle
+ }
+ }
+ Image {
+ id: Needle
+ x: 95; y: 33
+ smooth: true
+ source: "needle.png"
+ transform: Rotation {
+ id: NeedleRotation
+ origin.x: 7; origin.y: 65
+ angle: -130
+ angle: Follow {
+id: MyFollow
+ spring: 1.4
+ damping: .15
+ source: Math.min(Math.max(-130, Root.value*2.2 - 130), 133)
+ }
+ }
+ }
+ Image { x: 21; y: 18; source: "overlay.png" }
+}
diff --git a/examples/declarative/dial/DialLibrary/background.png b/examples/declarative/dial/DialLibrary/background.png
new file mode 100644
index 0000000..75d555d
--- /dev/null
+++ b/examples/declarative/dial/DialLibrary/background.png
Binary files differ
diff --git a/examples/declarative/dial/DialLibrary/needle.png b/examples/declarative/dial/DialLibrary/needle.png
new file mode 100644
index 0000000..2d19f75
--- /dev/null
+++ b/examples/declarative/dial/DialLibrary/needle.png
Binary files differ
diff --git a/examples/declarative/dial/DialLibrary/needle_shadow.png b/examples/declarative/dial/DialLibrary/needle_shadow.png
new file mode 100644
index 0000000..8d8a928
--- /dev/null
+++ b/examples/declarative/dial/DialLibrary/needle_shadow.png
Binary files differ
diff --git a/examples/declarative/dial/DialLibrary/overlay.png b/examples/declarative/dial/DialLibrary/overlay.png
new file mode 100644
index 0000000..3860a7b
--- /dev/null
+++ b/examples/declarative/dial/DialLibrary/overlay.png
Binary files differ
diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml
new file mode 100644
index 0000000..472ac66
--- /dev/null
+++ b/examples/declarative/dial/dial.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+import "DialLibrary"
+Rectangle {
+ color: "white"
+ width: 210; height: 240
+
+ // Dial with a slider to adjust it
+ Dial { id: Dial; value: Slider.x-2 }
+
+ Rectangle {
+ anchors.top: Dial.bottom
+ x: 20; width: 160; height: 16
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "steelblue" }
+ GradientStop { position: 1.0; color: "lightsteelblue" }
+ }
+ radius: 8; opacity: 0.7; smooth: true
+ Rectangle {
+ id: Slider
+ x: 2; y: 2; width: 30; height: 12
+ radius: 6; smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightgray" }
+ GradientStop { position: 1.0; color: "gray" }
+ }
+ MouseRegion {
+ anchors.fill: parent
+ drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: 128
+ }
+ }
+ }
+}
diff --git a/examples/declarative/dynamic/DynRect.qml b/examples/declarative/dynamic/DynRect.qml
new file mode 100644
index 0000000..06141ea
--- /dev/null
+++ b/examples/declarative/dynamic/DynRect.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+Item {
+ states: State{ name: "dying"; PropertyChanges{ target: newRect; opacity: 0 } }
+ transitions: Transition{
+ NumberAnimation{ properties: "opacity"; target: newRect; duration:500 }
+ }
+ Rectangle {color: "steelblue"; width: 100; height: 100; id: newRect }
+}
diff --git a/examples/declarative/dynamic/dynamic.js b/examples/declarative/dynamic/dynamic.js
new file mode 100644
index 0000000..8f1e138
--- /dev/null
+++ b/examples/declarative/dynamic/dynamic.js
@@ -0,0 +1,57 @@
+var dynamicObject = null;
+var fourthBox = null;
+var component = null;
+var started = false;
+function createQml(p) {
+ return createQmlObject('DynRect {}',p,'DynPart.qml');
+}
+
+function destroyDynamicObject() {
+ if(!(dynamicObject==null)){
+ dynamicObject.destroy();
+ dynamicObject = null;
+ }
+}
+
+function instantCreateWithComponent() {//Like create, but assumes instant readyness
+ if(dynamicObject!=null)//Already made
+ return null;
+ component = createComponent("dynamic.qml");
+ dynamicObject = component.createObject();
+ if(dynamicObject == null){
+ print("error creating component");
+ }else{
+ dynamicObject.parent = targetItem;
+ return dynamicObject;
+ }
+ return null;
+}
+
+function finishCreation(){
+ if(component.isReady && dynamicObject == null){
+ dynamicObject = component.createObject();
+ dynamicObject.parent = targetItem;
+ }else if(component.isError){
+ dynamicObject = null;
+ print("error creating component");
+ print(component.errorsString());
+ }
+}
+
+function createWithComponent(){
+ if(component!=null){
+ return finishCreation();
+ }
+ if(started!=false){
+ finishCreation();//Remakes if destroyed
+ return dynamicObject;
+ }
+ started = true;
+ component = createComponent("dynamic.qml");
+ finishCreation();
+ if(dynamicObject != null){
+ return dynamicObject;
+ }
+ component.statusChanged.connect(finishCreation);
+ return null;
+}
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
new file mode 100644
index 0000000..6ea7ab8
--- /dev/null
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Rectangle { id: page; width: 800; height: 800; color:"black"
+ Script { source: "dynamic.js" }
+ property bool extendStars: false;
+ Item { id: targetItem; x: 100; y: 100; }
+ Item { id: targetItem2; x: 0; y: 300; }
+ Rectangle { width: 100; height: 100; color: "green"; id: rect
+ MouseRegion { anchors.fill:parent; onClicked: {a = createWithComponent();}}
+ }
+ Rectangle { width: 100; height: 100; color: "red"; id: rect2; y:100;
+ MouseRegion { anchors.fill:parent; onClicked: {destroyDynamicObject();}}
+ }
+ Rectangle { width: 100; height: 100; color: "blue"; id: rect3; y:200;
+ MouseRegion { anchors.fill:parent; onClicked:
+ {
+ if(fourthBox == null) {
+ a = createQml(targetItem2);
+ if(a!=null) {
+ a.parent = targetItem2;//BUG: this should happen automatically
+ fourthBox = a;
+ print(a.toStr());
+ extendStars = true;
+ }
+ } else {
+ fourthBox.state = 'dying';
+ fourthBox.destroy(500);
+ fourthBox = null;
+ extendStars = false;
+ }
+ }
+ }
+ }
+ Particles { x:0; y:0; count:20; lifeSpan:500; width:100; height: if(extendStars){400;}else{300;} source:"star.png"}
+}
diff --git a/examples/declarative/dynamic/star.png b/examples/declarative/dynamic/star.png
new file mode 100644
index 0000000..defbde5
--- /dev/null
+++ b/examples/declarative/dynamic/star.png
Binary files differ
diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml
new file mode 100644
index 0000000..df301d8
--- /dev/null
+++ b/examples/declarative/easing/easing.qml
@@ -0,0 +1,94 @@
+import Qt 4.6
+
+Rectangle {
+ id: Window
+ width: 640
+ height: Layout.height
+ color: "white"
+
+ ListModel {
+ id: EasingTypes
+ ListElement { type: "easeLinear" }
+ ListElement { type: "easeInQuad" }
+ ListElement { type: "easeOutQuad" }
+ ListElement { type: "easeInOutQuad" }
+ ListElement { type: "easeOutInQuad" }
+ ListElement { type: "easeInCubic" }
+ ListElement { type: "easeOutCubic" }
+ ListElement { type: "easeInOutCubic" }
+ ListElement { type: "easeOutInCubic" }
+ ListElement { type: "easeInQuart" }
+ ListElement { type: "easeOutQuart" }
+ ListElement { type: "easeInOutQuart" }
+ ListElement { type: "easeOutInQuart" }
+ ListElement { type: "easeInQuint" }
+ ListElement { type: "easeOutQuint" }
+ ListElement { type: "easeInOutQuint" }
+ ListElement { type: "easeOutInQuint" }
+ ListElement { type: "easeInSine" }
+ ListElement { type: "easeOutSine" }
+ ListElement { type: "easeInOutSine" }
+ ListElement { type: "easeOutInSine" }
+ ListElement { type: "easeInExpo" }
+ ListElement { type: "easeOutExpo" }
+ ListElement { type: "easeInOutExpo" }
+ ListElement { type: "easeOutInExpo" }
+ ListElement { type: "easeInCirc" }
+ ListElement { type: "easeOutCirc" }
+ ListElement { type: "easeInOutCirc" }
+ ListElement { type: "easeOutInCirc" }
+ ListElement { type: "easeInElastic" }
+ ListElement { type: "easeOutElastic" }
+ ListElement { type: "easeInOutElastic" }
+ ListElement { type: "easeOutInElastic" }
+ ListElement { type: "easeInBack" }
+ ListElement { type: "easeOutBack" }
+ ListElement { type: "easeInOutBack" }
+ ListElement { type: "easeOutInBack" }
+ ListElement { type: "easeOutBounce" }
+ ListElement { type: "easeInBounce" }
+ ListElement { type: "easeInOutBounce" }
+ ListElement { type: "easeOutInBounce" }
+ }
+
+ Column {
+ id: Layout
+ anchors.left: Window.left
+ anchors.right: Window.right
+ Repeater {
+ model: EasingTypes
+ Component {
+ Text {
+ id: Text
+ text: type
+ height: 18
+ font.italic: true
+ x: SequentialAnimation {
+ id: Anim
+ NumberAnimation {
+ from: 0
+ to: Window.width / 2
+ easing: type
+ duration: 1000
+ }
+ PauseAnimation {
+ duration: 300
+ }
+ NumberAnimation {
+ to: 0
+ from: Window.width / 2
+ easing: type
+ duration: 1000
+ }
+ }
+ children: [
+ MouseRegion {
+ onClicked: { Anim.running=true }
+ anchors.fill: parent
+ }
+ ]
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/effects/pic.jpg b/examples/declarative/effects/pic.jpg
new file mode 100644
index 0000000..5775518
--- /dev/null
+++ b/examples/declarative/effects/pic.jpg
Binary files differ
diff --git a/examples/declarative/effects/test.qml b/examples/declarative/effects/test.qml
new file mode 100644
index 0000000..4cc8746
--- /dev/null
+++ b/examples/declarative/effects/test.qml
@@ -0,0 +1,75 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Image {
+ source: "pic.jpg"
+
+ effect: Blur {
+ blurRadius: NumberAnimation { id: BS; from: 0; to: 10; duration: 200; repeat: true }
+ }
+
+ MouseRegion { anchors.fill: parent; onClicked: BS.running = !BS.running }
+
+ Text { color: "white"; text: "Blur" }
+ }
+
+ Image {
+ source: "pic.jpg"
+
+ x: 200
+ effect: Grayscale {}
+
+ Text { color: "white"; text: "Grayscale" }
+ }
+
+ Image {
+ source: "pic.jpg"
+
+ x: 400
+ effect: Colorize { color: "blue" }
+
+ Text { color: "white"; text: "Colorize" }
+ }
+
+ Image {
+ source: "pic.jpg"
+
+ y: 300
+ effect: Pixelize {
+ pixelSize: NumberAnimation { id: PS; from: 0; to: 10; duration: 200; repeat: true }
+ }
+
+ MouseRegion { anchors.fill: parent; onClicked: PS.running = !PS.running }
+
+ Text { color: "white"; text: "Pixelize" }
+ }
+
+
+ Image {
+ source: "pic.jpg"
+
+ x: 200
+ y: 300
+ effect: DropShadow {
+ blurRadius: 3
+ offset.x: 3
+ offset.y: NumberAnimation { id: DS; from: 0; to: 10; duration: 200; repeat: true; }
+ }
+
+ MouseRegion { anchors.fill: parent; onClicked: DS.running = !DS.running }
+
+ Text { color: "white"; text: "DropShadow" }
+ }
+
+
+ Text {
+ x: 400; y: 300
+ text: "Clicking Blur, Pixelize or DropShadow will \ntoggle animation."
+ color: "black"
+ }
+
+}
diff --git a/examples/declarative/extending/adding/adding.pro b/examples/declarative/extending/adding/adding.pro
new file mode 100644
index 0000000..c02a35f
--- /dev/null
+++ b/examples/declarative/extending/adding/adding.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = adding
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp
+HEADERS += person.h
+RESOURCES += adding.qrc
diff --git a/examples/declarative/extending/adding/adding.qrc b/examples/declarative/extending/adding/adding.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/adding/adding.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/adding/example.qml b/examples/declarative/extending/adding/example.qml
new file mode 100644
index 0000000..ba7af7a
--- /dev/null
+++ b/examples/declarative/extending/adding/example.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+// ![0]
+Person {
+ name: "Bob Jones"
+ shoeSize: 12
+}
+// ![0]
diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp
new file mode 100644
index 0000000..7e5cbef
--- /dev/null
+++ b/examples/declarative/extending/adding/main.cpp
@@ -0,0 +1,22 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ Person *person = qobject_cast<Person *>(component.create());
+ if (person) {
+ qWarning() << "The person's name is" << person->name();
+ qWarning() << "They wear a" << person->shoeSize() << "sized shoe";
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/adding/person.cpp b/examples/declarative/extending/adding/person.cpp
new file mode 100644
index 0000000..ccf08b3
--- /dev/null
+++ b/examples/declarative/extending/adding/person.cpp
@@ -0,0 +1,30 @@
+#include "person.h"
+
+// ![0]
+Person::Person(QObject *parent)
+: QObject(parent), m_shoeSize(0)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+int Person::shoeSize() const
+{
+ return m_shoeSize;
+}
+
+void Person::setShoeSize(int s)
+{
+ m_shoeSize = s;
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Person, Person);
+// ![0]
diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h
new file mode 100644
index 0000000..3bef2d4
--- /dev/null
+++ b/examples/declarative/extending/adding/person.h
@@ -0,0 +1,27 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+// ![0]
+#include <qml.h>
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ int shoeSize() const;
+ void setShoeSize(int);
+private:
+ QString m_name;
+ int m_shoeSize;
+};
+QML_DECLARE_TYPE(Person);
+// ![0]
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/attached/attached.pro b/examples/declarative/extending/attached/attached.pro
new file mode 100644
index 0000000..b0f3fea
--- /dev/null
+++ b/examples/declarative/extending/attached/attached.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = attached
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += attached.qrc
diff --git a/examples/declarative/extending/attached/attached.qrc b/examples/declarative/extending/attached/attached.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/attached/attached.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp
new file mode 100644
index 0000000..2c4c218
--- /dev/null
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -0,0 +1,45 @@
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ m_rsvp = d;
+}
+
+QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
+{
+ return new BirthdayPartyAttached(object);
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h
new file mode 100644
index 0000000..8249af5
--- /dev/null
+++ b/examples/declarative/extending/attached/birthdayparty.h
@@ -0,0 +1,45 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <qml.h>
+#include "person.h"
+
+class BirthdayPartyAttached : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp);
+public:
+ BirthdayPartyAttached(QObject *object);
+
+ QDate rsvp() const;
+ void setRsvp(const QDate &);
+
+private:
+ QDate m_rsvp;
+};
+QML_DECLARE_TYPE(BirthdayPartyAttached);
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/attached/example.qml b/examples/declarative/extending/attached/example.qml
new file mode 100644
index 0000000..20233f6
--- /dev/null
+++ b/examples/declarative/extending/attached/example.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+BirthdayParty {
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
+ }
+
+ // ![1]
+ Boy {
+ name: "Joan Hodges"
+ BirthdayParty.rsvp: "2009-07-06"
+ shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
+ }
+ // ![1]
+ Boy {
+ name: "Jack Smith"
+ shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 }
+ }
+ Girl {
+ name: "Anne Brown"
+ BirthdayParty.rsvp: "2009-07-01"
+ shoe.size: 7
+ shoe.color: "red"
+ shoe.brand: "Marc Jacobs"
+ shoe.price: 699.99
+ }
+}
+
diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp
new file mode 100644
index 0000000..8b05b9d
--- /dev/null
+++ b/examples/declarative/extending/attached/main.cpp
@@ -0,0 +1,44 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+
+ for (int ii = 0; ii < party->guests()->count(); ++ii) {
+ Person *guest = party->guests()->at(ii);
+
+ QDate rsvpDate;
+ QObject *attached =
+ qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
+ if (attached)
+ rsvpDate = attached->property("rsvp").toDate();
+
+ if (rsvpDate.isNull())
+ qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd";
+ else
+ qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString());
+ }
+
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/attached/person.cpp b/examples/declarative/extending/attached/person.cpp
new file mode 100644
index 0000000..eeedd1d
--- /dev/null
+++ b/examples/declarative/extending/attached/person.cpp
@@ -0,0 +1,83 @@
+#include "person.h"
+
+ShoeDescription::ShoeDescription(QObject *parent)
+: QObject(parent), m_size(0), m_price(0)
+{
+}
+
+int ShoeDescription::size() const
+{
+ return m_size;
+}
+
+void ShoeDescription::setSize(int s)
+{
+ m_size = s;
+}
+
+QColor ShoeDescription::color() const
+{
+ return m_color;
+}
+
+void ShoeDescription::setColor(const QColor &c)
+{
+ m_color = c;
+}
+
+QString ShoeDescription::brand() const
+{
+ return m_brand;
+}
+
+void ShoeDescription::setBrand(const QString &b)
+{
+ m_brand = b;
+}
+
+qreal ShoeDescription::price() const
+{
+ return m_price;
+}
+
+void ShoeDescription::setPrice(qreal p)
+{
+ m_price = p;
+}
+QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
+
+Person::Person(QObject *parent)
+: QObject(parent)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+ShoeDescription *Person::shoe()
+{
+ return &m_shoe;
+}
+
+QML_DEFINE_NOCREATE_TYPE(Person);
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
diff --git a/examples/declarative/extending/attached/person.h b/examples/declarative/extending/attached/person.h
new file mode 100644
index 0000000..07dfe0e
--- /dev/null
+++ b/examples/declarative/extending/attached/person.h
@@ -0,0 +1,67 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qml.h>
+
+class ShoeDescription : public QObject {
+Q_OBJECT
+Q_PROPERTY(int size READ size WRITE setSize)
+Q_PROPERTY(QColor color READ color WRITE setColor)
+Q_PROPERTY(QString brand READ brand WRITE setBrand)
+Q_PROPERTY(qreal price READ price WRITE setPrice)
+public:
+ ShoeDescription(QObject *parent = 0);
+
+ int size() const;
+ void setSize(int);
+
+ QColor color() const;
+ void setColor(const QColor &);
+
+ QString brand() const;
+ void setBrand(const QString &);
+
+ qreal price() const;
+ void setPrice(qreal);
+private:
+ int m_size;
+ QColor m_color;
+ QString m_brand;
+ qreal m_price;
+};
+QML_DECLARE_TYPE(ShoeDescription);
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(ShoeDescription *shoe READ shoe);
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ ShoeDescription *shoe();
+private:
+ QString m_name;
+ ShoeDescription m_shoe;
+};
+QML_DECLARE_TYPE(Person);
+
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/binding/binding.pro b/examples/declarative/extending/binding/binding.pro
new file mode 100644
index 0000000..8298565
--- /dev/null
+++ b/examples/declarative/extending/binding/binding.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+TARGET = binding
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp \
+ happybirthday.cpp
+HEADERS += person.h \
+ birthdayparty.h \
+ happybirthday.h
+RESOURCES += binding.qrc
diff --git a/examples/declarative/extending/binding/binding.qrc b/examples/declarative/extending/binding/binding.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/binding/binding.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp
new file mode 100644
index 0000000..b4f09eb
--- /dev/null
+++ b/examples/declarative/extending/binding/birthdayparty.cpp
@@ -0,0 +1,66 @@
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ if (d != m_rsvp) {
+ m_rsvp = d;
+ emit rsvpChanged();
+ }
+}
+
+QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ if (c == m_celebrant) return;
+ m_celebrant = c;
+ emit celebrantChanged();
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+void BirthdayParty::startParty()
+{
+ QTime time = QTime::currentTime();
+ emit partyStarted(time);
+}
+
+QString BirthdayParty::speaker() const
+{
+ return QString();
+}
+
+void BirthdayParty::setSpeaker(const QString &speak)
+{
+ qWarning() << qPrintable(speak);
+}
+
+BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
+{
+ return new BirthdayPartyAttached(object);
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h
new file mode 100644
index 0000000..6905746
--- /dev/null
+++ b/examples/declarative/extending/binding/birthdayparty.h
@@ -0,0 +1,61 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <QDebug>
+#include <qml.h>
+#include "person.h"
+
+class BirthdayPartyAttached : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged);
+public:
+ BirthdayPartyAttached(QObject *object);
+
+ QDate rsvp() const;
+ void setRsvp(const QDate &);
+
+signals:
+ void rsvpChanged();
+
+private:
+ QDate m_rsvp;
+};
+QML_DECLARE_TYPE(BirthdayPartyAttached);
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+// ![0]
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant NOTIFY celebrantChanged)
+// ![0]
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+ QString speaker() const;
+ void setSpeaker(const QString &);
+
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+
+ void startParty();
+signals:
+ void partyStarted(const QTime &time);
+ void celebrantChanged();
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml
new file mode 100644
index 0000000..cedb8bd
--- /dev/null
+++ b/examples/declarative/extending/binding/example.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ id: TheParty
+
+ speaker: HappyBirthday { name: TheParty.celebrant.name }
+
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
+ }
+// ![0]
+ onPartyStarted: print("This party started rockin' at " + time);
+
+
+ Boy {
+ name: "Joan Hodges"
+ BirthdayParty.rsvp: "2009-07-06"
+ shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
+ }
+ Boy {
+ name: "Jack Smith"
+ shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 }
+ }
+ Girl {
+ name: "Anne Brown"
+ BirthdayParty.rsvp: "2009-07-01"
+ shoe.size: 7
+ shoe.color: "red"
+ shoe.brand: "Marc Jacobs"
+ shoe.price: 699.99
+ }
+
+// ![1]
+}
+// ![1]
diff --git a/examples/declarative/extending/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthday.cpp
new file mode 100644
index 0000000..d1f485e
--- /dev/null
+++ b/examples/declarative/extending/binding/happybirthday.cpp
@@ -0,0 +1,47 @@
+#include "happybirthday.h"
+#include <QTimer>
+
+HappyBirthday::HappyBirthday(QObject *parent)
+: QmlPropertyValueSource(parent), m_line(-1)
+{
+ setName(QString());
+ QTimer *timer = new QTimer(this);
+ QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance()));
+ timer->start(1000);
+}
+
+void HappyBirthday::setTarget(const QmlMetaProperty &p)
+{
+ m_target = p;
+}
+
+QString HappyBirthday::name() const
+{
+ return m_name;
+}
+
+void HappyBirthday::setName(const QString &name)
+{
+ if (m_name == name)
+ return;
+
+ m_name = name;
+
+ m_lyrics.clear();
+ m_lyrics << "Happy birthday to you,";
+ m_lyrics << "Happy birthday to you,";
+ m_lyrics << "Happy birthday dear " + m_name + ",";
+ m_lyrics << "Happy birthday to you!";
+ m_lyrics << "";
+
+ emit nameChanged();
+}
+
+void HappyBirthday::advance()
+{
+ m_line = (m_line + 1) % m_lyrics.count();
+
+ m_target.write(m_lyrics.at(m_line));
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h
new file mode 100644
index 0000000..3039db2
--- /dev/null
+++ b/examples/declarative/extending/binding/happybirthday.h
@@ -0,0 +1,32 @@
+#ifndef HAPPYBIRTHDAY_H
+#define HAPPYBIRTHDAY_H
+
+#include <QmlPropertyValueSource>
+
+class HappyBirthday : public QmlPropertyValueSource
+{
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+public:
+ HappyBirthday(QObject *parent = 0);
+
+ virtual void setTarget(const QmlMetaProperty &);
+
+ QString name() const;
+ void setName(const QString &);
+
+private slots:
+ void advance();
+
+signals:
+ void nameChanged();
+private:
+ int m_line;
+ QStringList m_lyrics;
+ QmlMetaProperty m_target;
+ QString m_name;
+};
+QML_DECLARE_TYPE(HappyBirthday);
+
+#endif // HAPPYBIRTHDAY_H
+
diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp
new file mode 100644
index 0000000..e808b32
--- /dev/null
+++ b/examples/declarative/extending/binding/main.cpp
@@ -0,0 +1,45 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+
+ for (int ii = 0; ii < party->guests()->count(); ++ii) {
+ Person *guest = party->guests()->at(ii);
+
+ QDate rsvpDate;
+ QObject *attached =
+ qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
+ if (attached)
+ rsvpDate = attached->property("rsvp").toDate();
+
+ if (rsvpDate.isNull())
+ qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd";
+ else
+ qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString());
+ }
+
+ party->startParty();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return app.exec();
+}
diff --git a/examples/declarative/extending/binding/person.cpp b/examples/declarative/extending/binding/person.cpp
new file mode 100644
index 0000000..849b3de
--- /dev/null
+++ b/examples/declarative/extending/binding/person.cpp
@@ -0,0 +1,103 @@
+#include "person.h"
+
+ShoeDescription::ShoeDescription(QObject *parent)
+: QObject(parent), m_size(0), m_price(0)
+{
+}
+
+int ShoeDescription::size() const
+{
+ return m_size;
+}
+
+void ShoeDescription::setSize(int s)
+{
+ if (m_size == s)
+ return;
+
+ m_size = s;
+ emit shoeChanged();
+}
+
+QColor ShoeDescription::color() const
+{
+ return m_color;
+}
+
+void ShoeDescription::setColor(const QColor &c)
+{
+ if (m_color == c)
+ return;
+
+ m_color = c;
+ emit shoeChanged();
+}
+
+QString ShoeDescription::brand() const
+{
+ return m_brand;
+}
+
+void ShoeDescription::setBrand(const QString &b)
+{
+ if (m_brand == b)
+ return;
+
+ m_brand = b;
+ emit shoeChanged();
+}
+
+qreal ShoeDescription::price() const
+{
+ return m_price;
+}
+
+void ShoeDescription::setPrice(qreal p)
+{
+ if (m_price == p)
+ return;
+
+ m_price = p;
+ emit shoeChanged();
+}
+QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
+
+Person::Person(QObject *parent)
+: QObject(parent)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ if (m_name == n)
+ return;
+
+ m_name = n;
+ emit nameChanged();
+}
+
+ShoeDescription *Person::shoe()
+{
+ return &m_shoe;
+}
+
+QML_DEFINE_NOCREATE_TYPE(Person);
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
diff --git a/examples/declarative/extending/binding/person.h b/examples/declarative/extending/binding/person.h
new file mode 100644
index 0000000..41513b9
--- /dev/null
+++ b/examples/declarative/extending/binding/person.h
@@ -0,0 +1,75 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qml.h>
+
+class ShoeDescription : public QObject {
+Q_OBJECT
+Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged)
+Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged)
+Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged)
+Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged)
+public:
+ ShoeDescription(QObject *parent = 0);
+
+ int size() const;
+ void setSize(int);
+
+ QColor color() const;
+ void setColor(const QColor &);
+
+ QString brand() const;
+ void setBrand(const QString &);
+
+ qreal price() const;
+ void setPrice(qreal);
+signals:
+ void shoeChanged();
+
+private:
+ int m_size;
+ QColor m_color;
+ QString m_brand;
+ qreal m_price;
+};
+QML_DECLARE_TYPE(ShoeDescription);
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+// ![0]
+Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT);
+// ![0]
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ ShoeDescription *shoe();
+signals:
+ void nameChanged();
+
+private:
+ QString m_name;
+ ShoeDescription m_shoe;
+};
+QML_DECLARE_TYPE(Person);
+
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp
new file mode 100644
index 0000000..ea97f548
--- /dev/null
+++ b/examples/declarative/extending/coercion/birthdayparty.cpp
@@ -0,0 +1,23 @@
+#include "birthdayparty.h"
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
new file mode 100644
index 0000000..2557d1a
--- /dev/null
+++ b/examples/declarative/extending/coercion/birthdayparty.h
@@ -0,0 +1,29 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qml.h>
+#include "person.h"
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+// ![0]
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+// ![0]
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/coercion/coercion.pro b/examples/declarative/extending/coercion/coercion.pro
new file mode 100644
index 0000000..136b210
--- /dev/null
+++ b/examples/declarative/extending/coercion/coercion.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = coercion
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += coercion.qrc
diff --git a/examples/declarative/extending/coercion/coercion.qrc b/examples/declarative/extending/coercion/coercion.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/coercion/coercion.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/coercion/example.qml b/examples/declarative/extending/coercion/example.qml
new file mode 100644
index 0000000..5090782
--- /dev/null
+++ b/examples/declarative/extending/coercion/example.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoeSize: 12
+ }
+ guests: [
+ Boy { name: "Joan Hodges" },
+ Boy { name: "Jack Smith" },
+ Girl { name: "Anne Brown" }
+ ]
+}
+// ![0]
diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp
new file mode 100644
index 0000000..75846fa
--- /dev/null
+++ b/examples/declarative/extending/coercion/main.cpp
@@ -0,0 +1,30 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+ for (int ii = 0; ii < party->guests()->count(); ++ii)
+ qWarning() << " " << party->guests()->at(ii)->name();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/coercion/person.cpp b/examples/declarative/extending/coercion/person.cpp
new file mode 100644
index 0000000..d075851
--- /dev/null
+++ b/examples/declarative/extending/coercion/person.cpp
@@ -0,0 +1,46 @@
+#include "person.h"
+
+Person::Person(QObject *parent)
+: QObject(parent), m_shoeSize(0)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+int Person::shoeSize() const
+{
+ return m_shoeSize;
+}
+
+void Person::setShoeSize(int s)
+{
+ m_shoeSize = s;
+}
+
+// ![0]
+QML_DEFINE_NOCREATE_TYPE(Person);
+// ![0]
+
+// ![1]
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
+// ![1]
diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h
new file mode 100644
index 0000000..de14019
--- /dev/null
+++ b/examples/declarative/extending/coercion/person.h
@@ -0,0 +1,41 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <qml.h>
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ int shoeSize() const;
+ void setShoeSize(int);
+private:
+ QString m_name;
+ int m_shoeSize;
+};
+QML_DECLARE_TYPE(Person);
+
+// ![0]
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+// ![0]
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp
new file mode 100644
index 0000000..ea97f548
--- /dev/null
+++ b/examples/declarative/extending/default/birthdayparty.cpp
@@ -0,0 +1,23 @@
+#include "birthdayparty.h"
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h
new file mode 100644
index 0000000..084da10
--- /dev/null
+++ b/examples/declarative/extending/default/birthdayparty.h
@@ -0,0 +1,30 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qml.h>
+#include "person.h"
+
+// ![0]
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+// ![0]
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/default/default.pro b/examples/declarative/extending/default/default.pro
new file mode 100644
index 0000000..0d5d45c
--- /dev/null
+++ b/examples/declarative/extending/default/default.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = default
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += default.qrc
diff --git a/examples/declarative/extending/default/default.qrc b/examples/declarative/extending/default/default.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/default/default.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/default/example.qml b/examples/declarative/extending/default/example.qml
new file mode 100644
index 0000000..5fe693a
--- /dev/null
+++ b/examples/declarative/extending/default/example.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoeSize: 12
+ }
+
+ Boy { name: "Joan Hodges" }
+ Boy { name: "Jack Smith" }
+ Girl { name: "Anne Brown" }
+}
+// ![0]
diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp
new file mode 100644
index 0000000..75846fa
--- /dev/null
+++ b/examples/declarative/extending/default/main.cpp
@@ -0,0 +1,30 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+ for (int ii = 0; ii < party->guests()->count(); ++ii)
+ qWarning() << " " << party->guests()->at(ii)->name();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/default/person.cpp b/examples/declarative/extending/default/person.cpp
new file mode 100644
index 0000000..7c468c6
--- /dev/null
+++ b/examples/declarative/extending/default/person.cpp
@@ -0,0 +1,42 @@
+#include "person.h"
+
+Person::Person(QObject *parent)
+: QObject(parent), m_shoeSize(0)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+int Person::shoeSize() const
+{
+ return m_shoeSize;
+}
+
+void Person::setShoeSize(int s)
+{
+ m_shoeSize = s;
+}
+
+QML_DEFINE_NOCREATE_TYPE(Person);
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
diff --git a/examples/declarative/extending/default/person.h b/examples/declarative/extending/default/person.h
new file mode 100644
index 0000000..872186c
--- /dev/null
+++ b/examples/declarative/extending/default/person.h
@@ -0,0 +1,39 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <qml.h>
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ int shoeSize() const;
+ void setShoeSize(int);
+private:
+ QString m_name;
+ int m_shoeSize;
+};
+QML_DECLARE_TYPE(Person);
+
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/extended/example.qml b/examples/declarative/extending/extended/example.qml
new file mode 100644
index 0000000..a276211
--- /dev/null
+++ b/examples/declarative/extending/extended/example.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+// ![0]
+QLineEdit {
+ leftMargin: 20
+}
+// ![0]
diff --git a/examples/declarative/extending/extended/extended.pro b/examples/declarative/extending/extended/extended.pro
new file mode 100644
index 0000000..1182226
--- /dev/null
+++ b/examples/declarative/extending/extended/extended.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = extended
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ lineedit.cpp
+HEADERS += lineedit.h
+RESOURCES += extended.qrc
diff --git a/examples/declarative/extending/extended/extended.qrc b/examples/declarative/extending/extended/extended.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/extended/extended.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp
new file mode 100644
index 0000000..fe4fdc3
--- /dev/null
+++ b/examples/declarative/extending/extended/lineedit.cpp
@@ -0,0 +1,66 @@
+#include "lineedit.h"
+#include <qml.h>
+
+LineEditExtension::LineEditExtension(QObject *object)
+: QObject(object), m_lineedit(static_cast<QLineEdit *>(object))
+{
+}
+
+int LineEditExtension::leftMargin() const
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ return l;
+}
+
+int LineEditExtension::setLeftMargin(int m)
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ m_lineedit->setTextMargins(m, t, r, b);
+}
+
+int LineEditExtension::rightMargin() const
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ return r;
+}
+
+int LineEditExtension::setRightMargin(int m)
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ m_lineedit->setTextMargins(l, t, m, b);
+}
+
+int LineEditExtension::topMargin() const
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ return t;
+}
+
+int LineEditExtension::setTopMargin(int m)
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ m_lineedit->setTextMargins(l, m, r, b);
+}
+
+int LineEditExtension::bottomMargin() const
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ return b;
+}
+
+int LineEditExtension::setBottomMargin(int m)
+{
+ int l, r, t, b;
+ m_lineedit->getTextMargins(&l, &t, &r, &b);
+ m_lineedit->setTextMargins(l, t, r, m);
+}
+
+QML_DECLARE_TYPE(QLineEdit);
+QML_DEFINE_EXTENDED_TYPE(QLineEdit, QLineEdit, LineEditExtension);
diff --git a/examples/declarative/extending/extended/lineedit.h b/examples/declarative/extending/extended/lineedit.h
new file mode 100644
index 0000000..860e042
--- /dev/null
+++ b/examples/declarative/extending/extended/lineedit.h
@@ -0,0 +1,34 @@
+#ifndef LINEEDIT_H
+#define LINEEDIT_H
+
+#include <QLineEdit>
+
+class LineEditExtension : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged);
+Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged);
+Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged);
+Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged);
+public:
+ LineEditExtension(QObject *);
+
+ int leftMargin() const;
+ int setLeftMargin(int);
+
+ int rightMargin() const;
+ int setRightMargin(int);
+
+ int topMargin() const;
+ int setTopMargin(int);
+
+ int bottomMargin() const;
+ int setBottomMargin(int);
+signals:
+ void marginsChanged();
+
+private:
+ QLineEdit *m_lineedit;
+};
+
+#endif // LINEEDIT_H
diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp
new file mode 100644
index 0000000..1006214
--- /dev/null
+++ b/examples/declarative/extending/extended/main.cpp
@@ -0,0 +1,22 @@
+#include <QApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include <QLineEdit>
+
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ QLineEdit *edit = qobject_cast<QLineEdit *>(component.create());
+
+ if (edit) {
+ edit->show();
+ return app.exec();
+ } else {
+ qWarning() << "An error occured";
+ return 0;
+ }
+}
diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp
new file mode 100644
index 0000000..ea97f548
--- /dev/null
+++ b/examples/declarative/extending/grouped/birthdayparty.cpp
@@ -0,0 +1,23 @@
+#include "birthdayparty.h"
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h
new file mode 100644
index 0000000..3d53319
--- /dev/null
+++ b/examples/declarative/extending/grouped/birthdayparty.h
@@ -0,0 +1,28 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qml.h>
+#include "person.h"
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/grouped/example.qml b/examples/declarative/extending/grouped/example.qml
new file mode 100644
index 0000000..1be7abe
--- /dev/null
+++ b/examples/declarative/extending/grouped/example.qml
@@ -0,0 +1,33 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
+ }
+
+ Boy {
+ name: "Joan Hodges"
+ shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
+ }
+ // ![1]
+ Boy {
+ name: "Jack Smith"
+ shoe {
+ size: 8
+ color: "blue"
+ brand: "Puma"
+ price: 19.95
+ }
+ }
+ // ![1]
+ Girl {
+ name: "Anne Brown"
+ shoe.size: 7
+ shoe.color: "red"
+ shoe.brand: "Marc Jacobs"
+ shoe.price: 699.99
+ }
+}
+// ![0]
diff --git a/examples/declarative/extending/grouped/grouped.pro b/examples/declarative/extending/grouped/grouped.pro
new file mode 100644
index 0000000..8fde8e8
--- /dev/null
+++ b/examples/declarative/extending/grouped/grouped.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = grouped
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += grouped.qrc
diff --git a/examples/declarative/extending/grouped/grouped.qrc b/examples/declarative/extending/grouped/grouped.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/grouped/grouped.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp
new file mode 100644
index 0000000..490e596
--- /dev/null
+++ b/examples/declarative/extending/grouped/main.cpp
@@ -0,0 +1,40 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+
+ Person *bestShoe = 0;
+ for (int ii = 0; ii < party->guests()->count(); ++ii) {
+ Person *guest = party->guests()->at(ii);
+ qWarning() << " " << guest->name();
+
+ if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price())
+ bestShoe = guest;
+ }
+ if (bestShoe)
+ qWarning() << bestShoe->name() << "is wearing the best shoes!";
+
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/grouped/person.cpp b/examples/declarative/extending/grouped/person.cpp
new file mode 100644
index 0000000..eeedd1d
--- /dev/null
+++ b/examples/declarative/extending/grouped/person.cpp
@@ -0,0 +1,83 @@
+#include "person.h"
+
+ShoeDescription::ShoeDescription(QObject *parent)
+: QObject(parent), m_size(0), m_price(0)
+{
+}
+
+int ShoeDescription::size() const
+{
+ return m_size;
+}
+
+void ShoeDescription::setSize(int s)
+{
+ m_size = s;
+}
+
+QColor ShoeDescription::color() const
+{
+ return m_color;
+}
+
+void ShoeDescription::setColor(const QColor &c)
+{
+ m_color = c;
+}
+
+QString ShoeDescription::brand() const
+{
+ return m_brand;
+}
+
+void ShoeDescription::setBrand(const QString &b)
+{
+ m_brand = b;
+}
+
+qreal ShoeDescription::price() const
+{
+ return m_price;
+}
+
+void ShoeDescription::setPrice(qreal p)
+{
+ m_price = p;
+}
+QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
+
+Person::Person(QObject *parent)
+: QObject(parent)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+ShoeDescription *Person::shoe()
+{
+ return &m_shoe;
+}
+
+QML_DEFINE_NOCREATE_TYPE(Person);
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
diff --git a/examples/declarative/extending/grouped/person.h b/examples/declarative/extending/grouped/person.h
new file mode 100644
index 0000000..b83eb5b
--- /dev/null
+++ b/examples/declarative/extending/grouped/person.h
@@ -0,0 +1,69 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qml.h>
+
+class ShoeDescription : public QObject {
+Q_OBJECT
+Q_PROPERTY(int size READ size WRITE setSize)
+Q_PROPERTY(QColor color READ color WRITE setColor)
+Q_PROPERTY(QString brand READ brand WRITE setBrand)
+Q_PROPERTY(qreal price READ price WRITE setPrice)
+public:
+ ShoeDescription(QObject *parent = 0);
+
+ int size() const;
+ void setSize(int);
+
+ QColor color() const;
+ void setColor(const QColor &);
+
+ QString brand() const;
+ void setBrand(const QString &);
+
+ qreal price() const;
+ void setPrice(qreal);
+private:
+ int m_size;
+ QColor m_color;
+ QString m_brand;
+ qreal m_price;
+};
+QML_DECLARE_TYPE(ShoeDescription);
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+// ![1]
+Q_PROPERTY(ShoeDescription *shoe READ shoe);
+// ![1]
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ ShoeDescription *shoe();
+private:
+ QString m_name;
+ ShoeDescription m_shoe;
+};
+QML_DECLARE_TYPE(Person);
+
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp
new file mode 100644
index 0000000..92bc3ba
--- /dev/null
+++ b/examples/declarative/extending/properties/birthdayparty.cpp
@@ -0,0 +1,25 @@
+#include "birthdayparty.h"
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+// ![0]
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+// ![0]
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
new file mode 100644
index 0000000..1804980
--- /dev/null
+++ b/examples/declarative/extending/properties/birthdayparty.h
@@ -0,0 +1,35 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qml.h>
+#include "person.h"
+
+// ![0]
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+// ![0]
+// ![1]
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+// ![1]
+// ![2]
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+// ![2]
+// ![3]
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+// ![3]
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/properties/example.qml b/examples/declarative/extending/properties/example.qml
new file mode 100644
index 0000000..326105a
--- /dev/null
+++ b/examples/declarative/extending/properties/example.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ celebrant: Person {
+ name: "Bob Jones"
+ shoeSize: 12
+ }
+ guests: [
+ Person { name: "Joan Hodges" },
+ Person { name: "Jack Smith" },
+ Person { name: "Anne Brown" }
+ ]
+}
+// ![0]
diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp
new file mode 100644
index 0000000..d487fbe
--- /dev/null
+++ b/examples/declarative/extending/properties/main.cpp
@@ -0,0 +1,26 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+ qWarning() << "They are inviting:";
+ for (int ii = 0; ii < party->guests()->count(); ++ii)
+ qWarning() << " " << party->guests()->at(ii)->name();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/properties/person.cpp b/examples/declarative/extending/properties/person.cpp
new file mode 100644
index 0000000..99fa33e
--- /dev/null
+++ b/examples/declarative/extending/properties/person.cpp
@@ -0,0 +1,28 @@
+#include "person.h"
+
+Person::Person(QObject *parent)
+: QObject(parent), m_shoeSize(0)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+int Person::shoeSize() const
+{
+ return m_shoeSize;
+}
+
+void Person::setShoeSize(int s)
+{
+ m_shoeSize = s;
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Person, Person);
diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h
new file mode 100644
index 0000000..2bc98c1
--- /dev/null
+++ b/examples/declarative/extending/properties/person.h
@@ -0,0 +1,25 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <qml.h>
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ int shoeSize() const;
+ void setShoeSize(int);
+private:
+ QString m_name;
+ int m_shoeSize;
+};
+QML_DECLARE_TYPE(Person);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/properties/properties.pro b/examples/declarative/extending/properties/properties.pro
new file mode 100644
index 0000000..6355644
--- /dev/null
+++ b/examples/declarative/extending/properties/properties.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = properties
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += properties.qrc
diff --git a/examples/declarative/extending/properties/properties.qrc b/examples/declarative/extending/properties/properties.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/properties/properties.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp
new file mode 100644
index 0000000..d6a0d56
--- /dev/null
+++ b/examples/declarative/extending/signal/birthdayparty.cpp
@@ -0,0 +1,51 @@
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ m_rsvp = d;
+}
+
+QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+void BirthdayParty::startParty()
+{
+ QTime time = QTime::currentTime();
+ emit partyStarted(time);
+}
+
+BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
+{
+ return new BirthdayPartyAttached(object);
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h
new file mode 100644
index 0000000..14d7c29
--- /dev/null
+++ b/examples/declarative/extending/signal/birthdayparty.h
@@ -0,0 +1,52 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <qml.h>
+#include "person.h"
+
+class BirthdayPartyAttached : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp);
+public:
+ BirthdayPartyAttached(QObject *object);
+
+ QDate rsvp() const;
+ void setRsvp(const QDate &);
+
+private:
+ QDate m_rsvp;
+};
+QML_DECLARE_TYPE(BirthdayPartyAttached);
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+
+ void startParty();
+// ![0]
+signals:
+ void partyStarted(const QTime &time);
+// ![0]
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml
new file mode 100644
index 0000000..1cbaab4
--- /dev/null
+++ b/examples/declarative/extending/signal/example.qml
@@ -0,0 +1,32 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ onPartyStarted: print("This party started rockin' at " + time);
+// ![0]
+
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
+ }
+
+ Boy {
+ name: "Joan Hodges"
+ BirthdayParty.rsvp: "2009-07-06"
+ shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
+ }
+ Boy {
+ name: "Jack Smith"
+ shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 }
+ }
+ Girl {
+ name: "Anne Brown"
+ BirthdayParty.rsvp: "2009-07-01"
+ shoe.size: 7
+ shoe.color: "red"
+ shoe.brand: "Marc Jacobs"
+ shoe.price: 699.99
+ }
+// ![1]
+}
+// ![1]
diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp
new file mode 100644
index 0000000..181614d
--- /dev/null
+++ b/examples/declarative/extending/signal/main.cpp
@@ -0,0 +1,45 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+
+ for (int ii = 0; ii < party->guests()->count(); ++ii) {
+ Person *guest = party->guests()->at(ii);
+
+ QDate rsvpDate;
+ QObject *attached =
+ qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
+ if (attached)
+ rsvpDate = attached->property("rsvp").toDate();
+
+ if (rsvpDate.isNull())
+ qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd";
+ else
+ qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString());
+ }
+
+ party->startParty();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}
diff --git a/examples/declarative/extending/signal/person.cpp b/examples/declarative/extending/signal/person.cpp
new file mode 100644
index 0000000..eeedd1d
--- /dev/null
+++ b/examples/declarative/extending/signal/person.cpp
@@ -0,0 +1,83 @@
+#include "person.h"
+
+ShoeDescription::ShoeDescription(QObject *parent)
+: QObject(parent), m_size(0), m_price(0)
+{
+}
+
+int ShoeDescription::size() const
+{
+ return m_size;
+}
+
+void ShoeDescription::setSize(int s)
+{
+ m_size = s;
+}
+
+QColor ShoeDescription::color() const
+{
+ return m_color;
+}
+
+void ShoeDescription::setColor(const QColor &c)
+{
+ m_color = c;
+}
+
+QString ShoeDescription::brand() const
+{
+ return m_brand;
+}
+
+void ShoeDescription::setBrand(const QString &b)
+{
+ m_brand = b;
+}
+
+qreal ShoeDescription::price() const
+{
+ return m_price;
+}
+
+void ShoeDescription::setPrice(qreal p)
+{
+ m_price = p;
+}
+QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
+
+Person::Person(QObject *parent)
+: QObject(parent)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+ShoeDescription *Person::shoe()
+{
+ return &m_shoe;
+}
+
+QML_DEFINE_NOCREATE_TYPE(Person);
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
diff --git a/examples/declarative/extending/signal/person.h b/examples/declarative/extending/signal/person.h
new file mode 100644
index 0000000..07dfe0e
--- /dev/null
+++ b/examples/declarative/extending/signal/person.h
@@ -0,0 +1,67 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qml.h>
+
+class ShoeDescription : public QObject {
+Q_OBJECT
+Q_PROPERTY(int size READ size WRITE setSize)
+Q_PROPERTY(QColor color READ color WRITE setColor)
+Q_PROPERTY(QString brand READ brand WRITE setBrand)
+Q_PROPERTY(qreal price READ price WRITE setPrice)
+public:
+ ShoeDescription(QObject *parent = 0);
+
+ int size() const;
+ void setSize(int);
+
+ QColor color() const;
+ void setColor(const QColor &);
+
+ QString brand() const;
+ void setBrand(const QString &);
+
+ qreal price() const;
+ void setPrice(qreal);
+private:
+ int m_size;
+ QColor m_color;
+ QString m_brand;
+ qreal m_price;
+};
+QML_DECLARE_TYPE(ShoeDescription);
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(ShoeDescription *shoe READ shoe);
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ ShoeDescription *shoe();
+private:
+ QString m_name;
+ ShoeDescription m_shoe;
+};
+QML_DECLARE_TYPE(Person);
+
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/signal/signal.pro b/examples/declarative/extending/signal/signal.pro
new file mode 100644
index 0000000..30e413f
--- /dev/null
+++ b/examples/declarative/extending/signal/signal.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = signal
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += signal.qrc
diff --git a/examples/declarative/extending/signal/signal.qrc b/examples/declarative/extending/signal/signal.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/signal/signal.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp
new file mode 100644
index 0000000..6bca2ef
--- /dev/null
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -0,0 +1,61 @@
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ m_rsvp = d;
+}
+
+QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QmlList<Person *> *BirthdayParty::guests()
+{
+ return &m_guests;
+}
+
+void BirthdayParty::startParty()
+{
+ QTime time = QTime::currentTime();
+ emit partyStarted(time);
+}
+
+QString BirthdayParty::speaker() const
+{
+ return QString();
+}
+
+void BirthdayParty::setSpeaker(const QString &speak)
+{
+ qWarning() << qPrintable(speak);
+}
+
+BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
+{
+ return new BirthdayPartyAttached(object);
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
new file mode 100644
index 0000000..fd25f28
--- /dev/null
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -0,0 +1,57 @@
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <QDebug>
+#include <qml.h>
+#include "person.h"
+
+class BirthdayPartyAttached : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp);
+public:
+ BirthdayPartyAttached(QObject *object);
+
+ QDate rsvp() const;
+ void setRsvp(const QDate &);
+
+private:
+ QDate m_rsvp;
+};
+QML_DECLARE_TYPE(BirthdayPartyAttached);
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QmlList<Person *> *guests READ guests)
+// ![0]
+Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
+// ![0]
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QmlList<Person *> *guests();
+
+ QString speaker() const;
+ void setSpeaker(const QString &);
+
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+
+ void startParty();
+signals:
+ void partyStarted(const QTime &time);
+
+private:
+ Person *m_celebrant;
+ QmlConcreteList<Person *> m_guests;
+};
+QML_DECLARE_TYPE(BirthdayParty);
+
+#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml
new file mode 100644
index 0000000..aba2796
--- /dev/null
+++ b/examples/declarative/extending/valuesource/example.qml
@@ -0,0 +1,36 @@
+import Qt 4.6
+
+// ![0]
+BirthdayParty {
+ speaker: HappyBirthday { name: "Bob Jones" }
+// ![0]
+
+ onPartyStarted: print("This party started rockin' at " + time);
+
+
+ celebrant: Boy {
+ name: "Bob Jones"
+ shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
+ }
+
+ Boy {
+ name: "Joan Hodges"
+ BirthdayParty.rsvp: "2009-07-06"
+ shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
+ }
+ Boy {
+ name: "Jack Smith"
+ shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 }
+ }
+ Girl {
+ name: "Anne Brown"
+ BirthdayParty.rsvp: "2009-07-01"
+ shoe.size: 7
+ shoe.color: "red"
+ shoe.brand: "Marc Jacobs"
+ shoe.price: 699.99
+ }
+
+// ![1]
+}
+// ![1]
diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthday.cpp
new file mode 100644
index 0000000..905dc51
--- /dev/null
+++ b/examples/declarative/extending/valuesource/happybirthday.cpp
@@ -0,0 +1,42 @@
+#include "happybirthday.h"
+#include <QTimer>
+
+HappyBirthday::HappyBirthday(QObject *parent)
+: QmlPropertyValueSource(parent), m_line(-1)
+{
+ setName(QString());
+ QTimer *timer = new QTimer(this);
+ QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance()));
+ timer->start(1000);
+}
+
+void HappyBirthday::setTarget(const QmlMetaProperty &p)
+{
+ m_target = p;
+}
+
+QString HappyBirthday::name() const
+{
+ return m_name;
+}
+
+void HappyBirthday::setName(const QString &name)
+{
+ m_name = name;
+
+ m_lyrics.clear();
+ m_lyrics << "Happy birthday to you,";
+ m_lyrics << "Happy birthday to you,";
+ m_lyrics << "Happy birthday dear " + m_name + ",";
+ m_lyrics << "Happy birthday to you!";
+ m_lyrics << "";
+}
+
+void HappyBirthday::advance()
+{
+ m_line = (m_line + 1) % m_lyrics.count();
+
+ m_target.write(m_lyrics.at(m_line));
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h
new file mode 100644
index 0000000..e0d4912
--- /dev/null
+++ b/examples/declarative/extending/valuesource/happybirthday.h
@@ -0,0 +1,36 @@
+#ifndef HAPPYBIRTHDAY_H
+#define HAPPYBIRTHDAY_H
+
+#include <QmlPropertyValueSource>
+
+// ![0]
+class HappyBirthday : public QmlPropertyValueSource
+{
+Q_OBJECT
+// ![0]
+Q_PROPERTY(QString name READ name WRITE setName)
+// ![1]
+public:
+ HappyBirthday(QObject *parent = 0);
+
+ virtual void setTarget(const QmlMetaProperty &);
+// ![1]
+
+ QString name() const;
+ void setName(const QString &);
+
+private slots:
+ void advance();
+
+private:
+ int m_line;
+ QStringList m_lyrics;
+ QmlMetaProperty m_target;
+ QString m_name;
+// ![2]
+};
+// ![2]
+QML_DECLARE_TYPE(HappyBirthday);
+
+#endif // HAPPYBIRTHDAY_H
+
diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp
new file mode 100644
index 0000000..e808b32
--- /dev/null
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -0,0 +1,45 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+
+ for (int ii = 0; ii < party->guests()->count(); ++ii) {
+ Person *guest = party->guests()->at(ii);
+
+ QDate rsvpDate;
+ QObject *attached =
+ qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
+ if (attached)
+ rsvpDate = attached->property("rsvp").toDate();
+
+ if (rsvpDate.isNull())
+ qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd";
+ else
+ qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString());
+ }
+
+ party->startParty();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return app.exec();
+}
diff --git a/examples/declarative/extending/valuesource/person.cpp b/examples/declarative/extending/valuesource/person.cpp
new file mode 100644
index 0000000..eeedd1d
--- /dev/null
+++ b/examples/declarative/extending/valuesource/person.cpp
@@ -0,0 +1,83 @@
+#include "person.h"
+
+ShoeDescription::ShoeDescription(QObject *parent)
+: QObject(parent), m_size(0), m_price(0)
+{
+}
+
+int ShoeDescription::size() const
+{
+ return m_size;
+}
+
+void ShoeDescription::setSize(int s)
+{
+ m_size = s;
+}
+
+QColor ShoeDescription::color() const
+{
+ return m_color;
+}
+
+void ShoeDescription::setColor(const QColor &c)
+{
+ m_color = c;
+}
+
+QString ShoeDescription::brand() const
+{
+ return m_brand;
+}
+
+void ShoeDescription::setBrand(const QString &b)
+{
+ m_brand = b;
+}
+
+qreal ShoeDescription::price() const
+{
+ return m_price;
+}
+
+void ShoeDescription::setPrice(qreal p)
+{
+ m_price = p;
+}
+QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
+
+Person::Person(QObject *parent)
+: QObject(parent)
+{
+}
+
+QString Person::name() const
+{
+ return m_name;
+}
+
+void Person::setName(const QString &n)
+{
+ m_name = n;
+}
+
+ShoeDescription *Person::shoe()
+{
+ return &m_shoe;
+}
+
+QML_DEFINE_NOCREATE_TYPE(Person);
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Boy, Boy);
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+QML_DEFINE_TYPE(People, 1, 0, 0, Girl, Girl);
diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h
new file mode 100644
index 0000000..07dfe0e
--- /dev/null
+++ b/examples/declarative/extending/valuesource/person.h
@@ -0,0 +1,67 @@
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qml.h>
+
+class ShoeDescription : public QObject {
+Q_OBJECT
+Q_PROPERTY(int size READ size WRITE setSize)
+Q_PROPERTY(QColor color READ color WRITE setColor)
+Q_PROPERTY(QString brand READ brand WRITE setBrand)
+Q_PROPERTY(qreal price READ price WRITE setPrice)
+public:
+ ShoeDescription(QObject *parent = 0);
+
+ int size() const;
+ void setSize(int);
+
+ QColor color() const;
+ void setColor(const QColor &);
+
+ QString brand() const;
+ void setBrand(const QString &);
+
+ qreal price() const;
+ void setPrice(qreal);
+private:
+ int m_size;
+ QColor m_color;
+ QString m_brand;
+ qreal m_price;
+};
+QML_DECLARE_TYPE(ShoeDescription);
+
+class Person : public QObject {
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName)
+Q_PROPERTY(ShoeDescription *shoe READ shoe);
+public:
+ Person(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &);
+
+ ShoeDescription *shoe();
+private:
+ QString m_name;
+ ShoeDescription m_shoe;
+};
+QML_DECLARE_TYPE(Person);
+
+class Boy : public Person {
+Q_OBJECT
+public:
+ Boy(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Boy);
+
+class Girl : public Person {
+Q_OBJECT
+public:
+ Girl(QObject * parent = 0);
+};
+QML_DECLARE_TYPE(Girl);
+
+#endif // PERSON_H
diff --git a/examples/declarative/extending/valuesource/valuesource.pro b/examples/declarative/extending/valuesource/valuesource.pro
new file mode 100644
index 0000000..9e54448
--- /dev/null
+++ b/examples/declarative/extending/valuesource/valuesource.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+TARGET = valuesource
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp \
+ happybirthday.cpp
+HEADERS += person.h \
+ birthdayparty.h \
+ happybirthday.h
+RESOURCES += valuesource.qrc
diff --git a/examples/declarative/extending/valuesource/valuesource.qrc b/examples/declarative/extending/valuesource/valuesource.qrc
new file mode 100644
index 0000000..e2fa01d
--- /dev/null
+++ b/examples/declarative/extending/valuesource/valuesource.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>example.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/fillmode/face.png b/examples/declarative/fillmode/face.png
new file mode 100644
index 0000000..9623b1a
--- /dev/null
+++ b/examples/declarative/fillmode/face.png
Binary files differ
diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml
new file mode 100644
index 0000000..94b0782
--- /dev/null
+++ b/examples/declarative/fillmode/fillmode.qml
@@ -0,0 +1,42 @@
+import Qt 4.6
+
+Image {
+ width: 400
+ height: 250
+ source: "face.png"
+ fillMode: SequentialAnimation {
+ running: true
+ repeat: true
+ PropertyAction { value: "Stretch" }
+ PropertyAction { target: Label; property: "text"; value: "Stretch" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: "PreserveAspectFit" }
+ PropertyAction { target: Label; property: "text"; value: "PreserveAspectFit" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: "PreserveAspectCrop" }
+ PropertyAction { target: Label; property: "text"; value: "PreserveAspectCrop" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: "Tile" }
+ PropertyAction { target: Label; property: "text"; value: "Tile" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: "TileHorizontally" }
+ PropertyAction { target: Label; property: "text"; value: "TileHorizontally" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: "TileVertically" }
+ PropertyAction { target: Label; property: "text"; value: "TileVertically" }
+ PauseAnimation { duration: 1000 }
+ }
+ Text {
+ id: Label
+ font.pointSize: 24
+ color: "blue"
+ style: "Outline"
+ styleColor: "white"
+ anchors { centerIn: parent }
+ }
+ Rectangle {
+ border.color: "black"
+ color: "transparent"
+ anchors { fill: parent; rightMargin: 1; bottomMargin: 1}
+ }
+}
diff --git a/examples/declarative/flowview/flickr.qml b/examples/declarative/flowview/flickr.qml
new file mode 100644
index 0000000..1cdb132
--- /dev/null
+++ b/examples/declarative/flowview/flickr.qml
@@ -0,0 +1,46 @@
+import Qt 4.6
+
+Rectangle {
+ radius: 5;
+ border.width: 1;
+ width:400;
+ height: 120;
+ color: background;
+
+ XmlListModel {
+ id: FeedModel
+ 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: "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()" }
+ }
+
+ ListView {
+ clip: true
+ orientation: "Horizontal"
+ width: parent.width
+ height: 86
+ y: 17
+ model: FeedModel
+ delegate:
+ Item { width: 90; height: 86
+ Rectangle {
+ anchors.centerIn: parent
+ width: 86; height: 86;
+ color: "white"; radius: 5
+ Image { source: imagePath; x: 5; y: 5 }
+ }
+ }
+ }
+}
+
diff --git a/examples/declarative/flowview/flowview.qml b/examples/declarative/flowview/flowview.qml
new file mode 100644
index 0000000..ca31bcc
--- /dev/null
+++ b/examples/declarative/flowview/flowview.qml
@@ -0,0 +1,147 @@
+import Qt 4.6
+
+Rectangle {
+ width: 800
+ height: 800
+ color: "black"
+
+ Rectangle {
+ id: MyPhone
+ transformOrigin: "Center"
+ anchors.centerIn: parent
+ width: 800
+ height: 480
+ clip: true
+
+ states: State {
+ name: "rotated"
+ PropertyChanges { target: ListView; z: 2 }
+ PropertyChanges { target: TopBar; y: -30 }
+ PropertyChanges { target: BottomBar; y: 480 }
+ PropertyChanges { target: LeftBar; x: 0 }
+ PropertyChanges { target: RightBar; x: 770 }
+ }
+ transitions: Transition {
+ from: "" ; to: "rotated"
+ reversible: true
+ SequentialAnimation {
+ NumberAnimation { targets: [TopBar, BottomBar]; properties: "x,y"; easing: "easeInOutQuad" }
+ NumberAnimation { targets: [LeftBar, RightBar]; properties: "x,y"; easing: "easeInOutQuad"}
+ }
+ }
+
+ color: "lightsteelblue"
+
+ VisualDataModel {
+ id: Model
+ model: ListModel {
+ ListElement { background: "red"; weblet: "rect.qml" }
+ ListElement { background: "yellow"; weblet: "rect.qml" }
+ ListElement { background: "blue"; weblet: "rect.qml" }
+ ListElement { background: "green"; weblet: "flickr.qml" }
+ ListElement { background: "orange"; weblet: "rect.qml" }
+ ListElement { background: "lightblue"; weblet: "rect.qml" }
+ }
+ delegate: Package {
+ Item { id: List; Package.name: "list"; width:120; height: 400; }
+ Item { id: Grid; Package.name: "grid"; width:400; height: 120; }
+ Loader { id: MyContent; width:400; height: 120; source: weblet }
+
+ StateGroup {
+ states: [
+ State {
+ name: "InList"
+ when: MyPhone.state == "rotated"
+ ParentChange { target: MyContent; parent: List }
+ PropertyChanges { target: MyContent; x: 120; y: 0; rotation: 90}
+ },
+ State {
+ name: "InGrid"
+ when: MyPhone.state != "rotated"
+ ParentChange { target: MyContent; parent: Grid }
+ PropertyChanges { target: MyContent; x: 0; y: 0; }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"; to: "InGrid"
+ SequentialAnimation {
+ ParentAction{}
+ PauseAnimation { duration: 50 * List.FlowView.column }
+ NumberAnimation { properties: "x,y,rotation"; easing: "easeInOutQuad" }
+ }
+ },
+ Transition {
+ from: "*"; to: "InList"
+ SequentialAnimation {
+ ParentAction{}
+ PauseAnimation { duration: 50 * (Grid.FlowView.row * 2 + Grid.FlowView.column) }
+ NumberAnimation { properties: "x,y,rotation"; easing: "easeInOutQuad" }
+ }
+ }
+ ]
+ }
+
+ }
+ }
+
+ Item {
+ FlowView {
+ id: ListView
+ vertical: true
+ y: 40
+ x: 40
+ width: 800
+ height: 400
+ column: 1
+ model: Model.parts.list
+ }
+
+ FlowView {
+ z: 1
+ y: 60
+ width: 800
+ height: 400
+ column: 2
+ model: Model.parts.grid
+ }
+ }
+
+ Rectangle {
+ id: TopBar
+ width: 800
+ height: 30
+ }
+ Rectangle {
+ id: BottomBar
+ width: 800
+ height: 30
+ y: 450
+ }
+ Rectangle {
+ id: LeftBar
+ x: -30
+ width: 30
+ height: 480
+ }
+ Rectangle {
+ id: RightBar
+ x: 800
+ width: 30
+ height: 480
+ }
+ }
+
+ Rectangle {
+ width: 80
+ height: 80
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ Text { text: "Switch" }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: if(MyPhone.state == "rotated") MyPhone.state=""; else MyPhone.state = "rotated";
+ }
+ }
+
+}
diff --git a/examples/declarative/flowview/rect.qml b/examples/declarative/flowview/rect.qml
new file mode 100644
index 0000000..7d2b58b
--- /dev/null
+++ b/examples/declarative/flowview/rect.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Rectangle { radius: 5; border.width: 1; width:400; height: 120; color: background; }
+
diff --git a/examples/declarative/focusscope/test.qml b/examples/declarative/focusscope/test.qml
new file mode 100644
index 0000000..22ffc8d
--- /dev/null
+++ b/examples/declarative/focusscope/test.qml
@@ -0,0 +1,76 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Keys.onDigit9Pressed: print("Error - Root")
+
+ FocusScope {
+ id: MyScope
+ focus: true
+
+ Keys.onDigit9Pressed: print("Error - FocusScope")
+
+ Rectangle {
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ border.color: MyScope.focus?"blue":"black"
+
+ Rectangle {
+ id: Item1
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: focus?"blue":"black"
+ Keys.onDigit9Pressed: print("Top Left");
+ KeyNavigation.right: Item2
+ focus: true
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.activeFocus?"red":"transparent"
+ }
+ }
+
+ Rectangle {
+ id: Item2
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: focus?"blue":"black"
+ KeyNavigation.left: Item1
+ Keys.onDigit9Pressed: print("Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.activeFocus?"red":"transparent"
+ }
+ }
+ }
+ KeyNavigation.down: Item3
+ }
+
+ Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" }
+
+ Rectangle {
+ id: Item3
+ x: 10; y: 300
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: focus?"blue":"black"
+
+ Keys.onDigit9Pressed: print("Bottom Left");
+ KeyNavigation.up: MyScope
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.activeFocus?"red":"transparent"
+ }
+ }
+
+}
diff --git a/examples/declarative/focusscope/test2.qml b/examples/declarative/focusscope/test2.qml
new file mode 100644
index 0000000..0ac0f5d
--- /dev/null
+++ b/examples/declarative/focusscope/test2.qml
@@ -0,0 +1,40 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Text { text: "All five rectangles should be red" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.focus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.focus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.focus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.focus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.focus?"red":"blue" }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml
new file mode 100644
index 0000000..51fa35a
--- /dev/null
+++ b/examples/declarative/focusscope/test3.qml
@@ -0,0 +1,50 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ ListModel {
+ id: Model
+ ListElement { name: "1" }
+ ListElement { name: "2" }
+ ListElement { name: "3" }
+ ListElement { name: "4" }
+ ListElement { name: "5" }
+ ListElement { name: "6" }
+ ListElement { name: "6" }
+ ListElement { name: "8" }
+ ListElement { name: "9" }
+ }
+
+ Component {
+ id: VerticalDelegate
+ FocusScope {
+ id: Root
+ width: 50; height: 50;
+ Keys.onDigit9Pressed: print("Error - " + name)
+ Rectangle {
+ focus: true
+ Keys.onDigit9Pressed: print(name)
+ width: 50; height: 50;
+ color: Root.ListView.isCurrentItem?"red":"green"
+ Text { text: name; anchors.centerIn: parent }
+ }
+ }
+ }
+
+ ListView {
+ width: 800; height: 50; orientation: "Horizontal"
+ focus: true
+ model: Model
+ delegate: VerticalDelegate
+ currentItemPositioning: "SnapAuto"
+ }
+
+
+ Text {
+ y: 100; x: 50
+ text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left."
+ }
+}
diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml
new file mode 100644
index 0000000..37dc2e8
--- /dev/null
+++ b/examples/declarative/follow/follow.qml
@@ -0,0 +1,73 @@
+import Qt 4.6
+
+Rectangle {
+ color: "#ffffff"
+ width: 320; height: 240
+ Rectangle {
+ id: Rect
+ color: "#00ff00"
+ y: 200; width: 60; height: 20
+ y: SequentialAnimation {
+ running: true; repeat: true
+ NumberAnimation {
+ to: 20; duration: 500
+ easing: "easeInOutQuad"
+ }
+ NumberAnimation {
+ to: 200; duration: 2000
+ easing: "easeOutBounce"
+ }
+ PauseAnimation { duration: 1000 }
+ }
+ }
+
+ // Velocity
+ Rectangle {
+ color: "#ff0000"
+ x: Rect.width; width: Rect.width; height: 20
+ y: 200
+ y: Follow { source: Rect.y; velocity: 200 }
+ }
+ Text { x: Rect.width; y: 220; text: "Velocity" }
+
+ // Spring
+ Rectangle {
+ color: "#ff0000"
+ x: Rect.width * 2; width: Rect.width/2; height: 20
+ y: 200
+ y: Follow { source: Rect.y; spring: 1.0; damping: 0.2 }
+ }
+ Rectangle {
+ color: "#880000"
+ x: Rect.width * 2.5; width: Rect.width/2; height: 20
+ y: 200
+ y: Follow { source: Rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ }
+ Text { x: Rect.width * 2; y: 220; text: "Spring" }
+
+ // Follow mouse
+ MouseRegion {
+ id: Mouse
+ anchors.fill: parent
+ Rectangle {
+ id: "Ball"
+ width: 20; height: 20
+ radius: 10
+ color: "#0000ff"
+ x: Follow { id: "F1"; source: Mouse.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ y: Follow { id: "F2"; source: Mouse.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ states: [
+ State {
+ name: "following"
+ when: !F1.inSync || !F2.inSync
+ PropertyChanges { target: Ball; color: "#ff0000" }
+ }
+ ]
+ transitions: [
+ Transition {
+ ColorAnimation { duration: 200 }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml
new file mode 100644
index 0000000..0314bb8
--- /dev/null
+++ b/examples/declarative/follow/pong.qml
@@ -0,0 +1,69 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ width: 640; height: 480
+ color: "#000000"
+
+ // Make a ball to bounce
+ Rectangle {
+ // Add a property for the target y coordinate
+ property var targetY : Page.height-10
+ property var direction : "right"
+
+ id: Ball
+ color: "#00ee00"
+ x: 20; width: 20; height: 20; z: 1
+
+ // Move the ball to the right and back to the left repeatedly
+ x: SequentialAnimation {
+ running: true; repeat: true
+ 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 follow the target y coordinate, with a velocity of 200
+ y: Follow { source: Ball.targetY; velocity: 200 }
+
+ // Detect the ball hitting the top or bottom of the view and bounce it
+ onYChanged: {
+ if (y <= 0)
+ targetY = Page.height-20;
+ else if (y >= Page.height-20)
+ targetY = 0;
+ }
+ }
+
+ // Place bats to the left and right of the view, following the y
+ // coordinates of the ball.
+ Rectangle {
+ id: LeftBat
+ color: "#00ee00"
+ x: 2; width: 20; height: 90
+ y: Follow {
+ source: Ball.y-45; velocity: 300
+ enabled: Ball.direction == 'left'
+ }
+ }
+ Rectangle {
+ id: RightBat
+ color: "#00ee00"
+ x: Page.width-22; width: 20; height: 90
+ y: Follow {
+ source: Ball.y-45; velocity: 300
+ enabled: Ball.direction == 'right'
+ }
+ }
+
+ // The rest, to make it look realistic, if neither ever scores...
+ Rectangle { color: "#00ee00"; x: Page.width/2-80; y: 0; width: 40; height: 60 }
+ Rectangle { color: "#000000"; x: Page.width/2-70; y: 10; width: 20; height: 40 }
+ Rectangle { color: "#00ee00"; x: Page.width/2+40; y: 0; width: 40; height: 60 }
+ Rectangle { color: "#000000"; x: Page.width/2+50; y: 10; width: 20; height: 40 }
+ Repeater {
+ model: Page.height/20
+ Rectangle { color: "#00ee00"; x: Page.width/2-5; y: index*20; width: 10; height: 10 }
+ }
+}
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml
new file mode 100644
index 0000000..f7ed494
--- /dev/null
+++ b/examples/declarative/fonts/fonts.qml
@@ -0,0 +1,66 @@
+import Qt 4.6
+
+Rectangle {
+ property string myText: "Lorem ipsum dolor sit amet, consectetur adipisicing elit"
+
+ width: 800; height: 600
+ color: Palette.base
+
+ SystemPalette { id: Palette; colorGroup: Qt.Active }
+
+ FontLoader { id: FixedFont; name: "Courier" }
+
+ FontLoader { id: LocalFont; source: "fonts/Fontin-Bold.ttf" }
+ /* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */
+
+ FontLoader { id: WebFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
+ FontLoader { id: WebFont2; source: "http://wrong.address.org" }
+
+ Column {
+ anchors.fill: parent
+ anchors.leftMargin: 10; anchors.rightMargin: 10
+ Text {
+ text: myText
+ color: Palette.windowText
+ width: parent.width; elide: "ElideRight"
+ font.family: "Times"
+ font.pointSize: 32
+ }
+ Text {
+ text: myText
+ color: Palette.windowText
+ width: parent.width; elide: "ElideRight"
+ font.family: FixedFont.name
+ font.pointSize: 32
+ }
+ Text {
+ text: myText
+ color: Palette.windowText
+ width: parent.width; elide: "ElideRight"
+ font.family: LocalFont.name
+ font.pointSize: 32
+ }
+ Text {
+ text: {
+ if (WebFont.status == 1) myText
+ else if (WebFont.status == 2) "Loading..."
+ else if (WebFont.status == 3) "Error loading font"
+ }
+ color: Palette.windowText
+ width: parent.width; elide: "ElideRight"
+ font.family: WebFont.name
+ font.pointSize: 32
+ }
+ Text {
+ text: {
+ if (WebFont2.status == 1) myText
+ else if (WebFont2.status == 2) "Loading..."
+ else if (WebFont2.status == 3) "Error loading font"
+ }
+ color: Palette.windowText
+ width: parent.width; elide: "ElideRight"
+ font.family: WebFont2.name
+ font.pointSize: 32
+ }
+ }
+}
diff --git a/examples/declarative/fonts/fonts/Fontin-Bold.ttf b/examples/declarative/fonts/fonts/Fontin-Bold.ttf
new file mode 100644
index 0000000..f6a33b0
--- /dev/null
+++ b/examples/declarative/fonts/fonts/Fontin-Bold.ttf
Binary files differ
diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml
new file mode 100644
index 0000000..6c2fd8d
--- /dev/null
+++ b/examples/declarative/layouts/Button.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.width + text.width + 13; height: pix.height + 10; id: page
+ property string text
+ property string icon
+ signal clicked
+ Image { id: pix; x: 5; y:5; source: parent.icon}
+ Text { id: text; text: page.text; color: "white"; x:pix.width+pix.x+3; anchors.verticalCenter: pix.verticalCenter;}
+ MouseRegion{ id:mr; anchors.fill: parent; onClicked: {parent.focus = true; page.clicked()}}
+
+ states:
+ State{ name:"pressed"; when:mr.pressed
+ PropertyChanges {target:text; x: 5}
+ PropertyChanges {target:pix; x:text.x+text.width + 3}
+ }
+
+ transitions:
+ Transition{
+ NumberAnimation{ properties:"x,left"; easing:"easeInOutQuad"; duration:200 }
+ }
+}
diff --git a/examples/declarative/layouts/add.png b/examples/declarative/layouts/add.png
new file mode 100644
index 0000000..f29d84b
--- /dev/null
+++ b/examples/declarative/layouts/add.png
Binary files differ
diff --git a/examples/declarative/layouts/del.png b/examples/declarative/layouts/del.png
new file mode 100644
index 0000000..1d753a3
--- /dev/null
+++ b/examples/declarative/layouts/del.png
Binary files differ
diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml
new file mode 100644
index 0000000..6e22d8b
--- /dev/null
+++ b/examples/declarative/layouts/layouts.qml
@@ -0,0 +1,25 @@
+import Qt 4.6
+
+Item { id: resizable
+ width:400; height:400;
+ GraphicsObjectContainer{
+ anchors.fill:parent
+ QGraphicsWidget{
+ geometry:{ "0,0," + parent.width.toString() + "x" + parent.height.toString(); }
+ layout: QGraphicsLinearLayout{
+ LayoutItem{
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { color: "yellow"; anchors.fill: parent }
+ }
+ LayoutItem{
+ minimumSize: "100x100"
+ maximumSize: "400x400"
+ preferredSize: "200x200"
+ Rectangle { color: "green"; anchors.fill: parent }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml
new file mode 100644
index 0000000..fe28105
--- /dev/null
+++ b/examples/declarative/layouts/positioners.qml
@@ -0,0 +1,51 @@
+import Qt 4.6
+Rectangle { width: 420; height: 420; id:page; color:"white"
+ Column { id: layout1; y:0; //width: 100; height:250;
+ move: Transition{ NumberAnimation {properties: "y"; easing: "easeOutBounce" }}
+ add: Transition{ NumberAnimation { properties: "y"; from: 500; duration:500; easing: "easeOutQuad"}}
+ remove: Transition { NumberAnimation { properties:"y"; to: 500; duration:500; easing: "easeInQuad"}}
+ Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueV1; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15
+ //opacity: Behavior{ NumberAnimation {}}
+ }
+ Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueV2; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15
+ //opacity: Behavior{ NumberAnimation {}}
+ }
+ Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 }
+ }
+ Row { id: layout2; y:300;
+ move: Transition{ NumberAnimation {properties: "x"; easing: "easeOutBounce" }}
+ add: Transition{ NumberAnimation { properties: "x"; from: 500; duration:500; easing: "easeOutQuad"}
+ NumberAnimation { properties: "opacity"; from: 0; duration: 500;}}
+ remove: Transition { NumberAnimation { properties: "x"; to: 500; duration:500; easing: "easeInQuad"}
+ NumberAnimation { properties: "opacity"; from: 1; duration: 500}}
+ Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { id: blueH1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { id: blueH2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ }
+ Button { text: "Remove"; icon: "del.png"; x: 135; y:90;
+ onClicked: {blueH2.opacity=0; blueH1.opacity=0; blueV1.opacity=0; blueV2.opacity=0; blueG1.opacity=0; blueG2.opacity=0; blueG3.opacity=0;}
+ }
+ Button { text: "Add"; icon: "add.png"; x: 145; y:140;
+ onClicked: {blueH2.opacity=1; blueH1.opacity=1; blueV1.opacity=1; blueV2.opacity=1; blueG1.opacity=1; blueG2.opacity=1; blueG3.opacity=1;}
+ }
+ Grid { x:260; y:0; columns:3
+ remove: Transition { NumberAnimation{ properties: "opacity"; from: 1; to: 0; duration: 500}
+ NumberAnimation{properties: "x,y"; easing: "easeOutBounce"} }
+ move: Transition { NumberAnimation{ properties: "x,y"; easing: "easeOutBounce" }}
+ add: Transition { NumberAnimation{ properties: "opacity"; from: 0; to: 1; duration: 500}
+ NumberAnimation{properties: "x,y"; easing: "easeOutBounce"} }
+ Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG3; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 }
+ }
+}
diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml
new file mode 100644
index 0000000..599452d
--- /dev/null
+++ b/examples/declarative/listview/content/MediaButton.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Item {
+ property var text
+ signal clicked
+
+ id: Container
+ Image {
+ id: Image
+ source: "pics/button.png"
+ }
+ Image {
+ id: Pressed
+ source: "pics/button-pressed.png"
+ opacity: 0
+ }
+ MouseRegion {
+ id: MouseRegion
+ anchors.fill: Image
+ onClicked: { Container.clicked(); }
+ }
+ Text {
+ font.bold: true
+ color: "white"
+ anchors.centerIn: Image
+ text: Container.text
+ }
+ width: Image.width
+ states: [
+ State {
+ name: "Pressed"
+ when: MouseRegion.pressed == true
+ PropertyChanges {
+ target: Pressed
+ opacity: 1
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/listview/content/pics/button-pressed.png b/examples/declarative/listview/content/pics/button-pressed.png
new file mode 100644
index 0000000..e434d32
--- /dev/null
+++ b/examples/declarative/listview/content/pics/button-pressed.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/button.png b/examples/declarative/listview/content/pics/button.png
new file mode 100644
index 0000000..56a63ce
--- /dev/null
+++ b/examples/declarative/listview/content/pics/button.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/fruit-salad.jpg b/examples/declarative/listview/content/pics/fruit-salad.jpg
new file mode 100644
index 0000000..da5a6b1
--- /dev/null
+++ b/examples/declarative/listview/content/pics/fruit-salad.jpg
Binary files differ
diff --git a/examples/declarative/listview/content/pics/hamburger.jpg b/examples/declarative/listview/content/pics/hamburger.jpg
new file mode 100644
index 0000000..d0a15be
--- /dev/null
+++ b/examples/declarative/listview/content/pics/hamburger.jpg
Binary files differ
diff --git a/examples/declarative/listview/content/pics/lemonade.jpg b/examples/declarative/listview/content/pics/lemonade.jpg
new file mode 100644
index 0000000..db445c9
--- /dev/null
+++ b/examples/declarative/listview/content/pics/lemonade.jpg
Binary files differ
diff --git a/examples/declarative/listview/content/pics/moreDown.png b/examples/declarative/listview/content/pics/moreDown.png
new file mode 100644
index 0000000..31a35d5
--- /dev/null
+++ b/examples/declarative/listview/content/pics/moreDown.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/moreUp.png b/examples/declarative/listview/content/pics/moreUp.png
new file mode 100644
index 0000000..fefb9c9
--- /dev/null
+++ b/examples/declarative/listview/content/pics/moreUp.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/pancakes.jpg b/examples/declarative/listview/content/pics/pancakes.jpg
new file mode 100644
index 0000000..60c4396
--- /dev/null
+++ b/examples/declarative/listview/content/pics/pancakes.jpg
Binary files differ
diff --git a/examples/declarative/listview/content/pics/vegetable-soup.jpg b/examples/declarative/listview/content/pics/vegetable-soup.jpg
new file mode 100644
index 0000000..9dce332
--- /dev/null
+++ b/examples/declarative/listview/content/pics/vegetable-soup.jpg
Binary files differ
diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml
new file mode 100644
index 0000000..9a00dca
--- /dev/null
+++ b/examples/declarative/listview/dummydata/MyPetsModel.qml
@@ -0,0 +1,61 @@
+import Qt 4.6
+
+// ListModel allows free form list models to be defined and populated.
+// Be sure to name the file the same as the id.
+ListModel {
+ id: MyListElementsModel
+ 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: "Whiskers"
+ 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/declarative/listview/dummydata/Recipes.qml b/examples/declarative/listview/dummydata/Recipes.qml
new file mode 100644
index 0000000..533730f
--- /dev/null
+++ b/examples/declarative/listview/dummydata/Recipes.qml
@@ -0,0 +1,90 @@
+import Qt 4.6
+
+ListModel {
+ id: Recipes
+ 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/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
new file mode 100644
index 0000000..2bf3a9f
--- /dev/null
+++ b/examples/declarative/listview/highlight.qml
@@ -0,0 +1,57 @@
+import Qt 4.6
+
+Rectangle {
+ width: 400; height: 300; color: "white"
+
+ // MyPets model is defined in dummydata/MyPetsModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+ // This one contains my pets.
+ // 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: 50
+ Column {
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ // Use the ListView.isCurrentItem attached property to
+ // indent the item if it is the current item.
+ states: [
+ State {
+ name: "Current"
+ when: Wrapper.ListView.isCurrentItem
+ PropertyChanges { target: Wrapper; x: 10 }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumberAnimation {
+ properties: "x"; duration: 200
+ }
+ }
+ ]
+ }
+ }
+ // Specify a highlight with custom movement. Note that autoHighlight
+ // is set to false in the ListView so that we can control how the
+ // highlight moves to the current item.
+ Component {
+ id: PetHighlight
+ Rectangle {
+ width: 200; height: 50; color: "#FFFF88"
+ y: Follow { source: List1.current.y; spring: 3; damping: 0.1 }
+ }
+ }
+ ListView {
+ id: List1
+ width: 200; height: parent.height
+ model: MyPetsModel; delegate: PetDelegate
+ highlight: PetHighlight; autoHighlight: false
+ focus: true
+ }
+}
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
new file mode 100644
index 0000000..061fab3
--- /dev/null
+++ b/examples/declarative/listview/itemlist.qml
@@ -0,0 +1,57 @@
+// This example demonstrates placing items in a view using
+// a VisualItemModel
+
+import Qt 4.6
+
+Rectangle {
+ color: "lightgray"
+ width: 240
+ height: 320
+
+ VisualItemModel {
+ id: ItemModel
+ Rectangle {
+ height: View.height; width: View.width; color: "#FFFEF0"
+ Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent }
+ }
+ Rectangle {
+ height: View.height; width: View.width; color: "#F0FFF7"
+ Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent }
+ }
+ Rectangle {
+ height: View.height; width: View.width; color: "#F4F0FF"
+ Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent }
+ }
+ }
+
+ ListView {
+ id: View
+ anchors.fill: parent
+ anchors.bottomMargin: 30
+ model: ItemModel
+ currentItemPositioning: "SnapAuto"
+ orientation: "Horizontal"
+ }
+
+ Rectangle {
+ color: "gray"
+ anchors.top: View.bottom
+ anchors.bottom: parent.bottom
+ height: 30
+ width: 240
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+ Repeater {
+ model: ItemModel.count
+ Rectangle {
+ width: 5; height: 5
+ radius: 3
+ MouseRegion { width: 20; height: 20; anchors.centerIn: parent; onClicked: View.currentIndex = index }
+ color: View.currentIndex == index ? "blue" : "white"
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml
new file mode 100644
index 0000000..0f197b4
--- /dev/null
+++ b/examples/declarative/listview/listview.qml
@@ -0,0 +1,82 @@
+import Qt 4.6
+
+Rectangle {
+ width: 600; height: 300; color: "white"
+
+ // MyPets model is defined in dummydata/MyPetsModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+ // This one contains my pets.
+ // 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: 50
+ Column {
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ }
+ }
+
+ // Define a highlight component. Just one of these will be instantiated
+ // by each ListView and placed behind the current item.
+ Component {
+ id: PetHighlight
+ Rectangle { color: "#FFFF88" }
+ }
+
+ // Show the model in three lists, with different currentItemPositioning.
+ // currentItemPositioning determines how the list behaves when the
+ // current item changes. Note that the second and third ListView
+ // set their currentIndex to be the same as the first, and that
+ // the first ListView is given keyboard focus.
+ // The default mode, Free, allows the currentItem to move freely
+ // within the visible area. If it would move outside the visible
+ // area, the view is scrolled to keep it visible.
+ // Snap currentItemPositioning attempts to keep the current item
+ // aligned with the snapPosition by scrolling the view, however the
+ // items will not scroll beyond the beginning or end of the view.
+ // SnapAuto currentItemPositioning always keeps the current item on
+ // the snapPosition by scrolling the view. It also automatically
+ // sets the current item as is scrolled with the mouse. Note
+ // that the first ListView sets its currentIndex to be equal to
+ // the third ListView's currentIndex. By flicking List3 with
+ // the mouse, the current index of List1 will be changed.
+ ListView {
+ id: List1
+ width: 200; height: parent.height
+ model: MyPetsModel; delegate: PetDelegate
+ highlight: PetHighlight; currentIndex: List3.currentIndex
+ focus: true
+ }
+ ListView {
+ id: List2
+ x: 200; width: 200; height: parent.height
+ model: MyPetsModel; delegate: PetDelegate; highlight: PetHighlight
+ currentItemPositioning: "Snap"; snapPosition: 125
+ currentIndex: List1.currentIndex
+ }
+ ListView {
+ id: List3
+ x: 400; width: 200; height: parent.height
+ model: MyPetsModel; delegate: PetDelegate
+ currentItemPositioning: "SnapAuto"; snapPosition: 125
+ currentIndex: List1.currentIndex
+ children: [
+ // Position a static highlight rather than a normal highlight so that
+ // when the view is flicked, the highlight does not move.
+ // By positioning the highlight at the same position as the snapPosition
+ // the item under the highlight will always be the current item.
+ // Note that we specify the 'children' property. This is because
+ // the default property of a ListView is 'delegate'.
+ Rectangle {
+ y: 125; width: 200; height: 50
+ color: "#FFFF88"; z: -1
+ }
+ ]
+ }
+}
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
new file mode 100644
index 0000000..eac8bb5
--- /dev/null
+++ b/examples/declarative/listview/recipes.qml
@@ -0,0 +1,132 @@
+import Qt 4.6
+
+import "content"
+// This example illustrates expanding a list item to show a more detailed view
+Rectangle {
+ id: page
+ width: 400; height: 240; color: "black"
+ resources: [
+ // Delegate for the recipes. This delegate has two modes:
+ // 1. the list mode (default), which just shows the picture and title of the recipe.
+ // 2. the details mode, which also shows the ingredients and method.
+ Component {
+ id: recipeDelegate
+ Item {
+ id: wrapper
+ width: List.width
+ // 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
+
+ // A simple rounded rectangle for the background
+ Rectangle {
+ id: background
+ x: 1; y: 2; width: parent.width-2; height: parent.height-4
+ color: "#FEFFEE"; border.color: "#FFBE4F"; 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.
+ MouseRegion {
+ id: pageMouse
+ anchors.fill: parent
+ onClicked: { wrapper.state = 'Details' }
+ }
+ // Layout the page. Picture, title and ingredients at the top, method at the
+ // bottom. Note that elements that should not be visible in the list
+ // mode have their opacity set to wrapper.detailsOpacity.
+ Row {
+ id: topLayout
+ x: 10; y: 10; height: recipePic.height; width: parent.width
+ spacing: 10
+ Image {
+ id: recipePic
+ source: picture; width: 48; height: 48
+ }
+ Column {
+ height: recipePic.height; width: background.width-recipePic.width-20
+ spacing: 5
+ Text { id: name; text: title; font.bold: true; font.pointSize: 16 }
+ Text {
+ text: "Ingredients"; font.pointSize: 12; font.bold: true
+ opacity: wrapper.detailsOpacity
+ }
+ Text {
+ text: ingredients; wrap: true; width: parent.width
+ opacity: wrapper.detailsOpacity
+ }
+ }
+ }
+ Item {
+ id: details
+ x: 10; width: parent.width-20
+ anchors.top: topLayout.bottom; anchors.topMargin: 10
+ anchors.bottom: parent.bottom; anchors.bottomMargin: 10
+ opacity: wrapper.detailsOpacity
+ Text {
+ id: methodTitle
+ text: "Method"; font.pointSize: 12; font.bold: true
+ anchors.top: parent.top
+ }
+ Flickable {
+ id: flick
+ anchors.top: methodTitle.bottom; anchors.bottom: parent.bottom
+ width: parent.width; viewportHeight: methodText.height; clip: true
+ Text { id: methodText; text: method; wrap: true; width: details.width }
+ }
+ Image {
+ anchors.right: flick.right; anchors.top: flick.top
+ source: "content/pics/moreUp.png"; opacity: flick.atYBeginning ? 0 : 1
+ }
+ Image {
+ anchors.right: flick.right; anchors.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 ('').
+ MediaButton {
+ anchors.right: background.right; anchors.rightMargin: 5
+ y: 10; opacity: wrapper.detailsOpacity
+ text: "Close"; onClicked: { wrapper.state = '' }
+ }
+ // Make the default height equal the hight of the picture, plus margin.
+ height: 68
+ states: [
+ State {
+ name: "Details"
+ PropertyChanges { target: background; color: "white" }
+ // Make the picture bigger
+ PropertyChanges { target: recipePic; width: 128; height: 128 }
+ // Make details visible
+ PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 }
+ // Make the detailed view fill the entire list area
+ PropertyChanges { target: wrapper; height: List.height }
+ // Move the list so that this item is at the top.
+ PropertyChanges { target: wrapper.ListView.view; explicit: true; yPosition: wrapper.y }
+ // Disallow flicking while we're in detailed view
+ PropertyChanges { target: wrapper.ListView.view; locked: 1 }
+ }
+ ]
+ transitions: [
+ Transition {
+ // Make the state changes smooth
+ ParallelAnimation {
+ ColorAnimation { property: "color"; duration: 500 }
+ NumberAnimation {
+ duration: 300; properties: "detailsOpacity,x,yPosition,height,width"
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ // The actual list
+ ListView {
+ id: List
+ model: Recipes; delegate: recipeDelegate
+ anchors.fill: parent; clip: true
+ }
+}
diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml
new file mode 100644
index 0000000..ddb4931
--- /dev/null
+++ b/examples/declarative/listview/sections.qml
@@ -0,0 +1,71 @@
+import Qt 4.6
+
+//! [0]
+Rectangle {
+ width: 200
+ height: 240
+ color: "white"
+ // MyPets model is defined in dummydata/MyPetsModel.qml
+ // The viewer automatically loads files in dummydata/* to assist
+ // development without a real data source.
+ // This one contains my pets.
+
+ // Define a delegate component that includes a separator for sections.
+ Component {
+ id: PetDelegate
+ Item {
+ id: Wrapper
+ width: 200
+ // My height is the combined height of the description and the section separator
+ height: Separator.height + Desc.height
+ Rectangle {
+ id: Separator
+ color: "lightsteelblue"
+ width: parent.width
+ // Only show the section separator when we are the beginning of a new section
+ // Note that for this to work nicely, the list must be ordered by section.
+ height: Wrapper.ListView.prevSection != Wrapper.ListView.section ? 20 : 0
+ opacity: Wrapper.ListView.prevSection != Wrapper.ListView.section ? 1 : 0
+ Text {
+ text: Wrapper.ListView.section; font.bold: true
+ x: 2; height: parent.height; verticalAlignment: 'AlignVCenter'
+ }
+ }
+ Item {
+ id: Desc
+ x: 5
+ height: Layout.height + 4
+ anchors.top: Separator.bottom
+ Column {
+ id: Layout
+ y: 2
+ Text { text: 'Name: ' + name }
+ Text { text: 'Type: ' + type }
+ Text { text: 'Age: ' + age }
+ }
+ }
+ }
+ }
+ // Define a highlight component. Just one of these will be instantiated
+ // by each ListView and placed behind the current item.
+ Component {
+ id: PetHighlight
+ Rectangle {
+ color: "#FFFF88"
+ }
+ }
+ // The list
+ ListView {
+ id: List
+ width: 200
+ height: parent.height
+ model: MyPetsModel
+ delegate: PetDelegate
+ highlight: PetHighlight
+ // The sectionExpression is simply the size of the pet.
+ // We use this to determine which section we are in above.
+ sectionExpression: "size"
+ focus: true
+ }
+}
+//! [0]
diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml
new file mode 100644
index 0000000..196cdc5
--- /dev/null
+++ b/examples/declarative/loader/Browser.qml
@@ -0,0 +1,113 @@
+import Qt 4.6
+
+Rectangle {
+ id: Root
+ width: parent.width
+ height: parent.height
+ color: Palette.base
+ FolderListModel {
+ id: folders
+ nameFilters: [ "*.qml" ]
+// folder: "E:"
+ }
+
+ SystemPalette { id: Palette; colorGroup: Qt.Active }
+
+ Component {
+ id: FolderDelegate
+ Rectangle {
+ id: Wrapper
+ function launch() {
+ if (folders.isFolder(index)) {
+ folders.folder = filePath;
+ } else {
+ qmlLauncher.launch(filePath);
+ }
+ }
+ width: Root.width
+ height: 32
+ color: "transparent"
+ Rectangle {
+ id: Highlight; visible: false
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { id: t1; position: 0.0; color: Palette.highlight }
+ GradientStop { id: t2; position: 1.0; color: Palette.lighter(Palette.highlight) }
+ }
+ }
+ Item {
+ width: 32; height: 32
+ Image { source: "images/fileopen.png"; anchors.centerIn: parent; visible: folders.isFolder(index)}
+ }
+ Text {
+ id: NameText
+ anchors.fill: parent; verticalAlignment: "AlignVCenter"
+ text: fileName; anchors.leftMargin: 32
+ font.pointSize: 10
+ color: Palette.windowText
+ }
+ MouseRegion {
+ id: Mouse
+ anchors.fill: parent
+ onClicked: { launch() }
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: Mouse.pressed
+ PropertyChanges { target: Highlight; visible: true }
+ PropertyChanges { target: NameText; color: Palette.highlightedText }
+ }
+ ]
+ }
+ }
+
+ Script {
+ function up(path) {
+ var pos = path.toString().lastIndexOf("/");
+ return path.toString().substring(0, pos);
+ }
+ }
+
+ ListView {
+ id: View
+ anchors.top: TitleBar.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ model: folders
+ delegate: FolderDelegate
+ highlight: Rectangle { color: "#FFFBAF" }
+ clip: true
+ focus: true
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) {
+ View.current.launch();
+ event.accepted = true;
+ }
+ }
+ }
+
+ Rectangle {
+ id: TitleBar
+ width: parent.width
+ height: 32
+ color: Palette.button; border.color: Palette.mid
+
+ Rectangle {
+ id: UpButton
+ width: 30
+ height: TitleBar.height
+ border.color: Palette.mid; color: "transparent"
+ MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) }
+ Image { anchors.centerIn: parent; source: "images/up.png" }
+ }
+
+ Text {
+ anchors.left: UpButton.right; anchors.right: parent.right; height: parent.height
+ anchors.leftMargin: 4; anchors.rightMargin: 4
+ text: folders.folder; color: Palette.buttonText
+ elide: "ElideLeft"; horizontalAlignment: "AlignRight"; verticalAlignment: "AlignVCenter"
+ }
+ }
+}
diff --git a/examples/declarative/loader/Button.qml b/examples/declarative/loader/Button.qml
new file mode 100644
index 0000000..d01a658
--- /dev/null
+++ b/examples/declarative/loader/Button.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+
+Rectangle {
+ id: Container
+
+ property var text
+ signal clicked
+
+ height: Text.height + 10
+ width: Text.width + 20
+ border.width: 1
+ radius: 4
+ color: "grey"
+ MouseRegion { anchors.fill: parent; onClicked: Container.clicked() }
+ Text { id: Text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text }
+}
diff --git a/examples/declarative/loader/images/fileopen.png b/examples/declarative/loader/images/fileopen.png
new file mode 100644
index 0000000..4aaf149
--- /dev/null
+++ b/examples/declarative/loader/images/fileopen.png
Binary files differ
diff --git a/examples/declarative/loader/images/up.png b/examples/declarative/loader/images/up.png
new file mode 100644
index 0000000..b05f802
--- /dev/null
+++ b/examples/declarative/loader/images/up.png
Binary files differ
diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro
new file mode 100644
index 0000000..089eaff
--- /dev/null
+++ b/examples/declarative/loader/loader.pro
@@ -0,0 +1,9 @@
+SOURCES = main.cpp
+RESOURCES = loader.qrc
+
+QT += script declarative network
+
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
+INSTALLS += target sources
diff --git a/examples/declarative/loader/loader.qml b/examples/declarative/loader/loader.qml
new file mode 100644
index 0000000..319db84
--- /dev/null
+++ b/examples/declarative/loader/loader.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Rectangle {
+ width: 300
+ height: 400
+ Loader {
+ anchors.fill: parent
+ source: "Browser.qml"
+ }
+}
diff --git a/examples/declarative/loader/loader.qrc b/examples/declarative/loader/loader.qrc
new file mode 100644
index 0000000..73ee253
--- /dev/null
+++ b/examples/declarative/loader/loader.qrc
@@ -0,0 +1,9 @@
+<RCC>
+ <qresource prefix="/">
+ <file>loader.qml</file>
+ <file>Browser.qml</file>
+ <file>images/fileopen.png</file>
+ <file>images/up.png</file>
+ <file>Button.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp
new file mode 100644
index 0000000..68f20d4
--- /dev/null
+++ b/examples/declarative/loader/main.cpp
@@ -0,0 +1,212 @@
+#include <QApplication>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+#include <QPlainTextEdit>
+#include <QAction>
+#include <QVBoxLayout>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QDebug>
+#include <QmlContext>
+#include <QmlComponent>
+#include <QmlEngine>
+#include <qfxview.h>
+#include <QDebug>
+#include <QNetworkDiskCache>
+#include <QNetworkAccessManager>
+
+QFxView *canvas = 0;
+
+class Logger : public QWidget
+{
+ Q_OBJECT
+public:
+ Logger() : QWidget() {
+ logText = new QPlainTextEdit;
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(logText);
+ layout->setMargin(0);
+ setLayout(layout);
+#ifdef Q_OS_SYMBIAN
+ QAction *closeAction = new QAction("Close", this);
+ closeAction->setSoftKeyRole(QAction::BackSoftKey);
+ connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
+
+ QList<QAction*> softKeys;
+ softKeys.append(closeAction);
+ setSoftKeys(softKeys);
+#endif
+ }
+
+ void append(const QString &text) {
+ logText->appendPlainText(text);
+ }
+
+ static Logger *instance() {
+ static Logger *logger = 0;
+ if (!logger)
+ logger = new Logger();
+ return logger;
+ }
+
+private:
+ QPlainTextEdit *logText;
+};
+
+void myMessageOutput(QtMsgType type, const char *msg)
+{
+ switch (type) {
+ case QtDebugMsg:
+ Logger::instance()->append(QString(msg));
+ break;
+ case QtWarningMsg:
+ Logger::instance()->append(QString(msg));
+ break;
+ case QtCriticalMsg:
+ Logger::instance()->append(QString(msg));
+ break;
+ case QtFatalMsg:
+ Logger::instance()->append(QString(msg));
+ abort();
+ }
+}
+
+
+class QmlLauncher : public QObject
+{
+ Q_OBJECT
+public:
+ QmlLauncher() {}
+
+ Q_INVOKABLE void launch(const QString &fileName)
+ {
+ QUrl url(fileName);
+ QFileInfo fi(fileName);
+ if (fi.exists()) {
+ url = QUrl::fromLocalFile(fi.absoluteFilePath());
+ QmlContext *ctxt = canvas->rootContext();
+ QDir dir(fi.path()+"/dummydata", "*.qml");
+ QStringList list = dir.entryList();
+ for (int i = 0; i < list.size(); ++i) {
+ QString qml = list.at(i);
+ QFile f(dir.filePath(qml));
+ f.open(QIODevice::ReadOnly);
+ QByteArray data = f.readAll();
+ QmlComponent comp(canvas->engine());
+ comp.setData(data, QUrl());
+ QObject *dummyData = comp.create();
+
+ if(comp.isError()) {
+ QList<QmlError> errors = comp.errors();
+ foreach (const QmlError &error, errors) {
+ qWarning() << error;
+ }
+ }
+
+ if (dummyData) {
+ qml.truncate(qml.length()-4);
+ ctxt->setContextProperty(qml, dummyData);
+ dummyData->setParent(this);
+ }
+ }
+ }
+
+ canvas->setUrl(fileName);
+ canvas->execute();
+ }
+
+signals:
+ void logUpdated();
+};
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow() : QMainWindow() {}
+
+
+public slots:
+ void toggleFullScreen()
+ {
+ if (isFullScreen()) {
+#ifdef Q_OS_SYMBIAN
+ showMaximized();
+#else
+ showNormal();
+#endif
+ } else {
+ showFullScreen();
+ }
+ }
+
+ void showLog()
+ {
+#ifdef Q_OS_SYMBIAN
+ Logger::instance()->showMaximized();
+#else
+ Logger::instance()->show();
+#endif
+ }
+};
+
+class ConfiguredNetworkAccessManager : public QNetworkAccessManager {
+public:
+ ConfiguredNetworkAccessManager()
+ {
+ QNetworkDiskCache *cache = new QNetworkDiskCache;
+ cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-loader-network-cache"));
+ setCache(cache);
+ }
+
+ QNetworkReply *createRequest (Operation op, const QNetworkRequest &req, QIODevice * outgoingData)
+ {
+ QNetworkRequest request = req;
+ request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+ request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ return QNetworkAccessManager::createRequest(op,request,outgoingData);
+ }
+};
+
+
+int main(int argc, char *argv[])
+{
+ qInstallMsgHandler(myMessageOutput);
+ QApplication app(argc, argv);
+
+ MainWindow *mw = new MainWindow;
+
+ QmlLauncher *launcher = new QmlLauncher;
+
+ QObject::connect(Logger::instance(), SIGNAL(textChanged()), launcher, SIGNAL(logUpdated()));
+
+ canvas = new QFxView;
+ canvas->setFocusPolicy(Qt::StrongFocus);
+ canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager);
+
+ mw->setCentralWidget(canvas);
+
+ QMenuBar *mb = mw->menuBar();
+ QAction *showLogAction = new QAction("View Log...", mw);
+ mb->addAction(showLogAction);
+ QObject::connect(showLogAction, SIGNAL(triggered()), mw, SLOT(showLog()));
+ QAction *toggleFSAction = new QAction("Fullscreen", mw);
+ mb->addAction(toggleFSAction);
+ QObject::connect(toggleFSAction, SIGNAL(triggered()), mw, SLOT(toggleFullScreen()));
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("qmlLauncher", launcher);
+ canvas->setUrl(QUrl("qrc:/loader.qml"));
+#ifdef Q_OS_SYMBIAN
+ canvas->setContentResizable(true);
+ mw->showMaximized();
+#else
+ mw->show();
+#endif
+ canvas->execute();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml
new file mode 100644
index 0000000..df4881c
--- /dev/null
+++ b/examples/declarative/minehunt/Description.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+
+Item {
+ id: Page
+ height: MyText.height + 20
+ property var text
+ MouseRegion {
+ anchors.fill: parent
+ drag.target: Page
+ drag.axis: "XandYAxis"
+ drag.minimumX: 0
+ drag.maximumX: 1000
+ drag.minimumY: 0
+ drag.maximumY: 1000
+ }
+ Rectangle {
+ radius: 10
+ anchors.fill: parent
+ color: "lightsteelblue"
+ }
+ Item {
+ x: 10
+ y: 10
+ width: parent.width - 20
+ height: parent.height - 20
+ Text {
+ id: MyText
+ text: Page.text
+ width: parent.width
+ clip: true
+ wrap: true
+ }
+ }
+}
diff --git a/examples/declarative/minehunt/Explosion.qml b/examples/declarative/minehunt/Explosion.qml
new file mode 100644
index 0000000..9b8bd6e
--- /dev/null
+++ b/examples/declarative/minehunt/Explosion.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+Item {
+ property bool explode : false
+
+ Particles {
+ id: particles
+ width: 38
+ height: 21
+ lifeSpan: 1000
+ lifeSpanDeviation: 0
+ source: "pics/star.png"
+ count: 0
+ angle: 270
+ angleDeviation: 360
+ velocity: 100
+ velocityDeviation: 20
+ z: 100
+ opacity: 0
+ streamIn: false
+ }
+ states: [ State { name: "exploding"; when: explode == true
+ PropertyChanges { target: particles; count: 200 }
+ PropertyChanges { target: particles; opacity: 1 }
+ PropertyChanges { target: particles; emitting: false } // i.e. emit only once
+ }
+ ]
+
+}
diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp
new file mode 100644
index 0000000..20f7492
--- /dev/null
+++ b/examples/declarative/minehunt/main.cpp
@@ -0,0 +1,309 @@
+#include "qmlengine.h"
+#include "qmlcontext.h"
+#include "qml.h"
+#include <qfxitem.h>
+#include <qfxview.h>
+
+#include <QWidget>
+#include <QApplication>
+#include <QFile>
+#include <QTime>
+#include <QTimer>
+#include <QVBoxLayout>
+#include <QFileInfo>
+
+QString fileName = "minehunt.qml";
+
+class Tile : public QObject
+{
+ Q_OBJECT
+public:
+ Tile() : _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;
+};
+
+QML_DECLARE_TYPE(Tile);
+QML_DEFINE_TYPE(0,0,0,0,Tile,Tile);
+
+class MyWidget : public QWidget
+{
+Q_OBJECT
+public:
+ MyWidget(int = 370, int = 480, QWidget *parent=0, Qt::WindowFlags flags=0);
+ ~MyWidget();
+
+ Q_PROPERTY(QList<Tile *> *tiles READ tiles CONSTANT);
+ QList<Tile *> *tiles() { return &_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 void flip(int row, int col);
+ Q_INVOKABLE void 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; }
+ Tile *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();}
+
+ QFxView *canvas;
+
+ QList<Tile *> _tiles;
+ int numCols;
+ int numRows;
+ bool playing;
+ bool won;
+ int remaining;
+ int nMines;
+ int nFlags;
+};
+
+MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags)
+: QWidget(parent, flags), canvas(0), numCols(9), numRows(9), playing(true), won(false)
+{
+ setObjectName("mainWidget");
+ srand(QTime(0,0,0).secsTo(QTime::currentTime()));
+
+ //initialize array
+ for(int ii = 0; ii < numRows * numCols; ++ii) {
+ _tiles << new Tile;
+ }
+
+ reset();
+
+ QVBoxLayout *vbox = new QVBoxLayout;
+ vbox->setMargin(0);
+ setLayout(vbox);
+
+ canvas = new QFxView(this);
+ canvas->setFixedSize(width, height);
+ vbox->addWidget(canvas);
+
+ QFile file(fileName);
+ file.open(QFile::ReadOnly);
+ QString qml = file.readAll();
+ canvas->setQml(qml, fileName);
+
+ QmlContext *ctxt = canvas->rootContext();
+ ctxt->addDefaultObject(this);
+
+ canvas->execute();
+}
+
+MyWidget::~MyWidget()
+{
+}
+
+void MyWidget::setBoard()
+{
+ foreach(Tile* 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);
+
+ Tile* 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++) {
+ Tile* t = tile(r, c);
+ if (t && !t->hasMine()) {
+ int hint = getHint(r,c);
+ t->setHint(hint);
+ }
+ }
+
+ setPlaying(true);
+}
+
+void MyWidget::reset()
+{
+ foreach(Tile* t, _tiles){
+ t->unflip();
+ t->setHasFlag(false);
+ }
+ nMines = 12;
+ nFlags = 0;
+ setPlaying(false);
+ QTimer::singleShot(900,this, SLOT(setBoard()));
+}
+
+int MyWidget::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++) {
+ Tile* t = tile(r, c);
+ if (t && t->hasMine())
+ hint++;
+ }
+ return hint;
+}
+
+void MyWidget::flip(int row, int col)
+{
+ if(!playing)
+ return;
+
+ Tile *t = tile(row, col);
+ if (!t || t->hasFlag())
+ return;
+
+ if(t->flipped()){
+ int flags = 0;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ Tile *nearT = tile(r, c);
+ if(!nearT || nearT == t)
+ continue;
+ if(nearT->hasFlag())
+ flags++;
+ }
+ if(!t->hint() || t->hint() != flags)
+ return;
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ Tile *nearT = tile(r, c);
+ if (nearT && !nearT->flipped() && !nearT->hasFlag()) {
+ flip( r, c );
+ }
+ }
+ return;
+ }
+
+ t->flip();
+
+ if (t->hint() == 0) {
+ for (int c = col-1; c <= col+1; c++)
+ for (int r = row-1; r <= row+1; r++) {
+ Tile* 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++) {
+ Tile* t = tile(r, c);
+ if (t && t->hasMine()) {
+ flip(r, c);
+ }
+ }
+ won = false;
+ hasWonChanged();
+ setPlaying(false);
+ }
+
+ remaining--;
+ if(!remaining){
+ won = true;
+ hasWonChanged();
+ setPlaying(false);
+ }
+}
+
+void MyWidget::flag(int row, int col)
+{
+ Tile *t = tile(row, col);
+ if(!t)
+ return;
+
+ t->setHasFlag(!t->hasFlag());
+ nFlags += (t->hasFlag()?1:-1);
+ emit numFlagsChanged();
+}
+/////////////////////////////////////////////////////////
+
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ bool frameless = false;
+
+ int width = 370;
+ int height = 480;
+
+ for (int i = 1; i < argc; ++i) {
+ QString arg = argv[i];
+ if (arg == "-frameless") {
+ frameless = true;
+ } else if(arg == "-width" && i < (argc - 1)) {
+ ++i;
+ width = ::atoi(argv[i]);
+ } else if(arg == "-height" && i < (argc - 1)) {
+ ++i;
+ height = ::atoi(argv[i]);
+ } else if (arg[0] != '-') {
+ fileName = arg;
+ }
+ }
+
+ MyWidget wid(width, height, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget);
+ wid.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/declarative/minehunt/minehunt.pro b/examples/declarative/minehunt/minehunt.pro
new file mode 100644
index 0000000..01791b1
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.pro
@@ -0,0 +1,9 @@
+SOURCES = main.cpp
+
+QT += script declarative
+contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl
+
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/minehunt
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS minehunt.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/minehunt
+INSTALLS += target sources
diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml
new file mode 100644
index 0000000..4bae64d
--- /dev/null
+++ b/examples/declarative/minehunt/minehunt.qml
@@ -0,0 +1,187 @@
+import Qt 4.6
+
+Item {
+ id: field
+ width: 370
+ height: 480
+
+ property int clickx : 0
+ property int clicky : 0
+
+ resources: [
+ Component {
+ id: tile
+ Flipable {
+ id: flipable
+ width: 40
+ height: 40
+ property int angle: 0;
+ 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.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ source: "pics/flag.png"
+ opacity: modelData.hasFlag
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+ }
+ back: Image {
+ source: "pics/back.png"
+ width: 40
+ height: 40
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ text: modelData.hint
+ color: "white"
+ font.bold: true
+ opacity: !modelData.hasMine && modelData.hint > 0
+ }
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ source: "pics/bomb.png"
+ opacity: modelData.hasMine
+ }
+ Explosion {
+ id: expl
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ //explode: modelData.hasMine && modelData.flipped//Doesn't wait for the pause
+ }
+ }
+ states: [
+ State {
+ name: "back"
+ when: modelData.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+ ]
+ transitions: [
+ Transition {
+ SequentialAnimation {
+ PauseAnimation {
+ duration: {
+ var ret = Math.abs(flipable.parent.x-field.clickx)
+ + Math.abs(flipable.parent.y-field.clicky);
+ if (ret > 0) {
+ if (modelData.hasMine && modelData.flipped) {
+ ret*3
+ } else {
+ ret
+ }
+ } else {
+ 0
+ }
+ }
+ }
+ NumberAnimation {
+ easing: "easeInOutQuad"
+ properties: "angle"
+ }
+ ScriptAction{
+ script: if(modelData.hasMine && modelData.flipped)
+ {expl.explode = true;}
+ }
+ }
+ }
+ ]
+ MouseRegion {
+ anchors.fill: parent
+ onPressed: {
+ field.clickx = flipable.parent.x;
+ field.clicky = flipable.parent.y;
+ row = Math.floor(index/9);
+ col = index - (Math.floor(index/9) * 9);
+ if (mouse.button==undefined || mouse.button==Qt.RightButton) {
+ flag(row,col);
+ } else {
+ flip(row,col);
+ }
+ }
+ }
+ }
+ }
+ ]
+ Image {
+ source: "pics/No-Ones-Laughing-3.jpg"
+ fillMode: "Tile"
+ }
+ Description {
+ text: "Use the 'minehunt' executable to run this demo!"
+ width: 300
+ opacity: tiles?0:1
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ Repeater {
+ model: tiles
+ x: 1
+ y: 1
+ Component {
+ ComponentInstance {
+ component: tile
+ x: (index - (Math.floor(index/9) * 9)) * 41
+ y: Math.floor(index/9) * 41
+ }
+ }
+ }
+ Item {
+ id: gamedata
+ width: 370
+ height: 100
+ y: 380
+ Text {
+ color: "white"
+ font.pointSize: 18
+ x: 20
+ y: 20
+ }
+ Image {
+ x: 100
+ y: 20
+ source: "pics/bomb-color.png"
+ }
+ Text {
+ x: 100
+ y: 60
+ color: "white"
+ text: numMines
+ }
+ Image {
+ x: 140
+ y: 20
+ source: "pics/flag-color.png"
+ }
+ Text {
+ x: 140
+ y: 60
+ color: "white"
+ text: numFlags
+ }
+ Image {
+ x: 280
+ y: 10
+ source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png'
+ MouseRegion {
+ anchors.fill: parent
+ onPressed: { reset() }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg b/examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg
new file mode 100644
index 0000000..445567f
--- /dev/null
+++ b/examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg
Binary files differ
diff --git a/examples/declarative/minehunt/pics/back.png b/examples/declarative/minehunt/pics/back.png
new file mode 100644
index 0000000..f6b3f0b
--- /dev/null
+++ b/examples/declarative/minehunt/pics/back.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/bomb-color.png b/examples/declarative/minehunt/pics/bomb-color.png
new file mode 100644
index 0000000..61ad0a9
--- /dev/null
+++ b/examples/declarative/minehunt/pics/bomb-color.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/bomb.png b/examples/declarative/minehunt/pics/bomb.png
new file mode 100644
index 0000000..a992575
--- /dev/null
+++ b/examples/declarative/minehunt/pics/bomb.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/face-sad.png b/examples/declarative/minehunt/pics/face-sad.png
new file mode 100644
index 0000000..cf00aaf
--- /dev/null
+++ b/examples/declarative/minehunt/pics/face-sad.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/face-smile-big.png b/examples/declarative/minehunt/pics/face-smile-big.png
new file mode 100644
index 0000000..f9c2335
--- /dev/null
+++ b/examples/declarative/minehunt/pics/face-smile-big.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/face-smile.png b/examples/declarative/minehunt/pics/face-smile.png
new file mode 100644
index 0000000..3d66d72
--- /dev/null
+++ b/examples/declarative/minehunt/pics/face-smile.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/flag-color.png b/examples/declarative/minehunt/pics/flag-color.png
new file mode 100644
index 0000000..aadad0f
--- /dev/null
+++ b/examples/declarative/minehunt/pics/flag-color.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/flag.png b/examples/declarative/minehunt/pics/flag.png
new file mode 100644
index 0000000..39cde4d
--- /dev/null
+++ b/examples/declarative/minehunt/pics/flag.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/front.png b/examples/declarative/minehunt/pics/front.png
new file mode 100644
index 0000000..834331b
--- /dev/null
+++ b/examples/declarative/minehunt/pics/front.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/star.png b/examples/declarative/minehunt/pics/star.png
new file mode 100644
index 0000000..3772359
--- /dev/null
+++ b/examples/declarative/minehunt/pics/star.png
Binary files differ
diff --git a/examples/declarative/modules/builtin-version.qml b/examples/declarative/modules/builtin-version.qml
new file mode 100644
index 0000000..4aa63be
--- /dev/null
+++ b/examples/declarative/modules/builtin-version.qml
@@ -0,0 +1,3 @@
+import Qt 4.6
+
+Rectangle {}
diff --git a/examples/declarative/modules/installed-qualified.qml b/examples/declarative/modules/installed-qualified.qml
new file mode 100644
index 0000000..3d40794
--- /dev/null
+++ b/examples/declarative/modules/installed-qualified.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+import com.nokia.Foo as F
+Item {
+ F.Bar { }
+}
diff --git a/examples/declarative/modules/installed-version.qml b/examples/declarative/modules/installed-version.qml
new file mode 100644
index 0000000..d90375dd
--- /dev/null
+++ b/examples/declarative/modules/installed-version.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+import com.nokia.Foo 1.6
+import com.nokia.Foo 1.7 as NewFoo
+Column {
+ Bar { }
+ Baz { }
+ NewFoo.Bar { }
+}
diff --git a/examples/declarative/modules/installed.qml b/examples/declarative/modules/installed.qml
new file mode 100644
index 0000000..a28fd10
--- /dev/null
+++ b/examples/declarative/modules/installed.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+import com.nokia.Foo
+Foo.Bar { }
diff --git a/examples/declarative/modules/lib/com/nokia/Foo/Bar.qml b/examples/declarative/modules/lib/com/nokia/Foo/Bar.qml
new file mode 100644
index 0000000..270cd46
--- /dev/null
+++ b/examples/declarative/modules/lib/com/nokia/Foo/Bar.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+Text {
+ text: "lib/com/nokia/Foo/Bar.qml"
+ color: "green"
+}
diff --git a/examples/declarative/modules/lib/com/nokia/Foo/Bar17.qml b/examples/declarative/modules/lib/com/nokia/Foo/Bar17.qml
new file mode 100644
index 0000000..f93fc62
--- /dev/null
+++ b/examples/declarative/modules/lib/com/nokia/Foo/Bar17.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+Text {
+ text: "lib/com/nokia/Foo/Bar17.qml"
+ color: "white"
+}
diff --git a/examples/declarative/modules/lib/com/nokia/Foo/Baz.qml b/examples/declarative/modules/lib/com/nokia/Foo/Baz.qml
new file mode 100644
index 0000000..4daa37f
--- /dev/null
+++ b/examples/declarative/modules/lib/com/nokia/Foo/Baz.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+Text {
+ text: "lib/com/nokia/Foo/Baz.qml"
+ color: "red"
+}
diff --git a/examples/declarative/modules/lib/com/nokia/Foo/qmldir b/examples/declarative/modules/lib/com/nokia/Foo/qmldir
new file mode 100644
index 0000000..b8111cb
--- /dev/null
+++ b/examples/declarative/modules/lib/com/nokia/Foo/qmldir
@@ -0,0 +1,6 @@
+# Baz was introduced in Foo 1.6
+# Bar 1.5 and 1.6 are the same, but in 1.7 it is reimplemented.
+Bar 1.5 Bar.qml
+Bar 1.6 Bar.qml
+Bar 1.7 Bar17.qml
+Baz 1.6 Baz.qml
diff --git a/examples/declarative/modules/local-qualified.qml b/examples/declarative/modules/local-qualified.qml
new file mode 100644
index 0000000..d3532af
--- /dev/null
+++ b/examples/declarative/modules/local-qualified.qml
@@ -0,0 +1,9 @@
+import Qt 4.6
+
+import "local" as X
+import "local/SubLib" as Y
+
+Column {
+ X.Foo { }
+ Y.Bar { }
+}
diff --git a/examples/declarative/modules/local.qml b/examples/declarative/modules/local.qml
new file mode 100644
index 0000000..c90bde3
--- /dev/null
+++ b/examples/declarative/modules/local.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+import "local"
+Foo { }
diff --git a/examples/declarative/modules/remote-qualified.qml b/examples/declarative/modules/remote-qualified.qml
new file mode 100644
index 0000000..581c868
--- /dev/null
+++ b/examples/declarative/modules/remote-qualified.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+import "http://qml.nokia.com/Clock.zip"
+Item {
+ Clock.Hand { ... }
+}
diff --git a/examples/declarative/modules/remote-zipped.qml b/examples/declarative/modules/remote-zipped.qml
new file mode 100644
index 0000000..d325b65
--- /dev/null
+++ b/examples/declarative/modules/remote-zipped.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+import "http://qml.nokia.com/Clock.zip"
+Item {
+ Clock { ... }
+}
diff --git a/examples/declarative/modules/wrong-installed-version.qml b/examples/declarative/modules/wrong-installed-version.qml
new file mode 100644
index 0000000..4442b11
--- /dev/null
+++ b/examples/declarative/modules/wrong-installed-version.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+import com.nokia.Foo 1.5
+Baz { } // Not available in 1.5, only 1.6!
diff --git a/examples/declarative/modules/wrong-installed.qml b/examples/declarative/modules/wrong-installed.qml
new file mode 100644
index 0000000..317c05c
--- /dev/null
+++ b/examples/declarative/modules/wrong-installed.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+import com.nokia.NonExistent
+
+Rectangle {}
diff --git a/examples/declarative/modules/wrong-local-qualified.qml b/examples/declarative/modules/wrong-local-qualified.qml
new file mode 100644
index 0000000..868bebf
--- /dev/null
+++ b/examples/declarative/modules/wrong-local-qualified.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+import "local" as X
+
+// WRONG: if imported qualified, must qualify
+Foo { }
diff --git a/examples/declarative/modules/wrong-local.qml b/examples/declarative/modules/wrong-local.qml
new file mode 100644
index 0000000..1958659
--- /dev/null
+++ b/examples/declarative/modules/wrong-local.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+import "local"
+
+// WRONG - cannot use qualification to access "local sublibraries".
+// (would have to import lib.SubLib)
+SubLib.Bar {
+}
diff --git a/examples/declarative/modules/zipped-qualified.qml b/examples/declarative/modules/zipped-qualified.qml
new file mode 100644
index 0000000..56e329f
--- /dev/null
+++ b/examples/declarative/modules/zipped-qualified.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+// Not currently supported
+import "zips/ClockPack.zip" as CP
+Item {
+ CP.Clock { ... }
+}
diff --git a/examples/declarative/modules/zipped.qml b/examples/declarative/modules/zipped.qml
new file mode 100644
index 0000000..4464616
--- /dev/null
+++ b/examples/declarative/modules/zipped.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+// Not currently supported
+import "zips/ClockPack.zip"
+Item {
+ Clock { ... }
+}
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml
new file mode 100644
index 0000000..91f3b6e
--- /dev/null
+++ b/examples/declarative/mouseregion/mouse.qml
@@ -0,0 +1,40 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 200; height: 200
+ Rectangle {
+ width: 50; height: 50
+ color: "red"
+ Text { text: "Click"; anchors.centerIn: parent }
+ MouseRegion {
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
+ onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') }
+ onPressAndHold: { print('press and hold') }
+ onEntered: { print('entered ' + pressed) }
+ onExited: { print('exited ' + pressed) }
+ anchors.fill: parent
+ }
+ }
+ Rectangle {
+ y: 100; width: 50; height: 50
+ color: "blue"
+ Text { text: "Drag"; anchors.centerIn: parent }
+ MouseRegion {
+ drag.target: parent
+ drag.axis: "XAxis"
+ drag.minimumX: 0
+ drag.maximumX: 150
+ onPressed: { print('press') }
+ onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { print('double click') }
+ onPressAndHold: { print('press and hold') }
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml
new file mode 100644
index 0000000..c1c4a4f
--- /dev/null
+++ b/examples/declarative/scrollbar/ScrollBar.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+
+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 var position
+ property var pageSize
+ property var orientation : "Vertical"
+
+ // 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 {
+ 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/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml
new file mode 100644
index 0000000..48cceb7
--- /dev/null
+++ b/examples/declarative/scrollbar/display.qml
@@ -0,0 +1,59 @@
+import Qt 4.6
+
+Rectangle {
+ width: 640
+ height: 480
+ // Create a flickable to view a large image.
+ Flickable {
+ id: View
+ anchors.fill: parent
+ Image {
+ id: Picture
+ source: "pics/niagara_falls.jpg"
+ }
+ viewportWidth: Picture.width
+ viewportHeight: Picture.height
+ // Only show the scrollbars when the view is moving.
+ states: [
+ State {
+ name: "ShowBars"
+ when: View.moving
+ PropertyChanges { target: SBV; opacity: 1 }
+ PropertyChanges { target: SBH; opacity: 1 }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ duration: 400
+ }
+ }
+ ]
+ }
+ // Attach scrollbars to the right and bottom edges of the view.
+ ScrollBar {
+ id: SBV
+ opacity: 0
+ orientation: "Vertical"
+ position: View.pageYPosition
+ pageSize: View.pageHeight
+ width: 12
+ height: View.height-12
+ anchors.right: View.right
+ }
+ /*
+ ScrollBar {
+ id: SBH
+ opacity: 0
+ orientation: "Horizontal"
+ position: View.pageXPosition
+ pageSize: View.pageWidth
+ height: 12
+ width: View.width-12
+ anchors.bottom: View.bottom
+ }
+ */
+}
diff --git a/examples/declarative/scrollbar/pics/niagara_falls.jpg b/examples/declarative/scrollbar/pics/niagara_falls.jpg
new file mode 100644
index 0000000..618d808
--- /dev/null
+++ b/examples/declarative/scrollbar/pics/niagara_falls.jpg
Binary files differ
diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml
new file mode 100644
index 0000000..a778c1a
--- /dev/null
+++ b/examples/declarative/slideswitch/Switch.qml
@@ -0,0 +1,58 @@
+import Qt 4.6
+
+Item {
+ id: Switch
+ width: Groove.width; height: Groove.height
+
+ property var on
+
+ Script {
+
+ function toggle() {
+ if(Switch.state == "On")
+ Switch.state = "Off";
+ else
+ Switch.state = "On";
+ }
+ function dorelease() {
+ if(Knob.x == 1) {
+ if(Switch.state == "Off")
+ return;
+ }
+
+ if(Knob.x == 78) {
+ if(Switch.state == "On")
+ return;
+ }
+
+ toggle();
+ }
+
+ }
+ Image { id: Groove; source: "background.svg" }
+ MouseRegion { anchors.fill: Groove; onClicked: { toggle() } }
+ Image { id: Knob; source: "knob.svg"; x: 1; y: 2 }
+ MouseRegion {
+ anchors.fill: Knob
+ onClicked: { toggle() }
+ onReleased: { dorelease() }
+ drag.target: Knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
+ }
+ states: [
+ State {
+ name: "On"
+ PropertyChanges { target: Knob; x: 78 }
+ PropertyChanges { target: Switch; on: true }
+ },
+ State {
+ name: "Off"
+ PropertyChanges { target: Knob; x: 1 }
+ PropertyChanges { target: Switch; on: false }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 }
+ }
+ ]
+}
diff --git a/examples/declarative/slideswitch/background.svg b/examples/declarative/slideswitch/background.svg
new file mode 100644
index 0000000..f920d3e
--- /dev/null
+++ b/examples/declarative/slideswitch/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/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/display.qml
new file mode 100644
index 0000000..346ffb1
--- /dev/null
+++ b/examples/declarative/slideswitch/display.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 150
+ height: 150
+ Switch {
+ anchors.centerIn: parent
+ }
+}
diff --git a/examples/declarative/slideswitch/knob.svg b/examples/declarative/slideswitch/knob.svg
new file mode 100644
index 0000000..fb69337
--- /dev/null
+++ b/examples/declarative/slideswitch/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/declarative/smooth/GradientRect.qml b/examples/declarative/smooth/GradientRect.qml
new file mode 100644
index 0000000..c4a287c
--- /dev/null
+++ b/examples/declarative/smooth/GradientRect.qml
@@ -0,0 +1,25 @@
+import Qt 4.6
+
+Item {
+ id: MyRect
+ property string color
+ property string border : ""
+ property int rotation
+ property int radius
+ property int borderWidth
+ property bool smooth: false
+
+ width: 80; height: 80
+ Item {
+ anchors.centerIn: parent; rotation: MyRect.rotation;
+ Rectangle {
+ anchors.centerIn: parent; width: 80; height: 80
+ border.color: MyRect.border; border.width: MyRect.border != "" ? 2 : 0
+ radius: MyRect.radius; smooth: MyRect.smooth
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: MyRect.color }
+ GradientStop { position: 1.0; color: "white" }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/smooth/MyRect.qml b/examples/declarative/smooth/MyRect.qml
new file mode 100644
index 0000000..3b68307
--- /dev/null
+++ b/examples/declarative/smooth/MyRect.qml
@@ -0,0 +1,21 @@
+import Qt 4.6
+
+Item {
+ id: MyRect
+ property string color
+ property string border : ""
+ property int rotation
+ property int radius
+ property int borderWidth
+ property bool smooth: false
+
+ width: 80; height: 80
+ Item {
+ anchors.centerIn: parent; rotation: MyRect.rotation;
+ Rectangle {
+ anchors.centerIn: parent; width: 80; height: 80
+ color: MyRect.color; border.color: MyRect.border; border.width: MyRect.border != "" ? 2 : 0
+ radius: MyRect.radius; smooth: MyRect.smooth
+ }
+ }
+}
diff --git a/examples/declarative/smooth/rect-painting.qml b/examples/declarative/smooth/rect-painting.qml
new file mode 100644
index 0000000..4b6e223
--- /dev/null
+++ b/examples/declarative/smooth/rect-painting.qml
@@ -0,0 +1,64 @@
+import Qt 4.6
+
+Rectangle {
+ width: 900; height: 500
+ color: "white"
+
+ Rectangle {
+ anchors.top: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ color: "#eeeeee"
+ }
+
+ Grid {
+ anchors.centerIn: parent
+ columns: 8; rows:4; spacing: 30
+
+ MyRect { color: "lightsteelblue" }
+ MyRect { color: "lightsteelblue"; border: "gray" }
+ MyRect { color: "lightsteelblue"; radius: 10 }
+ MyRect { color: "lightsteelblue"; radius: 10; border: "gray" }
+ GradientRect { color: "lightsteelblue" }
+ GradientRect { color: "lightsteelblue"; border: "gray" }
+ GradientRect { color: "lightsteelblue"; radius: 10 }
+ GradientRect { color: "lightsteelblue"; radius: 10; border: "gray" }
+
+ MyRect { color: "thistle"; rotation: 10 }
+ MyRect { color: "thistle"; border: "gray"; rotation: 10 }
+ MyRect { color: "thistle"; radius: 10; rotation: 10 }
+ MyRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10 }
+ GradientRect { color: "thistle"; rotation: 10 }
+ GradientRect { color: "thistle"; border: "gray"; rotation: 10 }
+ GradientRect { color: "thistle"; radius: 10; rotation: 10 }
+ GradientRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10 }
+
+ MyRect { color: "lightsteelblue"; smooth: true }
+ MyRect { color: "lightsteelblue"; border: "gray"; smooth: true }
+ MyRect { color: "lightsteelblue"; radius: 10; smooth: true }
+ MyRect { color: "lightsteelblue"; radius: 10; border: "gray"; smooth: true }
+ GradientRect { color: "lightsteelblue"; smooth: true }
+ GradientRect { color: "lightsteelblue"; border: "gray"; smooth: true }
+ GradientRect { color: "lightsteelblue"; radius: 10; smooth: true }
+ GradientRect { color: "lightsteelblue"; radius: 10; border: "gray"; smooth: true }
+
+ MyRect { color: "thistle"; rotation: 10; smooth: true }
+ MyRect { color: "thistle"; border: "gray"; rotation: 10; smooth: true }
+ MyRect { color: "thistle"; radius: 10; rotation: 10; smooth: true }
+ MyRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10; smooth: true }
+ GradientRect { color: "thistle"; rotation: 10; smooth: true }
+ GradientRect { color: "thistle"; border: "gray"; rotation: 10; smooth: true }
+ GradientRect { color: "thistle"; radius: 10; rotation: 10; smooth: true }
+ GradientRect { color: "thistle"; radius: 10; border: "gray"; rotation: 10; smooth: true }
+ }
+
+ Text {
+ text: "smooth: false"; font.bold: true
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.top
+ }
+ Text {
+ text: "smooth: true"; font.bold: true
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml
new file mode 100644
index 0000000..021cef3
--- /dev/null
+++ b/examples/declarative/snow/ImageBatch.qml
@@ -0,0 +1,72 @@
+import Qt 4.6
+
+GridView {
+ id: MyGrid
+ property int offset: 0
+ property var ref
+ property bool isSelected: ref.selectedItemColumn >= offset && ref.selectedItemColumn < offset + 5
+
+ currentIndex: (ref.selectedItemColumn - offset) + ref.selectedItemRow * 5
+
+ property int imageWidth: ref.imageWidth
+ property int imageHeight: ref.imageHeight
+
+ width: 5 * imageWidth
+ height: 4 * imageHeight
+ cellWidth: imageWidth
+ cellHeight: imageHeight
+
+ states: State {
+ name: "selected"; when: MyGrid.isSelected
+ PropertyChanges { target: MyGrid; z: 150 }
+ }
+ transitions: Transition {
+ SequentialAnimation {
+ PauseAnimation { duration: 150 }
+ PropertyAction { properties: "z" }
+ }
+ }
+ model: XmlListModel {
+ property string tags : ""
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2"
+ query: "/rss/channel/item"
+ namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
+
+ XmlRole { name: "url"; query: "media:content/@url/string()" }
+ }
+
+ Item {
+ id: Root
+ property bool isSelected: GridView.isCurrentItem && MyGrid.isSelected
+ transformOrigin: "Center"
+ width: MyGrid.imageWidth; height: MyGrid.imageHeight;
+
+ Image { id: Image; source: url; fillMode: "PreserveAspectFit"; smooth: true; anchors.fill: parent;
+ opacity: (status == 1)?1:0; opacity: Behavior { NumberAnimation { properties: "opacity" } } }
+ Loading { anchors.centerIn: parent; visible: Image.status!=1 }
+
+ states: State {
+ name: "selected"
+ when: Root.isSelected
+ PropertyChanges { target: Root; scale: 3; z: 100 }
+ }
+ transitions: [
+ Transition {
+ to: "selected"
+ SequentialAnimation {
+ PauseAnimation { duration: 150 }
+ PropertyAction { properties: "z" }
+ NumberAnimation { properties: "scale"; duration: 150; }
+ }
+ },
+ Transition {
+ from: "selected"
+ SequentialAnimation {
+ NumberAnimation { properties: "scale"; duration: 150 }
+ PropertyAction { properties: "z" }
+ }
+ }
+ ]
+ }
+}
+
diff --git a/examples/declarative/snow/Loading.qml b/examples/declarative/snow/Loading.qml
new file mode 100644
index 0000000..ff2c829
--- /dev/null
+++ b/examples/declarative/snow/Loading.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+Image {
+ id: Loading; source: "pics/loading.png"; transformOrigin: "Center"
+ rotation: NumberAnimation {
+ id: "RotationAnimation"; from: 0; to: 360; running: Loading.visible == true; repeat: true; duration: 900
+ }
+}
diff --git a/examples/declarative/snow/create.js b/examples/declarative/snow/create.js
new file mode 100644
index 0000000..9def7a7
--- /dev/null
+++ b/examples/declarative/snow/create.js
@@ -0,0 +1,12 @@
+var myComponent = null;
+
+function createNewBlock() {
+ if (myComponent == null)
+ myComponent = createComponent("ImageBatch.qml");
+
+ var obj = myComponent.createObject();
+ obj.parent = MyLayout;
+ obj.offset = maximumColumn + 1;
+ obj.ref = ImagePanel;
+ maximumColumn += 5;
+}
diff --git a/examples/declarative/snow/pics/loading.png b/examples/declarative/snow/pics/loading.png
new file mode 100644
index 0000000..0296cfe
--- /dev/null
+++ b/examples/declarative/snow/pics/loading.png
Binary files differ
diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml
new file mode 100644
index 0000000..b6781c3
--- /dev/null
+++ b/examples/declarative/snow/snow.qml
@@ -0,0 +1,69 @@
+import Qt 4.6
+
+Rectangle {
+ id: ImagePanel
+ width: 1024
+ height: 768
+ color: "black"
+
+ property int maximumColumn: 4
+ property int selectedItemRow: 0
+ property int selectedItemColumn: 0
+
+ Script { source: "create.js" }
+
+ onSelectedItemColumnChanged: if (selectedItemColumn == maximumColumn) createNewBlock();
+
+ property int imageWidth: 200
+ property int imageHeight: 200
+
+ property int selectedX: selectedItemColumn * imageWidth
+ property int selectedY: selectedItemRow * imageHeight
+
+ Item {
+ anchors.centerIn: parent
+ Row {
+ id: MyLayout
+ property real targetX: -(selectedX + imageWidth / 2)
+
+ property real targetDeform: 0
+ property bool slowDeform: true
+
+ property real deform: 0
+ deform: Follow {
+ id: "DeformFollow"; source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2
+ onSyncChanged: if(inSync) { MyLayout.slowDeform = true; MyLayout.targetDeform = 0; }
+ }
+
+ ImageBatch { offset: 0; ref: ImagePanel }
+
+ x: Follow { source: MyLayout.targetX; velocity: 1000 }
+ y: Follow { source: -(selectedY + imageHeight / 2); velocity: 500 }
+ }
+
+ transform: Rotation {
+ axis.y: 1; axis.z: 0
+ angle: MyLayout.deform * -100
+ }
+ }
+
+ Script {
+ function left() {
+ if (selectedItemColumn <= 0) return;
+ selectedItemColumn -= 1;
+ MyLayout.slowDeform = false;
+ MyLayout.targetDeform = Math.max(Math.min(MyLayout.deform - 0.1, -0.1), -0.4);
+ }
+ function right() {
+ selectedItemColumn += 1;
+ MyLayout.slowDeform = false;
+ MyLayout.targetDeform = Math.min(Math.max(MyLayout.deform + 0.1, 0.1), 0.4);
+ }
+ }
+
+ focus: true
+ Keys.onLeftPressed: "left()"
+ Keys.onRightPressed: "right()"
+ Keys.onUpPressed: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1"
+ Keys.onDownPressed: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1"
+}
diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml
new file mode 100644
index 0000000..d91b558
--- /dev/null
+++ b/examples/declarative/states/states.qml
@@ -0,0 +1,48 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ width: 300; height: 300; color: "white"
+ // A target region. Clicking in here sets the state to '' - the default state
+ Rectangle {
+ x: 0; y: 0; width: 50; height: 50
+ color: "transparent"; border.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='' } }
+ }
+ // Another target region. Clicking in here sets the state to 'Position1'
+ Rectangle {
+ x: 150; y: 50; width: 50; height: 50
+ color: "transparent"; border.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position1' } }
+ }
+ // Another target region. Clicking in here sets the state to 'Position2'
+ Rectangle {
+ x: 0; y: 200; width: 50; height: 50
+ color: "transparent"; border.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position2' } }
+ }
+ // Rect which will be moved when my state changes
+ Rectangle { id: myrect; width: 50; height: 50; color: "red" }
+
+ states: [
+ // In state 'Position1', change the 'myrect' item x, y to 150, 50.
+ State {
+ name: "Position1"
+ PropertyChanges {
+ target: myrect
+ x: 150
+ y: 50
+ }
+ },
+ // In state 'Position2', change y to 100. We do not specify 'x' here -
+ // it will therefore be restored to its default value of 0, if it
+ // had been changed.
+ State {
+ name: "Position2"
+ PropertyChanges {
+ target: myrect
+ y: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml
new file mode 100644
index 0000000..be1419d
--- /dev/null
+++ b/examples/declarative/states/transitions.qml
@@ -0,0 +1,68 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ width: 300; height: 300; color: "white"
+ // A target region. Clicking in here sets the state to '' - the default state
+ Rectangle {
+ x: 0; y: 0; width: 50; height: 50
+ color: "transparent"; border.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='' } }
+ }
+ // Another target region. Clicking in here sets the state to 'Position1'
+ Rectangle {
+ x: 150; y: 50; width: 50; height: 50
+ color: "transparent"; border.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position1' } }
+ }
+ // Another target region. Clicking in here sets the state to 'Position2'
+ Rectangle {
+ x: 0; y: 200; width: 50; height: 50
+ color: "transparent"; border.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position2' } }
+ }
+ // Rect which will be moved when my state changes
+ Rectangle { id: myrect; width: 50; height: 50; color: "red" }
+
+ states: [
+ // In state 'Position1', change the 'myrect' item x, y to 150, 50.
+ State {
+ name: "Position1"
+ PropertyChanges {
+ target: myrect
+ x: 150
+ y: 50
+ }
+ },
+ // In state 'Position2', change y to 100. We do not specify 'x' here -
+ // it will therefore be restored to its default value of 0, if it
+ // had been changed.
+ State {
+ name: "Position2"
+ PropertyChanges {
+ target: myrect
+ y: 200
+ }
+ }
+ ]
+
+ // transitions define how the properties change.
+ transitions: [
+ // When transitioning to 'Position1' move x,y over a duration of 1 second,
+ // with easeOutBounce easing function.
+ Transition {
+ from: "*"; to: "Position1"
+ NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 }
+ },
+ // When transitioning to 'Position2' move x,y over a duration of 2 seconds,
+ // with easeInOutQuad easing function.
+ Transition {
+ from: "*"; to: "Position2"
+ NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; 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/declarative/support/contact.cpp b/examples/declarative/support/contact.cpp
new file mode 100644
index 0000000..0821295
--- /dev/null
+++ b/examples/declarative/support/contact.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#include "contact.h"
+#include "qmltypes.h"
+
+QML_DEFINE_TYPE(0,0,0,0,Contact,Contact);
+Contact::Contact() : QObject(0)
+{
+ m_firstName = "John";
+ m_lastName = "Smith";
+ m_portraitFile = "contact.png";
+ m_company = "Trollkia";
+ m_emails << "smith@trollkia.com" << "john45@gmail.com";
+
+ m_numbers << new PhoneNumber;
+ m_numbers << new PhoneNumber;
+ m_numbers << new PhoneNumber;
+
+ m_numbers.at(0)->setType(PhoneNumber::HomePhone);
+ m_numbers.at(0)->setNumber("35412451");
+
+ m_numbers.at(1)->setType(PhoneNumber::BusinessPhone);
+ m_numbers.at(1)->setNumber("33424994");
+
+ m_numbers.at(2)->setType(PhoneNumber::MobilePhone);
+ m_numbers.at(2)->setNumber("0424655137");
+
+ m_addresses << new Address;
+ m_addresses << new Address;
+ m_addresses << new Address;
+ m_addresses.at(0)->setNumber(13);
+ m_addresses.at(0)->setStreet("Blackhill Cr");
+ m_addresses.at(0)->setCountry("Australia");
+ m_addresses.at(1)->setNumber(116);
+ m_addresses.at(1)->setStreet("Sandankerveien");
+ m_addresses.at(1)->setCountry("Norway");
+ m_addresses.at(2)->setNumber(92);
+ m_addresses.at(2)->setStreet("Elizibeth St");
+ m_addresses.at(2)->setCountry("Australia");
+}
+
+void Contact::addNumber(PhoneNumber *newNumber)
+{
+
+ m_numbers << newNumber;
+ emit numbersChanged();
+}
+
+void Contact::addAddress(Address *newAddress)
+{
+ m_addresses << newAddress;
+ emit addressesChanged();
+}
+
+void Contact::addEmail(QString &newEmail)
+{
+
+ m_emails << newEmail;
+ emit emailsChanged();
+}
+
+QML_DEFINE_TYPE(0,0,0,0,Address,Address);
+Address::Address()
+: _number(0)
+{
+}
+
+QML_DEFINE_TYPE(0,0,0,0,PhoneNumber, PhoneNumber);
+PhoneNumber::PhoneNumber()
+: _type(HomePhone)
+{
+}
diff --git a/examples/declarative/support/contact.h b/examples/declarative/support/contact.h
new file mode 100644
index 0000000..c403f8b
--- /dev/null
+++ b/examples/declarative/support/contact.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#ifndef CONTACT_H
+#define CONTACT_H
+
+#include <qml.h>
+#include <QtGui>
+
+
+class Address : public QObject
+{
+ Q_OBJECT
+public:
+ Address();
+
+ Q_PROPERTY(int number READ number WRITE setNumber NOTIFY changed);
+ Q_PROPERTY(QString street READ street WRITE setStreet NOTIFY changed);
+ Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY changed);
+
+ int number() const { return _number; }
+ void setNumber(int n) { _number = n; emit changed(); }
+
+ QString street() const { return _street; }
+ void setStreet(const QString &s) { _street = s; emit changed(); }
+
+ QString country() const { return _country; }
+ void setCountry(const QString &c) { _country = c; emit changed(); }
+
+signals:
+ void changed();
+
+private:
+ int _number;
+ QString _street;
+ QString _country;
+};
+QML_DECLARE_TYPE(Address);
+
+class PhoneNumber : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(PhoneType)
+public:
+ PhoneNumber();
+
+ enum PhoneType {
+ HomePhone,
+ BusinessPhone,
+ MobilePhone
+ };
+
+ Q_PROPERTY(QString number READ number WRITE setNumber NOTIFY changed);
+ Q_PROPERTY(PhoneType type READ type WRITE setType NOTIFY changed);
+
+ QString number() const { return _number; }
+ void setNumber(QString n) { _number = n; emit changed(); }
+
+ PhoneType type() const { return _type; }
+ void setType(PhoneType type) { _type = type; emit changed(); }
+
+signals:
+ void changed();
+
+private:
+ QString _number;
+ PhoneType _type;
+};
+QML_DECLARE_TYPE(PhoneNumber);
+
+class Contact : public QObject
+{
+ Q_OBJECT
+public:
+ Contact();
+
+ Q_PROPERTY(QString firstName READ firstName WRITE setFirstName NOTIFY nameChanged);
+ QString firstName() const { return m_firstName; }
+
+ Q_PROPERTY(QString lastName READ lastName WRITE setLastName NOTIFY nameChanged);
+ QString lastName() const { return m_lastName; }
+
+ Q_PROPERTY(QString portraitFile READ portraitFile WRITE setPortraitFile NOTIFY portraitChanged);
+ QString portraitFile() const { return m_portraitFile; }
+
+ Q_PROPERTY(QString company READ company WRITE setCompany NOTIFY companyChanged);
+ QString company() const { return m_company; }
+
+ Q_PROPERTY(QStringList emails READ emails WRITE setEmails NOTIFY emailsChanged);
+ QStringList emails() const { return m_emails; }
+
+ Q_PROPERTY(QList<Address *>* addresses READ addresses);
+ QList<Address *>* addresses() { return &m_addresses; }
+
+ Q_PROPERTY(QList<PhoneNumber *>* numbers READ numbers);
+ QList<PhoneNumber *>* numbers() { return &m_numbers; }
+
+
+ void addEmail(QString&);
+ void addAddress(Address*);
+ void addNumber(PhoneNumber*);
+
+public slots:
+ void setFirstName(const QString &name) { m_firstName = name; emit nameChanged(); }
+ void setLastName(const QString &name) { m_lastName = name; emit nameChanged(); }
+ void setPortraitFile(const QString &portraitFile) { m_portraitFile = portraitFile; emit portraitChanged(); }
+ void setCompany(const QString &company) { m_company = company; emit companyChanged(); }
+ void setEmails(const QStringList &emails) { m_emails = emails; emit emailsChanged(); }
+
+signals:
+ void nameChanged();
+ void portraitChanged();
+ void companyChanged();
+ void emailsChanged();
+ void numbersChanged();
+ void addressesChanged();
+
+private:
+ QString m_firstName;
+ QString m_lastName;
+ QString m_portraitFile;
+
+ QString m_company;
+
+ QList<Address *> m_addresses;
+ QList<PhoneNumber *>m_numbers;
+ QStringList m_emails;
+};
+QML_DECLARE_TYPE(Contact);
+
+#endif
diff --git a/examples/declarative/support/contactmodel.cpp b/examples/declarative/support/contactmodel.cpp
new file mode 100644
index 0000000..efe108fb
--- /dev/null
+++ b/examples/declarative/support/contactmodel.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#include "contactmodel.h"
+#include "qmltypes.h"
+
+ContactModel::ContactModel(QObject *parent) : QListModelInterface(parent)
+{
+ QFile f("../contacts/contacts.txt");
+ f.open(QIODevice::ReadOnly);
+ QTextStream ts(&f);
+ QString text = ts.readLine();
+ while(!text.isEmpty()) {
+ Contact *c = new Contact;
+ QStringList list = text.split(" ");
+ c->setFirstName(list[0]);
+ c->setLastName(list[1]);
+ for (int i = 2; i < list.count(); ++i)
+ c->addEmail(list[i]);
+ //contactList.append(c);
+ insertContact(c);
+
+ text = ts.readLine();
+ }
+ f.close();
+}
+
+ContactModel::~ContactModel()
+{
+ while (!contactList.isEmpty()) {
+ Contact *c = contactList.takeFirst();
+ delete c;
+ }
+}
+
+int ContactModel::count() const
+{
+ return contactList.count();
+}
+
+QHash<int,QVariant> ContactModel::data(int index, const QList<int> &roles) const
+{
+ QHash<int,QVariant> returnHash;
+
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ QVariant info;
+ switch(role) {
+ case PortraitRole:
+ info = "contact.png";
+ break;
+ case FirstNameRole:
+ info = contactList.at(index)->firstName();
+ break;
+ case LastNameRole:
+ info = contactList.at(index)->lastName();
+ break;
+ case CompanyRole:
+ info = contactList.at(index)->company();
+ break;
+ case EmailsRole:
+ info = contactList.at(index)->emails();
+ break;
+ case AddressesRole:
+ //returns QVariant BOOL
+ info = QVariant::fromValue(contactList.at(index)->addresses());
+ break;
+ case NumbersRole:
+ info = QVariant::fromValue(contactList.at(index)->numbers());
+ break;
+ default:
+ break;
+ }
+ returnHash.insert(role, info);
+ }
+
+ return returnHash;
+}
+
+QString ContactModel::toString(int role) const
+{
+ switch(role) {
+ case PortraitRole:
+ return "portrait";
+ case FirstNameRole:
+ return "firstName";
+ case LastNameRole:
+ return "lastName";
+ case CompanyRole:
+ return "company";
+ case EmailsRole:
+ return "emails";
+ case AddressesRole:
+ return "addresses";
+ case NumbersRole:
+ return "numbers";
+ default:
+ return "";
+ }
+}
+
+QList<int> ContactModel::roles() const
+{
+ return QList<int>() << PortraitRole << FirstNameRole << LastNameRole << CompanyRole << EmailsRole << AddressesRole << NumbersRole;
+}
+
+void ContactModel::deleteContact(int index)
+{
+ delete contactList.takeAt(index);
+ emit itemsRemoved(index, 1);
+}
+
+int ContactModel::insertContact(Contact *contact)
+{
+ int index = 0;
+ QString fullName = contact->lastName();
+ index = findIndex(fullName);
+ contactList.insert(index, contact);
+ emit itemsInserted(index, 1);
+ return index;
+}
+
+
+//search - binary search algorithm lastname only
+
+int ContactModel::findIndex(QString &searchName) const
+{
+ int start = 0;
+ int end = contactList.size()-1;
+ int middle = 0;
+ QString middleString;
+
+ while (start <= end)
+ {
+ middle = (start+end)/2;
+ middleString = contactList.at(middle)->lastName();
+ if (isAfter(searchName, middleString) < 0) start = middle+1;
+ else if( isAfter(middleString, searchName) < 0) end = middle-1;
+ else return middle;
+ }
+ return start;
+}
+
+int ContactModel::isAfter(QString &name1, QString &name2) const
+{
+ //if c1 is after c2 alphabetically, return positive
+ int compString = QString::compare(name1, name2, Qt::CaseInsensitive);
+ return -compString;
+}
diff --git a/examples/declarative/support/contactmodel.h b/examples/declarative/support/contactmodel.h
new file mode 100644
index 0000000..e262358
--- /dev/null
+++ b/examples/declarative/support/contactmodel.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#ifndef _CONTACTMODEL_H_
+#define _CONTACTMODEL_H_
+
+#include <qlistmodelinterface.h>
+#include "contact.h"
+
+class ContactModel : public QListModelInterface
+{
+ Q_OBJECT
+public:
+ ContactModel(QObject *parent = 0);
+ ~ContactModel();
+
+ enum Roles {
+ PortraitRole,
+ FirstNameRole,
+ LastNameRole,
+ CompanyRole,
+ EmailsRole,
+ AddressesRole,
+ NumbersRole
+ };
+
+ int count() const;
+
+ QHash<int,QVariant> data(int index, const QList<int> &roles) const;
+ QList<int> roles() const;
+
+
+ QString toString(int role) const;
+
+ void deleteContact(int index);
+ int insertContact(Contact *contact);
+
+ int isAfter(QString &name1, QString &name2) const;
+ int findIndex(QString &searchName) const;
+
+private:
+ QList<Contact*> contactList;
+};
+
+#endif
diff --git a/examples/declarative/support/support.pro b/examples/declarative/support/support.pro
new file mode 100644
index 0000000..1da1a28
--- /dev/null
+++ b/examples/declarative/support/support.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+TARGET = QtFxSupport
+DEPENDPATH += .
+INCLUDEPATH += .
+MOC_DIR = .moc
+OBJECTS_DIR = .obj
+DESTDIR = ../../lib
+QT += script declarative
+
+HEADERS += contact.h contactmodel.h
+SOURCES += contact.cpp contactmodel.cpp
+
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/Removebutton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/Removebutton.qml
new file mode 100644
index 0000000..a8ac7fe
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/Removebutton.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+//! [0]
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+}
+//! [0]
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml
new file mode 100644
index 0000000..050f05f
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml
@@ -0,0 +1,36 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: layout.width
+ height: layout.height
+ color: "white"
+ Column {
+ id: layout
+ width: childrenRect.width
+ GroupBox {
+ contents: "1/RemoveButton.qml"
+ label: "Rectangle Component"
+ }
+ GroupBox {
+ contents: "2/RemoveButton.qml"
+ label: "Closed Remove Item Button"
+ }
+ GroupBox {
+ contents: "2a/RemoveButton.qml"
+ label: "Alternative Closed Button"
+ }
+ GroupBox {
+ contents: "3/RemoveButton.qml"
+ label: "Open Remove Item Button"
+ }
+ GroupBox {
+ contents: "4/RemoveButton.qml"
+ label: "State Based Button"
+ }
+ GroupBox {
+ contents: "5/RemoveButton.qml"
+ label: "Animated Button"
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2/RemoveButton.qml
new file mode 100644
index 0000000..e323381
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2/RemoveButton.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+//! [0]
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ }
+}
+//! [0]
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2a/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2a/RemoveButton.qml
new file mode 100644
index 0000000..acada5b
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/2a/RemoveButton.qml
@@ -0,0 +1,22 @@
+import Qt 4.6
+
+//! [0]
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ children: [
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ }
+ ]
+}
+//! [0]
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/3/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/3/RemoveButton.qml
new file mode 100644
index 0000000..247d266
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/3/RemoveButton.qml
@@ -0,0 +1,41 @@
+import Qt 4.6
+
+//! [0]
+Rectangle {
+ id: removeButton
+ width: 230
+ height: 30
+ color: "red"
+ radius: 5
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ }
+}
+//! [0]
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml
new file mode 100644
index 0000000..ed74c4c
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4/RemoveButton.qml
@@ -0,0 +1,107 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+//! [script]
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+//! [script]
+//! [mouse region]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+//! [mouse region]
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+//! [states]
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: 230
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+//! [states]
+}
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml
new file mode 100644
index 0000000..7dc95c8
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/4a/RemoveButton.qml
@@ -0,0 +1,114 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+//! [script]
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+//! [script]
+//! [mouse region]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ id: trashMouseRegion
+ anchors.fill: parent
+ }
+ Connection {
+ sender: trashMouseRegion
+ signal: clicked()
+ script: {
+ toggle()
+ }
+ }
+ }
+//! [mouse region]
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+//! [states]
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: 230
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+//! [states]
+}
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml
new file mode 100644
index 0000000..75d5aaa
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/5/RemoveButton.qml
@@ -0,0 +1,114 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: 230
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+//! [transition]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+//! [transition]
+}
diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml
new file mode 100644
index 0000000..327c2bf
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/GroupBox.qml
@@ -0,0 +1,59 @@
+import Qt 4.6
+
+FocusScope {
+ id: groupBox
+ width: Math.max(270, subItem.width+40)
+ height: Math.max(70, subItem.height+40)
+
+ property var contents
+ property var label
+
+ Rectangle {
+ id: wrapper
+ x: 5
+ y: 10
+ radius: 10
+ width: groupBox.width-20
+ height: groupBox.height-20
+ color: "white"
+ border.color: "black"
+ Loader {
+ id: subItem
+ source: groupBox.contents
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ width: item.width
+ height: item.height
+ }
+ }
+ Rectangle {
+ x: 20
+ y: 0
+ height: text.height
+ width: text.width+10
+ color: "white"
+ Text {
+ x: 5
+ id: text
+ text: label
+ font.bold: true
+ }
+ }
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ opacity: parent.focus ? 0 : 0.3
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { parent.parent.focus=true }
+ }
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml
new file mode 100644
index 0000000..162452f
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml
@@ -0,0 +1,32 @@
+import Qt 4.6
+
+//! [load]
+Item {
+ id: contactField
+ clip: true
+ width: 230
+ height: 30
+ RemoveButton {
+ id: removeButton
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ }
+//! [load]
+ Text {
+ id: fieldText
+ width: contactField.width-80
+ anchors.right: removeButton.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ font.bold: true
+ color: "black"
+ text: 123123
+ }
+ Image {
+ source: "../../shared/pics/phone.png"
+ anchors.right: fieldText.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml
new file mode 100644
index 0000000..5ac62ce
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1/RemoveButton.qml
@@ -0,0 +1,112 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: 230
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml
new file mode 100644
index 0000000..cf50fb0
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+//! [load]
+Item {
+ id: contactField
+ clip: true
+ width: 230
+ height: 30
+ Loader {
+ id: removeButton
+ source: "RemoveButton.qml"
+ width: item.width
+ height: item.height
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ }
+//! [load]
+ Text {
+ id: fieldText
+ width: contactField.width-80
+ anchors.right: removeButton.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ font.bold: true
+ color: "black"
+ text: 123123
+ }
+ Image {
+ source: "../../shared/pics/phone.png"
+ anchors.right: fieldText.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml
new file mode 100644
index 0000000..5ac62ce
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1a/RemoveButton.qml
@@ -0,0 +1,112 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: 230
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml b/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml
new file mode 100644
index 0000000..ec115fe
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+//! [all]
+Rectangle {
+ width: 100
+ height: 100
+ color: "blue"
+ resources: [
+ Component {
+ id: redRectangle
+ Rectangle {
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ }
+ }
+ ]
+ ComponentInstance {
+ component: redRectangle
+ anchors.right: parent.right
+ anchors.top: parent.top
+ }
+ ComponentInstance {
+ component: redRectangle
+ anchors.left: parent.left
+ anchors.top: parent.top
+ }
+ ComponentInstance {
+ component: redRectangle
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ }
+}
+//! [all]
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml
new file mode 100644
index 0000000..eb694ce
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/1b/lib/RemoveButton.qml
@@ -0,0 +1,114 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ resources: [
+ Script {
+
+ function toggle() {
+ print('removeButton.toggle()');
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: 230
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml
new file mode 100644
index 0000000..2e1a488
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml
@@ -0,0 +1,34 @@
+import Qt 4.6
+
+Item {
+ id: contactField
+ clip: true
+ width: 230
+ height: 30
+//! [use properties and signals]
+ RemoveButton {
+ id: removeButton
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ expandedWidth: contactField.width
+ onConfirmed: { fieldText.text='' }
+ }
+//! [use properties and signals]
+ Text {
+ id: fieldText
+ width: contactField.width-80
+ anchors.right: removeButton.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ font.bold: true
+ color: "black"
+ text: 123123
+ }
+ Image {
+ source: "../../shared/pics/phone.png"
+ anchors.right: fieldText.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml
new file mode 100644
index 0000000..b1cd72e
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml
@@ -0,0 +1,120 @@
+import Qt 4.6
+
+//! [define properties and signals]
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ property var expandedWidth: 230
+ signal confirmed
+//! [define properties and signals]
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+//! [use signal]
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle(); removeButton.confirmed() }
+ }
+//! [use signal]
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+//! [use width]
+ PropertyChanges {
+ target: removeButton
+ width: removeButton.expandedWidth
+ }
+//! [use width]
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml
new file mode 100644
index 0000000..a913dda
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: layout.width
+ height: layout.height
+ color: "white"
+ Grid {
+ id: layout
+ columns: 2
+ rows: 4
+ width: childrenRect.width
+ GroupBox {
+ contents: "1/ContactField.qml"
+ label: "Loading: simple"
+ }
+ GroupBox {
+ contents: "1a/ContactField.qml"
+ label: "Loading: qml property"
+ }
+ GroupBox {
+ contents: "2/ContactField.qml"
+ label: "Using properties"
+ }
+ GroupBox {
+ id: prev
+ contents: "3/ContactField.qml"
+ label: "Defining signals"
+ }
+ GroupBox {
+ contents: "3/Contact.qml"
+ label: "Multiple Items"
+ }
+ GroupBox {
+ contents: "4/Contact.qml"
+ label: "Mouse Grabbing"
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml
new file mode 100644
index 0000000..3516cee
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml
@@ -0,0 +1,49 @@
+import Qt 4.6
+
+Item {
+ id: contactDetails
+ width: 230
+ height: layout.height
+
+ property var contactId: ""
+ property var label: ""
+ property var phone: ""
+ property var email: ""
+
+ onLabelChanged: { labelField.value = label }
+ onEmailChanged: { emailField.value = email }
+ onPhoneChanged: { phoneField.value = phone }
+
+ Column {
+ id: layout
+ anchors.fill: parent
+ spacing: 5
+ margin: 5
+ ContactField {
+ id: labelField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ label: "Name"
+ }
+ ContactField {
+ id: phoneField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/phone.png"
+ label: "Phone"
+ }
+ ContactField {
+ id: emailField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/email.png"
+ label: "Email"
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml
new file mode 100644
index 0000000..1517a74
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/3/ContactField.qml
@@ -0,0 +1,61 @@
+import Qt 4.6
+
+//! [all]
+Item {
+ id: contactField
+ clip: true
+ width: 230
+ height: 30
+ property var label: "Name"
+ property var icon: "../../shared/pics/phone.png"
+ property var value: ""
+ RemoveButton {
+ id: removeButton
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ expandedWidth: contactField.width
+ onConfirmed: { fieldText.text='' }
+ }
+ FieldText {
+ id: fieldText
+ width: contactField.width-70
+ anchors.right: removeButton.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ label: contactField.label
+ text: contactField.value
+ }
+ Image {
+ anchors.right: fieldText.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: contactField.icon
+ }
+ states: [
+ State {
+ name: "editingText"
+ when: fieldText.state == 'editing'
+ PropertyChanges {
+ target: removeButton.anchors
+ rightMargin: -35
+ }
+ PropertyChanges {
+ target: fieldText
+ width: contactField.width
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "width,rightMargin"
+ duration: 200
+ }
+ }
+ ]
+}
+//! [all]
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml
new file mode 100644
index 0000000..3a8bb7f
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml
@@ -0,0 +1,144 @@
+import Qt 4.6
+
+//! [value change]
+Rectangle {
+ id: fieldText
+ height: 30
+ radius: 5
+ color: "white"
+ property var text: ""
+ onTextChanged: { reset() }
+//! [value change]
+ property var label: ""
+ signal confirmed
+ resources: [
+ Script {
+
+ function edit() {
+ fieldText.state='editing';
+ }
+ function confirm() {
+ fieldText.text = textEdit.text;
+ fieldText.state='';
+ fieldText.confirmed();
+ }
+ function reset() {
+ textEdit.text = fieldText.text;
+ fieldText.state='';
+ }
+
+ }
+ ]
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ }
+ TextEdit {
+ id: textEdit
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ color: "black"
+ font.bold: true
+ readOnly: true
+ wrap: false
+ }
+//! [behavior]
+ Text {
+ id: textLabel
+ x: 5
+ width: parent.width-10
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: "AlignHCenter"
+ color: "#505050"
+ font.italic: true
+ text: fieldText.label
+ opacity: textEdit.text == '' ? 1 : 0
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+//! [behavior]
+ MouseRegion {
+ anchors.fill: cancelIcon
+ onClicked: { reset() }
+ }
+ MouseRegion {
+ anchors.fill: confirmIcon
+ onClicked: { confirm() }
+ }
+ MouseRegion {
+ id: editRegion
+ anchors.fill: textEdit
+ onClicked: { edit() }
+ }
+ states: [
+ State {
+ name: "editing"
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: textEdit
+ readOnly: false
+ }
+ PropertyChanges {
+ target: textEdit
+ focus: true
+ }
+ PropertyChanges {
+ target: editRegion
+ opacity: 0
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ leftMargin: 39
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ rightMargin: 39
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,leftMargin,rightMargin"
+ duration: 200
+ }
+ ColorAnimation {
+ property: "color"
+ duration: 150
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml
new file mode 100644
index 0000000..1276c6b
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml
@@ -0,0 +1,116 @@
+import Qt 4.6
+
+//! [all]
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ property var expandedWidth: 230
+ signal confirmed
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ } else {
+ removeButton.state = 'opened';
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle(); removeButton.confirmed() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: removeButton.expandedWidth
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
+//! [all]
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml
new file mode 100644
index 0000000..83988ab
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml
@@ -0,0 +1,52 @@
+import Qt 4.6
+
+//! [grab property]
+Item {
+ id: contactDetails
+ width: 230
+ height: layout.height
+ property var mouseGrabbed: false
+//! [grab property]
+
+ property var contactId: ""
+ property var label: ""
+ property var phone: ""
+ property var email: ""
+
+ onLabelChanged: { labelField.value = label }
+ onEmailChanged: { emailField.value = email }
+ onPhoneChanged: { phoneField.value = phone }
+
+ Column {
+ id: layout
+ anchors.fill: parent
+ spacing: 5
+ margin: 5
+ ContactField {
+ id: labelField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ label: "Name"
+ }
+ ContactField {
+ id: phoneField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/phone.png"
+ label: "Phone"
+ }
+ ContactField {
+ id: emailField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/email.png"
+ label: "Email"
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml
new file mode 100644
index 0000000..ccd756e
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/4/ContactField.qml
@@ -0,0 +1,58 @@
+import Qt 4.6
+
+Item {
+ id: contactField
+ clip: true
+ height: 30
+ property var label: "Name"
+ property var icon: "../../shared/pics/phone.png"
+ property var value: ""
+ RemoveButton {
+ id: removeButton
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ expandedWidth: contactField.width
+ onConfirmed: { fieldText.text='' }
+ }
+ FieldText {
+ id: fieldText
+ width: contactField.width-70
+ anchors.right: removeButton.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ label: contactField.label
+ text: contactField.value
+ }
+ Image {
+ anchors.right: fieldText.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: contactField.icon
+ }
+ states: [
+ State {
+ name: "editingText"
+ when: fieldText.state == 'editing'
+ PropertyChanges {
+ target: removeButton.anchors
+ rightMargin: -35
+ }
+ PropertyChanges {
+ target: fieldText
+ width: contactField.width
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "width,rightMargin"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml
new file mode 100644
index 0000000..8f98ede
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml
@@ -0,0 +1,145 @@
+import Qt 4.6
+
+Rectangle {
+ id: fieldText
+ height: 30
+ radius: 5
+ color: "white"
+ property var text: ""
+ property var label: ""
+ onTextChanged: { reset() }
+ signal confirmed
+ resources: [
+ Script {
+
+ function edit() {
+ if (!contactDetails.mouseGrabbed) {
+ fieldText.state='editing';
+ contactDetails.mouseGrabbed=true;
+ }
+ }
+ function confirm() {
+ fieldText.text = textEdit.text;
+ fieldText.state='';
+ contactDetails.mouseGrabbed=false;
+ fieldText.confirmed();
+ }
+ function reset() {
+ textEdit.text = fieldText.text;
+ fieldText.state='';
+ contactDetails.mouseGrabbed=false;
+ }
+
+ }
+ ]
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ }
+ TextEdit {
+ id: textEdit
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ color: "black"
+ font.bold: true
+ readOnly: true
+ wrap: false
+ }
+ Text {
+ id: textLabel
+ x: 5
+ width: parent.width-10
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: "AlignHCenter"
+ color: "#505050"
+ font.italic: true
+ text: fieldText.label
+ opacity: textEdit.text == '' ? 1 : 0
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+ MouseRegion {
+ anchors.fill: cancelIcon
+ onClicked: { reset() }
+ }
+ MouseRegion {
+ anchors.fill: confirmIcon
+ onClicked: { confirm() }
+ }
+ MouseRegion {
+ id: editRegion
+ anchors.fill: textEdit
+ onClicked: { edit() }
+ }
+ states: [
+ State {
+ name: "editing"
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: textEdit
+ readOnly: false
+ }
+ PropertyChanges {
+ target: textEdit
+ focus: true
+ }
+ PropertyChanges {
+ target: editRegion
+ opacity: 0
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ leftMargin: 39
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ rightMargin: 39
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,leftMargin,rightMargin"
+ duration: 200
+ }
+ ColorAnimation {
+ property: "color"
+ duration: 150
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml
new file mode 100644
index 0000000..8938184
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml
@@ -0,0 +1,120 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ property var expandedWidth: 230
+ signal confirmed
+ resources: [
+//! [grab]
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ contactDetails.mouseGrabbed=false;
+ } else {
+ if (!contactDetails.mouseGrabbed) {
+ removeButton.state = 'opened';
+ contactDetails.mouseGrabbed=true;
+ }
+ }
+ }
+
+ }
+//! [grab]
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle(); removeButton.confirmed() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ width: removeButton.expandedWidth
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml
new file mode 100644
index 0000000..327c2bf
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/2_Reuse/GroupBox.qml
@@ -0,0 +1,59 @@
+import Qt 4.6
+
+FocusScope {
+ id: groupBox
+ width: Math.max(270, subItem.width+40)
+ height: Math.max(70, subItem.height+40)
+
+ property var contents
+ property var label
+
+ Rectangle {
+ id: wrapper
+ x: 5
+ y: 10
+ radius: 10
+ width: groupBox.width-20
+ height: groupBox.height-20
+ color: "white"
+ border.color: "black"
+ Loader {
+ id: subItem
+ source: groupBox.contents
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ width: item.width
+ height: item.height
+ }
+ }
+ Rectangle {
+ x: 20
+ y: 0
+ height: text.height
+ width: text.width+10
+ color: "white"
+ Text {
+ x: 5
+ id: text
+ text: label
+ font.bold: true
+ }
+ }
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ opacity: parent.focus ? 0 : 0.3
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { parent.parent.focus=true }
+ }
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml
new file mode 100644
index 0000000..25cb539
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/1/ContactView.qml
@@ -0,0 +1,46 @@
+import Qt 4.6
+
+import "../lib"
+Item {
+ id: contacts
+ width: 240
+ height: 230
+ property var mouseGrabbed: false
+ resources: [
+//! [model]
+ SqlConnection {
+ id: contactDatabase
+ name: "qmlConnection"
+ driver: "QSQLITE"
+ databaseName: "../../shared/contacts.sqlite"
+ },
+ SqlQuery {
+ id: contactList
+ connection: contactDatabase
+ query: "SELECT recid, label, email, phone FROM contacts ORDER BY label, recid"
+ }
+//! [model]
+ ]
+//! [view]
+ ListView {
+ id: contactListView
+ anchors.fill: parent
+ clip: true
+ model: contactList
+ focus: true
+//! [delegate]
+ delegate: [
+ Text {
+ x: 45
+ y: 12
+ width: contactListView.width-45
+ height: 30
+ color: "black"
+ font.bold: true
+ text: model.label
+ }
+ ]
+//! [delegate]
+ }
+//! [view]
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml
new file mode 100644
index 0000000..d16e3ca
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/2/ContactView.qml
@@ -0,0 +1,124 @@
+import Qt 4.6
+
+import "../lib"
+Item {
+ id: contacts
+ width: 240
+ height: 230
+ property var mouseGrabbed: false
+ resources: [
+ SqlConnection {
+ id: contactDatabase
+ name: "qmlConnection"
+ driver: "QSQLITE"
+ databaseName: "../../shared/contacts.sqlite"
+ },
+ SqlQuery {
+ id: contactList
+ connection: contactDatabase
+ query: "SELECT recid, label, email, phone FROM contacts ORDER BY label, recid"
+ }
+ ]
+//! [button]
+ Button {
+ id: cancelEditButton
+ anchors.top: parent.top
+ anchors.topMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/cancel.png"
+ opacity: mouseGrabbed ? 0 : 1
+ }
+//! [button]
+ ListView {
+ id: contactListView
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: cancelEditButton.bottom
+ anchors.bottom: parent.bottom
+ clip: true
+ model: contactList
+ focus: true
+ delegate: [
+//! [components]
+ Item {
+ id: wrapper
+ x: 0
+ width: ListView.view.width
+ height: 34
+ Text {
+ id: label
+ x: 45
+ y: 12
+ width: parent.width-45
+ color: "black"
+ font.bold: true
+ text: model.label
+ }
+ MouseRegion {
+ anchors.fill: label
+ onClicked: { wrapper.state='opened'; }
+ }
+ Contact {
+ id: Details
+ anchors.fill: parent
+ contactId: model.recid
+ label: model.label
+ email: model.email
+ phone: model.phone
+ opacity: 0
+ }
+//! [components]
+//! [states]
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: wrapper
+ height: contactListView.height
+ }
+ PropertyChanges {
+ target: contactListView
+ explicit: true
+ yPosition: wrapper.y
+ }
+ PropertyChanges {
+ target: contactListView
+ locked: 1
+ }
+ PropertyChanges {
+ target: label
+ opacity: 0
+ }
+ PropertyChanges {
+ target: Details
+ opacity: 1
+ }
+ }
+ ]
+//! [states]
+//! [transitions]
+ transitions: [
+ Transition {
+ NumberAnimation {
+ duration: 500
+ properties: "yPosition,height,opacity"
+ }
+ }
+ ]
+//! [transitions]
+//! [connections]
+ Connection {
+ sender: cancelEditButton
+ signal: "clicked()"
+ script: {
+ if (wrapper.state == 'opened') {
+ wrapper.state = '';
+ }
+ }
+ }
+//! [connections]
+ }
+ ]
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml
new file mode 100644
index 0000000..bf73367
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/3/ContactView.qml
@@ -0,0 +1,137 @@
+import Qt 4.6
+
+import "../lib"
+Item {
+ id: contacts
+ width: 240
+ height: 230
+ property var mouseGrabbed: false
+ resources: [
+ SqlConnection {
+ id: contactDatabase
+ name: "qmlConnection"
+ driver: "QSQLITE"
+ databaseName: "../../shared/contacts.sqlite"
+ },
+ SqlQuery {
+ id: contactList
+ connection: contactDatabase
+ query: "SELECT recid, label, email, phone FROM contacts ORDER BY label, recid"
+ }
+ ]
+ Button {
+ id: cancelEditButton
+ anchors.top: parent.top
+ anchors.topMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/cancel.png"
+ opacity: mouseGrabbed ? 0 : 1
+ }
+ ListView {
+ id: contactListView
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: cancelEditButton.bottom
+ anchors.bottom: parent.bottom
+ clip: true
+ model: contactList
+ focus: true
+ delegate: [
+ Item {
+ id: wrapper
+ x: 0
+ width: ListView.view.width
+ height: 34
+ Text {
+ id: label
+ x: 45
+ y: 12
+ width: parent.width-45
+ color: "black"
+ font.bold: true
+ text: model.label
+ }
+//! [setting qml]
+ MouseRegion {
+ anchors.fill: label
+ onClicked: {
+ Details.source = 'Contact.qml';
+ wrapper.state='opened';
+ }
+ }
+ Loader {
+ id: Details
+ anchors.fill: parent
+ opacity: 0
+//! [setting qml]
+//! [binding]
+ Binding {
+ target: Details.item
+ property: "contactId"
+ value: model.recid
+ }
+ Binding {
+ target: Details.item
+ property: "label"
+ value: model.label
+ }
+ Binding {
+ target: Details.item
+ property: "phone"
+ value: model.phone
+ }
+ Binding {
+ target: Details.item
+ property: "email"
+ value: model.email
+ }
+//! [binding]
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: wrapper
+ height: contactListView.height
+ }
+ PropertyChanges {
+ target: contactListView
+ explicit: true
+ yPosition: wrapper.y
+ }
+ PropertyChanges {
+ target: contactListView
+ locked: 1
+ }
+ PropertyChanges {
+ target: label
+ opacity: 0
+ }
+ PropertyChanges {
+ target: Details
+ opacity: 1
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ NumberAnimation {
+ duration: 500
+ properties: "yPosition,height,opacity"
+ }
+ }
+ ]
+ Connection {
+ sender: cancelEditButton
+ signal: "clicked()"
+ script: {
+ if (wrapper.state == 'opened') {
+ wrapper.state = '';
+ }
+ }
+ }
+ }
+ ]
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml
new file mode 100644
index 0000000..a7764ed
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: layout.width
+ height: layout.height
+ color: "white"
+ Bind {
+ id: currentItem
+ value: true
+ }
+ // relies on the current focus behavior whereby setting focus=true on a
+ // component removes focus from any previous element
+ Grid {
+ id: layout
+ width: childrenRect.width
+ height: childrenRect.height
+ GroupBox {
+ contents: "1/ContactView.qml"
+ label: "list only"
+ }
+ GroupBox {
+ contents: "2/ContactView.qml"
+ label: "dynamic delegate"
+ }
+ GroupBox {
+ contents: "3/ContactView.qml"
+ label: "delayed loading"
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml
new file mode 100644
index 0000000..327c2bf
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/GroupBox.qml
@@ -0,0 +1,59 @@
+import Qt 4.6
+
+FocusScope {
+ id: groupBox
+ width: Math.max(270, subItem.width+40)
+ height: Math.max(70, subItem.height+40)
+
+ property var contents
+ property var label
+
+ Rectangle {
+ id: wrapper
+ x: 5
+ y: 10
+ radius: 10
+ width: groupBox.width-20
+ height: groupBox.height-20
+ color: "white"
+ border.color: "black"
+ Loader {
+ id: subItem
+ source: groupBox.contents
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ width: item.width
+ height: item.height
+ }
+ }
+ Rectangle {
+ x: 20
+ y: 0
+ height: text.height
+ width: text.width+10
+ color: "white"
+ Text {
+ x: 5
+ id: text
+ text: label
+ font.bold: true
+ }
+ }
+ Rectangle {
+ color: "black"
+ anchors.fill: parent
+ opacity: parent.focus ? 0 : 0.3
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { parent.parent.focus=true }
+ }
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml
new file mode 100644
index 0000000..9719231
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Item {
+ id: button
+ width: 30
+ height: 30
+ property var icon: ""
+ signal clicked
+ Rectangle {
+ id: buttonRect
+ anchors.fill: parent
+ color: "lightgreen"
+ radius: 5
+ Image {
+ id: iconImage
+ source: button.icon
+ anchors.horizontalCenter: buttonRect.horizontalCenter
+ anchors.verticalCenter: buttonRect.verticalCenter
+ }
+ MouseRegion {
+ id: buttonMouseRegion
+ anchors.fill: buttonRect
+ onClicked: { button.clicked() }
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: buttonMouseRegion.pressed == true
+ PropertyChanges {
+ target: buttonRect
+ color: "green"
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "pressed"
+ ColorAnimation {
+ property: "color"
+ duration: 200
+ }
+ },
+ Transition {
+ from: "pressed"
+ to: "*"
+ ColorAnimation {
+ property: "color"
+ duration: 1000
+ }
+ }
+ ]
+ }
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml
new file mode 100644
index 0000000..d00bf05
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml
@@ -0,0 +1,48 @@
+import Qt 4.6
+
+Item {
+ id: contactDetails
+ anchors.fill: parent
+
+ property var contactId: ""
+ property var label: ""
+ property var phone: ""
+ property var email: ""
+
+ onLabelChanged: { labelField.value = label }
+ onEmailChanged: { emailField.value = email }
+ onPhoneChanged: { phoneField.value = phone }
+
+ Column {
+ id: layout
+ anchors.fill: parent
+ spacing: 5
+ margin: 5
+ ContactField {
+ id: labelField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ label: "Name"
+ }
+ ContactField {
+ id: phoneField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/phone.png"
+ label: "Phone"
+ }
+ ContactField {
+ id: emailField
+ anchors.left: layout.left
+ anchors.leftMargin: 5
+ anchors.right: layout.right
+ anchors.rightMargin: 5
+ icon: "../../shared/pics/email.png"
+ label: "Email"
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml
new file mode 100644
index 0000000..ccd756e
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/lib/ContactField.qml
@@ -0,0 +1,58 @@
+import Qt 4.6
+
+Item {
+ id: contactField
+ clip: true
+ height: 30
+ property var label: "Name"
+ property var icon: "../../shared/pics/phone.png"
+ property var value: ""
+ RemoveButton {
+ id: removeButton
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ expandedWidth: contactField.width
+ onConfirmed: { fieldText.text='' }
+ }
+ FieldText {
+ id: fieldText
+ width: contactField.width-70
+ anchors.right: removeButton.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ label: contactField.label
+ text: contactField.value
+ }
+ Image {
+ anchors.right: fieldText.left
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ source: contactField.icon
+ }
+ states: [
+ State {
+ name: "editingText"
+ when: fieldText.state == 'editing'
+ PropertyChanges {
+ target: removeButton.anchors
+ rightMargin: -35
+ }
+ PropertyChanges {
+ target: fieldText
+ width: contactField.width
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "width,rightMargin"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml
new file mode 100644
index 0000000..228a00d
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml
@@ -0,0 +1,145 @@
+import Qt 4.6
+
+Rectangle {
+ id: fieldText
+ height: 30
+ radius: 5
+ color: "white"
+ property var text: ""
+ property var label: ""
+ onTextChanged: { reset() }
+ signal confirmed
+ resources: [
+ Script {
+
+ function edit() {
+ if (!contacts.mouseGrabbed) {
+ fieldText.state='editing';
+ contacts.mouseGrabbed=true;
+ }
+ }
+ function confirm() {
+ fieldText.text = textEdit.text;
+ fieldText.state='';
+ contacts.mouseGrabbed=false;
+ fieldText.confirmed();
+ }
+ function reset() {
+ textEdit.text = fieldText.text;
+ fieldText.state='';
+ contacts.mouseGrabbed=false;
+ }
+
+ }
+ ]
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ }
+ TextEdit {
+ id: textEdit
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ anchors.verticalCenter: parent.verticalCenter
+ color: "black"
+ font.bold: true
+ readOnly: true
+ wrap: false
+ }
+ Text {
+ id: textLabel
+ x: 5
+ width: parent.width-10
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: "AlignHCenter"
+ color: "#505050"
+ font.italic: true
+ text: fieldText.label
+ opacity: textEdit.text == '' ? 1 : 0
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+ MouseRegion {
+ anchors.fill: cancelIcon
+ onClicked: { reset() }
+ }
+ MouseRegion {
+ anchors.fill: confirmIcon
+ onClicked: { confirm() }
+ }
+ MouseRegion {
+ id: editRegion
+ anchors.fill: textEdit
+ onClicked: { edit() }
+ }
+ states: [
+ State {
+ name: "editing"
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: textEdit
+ readOnly: false
+ }
+ PropertyChanges {
+ target: textEdit
+ focus: true
+ }
+ PropertyChanges {
+ target: editRegion
+ opacity: 0
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ leftMargin: 39
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ rightMargin: 39
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,leftMargin,rightMargin"
+ duration: 200
+ }
+ ColorAnimation {
+ property: "color"
+ duration: 150
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml
new file mode 100644
index 0000000..3c77cd8
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml
@@ -0,0 +1,119 @@
+import Qt 4.6
+
+Rectangle {
+ id: removeButton
+ width: 30
+ height: 30
+ color: "red"
+ radius: 5
+ property var expandedWidth: 230
+ signal confirmed
+ resources: [
+ Script {
+ function toggle() {
+ if (removeButton.state == 'opened') {
+ removeButton.state = '';
+ contacts.mouseGrabbed=false;
+ } else {
+ if (!contacts.mouseGrabbed) {
+ removeButton.state = 'opened';
+ contacts.mouseGrabbed=true;
+ }
+ }
+ }
+
+ }
+ ]
+ Image {
+ id: trashIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/trash.png"
+ opacity: 1
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/cancel.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle() }
+ }
+ }
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../shared/pics/ok.png"
+ opacity: 0
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { toggle(); removeButton.confirmed() }
+ }
+ }
+ Text {
+ id: text
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: confirmIcon.right
+ anchors.leftMargin: 4
+ anchors.right: cancelIcon.left
+ anchors.rightMargin: 4
+ font.bold: true
+ color: "white"
+ horizontalAlignment: "AlignHCenter"
+ text: "Remove"
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "opened"
+ PropertyChanges {
+ target: removeButton
+ explicit: true
+ width: removeButton.expandedWidth
+ }
+ PropertyChanges {
+ target: text
+ opacity: 1
+ }
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: trashIcon
+ opacity: 0
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "opened"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,x,width"
+ duration: 200
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/tutorials/contacts/shared/contactGenSQL.pl b/examples/declarative/tutorials/contacts/shared/contactGenSQL.pl
new file mode 100755
index 0000000..2d328da
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/contactGenSQL.pl
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+my $count = shift;
+
+open(MFIRST, "<english-m.txt") or die "Could not open male names";
+open(FFIRST, "<english-f.txt") or die "Could not open female names";
+open(SURNAME, "<english-s.txt") or die "Could not open surnames names";
+open(ISP, "<email.txt") or die "Could not open isp names";
+
+my @mnames = <MFIRST>;
+my @fnames = <FFIRST>;
+my @surnames = <SURNAME>;
+my @isps = <ISP>;
+
+print "BEGIN;\n";
+print "CREATE TABLE contacts (recid INTEGER PRIMARY KEY, label TEXT, phone TEXT, email TEXT);\n";
+print "CREATE INDEX contactSortOrder ON contacts(label, recid);\n";
+
+my $i = 0;
+while ($i < $count) {
+ $i++;
+ my $fn = randomFirstName();
+ my $sn = randomLastName();
+ my $em = randomEmail($fn, $sn);
+ my $ph = randomPhoneNumber();
+
+ $fn =~ s/'/''/g;
+ $sn =~ s/'/''/g;
+ $em =~ s/'/''/g;
+ print "INSERT INTO contacts (label, email, phone) VALUES('$fn $sn', '$em', '$ph');\n"
+}
+
+print "COMMIT;\n";
+
+
+sub randomFirstName
+{
+ my $name;
+ if (int(rand 2) == 1) {
+ $name = $mnames[int(rand @mnames)];
+ } else {
+ $name = $fnames[int(rand @fnames)];
+ }
+ chomp $name;
+ $name;
+}
+
+sub randomLastName
+{
+ my $name = $surnames[int(rand @surnames)];
+ chomp $name;
+ $name;
+}
+
+sub randomEmail
+{
+ my ($fn, $ln) = @_;
+ my $isp = $isps[int(rand @isps)];
+ chomp $isp;
+ my $path = int(rand 3);
+ my $email;
+ if ($path == 0) {
+ $email = "$fn.$ln\@$isp";
+ } elsif ($path == 1) {
+ $email = "$fn\@$isp";
+ } elsif ($path == 2) {
+ $email = "$ln\@$isp";
+ }
+}
+
+sub randomPhoneNumber
+{
+ my @digits = qw(1 2 3 4 5 6 7 8 9 0);
+ my $phonenumber;
+ for (1 .. 8) {
+ $phonenumber .= $digits[int(rand @digits)];
+ }
+ $phonenumber;
+}
diff --git a/examples/declarative/tutorials/contacts/shared/contacts.sqlite b/examples/declarative/tutorials/contacts/shared/contacts.sqlite
new file mode 100644
index 0000000..d903775
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/contacts.sqlite
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/email.txt b/examples/declarative/tutorials/contacts/shared/email.txt
new file mode 100644
index 0000000..de9894b
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/email.txt
@@ -0,0 +1,7 @@
+emails.com
+emails.net
+mailserver.org
+mailserver.net
+mailserver.com
+BobsMail.com
+BillMail.com
diff --git a/examples/declarative/tutorials/contacts/shared/english-f.txt b/examples/declarative/tutorials/contacts/shared/english-f.txt
new file mode 100644
index 0000000..7da5474
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/english-f.txt
@@ -0,0 +1,143 @@
+Aimee
+Aleksandra
+Alice
+Alicia
+Allison
+Alyssa
+Amy
+Andrea
+Angel
+Angela
+Ann
+Anna
+Anne
+Anne
+Marie
+Annie
+Ashley
+Barbara
+Beatrice
+Beth
+Betty
+Brenda
+Brooke
+Candace
+Cara
+Caren
+Carol
+Caroline
+Carolyn
+Carrie
+Cassandra
+Catherine
+Charlotte
+Chrissy
+Christen
+Christina
+Christine
+Christy
+Claire
+Claudia
+Courtney
+Crystal
+Cynthia
+Dana
+Danielle
+Deanne
+Deborah
+Deirdre
+Denise
+Diane
+Dianne
+Dorothy
+Eileen
+Elena
+Elizabeth
+Emily
+Erica
+Erin
+Frances
+Gina
+Giulietta
+Heather
+Helen
+Jane
+Janet
+Janice
+Jenna
+Jennifer
+Jessica
+Joanna
+Joyce
+Julia
+Juliana
+Julie
+Justine
+Kara
+Karen
+Katharine
+Katherine
+Kathleen
+Kathryn
+Katrina
+Kelly
+Kerry
+Kim
+Kimberly
+Kristen
+Kristina
+Kristine
+Laura
+Laurel
+Lauren
+Laurie
+Leah
+Linda
+Lisa
+Lori
+Marcia
+Margaret
+Maria
+Marina
+Marisa
+Martha
+Mary
+Mary
+Ann
+Maya
+Melanie
+Melissa
+Michelle
+Monica
+Nancy
+Natalie
+Nicole
+Nina
+Pamela
+Patricia
+Rachel
+Rebecca
+Renee
+Sandra
+Sara
+Sharon
+Sheri
+Shirley
+Sonia
+Stefanie
+Stephanie
+Susan
+Suzanne
+Sylvia
+Tamara
+Tara
+Tatiana
+Terri
+Theresa
+Tiffany
+Tracy
+Valerie
+Veronica
+Vicky
+Vivian
+Wendy
diff --git a/examples/declarative/tutorials/contacts/shared/english-m.txt b/examples/declarative/tutorials/contacts/shared/english-m.txt
new file mode 100644
index 0000000..3c7b13e
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/english-m.txt
@@ -0,0 +1,130 @@
+Aaron
+Adam
+Adrian
+Alan
+Alejandro
+Alex
+Allen
+Andrew
+Andy
+Anthony
+Art
+Arthur
+Barry
+Bart
+Ben
+Benjamin
+Bill
+Bobby
+Brad
+Bradley
+Brendan
+Brett
+Brian
+Bruce
+Bryan
+Carlos
+Chad
+Charles
+Chris
+Christopher
+Chuck
+Clay
+Corey
+Craig
+Dan
+Daniel
+Darren
+Dave
+David
+Dean
+Dennis
+Denny
+Derek
+Don
+Doug
+Duane
+Edward
+Eric
+Eugene
+Evan
+Frank
+Fred
+Gary
+Gene
+George
+Gordon
+Greg
+Harry
+Henry
+Hunter
+Ivan
+Jack
+James
+Jamie
+Jason
+Jay
+Jeff
+Jeffrey
+Jeremy
+Jim
+Joe
+Joel
+John
+Jonathan
+Joseph
+Justin
+Keith
+Ken
+Kevin
+Larry
+Logan
+Marc
+Mark
+Matt
+Matthew
+Michael
+Mike
+Nat
+Nathan
+Patrick
+Paul
+Perry
+Peter
+Philip
+Phillip
+Randy
+Raymond
+Ricardo
+Richard
+Rick
+Rob
+Robert
+Rod
+Roger
+Ross
+Ruben
+Russell
+Ryan
+Sam
+Scot
+Scott
+Sean
+Shaun
+Stephen
+Steve
+Steven
+Stewart
+Stuart
+Ted
+Thomas
+Tim
+Toby
+Todd
+Tom
+Troy
+Victor
+Wade
+Walter
+Wayne
+William
diff --git a/examples/declarative/tutorials/contacts/shared/english-s.txt b/examples/declarative/tutorials/contacts/shared/english-s.txt
new file mode 100644
index 0000000..1f3682d
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/english-s.txt
@@ -0,0 +1,1003 @@
+Adams
+Adamson
+Adler
+Akers
+Akin
+Aleman
+Alexander
+Allen
+Allison
+Allwood
+Anderson
+Andreou
+Anthony
+Appelbaum
+Applegate
+Arbore
+Arenson
+Armold
+Arntzen
+Askew
+Athanas
+Atkinson
+Ausman
+Austin
+Averitt
+Avila-Sakar
+Badders
+Baer
+Baggerly
+Bailliet
+Baird
+Baker
+Ball
+Ballentine
+Ballew
+Banks
+Baptist-Nguyen
+Barbee
+Barber
+Barchas
+Barcio
+Bardsley
+Barkauskas
+Barnes
+Barnett
+Barnwell
+Barrera
+Barreto
+Barroso
+Barrow
+Bart
+Barton
+Bass
+Bates
+Bavinger
+Baxter
+Bazaldua
+Becker
+Beeghly
+Belforte
+Bellamy
+Bellavance
+Beltran
+Belusar
+Bennett
+Benoit
+Bensley
+Berger
+Berggren
+Bergman
+Berry
+Bertelson
+Bess
+Beusse
+Bickford
+Bierner
+Bird
+Birdwell
+Bixby
+Blackmon
+Blackwell
+Blair
+Blankinship
+Blanton
+Block
+Blomkalns
+Bloomfield
+Blume
+Boeckenhauer
+Bolding
+Bolt
+Bolton
+Book
+Boucher
+Boudreau
+Bowman
+Boyd
+Boyes
+Boyles
+Braby
+Braden
+Bradley
+Brady
+Bragg
+Brandow
+Brantley
+Brauner
+Braunhardt
+Bray
+Bredenberg
+Bremer
+Breyer
+Bricout
+Briggs
+Brittain
+Brockman
+Brockmoller
+Broman
+Brooks
+Brown
+Brubaker
+Bruce
+Brumfield
+Brumley
+Bruning
+Buck
+Budd
+Buhler
+Buhr
+Burleson
+Burns
+Burton
+Bush
+Butterfield
+Byers
+Byon
+Byrd
+Bzostek
+Cabrera
+Caesar
+Caffey
+Caffrey
+Calhoun
+Call
+Callahan
+Campbell
+Cano
+Capri
+Carey
+Carlisle
+Carlson
+Carmichael
+Carnes
+Carr
+Carreira
+Carroll
+Carson
+Carswell
+Carter
+Cartwright
+Cason
+Cates
+Catlett
+Caudle
+Cavallaro
+Cave
+Cazamias
+Chabot
+Chance
+Chapman
+Characklis
+Cheatham
+Chen
+Chern
+Cheville
+Chong
+Christensen
+Church
+Claibourn
+Clark
+Clasen
+Claude
+Close
+Coakley
+Coffey
+Cohen
+Cole
+Collier
+Conant
+Connell
+Conte
+Conway
+Cooley
+Cooper
+Copeland
+Coram
+Corbett
+Cort
+Cortes
+Cousins
+Cowsar
+Cox
+Coyne
+Crain
+Crankshaw
+Craven
+Crawford
+Cressman
+Crestani
+Crier
+Crocker
+Cromwell
+Crouse
+Crowder
+Crowe
+Culpepper
+Cummings
+Cunningham
+Currie
+Cusey
+Cutcher
+Cyprus
+D'Ascenzo
+Dabak
+Dakoulas
+Daly
+Dana
+Danburg
+Danenhauer
+Darley
+Darrouzet
+Dartt
+Daugherty
+Davila
+Davis
+Dawkins
+Day
+DeHart
+DeMoss
+DeMuth
+DeVincentis
+Deaton
+Dees
+Degenhardt
+Deggeller
+Deigaard
+Delabroy
+Delaney
+Demir
+Denison
+Denney
+Derr
+Deuel
+Devitt
+Diamond
+Dickinson
+Dietrich
+Dilbeck
+Dobson
+Dodds
+Dodson
+Doherty
+Dooley
+Dorsey
+Dortch
+Doughty
+Dove
+Dowd
+Dowling
+Drescher
+Drucker
+Dryer
+Dryver
+Duckworth
+Dunbar
+Dunham
+Dunn
+Duston
+Dettweiler
+Dyson
+Eason
+Eaton
+Ebert
+Eckhoff
+Edelman
+Edmonds
+Eichhorn
+Eisbach
+Elders
+Elias
+Elijah
+Elizabeth
+Elliott
+Elliston
+Elms
+Emerson
+Engelberg
+Engle
+Eplett
+Epp
+Erickson
+Estades
+Etezadi
+Evans
+Ewing
+Fair
+Farfan
+Fargason
+Farhat
+Farry
+Fawcett
+Faye
+Federle
+Felcher
+Feldman
+Ferguson
+Fergusson
+Fernandez
+Ferrer
+Fine
+Fineman
+Fisher
+Flanagan
+Flathmann
+Fleming
+Fletcher
+Folk
+Fortune
+Fossati
+Foster
+Foulston
+Fowler
+Fox
+Francis
+Frantom
+Franz
+Frazer
+Fredericks
+Frey
+Freymann
+Fuentes
+Fuller
+Fundling
+Furlong
+Gainer
+Galang
+Galeazzi
+Gamse
+Gannaway
+Garcia
+Gardner
+Garneau
+Gartler
+Garverick
+Garza
+Gatt
+Gattis
+Gayman
+Geiger
+Gelder
+George
+Gerbino
+Gerbode
+Gibson
+Gifford
+Gillespie
+Gillingham
+Gilpin
+Gilyot
+Girgis
+Gjertsen
+Glantz
+Glaze
+Glenn
+Glotzbach
+Gobble
+Gockenbach
+Goff
+Goffin
+Golden
+Goldwyn
+Gomez
+Gonzalez
+Good
+Graham
+Gramm
+Granlund
+Grant
+Gray
+Grayson
+Greene
+Greenslade
+Greenwood
+Greer
+Griffin
+Grinstein
+Grisham
+Gross
+Grove
+Guthrie
+Guyton
+Haas
+Hackney
+Haddock
+Hagelstein
+Hagen
+Haggard
+Haines
+Hale
+Haley
+Hall
+Halladay
+Hamill
+Hamilton
+Hammer
+Hancock
+Hane
+Hansen
+Harding
+Harless
+Harms
+Harper
+Harrigan
+Harris
+Harrison
+Hart
+Harton
+Hartz
+Harvey
+Hastings
+Hauenstein
+Haushalter
+Haven
+Hawes
+Hawkins
+Hawley
+Haygood
+Haylock
+Hazard
+Heath
+Heidel
+Heins
+Hellums
+Hendricks
+Henry
+Henson
+Herbert
+Herman
+Hernandez
+Herrera
+Hertzmann
+Hewitt
+Hightower
+Hildebrand
+Hill
+Hindman
+Hirasaki
+Hirsh
+Hochman
+Hocker
+Hoffman
+Hoffmann
+Holder
+Holland
+Holloman
+Holstein
+Holt
+Holzer
+Honeyman
+Hood
+Hooks
+Hopper
+Horne
+House
+Houston
+Howard
+Howell
+Howley
+Huang
+Hudgings
+Huffman
+Hughes
+Humphrey
+Hunt
+Hunter
+Hurley
+Huston
+Hutchinson
+Hyatt
+Irving
+Jacobs
+Jaramillo
+Jaranson
+Jarboe
+Jarrell
+Jenkins
+Johnson
+Johnston
+Jones
+Joy
+Juette
+Julicher
+Jumper
+Kabir
+Kamberova
+Kamen
+Kamine
+Kampe
+Kane
+Kang
+Kapetanovic
+Kargatis
+Karlin
+Karlsson
+Kasbekar
+Kasper
+Kastensmidt
+Katz
+Kauffman
+Kavanagh
+Kaydos
+Kearsley
+Keleher
+Kelly
+Kelty
+Kendrick
+Key
+Kicinski
+Kiefer
+Kielt
+Kim
+Kimmel
+Kincaid
+King
+Kinney
+Kipp
+Kirby
+Kirk
+Kirkland
+Kirkpatrick
+Klamczynski
+Klein
+Kopnicky
+Kotsonis
+Koutras
+Kramer
+Kremer
+Krohn
+Kuhlken
+Kunitz
+LaLonde
+LaValle
+LaWare
+Lacy
+Lam
+Lamb
+Lampkin
+Lane
+Langston
+Lanier
+Larsen
+Lassiter
+Latchford
+Lawera
+LeBlanc
+LeGrand
+Leatherbury
+Lebron
+Ledman
+Lee
+Leinenbach
+Leslie
+Levy
+Lewis
+Lichtenstein
+Lisowski
+Liston
+Litvak
+Llano-Restrepo
+Lloyd
+Lock
+Lodge
+Logan
+Lomonaco
+Long
+Lopez
+Lopez-Bassols
+Loren
+Loughridge
+Love
+Ludtke
+Luers
+Lukes
+Luxemburg
+MacAllister
+MacLeod
+Mackey
+Maddox
+Magee
+Mallinson
+Mann
+Manning
+Manthos
+Marie
+Marrow
+Marshall
+Martin
+Martinez
+Martisek
+Massey
+Mathis
+Matt
+Maxwell
+Mayer
+Mazurek
+McAdams
+McAfee
+McAlexander
+McBride
+McCarthy
+McClure
+McCord
+McCoy
+McCrary
+McCrossin
+McDonald
+McElfresh
+McFarland
+McGarr
+McGhee
+McGoldrick
+McGrath
+McGuire
+McKinley
+McMahan
+McMahon
+McMath
+McNally
+Mcdonald
+Meade
+Meador
+Mebane
+Medrano
+Melton
+Merchant
+Merwin
+Millam
+Millard
+Miller
+Mills
+Milstead
+Minard
+Miner
+Minkoff
+Minnotte
+Minyard
+Mirza
+Mitchell
+Money
+Monk
+Montgomery
+Monton
+Moore
+Moren
+Moreno
+Morris
+Morse
+Moss
+Moyer
+Mueller
+Mull
+Mullet
+Mullins
+Munn
+Murdock
+Murphey
+Murphy
+Murray
+Murry
+Mutchler
+Myers
+Myrick
+Nassar
+Nathan
+Nazzal
+Neal
+Nederveld
+Nelson
+Nguyen
+Nichols
+Nielsen
+Nockton
+Nolan
+Noonan
+Norbury
+Nordlander
+Norris
+Norvell
+Noyes
+Nugent
+Nunn
+O'Brien
+O'Connell
+O'Neill
+O'Steen
+Ober
+Odegard
+Oliver
+Ollmann
+Olson
+Ongley
+Ordway
+Ortiz
+Ouellette
+Overcash
+Overfelt
+Overley
+Owens
+Page
+Paige
+Pardue
+Parham
+Parker
+Parks
+Patterson
+Patton
+Paul
+Payne
+Peck
+Penisson
+Percer
+Perez
+Perlioni
+Perrino
+Peterman
+Peters
+Pfeiffer
+Phelps
+Philip
+Philippe
+Phillips
+Pickett
+Pippenger
+Pistole
+Platzek
+Player
+Poddar
+Poirier
+Poklepovic
+Polk
+Polking
+Pond
+Popish
+Porter
+Pound
+Pounds
+Powell
+Powers
+Prado
+Preston
+Price
+Prichep
+Priour
+Prischmann
+Pryor
+Puckett
+Raglin
+Ralston
+Rampersad
+Ratner
+Rawles
+Ray
+Read
+Reddy
+Reed
+Reese
+Reeves
+Reichenbach
+Reifel
+Rein
+Reiten
+Reiter
+Reitmeier
+Reynolds
+Richardson
+Rider
+Rhinehart
+Ritchie
+Rittenbach
+Roberts
+Robinson
+Rodriguez
+Rogers
+Roper
+Rosemblun
+Rosen
+Rosenberg
+Rosenblatt
+Ross
+Roth
+Rowatt
+Roy
+Royston
+Rozendal
+Rubble
+Ruhlin
+Rupert
+Russell
+Ruthruff
+Ryan
+Rye
+Sabry
+Sachitano
+Sachs
+Sammartino
+Sands
+Saunders
+Savely
+Scales
+Schaefer
+Schafer
+Scheer
+Schild
+Schlitt
+Schmitz
+Schneider
+Schoenberger
+Schoppe
+Scott
+Seay
+Segura
+Selesnick
+Self
+Seligmann
+Sewall
+Shami
+Shampine
+Sharp
+Shaw
+Shefelbine
+Sheldon
+Sherrill
+Shidle
+Shifley
+Shillingsburg
+Shisler
+Shopbell
+Shupack
+Sievert
+Simpson
+Sims
+Sissman
+Smayling
+Smith
+Snyder
+Solomon
+Solon
+Soltero
+Sommers
+Sonneborn
+Sorensen
+Southworth
+Spear
+Speight
+Spencer
+Spruell
+Spudich
+Stacy
+Staebel
+Steele
+Steinhour
+Steinke
+Stepp
+Stevens
+Stewart
+Stickel
+Stine
+Stivers
+Stobb
+Stone
+Stratmann
+Stubbers
+Stuckey
+Stugart
+Sullivan
+Sultan
+Sumrall
+Sunley
+Sunshine
+Sutton
+Swaim
+Swales
+Sweed
+Swick
+Swift
+Swindell
+Swint
+Symonds
+Syzdek
+Szafranski
+Takimoto
+Talbott
+Talwar
+Tanner
+Taslimi
+Tate
+Tatum
+Taylor
+Tchainikov
+Terk
+Thacker
+Thomas
+Thompson
+Thomson
+Thornton
+Thurman
+Thurow
+Tilley
+Tolle
+Towns
+Trafton
+Tran
+Trevas
+Trevino
+Triggs
+Truchard
+Tunison
+Turner
+Twedell
+Tyler
+Tyree
+Unger
+Van
+Vanderzanden
+Vanlandingham
+Varanasi
+Varela
+Varman
+Venier
+Verspoor
+Vick
+Visinsky
+Voltz
+Wagner
+Wake
+Walcott
+Waldron
+Walker
+Wallace
+Walters
+Walton
+Ward
+Wardle
+Warnes
+Warren
+Washington
+Watson
+Watters
+Webber
+Weidenfeller
+Weien
+Weimer
+Weiner
+Weinger
+Weinheimer
+Weirich
+Welch
+Wells
+Wendt
+West
+Westmoreland
+Wex
+Whitaker
+White
+Whitley
+Wiediger
+Wilburn
+Williams
+Williamson
+Willman
+Wilson
+Winger
+Wise
+Wisur
+Witt
+Wong
+Woodbury
+Wooten
+Workman
+Wright
+Wyatt
+Yates
+Yeamans
+Yen
+York
+Yotov
+Younan
+Young
+Zeldin
+Zettner
+Ziegler
+Zitterkopf
+Zucker
diff --git a/examples/declarative/tutorials/contacts/shared/pics/cancel.png b/examples/declarative/tutorials/contacts/shared/pics/cancel.png
new file mode 100644
index 0000000..ecc9533
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/cancel.png
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/pics/email.png b/examples/declarative/tutorials/contacts/shared/pics/email.png
new file mode 100644
index 0000000..04b3865
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/email.png
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/pics/new.png b/examples/declarative/tutorials/contacts/shared/pics/new.png
new file mode 100644
index 0000000..c7ebac3
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/new.png
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/pics/ok.png b/examples/declarative/tutorials/contacts/shared/pics/ok.png
new file mode 100644
index 0000000..5795f04
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/ok.png
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/pics/phone.png b/examples/declarative/tutorials/contacts/shared/pics/phone.png
new file mode 100644
index 0000000..fc9c222
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/phone.png
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/pics/search.png b/examples/declarative/tutorials/contacts/shared/pics/search.png
new file mode 100644
index 0000000..cc74e69
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/search.png
Binary files differ
diff --git a/examples/declarative/tutorials/contacts/shared/pics/trash.png b/examples/declarative/tutorials/contacts/shared/pics/trash.png
new file mode 100644
index 0000000..2042595
--- /dev/null
+++ b/examples/declarative/tutorials/contacts/shared/pics/trash.png
Binary files differ
diff --git a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml
new file mode 100644
index 0000000..f09dcd1
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ width: 480
+ height: 200
+ color: "LightGrey"
+ Text {
+ id: HelloText
+ text: "Hello world!"
+ font.pointSize: 24
+ font.bold: true
+ y: 30
+ anchors.horizontalCenter: Page.horizontalCenter
+ }
+}
diff --git a/examples/declarative/tutorials/helloworld/t2/Cell.qml b/examples/declarative/tutorials/helloworld/t2/Cell.qml
new file mode 100644
index 0000000..b3c52b7
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/t2/Cell.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+
+Item {
+ property var color
+
+ id: CellContainer
+ width: 40
+ height: 25
+
+ Rectangle {
+ anchors.fill: parent
+ color: CellContainer.color
+ }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { HelloText.color = CellContainer.color }
+ }
+}
diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml
new file mode 100644
index 0000000..458e302
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ width: 480
+ height: 200
+ color: "LightGrey"
+ Text {
+ id: HelloText
+ text: "Hello world!"
+ font.pointSize: 24
+ font.bold: true
+ y: 30
+ anchors.horizontalCenter: Page.horizontalCenter
+ }
+ Grid {
+ id: ColorPicker
+ x: 0
+ anchors.bottom: Page.bottom
+ width: 120; height: 50
+ rows: 2; columns: 3
+ Cell { color: "#ff0000" }
+ Cell { color: "#00ff00" }
+ Cell { color: "#0000ff" }
+ Cell { color: "#ffff00" }
+ Cell { color: "#00ffff" }
+ Cell { color: "#ff00ff" }
+ }
+}
diff --git a/examples/declarative/tutorials/helloworld/t3/Cell.qml b/examples/declarative/tutorials/helloworld/t3/Cell.qml
new file mode 100644
index 0000000..4b1a220
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/t3/Cell.qml
@@ -0,0 +1,17 @@
+import Qt 4.6
+
+Item {
+ property var color
+
+ id: CellContainer
+ width: 40
+ height: 25
+ Rectangle {
+ anchors.fill: parent
+ color: CellContainer.color
+ }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: { HelloText.color = CellContainer.color }
+ }
+}
diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml
new file mode 100644
index 0000000..81e1f6a
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml
@@ -0,0 +1,56 @@
+import Qt 4.6
+
+Rectangle {
+ id: Page
+ width: 480
+ height: 200
+ color: "LightGrey"
+ Text {
+ id: HelloText
+ text: "Hello world!"
+ font.pointSize: 24
+ font.bold: true
+ y: 30
+ anchors.horizontalCenter: Page.horizontalCenter
+ states: [
+ State {
+ name: "down"
+ when: MouseRegion.pressed == true
+ PropertyChanges {
+ target: HelloText
+ y: 160
+ color: "red"
+ }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "down"
+ reversible: true
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "y"
+ duration: 500
+ easing: "easeOutBounce"
+ }
+ ColorAnimation { property: "color"; duration: 500 }
+ }
+ }
+ ]
+ }
+ MouseRegion { id: MouseRegion; anchors.fill: HelloText }
+ Grid {
+ id: ColorPicker
+ x: 0
+ anchors.bottom: Page.bottom
+ width: 120; height: 50
+ rows: 2; columns: 3
+ Cell { color: "#ff0000" }
+ Cell { color: "#00ff00" }
+ Cell { color: "#0000ff" }
+ Cell { color: "#ffff00" }
+ Cell { color: "#00ffff" }
+ Cell { color: "#ff00ff" }
+ }
+}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
new file mode 100644
index 0000000..06d0bd4
--- /dev/null
+++ b/examples/declarative/velocity/Day.qml
@@ -0,0 +1,112 @@
+import Qt 4.6
+
+Rectangle {
+ property string day
+ property var stickies
+
+ width: 400
+ height: 500
+ radius: 7
+ border.color: "black"
+ id: Page
+ Image {
+ x: 10
+ y: 10
+ source: "cork.jpg"
+ }
+ Text {
+ x: 20
+ y: 20
+ height: 40
+ font.pointSize: 14
+ font.bold: true
+ width: 370
+ text: day
+ style: Outline
+ styleColor: "#dedede"
+ }
+ Repeater {
+ model: Page.stickies
+ Item {
+ x: Math.random() * 200 + 100
+ y: Math.random() * 300 + 50
+ id: StickyPage
+ rotation: Follow {
+ source: -Flick.horizontalVelocity / 100
+ spring: 2.0
+ damping: 0.1
+ }
+ Item {
+ id: Sticky
+ scale: 0.5
+ Image {
+ id: StickyImage
+ source: "sticky.png"
+ smooth: true
+ y: -20
+ x: 8 + -width * 0.6 / 2
+ scale: 0.6
+ }
+ TextEdit {
+ id: MyText
+ smooth: true
+ font.pointSize: 28
+ readOnly: false
+ x: -104
+ y: 36
+ wrap: true
+ rotation: -8
+ text: noteText
+ width: 195
+ height: 172
+ }
+ Item {
+ y: -20
+ x: StickyImage.x
+ width: StickyImage.width * StickyImage.scale
+ height: StickyImage.height * StickyImage.scale
+ MouseRegion {
+ id: Mouse
+ onClicked: { MyText.focus = true }
+ anchors.fill: parent
+ drag.target: StickyPage
+ drag.axis: "XandYAxis"
+ drag.minimumY: 0
+ drag.maximumY: 500
+ drag.minimumX: 0
+ drag.maximumX: 400
+ }
+ }
+ }
+ Image {
+ source: "tack.png"
+ x: -width / 2
+ y: -height * 0.7 / 2
+ scale: 0.7
+ }
+ 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/declarative/velocity/cork.jpg b/examples/declarative/velocity/cork.jpg
new file mode 100644
index 0000000..d4d706c
--- /dev/null
+++ b/examples/declarative/velocity/cork.jpg
Binary files differ
diff --git a/examples/declarative/velocity/sticky.png b/examples/declarative/velocity/sticky.png
new file mode 100644
index 0000000..73df3cd
--- /dev/null
+++ b/examples/declarative/velocity/sticky.png
Binary files differ
diff --git a/examples/declarative/velocity/tack.png b/examples/declarative/velocity/tack.png
new file mode 100644
index 0000000..cef2d1c
--- /dev/null
+++ b/examples/declarative/velocity/tack.png
Binary files differ
diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml
new file mode 100644
index 0000000..8ac42e1
--- /dev/null
+++ b/examples/declarative/velocity/velocity.qml
@@ -0,0 +1,115 @@
+import Qt 4.6
+
+Rectangle {
+ color: "lightSteelBlue"
+ width: 800
+ height: 600
+ ListModel {
+ id: List
+ ListElement {
+ name: "Sunday"
+ dayColor: "#808080"
+ notes: [
+ ListElement {
+ noteText: "Lunch"
+ },
+ ListElement {
+ noteText: "Party"
+ }
+ ]
+ }
+ ListElement {
+ name: "Monday"
+ dayColor: "blue"
+ notes: [
+ ListElement {
+ noteText: "Pickup kids"
+ },
+ ListElement {
+ noteText: "Checkout kinetic"
+ },
+ ListElement {
+ noteText: "Read email"
+ }
+ ]
+ }
+ ListElement {
+ name: "Tuesday"
+ dayColor: "yellow"
+ notes: [
+ ListElement {
+ noteText: "Walk dog"
+ },
+ ListElement {
+ noteText: "Buy newspaper"
+ }
+ ]
+ }
+ ListElement {
+ name: "Wednesday"
+ dayColor: "purple"
+ notes: [
+ ListElement {
+ noteText: "Cook dinner"
+ },
+ ListElement {
+ noteText: "Eat dinner"
+ }
+ ]
+ }
+ ListElement {
+ name: "Thursday"
+ dayColor: "blue"
+ notes: [
+ ListElement {
+ noteText: "5:30pm Meeting"
+ },
+ ListElement {
+ noteText: "Weed garden"
+ }
+ ]
+ }
+ ListElement {
+ name: "Friday"
+ dayColor: "green"
+ notes: [
+ ListElement {
+ noteText: "Still work"
+ },
+ ListElement {
+ noteText: "Drink"
+ }
+ ]
+ }
+ ListElement {
+ name: "Saturday"
+ dayColor: "orange"
+ notes: [
+ ListElement {
+ noteText: "Drink"
+ },
+ ListElement {
+ noteText: "Drink"
+ }
+ ]
+ }
+ }
+ Flickable {
+ id: Flick
+ anchors.fill: parent
+ viewportWidth: Lay.width
+ Row {
+ id: Lay
+ Repeater {
+ model: List
+ Component {
+ Day {
+ day: name
+ color: dayColor
+ stickies: notes
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml
new file mode 100644
index 0000000..dbd94e1
--- /dev/null
+++ b/examples/declarative/webview/autosize.qml
@@ -0,0 +1,61 @@
+import Qt 4.6
+
+// The WebView size is determined by the width, height,
+// preferredWidth, and preferredHeight properties.
+Rectangle {
+ id: Rect
+ color: "white"
+ width: 200
+ height: Layout.height
+ Column {
+ id: Layout
+ spacing: 2
+ WebView {
+ html: "No width defined."
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ }
+ }
+ WebView {
+ width: Rect.width
+ html: "The width is full."
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ }
+ }
+ WebView {
+ width: Rect.width/2
+ html: "The width is half."
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ }
+ }
+ WebView {
+ preferredWidth: Rect.width/2
+ html: "The preferredWidth is half."
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ }
+ }
+ WebView {
+ preferredWidth: Rect.width/2
+ html: "The_preferredWidth_is_half."
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ }
+ }
+ WebView {
+ width: Rect.width/2
+ html: "The_width_is_half."
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ }
+ }
+ }
+}
diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml
new file mode 100644
index 0000000..fe55185
--- /dev/null
+++ b/examples/declarative/webview/content/FieldText.qml
@@ -0,0 +1,163 @@
+import Qt 4.6
+
+Item {
+ id: fieldText
+ height: 30
+ property string text: ""
+ property string label: ""
+ property bool mouseGrabbed: false
+ signal confirmed
+ signal cancelled
+ signal startEdit
+
+ resources: [
+ Script {
+
+ function edit() {
+ if (!mouseGrabbed) {
+ fieldText.startEdit();
+ fieldText.state='editing';
+ mouseGrabbed=true;
+ }
+ }
+
+ function confirm() {
+ fieldText.state='';
+ fieldText.text = textEdit.text;
+ mouseGrabbed=false;
+ fieldText.confirmed();
+ }
+
+ function reset() {
+ textEdit.text = fieldText.text;
+ fieldText.state='';
+ mouseGrabbed=false;
+ fieldText.cancelled();
+ }
+
+ }
+ ]
+
+ Image {
+ id: cancelIcon
+ width: 22
+ height: 22
+ anchors.right: parent.right
+ anchors.rightMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "pics/cancel.png"
+ opacity: 0
+ }
+
+ Image {
+ id: confirmIcon
+ width: 22
+ height: 22
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ anchors.verticalCenter: parent.verticalCenter
+ source: "pics/ok.png"
+ opacity: 0
+ }
+
+ TextInput {
+ id: textEdit
+ text: fieldText.text
+ focus: false
+ anchors.left: parent.left
+ anchors.leftMargin: 0
+ anchors.right: parent.right
+ anchors.rightMargin: 0
+ anchors.verticalCenter: parent.verticalCenter
+ color: "black"
+ font.bold: true
+ readOnly: true
+ onAccepted: confirm()
+ Keys.onEscapePressed: reset()
+ }
+
+ Text {
+ id: textLabel
+ x: 5
+ width: parent.width-10
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: "AlignHCenter"
+ color: fieldText.state == "editing" ? "#505050" : "#AAAAAA"
+ font.italic: true
+ font.bold: true
+ text: label
+ opacity: textEdit.text == '' ? 1 : 0
+ opacity: Behavior {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+
+ MouseRegion {
+ anchors.fill: cancelIcon
+ onClicked: { reset() }
+ }
+
+ MouseRegion {
+ anchors.fill: confirmIcon
+ onClicked: { confirm() }
+ }
+
+ MouseRegion {
+ id: editRegion
+ anchors.fill: textEdit
+ onClicked: { edit() }
+ }
+
+ states: [
+ State {
+ name: "editing"
+ PropertyChanges {
+ target: confirmIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: cancelIcon
+ opacity: 1
+ }
+ PropertyChanges {
+ target: textEdit
+ color: "black"
+ readOnly: false
+ focus: true
+ selectionStart: 0
+ selectionEnd: -1
+ }
+ PropertyChanges {
+ target: editRegion
+ opacity: 0
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ leftMargin: 34
+ }
+ PropertyChanges {
+ target: textEdit.anchors
+ rightMargin: 34
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: ""
+ to: "*"
+ reversible: true
+ NumberAnimation {
+ properties: "opacity,leftMargin,rightMargin"
+ duration: 200
+ }
+ ColorAnimation {
+ property: "color"
+ duration: 150
+ }
+ }
+ ]
+}
diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml
new file mode 100644
index 0000000..95159b6
--- /dev/null
+++ b/examples/declarative/webview/content/SpinSquare.qml
@@ -0,0 +1,26 @@
+import Qt 4.6
+
+Item {
+ property var period : 250
+ property var color : "black"
+ id: Root
+
+ Item {
+ x: Root.width/2
+ y: Root.height/2
+ Rectangle {
+ color: Root.color
+ x: -width/2
+ y: -height/2
+ width: Root.width
+ height: width
+ }
+ rotation: NumberAnimation {
+ from: 0
+ to: 360
+ repeat: true
+ running: true
+ duration: Root.period
+ }
+ }
+}
diff --git a/examples/declarative/webview/content/pics/cancel.png b/examples/declarative/webview/content/pics/cancel.png
new file mode 100644
index 0000000..ecc9533
--- /dev/null
+++ b/examples/declarative/webview/content/pics/cancel.png
Binary files differ
diff --git a/examples/declarative/webview/content/pics/ok.png b/examples/declarative/webview/content/pics/ok.png
new file mode 100644
index 0000000..5795f04
--- /dev/null
+++ b/examples/declarative/webview/content/pics/ok.png
Binary files differ
diff --git a/examples/declarative/webview/evalandattach.html b/examples/declarative/webview/evalandattach.html
new file mode 100644
index 0000000..c0992bb
--- /dev/null
+++ b/examples/declarative/webview/evalandattach.html
@@ -0,0 +1,31 @@
+<body bgcolor=gray onload="ftext.confirmed.connect (ftext_confirmed); ">
+ <script>
+ do_it = function () {var oPressed = document.getElementById('pressed');
+ oPressed.innerHTML = 'MouseRegion in QML clicked!';};
+ ftext_confirmed = function () { statusText1.text = ftext.text; var oT = document.getElementById('htmlTextInput'); oT.value = ftext.text }
+ </script>
+ <table border=1>
+ <tr>
+ <td>&nbsp</td>
+ <td id='pressed'></td>
+ </tr>
+ <tr>
+ <td><label for='htmlTextInput'>Type something:</label></td>
+ <td><input type='text' name='htmlTextInput' size='25' id='htmlTextInput'
+ onfocus="statusText2.text = 'Focus in html text input.'"></td>
+ </tr>
+ <tr>
+ <td><label for='htmlButton'>&nbsp;</label></td>
+ <td>
+ <input type='button' id='htmlButton' value='Push'
+ onclick="var oText = document.getElementById('htmlTextInput'); statusText1.text = oText.value; ftext.text = oText.value" />
+ </tr>
+ </table>
+ <p>
+ Below a qml(QFxItem) object inside webkit:
+ </p>
+ <object data=content/FieldText.qml TYPE=application/x-qt-plugin id="ftext_id" text="" label="Cool:" width="200"
+ objectname="ftext">
+ </object>
+</body>
+
diff --git a/examples/declarative/webview/evalandattach.qml b/examples/declarative/webview/evalandattach.qml
new file mode 100644
index 0000000..e755819
--- /dev/null
+++ b/examples/declarative/webview/evalandattach.qml
@@ -0,0 +1,54 @@
+import Qt 4.6
+
+Item {
+ height: 640
+ width: 360
+ Text {
+ id: teksti
+ text: webView.statusText1
+ anchors.top: parent.top
+ height: 30
+ anchors.left: parent.left
+ width: parent.width/2
+ }
+
+ Text {
+ id: teksti2
+ text: webView.statusText2
+ anchors.top: parent.top
+ height: 30
+ anchors.left: teksti.right
+ anchors.right: parent.right
+ }
+
+ MouseRegion {
+ anchors.fill: teksti
+ onClicked: { webView.evaluateJavaScript ("do_it()") }
+ }
+
+ WebView {
+ id: webView
+ property alias statusText1: txt.text
+ property alias statusText2: txt2.text
+ anchors.top: teksti.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ focus: true
+ settings.pluginsEnabled: true
+ javaScriptWindowObjects: [
+ Object {
+ id: txt
+ WebView.windowObjectName: "statusText1"
+ property string text: "Click me!"
+ },
+ Object {
+ id: txt2
+ WebView.windowObjectName: "statusText2"
+ property string text: ""
+ }
+ ]
+ url: "evalandattach.html"
+ }
+
+}
diff --git a/examples/declarative/webview/inline-html.qml b/examples/declarative/webview/inline-html.qml
new file mode 100644
index 0000000..23b4555
--- /dev/null
+++ b/examples/declarative/webview/inline-html.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+// Inline HTML with loose formatting can be
+// set on the html property.
+WebView {
+ html:"\
+ <body bgcolor=white>\
+ <table border=1>\
+ <tr><th><th>One<th>Two<th>Three\
+ <tr><th>1<td>X<td>1<td>X\
+ <tr><th>2<td>0<td>X<td>0\
+ <tr><th>3<td>X<td>1<td>X\
+ </table>"
+}
diff --git a/examples/declarative/webview/newwindows.html b/examples/declarative/webview/newwindows.html
new file mode 100644
index 0000000..f169599
--- /dev/null
+++ b/examples/declarative/webview/newwindows.html
@@ -0,0 +1,3 @@
+<h1>Multiple windows...</h1>
+
+<a target="_blank" href="newwindows.html">Popup!</a>
diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml
new file mode 100644
index 0000000..9ff902e2
--- /dev/null
+++ b/examples/declarative/webview/newwindows.qml
@@ -0,0 +1,28 @@
+// Demonstrates opening new WebViews from HTML
+//
+// Note that to open windows from JavaScript, you will need to
+// allow it on WebView with settings.javascriptCanOpenWindows: true
+
+import Qt 4.6
+
+Row {
+ id: Pages
+ height: 200
+ resources: [
+ Component {
+ id: WebViewPage
+ Rectangle {
+ width: WV.width
+ height: WV.height
+ WebView {
+ id: WV
+ newWindowComponent: WebViewPage
+ newWindowParent: Pages
+ url: "newwindows.html"
+ }
+ }
+ }
+ ]
+ width: 500
+ ComponentInstance { component: WebViewPage }
+}
diff --git a/examples/declarative/webview/qml-in-html.qml b/examples/declarative/webview/qml-in-html.qml
new file mode 100644
index 0000000..b9c8d94
--- /dev/null
+++ b/examples/declarative/webview/qml-in-html.qml
@@ -0,0 +1,32 @@
+import Qt 4.6
+
+// The WebView supports QML data through the HTML OBJECT tag
+Rectangle {
+ color:"blue"
+ Flickable {
+ width: parent.width
+ height: parent.height/2
+ viewportWidth: Web.width*Web.scale
+ viewportHeight: Web.height*Web.scale
+ WebView {
+ id: Web
+ width: 250
+ height: 420
+ scale: 0.75
+ smooth: true
+ settings.pluginsEnabled: true
+ html: "<html>\
+ <body bgcolor=white>\
+ These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75%\
+ and placed in a Flickable area...\
+ <table border=1>\
+ <tr><th>Duration <th>Color <th>Plugin\
+ <tr><td>500 <td>red <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=500 color=red />\
+ <tr><td>2000 <td>blue <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=2000 color=blue />\
+ <tr><td>1000 <td>green <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=1000 color=green />\
+ </table>\
+ </body>\
+ </html>"
+ }
+ }
+}
diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml
new file mode 100644
index 0000000..0807cc5
--- /dev/null
+++ b/examples/declarative/webview/transparent.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+// The WebView background is transparent
+// if the HTML does not specify a background
+Rectangle {
+ color: "green"
+ width: Web.width
+ height: Web.height
+ WebView {
+ id: Web
+ html: "Hello <b>World!</b>"
+ }
+}
diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml
new file mode 100644
index 0000000..e0e53ef
--- /dev/null
+++ b/examples/declarative/xmldata/daringfireball.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 600
+ height: 600
+ resources: [
+ XmlListModel {
+ id: feedModel
+ source: "http://daringfireball.net/index.xml"
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+ XmlRole {
+ name: "title"
+ query: "title/string()"
+ }
+ XmlRole {
+ name: "tagline"
+ query: "author/name/string()"
+ }
+ XmlRole {
+ name: "content"
+ query: "content/string()"
+ }
+ },
+ Component {
+ id: feedDelegate
+ Item {
+ height: childrenRect.height + 20
+ Text {
+ x: 10
+ id: TitleText
+ text: title
+ font.bold: true
+ }
+ Text {
+ text: 'by ' + tagline
+ anchors.left: TitleText.right
+ anchors.leftMargin: 10
+ font.italic: true
+ }
+ Text {
+ x: 10
+ text: content
+ anchors.top: TitleText.bottom
+ width: 580
+ wrap: true
+ onLinkActivated: { print('link clicked: ' + link) }
+ }
+ }
+ }
+ ]
+ ListView {
+ id: list
+ anchors.fill: parent
+ clip: true
+ model: feedModel
+ delegate: feedDelegate
+ }
+}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
new file mode 100644
index 0000000..6395284
--- /dev/null
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -0,0 +1,106 @@
+import Qt 4.6
+
+Rectangle {
+ gradient: Gradient {
+ GradientStop { position: 0; color: "black" }
+ GradientStop { position: 1.0; color: "#AAAAAA" }
+ }
+ width: 600
+ height: 600
+ resources: [
+ XmlListModel {
+ id: feedModel
+ source: "http://rss.news.yahoo.com/rss/oceania"
+ query: "/rss/channel/item"
+ XmlRole {
+ name: "title"
+ query: "title/string()"
+ }
+ XmlRole {
+ name: "link"
+ query: "link/string()"
+ }
+ XmlRole {
+ name: "description"
+ query: "description/string()"
+ }
+ },
+ Component {
+ id: feedDelegate
+ Item {
+ id: Delegate
+ height: Wrapper.height + 10
+ MouseRegion {
+ anchors.fill: Wrapper
+ onPressed: { Delegate.ListView.list.currentIndex = index; }
+ onClicked: { if (Wrapper.state == 'Details') { Wrapper.state = '';} else {Wrapper.state = 'Details';} }
+ }
+ Rectangle {
+ id: Wrapper
+ y: 5
+ height: TitleText.height + 10
+ width: 580
+ color: "#F0F0F0"
+ radius: 5
+ Text {
+ x: 10
+ y: 5
+ id: TitleText
+ text: '<a href=\'' + link + '\'>' + title + '</a>'
+ font.bold: true
+ font.family: "Helvetica"
+ font.pointSize: 14
+ onLinkActivated: { print('link clicked: ' + link) }
+ }
+ Text {
+ x: 10
+ id: Description
+ text: description
+ width: 560
+ wrap: true
+ font.family: "Helvetica"
+ anchors.top: TitleText.bottom
+ anchors.topMargin: 5
+ opacity: 0
+ }
+ states: [
+ State {
+ name: "Details"
+ PropertyChanges { target: Wrapper; height: childrenRect.height + 10 }
+ PropertyChanges { target: Description; opacity: 1 }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "Details"
+ reversible: true
+ SequentialAnimation {
+ NumberAnimation {
+ duration: 200
+ properties: "height"
+ easing: "easeOutQuad"
+ }
+ NumberAnimation {
+ duration: 200
+ properties: "opacity"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ ListView {
+ id: list
+ x: 10
+ y: 10
+ width: parent.width - 20
+ height: parent.height - 20
+ clip: true
+ model: feedModel
+ delegate: feedDelegate
+ currentItemPositioning: "Snap"
+ }
+}
diff --git a/examples/examples.pro b/examples/examples.pro
index 7acd67b..4f4105b 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -22,6 +22,7 @@ SUBDIRS = \
tutorials \
widgets \
uitools \
+ declarative \
xml \
multitouch \
gestures