summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-03-30 14:56:41 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-03-30 14:56:41 (GMT)
commit87f66d52e362de003a9f2cdaafbfbe3ba4e5fbc3 (patch)
treef8b8c24056d54e19937dea1b0301af558597726a /examples
parent09ce407aaa4a00013a606bf0011faf6cbc654c72 (diff)
parent00f7426f3906361fb5addb36e428648eee5e2983 (diff)
downloadQt-87f66d52e362de003a9f2cdaafbfbe3ba4e5fbc3.zip
Qt-87f66d52e362de003a9f2cdaafbfbe3ba4e5fbc3.tar.gz
Qt-87f66d52e362de003a9f2cdaafbfbe3ba4e5fbc3.tar.bz2
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Conflicts: doc/src/modules.qdoc mkspecs/common/symbian/symbian.conf src/gui/graphicsview/qgraphicswidget.h src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtGuiu.def
Diffstat (limited to 'examples')
-rw-r--r--examples/assistant/README38
-rw-r--r--examples/assistant/assistant.pro10
-rw-r--r--examples/assistant/simpletextviewer/documentation/about.txt9
-rw-r--r--examples/assistant/simpletextviewer/documentation/browse.html34
-rw-r--r--examples/assistant/simpletextviewer/documentation/filedialog.html48
-rw-r--r--examples/assistant/simpletextviewer/documentation/findfile.html32
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/browse.pngbin21553 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.pngbin9589 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/filedialog.pngbin12318 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/handbook.pngbin1060 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/mainwindow.pngbin12769 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/open.pngbin11697 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/images/wildcard.pngbin11266 -> 0 bytes
-rw-r--r--examples/assistant/simpletextviewer/documentation/index.html41
-rw-r--r--examples/assistant/simpletextviewer/documentation/intro.html28
-rw-r--r--examples/assistant/simpletextviewer/documentation/openfile.html36
-rw-r--r--examples/assistant/simpletextviewer/documentation/simpletextviewer.adp40
-rw-r--r--examples/assistant/simpletextviewer/documentation/wildcardmatching.html57
-rw-r--r--examples/assistant/simpletextviewer/findfiledialog.cpp221
-rw-r--r--examples/assistant/simpletextviewer/mainwindow.cpp154
-rw-r--r--examples/assistant/simpletextviewer/simpletextviewer.pro18
-rw-r--r--examples/dbus/dbus-chat/chat_adaptor.cpp6
-rw-r--r--examples/dbus/dbus-chat/chat_adaptor.h24
-rw-r--r--examples/dbus/dbus-chat/chat_interface.cpp6
-rw-r--r--examples/dbus/dbus-chat/chat_interface.h10
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.pro2
-rw-r--r--examples/dbus/remotecontrolledcar/car/car_adaptor.cpp22
-rw-r--r--examples/dbus/remotecontrolledcar/car/car_adaptor.h (renamed from examples/dbus/remotecontrolledcar/car/car_adaptor_p.h)28
-rw-r--r--examples/dbus/remotecontrolledcar/car/main.cpp4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/car_interface.cpp15
-rw-r--r--examples/dbus/remotecontrolledcar/controller/car_interface.h (renamed from examples/dbus/remotecontrolledcar/controller/car_interface_p.h)36
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.cpp4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.h5
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.pro2
-rw-r--r--examples/declarative/animations/color-animation.qml71
-rw-r--r--examples/declarative/animations/easing.qml99
-rw-r--r--examples/declarative/animations/images/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/animations/images/moon.pngbin0 -> 2433 bytes
-rw-r--r--examples/declarative/animations/images/shadow.pngbin0 -> 425 bytes
-rw-r--r--examples/declarative/animations/images/star.pngbin0 -> 349 bytes
-rw-r--r--examples/declarative/animations/images/sun.pngbin0 -> 8153 bytes
-rw-r--r--examples/declarative/animations/property-animation.qml64
-rw-r--r--examples/declarative/aspectratio/face_fit.qml26
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml28
-rw-r--r--examples/declarative/aspectratio/pics/face.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/aspectratio/scale_and_crop.qml21
-rw-r--r--examples/declarative/aspectratio/scale_and_crop_simple.qml20
-rw-r--r--examples/declarative/aspectratio/scale_and_sidecrop.qml22
-rw-r--r--examples/declarative/aspectratio/scale_to_fit.qml22
-rw-r--r--examples/declarative/aspectratio/scale_to_fit_simple.qml20
-rw-r--r--examples/declarative/behaviours/SideRect.qml17
-rw-r--r--examples/declarative/behaviours/behavior-example.qml72
-rw-r--r--examples/declarative/border-image/animated.qml55
-rw-r--r--examples/declarative/border-image/borders.qml18
-rw-r--r--examples/declarative/border-image/content/MyBorderImage.qml37
-rw-r--r--examples/declarative/border-image/content/bw.pngbin0 -> 1357 bytes
-rw-r--r--examples/declarative/border-image/content/colors-round.sci7
-rw-r--r--examples/declarative/border-image/content/colors-stretch.sci5
-rw-r--r--examples/declarative/border-image/content/colors.pngbin0 -> 1655 bytes
-rw-r--r--examples/declarative/clocks/clocks.qml15
-rw-r--r--examples/declarative/clocks/content/Clock.qml80
-rw-r--r--examples/declarative/clocks/content/background.pngbin0 -> 46895 bytes
-rwxr-xr-xexamples/declarative/clocks/content/center.pngbin0 -> 765 bytes
-rwxr-xr-xexamples/declarative/clocks/content/clock-night.pngbin0 -> 23359 bytes
-rwxr-xr-xexamples/declarative/clocks/content/clock.pngbin0 -> 20653 bytes
-rwxr-xr-xexamples/declarative/clocks/content/hour.pngbin0 -> 625 bytes
-rwxr-xr-xexamples/declarative/clocks/content/minute.pngbin0 -> 625 bytes
-rwxr-xr-xexamples/declarative/clocks/content/second.pngbin0 -> 303 bytes
-rw-r--r--examples/declarative/connections/connections-example.qml27
-rw-r--r--examples/declarative/connections/content/Button.qml12
-rw-r--r--examples/declarative/connections/content/bg1.jpgbin0 -> 23771 bytes
-rw-r--r--examples/declarative/connections/content/rotate-left.pngbin0 -> 3061 bytes
-rw-r--r--examples/declarative/connections/content/rotate-right.pngbin0 -> 3115 bytes
-rw-r--r--examples/declarative/declarative.pro49
-rw-r--r--examples/declarative/dial/content/Dial.qml37
-rw-r--r--examples/declarative/dial/content/background.pngbin0 -> 35876 bytes
-rw-r--r--examples/declarative/dial/content/needle.pngbin0 -> 342 bytes
-rw-r--r--examples/declarative/dial/content/needle_shadow.pngbin0 -> 632 bytes
-rw-r--r--examples/declarative/dial/content/overlay.pngbin0 -> 3564 bytes
-rw-r--r--examples/declarative/dial/dial-example.qml35
-rw-r--r--examples/declarative/dynamic/dynamic.qml122
-rw-r--r--examples/declarative/dynamic/images/NOTE1
-rw-r--r--examples/declarative/dynamic/images/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/dynamic/images/moon.pngbin0 -> 1757 bytes
-rw-r--r--examples/declarative/dynamic/images/rabbit_brown.pngbin0 -> 1245 bytes
-rw-r--r--examples/declarative/dynamic/images/rabbit_bw.pngbin0 -> 1759 bytes
-rw-r--r--examples/declarative/dynamic/images/star.pngbin0 -> 349 bytes
-rw-r--r--examples/declarative/dynamic/images/sun.pngbin0 -> 8153 bytes
-rw-r--r--examples/declarative/dynamic/images/tree_s.pngbin0 -> 3406 bytes
-rw-r--r--examples/declarative/dynamic/qml/Button.qml24
-rw-r--r--examples/declarative/dynamic/qml/GenericItem.qml13
-rw-r--r--examples/declarative/dynamic/qml/PaletteItem.qml13
-rw-r--r--examples/declarative/dynamic/qml/PerspectiveItem.qml16
-rw-r--r--examples/declarative/dynamic/qml/Sun.qml24
-rw-r--r--examples/declarative/dynamic/qml/itemCreation.js82
-rw-r--r--examples/declarative/effects/effects.qml60
-rw-r--r--examples/declarative/effects/pic.pngbin0 -> 12933 bytes
-rw-r--r--examples/declarative/extending/adding/adding.pro15
-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.cpp64
-rw-r--r--examples/declarative/extending/adding/person.cpp69
-rw-r--r--examples/declarative/extending/adding/person.h67
-rw-r--r--examples/declarative/extending/attached/attached.pro17
-rw-r--r--examples/declarative/extending/attached/attached.qrc5
-rw-r--r--examples/declarative/extending/attached/birthdayparty.cpp92
-rw-r--r--examples/declarative/extending/attached/birthdayparty.h (renamed from examples/assistant/simpletextviewer/findfiledialog.h)82
-rw-r--r--examples/declarative/extending/attached/example.qml29
-rw-r--r--examples/declarative/extending/attached/main.cpp91
-rw-r--r--examples/declarative/extending/attached/person.cpp119
-rw-r--r--examples/declarative/extending/attached/person.h107
-rw-r--r--examples/declarative/extending/binding/binding.pro19
-rw-r--r--examples/declarative/extending/binding/binding.qrc5
-rw-r--r--examples/declarative/extending/binding/birthdayparty.cpp114
-rw-r--r--examples/declarative/extending/binding/birthdayparty.h105
-rw-r--r--examples/declarative/extending/binding/example.qml37
-rw-r--r--examples/declarative/extending/binding/happybirthday.cpp86
-rw-r--r--examples/declarative/extending/binding/happybirthday.h76
-rw-r--r--examples/declarative/extending/binding/main.cpp93
-rw-r--r--examples/declarative/extending/binding/person.cpp139
-rw-r--r--examples/declarative/extending/binding/person.h115
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.cpp72
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h71
-rw-r--r--examples/declarative/extending/coercion/coercion.pro17
-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.cpp78
-rw-r--r--examples/declarative/extending/coercion/person.cpp80
-rw-r--r--examples/declarative/extending/coercion/person.h81
-rw-r--r--examples/declarative/extending/default/birthdayparty.cpp72
-rw-r--r--examples/declarative/extending/default/birthdayparty.h72
-rw-r--r--examples/declarative/extending/default/default.pro17
-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.cpp76
-rw-r--r--examples/declarative/extending/default/person.cpp79
-rw-r--r--examples/declarative/extending/default/person.h79
-rw-r--r--examples/declarative/extending/extended/example.qml7
-rw-r--r--examples/declarative/extending/extended/extended.pro15
-rw-r--r--examples/declarative/extending/extended/extended.qrc5
-rw-r--r--examples/declarative/extending/extended/lineedit.cpp105
-rw-r--r--examples/declarative/extending/extended/lineedit.h74
-rw-r--r--examples/declarative/extending/extended/main.cpp65
-rw-r--r--examples/declarative/extending/extending.pro13
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.cpp72
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.h70
-rw-r--r--examples/declarative/extending/grouped/example.qml33
-rw-r--r--examples/declarative/extending/grouped/grouped.pro17
-rw-r--r--examples/declarative/extending/grouped/grouped.qrc5
-rw-r--r--examples/declarative/extending/grouped/main.cpp86
-rw-r--r--examples/declarative/extending/grouped/person.cpp119
-rw-r--r--examples/declarative/extending/grouped/person.h109
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp74
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h77
-rw-r--r--examples/declarative/extending/properties/example.qml15
-rw-r--r--examples/declarative/extending/properties/main.cpp69
-rw-r--r--examples/declarative/extending/properties/person.cpp67
-rw-r--r--examples/declarative/extending/properties/person.h65
-rw-r--r--examples/declarative/extending/properties/properties.pro18
-rw-r--r--examples/declarative/extending/properties/properties.qrc5
-rw-r--r--examples/declarative/extending/signal/birthdayparty.cpp99
-rw-r--r--examples/declarative/extending/signal/birthdayparty.h96
-rw-r--r--examples/declarative/extending/signal/example.qml32
-rw-r--r--examples/declarative/extending/signal/main.cpp92
-rw-r--r--examples/declarative/extending/signal/person.cpp119
-rw-r--r--examples/declarative/extending/signal/person.h107
-rw-r--r--examples/declarative/extending/signal/signal.pro17
-rw-r--r--examples/declarative/extending/signal/signal.qrc5
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp109
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h102
-rw-r--r--examples/declarative/extending/valuesource/example.qml36
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.cpp81
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.h80
-rw-r--r--examples/declarative/extending/valuesource/main.cpp94
-rw-r--r--examples/declarative/extending/valuesource/person.cpp119
-rw-r--r--examples/declarative/extending/valuesource/person.h107
-rw-r--r--examples/declarative/extending/valuesource/valuesource.pro19
-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.qml41
-rw-r--r--examples/declarative/flipable/back.pngbin0 -> 5048 bytes
-rw-r--r--examples/declarative/flipable/flipable-example.qml37
-rw-r--r--examples/declarative/flipable/front.pngbin0 -> 6431 bytes
-rw-r--r--examples/declarative/focus/Core/ContextMenu.qml15
-rw-r--r--examples/declarative/focus/Core/GridMenu.qml54
-rw-r--r--examples/declarative/focus/Core/ListViewDelegate.qml39
-rw-r--r--examples/declarative/focus/Core/ListViews.qml47
-rw-r--r--examples/declarative/focus/Core/images/arrow.pngbin0 -> 583 bytes
-rw-r--r--examples/declarative/focus/Core/images/qt-logo.pngbin0 -> 5149 bytes
-rw-r--r--examples/declarative/focus/Core/qmldir4
-rw-r--r--examples/declarative/focus/focus.qml50
-rw-r--r--examples/declarative/focusscope/test.qml76
-rw-r--r--examples/declarative/focusscope/test2.qml40
-rw-r--r--examples/declarative/focusscope/test3.qml52
-rw-r--r--examples/declarative/focusscope/test4.qml75
-rw-r--r--examples/declarative/focusscope/test5.qml83
-rw-r--r--examples/declarative/fonts/banner.qml18
-rw-r--r--examples/declarative/fonts/fonts.qml56
-rw-r--r--examples/declarative/fonts/fonts/tarzeau_ocr_a.ttfbin0 -> 24544 bytes
-rw-r--r--examples/declarative/fonts/hello.qml27
-rw-r--r--examples/declarative/gridview/gridview-example.qml38
-rw-r--r--examples/declarative/gridview/pics/AddressBook_48.pngbin0 -> 3350 bytes
-rw-r--r--examples/declarative/gridview/pics/AudioPlayer_48.pngbin0 -> 3806 bytes
-rw-r--r--examples/declarative/gridview/pics/Camera_48.pngbin0 -> 3540 bytes
-rw-r--r--examples/declarative/gridview/pics/DateBook_48.pngbin0 -> 2610 bytes
-rw-r--r--examples/declarative/gridview/pics/EMail_48.pngbin0 -> 3655 bytes
-rw-r--r--examples/declarative/gridview/pics/TodoList_48.pngbin0 -> 3429 bytes
-rw-r--r--examples/declarative/gridview/pics/VideoPlayer_48.pngbin0 -> 4151 bytes
-rw-r--r--examples/declarative/imageprovider/ImageProviderCore/qmldir2
-rw-r--r--examples/declarative/imageprovider/imageprovider-example.qml24
-rw-r--r--examples/declarative/imageprovider/imageprovider.cpp118
-rw-r--r--examples/declarative/imageprovider/imageprovider.pro21
-rw-r--r--examples/declarative/images/content/lemonade.jpgbin0 -> 6645 bytes
-rw-r--r--examples/declarative/images/images.qml69
-rw-r--r--examples/declarative/layouts/Button.qml22
-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.qml31
-rw-r--r--examples/declarative/layouts/positioners.qml163
-rw-r--r--examples/declarative/listmodel-threaded/dataloader.js14
-rw-r--r--examples/declarative/listmodel-threaded/timedisplay.qml33
-rw-r--r--examples/declarative/listview/content/ClickAutoRepeating.qml31
-rw-r--r--examples/declarative/listview/content/MediaButton.qml35
-rw-r--r--examples/declarative/listview/content/pics/add.pngbin0 -> 1577 bytes
-rw-r--r--examples/declarative/listview/content/pics/archive-insert.pngbin0 -> 896 bytes
-rw-r--r--examples/declarative/listview/content/pics/archive-remove.pngbin0 -> 1074 bytes
-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/del.pngbin0 -> 1661 bytes
-rw-r--r--examples/declarative/listview/content/pics/fruit-salad.jpgbin0 -> 17952 bytes
-rw-r--r--examples/declarative/listview/content/pics/go-down.pngbin0 -> 892 bytes
-rw-r--r--examples/declarative/listview/content/pics/go-up.pngbin0 -> 929 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/list-add.pngbin0 -> 907 bytes
-rw-r--r--examples/declarative/listview/content/pics/list-remove.pngbin0 -> 498 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/trash.pngbin0 -> 989 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/dynamic.qml159
-rw-r--r--examples/declarative/listview/highlight.qml57
-rw-r--r--examples/declarative/listview/itemlist.qml58
-rw-r--r--examples/declarative/listview/listview-example.qml77
-rw-r--r--examples/declarative/listview/recipes.qml140
-rw-r--r--examples/declarative/listview/sections.qml67
-rw-r--r--examples/declarative/mousearea/mouse.qml40
-rw-r--r--examples/declarative/objectlistmodel/dataobject.cpp73
-rw-r--r--examples/declarative/objectlistmodel/dataobject.h69
-rw-r--r--examples/declarative/objectlistmodel/main.cpp77
-rw-r--r--examples/declarative/objectlistmodel/objectlistmodel.pro18
-rw-r--r--examples/declarative/objectlistmodel/objectlistmodel.qrc5
-rw-r--r--examples/declarative/objectlistmodel/view.qml16
-rw-r--r--examples/declarative/package/Delegate.qml48
-rw-r--r--examples/declarative/package/view.qml35
-rw-r--r--examples/declarative/parallax/parallax.qml41
-rw-r--r--examples/declarative/parallax/pics/background.jpgbin0 -> 209814 bytes
-rw-r--r--examples/declarative/parallax/pics/face-smile.pngbin0 -> 15408 bytes
-rw-r--r--examples/declarative/parallax/pics/home-page.svg445
-rw-r--r--examples/declarative/parallax/pics/shadow.pngbin0 -> 425 bytes
-rw-r--r--examples/declarative/parallax/pics/yast-joystick.pngbin0 -> 2723 bytes
-rw-r--r--examples/declarative/parallax/pics/yast-wol.pngbin0 -> 3769 bytes
-rw-r--r--examples/declarative/parallax/qml/ParallaxView.qml84
-rw-r--r--examples/declarative/parallax/qml/Smiley.qml47
-rw-r--r--examples/declarative/plugins/README9
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/Clock.qml50
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/center.pngbin0 -> 765 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/clock.pngbin0 -> 20653 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/hour.pngbin0 -> 625 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/minute.pngbin0 -> 625 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/qmldir2
-rw-r--r--examples/declarative/plugins/plugin.cpp156
-rw-r--r--examples/declarative/plugins/plugins.pro27
-rw-r--r--examples/declarative/plugins/plugins.qml11
-rw-r--r--examples/declarative/progressbar/content/ProgressBar.qml37
-rw-r--r--examples/declarative/progressbar/content/background.pngbin0 -> 426 bytes
-rw-r--r--examples/declarative/progressbar/progressbars.qml24
-rw-r--r--examples/declarative/scrollbar/ScrollBar.qml31
-rw-r--r--examples/declarative/scrollbar/display.qml58
-rw-r--r--examples/declarative/scrollbar/pics/niagara_falls.jpgbin0 -> 604121 bytes
-rw-r--r--examples/declarative/searchbox/SearchBox.qml60
-rw-r--r--examples/declarative/searchbox/images/edit-clear-locationbar-rtl.pngbin0 -> 429 bytes
-rw-r--r--examples/declarative/searchbox/images/lineedit-bg-focus.pngbin0 -> 526 bytes
-rw-r--r--examples/declarative/searchbox/images/lineedit-bg.pngbin0 -> 426 bytes
-rw-r--r--examples/declarative/searchbox/main.qml13
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml73
-rw-r--r--examples/declarative/slideswitch/content/background.svg23
-rw-r--r--examples/declarative/slideswitch/content/knob.svg867
-rw-r--r--examples/declarative/slideswitch/slideswitch.qml11
-rw-r--r--examples/declarative/sql/hello.qml30
-rw-r--r--examples/declarative/states/states.qml50
-rw-r--r--examples/declarative/states/transitions.qml70
-rw-r--r--examples/declarative/states/user.pngbin0 -> 4886 bytes
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml50
-rw-r--r--examples/declarative/tabwidget/tab.pngbin0 -> 507 bytes
-rw-r--r--examples/declarative/tabwidget/tabs.qml48
-rw-r--r--examples/declarative/tic-tac-toe/content/Button.qml35
-rw-r--r--examples/declarative/tic-tac-toe/content/TicTac.qml20
-rw-r--r--examples/declarative/tic-tac-toe/content/pics/board.pngbin0 -> 11208 bytes
-rw-r--r--examples/declarative/tic-tac-toe/content/pics/o.pngbin0 -> 1470 bytes
-rw-r--r--examples/declarative/tic-tac-toe/content/pics/x.pngbin0 -> 1331 bytes
-rw-r--r--examples/declarative/tic-tac-toe/tic-tac-toe.qml78
-rw-r--r--examples/declarative/tutorials/helloworld/Cell.qml32
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial1.qml22
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial2.qml31
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial3.qml51
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Block.qml12
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml27
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml40
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Block.qml10
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Button.qml25
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.js61
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.qml43
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Block.qml21
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Button.qml25
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml23
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js189
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml62
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml64
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Button.qml25
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml21
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js249
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/highscores/README1
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml2
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl28
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/highscores/scores.php34
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/samegame.qml77
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/background.jpgbin0 -> 36473 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/blueStar.pngbin0 -> 278 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/blueStone.pngbin0 -> 3054 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/greenStar.pngbin0 -> 273 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/greenStone.pngbin0 -> 2932 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/redStar.pngbin0 -> 274 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/redStone.pngbin0 -> 2902 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/star.pngbin0 -> 262 bytes
-rw-r--r--examples/declarative/tutorials/samegame/shared/pics/yellowStone.pngbin0 -> 3056 bytes
-rw-r--r--examples/declarative/tvtennis/click.wavbin0 -> 3056 bytes
-rw-r--r--examples/declarative/tvtennis/paddle.wavbin0 -> 5320 bytes
-rw-r--r--examples/declarative/tvtennis/tvtennis.qml78
-rw-r--r--examples/declarative/velocity/Day.qml78
-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.qml108
-rw-r--r--examples/declarative/webview/autosize.qml61
-rw-r--r--examples/declarative/webview/content/FieldText.qml157
-rw-r--r--examples/declarative/webview/content/Mapping/Map.qml26
-rwxr-xr-xexamples/declarative/webview/content/Mapping/map.html52
-rw-r--r--examples/declarative/webview/content/SpinSquare.qml25
-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/googleMaps.qml41
-rw-r--r--examples/declarative/webview/inline-html.qml15
-rw-r--r--examples/declarative/webview/newwindows.html3
-rw-r--r--examples/declarative/webview/newwindows.qml31
-rw-r--r--examples/declarative/webview/transparent.qml14
-rw-r--r--examples/declarative/widgets/MyWidgets/qmldir1
-rw-r--r--examples/declarative/widgets/README4
-rw-r--r--examples/declarative/widgets/mywidgets.cpp99
-rw-r--r--examples/declarative/widgets/mywidgets.pro19
-rw-r--r--examples/declarative/widgets/mywidgets.qml53
-rw-r--r--examples/declarative/workerscript/workerscript.js15
-rw-r--r--examples/declarative/workerscript/workerscript.qml47
-rw-r--r--examples/declarative/xmldata/daringfireball.qml45
-rw-r--r--examples/declarative/xmldata/yahoonews.qml79
-rw-r--r--examples/declarative/xmlhttprequest/test.qml36
-rw-r--r--examples/declarative/xmlhttprequest/test.xml5
-rw-r--r--examples/dialogs/standarddialogs/dialog.cpp7
-rw-r--r--examples/draganddrop/draggabletext/dragwidget.cpp2
-rw-r--r--examples/examples.pro8
-rw-r--r--examples/graphicsview/padnavigator/padnavigator.qrc1
-rw-r--r--examples/graphicsview/weatheranchorlayout/main.cpp11
-rw-r--r--examples/help/remotecontrol/remotecontrol.cpp2
-rw-r--r--examples/help/simpletextviewer/assistant.cpp2
-rw-r--r--examples/itemviews/dirview/main.cpp3
-rw-r--r--examples/multimedia/audioinput/audioinput.cpp8
-rw-r--r--examples/network/bearercloud/bearercloud.cpp197
-rw-r--r--examples/network/bearercloud/bearercloud.h81
-rw-r--r--examples/network/bearercloud/bearercloud.pro16
-rw-r--r--examples/network/bearercloud/cloud.cpp363
-rw-r--r--examples/network/bearercloud/cloud.h99
-rw-r--r--examples/network/bearercloud/icons.qrc7
-rw-r--r--examples/network/bearercloud/lan.svg76
-rw-r--r--examples/network/bearercloud/main.cpp89
-rw-r--r--examples/network/bearercloud/unknown.svg76
-rw-r--r--examples/network/bearercloud/wlan.svg151
-rw-r--r--examples/network/bearermonitor/bearermonitor.cpp395
-rw-r--r--examples/network/bearermonitor/bearermonitor.h92
-rw-r--r--examples/network/bearermonitor/bearermonitor.pro26
-rw-r--r--examples/network/bearermonitor/bearermonitor_240_320.ui420
-rw-r--r--examples/network/bearermonitor/bearermonitor_640_480.ui386
-rw-r--r--examples/network/bearermonitor/main.cpp (renamed from examples/assistant/simpletextviewer/main.cpp)11
-rw-r--r--examples/network/bearermonitor/sessionwidget.cpp186
-rw-r--r--examples/network/bearermonitor/sessionwidget.h (renamed from examples/assistant/simpletextviewer/mainwindow.h)59
-rw-r--r--examples/network/bearermonitor/sessionwidget.ui307
-rw-r--r--examples/network/fortuneclient/fortuneclient.pro2
-rw-r--r--examples/network/fortuneserver/fortuneserver.pro2
-rw-r--r--examples/network/network-chat/network-chat.pro2
-rw-r--r--examples/network/network.pro4
-rw-r--r--examples/opengl/hellogl_es/cl_helper.h133
-rw-r--r--examples/opengl/hellogl_es/glwidget.cpp137
-rw-r--r--examples/opengl/hellogl_es/glwidget.h5
-rw-r--r--examples/opengl/opengl.pro6
-rw-r--r--examples/qtestlib/tutorial5/containers.cpp269
-rw-r--r--examples/qws/svgalib/README12
-rw-r--r--examples/qws/svgalib/svgalibpaintdevice.cpp2
-rw-r--r--examples/qws/svgalib/svgalibpaintengine.cpp45
-rw-r--r--examples/qws/svgalib/svgalibpaintengine.h6
-rw-r--r--examples/script/customclass/bytearrayclass.cpp17
-rw-r--r--examples/script/customclass/bytearrayclass.h2
-rw-r--r--examples/script/qstetrix/tetrixboard.cpp13
-rw-r--r--examples/script/qstetrix/tetrixboard.h10
-rw-r--r--examples/threads/waitconditions/waitconditions.pro2
-rw-r--r--examples/tools/completer/completer.pro4
-rw-r--r--examples/tools/completer/fsmodel.cpp (renamed from examples/tools/completer/dirmodel.cpp)11
-rw-r--r--examples/tools/completer/fsmodel.h (renamed from examples/tools/completer/dirmodel.h)12
-rw-r--r--examples/tools/completer/mainwindow.cpp20
-rw-r--r--examples/tutorials/addressbook/part3/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part4/addressbook.cpp2
-rw-r--r--examples/webkit/fancybrowser/main.cpp9
-rw-r--r--examples/webkit/fancybrowser/mainwindow.cpp27
-rw-r--r--examples/webkit/fancybrowser/mainwindow.h5
425 files changed, 16761 insertions, 1243 deletions
diff --git a/examples/assistant/README b/examples/assistant/README
deleted file mode 100644
index 85f5a43..0000000
--- a/examples/assistant/README
+++ /dev/null
@@ -1,38 +0,0 @@
-Support for interactive help is provided by the Qt Assistant application.
-Developers can take advantages of the facilities it offers to display
-specially-prepared documentation to users of their applications.
-
-
-The example launcher provided with Qt can be used to explore each of the
-examples in this directory.
-
-Documentation for these examples can be found via the Tutorial and Examples
-link in the main Qt documentation.
-
-
-Finding the Qt Examples and Demos launcher
-==========================================
-
-On Windows:
-
-The launcher can be accessed via the Windows Start menu. Select the menu
-entry entitled "Qt Examples and Demos" entry in the submenu containing
-the Qt tools.
-
-On Mac OS X:
-
-For the binary distribution, the qtdemo executable is installed in the
-/Developer/Applications/Qt directory. For the source distribution, it is
-installed alongside the other Qt tools on the path specified when Qt is
-configured.
-
-On Unix/Linux:
-
-The qtdemo executable is installed alongside the other Qt tools on the path
-specified when Qt is configured.
-
-On all platforms:
-
-The source code for the launcher can be found in the demos/qtdemo directory
-in the Qt package. This example is built at the same time as the Qt libraries,
-tools, examples, and demonstrations.
diff --git a/examples/assistant/assistant.pro b/examples/assistant/assistant.pro
deleted file mode 100644
index ff1f947..0000000
--- a/examples/assistant/assistant.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = simpletextviewer
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/assistant
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS assistant.pro README
-sources.path = $$[QT_INSTALL_EXAMPLES]/assistant
-INSTALLS += target sources
-
-symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/assistant/simpletextviewer/documentation/about.txt b/examples/assistant/simpletextviewer/documentation/about.txt
deleted file mode 100644
index eeab35f..0000000
--- a/examples/assistant/simpletextviewer/documentation/about.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-The Simple Text Viewer enables the user to select and view existing
-files.
-
-HTML files is displayed using rich text, while other files are
-presented as plain text. The application provides a file dialog
-allowing the user to search for files using wildcard matching. The
-search is performed within in the specified directory, and the user is
-given an option to browse the existing file system to find the
-relevant directory.
diff --git a/examples/assistant/simpletextviewer/documentation/browse.html b/examples/assistant/simpletextviewer/documentation/browse.html
deleted file mode 100644
index 987abf3..0000000
--- a/examples/assistant/simpletextviewer/documentation/browse.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Browse</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>Browse</h2></center></p>
-
- <p>
- The file dialog let you browse the current file system to
- specify the directory in which the file you want to open
- resides.
- Note that only the specified directory will be searched, any
- subdirectories will simply be ignored.
- </p>
-
- <br />
- <br />
- <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
- <tr valign="top" bgcolor="#f0f0f0">
- <td><center><img src="images/browse.png" /></center></td>
- </tr>
- </table>
-
- <br />
- <br />
- <p>
- See also: <a href="filedialog.html">File Dialog</a>, <a href="wildcardmatching.html">Wildcard Matching</a>,
- <a href="findfile.html">Find File</a>
- </p>
- </body>
-</html>
-
diff --git a/examples/assistant/simpletextviewer/documentation/filedialog.html b/examples/assistant/simpletextviewer/documentation/filedialog.html
deleted file mode 100644
index afa65ed..0000000
--- a/examples/assistant/simpletextviewer/documentation/filedialog.html
+++ /dev/null
@@ -1,48 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>File Dialog</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>File Dialog</h2></center></p>
-
- <p>
- In the file dialog you can name a particular file name, or
- search for files using wildcard matching, i.e. specify a
- file name containing wildcards. In addition you must specify
- the directory in which the file you search for resides.
- </p>
-
- <br />
- <br />
- <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
- <tr valign="top" bgcolor="#f0f0f0">
- <td><center><img src="images/filedialog.png" /></center></td>
- </tr>
- </table>
-
- <br />
- <br />
- <p>
- By default the dialog will search for all files (*) in the
- current directory (the directory the application is run from).
- </p>
-
- <p>
- When editing the file name and directory parameters, an
- overview of the matching files are displayed in the
- dialog. The overview is updated whenever the parameters
- change.
- </p>
-
- <br />
- <br />
- <p>
- See also: <a href="browse.html">Browse</a>, <a href="wildcardmatching.html">Wildcard Matching</a>,
- <a href="findfile.html">Find File</a>
- </p>
- </body>
-</html>
-
-
diff --git a/examples/assistant/simpletextviewer/documentation/findfile.html b/examples/assistant/simpletextviewer/documentation/findfile.html
deleted file mode 100644
index 32e0147..0000000
--- a/examples/assistant/simpletextviewer/documentation/findfile.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Find File</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>Find File</h2></center></p>
-
- <p>
- To open and view a file in the Simple Text Viewer, select the
- 'Open...' option in the 'File' menu. The application will then
- provide you with a file dialog that you can use to search for
- any existing file.
- </p>
-
- <br />
- <br />
- <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
- <tr valign="top" bgcolor="#f0f0f0">
- <td><center><img src="images/fadedfilemenu.png" /></center></td>
- </tr>
- </table>
-
- <br />
- <br />
- <p>
- See also: <a href="openfile.html">Open File</a>, <a href="filedialog.html">File Dialog</a>
- </p>
- </body>
-</html>
-
diff --git a/examples/assistant/simpletextviewer/documentation/images/browse.png b/examples/assistant/simpletextviewer/documentation/images/browse.png
deleted file mode 100644
index 86db6b1..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/browse.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.png b/examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.png
deleted file mode 100644
index fde0e43..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/fadedfilemenu.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/images/filedialog.png b/examples/assistant/simpletextviewer/documentation/images/filedialog.png
deleted file mode 100644
index 883a33a..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/filedialog.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/images/handbook.png b/examples/assistant/simpletextviewer/documentation/images/handbook.png
deleted file mode 100644
index 3bd2b92..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/handbook.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/images/mainwindow.png b/examples/assistant/simpletextviewer/documentation/images/mainwindow.png
deleted file mode 100644
index c28d5e9..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/mainwindow.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/images/open.png b/examples/assistant/simpletextviewer/documentation/images/open.png
deleted file mode 100644
index 1e5bba3..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/images/wildcard.png b/examples/assistant/simpletextviewer/documentation/images/wildcard.png
deleted file mode 100644
index 6e83a56..0000000
--- a/examples/assistant/simpletextviewer/documentation/images/wildcard.png
+++ /dev/null
Binary files differ
diff --git a/examples/assistant/simpletextviewer/documentation/index.html b/examples/assistant/simpletextviewer/documentation/index.html
deleted file mode 100644
index 5a7b1d5..0000000
--- a/examples/assistant/simpletextviewer/documentation/index.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Manual</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>Simple Text Viewer</h2></center></p>
-
- <p>
- The Simple Text Viewer enables the user to select and view
- existing files.
- </p>
-
- <p><center>
- <img src="images/mainwindow.png" />
- </center></p>
-
- <p>
- HTML files is displayed using rich text, while
- other files are presented as plain text. The application
- provides a file dialog allowing the user to search for files
- using wildcard matching. The search is performed within in the
- specified directory, and the user is given an option to browse
- the existing file system to find the relevant directory.
- </p>
-
- <ul>
- <li><a href="findfile.html">Find File</a></li>
- <ul>
- <li><a href="filedialog.html">File Dialog</a></li>
- <li><a href="wildcardmatching.html">WildCard Matching</a></li>
- <li><a href="browse.html">Browse</a></li>
- </ul>
- <li><a href="openfile.html">Open File</a></li>
- </ul>
- </body>
-</html>
-
-
-
diff --git a/examples/assistant/simpletextviewer/documentation/intro.html b/examples/assistant/simpletextviewer/documentation/intro.html
deleted file mode 100644
index 2e2aa40..0000000
--- a/examples/assistant/simpletextviewer/documentation/intro.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Manual</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>Simple Text Viewer</h2></center></p>
-
- <p>
- The Simple Text Viewer enables the user to select and view
- existing files.
- </p>
-
- <p><center>
- <img src="images/mainwindow.png" />
- </center></p>
-
- <p>
- The application provides its own custom documentation that is
- available through the <b>Help</b> menu in the main window's menubar
- and through the <b>Help</b> button in the application's find file
- dialog.
- </p>
-
- </body>
-</html>
-
diff --git a/examples/assistant/simpletextviewer/documentation/openfile.html b/examples/assistant/simpletextviewer/documentation/openfile.html
deleted file mode 100644
index e172de9..0000000
--- a/examples/assistant/simpletextviewer/documentation/openfile.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Open File</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>Open File</h2></center></p>
-
- <p>
- Once the file you want to view appears in the dialog's
- display, you can open it in two different ways.
- </p>
-
- <p>
- By pressing the 'Open' button the currently selected file will
- be opened. By default, the first file in the list of matching
- files is selected. Another way of opening a file is to simply
- double click the displayed file name.
- </p>
-
- <br />
- <br />
- <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
- <tr valign="top" bgcolor="#f0f0f0">
- <td><center><img src="images/open.png" /></center></td>
- </tr>
- </table>
-
- <br />
- <br />
- <p>
- See also: <a href="findfile.html">Find File</a>
- </p>
- </body>
-</html>
diff --git a/examples/assistant/simpletextviewer/documentation/simpletextviewer.adp b/examples/assistant/simpletextviewer/documentation/simpletextviewer.adp
deleted file mode 100644
index 660df4f..0000000
--- a/examples/assistant/simpletextviewer/documentation/simpletextviewer.adp
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE DCF>
-
-<assistantconfig version="3.2.0">
-
-<profile>
- <property name="name">simpletextviewer</property>
- <property name="title">Simple Text Viewer</property>
- <property name="applicationicon">images/handbook.png</property>
- <property name="startpage">index.html</property>
- <property name="aboutmenutext">About Simple Text Viewer</property>
- <property name="abouturl">about.txt</property>
- <property name="assistantdocs">.</property>
-</profile>
-
-<DCF ref="index.html" icon="images/handbook.png" title="Simple Text Viewer">
- <section ref="./findfile.html" title="Find File">
- <keyword ref="./index.html">Display</keyword>
- <keyword ref="./index.html">Rich text</keyword>
- <keyword ref="./index.html">Plain text</keyword>
- <keyword ref="./findfile.html">Find</keyword>
- <keyword ref="./findfile.html">File menu</keyword>
- <keyword ref="./filedialog.html">File name</keyword>
- <keyword ref="./filedialog.html">File dialog</keyword>
- <keyword ref="./wildcardmatching.html">File globbing</keyword>
- <keyword ref="./wildcardmatching.html">Wildcard matching</keyword>
- <keyword ref="./wildcardmatching.html">Wildcard syntax</keyword>
- <keyword ref="./browse.html">Browse</keyword>
- <keyword ref="./browse.html">Directory</keyword>
- <keyword ref="./openfile.html">Open</keyword>
- <keyword ref="./openfile.html">Select</keyword>
-
- <section ref="./filedialog.html" title="File Dialog" />
- <section ref="./wildcardmatching.html" title="Wildcard Matching" />
- <section ref="./browse.html" title="Browse" />
- </section>
- <section ref="./openfile.html" title="Open File" />
-</DCF>
-
-</assistantconfig>
-
diff --git a/examples/assistant/simpletextviewer/documentation/wildcardmatching.html b/examples/assistant/simpletextviewer/documentation/wildcardmatching.html
deleted file mode 100644
index eb1839a..0000000
--- a/examples/assistant/simpletextviewer/documentation/wildcardmatching.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Wildcard Matching</title>
- </head>
- <body style="font-size:12pt;font-family:helvetica">
-
- <p><center><h2>Wildcard Matching</h2></center></p>
-
- <p>
- Most command shells such as bash or cmd.exe support "file
- globbing", the ability to identify a group of files by using
- wildcards.
-
- <br />
- <br />
- <table align="center" cellpadding="2" cellspacing="1" border="0" width="100%">
- <tr valign="top" bgcolor="#f0f0f0">
- <td><center><img src="images/wildcard.png" /></center></td>
- </tr>
- </table>
-
- <br />
- <br />
- <p>
- Wildcard matching provides four features:
- </p>
-
- <ul>
- <li>Any character represents itself apart from those
- mentioned below. Thus 'c' matches the character 'c'.
- </li>
- <li>The '?' character matches any single character.</li>
- <li>The '*' matches zero or more of any characters.</li>
- <li>Sets of characters can be represented in square brackets.
- Within the character class, like outside, backslash
- has no special meaning.
- </li>
- </ul>
-
- <p>
- For example we could identify HTML files with
- <code>*.html</code>. This will match zero or more characters
- followed by a dot followed by 'h', 't', 'm' and 'l'.
- </p>
-
- <br />
- <br />
- <p>
- See also: <a href="browse.html">Browse</a>, <a href="filedialog.html">File Dialog</a>,
- <a href="findfile.html">Find File</a>
- </p>
- </body>
-</html>
-
-
-
diff --git a/examples/assistant/simpletextviewer/findfiledialog.cpp b/examples/assistant/simpletextviewer/findfiledialog.cpp
deleted file mode 100644
index 1f11f69..0000000
--- a/examples/assistant/simpletextviewer/findfiledialog.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-
-#include "findfiledialog.h"
-
-//! [0]
-FindFileDialog::FindFileDialog(QTextEdit *editor, QAssistantClient *assistant,
- QWidget *parent)
- : QDialog(parent)
-{
- currentAssistantClient = assistant;
- currentEditor = editor;
-//! [0]
-
- createButtons();
- createComboBoxes();
- createFilesTree();
- createLabels();
- createLayout();
-
- directoryComboBox->addItem(QDir::toNativeSeparators(QDir::currentPath()));
- fileNameComboBox->addItem("*");
- findFiles();
-
- setWindowTitle(tr("Find File"));
-//! [1]
-}
-//! [1]
-
-void FindFileDialog::browse()
-{
- QString currentDirectory = directoryComboBox->currentText();
- QString newDirectory = QFileDialog::getExistingDirectory(this,
- tr("Select Directory"), currentDirectory);
- if (!newDirectory.isEmpty()) {
- directoryComboBox->addItem(QDir::toNativeSeparators(newDirectory));
- directoryComboBox->setCurrentIndex(directoryComboBox->count() - 1);
- update();
- }
-}
-
-//! [2]
-void FindFileDialog::help()
-{
- currentAssistantClient->showPage(QLibraryInfo::location(QLibraryInfo::ExamplesPath) +
- QDir::separator() + "assistant/simpletextviewer/documentation/filedialog.html");
-}
-//! [2]
-
-void FindFileDialog::openFile(QTreeWidgetItem *item)
-{
- if (!item) {
- item = foundFilesTree->currentItem();
- if (!item)
- return;
- }
-
- QString fileName = item->text(0);
- QString path = directoryComboBox->currentText() + QDir::separator();
-
- QFile file(path + fileName);
- if (file.open(QIODevice::ReadOnly)) {
- QString data(file.readAll());
-
- if (fileName.endsWith(QLatin1String(".html")))
- currentEditor->setHtml(data);
- else
- currentEditor->setPlainText(data);
- }
- close();
-}
-
-void FindFileDialog::update()
-{
- findFiles();
- buttonBox->button(QDialogButtonBox::Open)->setEnabled(
- foundFilesTree->topLevelItemCount() > 0);
-}
-
-void FindFileDialog::findFiles()
-{
- QRegExp filePattern(fileNameComboBox->currentText() + '*');
- filePattern.setPatternSyntax(QRegExp::Wildcard);
-
- QDir directory(directoryComboBox->currentText());
-
- QStringList allFiles = directory.entryList(QDir::Files | QDir::NoSymLinks);
- QStringList matchingFiles;
-
- foreach (const QString &file, allFiles) {
- if (filePattern.exactMatch(file))
- matchingFiles << file;
- }
- showFiles(matchingFiles);
-}
-
-void FindFileDialog::showFiles(const QStringList &files)
-{
- foundFilesTree->clear();
-
- for (int i = 0; i < files.count(); ++i) {
- QTreeWidgetItem *item = new QTreeWidgetItem(foundFilesTree);
- item->setText(0, files[i]);
- }
-
- if (files.count() > 0)
- foundFilesTree->setCurrentItem(foundFilesTree->topLevelItem(0));
-}
-
-void FindFileDialog::createButtons()
-{
- browseButton = new QToolButton;
- browseButton->setText(tr("..."));
- connect(browseButton, SIGNAL(clicked()), this, SLOT(browse()));
-
- buttonBox = new QDialogButtonBox(QDialogButtonBox::Open
- | QDialogButtonBox::Cancel
- | QDialogButtonBox::Help);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(openFile()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
- connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));
-}
-
-void FindFileDialog::createComboBoxes()
-{
- directoryComboBox = new QComboBox;
- fileNameComboBox = new QComboBox;
-
- fileNameComboBox->setEditable(true);
- fileNameComboBox->setSizePolicy(QSizePolicy::Expanding,
- QSizePolicy::Preferred);
-
- directoryComboBox->setMinimumContentsLength(30);
- directoryComboBox->setSizeAdjustPolicy(
- QComboBox::AdjustToMinimumContentsLength);
- directoryComboBox->setSizePolicy(QSizePolicy::Expanding,
- QSizePolicy::Preferred);
-
- connect(fileNameComboBox, SIGNAL(editTextChanged(QString)),
- this, SLOT(update()));
- connect(directoryComboBox, SIGNAL(currentIndexChanged(QString)),
- this, SLOT(update()));
-}
-
-void FindFileDialog::createFilesTree()
-{
- foundFilesTree = new QTreeWidget;
- foundFilesTree->setColumnCount(1);
- foundFilesTree->setHeaderLabels(QStringList(tr("Matching Files")));
- foundFilesTree->setRootIsDecorated(false);
- foundFilesTree->setSelectionMode(QAbstractItemView::SingleSelection);
-
- connect(foundFilesTree, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
- this, SLOT(openFile(QTreeWidgetItem*)));
-}
-
-void FindFileDialog::createLabels()
-{
- directoryLabel = new QLabel(tr("Search in:"));
- fileNameLabel = new QLabel(tr("File name (including wildcards):"));
-}
-
-void FindFileDialog::createLayout()
-{
- QHBoxLayout *fileLayout = new QHBoxLayout;
- fileLayout->addWidget(fileNameLabel);
- fileLayout->addWidget(fileNameComboBox);
-
- QHBoxLayout *directoryLayout = new QHBoxLayout;
- directoryLayout->addWidget(directoryLabel);
- directoryLayout->addWidget(directoryComboBox);
- directoryLayout->addWidget(browseButton);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addLayout(fileLayout);
- mainLayout->addLayout(directoryLayout);
- mainLayout->addWidget(foundFilesTree);
- mainLayout->addStretch();
- mainLayout->addWidget(buttonBox);
- setLayout(mainLayout);
-}
diff --git a/examples/assistant/simpletextviewer/mainwindow.cpp b/examples/assistant/simpletextviewer/mainwindow.cpp
deleted file mode 100644
index 03eab02..0000000
--- a/examples/assistant/simpletextviewer/mainwindow.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-
-#include "mainwindow.h"
-#include "findfiledialog.h"
-
-//! [0]
-MainWindow::MainWindow()
-{
- textViewer = new QTextEdit;
- textViewer->setReadOnly(true);
- QFile file("documentation/intro.html");
- if (file.open(QIODevice::ReadOnly))
- textViewer->setHtml(file.readAll());
-
- setCentralWidget(textViewer);
-
- createActions();
- createMenus();
-
- initializeAssistant();
-
- setWindowTitle(tr("Simple Text Viewer"));
- resize(750, 400);
-}
-//! [0]
-
-//! [1]
-void MainWindow::closeEvent(QCloseEvent *)
-{
- if (assistantClient)
- assistantClient->closeAssistant();
-}
-//! [1]
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Simple Text Viewer"),
- tr("This example demonstrates how to use\n" \
- "Qt Assistant as help system for your\n" \
- "own application."));
-}
-
-//! [2]
-void MainWindow::assistant()
-{
- assistantClient->showPage(QLibraryInfo::location(QLibraryInfo::ExamplesPath) +
- QDir::separator() +
- "assistant/simpletextviewer/documentation/index.html");
-}
-//! [2]
-
-//! [3]
-void MainWindow::open()
-{
- FindFileDialog dialog(textViewer, assistantClient);
- dialog.exec();
-}
-//! [3]
-
-void MainWindow::createActions()
-{
- assistantAct = new QAction(tr("Help Contents"), this);
- assistantAct->setShortcuts(QKeySequence::HelpContents);
- connect(assistantAct, SIGNAL(triggered()), this, SLOT(assistant()));
-
- openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-
- clearAct = new QAction(tr("&Clear"), this);
- clearAct->setShortcut(tr("Ctrl+C"));
- connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear()));
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
-
- aboutAct = new QAction(tr("&About"), this);
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-}
-
-void MainWindow::createMenus()
-{
- fileMenu = new QMenu(tr("&File"), this);
- fileMenu->addAction(openAct);
- fileMenu->addAction(clearAct);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
-
- helpMenu = new QMenu(tr("&Help"), this);
- helpMenu->addAction(assistantAct);
- helpMenu->addSeparator();
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-
-
- menuBar()->addMenu(fileMenu);
- menuBar()->addMenu(helpMenu);
-}
-
-//! [4]
-void MainWindow::initializeAssistant()
-{
- assistantClient = new QAssistantClient(QLibraryInfo::location(QLibraryInfo::BinariesPath), this);
-
- QStringList arguments;
- arguments << "-profile" << QString("documentation") + QDir::separator() + QString("simpletextviewer.adp");
- assistantClient->setArguments(arguments);
-}
-//! [4]
diff --git a/examples/assistant/simpletextviewer/simpletextviewer.pro b/examples/assistant/simpletextviewer/simpletextviewer.pro
deleted file mode 100644
index 2c0eada..0000000
--- a/examples/assistant/simpletextviewer/simpletextviewer.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += assistant
-
-QT += network
-
-HEADERS = mainwindow.h \
- findfiledialog.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- findfiledialog.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/assistant/simpletextviewer
-sources.files = $$SOURCES $$HEADERS $$RESOURCES documentation *.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/assistant/simpletextviewer
-INSTALLS += target sources
-
-symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
-
diff --git a/examples/dbus/dbus-chat/chat_adaptor.cpp b/examples/dbus/dbus-chat/chat_adaptor.cpp
index dc07e1c..77e7ab0 100644
--- a/examples/dbus/dbus-chat/chat_adaptor.cpp
+++ b/examples/dbus/dbus-chat/chat_adaptor.cpp
@@ -38,10 +38,10 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** Do not edit! All changes made to it will be lost.
diff --git a/examples/dbus/dbus-chat/chat_adaptor.h b/examples/dbus/dbus-chat/chat_adaptor.h
index b1e66ad..47b7f8f 100644
--- a/examples/dbus/dbus-chat/chat_adaptor.h
+++ b/examples/dbus/dbus-chat/chat_adaptor.h
@@ -38,10 +38,10 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** This file may have been hand-edited. Look for HAND-EDIT comments
@@ -49,8 +49,8 @@
**
****************************************************************************/
-#ifndef CHAT_ADAPTOR_H_142741156243605
-#define CHAT_ADAPTOR_H_142741156243605
+#ifndef CHAT_ADAPTOR_H_1257535021
+#define CHAT_ADAPTOR_H_1257535021
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
@@ -72,14 +72,14 @@ class ChatAdaptor: public QDBusAbstractAdaptor
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat")
Q_CLASSINFO("D-Bus Introspection", ""
-" <interface name=\"com.trolltech.chat\" >\n"
-" <signal name=\"message\" >\n"
-" <arg direction=\"out\" type=\"s\" name=\"nickname\" />\n"
-" <arg direction=\"out\" type=\"s\" name=\"text\" />\n"
+" <interface name=\"com.trolltech.chat\">\n"
+" <signal name=\"message\">\n"
+" <arg direction=\"out\" type=\"s\" name=\"nickname\"/>\n"
+" <arg direction=\"out\" type=\"s\" name=\"text\"/>\n"
" </signal>\n"
-" <signal name=\"action\" >\n"
-" <arg direction=\"out\" type=\"s\" name=\"nickname\" />\n"
-" <arg direction=\"out\" type=\"s\" name=\"text\" />\n"
+" <signal name=\"action\">\n"
+" <arg direction=\"out\" type=\"s\" name=\"nickname\"/>\n"
+" <arg direction=\"out\" type=\"s\" name=\"text\"/>\n"
" </signal>\n"
" </interface>\n"
"")
diff --git a/examples/dbus/dbus-chat/chat_interface.cpp b/examples/dbus/dbus-chat/chat_interface.cpp
index f187ee0..3aba098 100644
--- a/examples/dbus/dbus-chat/chat_interface.cpp
+++ b/examples/dbus/dbus-chat/chat_interface.cpp
@@ -38,10 +38,10 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -i chat_interface.h -p :chat_interface.cpp chat/com.trolltech.chat.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -i chat_interface.h -p :chat_interface.cpp com.trolltech.chat.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/examples/dbus/dbus-chat/chat_interface.h b/examples/dbus/dbus-chat/chat_interface.h
index 3bf427b..a6aa2df 100644
--- a/examples/dbus/dbus-chat/chat_interface.h
+++ b/examples/dbus/dbus-chat/chat_interface.h
@@ -38,18 +38,18 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** Do not edit! All changes made to it will be lost.
**
****************************************************************************/
-#ifndef CHAT_INTERFACE_H_143021156243606
-#define CHAT_INTERFACE_H_143021156243606
+#ifndef CHAT_INTERFACE_H_1257535021
+#define CHAT_INTERFACE_H_1257535021
#include <QtCore/QObject>
#include <QtCore/QByteArray>
diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro
index 9b426d3..d362dc9 100644
--- a/examples/dbus/remotecontrolledcar/car/car.pro
+++ b/examples/dbus/remotecontrolledcar/car/car.pro
@@ -10,7 +10,7 @@ CONFIG += qdbus
# Input
# DBUS_ADAPTORS += car.xml
-HEADERS += car.h car_adaptor_p.h
+HEADERS += car.h car_adaptor.h
SOURCES += car.cpp main.cpp car_adaptor.cpp
# install
diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp
index bd4832e..da7505b 100644
--- a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp
+++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp
@@ -38,17 +38,17 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -i car_adaptor.h -a :car_adaptor.cpp car.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** Do not edit! All changes made to it will be lost.
**
****************************************************************************/
-#include "car_adaptor_p.h"
+#include "car_adaptor.h"
#include <QtCore/QMetaObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
@@ -58,40 +58,40 @@
#include <QtCore/QVariant>
/*
- * Implementation of adaptor class CarAdaptor
+ * Implementation of adaptor class CarInterfaceAdaptor
*/
-CarAdaptor::CarAdaptor(QObject *parent)
+CarInterfaceAdaptor::CarInterfaceAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}
-CarAdaptor::~CarAdaptor()
+CarInterfaceAdaptor::~CarInterfaceAdaptor()
{
// destructor
}
-void CarAdaptor::accelerate()
+void CarInterfaceAdaptor::accelerate()
{
// handle method call com.trolltech.Examples.CarInterface.accelerate
QMetaObject::invokeMethod(parent(), "accelerate");
}
-void CarAdaptor::decelerate()
+void CarInterfaceAdaptor::decelerate()
{
// handle method call com.trolltech.Examples.CarInterface.decelerate
QMetaObject::invokeMethod(parent(), "decelerate");
}
-void CarAdaptor::turnLeft()
+void CarInterfaceAdaptor::turnLeft()
{
// handle method call com.trolltech.Examples.CarInterface.turnLeft
QMetaObject::invokeMethod(parent(), "turnLeft");
}
-void CarAdaptor::turnRight()
+void CarInterfaceAdaptor::turnRight()
{
// handle method call com.trolltech.Examples.CarInterface.turnRight
QMetaObject::invokeMethod(parent(), "turnRight");
diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h b/examples/dbus/remotecontrolledcar/car/car_adaptor.h
index 5f769cd..b8b5602 100644
--- a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h
+++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.h
@@ -38,10 +38,10 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -a car_adaptor.h: car.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** This file may have been hand-edited. Look for HAND-EDIT comments
@@ -49,8 +49,8 @@
**
****************************************************************************/
-#ifndef CAR_ADAPTOR_P_H_1157030132
-#define CAR_ADAPTOR_P_H_1157030132
+#ifndef CAR_ADAPTOR_H_1264773009
+#define CAR_ADAPTOR_H_1264773009
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
@@ -67,22 +67,22 @@ QT_END_NAMESPACE
/*
* Adaptor class for interface com.trolltech.Examples.CarInterface
*/
-class CarAdaptor: public QDBusAbstractAdaptor
+class CarInterfaceAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface")
Q_CLASSINFO("D-Bus Introspection", ""
-" <interface name=\"com.trolltech.Examples.CarInterface\" >\n"
-" <method name=\"accelerate\" />\n"
-" <method name=\"decelerate\" />\n"
-" <method name=\"turnLeft\" />\n"
-" <method name=\"turnRight\" />\n"
-" <signal name=\"crashed\" />\n"
+" <interface name=\"com.trolltech.Examples.CarInterface\">\n"
+" <method name=\"accelerate\"/>\n"
+" <method name=\"decelerate\"/>\n"
+" <method name=\"turnLeft\"/>\n"
+" <method name=\"turnRight\"/>\n"
+" <signal name=\"crashed\"/>\n"
" </interface>\n"
"")
public:
- CarAdaptor(QObject *parent);
- virtual ~CarAdaptor();
+ CarInterfaceAdaptor(QObject *parent);
+ virtual ~CarInterfaceAdaptor();
public: // PROPERTIES
public Q_SLOTS: // METHODS
diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp
index 85b206c..eab82a7 100644
--- a/examples/dbus/remotecontrolledcar/car/main.cpp
+++ b/examples/dbus/remotecontrolledcar/car/main.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "car.h"
-#include "car_adaptor_p.h"
+#include "car_adaptor.h"
#include <QtGui/QApplication>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsScene>
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
view.resize(400, 300);
view.show();
- new CarAdaptor(car);
+ new CarInterfaceAdaptor(car);
QDBusConnection connection = QDBusConnection::sessionBus();
connection.registerObject("/Car", car);
connection.registerService("com.trolltech.CarExample");
diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp
index 01be1bf..21662b4 100644
--- a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp
@@ -38,10 +38,10 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -i car_interface.h -p :car_interface.cpp car.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qqdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** This file may have been hand-edited. Look for HAND-EDIT comments
@@ -49,18 +49,17 @@
**
****************************************************************************/
-#include "car_interface_p.h"
-
+#include "car_interface.h"
/*
- * Implementation of interface class CarInterface
+ * Implementation of interface class ComTrolltechExamplesCarInterfaceInterface
*/
-CarInterface::CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ComTrolltechExamplesCarInterfaceInterface::ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
{
}
-CarInterface::~CarInterface()
+ComTrolltechExamplesCarInterfaceInterface::~ComTrolltechExamplesCarInterfaceInterface()
{
}
diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h b/examples/dbus/remotecontrolledcar/controller/car_interface.h
index 8a5a907..228481c 100644
--- a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h
+++ b/examples/dbus/remotecontrolledcar/controller/car_interface.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -38,18 +38,18 @@
** $QT_END_LICENSE$
**
**
-** This file was generated by dbusxml2cpp version 0.6
-** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml
+** This file was generated by qdbusxml2cpp version 0.7
+** Command line was: qdbusxml2cpp -p car_interface.h: car.xml
**
-** dbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** This is an auto-generated file.
** Do not edit! All changes made to it will be lost.
**
****************************************************************************/
-#ifndef CAR_INTERFACE_P_H_1156853585
-#define CAR_INTERFACE_P_H_1156853585
+#ifndef CAR_INTERFACE_H_1264772826
+#define CAR_INTERFACE_H_1264772826
#include <QtCore/QObject>
#include <QtCore/QByteArray>
@@ -63,7 +63,7 @@
/*
* Proxy class for interface com.trolltech.Examples.CarInterface
*/
-class CarInterface: public QDBusAbstractInterface
+class ComTrolltechExamplesCarInterfaceInterface: public QDBusAbstractInterface
{
Q_OBJECT
public:
@@ -71,33 +71,33 @@ public:
{ return "com.trolltech.Examples.CarInterface"; }
public:
- CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+ ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
- ~CarInterface();
+ ~ComTrolltechExamplesCarInterfaceInterface();
public Q_SLOTS: // METHODS
- inline QDBusReply<void> accelerate()
+ inline QDBusPendingReply<> accelerate()
{
QList<QVariant> argumentList;
- return callWithArgumentList(QDBus::Block, QLatin1String("accelerate"), argumentList);
+ return asyncCallWithArgumentList(QLatin1String("accelerate"), argumentList);
}
- inline QDBusReply<void> decelerate()
+ inline QDBusPendingReply<> decelerate()
{
QList<QVariant> argumentList;
- return callWithArgumentList(QDBus::Block, QLatin1String("decelerate"), argumentList);
+ return asyncCallWithArgumentList(QLatin1String("decelerate"), argumentList);
}
- inline QDBusReply<void> turnLeft()
+ inline QDBusPendingReply<> turnLeft()
{
QList<QVariant> argumentList;
- return callWithArgumentList(QDBus::Block, QLatin1String("turnLeft"), argumentList);
+ return asyncCallWithArgumentList(QLatin1String("turnLeft"), argumentList);
}
- inline QDBusReply<void> turnRight()
+ inline QDBusPendingReply<> turnRight()
{
QList<QVariant> argumentList;
- return callWithArgumentList(QDBus::Block, QLatin1String("turnRight"), argumentList);
+ return asyncCallWithArgumentList(QLatin1String("turnRight"), argumentList);
}
Q_SIGNALS: // SIGNALS
@@ -107,7 +107,7 @@ Q_SIGNALS: // SIGNALS
namespace com {
namespace trolltech {
namespace Examples {
- typedef ::CarInterface CarInterface;
+ typedef ::ComTrolltechExamplesCarInterfaceInterface CarInterface;
}
}
}
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp
index 00a8875..5fca9e3 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp
@@ -42,13 +42,13 @@
#include <QtGui>
#include "controller.h"
-#include "car_interface_p.h"
+#include "car_interface.h"
Controller::Controller(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
- car = new CarInterface("com.trolltech.CarExample", "/Car",
+ car = new com::trolltech::Examples::CarInterface("com.trolltech.CarExample", "/Car",
QDBusConnection::sessionBus(), this);
startTimer(1000);
}
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h
index 07a1355..caadff9 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.h
+++ b/examples/dbus/remotecontrolledcar/controller/controller.h
@@ -43,8 +43,7 @@
#define CONTROLLER_H
#include "ui_controller.h"
-
-class CarInterface;
+#include "car_interface.h"
class Controller : public QWidget
{
@@ -64,7 +63,7 @@ private slots:
private:
Ui::Controller ui;
- CarInterface *car;
+ com::trolltech::Examples::CarInterface *car;
};
#endif
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro
index 159e3b1..375b9d7 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.pro
+++ b/examples/dbus/remotecontrolledcar/controller/controller.pro
@@ -11,7 +11,7 @@ CONFIG += qdbus
# Input
# DBUS_INTERFACES += car.xml
FORMS += controller.ui
-HEADERS += car_interface_p.h controller.h
+HEADERS += car_interface.h controller.h
SOURCES += main.cpp car_interface.cpp controller.cpp
# install
diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml
new file mode 100644
index 0000000..d8361ba
--- /dev/null
+++ b/examples/declarative/animations/color-animation.qml
@@ -0,0 +1,71 @@
+import Qt 4.6
+import Qt.labs.particles 1.0
+
+Item {
+ id: window
+ width: 640; height: 480
+
+ // Let's draw the sky...
+ Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 }
+ ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 }
+ }
+ }
+ GradientStop {
+ position: 1.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 }
+ ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 }
+ }
+ }
+ }
+ }
+
+ // the sun, moon, and stars
+ Item {
+ width: parent.width; height: 2 * parent.height
+ transformOrigin: Item.Center
+ NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite }
+ Image {
+ source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter
+ transformOrigin: Item.Center; rotation: -3 * parent.rotation
+ }
+ Image {
+ source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter
+ transformOrigin: Item.Center; rotation: -parent.rotation
+ }
+ Particles {
+ x: 0; y: parent.height/2; width: parent.width; height: parent.height/2
+ source: "images/star.png"; angleDeviation: 360; velocity: 0
+ velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800
+ SequentialAnimation on opacity {
+ loops: Animation.Infinite
+ NumberAnimation { from: 0; to: 1; duration: 5000 }
+ NumberAnimation { from: 1; to: 0; duration: 5000 }
+ }
+ }
+ }
+
+ // ...and the ground.
+ Rectangle {
+ anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ SequentialAnimation on color {
+ loops: Animation.Infinite
+ ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 }
+ ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 }
+ }
+ }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+}
diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml
new file mode 100644
index 0000000..8f2655e
--- /dev/null
+++ b/examples/declarative/animations/easing.qml
@@ -0,0 +1,99 @@
+import Qt 4.6
+
+Rectangle {
+ id: window
+ width: 600; height: 460; color: "#232323"
+
+ ListModel {
+ id: easingTypes
+ ListElement { type: "Linear"; ballColor: "DarkRed" }
+ ListElement { type: "InQuad"; ballColor: "IndianRed" }
+ ListElement { type: "OutQuad"; ballColor: "Salmon" }
+ ListElement { type: "InOutQuad"; ballColor: "Tomato" }
+ ListElement { type: "OutInQuad"; ballColor: "DarkOrange" }
+ ListElement { type: "InCubic"; ballColor: "Gold" }
+ ListElement { type: "OutCubic"; ballColor: "Yellow" }
+ ListElement { type: "InOutCubic"; ballColor: "PeachPuff" }
+ ListElement { type: "OutInCubic"; ballColor: "Thistle" }
+ ListElement { type: "InQuart"; ballColor: "Orchid" }
+ ListElement { type: "OutQuart"; ballColor: "Purple" }
+ ListElement { type: "InOutQuart"; ballColor: "SlateBlue" }
+ ListElement { type: "OutInQuart"; ballColor: "Chartreuse" }
+ ListElement { type: "InQuint"; ballColor: "LimeGreen" }
+ ListElement { type: "OutQuint"; ballColor: "SeaGreen" }
+ ListElement { type: "InOutQuint"; ballColor: "DarkGreen" }
+ ListElement { type: "OutInQuint"; ballColor: "Olive" }
+ ListElement { type: "InSine"; ballColor: "DarkSeaGreen" }
+ ListElement { type: "OutSine"; ballColor: "Teal" }
+ ListElement { type: "InOutSine"; ballColor: "Turquoise" }
+ ListElement { type: "OutInSine"; ballColor: "SteelBlue" }
+ ListElement { type: "InExpo"; ballColor: "SkyBlue" }
+ ListElement { type: "OutExpo"; ballColor: "RoyalBlue" }
+ ListElement { type: "InOutExpo"; ballColor: "MediumBlue" }
+ ListElement { type: "OutInExpo"; ballColor: "MidnightBlue" }
+ ListElement { type: "InCirc"; ballColor: "CornSilk" }
+ ListElement { type: "OutCirc"; ballColor: "Bisque" }
+ ListElement { type: "InOutCirc"; ballColor: "RosyBrown" }
+ ListElement { type: "OutInCirc"; ballColor: "SandyBrown" }
+ ListElement { type: "InElastic"; ballColor: "DarkGoldenRod" }
+ ListElement { type: "OutElastic"; ballColor: "Chocolate" }
+ ListElement { type: "InOutElastic"; ballColor: "SaddleBrown" }
+ ListElement { type: "OutInElastic"; ballColor: "Brown" }
+ ListElement { type: "InBack"; ballColor: "Maroon" }
+ ListElement { type: "OutBack"; ballColor: "LavenderBlush" }
+ ListElement { type: "InOutBack"; ballColor: "MistyRose" }
+ ListElement { type: "OutInBack"; ballColor: "Gainsboro" }
+ ListElement { type: "OutBounce"; ballColor: "Silver" }
+ ListElement { type: "InBounce"; ballColor: "DimGray" }
+ ListElement { type: "InOutBounce"; ballColor: "SlateGray" }
+ ListElement { type: "OutInBounce"; ballColor: "DarkSlateGray" }
+ }
+
+ Component {
+ id: delegate
+
+ Item {
+ height: 42; width: window.width
+ Text { text: type; anchors.centerIn: parent; color: "White" }
+ Rectangle {
+ id: slot1; color: "#121212"; x: 30; height: 32; width: 32
+ border.color: "#343434"; border.width: 1; radius: 8; anchors.verticalCenter: parent.verticalCenter
+ }
+ Rectangle {
+ id: slot2; color: "#121212"; x: window.width - 62; height: 32; width: 32
+ border.color: "#343434"; border.width: 1; radius: 8; anchors.verticalCenter: parent.verticalCenter
+ }
+ Rectangle {
+ id: rect; x: 30; color: "#454545"
+ border.color: "White"; border.width: 2
+ height: 32; width: 32; radius: 8; anchors.verticalCenter: parent.verticalCenter
+
+ MouseArea {
+ onClicked: if (rect.state == '') rect.state = "right"; else rect.state = ''
+ anchors.fill: parent
+ }
+
+ states : State {
+ name: "right"
+ PropertyChanges { target: rect; x: window.width - 62; color: ballColor }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; easing.type: type; duration: 1000 }
+ ColorAnimation { properties: "color"; easing.type: type; duration: 1000 }
+ }
+ }
+ }
+ }
+ }
+
+ Flickable {
+ anchors.fill: parent; contentHeight: layout.height
+ Column {
+ id: layout
+ anchors.left: parent.left; anchors.right: parent.right
+ Repeater { model: easingTypes; delegate: delegate }
+ }
+ }
+}
diff --git a/examples/declarative/animations/images/face-smile.png b/examples/declarative/animations/images/face-smile.png
new file mode 100644
index 0000000..3d66d72
--- /dev/null
+++ b/examples/declarative/animations/images/face-smile.png
Binary files differ
diff --git a/examples/declarative/animations/images/moon.png b/examples/declarative/animations/images/moon.png
new file mode 100644
index 0000000..9407b2b
--- /dev/null
+++ b/examples/declarative/animations/images/moon.png
Binary files differ
diff --git a/examples/declarative/animations/images/shadow.png b/examples/declarative/animations/images/shadow.png
new file mode 100644
index 0000000..8270565
--- /dev/null
+++ b/examples/declarative/animations/images/shadow.png
Binary files differ
diff --git a/examples/declarative/animations/images/star.png b/examples/declarative/animations/images/star.png
new file mode 100644
index 0000000..27ef924
--- /dev/null
+++ b/examples/declarative/animations/images/star.png
Binary files differ
diff --git a/examples/declarative/animations/images/sun.png b/examples/declarative/animations/images/sun.png
new file mode 100644
index 0000000..7713ca5
--- /dev/null
+++ b/examples/declarative/animations/images/sun.png
Binary files differ
diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml
new file mode 100644
index 0000000..401feb5
--- /dev/null
+++ b/examples/declarative/animations/property-animation.qml
@@ -0,0 +1,64 @@
+import Qt 4.6
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ // Let's draw the sky...
+ Rectangle {
+ anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "DeepSkyBlue" }
+ GradientStop { position: 1.0; color: "LightSkyBlue" }
+ }
+ }
+
+ // ...and the ground.
+ Rectangle {
+ anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ // The shadow for the smiley face
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "images/shadow.png"; y: smiley.minHeight + 58
+ transformOrigin: Item.Center
+
+ // The scale property depends on the y position of the smiley face.
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "images/face-smile.png"; y: minHeight
+
+ // Animate the y property. Setting repeat to true makes the
+ // animation repeat indefinitely, otherwise it would only run once.
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing.type: "OutExpo"; duration: 300
+ }
+
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing.type: "OutBounce"; duration: 1000
+ }
+
+ // Then pause for 500ms
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml
new file mode 100644
index 0000000..6a031a4
--- /dev/null
+++ b/examples/declarative/aspectratio/face_fit.qml
@@ -0,0 +1,26 @@
+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: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ anchors.centerIn: parent
+ 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..79e99e9
--- /dev/null
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -0,0 +1,28 @@
+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: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ anchors.centerIn: parent
+ source: "pics/face.png"
+ x: (parent.width-width*scale)/2
+ y: (parent.height-height*scale)/2
+ SpringFollow on scale {
+ source: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height),
+ Math.min(face.parent.width/face.width,face.parent.height/face.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..3d66d72
--- /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..2e2b6ed
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_and_crop.qml
@@ -0,0 +1,21 @@
+import Qt 4.6
+
+// Here, we implement "Scale and Crop" behaviour.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ anchors.centerIn: parent
+ 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_crop_simple.qml b/examples/declarative/aspectratio/scale_and_crop_simple.qml
new file mode 100644
index 0000000..e720ce7
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_and_crop_simple.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+// Here, we implement "Scale to Fit" behaviour, using the
+// fillMode property.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ source: "pics/face.png"
+ fillMode: Image.PreserveAspectCrop
+ anchors.fill: parent
+ }
+}
diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml
new file mode 100644
index 0000000..8230e49
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml
@@ -0,0 +1,22 @@
+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: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ anchors.centerIn: parent
+ 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..eae4d16
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_to_fit.qml
@@ -0,0 +1,22 @@
+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: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ anchors.centerIn: parent
+ 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..7389581
--- /dev/null
+++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+// Here, we implement "Scale to Fit" behaviour, using the
+// fillMode property.
+//
+Rectangle {
+ // default size: whole image, unscaled
+ width: face.width
+ height: face.height
+ color: "gray"
+ clip: true
+
+ Image {
+ id: face
+ smooth: true
+ source: "pics/face.png"
+ fillMode: Image.PreserveAspectFit
+ anchors.fill: parent
+ }
+}
diff --git a/examples/declarative/behaviours/SideRect.qml b/examples/declarative/behaviours/SideRect.qml
new file mode 100644
index 0000000..63b7db2
--- /dev/null
+++ b/examples/declarative/behaviours/SideRect.qml
@@ -0,0 +1,17 @@
+import Qt 4.6
+
+Rectangle {
+ id: myRect
+
+ property string text
+
+ color: "black"
+ width: 75; height: 50
+ radius: 5
+ border.width: 10; border.color: "white";
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: { focusRect.x = myRect.x; focusRect.y = myRect.y; focusRect.text = myRect.text }
+ }
+}
diff --git a/examples/declarative/behaviours/behavior-example.qml b/examples/declarative/behaviours/behavior-example.qml
new file mode 100644
index 0000000..c84bf62
--- /dev/null
+++ b/examples/declarative/behaviours/behavior-example.qml
@@ -0,0 +1,72 @@
+import Qt 4.6
+
+Rectangle {
+ color: "black"
+ width: 400; height: 400
+
+ Rectangle {
+ color: "transparent"
+ anchors.centerIn: parent
+ width: 200; height: 200
+ radius: 30
+ border.width: 10; border.color: "white";
+
+ SideRect {
+ id: leftRect
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.left
+ text: "Left"
+ }
+
+ SideRect {
+ id: rightRect
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.right
+ text: "Right"
+ }
+
+ SideRect {
+ id: topRect
+ anchors.verticalCenter: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Top"
+ }
+
+ SideRect {
+ id: bottomRect
+ anchors.verticalCenter: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Bottom"
+ }
+
+
+ Rectangle {
+ id: focusRect
+
+ property string text
+
+ color: "red"
+ width: 75; height: 50
+ radius: 5
+ border.width: 10; border.color: "white";
+ x: 100-37; y: 100-25
+ Behavior on x { NumberAnimation { duration: 300 } }
+ Behavior on y { NumberAnimation { duration: 300 } }
+ Text {
+ id: focusText
+ text: focusRect.text;
+ Behavior on text {
+ SequentialAnimation {
+ NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 }
+ PropertyAction {}
+ NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 }
+ }
+ }
+ anchors.centerIn: parent;
+ color: "white";
+ font.pixelSize: 16
+ font.bold: true
+ }
+ }
+ }
+}
diff --git a/examples/declarative/border-image/animated.qml b/examples/declarative/border-image/animated.qml
new file mode 100644
index 0000000..29c02b3
--- /dev/null
+++ b/examples/declarative/border-image/animated.qml
@@ -0,0 +1,55 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ id: page
+ color: "white"
+ width: 1030; height: 540
+
+ MyBorderImage {
+ x: 20; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ }
+ MyBorderImage {
+ x: 270; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat
+ }
+ MyBorderImage {
+ x: 520; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat
+ }
+ MyBorderImage {
+ x: 770; y: 20; minWidth: 120; maxWidth: 240
+ minHeight: 120; maxHeight: 240
+ source: "content/colors.png"; margin: 30
+ horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round
+ }
+ MyBorderImage {
+ x: 20; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ }
+ MyBorderImage {
+ x: 270; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat
+ }
+ MyBorderImage {
+ x: 520; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat
+ }
+ MyBorderImage {
+ x: 770; y: 280; minWidth: 60; maxWidth: 200
+ minHeight: 40; maxHeight: 200
+ source: "content/bw.png"; margin: 10
+ horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round
+ }
+}
diff --git a/examples/declarative/border-image/borders.qml b/examples/declarative/border-image/borders.qml
new file mode 100644
index 0000000..9879416
--- /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: "content/colors-stretch.sci"
+ }
+ BorderImage {
+ x: 270; y: 20; width: 230; height: 240
+ smooth: true
+ source: "content/colors-round.sci"
+ }
+}
diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml
new file mode 100644
index 0000000..f0c3cfc
--- /dev/null
+++ b/examples/declarative/border-image/content/MyBorderImage.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+
+Item {
+ property alias horizontalMode: image.horizontalTileMode
+ property alias verticalMode: image.verticalTileMode
+ property alias source: image.source
+
+ property int minWidth
+ property int minHeight
+ property int maxWidth
+ property int maxHeight
+ property int margin
+
+ id: container
+ width: 240; height: 240
+
+ BorderImage {
+ id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2
+
+ SequentialAnimation on width {
+ loops: Animation.Infinite
+ NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" }
+ }
+
+ SequentialAnimation on height {
+ loops: Animation.Infinite
+ NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" }
+ }
+
+ border.top: container.margin
+ border.left: container.margin
+ border.bottom: container.margin
+ border.right: container.margin
+ }
+}
diff --git a/examples/declarative/border-image/content/bw.png b/examples/declarative/border-image/content/bw.png
new file mode 100644
index 0000000..486eaae
--- /dev/null
+++ b/examples/declarative/border-image/content/bw.png
Binary files differ
diff --git a/examples/declarative/border-image/content/colors-round.sci b/examples/declarative/border-image/content/colors-round.sci
new file mode 100644
index 0000000..506f6f5
--- /dev/null
+++ b/examples/declarative/border-image/content/colors-round.sci
@@ -0,0 +1,7 @@
+border.left:30
+border.top:30
+border.right:30
+border.bottom:30
+horizontalTileRule:Round
+verticalTileRule:Round
+source:colors.png
diff --git a/examples/declarative/border-image/content/colors-stretch.sci b/examples/declarative/border-image/content/colors-stretch.sci
new file mode 100644
index 0000000..e4989a7
--- /dev/null
+++ b/examples/declarative/border-image/content/colors-stretch.sci
@@ -0,0 +1,5 @@
+border.left:30
+border.top:30
+border.right:30
+border.bottom:30
+source:colors.png
diff --git a/examples/declarative/border-image/content/colors.png b/examples/declarative/border-image/content/colors.png
new file mode 100644
index 0000000..dfb62f3
--- /dev/null
+++ b/examples/declarative/border-image/content/colors.png
Binary files differ
diff --git a/examples/declarative/clocks/clocks.qml b/examples/declarative/clocks/clocks.qml
new file mode 100644
index 0000000..624748a
--- /dev/null
+++ b/examples/declarative/clocks/clocks.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ width: childrenRect.width
+ height: childrenRect.height
+ color: "#646464"
+
+ Grid {
+ columns: 3
+ Clock { city: "New York"; shift: -4 }
+ Clock { city: "Mumbai"; shift: 5.5 }
+ Clock { city: "Tokyo"; shift: 9 }
+ }
+}
diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml
new file mode 100644
index 0000000..75a1cf5
--- /dev/null
+++ b/examples/declarative/clocks/content/Clock.qml
@@ -0,0 +1,80 @@
+import Qt 4.6
+
+Item {
+ id: clock
+ width: 200; height: 230
+
+ property alias city: cityLabel.text
+ property var hours
+ property var minutes
+ property var seconds
+ property var shift : 0
+ property bool night: false
+
+ function timeChanged() {
+ var date = new Date;
+ hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
+ if ( hours < 7 || hours > 19 ) night = true; else night = false
+ minutes = shift ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
+ seconds = date.getUTCSeconds();
+ }
+
+ Timer {
+ interval: 100; running: true; repeat: true; triggeredOnStart: true
+ onTriggered: clock.timeChanged()
+ }
+
+ Image { id: background; source: "clock.png"; visible: clock.night == false }
+ Image { source: "clock-night.png"; visible: clock.night == true }
+
+ Image {
+ x: 92.5; y: 27
+ source: "hour.png"
+ smooth: true
+ transform: Rotation {
+ id: hourRotation
+ origin.x: 7.5; origin.y: 73; angle: 0
+ SpringFollow on angle {
+ spring: 2; damping: 0.2; modulus: 360
+ source: (clock.hours * 30) + (clock.minutes * 0.5)
+ }
+ }
+ }
+
+ Image {
+ x: 93.5; y: 17
+ source: "minute.png"
+ smooth: true
+ transform: Rotation {
+ id: minuteRotation
+ origin.x: 6.5; origin.y: 83; angle: 0
+ SpringFollow on angle {
+ spring: 2; damping: 0.2; modulus: 360
+ source: clock.minutes * 6
+ }
+ }
+ }
+
+ Image {
+ x: 97.5; y: 20
+ source: "second.png"
+ smooth: true
+ transform: Rotation {
+ id: secondRotation
+ origin.x: 2.5; origin.y: 80; angle: 0
+ SpringFollow on angle {
+ spring: 5; damping: 0.25; modulus: 360
+ source: clock.seconds * 6
+ }
+ }
+ }
+
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/examples/declarative/clocks/content/background.png b/examples/declarative/clocks/content/background.png
new file mode 100644
index 0000000..a885950
--- /dev/null
+++ b/examples/declarative/clocks/content/background.png
Binary files differ
diff --git a/examples/declarative/clocks/content/center.png b/examples/declarative/clocks/content/center.png
new file mode 100755
index 0000000..7fbd802
--- /dev/null
+++ b/examples/declarative/clocks/content/center.png
Binary files differ
diff --git a/examples/declarative/clocks/content/clock-night.png b/examples/declarative/clocks/content/clock-night.png
new file mode 100755
index 0000000..cc7151a
--- /dev/null
+++ b/examples/declarative/clocks/content/clock-night.png
Binary files differ
diff --git a/examples/declarative/clocks/content/clock.png b/examples/declarative/clocks/content/clock.png
new file mode 100755
index 0000000..462edac
--- /dev/null
+++ b/examples/declarative/clocks/content/clock.png
Binary files differ
diff --git a/examples/declarative/clocks/content/hour.png b/examples/declarative/clocks/content/hour.png
new file mode 100755
index 0000000..f8061a1
--- /dev/null
+++ b/examples/declarative/clocks/content/hour.png
Binary files differ
diff --git a/examples/declarative/clocks/content/minute.png b/examples/declarative/clocks/content/minute.png
new file mode 100755
index 0000000..1297ec7
--- /dev/null
+++ b/examples/declarative/clocks/content/minute.png
Binary files differ
diff --git a/examples/declarative/clocks/content/second.png b/examples/declarative/clocks/content/second.png
new file mode 100755
index 0000000..4aa9fb5
--- /dev/null
+++ b/examples/declarative/clocks/content/second.png
Binary files differ
diff --git a/examples/declarative/connections/connections-example.qml b/examples/declarative/connections/connections-example.qml
new file mode 100644
index 0000000..c35bda5
--- /dev/null
+++ b/examples/declarative/connections/connections-example.qml
@@ -0,0 +1,27 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ id: window; color: "#646464"
+ width: 640; height: 480
+
+ property int angle: 0
+
+ Image {
+ id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center
+ rotation: window.angle
+ Behavior on rotation { NumberAnimation { easing.type: "OutCubic"; duration: 300 } }
+ }
+
+ Button {
+ id: leftButton; image: "content/rotate-left.png"
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 10 }
+ }
+ Button {
+ id: rightButton; image: "content/rotate-right.png"
+ anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 }
+ }
+
+ Connections { target: leftButton; onClicked: window.angle -= 90 }
+ Connections { target: rightButton; onClicked: window.angle += 90 }
+}
diff --git a/examples/declarative/connections/content/Button.qml b/examples/declarative/connections/content/Button.qml
new file mode 100644
index 0000000..0e33c78
--- /dev/null
+++ b/examples/declarative/connections/content/Button.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+
+Item {
+ id: button
+ width: 48; height: 48
+
+ property alias image: icon.source
+ signal clicked
+
+ Image { id: icon }
+ MouseArea { anchors.fill: icon; onClicked: button.clicked() }
+}
diff --git a/examples/declarative/connections/content/bg1.jpg b/examples/declarative/connections/content/bg1.jpg
new file mode 100644
index 0000000..dfc7cee
--- /dev/null
+++ b/examples/declarative/connections/content/bg1.jpg
Binary files differ
diff --git a/examples/declarative/connections/content/rotate-left.png b/examples/declarative/connections/content/rotate-left.png
new file mode 100644
index 0000000..c30387e
--- /dev/null
+++ b/examples/declarative/connections/content/rotate-left.png
Binary files differ
diff --git a/examples/declarative/connections/content/rotate-right.png b/examples/declarative/connections/content/rotate-right.png
new file mode 100644
index 0000000..1b05674
--- /dev/null
+++ b/examples/declarative/connections/content/rotate-right.png
Binary files differ
diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro
new file mode 100644
index 0000000..bddfbee
--- /dev/null
+++ b/examples/declarative/declarative.pro
@@ -0,0 +1,49 @@
+TEMPLATE = subdirs
+
+# These examples contain some C++ and need to be built
+SUBDIRS = \
+ extending \
+ imageprovider \
+ objectlistmodel \
+ plugins \
+ widgets
+
+# These examples contain no C++ and can simply be copied
+sources.files = \
+ animations \
+ aspectratio \
+ behaviours \
+ border-image \
+ clocks \
+ connections \
+ dial \
+ dynamic \
+ effects \
+ fillmode \
+ focus \
+ focusscope \
+ fonts \
+ gridview \
+ layouts \
+ listview \
+ mousearea \
+ package \
+ parallax \
+ progressbar \
+ scrollbar \
+ searchbox \
+ slideswitch \
+ sql \
+ states \
+ tabwidget \
+ tic-tac-toe \
+ tutorials \
+ tvtennis \
+ velocity \
+ webview \
+ workerlistmodel \
+ workerscript \
+ xmldata \
+ xmlhttprequest
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative
+INSTALLS += sources
diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml
new file mode 100644
index 0000000..ad4717a
--- /dev/null
+++ b/examples/declarative/dial/content/Dial.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+
+Item {
+ id: root
+ property real value : 0
+
+ width: 210; height: 210
+
+ Image { 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
+ SpringFollow on angle {
+ spring: 1.4
+ damping: .15
+ source: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ }
+ }
+ }
+ Image { x: 21; y: 18; source: "overlay.png" }
+}
diff --git a/examples/declarative/dial/content/background.png b/examples/declarative/dial/content/background.png
new file mode 100644
index 0000000..75d555d
--- /dev/null
+++ b/examples/declarative/dial/content/background.png
Binary files differ
diff --git a/examples/declarative/dial/content/needle.png b/examples/declarative/dial/content/needle.png
new file mode 100644
index 0000000..2d19f75
--- /dev/null
+++ b/examples/declarative/dial/content/needle.png
Binary files differ
diff --git a/examples/declarative/dial/content/needle_shadow.png b/examples/declarative/dial/content/needle_shadow.png
new file mode 100644
index 0000000..8d8a928
--- /dev/null
+++ b/examples/declarative/dial/content/needle_shadow.png
Binary files differ
diff --git a/examples/declarative/dial/content/overlay.png b/examples/declarative/dial/content/overlay.png
new file mode 100644
index 0000000..3860a7b
--- /dev/null
+++ b/examples/declarative/dial/content/overlay.png
Binary files differ
diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml
new file mode 100644
index 0000000..3aed70e
--- /dev/null
+++ b/examples/declarative/dial/dial-example.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ color: "#545454"
+ width: 300; height: 300
+
+ // Dial with a slider to adjust it
+ Dial { id: dial; anchors.centerIn: parent; value: slider.x *100 / (container.width - 34) }
+
+ Rectangle {
+ id: container
+ anchors.bottom: parent.bottom; anchors.bottomMargin: 10
+ anchors.left: parent.left; anchors.leftMargin: 20
+ anchors.right: parent.right; anchors.rightMargin: 20; height: 16
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "gray" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+ radius: 8; opacity: 0.7; smooth: true
+ Rectangle {
+ id: slider
+ x: 1; y: 1; width: 30; height: 14
+ radius: 6; smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#424242" }
+ GradientStop { position: 1.0; color: "black" }
+ }
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: container.width - 32
+ }
+ }
+ }
+}
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
new file mode 100644
index 0000000..7de4d38
--- /dev/null
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -0,0 +1,122 @@
+import Qt 4.6
+import Qt.labs.particles 1.0
+import "qml"
+
+Item {
+ id: window
+ //This is a desktop-sized example
+ width: 1024; height: 512
+ property int activeSuns: 0
+
+ // sky
+ Rectangle { id: sky
+ anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter }
+ gradient: Gradient {
+ GradientStop { id: stopA; position: 0.0; color: "#0E1533" }
+ GradientStop { id: stopB; position: 1.0; color: "#437284" }
+ }
+ }
+
+ // stars (when there's no sun)
+ Particles {
+ id: stars
+ x: 0; y: 0; width: parent.width; height: parent.height / 2
+ source: "images/star.png"; angleDeviation: 360; velocity: 0
+ velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800
+ opacity: 1
+ }
+
+ // ground, which has a z such that the sun can set behind it
+ Rectangle {
+ id: ground
+ z: 2
+ anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.right; bottom: parent.bottom }
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "ForestGreen" }
+ GradientStop { position: 1.0; color: "DarkGreen" }
+ }
+ }
+
+ //Day state, for when you place a sun
+ states: State {
+ name: "Day"; when: window.activeSuns > 0
+ PropertyChanges { target: stopA; color: "DeepSkyBlue"}
+ PropertyChanges { target: stopB; color: "SkyBlue"}
+ PropertyChanges { target: stars; opacity: 0 }
+ }
+
+ transitions: Transition {
+ PropertyAnimation { duration: 3000 }
+ ColorAnimation { duration: 3000 }
+ }
+
+ SystemPalette { id: activePalette }
+
+ // toolbox
+ Rectangle {
+ id: toolbox
+ z: 3 //Above ground
+ color: activePalette.window;
+ width: 480
+ anchors { right: parent.right; top:parent.top; bottom: parent.bottom }
+ Rectangle { //Not a child of any positioner
+ color: "white"; border.color: "black";
+ width: toolRow.width + 4
+ height: toolRow.height + 4
+ x: toolboxPositioner.x + toolRow.x - 2
+ y: toolboxPositioner.y + toolRow.y - 2
+ }
+ Column {
+ id: toolboxPositioner
+ anchors.centerIn: parent
+ spacing: 8
+ Text { text: "Drag an item into the scene." }
+ Row {
+ id: toolRow
+ spacing: 8;
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ file: "Sun.qml";
+ image: "../images/sun.png"
+ }
+ PaletteItem {
+ file: "GenericItem.qml"
+ image: "../images/moon.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ file: "PerspectiveItem.qml"
+ image: "../images/tree_s.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ file: "PerspectiveItem.qml"
+ image: "../images/rabbit_brown.png"
+ }
+ PaletteItem {
+ anchors.verticalCenter: parent.verticalCenter
+ file: "PerspectiveItem.qml"
+ image: "../images/rabbit_bw.png"
+ }
+ }
+ Text { text: "Active Suns: " + activeSuns }
+ Rectangle { width: 440; height: 1; color: "black" }
+ Text { text: "Arbitrary QML: " }
+ TextEdit {
+ id: qmlText
+ width: 460
+ height: 220
+ readOnly: false
+ focusOnPress: true
+ font.pixelSize: 14
+
+ text: "import Qt 4.6\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ }
+ Button {
+ text: "Create"
+ onClicked: createQmlObject(qmlText.text, window, 'CustomObject');
+ }
+ }
+ }
+
+}
diff --git a/examples/declarative/dynamic/images/NOTE b/examples/declarative/dynamic/images/NOTE
new file mode 100644
index 0000000..fcd87f9
--- /dev/null
+++ b/examples/declarative/dynamic/images/NOTE
@@ -0,0 +1 @@
+Images (except star.png) are from the KDE project.
diff --git a/examples/declarative/dynamic/images/face-smile.png b/examples/declarative/dynamic/images/face-smile.png
new file mode 100644
index 0000000..3d66d72
--- /dev/null
+++ b/examples/declarative/dynamic/images/face-smile.png
Binary files differ
diff --git a/examples/declarative/dynamic/images/moon.png b/examples/declarative/dynamic/images/moon.png
new file mode 100644
index 0000000..1c0d606
--- /dev/null
+++ b/examples/declarative/dynamic/images/moon.png
Binary files differ
diff --git a/examples/declarative/dynamic/images/rabbit_brown.png b/examples/declarative/dynamic/images/rabbit_brown.png
new file mode 100644
index 0000000..ebfdeed
--- /dev/null
+++ b/examples/declarative/dynamic/images/rabbit_brown.png
Binary files differ
diff --git a/examples/declarative/dynamic/images/rabbit_bw.png b/examples/declarative/dynamic/images/rabbit_bw.png
new file mode 100644
index 0000000..7bff9b9
--- /dev/null
+++ b/examples/declarative/dynamic/images/rabbit_bw.png
Binary files differ
diff --git a/examples/declarative/dynamic/images/star.png b/examples/declarative/dynamic/images/star.png
new file mode 100644
index 0000000..27ef924
--- /dev/null
+++ b/examples/declarative/dynamic/images/star.png
Binary files differ
diff --git a/examples/declarative/dynamic/images/sun.png b/examples/declarative/dynamic/images/sun.png
new file mode 100644
index 0000000..7713ca5
--- /dev/null
+++ b/examples/declarative/dynamic/images/sun.png
Binary files differ
diff --git a/examples/declarative/dynamic/images/tree_s.png b/examples/declarative/dynamic/images/tree_s.png
new file mode 100644
index 0000000..6eac35a
--- /dev/null
+++ b/examples/declarative/dynamic/images/tree_s.png
Binary files differ
diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml
new file mode 100644
index 0000000..757e295
--- /dev/null
+++ b/examples/declarative/dynamic/qml/Button.qml
@@ -0,0 +1,24 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+
+ property var text
+ signal clicked
+
+ SystemPalette { id: activePalette }
+ height: text.height + 10
+ width: text.width + 20
+ border.width: 1
+ radius: 4; smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0;
+ color: if(!mr.pressed){activePalette.light;}else{activePalette.button;}
+ }
+ GradientStop { position: 1.0;
+ color: if(!mr.pressed){activePalette.button;}else{activePalette.dark;}
+ }
+ }
+ MouseArea { id:mr; anchors.fill: parent; onClicked: container.clicked() }
+ Text { id: text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text; color: activePalette.buttonText }
+}
diff --git a/examples/declarative/dynamic/qml/GenericItem.qml b/examples/declarative/dynamic/qml/GenericItem.qml
new file mode 100644
index 0000000..10e3dba
--- /dev/null
+++ b/examples/declarative/dynamic/qml/GenericItem.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+Item{
+ property bool created: false
+ property string image
+ width: imageItem.width
+ height: imageItem.height
+ z: 2
+ Image{
+ id: imageItem
+ source: image;
+ }
+}
diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml
new file mode 100644
index 0000000..08bdc40
--- /dev/null
+++ b/examples/declarative/dynamic/qml/PaletteItem.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+import "itemCreation.js" as Code
+
+GenericItem {
+ id: itemButton
+ property string file
+ MouseArea {
+ anchors.fill: parent;
+ onPressed: Code.startDrag(mouse);
+ onPositionChanged: Code.moveDrag(mouse);
+ onReleased: Code.endDrag(mouse);
+ }
+}
diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml
new file mode 100644
index 0000000..a0dfad3
--- /dev/null
+++ b/examples/declarative/dynamic/qml/PerspectiveItem.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+
+Image {
+ id: tree
+ property bool created: false
+ property double scaleFactor: Math.max((y+height-250)*0.01, 0.3)
+ property double scaledBottom: y + (height+height*scaleFactor)/2
+ property bool onLand: scaledBottom > window.height/2
+ property string image //Needed for compatibility with GenericItem
+ opacity: onLand ? 1 : 0.25
+ onCreatedChanged: if (created && !onLand) { tree.destroy() } else { z = scaledBottom }
+ scale: scaleFactor
+ transformOrigin: "Center"
+ source: image; smooth: true
+ onYChanged: z = scaledBottom
+}
diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml
new file mode 100644
index 0000000..81b6e9b
--- /dev/null
+++ b/examples/declarative/dynamic/qml/Sun.qml
@@ -0,0 +1,24 @@
+import Qt 4.6
+
+Image {
+ id: sun
+ property bool created: false
+ property string image: "../images/sun.png"
+ onCreatedChanged: if(created){window.activeSuns++;}else{window.activeSuns--;}
+
+ source: image;
+ z: 1
+
+ //x and y get set when instantiated
+ //head offscreen
+ NumberAnimation on y {
+ to: window.height / 2;
+ running: created
+ onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen";
+ }
+
+ states: State {
+ name: "OffScreen";
+ StateChangeScript { script: { sun.created = false; sun.destroy() } }
+ }
+}
diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js
new file mode 100644
index 0000000..ccc03aa
--- /dev/null
+++ b/examples/declarative/dynamic/qml/itemCreation.js
@@ -0,0 +1,82 @@
+var itemComponent = null;
+var draggedItem = null;
+var startingMouse;
+var startingZ;
+//Until QT-2385 is resolved we need to convert to scene coordinates manually
+var xOffset;
+var yOffset;
+function setSceneOffset()
+{
+ xOffset = 0;
+ yOffset = 0;
+ var p = itemButton;
+ while(p != window){
+ xOffset += p.x;
+ yOffset += p.y;
+ p = p.parent;
+ }
+}
+
+function startDrag(mouse)
+{
+ setSceneOffset();
+ startingMouse = { x: mouse.x, y: mouse.y }
+ loadComponent();
+}
+
+//Creation is split into two functions due to an asyncronous wait while
+//possible external files are loaded.
+
+function loadComponent() {
+ if (itemComponent != null) //Already loaded the component
+ createItem();
+
+ itemComponent = createComponent(itemButton.file);
+ //print(itemButton.file)
+ if(itemComponent.isLoading){
+ component.statusChanged.connect(finishCreation);
+ }else{//Depending on the content, it can be ready or error immediately
+ createItem();
+ }
+}
+
+function createItem() {
+ if (itemComponent.isReady && draggedItem == null) {
+ draggedItem = itemComponent.createObject();
+ draggedItem.parent = window;
+ draggedItem.image = itemButton.image;
+ draggedItem.x = xOffset;
+ draggedItem.y = yOffset;
+ startingZ = draggedItem.z;
+ draggedItem.z = 4;//On top
+ } else if (itemComponent.isError) {
+ draggedItem = null;
+ print("error creating component");
+ print(component.errorsString());
+ }
+}
+
+function moveDrag(mouse)
+{
+ if(draggedItem == null)
+ return;
+
+ draggedItem.x = mouse.x + xOffset - startingMouse.x;
+ draggedItem.y = mouse.y + yOffset - startingMouse.y;
+}
+
+function endDrag(mouse)
+{
+ if(draggedItem == null)
+ return;
+
+ if(draggedItem.x + draggedItem.width > toolbox.x){ //Don't drop it in the toolbox
+ draggedItem.destroy();
+ draggedItem = null;
+ }else{
+ draggedItem.z = startingZ;
+ draggedItem.created = true;
+ draggedItem = null;
+ }
+}
+
diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml
new file mode 100644
index 0000000..2280a2a
--- /dev/null
+++ b/examples/declarative/effects/effects.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 400
+ height: 200
+
+ Image {
+ id: blur
+ x: 5
+ source: "pic.png"
+
+ effect: Blur {
+ NumberAnimation on blurRadius {
+ id: blurEffect
+ running: false
+ from: 0; to: 10
+ duration: 1000
+ loops: Animation.Infinite
+ }
+ }
+
+ MouseArea { anchors.fill: parent; onClicked: blurEffect.running = !blurEffect.running }
+ }
+
+ Text { text: "Blur"; anchors.top: blur.bottom; anchors.horizontalCenter: blur.horizontalCenter }
+
+ Image {
+ id: dropShadow
+ source: "pic.png"
+ x: 135
+
+ effect: DropShadow {
+ blurRadius: 3
+ offset.x: 3
+ NumberAnimation on offset.y { id: dropShadowEffect; from: 0; to: 10; duration: 1000; running: false; loops: Animation.Infinite; }
+ }
+
+ MouseArea { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running }
+ }
+
+ Image {
+ id: colorize
+ source: "pic.png"
+ x: 265
+
+ effect: Colorize { color: "blue" }
+ }
+
+ Text { text: "Colorize"; anchors.top: colorize.bottom; anchors.horizontalCenter: colorize.horizontalCenter }
+
+ Text { text: "Drop Shadow"; anchors.top: dropShadow.bottom; anchors.horizontalCenter: dropShadow.horizontalCenter }
+
+ Text {
+ y: 155; anchors.horizontalCenter: parent.horizontalCenter
+ text: "Clicking Blur or Drop Shadow will \ntoggle animation."
+ color: "black"
+ }
+
+}
diff --git a/examples/declarative/effects/pic.png b/examples/declarative/effects/pic.png
new file mode 100644
index 0000000..051e738
--- /dev/null
+++ b/examples/declarative/effects/pic.png
Binary files differ
diff --git a/examples/declarative/extending/adding/adding.pro b/examples/declarative/extending/adding/adding.pro
new file mode 100644
index 0000000..6072de4
--- /dev/null
+++ b/examples/declarative/extending/adding/adding.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+TARGET = adding
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp
+HEADERS += person.h
+RESOURCES += adding.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding
+INSTALLS += target sources
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..c608f94
--- /dev/null
+++ b/examples/declarative/extending/adding/example.qml
@@ -0,0 +1,8 @@
+import People 1.0
+
+// ![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..b9e5aa3
--- /dev/null
+++ b/examples/declarative/extending/adding/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<Person>("People", 1,0, "Person");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
+ Person *person = qobject_cast<Person *>(component.create());
+ if (person) {
+ qWarning() << "The person's name is" << person->name();
+ 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..cdf08e0
--- /dev/null
+++ b/examples/declarative/extending/adding/person.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+// ![0]
diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h
new file mode 100644
index 0000000..fbaf2df
--- /dev/null
+++ b/examples/declarative/extending/adding/person.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+// ![0]
+#include <qdeclarative.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..f6d76ed
--- /dev/null
+++ b/examples/declarative/extending/attached/attached.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = attached
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += attached.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached
+INSTALLS += target sources
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..d4f2675
--- /dev/null
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ m_rsvp = d;
+}
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
+BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
+{
+ return new BirthdayPartyAttached(object);
+}
+
diff --git a/examples/assistant/simpletextviewer/findfiledialog.h b/examples/declarative/extending/attached/birthdayparty.h
index aac27f1..d8ca2e1 100644
--- a/examples/assistant/simpletextviewer/findfiledialog.h
+++ b/examples/declarative/extending/attached/birthdayparty.h
@@ -38,62 +38,52 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
-#ifndef FINDFILEDIALOG_H
-#define FINDFILEDIALOG_H
+#include <QObject>
+#include <QDate>
+#include <qdeclarative.h>
+#include "person.h"
-#include <QAssistantClient>
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QDialogButtonBox;
-class QLabel;
-class QTextEdit;
-class QToolButton;
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-//! [0]
-class FindFileDialog : public QDialog
+class BirthdayPartyAttached : public QObject
{
- Q_OBJECT
-
+Q_OBJECT
+Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp)
public:
- FindFileDialog(QTextEdit *editor, QAssistantClient *assistant,
- QWidget *parent = 0);
+ BirthdayPartyAttached(QObject *object);
-private slots:
- void browse();
- void help();
- void openFile(QTreeWidgetItem *item = 0);
- void update();
+ QDate rsvp() const;
+ void setRsvp(const QDate &);
private:
- void findFiles();
- void showFiles(const QStringList &files);
-
- void createButtons();
- void createComboBoxes();
- void createFilesTree();
- void createLabels();
- void createLayout();
-
- QAssistantClient *currentAssistantClient;
- QTextEdit *currentEditor;
- QTreeWidget *foundFilesTree;
+ QDate m_rsvp;
+};
+QML_DECLARE_TYPE(BirthdayPartyAttached)
- QComboBox *directoryComboBox;
- QComboBox *fileNameComboBox;
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
- QLabel *directoryLabel;
- QLabel *fileNameLabel;
+ Person *celebrant() const;
+ void setCelebrant(Person *);
- QDialogButtonBox *buttonBox;
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
- QToolButton *browseButton;
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+private:
+ Person *m_celebrant;
+ QList<Person *> m_guests;
};
-//! [0]
-#endif
+QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
+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..952eb93
--- /dev/null
+++ b/examples/declarative/extending/attached/example.qml
@@ -0,0 +1,29 @@
+import People 1.0
+
+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..fd2d525
--- /dev/null
+++ b/examples/declarative/extending/attached/main.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayPartyAttached>();
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<ShoeDescription>();
+ qmlRegisterType<Person>();
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii) {
+ Person *guest = party->guest(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..0a9e508
--- /dev/null
+++ b/examples/declarative/extending/attached/person.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+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;
+}
+
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
diff --git a/examples/declarative/extending/attached/person.h b/examples/declarative/extending/attached/person.h
new file mode 100644
index 0000000..0f86d8b
--- /dev/null
+++ b/examples/declarative/extending/attached/person.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qdeclarative.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..903712e
--- /dev/null
+++ b/examples/declarative/extending/binding/binding.pro
@@ -0,0 +1,19 @@
+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
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding
+INSTALLS += target sources
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..e5be2b9
--- /dev/null
+++ b/examples/declarative/extending/binding/birthdayparty.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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();
+ }
+}
+
+
+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();
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
+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);
+}
+
diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h
new file mode 100644
index 0000000..8486442
--- /dev/null
+++ b/examples/declarative/extending/binding/birthdayparty.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <QDebug>
+#include <qdeclarative.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(QDeclarativeListProperty<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 *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+ 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;
+ QList<Person *> m_guests;
+};
+
+QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
+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..b66bc86
--- /dev/null
+++ b/examples/declarative/extending/binding/example.qml
@@ -0,0 +1,37 @@
+import People 1.0
+
+// ![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: console.log("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..aa5f937
--- /dev/null
+++ b/examples/declarative/extending/binding/happybirthday.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "happybirthday.h"
+#include <QTimer>
+
+HappyBirthday::HappyBirthday(QObject *parent)
+: QObject(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 QDeclarativeProperty &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));
+}
+
diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h
new file mode 100644
index 0000000..eb2da5e
--- /dev/null
+++ b/examples/declarative/extending/binding/happybirthday.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef HAPPYBIRTHDAY_H
+#define HAPPYBIRTHDAY_H
+
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeProperty>
+#include <qdeclarative.h>
+
+#include <QStringList>
+
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
+{
+Q_OBJECT
+Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+public:
+ HappyBirthday(QObject *parent = 0);
+
+ virtual void setTarget(const QDeclarativeProperty &);
+
+ QString name() const;
+ void setName(const QString &);
+
+private slots:
+ void advance();
+
+signals:
+ void nameChanged();
+private:
+ int m_line;
+ QStringList m_lyrics;
+ QDeclarativeProperty 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..ce6c50d
--- /dev/null
+++ b/examples/declarative/extending/binding/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "happybirthday.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+ qmlRegisterType<BirthdayPartyAttached>();
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<HappyBirthday>("People", 1,0, "HappyBirthday");
+ qmlRegisterType<ShoeDescription>();
+ qmlRegisterType<Person>();
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii) {
+ Person *guest = party->guest(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..9a2248f
--- /dev/null
+++ b/examples/declarative/extending/binding/person.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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();
+}
+
+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;
+}
+
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
diff --git a/examples/declarative/extending/binding/person.h b/examples/declarative/extending/binding/person.h
new file mode 100644
index 0000000..1bec71c
--- /dev/null
+++ b/examples/declarative/extending/binding/person.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qdeclarative.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..523a42d
--- /dev/null
+++ b/examples/declarative/extending/coercion/birthdayparty.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
new file mode 100644
index 0000000..fffd407
--- /dev/null
+++ b/examples/declarative/extending/coercion/birthdayparty.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qdeclarative.h>
+#include "person.h"
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+// ![0]
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+// ![0]
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+private:
+ Person *m_celebrant;
+ QList<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..c8daed8
--- /dev/null
+++ b/examples/declarative/extending/coercion/coercion.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = coercion
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += coercion.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion
+INSTALLS += target sources
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..64d26b0
--- /dev/null
+++ b/examples/declarative/extending/coercion/example.qml
@@ -0,0 +1,15 @@
+import People 1.0
+
+// ![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..312aff9
--- /dev/null
+++ b/examples/declarative/extending/coercion/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+// ![0]
+ qmlRegisterType<Person>();
+// ![0]
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii)
+ qWarning() << " " << party->guest(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..5b5203a
--- /dev/null
+++ b/examples/declarative/extending/coercion/person.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+// ![1]
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
+// ![1]
diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h
new file mode 100644
index 0000000..298ffb1
--- /dev/null
+++ b/examples/declarative/extending/coercion/person.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <qdeclarative.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..523a42d
--- /dev/null
+++ b/examples/declarative/extending/default/birthdayparty.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h
new file mode 100644
index 0000000..49c20bd
--- /dev/null
+++ b/examples/declarative/extending/default/birthdayparty.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qdeclarative.h>
+#include "person.h"
+
+// ![0]
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+private:
+ Person *m_celebrant;
+ QList<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..32aff0b
--- /dev/null
+++ b/examples/declarative/extending/default/default.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = default
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += default.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default
+INSTALLS += target sources
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..58035f9
--- /dev/null
+++ b/examples/declarative/extending/default/example.qml
@@ -0,0 +1,14 @@
+import People 1.0
+
+// ![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..06282ad
--- /dev/null
+++ b/examples/declarative/extending/default/main.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<Person>();
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii)
+ qWarning() << " " << party->guest(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..69216d3
--- /dev/null
+++ b/examples/declarative/extending/default/person.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
diff --git a/examples/declarative/extending/default/person.h b/examples/declarative/extending/default/person.h
new file mode 100644
index 0000000..b3eceaa
--- /dev/null
+++ b/examples/declarative/extending/default/person.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <qdeclarative.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..985ce20
--- /dev/null
+++ b/examples/declarative/extending/extended/example.qml
@@ -0,0 +1,7 @@
+import People 1.0
+
+// ![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..97af286
--- /dev/null
+++ b/examples/declarative/extending/extended/extended.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+TARGET = extended
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ lineedit.cpp
+HEADERS += lineedit.h
+RESOURCES += extended.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended
+INSTALLS += target sources
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..417fbd9
--- /dev/null
+++ b/examples/declarative/extending/extended/lineedit.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "lineedit.h"
+#include <qdeclarative.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;
+}
+
+void 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;
+}
+
+void 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;
+}
+
+void 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;
+}
+
+void 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);
diff --git a/examples/declarative/extending/extended/lineedit.h b/examples/declarative/extending/extended/lineedit.h
new file mode 100644
index 0000000..ca96d05
--- /dev/null
+++ b/examples/declarative/extending/extended/lineedit.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef 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;
+ void setLeftMargin(int);
+
+ int rightMargin() const;
+ void setRightMargin(int);
+
+ int topMargin() const;
+ void setTopMargin(int);
+
+ int bottomMargin() const;
+ void 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..ca7242d
--- /dev/null
+++ b/examples/declarative/extending/extended/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include <QLineEdit>
+#include "lineedit.h"
+
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterExtendedType<QLineEdit, LineEditExtension>("People", 1,0, "QLineEdit");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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/extending.pro b/examples/declarative/extending/extending.pro
new file mode 100644
index 0000000..169c7ab
--- /dev/null
+++ b/examples/declarative/extending/extending.pro
@@ -0,0 +1,13 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ adding \
+ attached \
+ binding \
+ coercion \
+ default \
+ extended \
+ grouped \
+ properties \
+ signal \
+ valuesource
diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp
new file mode 100644
index 0000000..523a42d
--- /dev/null
+++ b/examples/declarative/extending/grouped/birthdayparty.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h
new file mode 100644
index 0000000..42439c4
--- /dev/null
+++ b/examples/declarative/extending/grouped/birthdayparty.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qdeclarative.h>
+#include "person.h"
+
+class BirthdayParty : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+private:
+ Person *m_celebrant;
+ QList<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..55912ed
--- /dev/null
+++ b/examples/declarative/extending/grouped/example.qml
@@ -0,0 +1,33 @@
+import People 1.0
+
+// ![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..576e1d2
--- /dev/null
+++ b/examples/declarative/extending/grouped/grouped.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = grouped
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += grouped.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped
+INSTALLS += target sources
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..b383a8b
--- /dev/null
+++ b/examples/declarative/extending/grouped/main.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<ShoeDescription>();
+ qmlRegisterType<Person>();
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii) {
+ Person *guest = party->guest(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..0a9e508
--- /dev/null
+++ b/examples/declarative/extending/grouped/person.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+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;
+}
+
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
diff --git a/examples/declarative/extending/grouped/person.h b/examples/declarative/extending/grouped/person.h
new file mode 100644
index 0000000..5dab378
--- /dev/null
+++ b/examples/declarative/extending/grouped/person.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qdeclarative.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..14fd6a3
--- /dev/null
+++ b/examples/declarative/extending/properties/birthdayparty.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+// ![0]
+
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
new file mode 100644
index 0000000..c4cb536
--- /dev/null
+++ b/examples/declarative/extending/properties/birthdayparty.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <qdeclarative.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(QDeclarativeListProperty<Person> guests READ guests)
+// ![2]
+// ![3]
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+private:
+ Person *m_celebrant;
+ QList<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..9594a84
--- /dev/null
+++ b/examples/declarative/extending/properties/example.qml
@@ -0,0 +1,15 @@
+import People 1.0
+
+// ![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..350f8bd
--- /dev/null
+++ b/examples/declarative/extending/properties/main.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<Person>("People", 1,0, "Person");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii)
+ qWarning() << " " << party->guest(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..92c54f5
--- /dev/null
+++ b/examples/declarative/extending/properties/person.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h
new file mode 100644
index 0000000..860a607
--- /dev/null
+++ b/examples/declarative/extending/properties/person.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <qdeclarative.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..a8f4301
--- /dev/null
+++ b/examples/declarative/extending/properties/properties.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = properties
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += properties.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties
+INSTALLS += target sources
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..65ff530
--- /dev/null
+++ b/examples/declarative/extending/signal/birthdayparty.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ m_rsvp = d;
+}
+
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
+void BirthdayParty::startParty()
+{
+ QTime time = QTime::currentTime();
+ emit partyStarted(time);
+}
+
+BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
+{
+ return new BirthdayPartyAttached(object);
+}
+
diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h
new file mode 100644
index 0000000..bcdc513
--- /dev/null
+++ b/examples/declarative/extending/signal/birthdayparty.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <qdeclarative.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(QDeclarativeListProperty<Person> guests READ guests)
+Q_CLASSINFO("DefaultProperty", "guests")
+public:
+ BirthdayParty(QObject *parent = 0);
+
+ Person *celebrant() const;
+ void setCelebrant(Person *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+
+ void startParty();
+// ![0]
+signals:
+ void partyStarted(const QTime &time);
+// ![0]
+
+private:
+ Person *m_celebrant;
+ QList<Person *> m_guests;
+};
+
+QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
+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..c7d4792
--- /dev/null
+++ b/examples/declarative/extending/signal/example.qml
@@ -0,0 +1,32 @@
+import People 1.0
+
+// ![0]
+BirthdayParty {
+ onPartyStarted: console.log("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..1b23a46
--- /dev/null
+++ b/examples/declarative/extending/signal/main.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayPartyAttached>();
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<ShoeDescription>();
+ qmlRegisterType<Person>();
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii) {
+ Person *guest = party->guest(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..0a9e508
--- /dev/null
+++ b/examples/declarative/extending/signal/person.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+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;
+}
+
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
diff --git a/examples/declarative/extending/signal/person.h b/examples/declarative/extending/signal/person.h
new file mode 100644
index 0000000..0f86d8b
--- /dev/null
+++ b/examples/declarative/extending/signal/person.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qdeclarative.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..6367a38
--- /dev/null
+++ b/examples/declarative/extending/signal/signal.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = signal
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ person.cpp \
+ birthdayparty.cpp
+HEADERS += person.h \
+ birthdayparty.h
+RESOURCES += signal.qrc
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal
+INSTALLS += target sources
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..99d98be
--- /dev/null
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "birthdayparty.h"
+
+BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
+: QObject(object)
+{
+}
+
+QDate BirthdayPartyAttached::rsvp() const
+{
+ return m_rsvp;
+}
+
+void BirthdayPartyAttached::setRsvp(const QDate &d)
+{
+ m_rsvp = d;
+}
+
+
+BirthdayParty::BirthdayParty(QObject *parent)
+: QObject(parent), m_celebrant(0)
+{
+}
+
+Person *BirthdayParty::celebrant() const
+{
+ return m_celebrant;
+}
+
+void BirthdayParty::setCelebrant(Person *c)
+{
+ m_celebrant = c;
+}
+
+QDeclarativeListProperty<Person> BirthdayParty::guests()
+{
+ return QDeclarativeListProperty<Person>(this, m_guests);
+}
+
+int BirthdayParty::guestCount() const
+{
+ return m_guests.count();
+}
+
+Person *BirthdayParty::guest(int index) const
+{
+ return m_guests.at(index);
+}
+
+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);
+}
+
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
new file mode 100644
index 0000000..819a200
--- /dev/null
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BIRTHDAYPARTY_H
+#define BIRTHDAYPARTY_H
+
+#include <QObject>
+#include <QDate>
+#include <QDebug>
+#include <qdeclarative.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(QDeclarativeListProperty<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 *);
+
+ QDeclarativeListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
+
+ QString speaker() const;
+ void setSpeaker(const QString &);
+
+ static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
+
+ void startParty();
+signals:
+ void partyStarted(const QTime &time);
+
+private:
+ Person *m_celebrant;
+ QList<Person *> m_guests;
+};
+
+QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
+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..7cdf8c0
--- /dev/null
+++ b/examples/declarative/extending/valuesource/example.qml
@@ -0,0 +1,36 @@
+import People 1.0
+
+// ![0]
+BirthdayParty {
+ speaker: HappyBirthday { name: "Bob Jones" }
+// ![0]
+
+ onPartyStarted: console.log("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..0dbbd6e
--- /dev/null
+++ b/examples/declarative/extending/valuesource/happybirthday.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "happybirthday.h"
+#include <QTimer>
+
+HappyBirthday::HappyBirthday(QObject *parent)
+: QObject(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 QDeclarativeProperty &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));
+}
+
diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h
new file mode 100644
index 0000000..b48c012
--- /dev/null
+++ b/examples/declarative/extending/valuesource/happybirthday.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef HAPPYBIRTHDAY_H
+#define HAPPYBIRTHDAY_H
+
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeProperty>
+#include <qdeclarative.h>
+
+#include <QStringList>
+
+// ![0]
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
+{
+Q_OBJECT
+// ![0]
+Q_PROPERTY(QString name READ name WRITE setName)
+// ![1]
+public:
+ HappyBirthday(QObject *parent = 0);
+
+ virtual void setTarget(const QDeclarativeProperty &);
+// ![1]
+
+ QString name() const;
+ void setName(const QString &);
+
+private slots:
+ void advance();
+
+private:
+ int m_line;
+ QStringList m_lyrics;
+ QDeclarativeProperty 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..2574917
--- /dev/null
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QCoreApplication>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "happybirthday.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ qmlRegisterType<BirthdayPartyAttached>();
+ qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty");
+ qmlRegisterType<HappyBirthday>("People", 1,0, "HappyBirthday");
+ qmlRegisterType<ShoeDescription>();
+ qmlRegisterType<Person>();
+ qmlRegisterType<Boy>("People", 1,0, "Boy");
+ qmlRegisterType<Girl>("People", 1,0, "Girl");
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent 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->guestCount(); ++ii) {
+ Person *guest = party->guest(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..0a9e508
--- /dev/null
+++ b/examples/declarative/extending/valuesource/person.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "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;
+}
+
+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;
+}
+
+
+Boy::Boy(QObject * parent)
+: Person(parent)
+{
+}
+
+
+Girl::Girl(QObject * parent)
+: Person(parent)
+{
+}
+
diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h
new file mode 100644
index 0000000..0f86d8b
--- /dev/null
+++ b/examples/declarative/extending/valuesource/person.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PERSON_H
+#define PERSON_H
+
+#include <QObject>
+#include <QColor>
+#include <qdeclarative.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..d3409b6
--- /dev/null
+++ b/examples/declarative/extending/valuesource/valuesource.pro
@@ -0,0 +1,19 @@
+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
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource
+INSTALLS += target sources
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..3f2020c
--- /dev/null
+++ b/examples/declarative/fillmode/fillmode.qml
@@ -0,0 +1,41 @@
+import Qt 4.6
+
+Image {
+ width: 400
+ height: 250
+ source: "face.png"
+ SequentialAnimation on fillMode {
+ loops: Animation.Infinite
+ PropertyAction { value: Image.Stretch }
+ PropertyAction { target: label; property: "text"; value: "Stretch" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: Image.PreserveAspectFit }
+ PropertyAction { target: label; property: "text"; value: "PreserveAspectFit" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: Image.PreserveAspectCrop }
+ PropertyAction { target: label; property: "text"; value: "PreserveAspectCrop" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: Image.Tile }
+ PropertyAction { target: label; property: "text"; value: "Tile" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: Image.TileHorizontally }
+ PropertyAction { target: label; property: "text"; value: "TileHorizontally" }
+ PauseAnimation { duration: 1000 }
+ PropertyAction { value: Image.TileVertically }
+ PropertyAction { target: label; property: "text"; value: "TileVertically" }
+ PauseAnimation { duration: 1000 }
+ }
+ Text {
+ id: label
+ font.pointSize: 24
+ color: "blue"
+ style: Text.Outline
+ styleColor: "white"
+ anchors { centerIn: parent }
+ }
+ Rectangle {
+ border.color: "black"
+ color: "transparent"
+ anchors { fill: parent; rightMargin: 1; bottomMargin: 1}
+ }
+}
diff --git a/examples/declarative/flipable/back.png b/examples/declarative/flipable/back.png
new file mode 100644
index 0000000..0b4cafc
--- /dev/null
+++ b/examples/declarative/flipable/back.png
Binary files differ
diff --git a/examples/declarative/flipable/flipable-example.qml b/examples/declarative/flipable/flipable-example.qml
new file mode 100644
index 0000000..c837ebc
--- /dev/null
+++ b/examples/declarative/flipable/flipable-example.qml
@@ -0,0 +1,37 @@
+//! [0]
+import Qt 4.6
+
+Flipable {
+ id: flipable
+ width: 240
+ height: 240
+
+ property int angle: 0
+ property bool flipped: false
+
+ front: Image { source: "front.png" }
+ back: Image { source: "back.png" }
+
+ transform: Rotation {
+ origin.x: flipable.width/2; origin.y: flipable.height/2
+ axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"
+ PropertyChanges { target: flipable; angle: 180 }
+ when: flipable.flipped
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "angle"; duration: 1000 }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: flipable.flipped = !flipable.flipped
+ }
+}
+//! [0]
+
diff --git a/examples/declarative/flipable/front.png b/examples/declarative/flipable/front.png
new file mode 100644
index 0000000..796b605
--- /dev/null
+++ b/examples/declarative/flipable/front.png
Binary files differ
diff --git a/examples/declarative/focus/Core/ContextMenu.qml b/examples/declarative/focus/Core/ContextMenu.qml
new file mode 100644
index 0000000..bd6d8a2
--- /dev/null
+++ b/examples/declarative/focus/Core/ContextMenu.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+
+FocusScope {
+ id: container
+ property bool open: false
+
+ Item {
+ anchors.fill: parent
+
+ Rectangle {
+ anchors.fill: parent; color: "#D1DBBD"; focus: true
+ Keys.onRightPressed: mainView.focus = true
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/GridMenu.qml b/examples/declarative/focus/Core/GridMenu.qml
new file mode 100644
index 0000000..03d837a
--- /dev/null
+++ b/examples/declarative/focus/Core/GridMenu.qml
@@ -0,0 +1,54 @@
+import Qt 4.6
+
+FocusScope {
+ property alias interactive: gridView.interactive
+
+ onWantsFocusChanged: if (wantsFocus) mainView.state = ""
+
+ Rectangle {
+ clip: true; anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#193441" }
+ GradientStop { position: 1.0; color: Qt.darker("#193441") }
+ }
+
+ GridView {
+ id: gridView; cellWidth: 152; cellHeight: 152; focus: true
+ x: 20; width: parent.width - 40; height: parent.height
+ model: 12
+ KeyNavigation.down: listViews
+ KeyNavigation.left: contextMenu
+
+ delegate: Item {
+ id: container; width: GridView.view.cellWidth; height: GridView.view.cellHeight
+
+ Rectangle {
+ id: content
+ color: "transparent"; smooth: true
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10
+ Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
+ Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
+ }
+
+ MouseArea {
+ id: mouseArea; anchors.fill: parent; hoverEnabled: true
+ onClicked: {
+ GridView.view.currentIndex = index
+ container.focus = true
+ gridMenu.focus = true
+ mainView.focus = true
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.focus == true
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/ListViewDelegate.qml b/examples/declarative/focus/Core/ListViewDelegate.qml
new file mode 100644
index 0000000..b7e067a
--- /dev/null
+++ b/examples/declarative/focus/Core/ListViewDelegate.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Component {
+ Item {
+ id: container
+ x: 5; width: ListView.view.width - 10; height: 60
+
+ Rectangle {
+ id: content
+ color: "transparent"; smooth: true
+ anchors.centerIn: parent; width: container.width - 40; height: container.height - 10; radius: 10
+ Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
+ Text {
+ text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent
+ font.pixelSize: 14
+ }
+ }
+
+ MouseArea {
+ id: mouseArea; anchors.fill: parent; hoverEnabled: true
+ onClicked: {
+ ListView.view.currentIndex = index
+ container.focus = true
+ ListView.view.focus = true
+ listViews.focus = true
+ mainView.focus = true
+ }
+ }
+
+ states: State {
+ name: "active"; when: container.focus == true
+ PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; duration: 100 }
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/ListViews.qml b/examples/declarative/focus/Core/ListViews.qml
new file mode 100644
index 0000000..3cc4836
--- /dev/null
+++ b/examples/declarative/focus/Core/ListViews.qml
@@ -0,0 +1,47 @@
+import Qt 4.6
+
+FocusScope {
+ clip: true
+
+ onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews"
+
+ ListView {
+ id: list1
+ delegate: ListViewDelegate {}
+ y: wantsFocus ? 10 : 40; focus: true; width: parent.width / 3; height: parent.height - 20
+ model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
+ Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ }
+
+ ListView {
+ id: list2
+ delegate: ListViewDelegate {}
+ y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
+ Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ }
+
+ ListView {
+ id: list3
+ delegate: ListViewDelegate {}
+ y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ model: 10; KeyNavigation.up: gridMenu; KeyNavigation.left: list2
+ Behavior on y { NumberAnimation { duration: 600; easing.type: "OutQuint" } }
+ }
+
+ Rectangle { width: parent.width; height: 1; color: "#D1DBBD" }
+ Rectangle {
+ y: 1; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#3E606F" }
+ GradientStop { position: 1.0; color: "transparent" }
+ }
+ }
+ Rectangle {
+ y: parent.height - 10; width: parent.width; height: 10
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#3E606F" }
+ GradientStop { position: 0.0; color: "transparent" }
+ }
+ }
+}
diff --git a/examples/declarative/focus/Core/images/arrow.png b/examples/declarative/focus/Core/images/arrow.png
new file mode 100644
index 0000000..14978c2
--- /dev/null
+++ b/examples/declarative/focus/Core/images/arrow.png
Binary files differ
diff --git a/examples/declarative/focus/Core/images/qt-logo.png b/examples/declarative/focus/Core/images/qt-logo.png
new file mode 100644
index 0000000..14ddf2a
--- /dev/null
+++ b/examples/declarative/focus/Core/images/qt-logo.png
Binary files differ
diff --git a/examples/declarative/focus/Core/qmldir b/examples/declarative/focus/Core/qmldir
new file mode 100644
index 0000000..0460d9c
--- /dev/null
+++ b/examples/declarative/focus/Core/qmldir
@@ -0,0 +1,4 @@
+ContextMenu ContextMenu.qml
+GridMenu GridMenu.qml
+ListViews Listviews.qml
+ListViewDelegate ListViewDelegate.qml
diff --git a/examples/declarative/focus/focus.qml b/examples/declarative/focus/focus.qml
new file mode 100644
index 0000000..a8dc3c8
--- /dev/null
+++ b/examples/declarative/focus/focus.qml
@@ -0,0 +1,50 @@
+import Qt 4.6
+import "Core" 1.0
+
+Rectangle {
+ id: window; width: 800; height: 480; color: "#3E606F"
+
+ FocusScope {
+ id: mainView; focus: true; width: parent.width; height: parent.height
+
+ GridMenu {
+ id: gridMenu; focus: true
+ width: parent.width; height: 320; interactive: parent.wantsFocus
+ }
+
+ ListViews { id: listViews; y: 320; width: parent.width; height: 320 }
+
+ Rectangle { id: shade; color: "black"; opacity: 0; anchors.fill: parent }
+
+ states: State {
+ name: "showListViews"
+ PropertyChanges { target: gridMenu; y: -160 }
+ PropertyChanges { target: listViews; y: 160 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "y"; duration: 600; easing.type: "OutQuint" }
+ }
+ }
+
+ Image {
+ source: "Core/images/arrow.png"; rotation: 90; anchors.verticalCenter: parent.verticalCenter
+ MouseArea {
+ anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 }
+ onClicked: window.state = "contextMenuOpen"
+ }
+ }
+
+ ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height }
+
+ states: State {
+ name: "contextMenuOpen"; when: !mainView.wantsFocus
+ PropertyChanges { target: contextMenu; x: 0; open: true }
+ PropertyChanges { target: mainView; x: 130 }
+ PropertyChanges { target: shade; opacity: 0.25 }
+ }
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: "OutQuint" }
+ }
+}
diff --git a/examples/declarative/focusscope/test.qml b/examples/declarative/focusscope/test.qml
new file mode 100644
index 0000000..e4332e7
--- /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: console.log("Error - Root")
+
+ FocusScope {
+ id: myScope
+ focus: true
+
+ Keys.onDigit9Pressed: console.log("Error - FocusScope")
+
+ Rectangle {
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ border.color: myScope.wantsFocus?"blue":"black"
+
+ Rectangle {
+ id: item1
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ Keys.onDigit9Pressed: console.log("Top Left");
+ KeyNavigation.right: item2
+ focus: true
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+ Rectangle {
+ id: item2
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ KeyNavigation.left: item1
+ Keys.onDigit9Pressed: console.log("Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"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: wantsFocus?"blue":"black"
+
+ Keys.onDigit9Pressed: console.log("Bottom Left");
+ KeyNavigation.up: myScope
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+}
diff --git a/examples/declarative/focusscope/test2.qml b/examples/declarative/focusscope/test2.qml
new file mode 100644
index 0000000..5b6971a
--- /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.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+
+ FocusScope {
+ y: 100
+ focus: true
+ Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml
new file mode 100644
index 0000000..9344d07
--- /dev/null
+++ b/examples/declarative/focusscope/test3.qml
@@ -0,0 +1,52 @@
+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: console.log("Error - " + name)
+ Rectangle {
+ focus: true
+ Keys.onDigit9Pressed: console.log(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
+ preferredHighlightBegin: 100
+ preferredHighlightEnd: 100
+ highlightRangeMode: "StrictlyEnforceRange"
+ }
+
+
+ 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/focusscope/test4.qml b/examples/declarative/focusscope/test4.qml
new file mode 100644
index 0000000..cc96df9
--- /dev/null
+++ b/examples/declarative/focusscope/test4.qml
@@ -0,0 +1,75 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Keys.onDigit9Pressed: console.log("Error - Root")
+
+ FocusScope {
+ id: myScope
+
+ Keys.onDigit9Pressed: console.log("Error - FocusScope")
+
+ Rectangle {
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ border.color: myScope.wantsFocus?"blue":"black"
+
+ Rectangle {
+ id: item1
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ Keys.onDigit9Pressed: console.log("Error - Top Left");
+ KeyNavigation.right: item2
+ focus: true
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+ Rectangle {
+ id: item2
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ KeyNavigation.left: item1
+ Keys.onDigit9Pressed: console.log("Error - Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+ }
+ KeyNavigation.down: item3
+ }
+
+ Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." }
+
+ Rectangle {
+ id: item3
+ x: 10; y: 300
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+
+ Keys.onDigit9Pressed: console.log("Error - Bottom Left");
+ KeyNavigation.up: myScope
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+
+}
diff --git a/examples/declarative/focusscope/test5.qml b/examples/declarative/focusscope/test5.qml
new file mode 100644
index 0000000..da98350
--- /dev/null
+++ b/examples/declarative/focusscope/test5.qml
@@ -0,0 +1,83 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 800
+ height: 600
+
+ Keys.onReturnPressed: console.log("Error - Root")
+
+ FocusScope {
+ id: myScope
+ focus: true
+
+ Keys.onReturnPressed: console.log("Error - FocusScope")
+
+ Rectangle {
+ height: 120
+ width: 420
+
+ color: "transparent"
+ border.width: 5
+ border.color: myScope.wantsFocus?"blue":"black"
+
+ Rectangle {
+ x: 10; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: item1.wantsFocus?"blue":"black"
+ }
+
+ TextEdit {
+ id: item1
+ x: 20; y: 20
+ width: 90; height: 90
+ color: "white"
+ font.pixelSize: 20
+ Keys.onReturnPressed: console.log("Top Left");
+ KeyNavigation.right: item2
+ focus: true
+ wrap: true
+ text: "Box 1"
+ }
+
+ Rectangle {
+ id: item2
+ x: 310; y: 10
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: wantsFocus?"blue":"black"
+ KeyNavigation.left: item1
+ Keys.onReturnPressed: console.log("Top Right");
+
+ Rectangle {
+ width: 50; height: 50; anchors.centerIn: parent
+ color: parent.focus?"red":"transparent"
+ }
+ }
+ }
+ KeyNavigation.down: item3
+ }
+
+ Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" }
+
+ Rectangle {
+ x: 10; y: 300
+ width: 100; height: 100; color: "green"
+ border.width: 5
+ border.color: item3.wantsFocus?"blue":"black"
+ }
+
+ TextEdit {
+ id: item3
+ x: 20; y: 310
+ width: 90; height: 90
+ color: "white"
+ font.pixelSize: 20
+ text: "Box 3"
+
+ Keys.onReturnPressed: console.log("Bottom Left");
+ KeyNavigation.up: myScope
+ wrap: true
+ }
+}
diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml
new file mode 100644
index 0000000..957246f
--- /dev/null
+++ b/examples/declarative/fonts/banner.qml
@@ -0,0 +1,18 @@
+import Qt 4.6
+
+Rectangle {
+ id: screen
+ width: 640; height: 320; color: "steelblue"
+
+ property int pixelSize: screen.height * 1.25
+ property color textColor: "lightsteelblue"
+ property string text: "Hello world! "
+
+ Row {
+ y: -screen.height / 4.5
+ NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite }
+ Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text }
+ }
+}
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml
new file mode 100644
index 0000000..e928df4
--- /dev/null
+++ b/examples/declarative/fonts/fonts.qml
@@ -0,0 +1,56 @@
+import Qt 4.6
+
+Rectangle {
+ property string myText: "The quick brown fox jumps over the lazy dog."
+
+ width: 800; height: 480
+ color: "steelblue"
+
+ FontLoader { id: fixedFont; name: "Courier" }
+ FontLoader { id: localFont; source: "fonts/tarzenau-ocr-a.ttf" }
+ FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
+
+ Column {
+ anchors.fill: parent; spacing: 15
+ anchors.leftMargin: 10; anchors.rightMargin: 10
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideRight
+ font.family: "Times"; font.pointSize: 42
+ }
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideLeft
+ font.family: "Times"; font.pointSize: 42
+ font.capitalization: Font.AllUppercase
+ }
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideMiddle
+ font.family: fixedFont.name; font.pointSize: 42; font.weight: Font.Bold
+ font.capitalization: Font.AllLowercase
+ }
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideRight
+ font.family: fixedFont.name; font.pointSize: 42; font.italic: true
+ font.capitalization: Font.SmallCaps
+ }
+ Text {
+ text: myText; color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideLeft
+ font.family: localFont.name; font.pointSize: 42
+ font.capitalization: Font.Capitalize
+ }
+ Text {
+ text: {
+ if (webFont.status == 1) myText
+ else if (webFont.status == 2) "Loading..."
+ else if (webFont.status == 3) "Error loading font"
+ }
+ color: "lightsteelblue"
+ width: parent.width; elide: Text.ElideMiddle
+ font.family: webFont.name; font.pointSize: 42
+ }
+ }
+}
diff --git a/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf b/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf
new file mode 100644
index 0000000..cf93f96
--- /dev/null
+++ b/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml
new file mode 100644
index 0000000..e15a0f0
--- /dev/null
+++ b/examples/declarative/fonts/hello.qml
@@ -0,0 +1,27 @@
+import Qt 4.6
+
+Rectangle {
+ id: screen; width: 800; height: 480; color: "black"
+
+ Item {
+ id: container; x: screen.width / 2; y: screen.height / 2
+ Text {
+ id: text; color: "white"; anchors.centerIn: parent
+ text: "Hello world!"; font.pixelSize: 60
+
+ SequentialAnimation on font.letterSpacing {
+ loops: Animation.Infinite;
+ NumberAnimation { from: 100; to: 300; easing.type: "InQuad"; duration: 3000 }
+ ScriptAction { script: {
+ container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
+ container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
+ } }
+ }
+ SequentialAnimation on opacity {
+ loops: Animation.Infinite;
+ NumberAnimation { from: 1; to: 0; duration: 2600 }
+ PauseAnimation { duration: 400 }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/gridview/gridview-example.qml b/examples/declarative/gridview/gridview-example.qml
new file mode 100644
index 0000000..93931c7
--- /dev/null
+++ b/examples/declarative/gridview/gridview-example.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Rectangle {
+ width: 300; height: 400; color: "white"
+
+ ListModel {
+ id: appModel
+ ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" }
+ ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" }
+ ListElement { name: "Camera"; icon: "pics/Camera_48.png" }
+ ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" }
+ ListElement { name: "Messaging"; icon: "pics/EMail_48.png" }
+ ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" }
+ ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" }
+ }
+
+ Component {
+ id: appDelegate
+ Item {
+ width: 100; height: 100
+ Image { id: myIcon; y: 20; anchors.horizontalCenter: parent.horizontalCenter; source: icon }
+ Text { anchors.top: myIcon.bottom; anchors.horizontalCenter: parent.horizontalCenter; text: name }
+ }
+ }
+
+ Component {
+ id: appHighlight
+ Rectangle { width: 80; height: 80; color: "lightsteelblue" }
+ }
+
+ GridView {
+ anchors.fill: parent
+ cellWidth: 100; cellHeight: 100
+ model: appModel; delegate: appDelegate
+ highlight: appHighlight
+ focus: true
+ }
+}
diff --git a/examples/declarative/gridview/pics/AddressBook_48.png b/examples/declarative/gridview/pics/AddressBook_48.png
new file mode 100644
index 0000000..1ab7c8e
--- /dev/null
+++ b/examples/declarative/gridview/pics/AddressBook_48.png
Binary files differ
diff --git a/examples/declarative/gridview/pics/AudioPlayer_48.png b/examples/declarative/gridview/pics/AudioPlayer_48.png
new file mode 100644
index 0000000..f4b8689
--- /dev/null
+++ b/examples/declarative/gridview/pics/AudioPlayer_48.png
Binary files differ
diff --git a/examples/declarative/gridview/pics/Camera_48.png b/examples/declarative/gridview/pics/Camera_48.png
new file mode 100644
index 0000000..c76b524
--- /dev/null
+++ b/examples/declarative/gridview/pics/Camera_48.png
Binary files differ
diff --git a/examples/declarative/gridview/pics/DateBook_48.png b/examples/declarative/gridview/pics/DateBook_48.png
new file mode 100644
index 0000000..58f5787
--- /dev/null
+++ b/examples/declarative/gridview/pics/DateBook_48.png
Binary files differ
diff --git a/examples/declarative/gridview/pics/EMail_48.png b/examples/declarative/gridview/pics/EMail_48.png
new file mode 100644
index 0000000..d6d84a6
--- /dev/null
+++ b/examples/declarative/gridview/pics/EMail_48.png
Binary files differ
diff --git a/examples/declarative/gridview/pics/TodoList_48.png b/examples/declarative/gridview/pics/TodoList_48.png
new file mode 100644
index 0000000..0988448
--- /dev/null
+++ b/examples/declarative/gridview/pics/TodoList_48.png
Binary files differ
diff --git a/examples/declarative/gridview/pics/VideoPlayer_48.png b/examples/declarative/gridview/pics/VideoPlayer_48.png
new file mode 100644
index 0000000..52638c5
--- /dev/null
+++ b/examples/declarative/gridview/pics/VideoPlayer_48.png
Binary files differ
diff --git a/examples/declarative/imageprovider/ImageProviderCore/qmldir b/examples/declarative/imageprovider/ImageProviderCore/qmldir
new file mode 100644
index 0000000..1028590
--- /dev/null
+++ b/examples/declarative/imageprovider/ImageProviderCore/qmldir
@@ -0,0 +1,2 @@
+plugin imageprovider
+
diff --git a/examples/declarative/imageprovider/imageprovider-example.qml b/examples/declarative/imageprovider/imageprovider-example.qml
new file mode 100644
index 0000000..a895821
--- /dev/null
+++ b/examples/declarative/imageprovider/imageprovider-example.qml
@@ -0,0 +1,24 @@
+import Qt 4.6
+import "ImageProviderCore"
+//![0]
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Item {
+ width: 100
+ height: 50
+ Text {
+ text: "Loading..."
+ anchors.centerIn: parent
+ }
+ Image {
+ source: modelData
+ sourceSize: "50x25"
+ }
+ }
+ }
+}
+//![0]
diff --git a/examples/declarative/imageprovider/imageprovider.cpp b/examples/declarative/imageprovider/imageprovider.cpp
new file mode 100644
index 0000000..4c4aa94
--- /dev/null
+++ b/examples/declarative/imageprovider/imageprovider.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <qdeclarativeextensionplugin.h>
+
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeimageprovider.h>
+#include <qdeclarativeview.h>
+#include <QImage>
+#include <QPainter>
+
+/*
+ This example illustrates using a QDeclarativeImageProvider to serve
+ images asynchronously.
+*/
+
+//![0]
+class ColorImageProvider : public QDeclarativeImageProvider
+{
+public:
+ // This is run in a low priority thread.
+ QImage request(const QString &id, QSize *size, const QSize &req_size)
+ {
+ if (size) *size = QSize(100,50);
+ QImage image(
+ req_size.width() > 0 ? req_size.width() : 100,
+ req_size.height() > 0 ? req_size.height() : 50,
+ QImage::Format_RGB32);
+ image.fill(QColor(id).rgba());
+ QPainter p(&image);
+ QFont f = p.font();
+ f.setPixelSize(30);
+ p.setFont(f);
+ p.setPen(Qt::black);
+ if (req_size.isValid())
+ p.scale(req_size.width()/100.0, req_size.height()/50.0);
+ p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id);
+ return image;
+ }
+};
+
+
+class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri) {
+ Q_UNUSED(uri);
+
+ }
+
+ void initializeEngine(QDeclarativeEngine *engine, const char *uri) {
+ Q_UNUSED(uri);
+
+ engine->addImageProvider("colors", new ColorImageProvider);
+
+ QStringList dataList;
+ dataList.append("image://colors/red");
+ dataList.append("image://colors/green");
+ dataList.append("image://colors/blue");
+ dataList.append("image://colors/brown");
+ dataList.append("image://colors/orange");
+ dataList.append("image://colors/purple");
+ dataList.append("image://colors/yellow");
+
+ QDeclarativeContext *ctxt = engine->rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+ }
+
+};
+
+#include "imageprovider.moc"
+
+Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin);
+//![0]
+
diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro
new file mode 100644
index 0000000..86dbcca
--- /dev/null
+++ b/examples/declarative/imageprovider/imageprovider.pro
@@ -0,0 +1,21 @@
+TEMPLATE = lib
+TARGET = imageprovider
+QT += declarative
+CONFIG += qt plugin
+
+TARGET = $$qtLibraryTarget($$TARGET)
+DESTDIR = ImageProviderCore
+
+# Input
+SOURCES += imageprovider.cpp
+
+sources.files = $$SOURCES imageprovider.qml imageprovider.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider
+
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore
+
+ImageProviderCore_sources.files = \
+ ImageProviderCore/qmldir
+ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore
+
+INSTALLS = sources ImageProviderCore_sources target
diff --git a/examples/declarative/images/content/lemonade.jpg b/examples/declarative/images/content/lemonade.jpg
new file mode 100644
index 0000000..db445c9
--- /dev/null
+++ b/examples/declarative/images/content/lemonade.jpg
Binary files differ
diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml
new file mode 100644
index 0000000..35ce1ab
--- /dev/null
+++ b/examples/declarative/images/images.qml
@@ -0,0 +1,69 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: grid.width + 50
+ height: grid.height + 50
+
+ Grid {
+ x: 25; y: 25
+ id: grid
+ columns: 3
+
+ Image {
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ sourceSize.width: 50
+ sourceSize.height: 50
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ sourceSize.width: 50
+ sourceSize.height: 50
+ smooth: true
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ scale: 1/3
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ scale: 1/3
+ sourceSize.width: 50
+ sourceSize.height: 50
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ scale: 1/3
+ sourceSize.width: 50
+ sourceSize.height: 50
+ smooth: true
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ width: 50; height: 50; transform: Translate { x: 50 }
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ width: 50; height: 50; transform: Translate { x: 50 }
+ sourceSize.width: 50
+ sourceSize.height: 50
+ source: "content/lemonade.jpg"
+ }
+
+ Image {
+ width: 50; height: 50; transform: Translate { x: 50 }
+ sourceSize: "50x50" // syntactic sugar
+ smooth: true
+ source: "content/lemonade.jpg"
+ }
+ }
+}
diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml
new file mode 100644
index 0000000..7cbf68a
--- /dev/null
+++ b/examples/declarative/layouts/Button.qml
@@ -0,0 +1,22 @@
+import Qt 4.6
+
+Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.width + textelement.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: textelement; text: page.text; color: "white"; x:pix.width+pix.x+3; anchors.verticalCenter: pix.verticalCenter;}
+ MouseArea{ id:mr; anchors.fill: parent; onClicked: {parent.focus = true; page.clicked()}}
+
+ states:
+ State{ name:"pressed"; when:mr.pressed
+ PropertyChanges {target:textelement; x: 5}
+ PropertyChanges {target:pix; x:textelement.x+textelement.width + 3}
+ }
+
+ transitions:
+ Transition{
+ NumberAnimation { properties:"x,left"; easing.type:"InOutQuad"; 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..4b2a3f8
--- /dev/null
+++ b/examples/declarative/layouts/layouts.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+import Qt.widgets 4.6
+Item {
+ id: resizable
+ width:400
+ height:400
+
+ GraphicsObjectContainer {
+ anchors.fill:parent
+
+ QGraphicsWidget {
+ size.width:parent.width
+ size.height:parent.height
+
+ 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..bce53bd
--- /dev/null
+++ b/examples/declarative/layouts/positioners.qml
@@ -0,0 +1,163 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: 420
+ height: 420
+ color: "white"
+
+ Column {
+ id: layout1
+ y: 0
+ move: Transition {
+ NumberAnimation {
+ properties: "y"; easing.type: "OutBounce"
+ }
+ }
+ add: Transition {
+ NumberAnimation {
+ properties: "y"; easing.type: "OutQuad"
+ }
+ }
+ 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
+ Behavior on opacity {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
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Row {
+ id: layout2
+ y: 300
+ move: Transition {
+ NumberAnimation {
+ properties: "x"; easing.type: "OutBounce"
+ }
+ }
+ add: Transition {
+ NumberAnimation {
+ properties: "x"; easing.type: "OutQuad"
+ }
+ }
+ 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
+ Behavior on opacity {NumberAnimation{}}
+ }
+ 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
+ Behavior on opacity {NumberAnimation{}}
+ }
+ 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
+ blueF1.opacity = 0
+ blueF2.opacity = 0
+ blueF3.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
+ blueF1.opacity = 1
+ blueF2.opacity = 1
+ blueF3.opacity = 1
+ }
+ }
+
+ Grid {
+ x: 260
+ y: 0
+ columns: 3
+
+ move: Transition {
+ NumberAnimation {
+ properties: "x,y"; easing.type: "OutBounce"
+ }
+ }
+
+ add: Transition {
+ NumberAnimation {
+ properties: "x,y"; easing.type: "OutBounce"
+ }
+ }
+
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG1; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG2; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueG3; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ }
+
+ Flow {
+ id: layout4
+ x: 260
+ y: 250
+ width: 150
+
+ move: Transition {
+ NumberAnimation {
+ properties: "x,y"; easing.type: "OutBounce"
+ }
+ }
+
+ add: Transition {
+ NumberAnimation {
+ properties: "x,y"; easing.type: "OutBounce"
+ }
+ }
+ Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueF1; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueF2; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 }
+ Rectangle { id: blueF3; color: "lightsteelblue"; width: 40; height: 50; border.color: "black"; radius: 15
+ Behavior on opacity {NumberAnimation{}}
+ }
+ Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 }
+ }
+
+}
diff --git a/examples/declarative/listmodel-threaded/dataloader.js b/examples/declarative/listmodel-threaded/dataloader.js
new file mode 100644
index 0000000..eac7478
--- /dev/null
+++ b/examples/declarative/listmodel-threaded/dataloader.js
@@ -0,0 +1,14 @@
+// ![0]
+WorkerScript.onMessage = function(msg) {
+ console.log("Worker told to", msg.action);
+
+ if (msg.action == 'appendCurrentTime') {
+ var data = {'time': new Date().toTimeString()};
+ msg.model.append(data);
+ msg.model.sync(); // updates the changes to the list
+
+ var msgToSend = {'msg': 'Model updated!'};
+ WorkerScript.sendMessage(msgToSend);
+ }
+}
+// ![0]
diff --git a/examples/declarative/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml
new file mode 100644
index 0000000..e8d8fe2
--- /dev/null
+++ b/examples/declarative/listmodel-threaded/timedisplay.qml
@@ -0,0 +1,33 @@
+// ![0]
+import Qt 4.6
+
+ListView {
+ width: 200
+ height: 300
+
+ model: listModel
+ delegate: Component {
+ Text { text: time }
+ }
+
+ ListModel { id: listModel }
+
+ WorkerScript {
+ id: worker
+ source: "dataloader.js"
+ onMessage: {
+ console.log("Worker said", messageObject.msg);
+ }
+ }
+
+ Timer {
+ id: timer
+ interval: 2000; repeat: true; running: true; triggeredOnStart: true
+
+ onTriggered: {
+ var msg = {'action': 'appendCurrentTime', 'model': listModel};
+ worker.sendMessage(msg);
+ }
+ }
+}
+// ![0]
diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml
new file mode 100644
index 0000000..cbf1f3b
--- /dev/null
+++ b/examples/declarative/listview/content/ClickAutoRepeating.qml
@@ -0,0 +1,31 @@
+import Qt 4.6
+
+Item {
+ id: page
+ property int repeatdelay: 300
+ property int repeatperiod: 75
+ property bool isPressed: false
+
+ signal pressed
+ signal released
+ signal clicked
+
+ SequentialAnimation on isPressed {
+ running: false
+ id: autoRepeat
+ PropertyAction { target: page; property: "isPressed"; value: true }
+ ScriptAction { script: page.pressed() }
+ ScriptAction { script: page.clicked() }
+ PauseAnimation { duration: repeatdelay }
+ SequentialAnimation {
+ loops: Animation.Infinite
+ ScriptAction { script: page.clicked() }
+ PauseAnimation { duration: repeatperiod }
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onPressed: autoRepeat.start()
+ onReleased: { autoRepeat.stop(); parent.isPressed = false; page.released() }
+ }
+}
diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml
new file mode 100644
index 0000000..e9065c1
--- /dev/null
+++ b/examples/declarative/listview/content/MediaButton.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Item {
+ property var text
+ signal clicked
+
+ id: container
+ Image {
+ id: normal
+ source: "pics/button.png"
+ }
+ Image {
+ id: pressed
+ source: "pics/button-pressed.png"
+ opacity: 0
+ }
+ MouseArea {
+ id: clickRegion
+ anchors.fill: normal
+ onClicked: { container.clicked(); }
+ }
+ Text {
+ font.bold: true
+ color: "white"
+ anchors.centerIn: normal
+ text: container.text
+ }
+ width: normal.width
+
+ states: State {
+ name: "Pressed"
+ when: clickRegion.pressed == true
+ PropertyChanges { target: pressed; opacity: 1 }
+ }
+}
diff --git a/examples/declarative/listview/content/pics/add.png b/examples/declarative/listview/content/pics/add.png
new file mode 100644
index 0000000..f29d84b
--- /dev/null
+++ b/examples/declarative/listview/content/pics/add.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/archive-insert.png b/examples/declarative/listview/content/pics/archive-insert.png
new file mode 100644
index 0000000..b706248
--- /dev/null
+++ b/examples/declarative/listview/content/pics/archive-insert.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/archive-remove.png b/examples/declarative/listview/content/pics/archive-remove.png
new file mode 100644
index 0000000..9640f6b
--- /dev/null
+++ b/examples/declarative/listview/content/pics/archive-remove.png
Binary files differ
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/del.png b/examples/declarative/listview/content/pics/del.png
new file mode 100644
index 0000000..1d753a3
--- /dev/null
+++ b/examples/declarative/listview/content/pics/del.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/go-down.png b/examples/declarative/listview/content/pics/go-down.png
new file mode 100644
index 0000000..63331a5
--- /dev/null
+++ b/examples/declarative/listview/content/pics/go-down.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/go-up.png b/examples/declarative/listview/content/pics/go-up.png
new file mode 100644
index 0000000..4459024
--- /dev/null
+++ b/examples/declarative/listview/content/pics/go-up.png
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/list-add.png b/examples/declarative/listview/content/pics/list-add.png
new file mode 100644
index 0000000..e029787
--- /dev/null
+++ b/examples/declarative/listview/content/pics/list-add.png
Binary files differ
diff --git a/examples/declarative/listview/content/pics/list-remove.png b/examples/declarative/listview/content/pics/list-remove.png
new file mode 100644
index 0000000..2bb1a59
--- /dev/null
+++ b/examples/declarative/listview/content/pics/list-remove.png
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/trash.png b/examples/declarative/listview/content/pics/trash.png
new file mode 100644
index 0000000..2042595
--- /dev/null
+++ b/examples/declarative/listview/content/pics/trash.png
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..1ac37bb
--- /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.
+
+ListModel {
+ id: petsModel
+ ListElement {
+ name: "Polly"
+ type: "Parrot"
+ age: 12
+ size: "Small"
+ }
+ ListElement {
+ name: "Penny"
+ type: "Turtle"
+ age: 4
+ size: "Small"
+ }
+ ListElement {
+ name: "Warren"
+ type: "Rabbit"
+ age: 2
+ size: "Small"
+ }
+ ListElement {
+ name: "Spot"
+ type: "Dog"
+ age: 9
+ size: "Medium"
+ }
+ ListElement {
+ name: "Schrödinger"
+ type: "Cat"
+ age: 2
+ size: "Medium"
+ }
+ ListElement {
+ name: "Joey"
+ type: "Kangaroo"
+ age: 1
+ size: "Medium"
+ }
+ ListElement {
+ name: "Kimba"
+ type: "Bunny"
+ age: 65
+ size: "Large"
+ }
+ ListElement {
+ name: "Rover"
+ type: "Dog"
+ age: 5
+ size: "Large"
+ }
+ ListElement {
+ name: "Tiny"
+ type: "Elephant"
+ age: 15
+ size: "Large"
+ }
+}
diff --git a/examples/declarative/listview/dummydata/Recipes.qml b/examples/declarative/listview/dummydata/Recipes.qml
new file mode 100644
index 0000000..68e94ac
--- /dev/null
+++ b/examples/declarative/listview/dummydata/Recipes.qml
@@ -0,0 +1,90 @@
+import Qt 4.6
+
+ListModel {
+ id: recipesModel
+ 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/dynamic.qml b/examples/declarative/listview/dynamic.qml
new file mode 100644
index 0000000..81550d7
--- /dev/null
+++ b/examples/declarative/listview/dynamic.qml
@@ -0,0 +1,159 @@
+import Qt 4.6
+import "content"
+import "../scrollbar"
+
+Rectangle {
+ width: 640; height: 480
+ color: "#343434"
+
+ ListModel {
+ id: fruitModel
+ ListElement {
+ name: "Apple"; cost: 2.45
+ attributes: [
+ ListElement { description: "Core" },
+ ListElement { description: "Deciduous" }
+ ]
+ }
+ ListElement {
+ name: "Banana"; cost: 1.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Seedless" }
+ ]
+ }
+ ListElement {
+ name: "Cumquat"; cost: 3.25
+ attributes: [
+ ListElement { description: "Citrus" }
+ ]
+ }
+ ListElement {
+ name: "Durian"; cost: 9.95
+ attributes: [
+ ListElement { description: "Tropical" },
+ ListElement { description: "Smelly" }
+ ]
+ }
+ ListElement {
+ name: "Elderberry"; cost: 0.05
+ attributes: [
+ ListElement { description: "Berry" }
+ ]
+ }
+ ListElement {
+ name: "Fig"; cost: 0.25
+ attributes: [
+ ListElement { description: "Flower" }
+ ]
+ }
+ }
+
+ Component {
+ id: fruitDelegate
+ Item {
+ width: parent.width; height: 55
+
+ Column {
+ id: moveButtons; x: 5; width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter
+ Image { source: "content/pics/go-up.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index-1,1) }
+ }
+ Image { source: "content/pics/go-down.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index,index+1,1) }
+ }
+ }
+
+ Column {
+ anchors { right: itemButtons.left; verticalCenter: parent.verticalCenter; left: moveButtons.right; leftMargin: 10 }
+ Text {
+ id: label; font.bold: true; text: name; elide: Text.ElideRight; font.pixelSize: 15
+ width: parent.width; color: "White"
+ }
+ Row {
+ spacing: 5
+ Repeater { model: attributes; Component { Text { text: description; color: "White" } } }
+ }
+ }
+
+ Row {
+ id: itemButtons
+ anchors.right: removeButton.left; anchors.rightMargin: 35; spacing: 10
+ width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter
+ Image { source: "content/pics/list-add.png"
+ ClickAutoRepeating { id: clickUp; anchors.fill: parent; onClicked: fruitModel.setProperty(index,"cost",cost+0.25) }
+ scale: clickUp.isPressed ? 0.9 : 1; transformOrigin: Item.Center
+ }
+ Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; }
+ Image { source: "content/pics/list-remove.png"
+ ClickAutoRepeating { id: clickDown; anchors.fill: parent; onClicked: fruitModel.setProperty(index,"cost",Math.max(0,cost-0.25)) }
+ scale: clickDown.isPressed ? 0.9 : 1; transformOrigin: Item.Center
+ }
+ }
+ Image {
+ id: removeButton; source: "content/pics/archive-remove.png"
+ anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 }
+ MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) }
+ }
+ }
+ }
+
+ ListView {
+ id: view
+ model: fruitModel; delegate: fruitDelegate
+ anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top }
+ }
+
+ // Attach scrollbar to the right edge of the view.
+ ScrollBar {
+ id: verticalScrollBar
+ opacity: 0
+ orientation: "Vertical"
+ position: view.visibleArea.yPosition
+ pageSize: view.visibleArea.heightRatio
+ width: 8
+ height: view.height
+ anchors.right: view.right
+ // Only show the scrollbar when the view is moving.
+ states: [
+ State {
+ name: "ShowBars"; when: view.moving
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ }
+ ]
+ transitions: [ Transition { NumberAnimation { properties: "opacity"; duration: 400 } } ]
+ }
+
+ Row {
+ x: 8; width: childrenRect.width
+ height: childrenRect.height
+ anchors { bottom: parent.bottom; bottomMargin: 8 }
+ spacing: 8
+ id: buttons
+ Image { source: "content/pics/archive-insert.png"
+ MouseArea { anchors.fill: parent;
+ onClicked: {
+ fruitModel.append({
+ "name":"Pizza Margarita",
+ "cost":5.95,
+ "attributes":[{"description": "Cheese"},{"description": "Tomato"}]
+ })
+ }
+ }
+ }
+ Image { source: "content/pics/archive-insert.png"
+ MouseArea { anchors.fill: parent;
+ onClicked: {
+ fruitModel.insert(0,{
+ "name":"Pizza Supreme",
+ "cost":9.95,
+ "attributes":[{"description": "Cheese"},{"description": "Tomato"},{"description": "The Works"}]
+ })
+ }
+ }
+ }
+ Image { source: "content/pics/archive-remove.png"
+ MouseArea { anchors.fill: parent; onClicked: fruitModel.clear() }
+ }
+ }
+}
diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
new file mode 100644
index 0000000..5e4911d
--- /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 highlightFollowsCurrentItem
+ // 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"
+ SpringFollow on y { source: list1.currentItem.y; spring: 3; damping: 0.1 }
+ }
+ }
+ ListView {
+ id: list1
+ width: 200; height: parent.height
+ model: MyPetsModel; delegate: petDelegate
+ highlight: petHighlight; highlightFollowsCurrentItem: false
+ focus: true
+ }
+}
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
new file mode 100644
index 0000000..41aa860
--- /dev/null
+++ b/examples/declarative/listview/itemlist.qml
@@ -0,0 +1,58 @@
+// 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
+ preferredHighlightBegin: 0; preferredHighlightEnd: 0
+ highlightRangeMode: "StrictlyEnforceRange"
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem; flickDeceleration: 2000
+ }
+
+ 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
+ MouseArea { width: 20; height: 20; anchors.centerIn: parent; onClicked: view.currentIndex = index }
+ color: view.currentIndex == index ? "blue" : "white"
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/listview/listview-example.qml b/examples/declarative/listview/listview-example.qml
new file mode 100644
index 0000000..92acce1
--- /dev/null
+++ b/examples/declarative/listview/listview-example.qml
@@ -0,0 +1,77 @@
+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 {
+ 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 highlight ranges.
+ // preferredHighlightBegin and preferredHighlightEnd set the
+ // range in which to attempt to maintain the highlight.
+ // 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 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.
+ // The second list sets a highlight range which attempts to keep the
+ // current item within the the bounds of the range, however
+ // items will not scroll beyond the beginning or end of the view,
+ // forcing the highlight to move outside the range at the ends.
+ // The third list sets the highlightRangeMode to StrictlyEnforceRange
+ // and sets a range smaller than the height of an item. This
+ // forces the current item to change when the view is flicked,
+ // since the highlight is unable to move.
+ // 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
+ preferredHighlightBegin: 80
+ preferredHighlightEnd: 220
+ highlightRangeMode: "ApplyRange"
+ currentIndex: list1.currentIndex
+ }
+ ListView {
+ id: list3
+ x: 400; width: 200; height: parent.height
+ model: MyPetsModel; delegate: petDelegate; highlight: petHighlight
+ currentIndex: list1.currentIndex
+ preferredHighlightBegin: 125
+ preferredHighlightEnd: 125
+ highlightRangeMode: "StrictlyEnforceRange"
+ flickDeceleration: 1000
+ }
+}
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
new file mode 100644
index 0000000..b76a9ab
--- /dev/null
+++ b/examples/declarative/listview/recipes.qml
@@ -0,0 +1,140 @@
+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"
+
+ // 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.
+ MouseArea {
+ 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; contentHeight: 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; contentY: wrapper.y }
+ // Disallow flicking while we're in detailed view
+ PropertyChanges { target: wrapper.ListView.view; interactive: false }
+ }
+
+ transitions: Transition {
+ // Make the state changes smooth
+ ParallelAnimation {
+ ColorAnimation { property: "color"; duration: 500 }
+ NumberAnimation {
+ duration: 300; properties: "detailsOpacity,x,contentY,height,width"
+ }
+ }
+ }
+ }
+ }
+
+ // The actual list
+ ListView {
+ id: 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..877026b
--- /dev/null
+++ b/examples/declarative/listview/sections.qml
@@ -0,0 +1,67 @@
+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: desc.height
+ Item {
+ id: desc
+ x: 5
+ height: layout.height + 4
+ 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: myList
+ 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.
+ section.property: "size"
+ section.criteria: ViewSection.FullString
+ section.delegate: Rectangle {
+ color: "lightsteelblue"
+ width: 200
+ height: 20
+ Text {
+ text: section; font.bold: true
+ x: 2; height: parent.height; verticalAlignment: 'AlignVCenter'
+ }
+ }
+ focus: true
+ }
+}
+//! [0]
diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml
new file mode 100644
index 0000000..9191f8a
--- /dev/null
+++ b/examples/declarative/mousearea/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 }
+ MouseArea {
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
+ onReleased: { console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') }
+ onPressAndHold: { console.log('press and hold') }
+ onEntered: { console.log('entered ' + pressed) }
+ onExited: { console.log('exited ' + pressed) }
+ anchors.fill: parent
+ }
+ }
+ Rectangle {
+ y: 100; width: 50; height: 50
+ color: "blue"
+ Text { text: "Drag"; anchors.centerIn: parent }
+ MouseArea {
+ drag.target: parent
+ drag.axis: "XAxis"
+ drag.minimumX: 0
+ drag.maximumX: 150
+ onPressed: { console.log('press') }
+ onReleased: { console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { console.log('double click') }
+ onPressAndHold: { console.log('press and hold') }
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/examples/declarative/objectlistmodel/dataobject.cpp b/examples/declarative/objectlistmodel/dataobject.cpp
new file mode 100644
index 0000000..4c44ee4
--- /dev/null
+++ b/examples/declarative/objectlistmodel/dataobject.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include "dataobject.h"
+
+DataObject::DataObject(QObject *parent)
+ : QObject(parent)
+{
+}
+
+DataObject::DataObject(const QString &name, const QString &color, QObject *parent)
+ : QObject(parent), m_name(name), m_color(color)
+{
+}
+
+QString DataObject::name() const
+{
+ return m_name;
+}
+
+void DataObject::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString DataObject::color() const
+{
+ return m_color;
+}
+
+void DataObject::setColor(const QString &color)
+{
+ m_color = color;
+}
diff --git a/examples/declarative/objectlistmodel/dataobject.h b/examples/declarative/objectlistmodel/dataobject.h
new file mode 100644
index 0000000..6804474
--- /dev/null
+++ b/examples/declarative/objectlistmodel/dataobject.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DATAOBJECT_H
+#define DATAOBJECT_H
+
+#include <QObject>
+
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString color READ color WRITE setColor)
+
+public:
+ DataObject(QObject *parent=0);
+ DataObject(const QString &name, const QString &color, QObject *parent=0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString color() const;
+ void setColor(const QString &color);
+
+private:
+ QString m_name;
+ QString m_color;
+};
+
+#endif // DATAOBJECT_H
diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp
new file mode 100644
index 0000000..b210570
--- /dev/null
+++ b/examples/declarative/objectlistmodel/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeview.h>
+
+#include "dataobject.h"
+
+/*
+ This example illustrates exposing a QList<QObject*> as a
+ model in QML
+*/
+
+int main(int argc, char ** argv)
+{
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/declarative/objectlistmodel/objectlistmodel.pro b/examples/declarative/objectlistmodel/objectlistmodel.pro
new file mode 100644
index 0000000..869cde3
--- /dev/null
+++ b/examples/declarative/objectlistmodel/objectlistmodel.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = objectlistmodel
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp \
+ dataobject.cpp
+HEADERS += dataobject.h
+RESOURCES += objectlistmodel.qrc
+
+sources.files = $$SOURCES $$HEADERS $$RESOURCES objectlistmodel.pro view.qml
+sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel
+target.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel
+
+INSTALLS += sources target
+
diff --git a/examples/declarative/objectlistmodel/objectlistmodel.qrc b/examples/declarative/objectlistmodel/objectlistmodel.qrc
new file mode 100644
index 0000000..17e9301
--- /dev/null
+++ b/examples/declarative/objectlistmodel/objectlistmodel.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>view.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/objectlistmodel/view.qml b/examples/declarative/objectlistmodel/view.qml
new file mode 100644
index 0000000..5f5e415
--- /dev/null
+++ b/examples/declarative/objectlistmodel/view.qml
@@ -0,0 +1,16 @@
+import Qt 4.6
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ color: model.color
+ Text { text: name }
+ }
+ }
+}
diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml
new file mode 100644
index 0000000..f35314f
--- /dev/null
+++ b/examples/declarative/package/Delegate.qml
@@ -0,0 +1,48 @@
+import Qt 4.6
+
+//![0]
+Package {
+ Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' }
+ Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' }
+
+ Rectangle {
+ id: wrapper
+ width: 200; height: 25
+ color: 'lightsteelblue'
+
+ Text { text: display; anchors.centerIn: parent }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (wrapper.state == 'inList')
+ wrapper.state = 'inGrid';
+ else
+ wrapper.state = 'inList';
+ }
+ }
+
+ state: 'inList'
+ states: [
+ State {
+ name: 'inList'
+ ParentChange { target: wrapper; parent: listDelegate }
+ },
+ State {
+ name: 'inGrid'
+ ParentChange {
+ target: wrapper; parent: gridDelegate
+ x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParentAnimation {
+ NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml
new file mode 100644
index 0000000..07bba0c
--- /dev/null
+++ b/examples/declarative/package/view.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Item {
+ width: 400
+ height: 200
+
+ ListModel {
+ id: myModel
+ ListElement { display: "One" }
+ ListElement { display: "Two" }
+ ListElement { display: "Three" }
+ ListElement { display: "Four" }
+ ListElement { display: "Five" }
+ ListElement { display: "Six" }
+ ListElement { display: "Seven" }
+ ListElement { display: "Eight" }
+ }
+ //![0]
+ VisualDataModel {
+ id: visualModel
+ delegate: Delegate {}
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ GridView {
+ x: 200; width: 200; height:200
+ cellHeight: 50
+ model: visualModel.parts.grid
+ }
+ //![0]
+}
diff --git a/examples/declarative/parallax/parallax.qml b/examples/declarative/parallax/parallax.qml
new file mode 100644
index 0000000..6193f27
--- /dev/null
+++ b/examples/declarative/parallax/parallax.qml
@@ -0,0 +1,41 @@
+import Qt 4.6
+import "../clocks/content"
+import "qml"
+
+Rectangle {
+ id: root
+
+ width: 320; height: 480
+
+ ParallaxView {
+ id: parallax
+ anchors.fill: parent
+ background: "pics/background.jpg"
+
+ Item {
+ property url icon: "pics/yast-wol.png"
+ width: 320; height: 480
+ Clock { anchors.centerIn: parent }
+ }
+
+ Item {
+ property url icon: "pics/home-page.svg"
+ width: 320; height: 480
+ Smiley { }
+ }
+
+ Item {
+ property url icon: "pics/yast-joystick.png"
+ width: 320; height: 480
+
+ Loader {
+ anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter }
+ width: 300; height: 400
+ clip: true; resizeMode: Loader.SizeItemToLoader
+ source: "../../../demos/declarative/samegame/samegame.qml"
+ }
+ }
+
+ currentIndex: root.currentIndex
+ }
+}
diff --git a/examples/declarative/parallax/pics/background.jpg b/examples/declarative/parallax/pics/background.jpg
new file mode 100644
index 0000000..61cca2f
--- /dev/null
+++ b/examples/declarative/parallax/pics/background.jpg
Binary files differ
diff --git a/examples/declarative/parallax/pics/face-smile.png b/examples/declarative/parallax/pics/face-smile.png
new file mode 100644
index 0000000..3d66d72
--- /dev/null
+++ b/examples/declarative/parallax/pics/face-smile.png
Binary files differ
diff --git a/examples/declarative/parallax/pics/home-page.svg b/examples/declarative/parallax/pics/home-page.svg
new file mode 100644
index 0000000..4f16958
--- /dev/null
+++ b/examples/declarative/parallax/pics/home-page.svg
@@ -0,0 +1,445 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ overflow="visible"
+ enable-background="new 0 0 128 129.396"
+ xml:space="preserve"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="go-home.svg"
+ sodipodi:docbase="/home/jimmac/src/cvs/tango-icon-theme/scalable/actions"
+ version="1.0"
+ inkscape:export-filename="/home/tigert/My Downloads/go-home.png"
+ inkscape:export-xdpi="90.000000"
+ inkscape:export-ydpi="90.000000"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata367"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" /><dc:title>Go Home</dc:title><dc:creator><cc:Agent><dc:title>Jakub Steiner</dc:title></cc:Agent></dc:creator><dc:source>http://jimmac.musichall.cz</dc:source><dc:subject><rdf:Bag><rdf:li>home</rdf:li><rdf:li>return</rdf:li><rdf:li>go</rdf:li><rdf:li>default</rdf:li><rdf:li>user</rdf:li><rdf:li>directory</rdf:li></rdf:Bag></dc:subject><dc:contributor><cc:Agent><dc:title>Tuomas Kuosmanen</dc:title></cc:Agent></dc:contributor></cc:Work><cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/"><cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /></cc:License></rdf:RDF></metadata><defs
+ id="defs365"><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 24 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="48 : 24 : 1"
+ inkscape:persp3d-origin="24 : 16 : 1"
+ id="perspective92" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5060"
+ id="radialGradient5031"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
+ cx="605.71429"
+ cy="486.64789"
+ fx="605.71429"
+ fy="486.64789"
+ r="117.14286" /><linearGradient
+ inkscape:collect="always"
+ id="linearGradient5060"><stop
+ style="stop-color:black;stop-opacity:1;"
+ offset="0"
+ id="stop5062" /><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="1"
+ id="stop5064" /></linearGradient><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5060"
+ id="radialGradient5029"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
+ cx="605.71429"
+ cy="486.64789"
+ fx="605.71429"
+ fy="486.64789"
+ r="117.14286" /><linearGradient
+ id="linearGradient5048"><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="0"
+ id="stop5050" /><stop
+ id="stop5056"
+ offset="0.5"
+ style="stop-color:black;stop-opacity:1;" /><stop
+ style="stop-color:black;stop-opacity:0;"
+ offset="1"
+ id="stop5052" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient5048"
+ id="linearGradient5027"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
+ x1="302.85715"
+ y1="366.64789"
+ x2="302.85715"
+ y2="609.50507" /><linearGradient
+ id="linearGradient2406"><stop
+ style="stop-color:#7c7e79;stop-opacity:1;"
+ offset="0"
+ id="stop2408" /><stop
+ id="stop2414"
+ offset="0.1724138"
+ style="stop-color:#848681;stop-opacity:1;" /><stop
+ style="stop-color:#898c86;stop-opacity:1;"
+ offset="1"
+ id="stop2410" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2390"><stop
+ style="stop-color:#919191;stop-opacity:1;"
+ offset="0"
+ id="stop2392" /><stop
+ style="stop-color:#919191;stop-opacity:0;"
+ offset="1"
+ id="stop2394" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2378"><stop
+ style="stop-color:#575757;stop-opacity:1;"
+ offset="0"
+ id="stop2380" /><stop
+ style="stop-color:#575757;stop-opacity:0;"
+ offset="1"
+ id="stop2382" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2368"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2370" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2372" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2349"><stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2351" /><stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2353" /></linearGradient><linearGradient
+ id="linearGradient2341"><stop
+ id="stop2343"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" /><stop
+ id="stop2345"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:0;" /></linearGradient><linearGradient
+ id="linearGradient2329"><stop
+ style="stop-color:#000000;stop-opacity:0.18556701;"
+ offset="0"
+ id="stop2331" /><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="1"
+ id="stop2333" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2319"><stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop2321" /><stop
+ style="stop-color:#000000;stop-opacity:0;"
+ offset="1"
+ id="stop2323" /></linearGradient><linearGradient
+ id="linearGradient2307"><stop
+ style="stop-color:#edd400;stop-opacity:1;"
+ offset="0"
+ id="stop2309" /><stop
+ style="stop-color:#998800;stop-opacity:1;"
+ offset="1"
+ id="stop2311" /></linearGradient><linearGradient
+ inkscape:collect="always"
+ id="linearGradient2299"><stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2301" /><stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2303" /></linearGradient><linearGradient
+ id="XMLID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="80.223602"
+ y1="117.5205"
+ x2="48.046001"
+ y2="59.7995"
+ gradientTransform="matrix(0.314683,0.000000,0.000000,0.314683,4.128264,3.742874)">
+ <stop
+ offset="0"
+ style="stop-color:#CCCCCC"
+ id="stop17" />
+ <stop
+ offset="0.9831"
+ style="stop-color:#FFFFFF"
+ id="stop19" />
+ <midPointStop
+ offset="0"
+ style="stop-color:#CCCCCC"
+ id="midPointStop48" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#CCCCCC"
+ id="midPointStop50" />
+ <midPointStop
+ offset="0.9831"
+ style="stop-color:#FFFFFF"
+ id="midPointStop52" />
+ </linearGradient><linearGradient
+ inkscape:collect="always"
+ xlink:href="#XMLID_2_"
+ id="linearGradient1514"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.336922,0.000000,0.000000,0.166888,17.98288,15.46151)"
+ x1="52.006104"
+ y1="166.1331"
+ x2="14.049017"
+ y2="-42.218513" /><linearGradient
+ id="XMLID_39_"
+ gradientUnits="userSpaceOnUse"
+ x1="64.387703"
+ y1="65.124001"
+ x2="64.387703"
+ y2="35.569"
+ gradientTransform="matrix(0.354101,0.000000,0.000000,0.354101,1.638679,-8.364921e-2)">
+ <stop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="stop336" />
+ <stop
+ offset="0.8539"
+ style="stop-color:#FF6200"
+ id="stop338" />
+ <stop
+ offset="1"
+ style="stop-color:#F25D00"
+ id="stop340" />
+ <midPointStop
+ offset="0"
+ style="stop-color:#FFFFFF"
+ id="midPointStop335" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#FFFFFF"
+ id="midPointStop337" />
+ <midPointStop
+ offset="0.8539"
+ style="stop-color:#FF6200"
+ id="midPointStop339" />
+ <midPointStop
+ offset="0.5"
+ style="stop-color:#FF6200"
+ id="midPointStop341" />
+ <midPointStop
+ offset="1"
+ style="stop-color:#F25D00"
+ id="midPointStop343" />
+ </linearGradient><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2299"
+ id="radialGradient2305"
+ cx="7.5326638"
+ cy="24.202574"
+ fx="7.5326638"
+ fy="24.202574"
+ r="8.2452128"
+ gradientTransform="matrix(4.100086,-1.627292e-17,2.125447e-14,4.201322,-25.41506,-78.53967)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2307"
+ id="radialGradient2313"
+ cx="19.985598"
+ cy="36.77816"
+ fx="19.985598"
+ fy="36.77816"
+ r="1.0821035"
+ gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.565787)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2319"
+ id="radialGradient2325"
+ cx="20.443665"
+ cy="37.425829"
+ fx="20.443665"
+ fy="37.425829"
+ r="1.0821035"
+ gradientTransform="matrix(1.125263,0.000000,0.000000,0.982744,-3.428678,0.731106)"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2329"
+ id="linearGradient2335"
+ x1="17.602522"
+ y1="26.057423"
+ x2="17.682528"
+ y2="32.654099"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.898789,0,0,1.071914,0.478025,-2.080838)" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2341"
+ id="radialGradient2339"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(4.100086,1.627292e-17,2.125447e-14,-4.201322,-5.198109,105.3535)"
+ cx="11.68129"
+ cy="19.554111"
+ fx="11.68129"
+ fy="19.554111"
+ r="8.2452126" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2349"
+ id="radialGradient2355"
+ cx="24.023088"
+ cy="40.56913"
+ fx="24.023088"
+ fy="40.56913"
+ r="16.28684"
+ gradientTransform="matrix(1.000000,0.000000,0.000000,0.431250,1.157278e-15,23.07369)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2368"
+ id="radialGradient2374"
+ cx="29.913452"
+ cy="30.442923"
+ fx="29.913452"
+ fy="30.442923"
+ r="4.0018832"
+ gradientTransform="matrix(3.751495,-2.191984e-22,1.723265e-22,3.147818,-82.00907,-65.70704)"
+ gradientUnits="userSpaceOnUse" /><radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2378"
+ id="radialGradient2384"
+ cx="24.195112"
+ cy="10.577631"
+ fx="24.195112"
+ fy="10.577631"
+ r="15.242914"
+ gradientTransform="matrix(1.125263,-3.585417e-8,4.269819e-8,1.340059,-3.006704,1.355395)"
+ gradientUnits="userSpaceOnUse" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2390"
+ id="linearGradient2396"
+ x1="30.603519"
+ y1="37.337803"
+ x2="30.603519"
+ y2="36.112415"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.263867,0,0,0.859794,-6.499556,8.390924)" /><linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2406"
+ id="linearGradient2412"
+ x1="17.850183"
+ y1="28.939463"
+ x2="19.040216"
+ y2="41.03223"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.888785,0,0,1.08932,2.41099,-1.524336)" /></defs><sodipodi:namedview
+ inkscape:cy="-2.3755359"
+ inkscape:cx="25.234802"
+ inkscape:zoom="1"
+ inkscape:window-height="691"
+ inkscape:window-width="872"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="0.21568627"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:showpageshadow="false"
+ inkscape:window-x="466"
+ inkscape:window-y="157"
+ inkscape:current-layer="svg2"
+ fill="#555753"
+ showgrid="false"
+ stroke="#a40000"
+ showguides="true"
+ inkscape:guide-bbox="true" />
+ <g
+ style="display:inline"
+ id="g5022"
+ transform="matrix(2.158196e-2,0,0,1.859457e-2,43.12251,41.63767)"><rect
+ y="-150.69685"
+ x="-1559.2523"
+ height="478.35718"
+ width="1339.6335"
+ id="rect4173"
+ style="opacity:0.40206185;color:black;fill:url(#linearGradient5027);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ sodipodi:nodetypes="cccc"
+ id="path5058"
+ d="M -219.61876,-150.68038 C -219.61876,-150.68038 -219.61876,327.65041 -219.61876,327.65041 C -76.744594,328.55086 125.78146,220.48075 125.78138,88.454235 C 125.78138,-43.572302 -33.655436,-150.68036 -219.61876,-150.68038 z "
+ style="opacity:0.40206185;color:black;fill:url(#radialGradient5029);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:0.40206185;color:black;fill:url(#radialGradient5031);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M -1559.2523,-150.68038 C -1559.2523,-150.68038 -1559.2523,327.65041 -1559.2523,327.65041 C -1702.1265,328.55086 -1904.6525,220.48075 -1904.6525,88.454235 C -1904.6525,-43.572302 -1745.2157,-150.68036 -1559.2523,-150.68038 z "
+ id="path5018"
+ sodipodi:nodetypes="cccc" /></g><path
+ style="color:#000000;fill:url(#linearGradient1514);fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:1.0000006;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 21.619576,8.1833733 L 27.577035,8.1833733 C 28.416767,8.1833733 41.46351,23.618701 41.46351,24.524032 L 41.019989,43.020777 C 41.019989,43.92611 40.343959,44.654954 39.504227,44.654954 L 8.0469496,44.654954 C 7.2072167,44.654954 6.5311871,43.92611 6.5311871,43.020777 L 6.5876651,24.524032 C 6.5876651,23.618701 20.779844,8.1833733 21.619576,8.1833733 z "
+ id="rect1512"
+ sodipodi:nodetypes="ccccccccc" /><path
+ style="fill:none"
+ id="path5"
+ d="M 46.963575,45.735573 L 1.6386762,45.735573 L 1.6386762,0.41067554 L 46.963575,0.41067554 L 46.963575,45.735573 z " /><path
+ style="fill:url(#linearGradient2335);fill-opacity:1;fill-rule:evenodd"
+ id="path2327"
+ d="M 23,29 L 22.954256,44.090942 L 11.111465,44.090942 L 11,29 L 23,29 z "
+ clip-rule="evenodd"
+ sodipodi:nodetypes="ccccc" /><path
+ sodipodi:nodetypes="ccccccccc"
+ id="path2357"
+ d="M 21.780459,9.405584 L 27.339556,9.405584 C 28.123138,9.405584 40.340425,23.805172 40.340425,24.649756 L 39.993267,42.862067 C 39.993267,43.321326 39.84953,43.515532 39.480892,43.515532 L 8.0936894,43.529812 C 7.7250517,43.529812 7.5097258,43.449894 7.5097258,43.076262 L 7.7250676,24.649756 C 7.7250676,23.805172 20.99688,9.405584 21.780459,9.405584 z "
+ style="opacity:0.3125;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.00000012;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ clip-rule="evenodd"
+ d="M 7.2075295,27.943053 L 7.1532728,30.538247 L 25.521437,17.358993 L 40.807832,28.513421 L 40.879142,28.201707 L 24.508686,12.297576 L 7.2075295,27.943053 z "
+ id="path23"
+ style="opacity:0.2;fill:url(#radialGradient2384);fill-opacity:1;fill-rule:evenodd"
+ sodipodi:nodetypes="ccccccc" /><path
+ clip-rule="evenodd"
+ d="M 22,30 L 22,44.090942 L 12.188971,44.090942 L 12,30 L 22,30 z "
+ id="path188"
+ style="fill:url(#linearGradient2412);fill-opacity:1;fill-rule:evenodd"
+ sodipodi:nodetypes="ccccc" /><path
+ style="opacity:0.40909089;fill:url(#radialGradient2325);fill-opacity:1;fill-rule:evenodd"
+ id="path2315"
+ d="M 19.576856,36.44767 C 20.249646,36.44767 20.793472,36.922275 20.793472,37.506177 C 20.793472,38.095988 20.249646,38.574532 19.576856,38.574532 C 18.904584,38.574532 18.35817,38.095988 18.35817,37.506177 C 18.358685,36.922275 18.904584,36.44767 19.576856,36.44767 z "
+ clip-rule="evenodd" /><path
+ clip-rule="evenodd"
+ d="M 19.462314,35.932229 C 20.135103,35.932229 20.678929,36.406834 20.678929,36.990736 C 20.678929,37.580545 20.135103,38.059089 19.462314,38.059089 C 18.790041,38.059089 18.243627,37.580545 18.243627,36.990736 C 18.244142,36.406834 18.790041,35.932229 19.462314,35.932229 z "
+ id="path217"
+ style="fill:url(#radialGradient2313);fill-opacity:1;fill-rule:evenodd" /><path
+ d="M 24.447748,11.559337 L 43.374808,28.729205 L 43.869487,29.121196 L 44.273163,28.949811 L 43.900293,28.188138 L 43.622679,27.964702 L 24.447748,12.392396 L 5.0582327,28.135731 L 4.8206309,28.279851 L 4.603921,28.986637 L 5.0373408,29.115885 L 5.4218948,28.807462 L 24.447748,11.559337 z "
+ id="path342"
+ style="fill:url(#XMLID_39_)"
+ sodipodi:nodetypes="ccccccccccccc" /><path
+ style="fill:#ef2929;stroke:#a40000"
+ id="path362"
+ d="M 24.330168,2.2713382 L 2.4484294,20.372675 L 1.8237005,27.538603 L 3.8236367,29.602926 C 3.8236367,29.602926 24.231018,12.445641 24.44773,12.274963 L 44.08027,29.818223 L 45.978694,27.494226 L 44.362903,20.382852 L 24.44773,2.1668788 L 24.330168,2.2713382 z "
+ sodipodi:nodetypes="cccccccccc" />
+<path
+ style="opacity:0.40909089;color:#000000;fill:url(#radialGradient2305);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 2.8413446,20.613129 L 2.5497894,27.236494 L 24.369219,8.980075 L 24.298891,3.0867443 L 2.8413446,20.613129 z "
+ id="path1536"
+ sodipodi:nodetypes="ccccc" /><path
+ sodipodi:nodetypes="ccccc"
+ id="path2337"
+ d="M 24.483763,8.7509884 L 24.583223,2.9098867 L 43.912186,20.56184 L 45.403998,27.062652 L 24.483763,8.7509884 z "
+ style="opacity:0.13636367;color:#000000;fill:url(#radialGradient2339);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /><path
+ style="opacity:0.31818183;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.99999934;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 27.102228,27.719824 L 36.142223,27.719824 C 36.912818,27.719824 37.53319,28.340194 37.53319,29.110791 L 37.525229,38.190012 C 37.525229,38.960608 36.928907,39.455981 36.158311,39.455981 L 27.102228,39.455981 C 26.331631,39.455981 25.711261,38.835608 25.711261,38.065012 L 25.711261,29.110791 C 25.711261,28.340194 26.331631,27.719824 27.102228,27.719824 z "
+ id="rect2361"
+ sodipodi:nodetypes="ccccccccc" /><rect
+ style="opacity:1;color:#000000;fill:#3465a4;fill-opacity:1;fill-rule:nonzero;stroke:#757575;stroke-width:0.9999994;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ id="rect3263"
+ width="10.001333"
+ height="9.9624557"
+ x="26.507767"
+ y="28.514256"
+ rx="0.38128215"
+ ry="0.38128215" /><path
+ style="opacity:0.39772728;color:#000000;fill:url(#radialGradient2374);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999958;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
+ d="M 27.107118,34.408261 C 30.725101,34.739438 32.634842,32.962557 35.97527,32.855521 L 36,29.00603 L 27.088388,29 L 27.107118,34.408261 z "
+ id="rect2363"
+ sodipodi:nodetypes="ccccc" /></svg> \ No newline at end of file
diff --git a/examples/declarative/parallax/pics/shadow.png b/examples/declarative/parallax/pics/shadow.png
new file mode 100644
index 0000000..8270565
--- /dev/null
+++ b/examples/declarative/parallax/pics/shadow.png
Binary files differ
diff --git a/examples/declarative/parallax/pics/yast-joystick.png b/examples/declarative/parallax/pics/yast-joystick.png
new file mode 100644
index 0000000..858cea0
--- /dev/null
+++ b/examples/declarative/parallax/pics/yast-joystick.png
Binary files differ
diff --git a/examples/declarative/parallax/pics/yast-wol.png b/examples/declarative/parallax/pics/yast-wol.png
new file mode 100644
index 0000000..7712180
--- /dev/null
+++ b/examples/declarative/parallax/pics/yast-wol.png
Binary files differ
diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml
new file mode 100644
index 0000000..08193ae
--- /dev/null
+++ b/examples/declarative/parallax/qml/ParallaxView.qml
@@ -0,0 +1,84 @@
+import Qt 4.6
+
+Item {
+ id: root
+
+ property alias background: background.source
+ default property alias content: visualModel.children
+ property int currentIndex: 0
+
+ Image {
+ id: background
+ fillMode: Image.TileHorizontally
+ x: -list.contentX / 2
+ width: Math.max(list.contentWidth, parent.width)
+ }
+
+ ListView {
+ id: list
+
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ orientation: "Horizontal"
+ overShoot: false
+ anchors.fill: parent
+ model: VisualItemModel { id: visualModel }
+
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ snapMode: ListView.SnapOneItem
+ }
+
+ ListView {
+ id: selector
+
+ Rectangle {
+ color: "#60FFFFFF"
+ x: -10; y: -10; radius: 10; z: -1
+ width: parent.width + 20; height: parent.height + 20
+ }
+ currentIndex: root.currentIndex
+ onCurrentIndexChanged: root.currentIndex = currentIndex
+
+ height: 50
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: Math.min(count * 50, parent.width - 20)
+ interactive: width == parent.width - 20
+ orientation: "Horizontal"
+
+ delegate: Item {
+ width: 50; height: 50
+ id: delegateRoot
+
+ Image {
+ id: image
+ source: modelData.icon
+ smooth: true
+ scale: 0.8
+ transformOrigin: "Center"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { root.currentIndex = index }
+ }
+
+ states: State {
+ name: "Selected"
+ when: delegateRoot.ListView.isCurrentItem == true
+ PropertyChanges {
+ target: image
+ scale: 1
+ y: -5
+ }
+ }
+ transitions: Transition {
+ NumberAnimation {
+ properties: "scale,y"
+ }
+ }
+ }
+ model: visualModel.children
+ }
+}
diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml
new file mode 100644
index 0000000..c13b879
--- /dev/null
+++ b/examples/declarative/parallax/qml/Smiley.qml
@@ -0,0 +1,47 @@
+import Qt 4.6
+
+Item {
+ id: window
+ width: 320; height: 480
+
+ // The shadow for the smiley face
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "../pics/shadow.png"; y: smiley.minHeight + 58
+ transformOrigin: Item.Center
+
+ // The scale property depends on the y position of the smiley face.
+ scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight)
+ }
+
+ Image {
+ id: smiley
+ property int maxHeight: window.height / 3
+ property int minHeight: 2 * window.height / 3
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "../pics/face-smile.png"; y: minHeight
+
+ // Animate the y property. Setting repeat to true makes the
+ // animation repeat indefinitely, otherwise it would only run once.
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
+ NumberAnimation {
+ from: smiley.minHeight; to: smiley.maxHeight
+ easing.type: "OutExpo"; duration: 300
+ }
+
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
+ NumberAnimation {
+ from: smiley.maxHeight; to: smiley.minHeight
+ easing.type: "OutBounce"; duration: 1000
+ }
+
+ // Then pause for 500ms
+ PauseAnimation { duration: 500 }
+ }
+ }
+}
+
diff --git a/examples/declarative/plugins/README b/examples/declarative/plugins/README
new file mode 100644
index 0000000..3ae256d
--- /dev/null
+++ b/examples/declarative/plugins/README
@@ -0,0 +1,9 @@
+This example shows a module "com.nokia.TimeExample" that is implemented
+by a C++ plugin (providing the "Time" type), and by QML files (providing the
+"Clock" type).
+
+To run:
+
+ make install
+ qml plugins.qml
+
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
new file mode 100644
index 0000000..622fcf9
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
@@ -0,0 +1,50 @@
+import Qt 4.6
+
+Rectangle {
+ id: clock
+ width: 200; height: 200; color: "gray"
+
+ property alias city: cityLabel.text
+ property var hours
+ property var minutes
+ property var shift : 0
+
+ Image { id: background; source: "clock.png" }
+
+ Image {
+ x: 92.5; y: 27
+ source: "hour.png"
+ smooth: true
+ transform: Rotation {
+ id: hourRotation
+ origin.x: 7.5; origin.y: 73; angle: 0
+ SpringFollow on angle {
+ spring: 2; damping: 0.2; modulus: 360
+ source: (clock.hours * 30) + (clock.minutes * 0.5)
+ }
+ }
+ }
+
+ Image {
+ x: 93.5; y: 17
+ source: "minute.png"
+ smooth: true
+ transform: Rotation {
+ id: minuteRotation
+ origin.x: 6.5; origin.y: 83; angle: 0
+ SpringFollow on angle {
+ spring: 2; damping: 0.2; modulus: 360
+ source: clock.minutes * 6
+ }
+ }
+ }
+
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/center.png b/examples/declarative/plugins/com/nokia/TimeExample/center.png
new file mode 100644
index 0000000..7fbd802
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/center.png
Binary files differ
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/plugins/com/nokia/TimeExample/clock.png
new file mode 100644
index 0000000..462edac
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/clock.png
Binary files differ
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/plugins/com/nokia/TimeExample/hour.png
new file mode 100644
index 0000000..f8061a1
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/hour.png
Binary files differ
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/plugins/com/nokia/TimeExample/minute.png
new file mode 100644
index 0000000..1297ec7
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/minute.png
Binary files differ
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/plugins/com/nokia/TimeExample/qmldir
new file mode 100644
index 0000000..e9ef115
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/qmldir
@@ -0,0 +1,2 @@
+Clock 1.0 Clock.qml
+plugin qtimeexampleqmlplugin
diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp
new file mode 100644
index 0000000..741f68a
--- /dev/null
+++ b/examples/declarative/plugins/plugin.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
+#include <qdebug.h>
+#include <qdatetime.h>
+#include <qbasictimer.h>
+#include <qapplication.h>
+
+// Implements a "Time" class with hour and minute properties
+// that change on-the-minute yet efficiently sleep the rest
+// of the time.
+
+class MinuteTimer : public QObject
+{
+ Q_OBJECT
+public:
+ MinuteTimer(QObject *parent) : QObject(parent)
+ {
+ }
+
+ void start()
+ {
+ if (!timer.isActive()) {
+ time = QTime::currentTime();
+ timer.start(60000-time.second()*1000, this);
+ }
+ }
+
+ void stop()
+ {
+ timer.stop();
+ }
+
+ int hour() const { return time.hour(); }
+ int minute() const { return time.minute(); }
+
+signals:
+ void timeChanged();
+
+protected:
+ void timerEvent(QTimerEvent *)
+ {
+ QTime now = QTime::currentTime();
+ if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) {
+ // just missed time tick over, force it, wait extra 0.5 seconds
+ time.addSecs(60);
+ timer.start(60500, this);
+ } else {
+ time = now;
+ timer.start(60000-time.second()*1000, this);
+ }
+ emit timeChanged();
+ }
+
+private:
+ QTime time;
+ QBasicTimer timer;
+};
+
+class Time : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int hour READ hour NOTIFY timeChanged)
+ Q_PROPERTY(int minute READ minute NOTIFY timeChanged)
+
+public:
+ Time(QObject *parent=0) : QObject(parent)
+ {
+ if (++instances == 1) {
+ if (!timer)
+ timer = new MinuteTimer(qApp);
+ connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged()));
+ timer->start();
+ }
+ }
+
+ ~Time()
+ {
+ if (--instances == 0) {
+ timer->stop();
+ }
+ }
+
+ int minute() const { return timer->minute(); }
+ int hour() const { return timer->hour(); }
+
+signals:
+ void timeChanged();
+
+private:
+ QTime t;
+ static MinuteTimer *timer;
+ static int instances;
+};
+
+int Time::instances=0;
+MinuteTimer *Time::timer=0;
+
+
+QML_DECLARE_TYPE(Time);
+
+
+class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample"));
+ qmlRegisterType<Time>(uri, 1, 0, "Time");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin);
diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro
new file mode 100644
index 0000000..877a5ce
--- /dev/null
+++ b/examples/declarative/plugins/plugins.pro
@@ -0,0 +1,27 @@
+TEMPLATE = lib
+DESTDIR = com/nokia/TimeExample
+TARGET = qtimeexampleqmlplugin
+CONFIG += qt plugin
+QT += declarative
+VERSION = 1.0.0
+
+SOURCES += plugin.cpp
+
+qdeclarativesources.files += \
+ com/nokia/TimeExample/qdeclarativedir \
+ com/nokia/TimeExample/center.png \
+ com/nokia/TimeExample/clock.png \
+ com/nokia/TimeExample/Clock.qml \
+ com/nokia/TimeExample/hour.png \
+ com/nokia/TimeExample/minute.png
+
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
+
+sources.files += plugins.pro plugin.cpp plugins.qml README
+sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
+
+target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
+
+INSTALLS += qdeclarativesources sources target
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml
new file mode 100644
index 0000000..449cd9a
--- /dev/null
+++ b/examples/declarative/plugins/plugins.qml
@@ -0,0 +1,11 @@
+import com.nokia.TimeExample 1.0 // import types from the plugin
+
+Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml)
+
+ Time { // this class is defined in C++ (plugin.cpp)
+ id: time
+ }
+
+ hours: time.hour
+ minutes: time.minute
+}
diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml
new file mode 100644
index 0000000..aafb12e
--- /dev/null
+++ b/examples/declarative/progressbar/content/ProgressBar.qml
@@ -0,0 +1,37 @@
+import Qt 4.6
+
+Item {
+ id: progressbar
+ width: 250; height: 23; clip: true
+
+ property int minimum: 0
+ property int maximum: 100
+ property int value: 0
+ property alias color: g1.color
+ property alias secondColor: g2.color
+
+ BorderImage {
+ source: "background.png"
+ width: parent.width; height: parent.height
+ border.left: 4; border.top: 4; border.right: 4; border.bottom: 4
+ }
+
+ Rectangle {
+ property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
+ id: highlight; radius: 1
+ anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom
+ anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3
+ width: highlight.widthDest
+ Behavior on width { SmoothedAnimation { velocity: 1200 } }
+ gradient: Gradient {
+ GradientStop { id: g1; position: 0.0 }
+ GradientStop { id: g2; position: 1.0 }
+ }
+ }
+ Text {
+ anchors.right: highlight.right; anchors.rightMargin: 6
+ color: "white"; font.bold: true
+ anchors.verticalCenter: parent.verticalCenter
+ text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
+ }
+}
diff --git a/examples/declarative/progressbar/content/background.png b/examples/declarative/progressbar/content/background.png
new file mode 100644
index 0000000..9044226
--- /dev/null
+++ b/examples/declarative/progressbar/content/background.png
Binary files differ
diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml
new file mode 100644
index 0000000..c8022b0
--- /dev/null
+++ b/examples/declarative/progressbar/progressbars.qml
@@ -0,0 +1,24 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ id: main
+ width: 600; height: 405; color: "#edecec"
+
+ Flickable {
+ anchors.fill: parent; contentHeight: column.height + 20
+ Column {
+ id: column; x: 10; y: 10; spacing: 10
+ Repeater {
+ model: 25
+ ProgressBar {
+ property int r: Math.floor(Math.random() * 5000 + 1000)
+ width: main.width - 20
+ NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite }
+ ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite }
+ ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml
new file mode 100644
index 0000000..802b537
--- /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 real position
+ property real 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..84763d2
--- /dev/null
+++ b/examples/declarative/scrollbar/display.qml
@@ -0,0 +1,58 @@
+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"
+ asynchronous: true
+ }
+ contentWidth: picture.width
+ contentHeight: picture.height
+ // Only show the scrollbars when the view is moving.
+ states: [
+ State {
+ name: "ShowBars"
+ when: view.moving
+ PropertyChanges { target: verticalScrollBar; opacity: 1 }
+ PropertyChanges { target: horizontalScrollBar; opacity: 1 }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ duration: 400
+ }
+ }
+ ]
+ }
+ // Attach scrollbars to the right and bottom edges of the view.
+ ScrollBar {
+ id: verticalScrollBar
+ opacity: 0
+ orientation: "Vertical"
+ position: view.visibleArea.yPosition
+ pageSize: view.visibleArea.heightRatio
+ width: 12
+ height: view.height-12
+ anchors.right: view.right
+ }
+ ScrollBar {
+ id: horizontalScrollBar
+ opacity: 0
+ orientation: "Horizontal"
+ position: view.visibleArea.xPosition
+ pageSize: view.visibleArea.widthRatio
+ 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/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml
new file mode 100644
index 0000000..524b652
--- /dev/null
+++ b/examples/declarative/searchbox/SearchBox.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+FocusScope {
+ id: focusScope
+ width: 250; height: 28
+
+ BorderImage {
+ source: "images/lineedit-bg.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ }
+
+ BorderImage {
+ source: "images/lineedit-bg-focus.png"
+ width: parent.width; height: parent.height
+ border { left: 4; top: 4; right: 4; bottom: 4 }
+ visible: parent.wantsFocus ? true : false
+ }
+
+ Text {
+ id: typeSomething; anchors.fill: parent; anchors.leftMargin: 8
+ verticalAlignment: Text.AlignVCenter
+ text: "Type something..."; color: "gray"; font.italic: true
+ }
+
+ MouseArea { anchors.fill: parent; onClicked: focusScope.focus = true }
+
+ TextInput {
+ id: textInput
+ anchors.left: parent.left; anchors.leftMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ focus: if (1) true
+ }
+
+ Image {
+ id: clear
+ anchors.right: parent.right; anchors.rightMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ source: "images/edit-clear-locationbar-rtl.png"; opacity: 0
+
+ MouseArea { anchors.fill: parent; onClicked: { textInput.text = ''; focusScope.focus = true } }
+ }
+
+ states: State {
+ name: "hasText"; when: textInput.text != ''
+ PropertyChanges { target: typeSomething; opacity: 0 }
+ PropertyChanges { target: clear; opacity: 1 }
+ }
+
+ transitions: [
+ Transition {
+ from: ""; to: "hasText"
+ NumberAnimation { exclude: typeSomething; properties: "opacity" }
+ },
+ Transition {
+ from: "hasText"; to: ""
+ NumberAnimation { properties: "opacity" }
+ }
+ ]
+}
diff --git a/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png b/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png
new file mode 100644
index 0000000..91eb270
--- /dev/null
+++ b/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png
Binary files differ
diff --git a/examples/declarative/searchbox/images/lineedit-bg-focus.png b/examples/declarative/searchbox/images/lineedit-bg-focus.png
new file mode 100644
index 0000000..bbfac38
--- /dev/null
+++ b/examples/declarative/searchbox/images/lineedit-bg-focus.png
Binary files differ
diff --git a/examples/declarative/searchbox/images/lineedit-bg.png b/examples/declarative/searchbox/images/lineedit-bg.png
new file mode 100644
index 0000000..9044226
--- /dev/null
+++ b/examples/declarative/searchbox/images/lineedit-bg.png
Binary files differ
diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml
new file mode 100644
index 0000000..9b33be3
--- /dev/null
+++ b/examples/declarative/searchbox/main.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+Rectangle {
+ width: 500; height: 250; color: "#edecec"
+
+ Column {
+ anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter; spacing: 10
+
+ SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true }
+ SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 }
+ SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 }
+ }
+}
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
new file mode 100644
index 0000000..758aee6
--- /dev/null
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -0,0 +1,73 @@
+//![0]
+import Qt 4.6
+
+Item {
+ id: toggleswitch
+ width: background.width; height: background.height
+
+//![1]
+ property bool on: false
+//![1]
+
+//![2]
+ function toggle() {
+ if (toggleswitch.state == "on")
+ toggleswitch.state = "off";
+ else toggleswitch.state = "on";
+ }
+//![2]
+
+//![3]
+ function dorelease() {
+ if (knob.x == 1) {
+ if (toggleswitch.state == "off") return;
+ }
+ if (knob.x == 78) {
+ if (toggleswitch.state == "on") return;
+ }
+ toggle();
+ }
+//![3]
+
+//![4]
+ Image {
+ id: background; source: "background.svg"
+ MouseArea { anchors.fill: parent; onClicked: toggle() }
+ }
+//![4]
+
+//![5]
+ Image {
+ id: knob; source: "knob.svg"; x: 1; y: 2
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
+ onClicked: toggle()
+ onReleased: dorelease()
+ }
+ }
+//![5]
+
+//![6]
+ states: [
+ State {
+ name: "on"
+ PropertyChanges { target: knob; x: 78 }
+ PropertyChanges { target: toggleswitch; on: true }
+ },
+ State {
+ name: "off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: toggleswitch; on: false }
+ }
+ ]
+//![6]
+
+//![7]
+ transitions: Transition {
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad"; duration: 200 }
+ }
+//![7]
+}
+//![0]
diff --git a/examples/declarative/slideswitch/content/background.svg b/examples/declarative/slideswitch/content/background.svg
new file mode 100644
index 0000000..f920d3e
--- /dev/null
+++ b/examples/declarative/slideswitch/content/background.svg
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+]>
+<svg version="1.1"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+ x="0px" y="0px" width="130px" height="56px" viewBox="0 0 130 56" enable-background="new 0 0 130 56" xml:space="preserve">
+<defs>
+</defs>
+<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-37.5005" y1="-66" x2="-37.5005" y2="-121.9985" gradientTransform="matrix(1 0 0 -1 102.5 -66)">
+ <stop offset="0.0056" style="stop-color:#000000"/>
+ <stop offset="1" style="stop-color:#EAECEF"/>
+</linearGradient>
+<path fill="url(#SVGID_1_)" d="M101.998,55.998H28c-15.439,0-28-12.562-28-28C0,12.56,12.561,0,28,0h73.998
+ c15.439,0,28,12.559,28,27.998C129.998,43.438,117.438,55.998,101.998,55.998L101.998,55.998z"/>
+<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="-5.5" y1="-132.1338" x2="-69.5002" y2="-55.8613" gradientTransform="matrix(1 0 0 -1 102.5 -66)">
+ <stop offset="0.0056" style="stop-color:#000000"/>
+ <stop offset="1" style="stop-color:#828385"/>
+</linearGradient>
+<path fill="url(#SVGID_2_)" d="M127.999,27.998c0,14.359-11.642,26-26,26h-74c-14.359,0-26-11.641-26-26l0,0
+ c0-14.359,11.641-26,26-26h74C116.357,1.998,127.999,13.639,127.999,27.998L127.999,27.998z"/>
+</svg>
diff --git a/examples/declarative/slideswitch/content/knob.svg b/examples/declarative/slideswitch/content/knob.svg
new file mode 100644
index 0000000..fb69337
--- /dev/null
+++ b/examples/declarative/slideswitch/content/knob.svg
@@ -0,0 +1,867 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ x="0px"
+ y="0px"
+ width="52px"
+ height="52px"
+ viewBox="0 0 52 52"
+ enable-background="new 0 0 52 52"
+ xml:space="preserve"
+ id="svg3883"
+ sodipodi:version="0.32"
+ inkscape:version="0.44.1"
+ sodipodi:docname="knob_on.svg"
+ sodipodi:docbase="/local/axel/embeddedwidgets/embeddedstories/skins/svgslideswitch/MetallicBrush"><metadata
+ id="metadata4200"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
+ inkscape:window-height="640"
+ inkscape:window-width="937"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ inkscape:zoom="8.3653846"
+ inkscape:cx="26.000002"
+ inkscape:cy="26"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:current-layer="svg3883" />
+<defs
+ id="defs3885">
+</defs>
+<linearGradient
+ id="SVGID_1_"
+ gradientUnits="userSpaceOnUse"
+ x1="-59.7866"
+ y1="-115.917"
+ x2="-93.2123"
+ y2="-76.0818"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#000000"
+ id="stop3888" />
+ <stop
+ offset="1"
+ style="stop-color:#EAECEF"
+ id="stop3890" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="26"
+ id="circle3892"
+ style="fill:url(#SVGID_1_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="26"
+ sodipodi:ry="26"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_2_"
+ gradientUnits="userSpaceOnUse"
+ x1="-100.5"
+ y1="-96"
+ x2="-52.5"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3895" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3897" />
+ <stop
+ offset="0.6043"
+ style="stop-color:#E7EAED"
+ id="stop3899" />
+ <stop
+ offset="0.6751"
+ style="stop-color:#DEE4E7"
+ id="stop3901" />
+ <stop
+ offset="0.7358"
+ style="stop-color:#CFD9DD"
+ id="stop3903" />
+ <stop
+ offset="0.791"
+ style="stop-color:#B9CACF"
+ id="stop3905" />
+ <stop
+ offset="0.8425"
+ style="stop-color:#9EB6BD"
+ id="stop3907" />
+ <stop
+ offset="0.891"
+ style="stop-color:#7B9EA7"
+ id="stop3909" />
+ <stop
+ offset="0.9374"
+ style="stop-color:#53828C"
+ id="stop3911" />
+ <stop
+ offset="0.9809"
+ style="stop-color:#25626E"
+ id="stop3913" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3915" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="24"
+ id="circle3917"
+ style="fill:url(#SVGID_2_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="24"
+ sodipodi:ry="24"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_3_"
+ gradientUnits="userSpaceOnUse"
+ x1="-98.6328"
+ y1="-96"
+ x2="-54.3672"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3920" />
+ <stop
+ offset="0.073"
+ style="stop-color:#8FAECB"
+ id="stop3922" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3924" />
+ <stop
+ offset="0.5902"
+ style="stop-color:#E7E9ED"
+ id="stop3926" />
+ <stop
+ offset="0.618"
+ style="stop-color:#E4E7EB"
+ id="stop3928" />
+ <stop
+ offset="0.6697"
+ style="stop-color:#E0E4E9"
+ id="stop3930" />
+ <stop
+ offset="0.7211"
+ style="stop-color:#D4DCE1"
+ id="stop3932" />
+ <stop
+ offset="0.7722"
+ style="stop-color:#C0CFD5"
+ id="stop3934" />
+ <stop
+ offset="0.809"
+ style="stop-color:#ADC2C9"
+ id="stop3936" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3938" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="22.132999"
+ id="circle3940"
+ style="fill:url(#SVGID_3_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="22.132999"
+ sodipodi:ry="22.132999"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_4_"
+ gradientUnits="userSpaceOnUse"
+ x1="-96.7671"
+ y1="-96"
+ x2="-56.2324"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3943" />
+ <stop
+ offset="0.073"
+ style="stop-color:#86A7C4"
+ id="stop3945" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3947" />
+ <stop
+ offset="0.577"
+ style="stop-color:#E7EAED"
+ id="stop3949" />
+ <stop
+ offset="0.618"
+ style="stop-color:#E1E6EA"
+ id="stop3951" />
+ <stop
+ offset="0.6697"
+ style="stop-color:#DDE3E8"
+ id="stop3953" />
+ <stop
+ offset="0.7211"
+ style="stop-color:#D1DBE1"
+ id="stop3955" />
+ <stop
+ offset="0.7722"
+ style="stop-color:#BDCDD5"
+ id="stop3957" />
+ <stop
+ offset="0.809"
+ style="stop-color:#AAC0CA"
+ id="stop3959" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3961" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="20.267"
+ id="circle3963"
+ style="fill:url(#SVGID_4_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="20.267"
+ sodipodi:ry="20.267"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_5_"
+ gradientUnits="userSpaceOnUse"
+ x1="-94.8999"
+ y1="-96"
+ x2="-58.0996"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3966" />
+ <stop
+ offset="0.073"
+ style="stop-color:#7E9FBC"
+ id="stop3968" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3970" />
+ <stop
+ offset="0.5709"
+ style="stop-color:#E6E9ED"
+ id="stop3972" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DFE4E9"
+ id="stop3974" />
+ <stop
+ offset="0.6687"
+ style="stop-color:#DBE1E7"
+ id="stop3976" />
+ <stop
+ offset="0.7193"
+ style="stop-color:#CFD9E0"
+ id="stop3978" />
+ <stop
+ offset="0.7695"
+ style="stop-color:#BBCCD6"
+ id="stop3980" />
+ <stop
+ offset="0.809"
+ style="stop-color:#A6BECA"
+ id="stop3982" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop3984" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="18.4"
+ id="circle3986"
+ style="fill:url(#SVGID_5_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="18.4"
+ sodipodi:ry="18.4"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_6_"
+ gradientUnits="userSpaceOnUse"
+ x1="-93.0332"
+ y1="-96"
+ x2="-59.9668"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop3989" />
+ <stop
+ offset="0.073"
+ style="stop-color:#7697B4"
+ id="stop3991" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop3993" />
+ <stop
+ offset="0.5636"
+ style="stop-color:#E6E9ED"
+ id="stop3995" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DCE2E8"
+ id="stop3997" />
+ <stop
+ offset="0.6687"
+ style="stop-color:#D8DFE6"
+ id="stop3999" />
+ <stop
+ offset="0.7193"
+ style="stop-color:#CCD7E0"
+ id="stop4001" />
+ <stop
+ offset="0.7695"
+ style="stop-color:#B8CAD5"
+ id="stop4003" />
+ <stop
+ offset="0.809"
+ style="stop-color:#A3BCCA"
+ id="stop4005" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4007" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="16.533001"
+ id="circle4009"
+ style="fill:url(#SVGID_6_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="16.533001"
+ sodipodi:ry="16.533001"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_7_"
+ gradientUnits="userSpaceOnUse"
+ x1="-91.167"
+ y1="-96"
+ x2="-61.833"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4012" />
+ <stop
+ offset="0.073"
+ style="stop-color:#6D8FAD"
+ id="stop4014" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4016" />
+ <stop
+ offset="0.5605"
+ style="stop-color:#E5E8EC"
+ id="stop4018" />
+ <stop
+ offset="0.618"
+ style="stop-color:#DAE1E7"
+ id="stop4020" />
+ <stop
+ offset="0.6679"
+ style="stop-color:#D6DEE5"
+ id="stop4022" />
+ <stop
+ offset="0.7175"
+ style="stop-color:#CAD6DF"
+ id="stop4024" />
+ <stop
+ offset="0.7669"
+ style="stop-color:#B6C9D6"
+ id="stop4026" />
+ <stop
+ offset="0.809"
+ style="stop-color:#9FBACB"
+ id="stop4028" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4030" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="14.667"
+ id="circle4032"
+ style="fill:url(#SVGID_7_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="14.667"
+ sodipodi:ry="14.667"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_8_"
+ gradientUnits="userSpaceOnUse"
+ x1="-89.2998"
+ y1="-96"
+ x2="-63.7002"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4035" />
+ <stop
+ offset="0.073"
+ style="stop-color:#6587A5"
+ id="stop4037" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4039" />
+ <stop
+ offset="0.5588"
+ style="stop-color:#E4E8EC"
+ id="stop4041" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D8DFE7"
+ id="stop4043" />
+ <stop
+ offset="0.6675"
+ style="stop-color:#D4DCE5"
+ id="stop4045" />
+ <stop
+ offset="0.7167"
+ style="stop-color:#C8D5E0"
+ id="stop4047" />
+ <stop
+ offset="0.7657"
+ style="stop-color:#B4C8D6"
+ id="stop4049" />
+ <stop
+ offset="0.809"
+ style="stop-color:#9CB8CB"
+ id="stop4051" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4053" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="12.8"
+ id="circle4055"
+ style="fill:url(#SVGID_8_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="12.8"
+ sodipodi:ry="12.8"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_9_"
+ gradientUnits="userSpaceOnUse"
+ x1="-87.4331"
+ y1="-96"
+ x2="-65.5664"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4058" />
+ <stop
+ offset="0.073"
+ style="stop-color:#5D809D"
+ id="stop4060" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4062" />
+ <stop
+ offset="0.5567"
+ style="stop-color:#E3E7EC"
+ id="stop4064" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D5DDE6"
+ id="stop4066" />
+ <stop
+ offset="0.6671"
+ style="stop-color:#D1DAE4"
+ id="stop4068" />
+ <stop
+ offset="0.7159"
+ style="stop-color:#C5D3DF"
+ id="stop4070" />
+ <stop
+ offset="0.7645"
+ style="stop-color:#B1C6D6"
+ id="stop4072" />
+ <stop
+ offset="0.809"
+ style="stop-color:#98B5CB"
+ id="stop4074" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4076" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="10.933"
+ id="circle4078"
+ style="fill:url(#SVGID_9_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="10.933"
+ sodipodi:ry="10.933"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_10_"
+ gradientUnits="userSpaceOnUse"
+ x1="-85.5659"
+ y1="-96"
+ x2="-67.4336"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4081" />
+ <stop
+ offset="0.073"
+ style="stop-color:#547896"
+ id="stop4083" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4085" />
+ <stop
+ offset="0.5588"
+ style="stop-color:#E1E6EB"
+ id="stop4087" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D3DCE5"
+ id="stop4089" />
+ <stop
+ offset="0.6663"
+ style="stop-color:#CFD9E3"
+ id="stop4091" />
+ <stop
+ offset="0.7143"
+ style="stop-color:#C3D2DF"
+ id="stop4093" />
+ <stop
+ offset="0.7621"
+ style="stop-color:#AFC5D7"
+ id="stop4095" />
+ <stop
+ offset="0.809"
+ style="stop-color:#94B3CC"
+ id="stop4097" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4099" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="9.066"
+ id="circle4101"
+ style="fill:url(#SVGID_10_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="9.066"
+ sodipodi:ry="9.066"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_11_"
+ gradientUnits="userSpaceOnUse"
+ x1="-83.7002"
+ y1="-96"
+ x2="-69.2998"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4104" />
+ <stop
+ offset="0.073"
+ style="stop-color:#4C708E"
+ id="stop4106" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4108" />
+ <stop
+ offset="0.5625"
+ style="stop-color:#DEE4EA"
+ id="stop4110" />
+ <stop
+ offset="0.618"
+ style="stop-color:#D0DAE4"
+ id="stop4112" />
+ <stop
+ offset="0.6663"
+ style="stop-color:#CCD7E2"
+ id="stop4114" />
+ <stop
+ offset="0.7143"
+ style="stop-color:#C0D0DE"
+ id="stop4116" />
+ <stop
+ offset="0.7621"
+ style="stop-color:#ACC3D6"
+ id="stop4118" />
+ <stop
+ offset="0.809"
+ style="stop-color:#91B1CC"
+ id="stop4120" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4122" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="7.1999998"
+ id="circle4124"
+ style="fill:url(#SVGID_11_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="7.1999998"
+ sodipodi:ry="7.1999998"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_12_"
+ gradientUnits="userSpaceOnUse"
+ x1="-81.833"
+ y1="-96"
+ x2="-71.167"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4127" />
+ <stop
+ offset="0.073"
+ style="stop-color:#446986"
+ id="stop4129" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4131" />
+ <stop
+ offset="0.5757"
+ style="stop-color:#D9E0E8"
+ id="stop4133" />
+ <stop
+ offset="0.618"
+ style="stop-color:#CED8E3"
+ id="stop4135" />
+ <stop
+ offset="0.6655"
+ style="stop-color:#CAD5E2"
+ id="stop4137" />
+ <stop
+ offset="0.7129"
+ style="stop-color:#BECEDD"
+ id="stop4139" />
+ <stop
+ offset="0.7601"
+ style="stop-color:#AAC1D6"
+ id="stop4141" />
+ <stop
+ offset="0.807"
+ style="stop-color:#8EB0CC"
+ id="stop4143" />
+ <stop
+ offset="0.809"
+ style="stop-color:#8DAFCC"
+ id="stop4145" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4147" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="5.3330002"
+ id="circle4149"
+ style="fill:url(#SVGID_12_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="5.3330002"
+ sodipodi:ry="5.3330002"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_13_"
+ gradientUnits="userSpaceOnUse"
+ x1="-79.9658"
+ y1="-96"
+ x2="-73.0342"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4152" />
+ <stop
+ offset="0.073"
+ style="stop-color:#3B617F"
+ id="stop4154" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4156" />
+ <stop
+ offset="0.6087"
+ style="stop-color:#CED9E3"
+ id="stop4158" />
+ <stop
+ offset="0.618"
+ style="stop-color:#CBD7E2"
+ id="stop4160" />
+ <stop
+ offset="0.6655"
+ style="stop-color:#C7D4E1"
+ id="stop4162" />
+ <stop
+ offset="0.7129"
+ style="stop-color:#BBCDDD"
+ id="stop4164" />
+ <stop
+ offset="0.7601"
+ style="stop-color:#A7C0D6"
+ id="stop4166" />
+ <stop
+ offset="0.807"
+ style="stop-color:#8BAECD"
+ id="stop4168" />
+ <stop
+ offset="0.809"
+ style="stop-color:#8AADCD"
+ id="stop4170" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4172" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="3.4660001"
+ id="circle4174"
+ style="fill:url(#SVGID_13_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="3.4660001"
+ sodipodi:ry="3.4660001"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+<linearGradient
+ id="SVGID_14_"
+ gradientUnits="userSpaceOnUse"
+ x1="-78.1001"
+ y1="-96"
+ x2="-74.9004"
+ y2="-96"
+ gradientTransform="matrix(1,0,0,-1,102.5,-70)">
+ <stop
+ offset="0.0056"
+ style="stop-color:#8AADCE"
+ id="stop4177" />
+ <stop
+ offset="0.073"
+ style="stop-color:#335977"
+ id="stop4179" />
+ <stop
+ offset="0.5"
+ style="stop-color:#EAECEF"
+ id="stop4181" />
+ <stop
+ offset="0.618"
+ style="stop-color:#C9D5E1"
+ id="stop4183" />
+ <stop
+ offset="0.6648"
+ style="stop-color:#C5D3E0"
+ id="stop4185" />
+ <stop
+ offset="0.7114"
+ style="stop-color:#B9CBDC"
+ id="stop4187" />
+ <stop
+ offset="0.758"
+ style="stop-color:#A5BFD6"
+ id="stop4189" />
+ <stop
+ offset="0.8042"
+ style="stop-color:#89ADCE"
+ id="stop4191" />
+ <stop
+ offset="0.809"
+ style="stop-color:#86ABCD"
+ id="stop4193" />
+ <stop
+ offset="1"
+ style="stop-color:#0E525F"
+ id="stop4195" />
+</linearGradient>
+<circle
+ cx="26"
+ cy="26"
+ r="1.6"
+ id="circle4197"
+ style="fill:url(#SVGID_14_)"
+ sodipodi:cx="26"
+ sodipodi:cy="26"
+ sodipodi:rx="1.6"
+ sodipodi:ry="1.6"
+ transform="matrix(0.923077,0,0,0.923077,2,1.999996)" />
+</svg> \ No newline at end of file
diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml
new file mode 100644
index 0000000..396749f
--- /dev/null
+++ b/examples/declarative/slideswitch/slideswitch.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ color: "white"
+ width: 400; height: 250
+
+//![0]
+ Switch { anchors.centerIn: parent; on: false }
+//![0]
+}
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
new file mode 100644
index 0000000..29e084c
--- /dev/null
+++ b/examples/declarative/sql/hello.qml
@@ -0,0 +1,30 @@
+import Qt 4.6
+
+Text {
+ function findGreetings() {
+ var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
+
+ db.transaction(
+ function(tx) {
+ // Create the database if it doesn't already exist
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+
+ // Add (another) greeting row
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+
+ // Show all added greetings
+ var rs = tx.executeSql('SELECT * FROM Greeting');
+
+ var r = ""
+ for(var i = 0; i < rs.rows.length; i++) {
+ r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
+ }
+ text = r
+ }
+ )
+ }
+
+ text: "?"
+ Component.onCompleted: findGreetings()
+}
+
diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml
new file mode 100644
index 0000000..89f2421
--- /dev/null
+++ b/examples/declarative/states/states.qml
@@ -0,0 +1,50 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: 640; height: 480; color: "#343434"
+
+ // A target region. Clicking in here sets the state to the default state
+ Rectangle {
+ id: initialPosition
+ anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
+ width: 64; height: 64; radius: 6
+ color: "Transparent"; border.color: "Gray"
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
+ }
+
+ // Another target region. Clicking in here sets the state to 'Position1'
+ Rectangle {
+ id: position1
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
+ width: 64; height: 64; radius: 6
+ color: "Transparent"; border.color: "Gray"
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position1' }
+ }
+
+ // Another target region. Clicking in here sets the state to 'Position2'
+ Rectangle {
+ id: position2
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
+ width: 64; height: 64; radius: 6
+ color: "Transparent"; border.color: "Gray"
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position2' }
+ }
+
+ // The image which will be moved when my state changes
+ Image { id: user; source: "user.png"; x: initialPosition.x; y: initialPosition.y }
+
+ states: [
+ // In state 'Position1', change the 'user' item position to rect2's position.
+ State {
+ name: "Position1"
+ PropertyChanges { target: user; x: position1.x; y: position1.y }
+ },
+
+ // In state 'Position2', change the 'user' item position to rect3's position.
+ State {
+ name: "Position2"
+ PropertyChanges { target: user; x: position2.x; y: position2.y }
+ }
+ ]
+}
diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml
new file mode 100644
index 0000000..8ad61ad
--- /dev/null
+++ b/examples/declarative/states/transitions.qml
@@ -0,0 +1,70 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: 640; height: 480; color: "#343434"
+
+ // A target region. Clicking in here sets the state to the default state
+ Rectangle {
+ id: initialPosition
+ anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 }
+ width: 64; height: 64; radius: 6
+ color: "Transparent"; border.color: "Gray"
+ MouseArea { anchors.fill: parent; onClicked: page.state = '' }
+ }
+
+ // Another target region. Clicking in here sets the state to 'Position1'
+ Rectangle {
+ id: position1
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 }
+ width: 64; height: 64; radius: 6
+ color: "Transparent"; border.color: "Gray"
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position1' }
+ }
+
+ // Another target region. Clicking in here sets the state to 'Position2'
+ Rectangle {
+ id: position2
+ anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 }
+ width: 64; height: 64; radius: 6
+ color: "Transparent"; border.color: "Gray"
+ MouseArea { anchors.fill: parent; onClicked: page.state = 'Position2' }
+ }
+
+ // The image which will be moved when my state changes
+ Image { id: user; source: "user.png"; x: initialPosition.x; y: initialPosition.y }
+
+ states: [
+ // In state 'Position1', change the 'user' item position to rect2's position.
+ State {
+ name: "Position1"
+ PropertyChanges { target: user; x: position1.x; y: position1.y }
+ },
+
+ // In state 'Position2', change the 'user' item position to rect3's position.
+ State {
+ name: "Position2"
+ PropertyChanges { target: user; x: position2.x; y: position2.y }
+ }
+ ]
+
+ // transitions define how the properties change.
+ transitions: [
+ // When transitioning to 'Position1' move x,y over a duration of 1 second,
+ // with OutBounce easing function.
+ Transition {
+ from: "*"; to: "Position1"
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce"; duration: 1000 }
+ },
+ // When transitioning to 'Position2' move x,y over a duration of 2 seconds,
+ // with InOutQuad easing function.
+ Transition {
+ from: "*"; to: "Position2"
+ NumberAnimation { properties: "x,y"; easing.type: "InOutQuad"; duration: 2000 }
+ },
+ // For any other state changes move x,y linearly over duration of 200ms.
+ Transition {
+ NumberAnimation { properties: "x,y"; duration: 200 }
+ }
+ ]
+}
diff --git a/examples/declarative/states/user.png b/examples/declarative/states/user.png
new file mode 100644
index 0000000..dd7d7a2
--- /dev/null
+++ b/examples/declarative/states/user.png
Binary files differ
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
new file mode 100644
index 0000000..f0f7164
--- /dev/null
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -0,0 +1,50 @@
+import Qt 4.6
+
+Item {
+ id: tabWidget
+ property int current: 0
+ default property alias content: stack.children
+
+ onCurrentChanged: setOpacities()
+ Component.onCompleted: setOpacities()
+
+ function setOpacities()
+ {
+ for (var i = 0; i < stack.children.length; ++i) {
+ stack.children[i].opacity = i == current ? 1 : 0
+ }
+ }
+
+ Row {
+ id: header
+ Repeater {
+ delegate:
+ Rectangle {
+ width: tabWidget.width / stack.children.length; height: 36
+ Rectangle {
+ color: "#acb2c2"; width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ }
+ BorderImage {
+ source: "tab.png"; visible: tabWidget.current == index; border.left: 7; border.right: 7
+ anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
+ }
+ Text {
+ horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent; text: stack.children[index].title
+ elide: Text.ElideRight; font.bold: tabWidget.current == index
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: tabWidget.current = index
+ }
+ }
+ model: stack.children.length
+ }
+ }
+
+ Item {
+ id: stack
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom; width: tabWidget.width
+ }
+}
diff --git a/examples/declarative/tabwidget/tab.png b/examples/declarative/tabwidget/tab.png
new file mode 100644
index 0000000..ad80216
--- /dev/null
+++ b/examples/declarative/tabwidget/tab.png
Binary files differ
diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml
new file mode 100644
index 0000000..1d11b03
--- /dev/null
+++ b/examples/declarative/tabwidget/tabs.qml
@@ -0,0 +1,48 @@
+import Qt 4.6
+
+TabWidget {
+ id: tabs
+ width: 640; height: 480
+
+ Rectangle {
+ property string title: "Red"
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#ff7f7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Roses are red"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
+ }
+
+ Rectangle {
+ property string title: "Green"
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7fff7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Flower stems are green"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
+ }
+
+ Rectangle {
+ property string title: "Blue"
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7f7fff"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Violets are blue"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
+ }
+}
diff --git a/examples/declarative/tic-tac-toe/content/Button.qml b/examples/declarative/tic-tac-toe/content/Button.qml
new file mode 100644
index 0000000..cfc2f04
--- /dev/null
+++ b/examples/declarative/tic-tac-toe/content/Button.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+ property bool down: false
+ property string mainCol: "lightgray"
+ property string darkCol: "darkgray"
+ property string lightCol: "white"
+
+ color: mainCol; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(mainCol); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (container.down) { darkCol } else { lightCol } }
+ GradientStop { position: 1.0; color: mainCol }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text;
+ anchors.centerIn: container
+ color: "blue"
+ styleColor: "white"
+ style: Text.Outline
+ font.pixelSize: 14
+ font.bold: true
+ }
+}
diff --git a/examples/declarative/tic-tac-toe/content/TicTac.qml b/examples/declarative/tic-tac-toe/content/TicTac.qml
new file mode 100644
index 0000000..ccb7b78
--- /dev/null
+++ b/examples/declarative/tic-tac-toe/content/TicTac.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+Item {
+ signal clicked
+
+ states: [
+ State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } },
+ State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } }
+ ]
+
+ Image {
+ id: image
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+}
diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png
new file mode 100644
index 0000000..e7a7324
--- /dev/null
+++ b/examples/declarative/tic-tac-toe/content/pics/board.png
Binary files differ
diff --git a/examples/declarative/tic-tac-toe/content/pics/o.png b/examples/declarative/tic-tac-toe/content/pics/o.png
new file mode 100644
index 0000000..abc7ee0
--- /dev/null
+++ b/examples/declarative/tic-tac-toe/content/pics/o.png
Binary files differ
diff --git a/examples/declarative/tic-tac-toe/content/pics/x.png b/examples/declarative/tic-tac-toe/content/pics/x.png
new file mode 100644
index 0000000..ddc65c8
--- /dev/null
+++ b/examples/declarative/tic-tac-toe/content/pics/x.png
Binary files differ
diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml
new file mode 100644
index 0000000..4bb1e3f
--- /dev/null
+++ b/examples/declarative/tic-tac-toe/tic-tac-toe.qml
@@ -0,0 +1,78 @@
+import Qt 4.6
+import "content"
+import "tic-tac-toe.js" as Logic
+
+Item {
+ id: game
+ property bool show: false;
+ width: 440
+ height: 480
+ anchors.fill: parent
+ property real difficulty: 1.0; //chance it will actually think
+
+ Image {
+ id: boardimage
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "content/pics/board.png"
+ }
+
+ Grid {
+ id: board
+ anchors.fill: boardimage
+
+ columns: 3
+
+ Repeater {
+ model: 9
+ TicTac {
+ width: board.width/3
+ height: board.height/3
+ onClicked: {
+ if (!endtimer.running) {
+ if (!Logic.makeMove(index,"X"))
+ Logic.computerTurn()
+ }
+ }
+ }
+ }
+
+ Timer {
+ id: endtimer
+ interval: 1600
+ onTriggered: { msg.opacity = 0; Logic.restart() }
+ }
+ }
+
+ Row {
+ spacing: 4
+ anchors.top: board.bottom
+ anchors.horizontalCenter: board.horizontalCenter
+ Button {
+ text: "Hard"
+ onClicked: game.difficulty=1.0;
+ down: game.difficulty == 1.0
+ }
+ Button {
+ text: "Moderate"
+ onClicked: game.difficulty=0.8;
+ down: game.difficulty == 0.8
+ }
+ Button {
+ text: "Easy"
+ onClicked: game.difficulty=0.2;
+ down: game.difficulty == 0.2
+ }
+ }
+
+ Text {
+ id: msg
+ opacity: 0
+ anchors.centerIn: parent
+ color: "blue"
+ styleColor: "white"
+ style: Text.Outline
+ font.pixelSize: 50
+ font.bold: true
+ }
+}
diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml
new file mode 100644
index 0000000..de4f3bb
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/Cell.qml
@@ -0,0 +1,32 @@
+//![0]
+import Qt 4.6
+
+//![1]
+Item {
+ id: container
+//![4]
+ property alias color: rectangle.color
+//![4]
+//![5]
+ signal clicked(color color)
+//![5]
+
+ width: 40; height: 25
+//![1]
+
+//![2]
+ Rectangle {
+ id: rectangle
+ border.color: "white"
+ anchors.fill: parent
+ }
+//![2]
+
+//![3]
+ MouseArea {
+ anchors.fill: parent
+ onClicked: container.clicked(container.color)
+ }
+//![3]
+}
+//![0]
diff --git a/examples/declarative/tutorials/helloworld/tutorial1.qml b/examples/declarative/tutorials/helloworld/tutorial1.qml
new file mode 100644
index 0000000..93d3c34
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/tutorial1.qml
@@ -0,0 +1,22 @@
+//![0]
+//![3]
+import Qt 4.6
+//![3]
+
+//![1]
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+//![1]
+
+//![2]
+ Text {
+ id: helloText
+ text: "Hello world!"
+ font.pointSize: 24; font.bold: true
+ y: 30; anchors.horizontalCenter: page.horizontalCenter
+ }
+//![2]
+}
+//![0]
diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml
new file mode 100644
index 0000000..99889d7
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/tutorial2.qml
@@ -0,0 +1,31 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ font.pointSize: 24; font.bold: true
+ y: 30; anchors.horizontalCenter: page.horizontalCenter
+ }
+
+ Grid {
+ id: colorPicker
+ anchors.bottom: page.bottom
+ rows: 2; columns: 3; spacing: 3
+
+//![1]
+ Cell { color: "red"; onClicked: helloText.color = color }
+//![1]
+ Cell { color: "green"; onClicked: helloText.color = color }
+ Cell { color: "blue"; onClicked: helloText.color = color }
+ Cell { color: "yellow"; onClicked: helloText.color = color }
+ Cell { color: "steelblue"; onClicked: helloText.color = color }
+ Cell { color: "black"; onClicked: helloText.color = color }
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml
new file mode 100644
index 0000000..b8a4f77
--- /dev/null
+++ b/examples/declarative/tutorials/helloworld/tutorial3.qml
@@ -0,0 +1,51 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ font.pointSize: 24; font.bold: true
+ y: 30; anchors.horizontalCenter: page.horizontalCenter
+ transformOrigin: Item.Center
+
+//![1]
+ MouseArea { id: mouseRegion; anchors.fill: parent }
+//![1]
+
+//![2]
+ states: State {
+ name: "down"; when: mouseRegion.pressed == true
+ PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
+ }
+//![2]
+
+//![3]
+ transitions: Transition {
+ from: ""; to: "down"; reversible: true
+ ParallelAnimation {
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: "InOutQuad" }
+ ColorAnimation { duration: 500 }
+ }
+ }
+//![3]
+ }
+
+ Grid {
+ id: colorPicker
+ anchors.bottom: page.bottom
+ rows: 2; columns: 3; spacing: 3
+
+ Cell { color: "red"; onClicked: helloText.color = color }
+ Cell { color: "green"; onClicked: helloText.color = color }
+ Cell { color: "blue"; onClicked: helloText.color = color }
+ Cell { color: "yellow"; onClicked: helloText.color = color }
+ Cell { color: "steelblue"; onClicked: helloText.color = color }
+ Cell { color: "black"; onClicked: helloText.color = color }
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml
new file mode 100644
index 0000000..f133b17
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml
@@ -0,0 +1,12 @@
+//![0]
+import Qt 4.6
+
+Item {
+ id:block
+
+ Image { id: img
+ source: "../shared/pics/redStone.png";
+ anchors.fill: parent
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
new file mode 100644
index 0000000..2e31ff8
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -0,0 +1,27 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
new file mode 100644
index 0000000..5ed30c9
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
@@ -0,0 +1,40 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: screen
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
+
+ Image {
+ id: background
+ anchors.fill: parent; source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolbar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+ Button {
+ id: btnA; text: "New Game"; onClicked: console.log("Implement me!");
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Text {
+ id: score
+ text: "Score: Who knows?"; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml
new file mode 100644
index 0000000..e4b3354
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame2/Block.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Item {
+ id:block
+
+ Image { id: img
+ source: "../shared/pics/redStone.png";
+ anchors.fill: parent
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml
new file mode 100644
index 0000000..6629302
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml
@@ -0,0 +1,25 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js
new file mode 100644
index 0000000..2c02c61
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js
@@ -0,0 +1,61 @@
+//![0]
+//Note that X/Y referred to here are in game coordinates
+var maxX = 10;//Nums are for tileSize 40
+var maxY = 15;
+var tileSize = 40;
+var maxIndex = maxX*maxY;
+var board = new Array(maxIndex);
+var tileSrc = "Block.qml";
+var component;
+
+//Index function used instead of a 2D array
+function index(xIdx,yIdx) {
+ return xIdx + (yIdx * maxX);
+}
+
+function initBoard()
+{
+ //Calculate board size
+ maxX = Math.floor(background.width/tileSize);
+ maxY = Math.floor(background.height/tileSize);
+ maxIndex = maxY*maxX;
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ for(var xIdx=0; xIdx<maxX; xIdx++){
+ for(var yIdx=0; yIdx<maxY; yIdx++){
+ board[index(xIdx,yIdx)] = null;
+ createBlock(xIdx,yIdx);
+ }
+ }
+}
+
+function createBlock(xIdx,yIdx){
+ if(component==null)
+ component = createComponent(tileSrc);
+
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if(component.isReady){
+ var dynamicObject = component.createObject();
+ if(dynamicObject == null){
+ print("error creating block");
+ print(component.errorsString());
+ return false;
+ }
+ dynamicObject.parent = background;
+ dynamicObject.x = xIdx*tileSize;
+ dynamicObject.y = yIdx*tileSize;
+ dynamicObject.width = tileSize;
+ dynamicObject.height = tileSize;
+ board[index(xIdx,yIdx)] = dynamicObject;
+ }else{//isError or isLoading
+ print("error loading block component");
+ print(component.errorsString());
+ return false;
+ }
+ return true;
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
new file mode 100644
index 0000000..7e0bc0c
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
@@ -0,0 +1,43 @@
+import Qt 4.6
+
+Rectangle {
+ id: screen
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+//![2]
+ Script { source: "samegame.js" }
+//![2]
+
+ Item {
+ width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
+
+ Image {
+ id: background
+ anchors.fill: parent; source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+
+ Rectangle {
+ id: toolbar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+//![1]
+ Button {
+ id: btnA; text: "New Game"; onClicked: initBoard();
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+//![1]
+
+ Text {
+ id: score
+ text: "Score: Who knows?"; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml
new file mode 100644
index 0000000..7620104
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame3/Block.qml
@@ -0,0 +1,21 @@
+//![0]
+import Qt 4.6
+
+Item {
+ id:block
+ property int type: 0
+
+ Image { id: img
+ source: {
+ if(type == 0){
+ "../shared/pics/redStone.png";
+ } else if(type == 1) {
+ "../shared/pics/blueStone.png";
+ } else {
+ "../shared/pics/greenStone.png";
+ }
+ }
+ anchors.fill: parent
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml
new file mode 100644
index 0000000..6629302
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml
@@ -0,0 +1,25 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
new file mode 100644
index 0000000..36178ec
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -0,0 +1,23 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: page
+ function forceClose() {
+ page.closed();
+ page.opacity = 0;
+ }
+ function show(txt) {
+ myText.text = txt;
+ page.opacity = 1;
+ }
+ signal closed();
+ color: "white"; border.width: 1; width: myText.width + 20; height: 60;
+ opacity: 0
+ Behavior on opacity {
+ NumberAnimation { duration: 1000 }
+ }
+ Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
new file mode 100644
index 0000000..38efb3b
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -0,0 +1,189 @@
+/* This script file handles the game logic */
+//Note that X/Y referred to here are in game coordinates
+var maxX = 10;//Nums are for tileSize 40
+var maxY = 15;
+var maxIndex = maxX*maxY;
+var board = new Array(maxIndex);
+var tileSrc = "Block.qml";
+var component;
+
+//Index function used instead of a 2D array
+function index(xIdx,yIdx) {
+ return xIdx + (yIdx * maxX);
+}
+
+function initBoard()
+{
+ for(var i = 0; i<maxIndex; i++){
+ //Delete old blocks
+ if(board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
+ maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
+ maxIndex = maxY*maxX;
+
+ //Close dialogs
+ dialog.forceClose();
+
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for(var xIdx=0; xIdx<maxX; xIdx++){
+ for(var yIdx=0; yIdx<maxY; yIdx++){
+ board[index(xIdx,yIdx)] = null;
+ createBlock(xIdx,yIdx);
+ }
+ }
+}
+
+function createBlock(xIdx,yIdx){
+ if(component==null)
+ component = createComponent(tileSrc);
+
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if(component.isReady){
+ var dynamicObject = component.createObject();
+ if(dynamicObject == null){
+ print("error creating block");
+ print(component.errorsString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.parent = gameCanvas;
+ dynamicObject.x = xIdx*gameCanvas.tileSize;
+ dynamicObject.y = yIdx*gameCanvas.tileSize;
+ dynamicObject.width = gameCanvas.tileSize;
+ dynamicObject.height = gameCanvas.tileSize;
+ board[index(xIdx,yIdx)] = dynamicObject;
+ }else{//isError or isLoading
+ print("error loading block component");
+ print(component.errorsString());
+ return false;
+ }
+ return true;
+}
+
+var fillFound;//Set after a floodFill call to the number of tiles found
+var floodBoard;//Set to 1 if the floodFill reaches off that node
+//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+//![1]
+function handleClick(x,y)
+{
+ var xIdx = Math.floor(x/gameCanvas.tileSize);
+ var yIdx = Math.floor(y/gameCanvas.tileSize);
+ if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ return;
+ if(board[index(xIdx, yIdx)] == null)
+ return;
+ //If it's a valid tile, remove it and all connected (does nothing if it's not connected)
+ floodFill(xIdx,yIdx, -1);
+ if(fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+//![1]
+
+function floodFill(xIdx,yIdx,type)
+{
+ if(board[index(xIdx, yIdx)] == null)
+ return;
+ var first = false;
+ if(type == -1){
+ first = true;
+ type = board[index(xIdx,yIdx)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ return;
+ if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type))
+ return;
+ floodBoard[index(xIdx, yIdx)] = 1;
+ floodFill(xIdx+1,yIdx,type);
+ floodFill(xIdx-1,yIdx,type);
+ floodFill(xIdx,yIdx+1,type);
+ floodFill(xIdx,yIdx-1,type);
+ if(first==true && fillFound == 0)
+ return;//Can't remove single tiles
+ board[index(xIdx,yIdx)].opacity = 0;
+ board[index(xIdx,yIdx)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ //Fall down
+ for(var xIdx=0; xIdx<maxX; xIdx++){
+ var fallDist = 0;
+ for(var yIdx=maxY-1; yIdx>=0; yIdx--){
+ if(board[index(xIdx,yIdx)] == null){
+ fallDist += 1;
+ }else{
+ if(fallDist > 0){
+ var obj = board[index(xIdx,yIdx)];
+ obj.y += fallDist * gameCanvas.tileSize;
+ board[index(xIdx,yIdx+fallDist)] = obj;
+ board[index(xIdx,yIdx)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ var fallDist = 0;
+ for(var xIdx=0; xIdx<maxX; xIdx++){
+ if(board[index(xIdx, maxY - 1)] == null){
+ fallDist += 1;
+ }else{
+ if(fallDist > 0){
+ for(var yIdx=0; yIdx<maxY; yIdx++){
+ var obj = board[index(xIdx,yIdx)];
+ if(obj == null)
+ continue;
+ obj.x -= fallDist * gameCanvas.tileSize;
+ board[index(xIdx-fallDist,yIdx)] = obj;
+ board[index(xIdx,yIdx)] = null;
+ }
+ }
+ }
+ }
+}
+
+//![2]
+function victoryCheck()
+{
+ //awards bonuses for no tiles left
+ var deservesBonus = true;
+ for(var xIdx=maxX-1; xIdx>=0; xIdx--)
+ if(board[index(xIdx, maxY - 1)] != null)
+ deservesBonus = false;
+ if(deservesBonus)
+ gameCanvas.score += 500;
+ //Checks for game over
+ if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1)))
+ dialog.show("Game Over. Your score is " + gameCanvas.score);
+}
+//![2]
+
+//only floods up and right, to see if it can find adjacent same-typed tiles
+function floodMoveCheck(xIdx, yIdx, type)
+{
+ if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ return false;
+ if(board[index(xIdx, yIdx)] == null)
+ return false;
+ var myType = board[index(xIdx, yIdx)].type;
+ if(type == myType)
+ return true;
+ return floodMoveCheck(xIdx + 1, yIdx, myType) ||
+ floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type);
+}
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
new file mode 100644
index 0000000..168bf9b
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -0,0 +1,62 @@
+//![0]
+import Qt 4.6
+
+Rectangle {
+ id: screen
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+ Script { source: "samegame.js" }
+
+ Item {
+ width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
+
+ Image {
+ id: background
+ anchors.fill: parent; source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+//![1]
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int tileSize: 40
+
+ z: 20; anchors.centerIn: parent
+ width: parent.width - (parent.width % tileSize);
+ height: parent.height - (parent.height % tileSize);
+
+ MouseArea {
+ id: gameMR
+ anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
+ }
+ }
+//![1]
+ }
+
+//![2]
+ Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+//![2]
+
+ Rectangle {
+ id: toolbar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+ Button {
+ id: btnA; text: "New Game"; onClicked: initBoard();
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Text {
+ id: score
+ text: "Score: " + gameCanvas.score; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
new file mode 100644
index 0000000..a6ef62c
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -0,0 +1,64 @@
+import Qt 4.6
+import Qt.labs.particles 1.0
+
+Item { id:block
+ property int type: 0
+ property bool dying: false
+ //![1]
+ property bool spawned: false
+ property int targetX: 0
+ property int targetY: 0
+
+ SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on y { source: targetY; spring: 2; damping: 0.2 }
+ //![1]
+
+ //![2]
+ Image { id: img
+ source: {
+ if(type == 0){
+ "../../shared/pics/redStone.png";
+ } else if(type == 1) {
+ "../../shared/pics/blueStone.png";
+ } else {
+ "../../shared/pics/greenStone.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { properties:"opacity"; duration: 200 } }
+ anchors.fill: parent
+ }
+ //![2]
+
+ //![3]
+ Particles { id: particles
+ width:1; height:1; anchors.centerIn: parent;
+ emissionRate: 0;
+ lifeSpan: 700; lifeSpanDeviation: 600;
+ angle: 0; angleDeviation: 360;
+ velocity: 100; velocityDeviation:30;
+ source: {
+ if(type == 0){
+ "../../shared/pics/redStar.png";
+ } else if (type == 1) {
+ "../../shared/pics/blueStar.png";
+ } else {
+ "../../shared/pics/greenStar.png";
+ }
+ }
+ }
+ //![3]
+
+ //![4]
+ states: [
+ State{ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+ State{ name: "DeathState"; when: dying == true
+ StateChangeScript { script: particles.burst(50); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+ //![4]
+}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
new file mode 100644
index 0000000..6629302
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
@@ -0,0 +1,25 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+
+ signal clicked
+ property string text: "Button"
+
+ color: activePalette.button; smooth: true
+ width: txtItem.width + 20; height: txtItem.height + 6
+ border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
+
+ gradient: Gradient {
+ GradientStop {
+ id: topGrad; position: 0.0
+ color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ GradientStop { position: 1.0; color: activePalette.button }
+ }
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Text {
+ id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
new file mode 100644
index 0000000..831c03b
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
@@ -0,0 +1,21 @@
+import Qt 4.6
+
+Rectangle {
+ id: page
+ function forceClose() {
+ page.closed();
+ page.opacity = 0;
+ }
+ function show(txt) {
+ myText.text = txt;
+ page.opacity = 1;
+ }
+ signal closed();
+ color: "white"; border.width: 1; width: myText.width + 20; height: 60;
+ opacity: 0
+ Behavior on opacity {
+ NumberAnimation { duration: 1000 }
+ }
+ Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
+ MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
new file mode 100755
index 0000000..2a0d718
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -0,0 +1,249 @@
+/* This script file handles the game logic */
+//Note that X/Y referred to here are in game coordinates
+var maxX = 10;//Nums are for gameCanvas.tileSize 40
+var maxY = 15;
+var maxIndex = maxX*maxY;
+var board = new Array(maxIndex);
+var tileSrc = "content/BoomBlock.qml";
+//var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
+var scoresURL = "";
+var timer;
+var component = createComponent(tileSrc);
+
+//Index function used instead of a 2D array
+function index(xIdx,yIdx) {
+ return xIdx + (yIdx * maxX);
+}
+
+function timeStr(msecs) {
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
+function getTileSize()
+{
+ return tileSize;
+}
+
+function initBoard()
+{
+ for(var i = 0; i<maxIndex; i++){
+ //Delete old blocks
+ if(board[i] != null)
+ board[i].destroy();
+ }
+
+ //Calculate board size
+ maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
+ maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
+ maxIndex = maxY*maxX;
+
+ //Close dialogs
+ scoreName.forceClose();
+ dialog.forceClose();
+
+ var a = new Date();
+ //Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ for(var xIdx=0; xIdx<maxX; xIdx++){
+ for(var yIdx=0; yIdx<maxY; yIdx++){
+ board[index(xIdx,yIdx)] = null;
+ createBlock(xIdx,yIdx);
+ }
+ }
+ timer = new Date();
+
+ print(timer.valueOf() - a.valueOf());
+}
+
+var fillFound;//Set after a floodFill call to the number of tiles found
+var floodBoard;//Set to 1 if the floodFill reaches off that node
+//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+function handleClick(x,y)
+{
+ var xIdx = Math.floor(x/gameCanvas.tileSize);
+ var yIdx = Math.floor(y/gameCanvas.tileSize);
+ if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ return;
+ if(board[index(xIdx, yIdx)] == null)
+ return;
+ //If it's a valid tile, remove it and all connected (does nothing if it's not connected)
+ floodFill(xIdx,yIdx, -1);
+ if(fillFound <= 0)
+ return;
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ shuffleDown();
+ victoryCheck();
+}
+
+function floodFill(xIdx,yIdx,type)
+{
+ if(board[index(xIdx, yIdx)] == null)
+ return;
+ var first = false;
+ if(type == -1){
+ first = true;
+ type = board[index(xIdx,yIdx)].type;
+
+ //Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ return;
+ if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type))
+ return;
+ floodBoard[index(xIdx, yIdx)] = 1;
+ floodFill(xIdx+1,yIdx,type);
+ floodFill(xIdx-1,yIdx,type);
+ floodFill(xIdx,yIdx+1,type);
+ floodFill(xIdx,yIdx-1,type);
+ if(first==true && fillFound == 0)
+ return;//Can't remove single tiles
+ board[index(xIdx,yIdx)].dying = true;
+ board[index(xIdx,yIdx)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ //Fall down
+ for(var xIdx=0; xIdx<maxX; xIdx++){
+ var fallDist = 0;
+ for(var yIdx=maxY-1; yIdx>=0; yIdx--){
+ if(board[index(xIdx,yIdx)] == null){
+ fallDist += 1;
+ }else{
+ if(fallDist > 0){
+ var obj = board[index(xIdx,yIdx)];
+ obj.targetY += fallDist * gameCanvas.tileSize;
+ board[index(xIdx,yIdx+fallDist)] = obj;
+ board[index(xIdx,yIdx)] = null;
+ }
+ }
+ }
+ }
+ //Fall to the left
+ fallDist = 0;
+ for(xIdx=0; xIdx<maxX; xIdx++){
+ if(board[index(xIdx, maxY - 1)] == null){
+ fallDist += 1;
+ }else{
+ if(fallDist > 0){
+ for(yIdx=0; yIdx<maxY; yIdx++){
+ obj = board[index(xIdx,yIdx)];
+ if(obj == null)
+ continue;
+ obj.targetX -= fallDist * gameCanvas.tileSize;
+ board[index(xIdx-fallDist,yIdx)] = obj;
+ board[index(xIdx,yIdx)] = null;
+ }
+ }
+ }
+ }
+}
+
+function victoryCheck()
+{
+ //awards bonuses for no tiles left
+ var deservesBonus = true;
+ for(var xIdx=maxX-1; xIdx>=0; xIdx--)
+ if(board[index(xIdx, maxY - 1)] != null)
+ deservesBonus = false;
+ if(deservesBonus)
+ gameCanvas.score += 500;
+ //Checks for game over
+ if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
+ timer = new Date() - timer;
+ scoreName.show("You won! Please enter your name: ");
+ //dialog.show("Game Over. Your score is " + gameCanvas.score);
+ }
+}
+
+//only floods up and right, to see if it can find adjacent same-typed tiles
+function floodMoveCheck(xIdx, yIdx, type)
+{
+ if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ return false;
+ if(board[index(xIdx, yIdx)] == null)
+ return false;
+ var myType = board[index(xIdx, yIdx)].type;
+ if(type == myType)
+ return true;
+ return floodMoveCheck(xIdx + 1, yIdx, myType) ||
+ floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type);
+}
+
+function createBlock(xIdx,yIdx){
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if(component.isReady){
+ var dynamicObject = component.createObject();
+ if(dynamicObject == null){
+ print("error creating block");
+ print(component.errorsString());
+ return false;
+ }
+ dynamicObject.type = Math.floor(Math.random() * 3);
+ dynamicObject.parent = gameCanvas;
+ dynamicObject.x = xIdx*gameCanvas.tileSize;
+ dynamicObject.targetX = xIdx*gameCanvas.tileSize;
+ dynamicObject.targetY = yIdx*gameCanvas.tileSize;
+ dynamicObject.width = gameCanvas.tileSize;
+ dynamicObject.height = gameCanvas.tileSize;
+ dynamicObject.spawned = true;
+ board[index(xIdx,yIdx)] = dynamicObject;
+ }else{//isError or isLoading
+ print("error loading block component");
+ print(component.errorsString());
+ return false;
+ }
+ return true;
+}
+
+//![2]
+function saveHighScore(name) {
+ if(scoresURL!="")
+ sendHighScore(name);
+ //OfflineStorage
+ var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores",100);
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [name, gameCanvas.score, maxX+"x"+maxY ,Math.floor(timer/1000)];
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10');
+ var r = "\nHIGH SCORES for a standard sized grid\n\n"
+ for(var i = 0; i < rs.rows.length; i++){
+ r += (i+1)+". " + rs.rows.item(i).name +' got '
+ + rs.rows.item(i).score + ' points in '
+ + rs.rows.item(i).time + ' seconds.\n';
+ }
+ dialog.show(r);
+ }
+ );
+}
+//![2]
+
+//![1]
+function sendHighScore(name) {
+ var postman = new XMLHttpRequest()
+ var postData = "name="+name+"&score="+gameCanvas.score
+ +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000);
+ postman.open("POST", scoresURL, true);
+ postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ postman.onreadystatechange = function() {
+ if (postman.readyState == postman.DONE) {
+ dialog.show("Your score has been uploaded.");
+ }
+ }
+ postman.send(postData);
+}
+//![1]
diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/README b/examples/declarative/tutorials/samegame/samegame4/highscores/README
new file mode 100644
index 0000000..eaa00fa
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml
new file mode 100755
index 0000000..c3fd90d
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl
new file mode 100755
index 0000000..670354c
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php
new file mode 100755
index 0000000..3cceb2d
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php
@@ -0,0 +1,34 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ //if($grid != "10x10"){
+ //Need a standard, so as to reject others?
+ //}
+ $file = fopen("score_data.xml", "a"); #It's XML. Happy?
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>
diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
new file mode 100644
index 0000000..c2e8018
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
@@ -0,0 +1,77 @@
+import Qt 4.6
+import "content"
+
+Rectangle {
+ id: screen
+ width: 490; height: 720
+
+ SystemPalette { id: activePalette }
+
+ Item {
+ width: parent.width; anchors.top: parent.top; anchors.bottom: toolBar.top
+
+ Image {
+ id: background
+ anchors.fill: parent; source: "../shared/pics/background.jpg"
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ Item {
+ id: gameCanvas
+ property int score: 0
+ property int tileSize: 40
+
+ Script { source: "content/samegame.js" }
+
+ z: 20; anchors.centerIn: parent
+ width: parent.width - (parent.width % getTileSize());
+ height: parent.height - (parent.height % getTileSize());
+
+ MouseArea {
+ id: gameMR
+ anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+ Dialog {
+ id: scoreName; anchors.centerIn: parent; z: 22;
+ Text {
+ id: spacer
+ opacity: 0
+ text: " You won! Please enter your name:"
+ }
+ TextInput {
+ id: editor
+ onAccepted: {
+ if(scoreName.opacity==1&&editor.text!="")
+ saveHighScore(editor.text);
+ scoreName.forceClose();
+ }
+ anchors.verticalCenter: parent.verticalCenter
+ width: 72; focus: true
+ anchors.left: spacer.right
+ }
+ }
+
+ Rectangle {
+ id: toolBar
+ color: activePalette.window
+ height: 32; width: parent.width
+ anchors.bottom: screen.bottom
+
+ Button {
+ id: btnA; text: "New Game"; onClicked: {initBoard();}
+ anchors.left: parent.left; anchors.leftMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ Text {
+ id: score
+ text: "Score: " + gameCanvas.score; font.bold: true
+ anchors.right: parent.right; anchors.rightMargin: 3
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/shared/pics/background.jpg b/examples/declarative/tutorials/samegame/shared/pics/background.jpg
new file mode 100644
index 0000000..903d395
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/background.jpg
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/blueStar.png b/examples/declarative/tutorials/samegame/shared/pics/blueStar.png
new file mode 100644
index 0000000..ff9588f
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/blueStar.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/blueStone.png b/examples/declarative/tutorials/samegame/shared/pics/blueStone.png
new file mode 100644
index 0000000..20e43c7
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/blueStone.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/greenStar.png b/examples/declarative/tutorials/samegame/shared/pics/greenStar.png
new file mode 100644
index 0000000..cd06854
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/greenStar.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/greenStone.png b/examples/declarative/tutorials/samegame/shared/pics/greenStone.png
new file mode 100644
index 0000000..b568a19
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/greenStone.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/redStar.png b/examples/declarative/tutorials/samegame/shared/pics/redStar.png
new file mode 100644
index 0000000..0a4dffe
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/redStar.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/redStone.png b/examples/declarative/tutorials/samegame/shared/pics/redStone.png
new file mode 100644
index 0000000..36b09a2
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/redStone.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/star.png b/examples/declarative/tutorials/samegame/shared/pics/star.png
new file mode 100644
index 0000000..defbde5
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/star.png
Binary files differ
diff --git a/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png b/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png
new file mode 100644
index 0000000..b1ce762
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png
Binary files differ
diff --git a/examples/declarative/tvtennis/click.wav b/examples/declarative/tvtennis/click.wav
new file mode 100644
index 0000000..26c46f8
--- /dev/null
+++ b/examples/declarative/tvtennis/click.wav
Binary files differ
diff --git a/examples/declarative/tvtennis/paddle.wav b/examples/declarative/tvtennis/paddle.wav
new file mode 100644
index 0000000..604e0e5
--- /dev/null
+++ b/examples/declarative/tvtennis/paddle.wav
Binary files differ
diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml
new file mode 100644
index 0000000..fcb285d
--- /dev/null
+++ b/examples/declarative/tvtennis/tvtennis.qml
@@ -0,0 +1,78 @@
+import Qt 4.6
+import Qt.multimedia 4.7
+
+Rectangle {
+ id: page
+ width: 640; height: 480
+ color: "Black"
+
+ // Make a ball to bounce
+ Rectangle {
+ // Add a property for the target y coordinate
+ property int targetY : page.height - 10
+ property var direction : "right"
+
+ id: ball
+ color: "Lime"
+ x: 20; width: 20; height: 20; z: 1
+
+ SoundEffect { id: paddle; source: "paddle.wav" }
+ SoundEffect { id: wall; source: "click.wav" }
+
+ // Move the ball to the right and back to the left repeatedly
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { to: page.width - 40; duration: 2000 }
+ ScriptAction { script: paddle.play() }
+ PropertyAction { target: ball; property: "direction"; value: "left" }
+ NumberAnimation { to: 20; duration: 2000 }
+ ScriptAction { script: paddle.play() }
+ PropertyAction { target: ball; property: "direction"; value: "right" }
+ }
+
+ // Make y follow the target y coordinate, with a velocity of 200
+ SpringFollow on y { source: ball.targetY; velocity: 200 }
+
+ // Detect the ball hitting the top or bottom of the view and bounce it
+ onYChanged: {
+ if (y <= 0) {
+ wall.play();
+ targetY = page.height - 20;
+ } else if (y >= page.height - 20) {
+ wall.play();
+ targetY = 0;
+ }
+ }
+ }
+
+ // Place bats to the left and right of the view, following the y
+ // coordinates of the ball.
+ Rectangle {
+ id: leftBat
+ color: "Lime"
+ x: 2; width: 20; height: 90
+ SpringFollow on y {
+ source: ball.y - 45; velocity: 300
+ enabled: ball.direction == 'left'
+ }
+ }
+ Rectangle {
+ id: rightBat
+ color: "Lime"
+ x: page.width - 22; width: 20; height: 90
+ SpringFollow on y {
+ source: ball.y-45; velocity: 300
+ enabled: ball.direction == 'right'
+ }
+ }
+
+ // The rest, to make it look realistic, if neither ever scores...
+ Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 }
+ Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 }
+ Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 }
+ Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 }
+ Repeater {
+ model: page.height / 20
+ Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 }
+ }
+}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
new file mode 100644
index 0000000..f4c24a5
--- /dev/null
+++ b/examples/declarative/velocity/Day.qml
@@ -0,0 +1,78 @@
+import Qt 4.6
+
+Rectangle {
+ property alias day: dayText.text
+ property var stickies
+
+ id: page
+ width: 400; height: 500; radius: 7
+ border.color: "black"
+
+ Image { x: 10; y: 10; source: "cork.jpg" }
+
+ Text {
+ id: dayText; x: 20; y: 20
+ height: 40; width: 370
+ font.pointSize: 14; font.bold: true
+ style: Text.Outline; styleColor: "#dedede"
+ }
+
+ Repeater {
+ model: page.stickies
+
+ Item {
+ id: stickyPage
+ x: Math.random() * 200 + 100
+ y: Math.random() * 300 + 50
+ SpringFollow on rotation {
+ source: -flickable.horizontalVelocity / 100
+ spring: 2.0; damping: 0.1
+ }
+
+ Item {
+ id: sticky
+ scale: 0.5
+ Image {
+ id: stickyImage; source: "sticky.png"; transformOrigin: Item.TopLeft
+ 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
+ MouseArea {
+ id: mouse
+ onClicked: { myText.focus = true }
+ anchors.fill: parent
+ drag.target: stickyPage; drag.axis: MouseArea.XandYAxis; drag.minimumY: 0; drag.maximumY: 500
+ drag.minimumX: 0; drag.maximumX: 400
+ }
+ }
+ }
+
+ Image {
+ source: "tack.png"; transformOrigin: Item.TopLeft
+ 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..0d1881e
--- /dev/null
+++ b/examples/declarative/velocity/velocity.qml
@@ -0,0 +1,108 @@
+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: flickable
+ anchors.fill: parent; contentWidth: 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..3c00ee6
--- /dev/null
+++ b/examples/declarative/webview/autosize.qml
@@ -0,0 +1,61 @@
+import Qt 4.6
+import org.webkit 1.0
+
+// 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..1da9219
--- /dev/null
+++ b/examples/declarative/webview/content/FieldText.qml
@@ -0,0 +1,157 @@
+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
+
+ 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: Text.AlignHCenter
+ color: fieldText.state == "editing" ? "#505050" : "#AAAAAA"
+ font.italic: true
+ font.bold: true
+ text: label
+ opacity: textEdit.text == '' ? 1 : 0
+ Behavior on opacity {
+ NumberAnimation {
+ property: "opacity"
+ duration: 250
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: cancelIcon
+ onClicked: { reset() }
+ }
+
+ MouseArea {
+ anchors.fill: confirmIcon
+ onClicked: { confirm() }
+ }
+
+ MouseArea {
+ 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/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml
new file mode 100644
index 0000000..38c42dd
--- /dev/null
+++ b/examples/declarative/webview/content/Mapping/Map.qml
@@ -0,0 +1,26 @@
+import Qt 4.6
+import org.webkit 1.0
+
+Item {
+ id: page
+ property real latitude: -34.397
+ property real longitude: 150.644
+ property string address: ""
+ property alias status: js.status
+ WebView {
+ id: map
+ anchors.fill: parent
+ url: "map.html"
+ javaScriptWindowObjects: QtObject {
+ id: js
+ WebView.windowObjectName: "qml"
+ property real lat: page.latitude
+ property real lng: page.longitude
+ property string address: page.address
+ property string status: "Loading"
+ onAddressChanged: { if (map.url != "" && map.progress==1) map.evaluateJavaScript("goToAddress()") }
+ }
+ pressGrabTime: 0
+ onLoadFinished: { evaluateJavaScript("goToAddress()"); }
+ }
+}
diff --git a/examples/declarative/webview/content/Mapping/map.html b/examples/declarative/webview/content/Mapping/map.html
new file mode 100755
index 0000000..a8726fd
--- /dev/null
+++ b/examples/declarative/webview/content/Mapping/map.html
@@ -0,0 +1,52 @@
+<html>
+<head>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+<script type="text/javascript">
+ var geocoder
+ var map
+ function goToLatLng(latlng,bounds) {
+ if (map) {
+ map.setCenter(latlng)
+ map.fitBounds(bounds)
+ } else {
+ var myOptions = {
+ zoom: 8,
+ center: latlng,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+ map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+ }
+ }
+ function initialize() {
+ geocoder = new google.maps.Geocoder();
+ if (window.qml.address) {
+ goToAddress()
+ } else {
+ goToLatLng(new google.maps.LatLng(window.qml.lat,window.qml.lng));
+ }
+ }
+ function goToAddress() {
+ if (geocoder) {
+ var req = {
+ address: window.qml.address,
+ }
+ if (map)
+ req.bounds = map.getBounds()
+ window.qml.status = "Loading";
+ geocoder.geocode(req, function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK) {
+ window.qml.status = "Ready";
+ goToLatLng(results[0].geometry.location,results[0].geometry.bounds);
+ } else {
+ window.qml.status = "Error";
+ }
+ });
+ }
+ }
+</script>
+</head>
+<body onload="initialize()" leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px">
+ <div id="map_canvas" style="width:100%; height:100%"></div>
+</body>
+</html>
diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml
new file mode 100644
index 0000000..62c0ce2
--- /dev/null
+++ b/examples/declarative/webview/content/SpinSquare.qml
@@ -0,0 +1,25 @@
+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
+ }
+ NumberAnimation on rotation {
+ from: 0
+ to: 360
+ loops: Animation.Infinite
+ 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/googleMaps.qml b/examples/declarative/webview/googleMaps.qml
new file mode 100644
index 0000000..a0926f5
--- /dev/null
+++ b/examples/declarative/webview/googleMaps.qml
@@ -0,0 +1,41 @@
+// This example demonstrates how Web services such as Google Maps can be
+// abstracted as QML types. Here we have a "Mapping" module with a "Map"
+// type. The Map type has an address property. Setting that property moves
+// the map. The underlying implementation uses WebView and the Google Maps
+// API, but users from QML don't need to understand the implementation in
+// order to create a Map.
+
+import Qt 4.6
+import org.webkit 1.0
+import "content/Mapping"
+
+Map {
+ id: map
+ width: 300
+ height: 300
+ address: "Paris"
+ Rectangle {
+ color: "white"
+ width: input.width + 20
+ height: input.height + 4
+ radius: 5
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 5
+ opacity: map.status == "Ready" ? 1 : 0
+ x: 70
+ TextInput {
+ id: input
+ text: map.address
+ anchors.centerIn: parent
+ Keys.onReturnPressed: map.address = input.text
+ }
+ }
+ Text {
+ id: loading
+ anchors.centerIn: parent
+ text: map.status == "Error" ? "Error" : "Loading"
+ opacity: map.status == "Ready" ? 0 : 1
+ font.pixelSize: 30
+ Behavior on opacity {NumberAnimation{}}
+ }
+}
diff --git a/examples/declarative/webview/inline-html.qml b/examples/declarative/webview/inline-html.qml
new file mode 100644
index 0000000..41dfec3
--- /dev/null
+++ b/examples/declarative/webview/inline-html.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+import org.webkit 1.0
+
+// 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..c62aba6
--- /dev/null
+++ b/examples/declarative/webview/newwindows.qml
@@ -0,0 +1,31 @@
+// 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
+import org.webkit 1.0
+
+Grid {
+ columns: 3
+ id: pages
+ height: 300; width: 600
+
+ Component {
+ id: webViewPage
+ Rectangle {
+ width: webView.width
+ height: webView.height
+ border.color: "gray"
+
+ WebView {
+ id: webView
+ newWindowComponent: webViewPage
+ newWindowParent: pages
+ url: "newwindows.html"
+ }
+ }
+ }
+
+ Loader { sourceComponent: webViewPage }
+}
diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml
new file mode 100644
index 0000000..5530819
--- /dev/null
+++ b/examples/declarative/webview/transparent.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+import org.webkit 1.0
+
+// 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/widgets/MyWidgets/qmldir b/examples/declarative/widgets/MyWidgets/qmldir
new file mode 100644
index 0000000..dc1d10e
--- /dev/null
+++ b/examples/declarative/widgets/MyWidgets/qmldir
@@ -0,0 +1 @@
+plugin mywidgetsplugin
diff --git a/examples/declarative/widgets/README b/examples/declarative/widgets/README
new file mode 100644
index 0000000..f85a1e8
--- /dev/null
+++ b/examples/declarative/widgets/README
@@ -0,0 +1,4 @@
+To run:
+
+ make install
+ qml mywidgets.qml
diff --git a/examples/declarative/widgets/mywidgets.cpp b/examples/declarative/widgets/mywidgets.cpp
new file mode 100644
index 0000000..e17240d
--- /dev/null
+++ b/examples/declarative/widgets/mywidgets.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtGui/QGraphicsProxyWidget>
+#include <QtGui/QPushButton>
+#include <QDebug>
+
+class MyPushButton : public QGraphicsProxyWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+
+public:
+ MyPushButton(QGraphicsItem* parent = 0)
+ : QGraphicsProxyWidget(parent)
+ {
+ widget = new QPushButton("MyPushButton");
+ widget->setAttribute(Qt::WA_NoSystemBackground);
+ setWidget(widget);
+
+ QObject::connect(widget, SIGNAL(clicked(bool)), this, SIGNAL(clicked(bool)));
+ }
+
+ QString text() const
+ {
+ return widget->text();
+ }
+
+ void setText(const QString& text)
+ {
+ if (text != widget->text()) {
+ widget->setText(text);
+ emit textChanged();
+ }
+ }
+
+Q_SIGNALS:
+ void clicked(bool);
+ void textChanged();
+
+private:
+ QPushButton *widget;
+};
+
+class MyWidgetsPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ qmlRegisterType<MyPushButton>(uri, 1, 0, "MyPushButton");
+ }
+};
+
+#include "mywidgets.moc"
+
+QML_DECLARE_TYPE(MyPushButton)
+
+Q_EXPORT_PLUGIN2(mywidgetsplugin, MyWidgetsPlugin);
diff --git a/examples/declarative/widgets/mywidgets.pro b/examples/declarative/widgets/mywidgets.pro
new file mode 100644
index 0000000..258edb1
--- /dev/null
+++ b/examples/declarative/widgets/mywidgets.pro
@@ -0,0 +1,19 @@
+TEMPLATE = lib
+DESTDIR = MyWidgets
+TARGET = mywidgetsplugin
+CONFIG += qt plugin
+QT += declarative
+VERSION = 1.0.0
+
+SOURCES += mywidgets.cpp
+
+sources.files += mywidgets.pro mywidgets.cpp mywidgets.qml
+
+sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
+
+target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
+
+INSTALLS += sources target
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+
diff --git a/examples/declarative/widgets/mywidgets.qml b/examples/declarative/widgets/mywidgets.qml
new file mode 100644
index 0000000..b1efed4
--- /dev/null
+++ b/examples/declarative/widgets/mywidgets.qml
@@ -0,0 +1,53 @@
+import Qt 4.6
+import "MyWidgets" 1.0
+
+Rectangle {
+ id: window
+ width: 640; height: 480; color: palette.window
+
+ property int margin: 30
+
+ SystemPalette { id: palette }
+
+ MyPushButton {
+ id: button1; x: margin; y: margin; text: "Right"; onClicked: window.state = "right"
+ transformOriginPoint: Qt.point(width / 2, height / 2)
+ }
+
+ MyPushButton {
+ id: button2; x: margin; y: margin + 30; text: "Bottom"; onClicked: window.state = "bottom"
+ transformOriginPoint: Qt.point(width / 2, height / 2)
+ }
+
+ MyPushButton {
+ id: button3; x: margin; y: margin + 60; text: "Quit"; onClicked: Qt.quit()
+ transformOriginPoint: Qt.point(width / 2, height / 2)
+ }
+
+ states: [
+ State {
+ name: "right"
+ PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" }
+ PropertyChanges { target: button2; x: window.width - width - margin }
+ PropertyChanges { target: button3; x: window.width - width - margin }
+ PropertyChanges { target: window; color: Qt.darker(palette.window) }
+ },
+ State {
+ name: "bottom"
+ PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 }
+ PropertyChanges {
+ target: button2; x: button1.x + button1.width + 10; y: window.height - height - margin; rotation: 180
+ text: "Top"; onClicked: window.state = ""
+ }
+ PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 }
+ PropertyChanges { target: window; color: Qt.lighter(palette.window) }
+ }
+ ]
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "x,y,rotation"; duration: 600; easing.type: "OutQuad" }
+ ColorAnimation { target: window; duration: 600 }
+ }
+ }
+}
diff --git a/examples/declarative/workerscript/workerscript.js b/examples/declarative/workerscript/workerscript.js
new file mode 100644
index 0000000..f76471f
--- /dev/null
+++ b/examples/declarative/workerscript/workerscript.js
@@ -0,0 +1,15 @@
+var lastx = 0;
+var lasty = 0;
+
+WorkerScript.onMessage = function(message) {
+ var ydiff = message.y - lasty;
+ var xdiff = message.x - lastx;
+
+ var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff);
+
+ lastx = message.x;
+ lasty = message.y;
+
+ WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} );
+}
+
diff --git a/examples/declarative/workerscript/workerscript.qml b/examples/declarative/workerscript/workerscript.qml
new file mode 100644
index 0000000..0566f1f
--- /dev/null
+++ b/examples/declarative/workerscript/workerscript.qml
@@ -0,0 +1,47 @@
+import Qt 4.6
+
+Rectangle {
+ width: 480; height: 320;
+
+ WorkerScript {
+ id: myWorker
+ source: "workerscript.js"
+
+ onMessage: {
+ print("Moved " + messageObject.xmove + " along the X axis.");
+ print("Moved " + messageObject.ymove + " along the Y axis.");
+ print("Moved " + messageObject.move + " pixels.");
+ }
+ }
+
+ Rectangle {
+ width: 200; height: 200
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ color: "red"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } );
+ }
+ }
+
+ Rectangle {
+ width: 200; height: 200
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ color: "blue"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } );
+ }
+ }
+
+ Text {
+ text: "Click a Rectangle!"
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 50
+ }
+}
diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml
new file mode 100644
index 0000000..456f309
--- /dev/null
+++ b/examples/declarative/xmldata/daringfireball.qml
@@ -0,0 +1,45 @@
+import Qt 4.6
+
+Rectangle {
+ color: "white"
+ width: 600; height: 600
+
+ 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 {
+ id: titleText
+ x: 10
+ 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: { console.log('link clicked: ' + link) }
+ }
+ }
+ }
+
+ ListView {
+ anchors.fill: parent
+ model: feedModel; delegate: feedDelegate
+ }
+}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
new file mode 100644
index 0000000..f7c269c
--- /dev/null
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -0,0 +1,79 @@
+import Qt 4.6
+
+Rectangle {
+ gradient: Gradient {
+ GradientStop { position: 0; color: "black" }
+ GradientStop { position: 1.0; color: "#AAAAAA" }
+ }
+ width: 600; height: 600
+
+ 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
+
+ MouseArea {
+ anchors.fill: wrapper
+ onPressed: delegate.ListView.view.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 {
+ id: titleText
+ x: 10; y: 5
+ text: '<a href=\'' + link + '\'>' + title + '</a>'
+ font.bold: true; font.family: "Helvetica"; font.pointSize: 14
+ onLinkActivated: { console.log('link clicked: ' + link) }
+ }
+
+ Text {
+ x: 10
+ id: descriptionText
+ 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: descriptionText; opacity: 1 }
+ }
+
+ transitions: Transition {
+ from: "*"; to: "Details"; reversible: true
+ SequentialAnimation {
+ NumberAnimation { duration: 200; properties: "height"; easing.type: "OutQuad" }
+ NumberAnimation { duration: 200; properties: "opacity" }
+ }
+ }
+ }
+ }
+ }
+
+ ListView {
+ id: list
+ x: 10; y: 10
+ width: parent.width - 20; height: parent.height - 20
+ model: feedModel
+ delegate: feedDelegate
+ }
+}
diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml
new file mode 100644
index 0000000..15ac54b
--- /dev/null
+++ b/examples/declarative/xmlhttprequest/test.qml
@@ -0,0 +1,36 @@
+import Qt 4.6
+
+Rectangle {
+ width: 800; height: 600
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+
+ var doc = new XMLHttpRequest();
+ doc.onreadystatechange = function() {
+ if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ console.log("Headers -->");
+ console.log(doc.getAllResponseHeaders ());
+ console.log("Last modified -->");
+ console.log(doc.getResponseHeader ("Last-Modified"));
+ }
+ else if (doc.readyState == XMLHttpRequest.DONE) {
+
+ var a = doc.responseXML.documentElement;
+ for (var ii = 0; ii < a.childNodes.length; ++ii) {
+ console.log(a.childNodes[ii].nodeName);
+ }
+ console.log("Headers -->");
+ console.log(doc.getAllResponseHeaders ());
+ console.log("Last modified -->");
+ console.log(doc.getResponseHeader ("Last-Modified"));
+
+ }
+ }
+
+ doc.open("GET", "test.xml");
+ doc.send();
+ }
+ }
+}
diff --git a/examples/declarative/xmlhttprequest/test.xml b/examples/declarative/xmlhttprequest/test.xml
new file mode 100644
index 0000000..8b7f1e1
--- /dev/null
+++ b/examples/declarative/xmlhttprequest/test.xml
@@ -0,0 +1,5 @@
+<data>
+ <element1 />
+ <element2 />
+</data>
+
diff --git a/examples/dialogs/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp
index 9001619..92ed334 100644
--- a/examples/dialogs/standarddialogs/dialog.cpp
+++ b/examples/dialogs/standarddialogs/dialog.cpp
@@ -239,7 +239,12 @@ void Dialog::setText()
void Dialog::setColor()
{
- QColor color = QColorDialog::getColor(Qt::green, this);
+ QColor color;
+ if (native->isChecked())
+ color = QColorDialog::getColor(Qt::green, this);
+ else
+ color = QColorDialog::getColor(Qt::green, this, "Select Color", QColorDialog::DontUseNativeDialog);
+
if (color.isValid()) {
colorLabel->setText(color.name());
colorLabel->setPalette(QPalette(color));
diff --git a/examples/draganddrop/draggabletext/dragwidget.cpp b/examples/draganddrop/draggabletext/dragwidget.cpp
index 0ada3ac..1fd40be 100644
--- a/examples/draganddrop/draggabletext/dragwidget.cpp
+++ b/examples/draganddrop/draggabletext/dragwidget.cpp
@@ -82,7 +82,7 @@ DragWidget::DragWidget(QWidget *parent)
void DragWidget::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasText()) {
- if (children().contains(event->source())) {
+ if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
event->accept();
} else {
diff --git a/examples/examples.pro b/examples/examples.pro
index 7d9aa05..b046167 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -47,17 +47,17 @@ contains(QT_CONFIG, multimedia) {
contains(QT_CONFIG, script): SUBDIRS += script
contains(QT_CONFIG, phonon):!static: SUBDIRS += phonon
-contains(QT_CONFIG, webkit): SUBDIRS += webkit
embedded:SUBDIRS += qws
!wince*:!symbian: {
- !contains(QT_EDITION, Console):contains(QT_BUILD_PARTS, tools):SUBDIRS += designer
- contains(QT_BUILD_PARTS, tools):SUBDIRS += assistant qtestlib help
+ !contains(QT_EDITION, Console):contains(QT_BUILD_PARTS, tools):SUBDIRS += designer
+ contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib help
} else {
- contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib
+ contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib
}
contains(QT_CONFIG, opengl): SUBDIRS += opengl
contains(QT_CONFIG, openvg): SUBDIRS += openvg
contains(QT_CONFIG, dbus): SUBDIRS += dbus
+contains(QT_CONFIG, declarative): SUBDIRS += declarative
win32: SUBDIRS += activeqt
contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns
contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows
diff --git a/examples/graphicsview/padnavigator/padnavigator.qrc b/examples/graphicsview/padnavigator/padnavigator.qrc
index 30ee8e1..b26ab92 100644
--- a/examples/graphicsview/padnavigator/padnavigator.qrc
+++ b/examples/graphicsview/padnavigator/padnavigator.qrc
@@ -9,6 +9,5 @@
<file>images/kopeteavailable.png</file>
<file>images/metacontact_online.png</file>
<file>images/minitools.png</file>
- <file>images/blue_angle_swirl.jpg</file>
</qresource>
</RCC>
diff --git a/examples/graphicsview/weatheranchorlayout/main.cpp b/examples/graphicsview/weatheranchorlayout/main.cpp
index aa06476..391fdd8 100644
--- a/examples/graphicsview/weatheranchorlayout/main.cpp
+++ b/examples/graphicsview/weatheranchorlayout/main.cpp
@@ -97,6 +97,8 @@ protected:
case Qt::MaximumSize:
sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
break;
+ default:
+ break;
}
return sh;
}
@@ -167,15 +169,6 @@ private:
};
-static QGraphicsProxyWidget *createItem(const QString &name = "Unnamed")
-{
- QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
- w->setWidget(new QPushButton(name));
- w->setData(0, name);
- w->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- return w;
-}
-
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(weatheranchorlayout);
diff --git a/examples/help/remotecontrol/remotecontrol.cpp b/examples/help/remotecontrol/remotecontrol.cpp
index 2492298..b51d8f7 100644
--- a/examples/help/remotecontrol/remotecontrol.cpp
+++ b/examples/help/remotecontrol/remotecontrol.cpp
@@ -123,7 +123,7 @@ void RemoteControl::sendCommand(const QString &cmd)
{
if (process->state() != QProcess::Running)
return;
- process->write(cmd.toLocal8Bit() + '\0');
+ process->write(cmd.toLocal8Bit() + '\n');
}
void RemoteControl::on_indexButton_clicked()
diff --git a/examples/help/simpletextviewer/assistant.cpp b/examples/help/simpletextviewer/assistant.cpp
index 7d779f3..3acc193 100644
--- a/examples/help/simpletextviewer/assistant.cpp
+++ b/examples/help/simpletextviewer/assistant.cpp
@@ -73,7 +73,7 @@ void Assistant::showDocumentation(const QString &page)
QByteArray ba("SetSource ");
ba.append("qthelp://com.trolltech.examples.simpletextviewer/doc/");
- proc->write(ba + page.toLocal8Bit() + '\0');
+ proc->write(ba + page.toLocal8Bit() + '\n');
}
//! [1]
diff --git a/examples/itemviews/dirview/main.cpp b/examples/itemviews/dirview/main.cpp
index f26e2f0..5f33810 100644
--- a/examples/itemviews/dirview/main.cpp
+++ b/examples/itemviews/dirview/main.cpp
@@ -45,7 +45,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QDirModel model;
+ QFileSystemModel model;
+ model.setRootPath("");
QTreeView tree;
tree.setModel(&model);
diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp
index 7c2cc30..af72385 100644
--- a/examples/multimedia/audioinput/audioinput.cpp
+++ b/examples/multimedia/audioinput/audioinput.cpp
@@ -76,7 +76,8 @@ AudioInfo::AudioInfo(const QAudioFormat &format, QObject *parent)
case QAudioFormat::SignedInt:
m_maxAmplitude = 127;
break;
- default: ;
+ default:
+ break;
}
break;
case 16:
@@ -87,9 +88,12 @@ AudioInfo::AudioInfo(const QAudioFormat &format, QObject *parent)
case QAudioFormat::SignedInt:
m_maxAmplitude = 32767;
break;
- default: ;
+ default:
+ break;
}
break;
+ default:
+ break;
}
}
diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp
new file mode 100644
index 0000000..27a296d
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearercloud.h"
+#include "cloud.h"
+
+#include <QGraphicsTextItem>
+#include <QTimer>
+#include <QDateTime>
+#include <QHostInfo>
+
+#include <QDebug>
+
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+//! [0]
+BearerCloud::BearerCloud(QObject *parent)
+: QGraphicsScene(parent), timerId(0)
+{
+ setSceneRect(-300, -300, 600, 600);
+
+ qsrand(QDateTime::currentDateTime().toTime_t());
+
+ offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX;
+ offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6;
+ offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6;
+ offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6;
+
+ thisDevice = new QGraphicsTextItem(QHostInfo::localHostName());
+ thisDevice->setData(0, QLatin1String("This Device"));
+ thisDevice->setPos(thisDevice->boundingRect().width() / -2,
+ thisDevice->boundingRect().height() / -2);
+ addItem(thisDevice);
+
+ qreal radius = Cloud::getRadiusForState(QNetworkConfiguration::Active);
+ QGraphicsEllipseItem *orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::green));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Discovered);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::blue));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Defined);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::darkGray));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Undefined);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::lightGray));
+ addItem(orbit);
+
+ connect(&manager, SIGNAL(configurationAdded(QNetworkConfiguration)),
+ this, SLOT(configurationAdded(QNetworkConfiguration)));
+ connect(&manager, SIGNAL(configurationRemoved(QNetworkConfiguration)),
+ this, SLOT(configurationRemoved(QNetworkConfiguration)));
+ connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)),
+ this, SLOT(configurationChanged(QNetworkConfiguration)));
+
+ QTimer::singleShot(0, this, SLOT(updateConfigurations()));
+}
+//! [0]
+
+BearerCloud::~BearerCloud()
+{
+}
+
+void BearerCloud::cloudMoved()
+{
+ if (!timerId)
+ timerId = startTimer(1000 / 25);
+}
+
+void BearerCloud::timerEvent(QTimerEvent *)
+{
+ QList<Cloud *> clouds;
+ foreach (QGraphicsItem *item, items()) {
+ if (Cloud *cloud = qgraphicsitem_cast<Cloud *>(item))
+ clouds << cloud;
+ }
+
+ foreach (Cloud *cloud, clouds)
+ cloud->calculateForces();
+
+ bool cloudsMoved = false;
+ foreach (Cloud *cloud, clouds)
+ cloudsMoved |= cloud->advance();
+
+ if (!cloudsMoved) {
+ killTimer(timerId);
+ timerId = 0;
+ }
+}
+
+//! [2]
+void BearerCloud::configurationAdded(const QNetworkConfiguration &config)
+{
+ const QNetworkConfiguration::StateFlags state = config.state();
+
+ configStates.insert(state, config.identifier());
+
+ const qreal radius = Cloud::getRadiusForState(state);
+ const int count = configStates.count(state);
+ const qreal angle = 2 * M_PI / count;
+
+ Cloud *item = new Cloud(config);
+ configurations.insert(config.identifier(), item);
+
+ item->setPos(radius * cos((count-1) * angle + offset[state]),
+ radius * sin((count-1) * angle + offset[state]));
+
+ addItem(item);
+
+ cloudMoved();
+}
+//! [2]
+
+//! [3]
+void BearerCloud::configurationRemoved(const QNetworkConfiguration &config)
+{
+ foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys())
+ configStates.remove(state, config.identifier());
+
+ Cloud *item = configurations.take(config.identifier());
+
+ item->setFinalScale(0.0);
+ item->setDeleteAfterAnimation(true);
+
+ cloudMoved();
+}
+//! [3]
+
+//! [4]
+void BearerCloud::configurationChanged(const QNetworkConfiguration &config)
+{
+ foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys())
+ configStates.remove(state, config.identifier());
+
+ configStates.insert(config.state(), config.identifier());
+
+ cloudMoved();
+}
+//! [4]
+
+//! [1]
+void BearerCloud::updateConfigurations()
+{
+ QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
+
+ while (!allConfigurations.isEmpty())
+ configurationAdded(allConfigurations.takeFirst());
+
+ cloudMoved();
+}
+//! [1]
+
diff --git a/examples/network/bearercloud/bearercloud.h b/examples/network/bearercloud/bearercloud.h
new file mode 100644
index 0000000..09de4c6
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QNetworkConfigurationManager>
+
+#include <QGraphicsScene>
+#include <QMap>
+#include <QHash>
+
+QT_USE_NAMESPACE
+
+class Cloud;
+
+class BearerCloud : public QGraphicsScene
+{
+ Q_OBJECT
+
+public:
+ BearerCloud(QObject *parent = 0);
+ ~BearerCloud();
+
+ void cloudMoved();
+
+ void timerEvent(QTimerEvent *event);
+
+private Q_SLOTS:
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
+ void updateConfigurations();
+
+private:
+ QNetworkConfigurationManager manager;
+
+ QGraphicsTextItem *thisDevice;
+ QHash<QString, Cloud *> configurations;
+
+ QMap<QNetworkConfiguration::StateFlags, qreal> offset;
+ QMultiMap<QNetworkConfiguration::StateFlags, QString> configStates;
+
+ int timerId;
+};
+
diff --git a/examples/network/bearercloud/bearercloud.pro b/examples/network/bearercloud/bearercloud.pro
new file mode 100644
index 0000000..c07626a
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.pro
@@ -0,0 +1,16 @@
+HEADERS = bearercloud.h \
+ cloud.h
+
+SOURCES = main.cpp \
+ bearercloud.cpp \
+ cloud.cpp
+
+RESOURCES = icons.qrc
+
+TARGET = bearercloud
+
+QT = core gui network svg
+
+CONFIG += console
+
+symbian:TARGET.CAPABILITY = NetworkServices ReadUserData
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
new file mode 100644
index 0000000..d041034
--- /dev/null
+++ b/examples/network/bearercloud/cloud.cpp
@@ -0,0 +1,363 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cloud.h"
+#include "bearercloud.h"
+
+#include <qnetworksession.h>
+
+#include <QGraphicsTextItem>
+#include <QGraphicsSvgItem>
+#include <QGraphicsSceneMouseEvent>
+#include <QSvgRenderer>
+#include <QPainter>
+
+#include <QDebug>
+
+#include <math.h>
+
+static QMap<QString, QSvgRenderer *> svgCache;
+
+//! [0]
+Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent)
+: QGraphicsItem(parent), configuration(config), deleteAfterAnimation(false)
+{
+ session = new QNetworkSession(configuration, this);
+ connect(session, SIGNAL(newConfigurationActivated()),
+ this, SLOT(newConfigurationActivated()));
+ connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
+ this, SLOT(stateChanged(QNetworkSession::State)));
+
+ setFlag(ItemIsMovable);
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
+ setFlag(ItemSendsGeometryChanges);
+#endif
+ setZValue(1);
+
+ icon = new QGraphicsSvgItem(this);
+ text = new QGraphicsTextItem(this);
+
+ currentScale = 0;
+ finalScale = 1;
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ setOpacity(0);
+
+ newConfigurationActivated();
+}
+//! [0]
+
+Cloud::~Cloud()
+{
+}
+
+void Cloud::setFinalScale(qreal factor)
+{
+ finalScale = factor;
+}
+
+void Cloud::setDeleteAfterAnimation(bool deleteAfter)
+{
+ deleteAfterAnimation = deleteAfter;
+}
+
+void Cloud::calculateForces()
+{
+ if (!scene() || scene()->mouseGrabberItem() == this) {
+ newPos = pos();
+ return;
+ }
+
+ // sum up all the forces push this item away
+ qreal xvel = 0;
+ qreal yvel = 0;
+ QLineF orbitForce;
+ foreach (QGraphicsItem *item, scene()->items()) {
+ // other clouds
+ Cloud *cloud = qgraphicsitem_cast<Cloud *>(item);
+ if (!cloud && item->data(0) != QLatin1String("This Device"))
+ continue;
+
+ qreal factor = 1.0;
+
+ QLineF line(cloud ? item->mapToScene(0, 0) : QPointF(0, 0), mapToScene(0, 0));
+ if (item->data(0) == QLatin1String("This Device"))
+ orbitForce = line;
+
+ if (cloud)
+ factor = cloud->currentScale;
+
+ qreal dx = line.dx();
+ qreal dy = line.dy();
+ double l = 2.0 * (dx * dx + dy * dy);
+ if (l > 0) {
+ xvel += factor * dx * 200.0 / l;
+ yvel += factor * dy * 200.0 / l;
+ }
+ }
+
+ // tendency to stay at a fixed orbit
+ qreal orbit = getRadiusForState(configuration.state());
+ qreal distance = orbitForce.length();
+
+ QLineF unit = orbitForce.unitVector();
+
+ orbitForce.setLength(xvel * unit.dx() + yvel * unit.dy());
+
+ qreal w = 2 - exp(-pow(distance-orbit, 2)/(2 * 50));
+
+ if (distance < orbit) {
+ xvel += orbitForce.dx() * w;
+ yvel += orbitForce.dy() * w;
+ } else {
+ xvel -= orbitForce.dx() * w;
+ yvel -= orbitForce.dy() * w;
+ }
+
+ if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
+ xvel = yvel = 0;
+
+ QRectF sceneRect = scene()->sceneRect();
+ newPos = pos() + QPointF(xvel, yvel);
+ newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
+ newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
+}
+
+bool Cloud::advance()
+{
+ static const qreal scaleDelta = 0.01;
+
+ bool animated = false;
+
+ if (currentScale < finalScale) {
+ animated = true;
+ currentScale = qMin<qreal>(currentScale + scaleDelta, finalScale);
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ } else if (currentScale > finalScale) {
+ animated = true;
+ currentScale = qMax<qreal>(currentScale - scaleDelta, finalScale);
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ }
+
+ if (newPos != pos()) {
+ setPos(newPos);
+ animated = true;
+ }
+
+ if (opacity() != finalOpacity) {
+ animated = true;
+ if (qAbs(finalScale - currentScale) > 0.0) {
+ // use scale as reference
+ setOpacity(opacity() + scaleDelta * (finalOpacity - opacity()) /
+ qAbs(finalScale - currentScale));
+ } else {
+ setOpacity(finalOpacity);
+ }
+ }
+
+ if (!animated && deleteAfterAnimation)
+ deleteLater();
+
+ return animated;
+}
+
+QRectF Cloud::boundingRect() const
+{
+ return childrenBoundingRect();
+}
+
+void Cloud::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+//! [4]
+QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ switch (change) {
+ case ItemPositionHasChanged:
+ if (BearerCloud *bearercloud = qobject_cast<BearerCloud *>(scene()))
+ bearercloud->cloudMoved();
+ default:
+ ;
+ };
+
+ return QGraphicsItem::itemChange(change, value);
+}
+//! [4]
+
+//! [3]
+void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ if (session->isOpen())
+ session->close();
+ else
+ session->open();
+
+ event->accept();
+ }
+}
+//! [3]
+
+//! [2]
+void Cloud::stateChanged(QNetworkSession::State state)
+{
+ if (configuration.name().isEmpty())
+ finalOpacity = qreal(0.1);
+ else if (session->state() == QNetworkSession::NotAvailable)
+ finalOpacity = 0.5;
+ else
+ finalOpacity = 1.0;
+
+ QString tooltip;
+
+ if (configuration.name().isEmpty())
+ tooltip += tr("<b>HIDDEN NETWORK</b><br>");
+ else
+ tooltip += tr("<b>%1</b><br>").arg(configuration.name());
+
+#ifndef QT_NO_NETWORKINTERFACE
+ const QNetworkInterface interface = session->interface();
+ if (interface.isValid())
+ tooltip += tr("<br>Interface: %1").arg(interface.humanReadableName());
+ tooltip += tr("<br>Id: %1").arg(configuration.identifier());
+#endif
+
+ const QString bearerName = configuration.bearerName();
+ if (!bearerName.isEmpty())
+ tooltip += tr("<br>Bearer: %1").arg(bearerName);
+
+ QString s = tr("<br>State: %1 (%2)");
+ switch (state) {
+ case QNetworkSession::Invalid:
+ s = s.arg(tr("Invalid"));
+ break;
+ case QNetworkSession::NotAvailable:
+ s = s.arg(tr("Not Available"));
+ break;
+ case QNetworkSession::Connecting:
+ s = s.arg(tr("Connecting"));
+ break;
+ case QNetworkSession::Connected:
+ s = s.arg(tr("Connected"));
+ break;
+ case QNetworkSession::Closing:
+ s = s.arg(tr("Closing"));
+ break;
+ case QNetworkSession::Disconnected:
+ s = s.arg(tr("Disconnected"));
+ break;
+ case QNetworkSession::Roaming:
+ s = s.arg(tr("Roaming"));
+ break;
+ default:
+ s = s.arg(tr("Unknown"));
+ }
+
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
+ else
+ s = s.arg(tr("Closed"));
+
+ tooltip += s;
+
+ tooltip += tr("<br><br>Active time: %1 seconds").arg(session->activeTime());
+ tooltip += tr("<br>Received data: %1 bytes").arg(session->bytesReceived());
+ tooltip += tr("<br>Sent data: %1 bytes").arg(session->bytesWritten());
+
+ setToolTip(tooltip);
+}
+//! [2]
+
+//! [1]
+void Cloud::newConfigurationActivated()
+{
+ const QString bearerName = configuration.bearerName();
+ if (!svgCache.contains(bearerName)) {
+ if (bearerName == QLatin1String("WLAN"))
+ svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":wlan.svg")));
+ else if (bearerName == QLatin1String("Ethernet"))
+ svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":lan.svg")));
+ else
+ svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":unknown.svg")));
+ }
+
+ icon->setSharedRenderer(svgCache[bearerName]);
+
+ if (configuration.name().isEmpty()) {
+ text->setPlainText(tr("HIDDEN NETWORK"));
+ } else {
+ if (configuration.type() == QNetworkConfiguration::ServiceNetwork)
+ text->setHtml("<b>" + configuration.name() + "</b>");
+ else
+ text->setPlainText(configuration.name());
+ }
+
+ const qreal height = icon->boundingRect().height() + text->boundingRect().height();
+
+ icon->setPos(icon->boundingRect().width() / -2, height / -2);
+
+ text->setPos(text->boundingRect().width() / -2,
+ height / 2 - text->boundingRect().height());
+
+ stateChanged(session->state());
+}
+//! [1]
+
+qreal Cloud::getRadiusForState(QNetworkConfiguration::StateFlags state)
+{
+ switch (state) {
+ case QNetworkConfiguration::Active:
+ return 100;
+ break;
+ case QNetworkConfiguration::Discovered:
+ return 150;
+ break;
+ case QNetworkConfiguration::Defined:
+ return 200;
+ break;
+ case QNetworkConfiguration::Undefined:
+ return 250;
+ break;
+ default:
+ return 300;
+ }
+}
+
diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h
new file mode 100644
index 0000000..9e25fb6
--- /dev/null
+++ b/examples/network/bearercloud/cloud.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+
+#include <QGraphicsItem>
+QT_USE_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+class QGraphicsTextItem;
+class QGraphicsSvgItem;
+QT_END_NAMESPACE
+
+class Cloud : public QObject, public QGraphicsItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem)
+
+public:
+ explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
+ ~Cloud();
+
+ enum { Type = UserType + 1 };
+ int type() const { return Type; }
+
+ void setFinalScale(qreal factor);
+ void setDeleteAfterAnimation(bool deleteAfter);
+
+ void calculateForces();
+
+ bool advance();
+ QRectF boundingRect() const;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ static qreal getRadiusForState(QNetworkConfiguration::StateFlags state);
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+
+private Q_SLOTS:
+ void stateChanged(QNetworkSession::State state);
+ void newConfigurationActivated();
+
+private:
+ QNetworkConfiguration configuration;
+ QNetworkSession *session;
+
+ QGraphicsTextItem *text;
+ QGraphicsSvgItem *icon;
+
+ qreal finalOpacity;
+ qreal finalScale;
+ qreal currentScale;
+
+ QPointF newPos;
+
+ bool deleteAfterAnimation;
+};
+
diff --git a/examples/network/bearercloud/icons.qrc b/examples/network/bearercloud/icons.qrc
new file mode 100644
index 0000000..84a8939
--- /dev/null
+++ b/examples/network/bearercloud/icons.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>wlan.svg</file>
+ <file>lan.svg</file>
+ <file>unknown.svg</file>
+</qresource>
+</RCC>
diff --git a/examples/network/bearercloud/lan.svg b/examples/network/bearercloud/lan.svg
new file mode 100644
index 0000000..3cce805
--- /dev/null
+++ b/examples/network/bearercloud/lan.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25.000002"
+ height="9.6406126"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="lan.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="15.244635"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1459"
+ inkscape:window-height="964"
+ inkscape:window-x="453"
+ inkscape:window-y="166" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-4.0978193e-8,-19.359387)">
+ <text
+ xml:space="preserve"
+ style="font-size:13.99289513px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="-1.1205248"
+ y="29"
+ id="text3239"><tspan
+ sodipodi:role="line"
+ id="tspan3241"
+ x="-1.1205248"
+ y="29">LAN</tspan></text>
+ </g>
+</svg>
diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp
new file mode 100644
index 0000000..86ef46f
--- /dev/null
+++ b/examples/network/bearercloud/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearercloud.h"
+
+#include <QApplication>
+#include <QGraphicsView>
+
+class CloudView : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ CloudView(QGraphicsScene *scene);
+ ~CloudView() { }
+
+protected:
+ void resizeEvent(QResizeEvent *) {
+ fitInView(sceneRect(), Qt::KeepAspectRatio);
+ }
+#ifdef Q_OS_WINCE
+ void hideEvent(QHideEvent *) {
+ qApp->quit();
+ }
+#endif
+};
+
+CloudView::CloudView(QGraphicsScene *scene)
+: QGraphicsView(scene)
+{
+ setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing |
+ QPainter::SmoothPixmapTransform);
+#if defined (Q_OS_SYMBIAN) || defined (Q_OS_WINCE)
+ setWindowState(Qt::WindowMaximized);
+#endif
+}
+
+#include "main.moc"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ BearerCloud bearerCloud;
+
+ CloudView view(&bearerCloud);
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/network/bearercloud/unknown.svg b/examples/network/bearercloud/unknown.svg
new file mode 100644
index 0000000..fd10298
--- /dev/null
+++ b/examples/network/bearercloud/unknown.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="9.0681238"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="unknown.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="15.244635"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1459"
+ inkscape:window-height="964"
+ inkscape:window-x="453"
+ inkscape:window-y="166" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-6.891787e-8,-19.931876)">
+ <text
+ xml:space="preserve"
+ style="font-size:13.16195393px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="-1.0539845"
+ y="29"
+ id="text3239"><tspan
+ sodipodi:role="line"
+ id="tspan3241"
+ x="-1.0539845"
+ y="29">NET</tspan></text>
+ </g>
+</svg>
diff --git a/examples/network/bearercloud/wlan.svg b/examples/network/bearercloud/wlan.svg
new file mode 100644
index 0000000..8b86089
--- /dev/null
+++ b/examples/network/bearercloud/wlan.svg
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="27"
+ height="29"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="wlan.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="23.665236"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1912"
+ inkscape:window-height="1130"
+ inkscape:window-x="0"
+ inkscape:window-y="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g6334"
+ transform="translate(1.0000001,0)">
+ <path
+ id="path2393"
+ d="M 12.500248,9.499893 L 12.500248,28.500095"
+ style="fill:none;fill-rule:evenodd;stroke:#3bb3ff;stroke-width:0.99981093;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(1.0216765,0,0,1.0324764,0.4493163,-22.692096)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3171"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(1.6055152,0,0,1.6224868,-7.5798083,-40.80263)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3175"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(2.4812855,0,0,2.5075146,-17.62358,-67.968804)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3177"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-1.0216765,0,0,1.0324764,24.550388,-22.692096)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3179"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-1.6055152,0,0,1.6224868,32.580246,-40.80263)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3181"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-2.4812855,0,0,2.5075146,42.623143,-67.968804)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3183"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ </g>
+ </g>
+</svg>
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp
new file mode 100644
index 0000000..5b2bad1
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor.cpp
@@ -0,0 +1,395 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearermonitor.h"
+#include "sessionwidget.h"
+
+#include <QDebug>
+
+#ifdef Q_OS_WIN
+#include <winsock2.h>
+#undef interface
+
+#ifndef NS_NLA
+#define NS_NLA 15
+#endif
+#endif
+
+BearerMonitor::BearerMonitor(QWidget *parent)
+: QWidget(parent)
+{
+ setupUi(this);
+ delete tabWidget->currentWidget();
+ sessionGroup->hide();
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+ setWindowState(Qt::WindowMaximized);
+#endif
+ updateConfigurations();
+
+ onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty());
+
+ QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration();
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = treeWidget->topLevelItem(i);
+
+ if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) {
+ treeWidget->setCurrentItem(item);
+ showConfigurationFor(item);
+ break;
+ }
+ }
+
+ connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)),
+ this, SLOT(configurationAdded(const QNetworkConfiguration&)));
+ connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)),
+ this, SLOT(configurationRemoved(const QNetworkConfiguration&)));
+ connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)),
+ this, SLOT(configurationChanged(const QNetworkConfiguration)));
+ connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations()));
+ connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool)));
+
+#ifdef Q_OS_WIN
+ connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork()));
+ connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork()));
+#else
+ nlaGroup->hide();
+#endif
+
+ connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
+ this, SLOT(createSessionFor(QTreeWidgetItem*)));
+
+ connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
+ this, SLOT(showConfigurationFor(QTreeWidgetItem*)));
+
+ connect(newSessionButton, SIGNAL(clicked()),
+ this, SLOT(createNewSession()));
+ connect(deleteSessionButton, SIGNAL(clicked()),
+ this, SLOT(deleteSession()));
+
+ connect(scanButton, SIGNAL(clicked()),
+ this, SLOT(performScan()));
+}
+
+BearerMonitor::~BearerMonitor()
+{
+}
+
+static void updateItem(QTreeWidgetItem *item, const QNetworkConfiguration &config)
+{
+ item->setText(0, config.name());
+ item->setData(0, Qt::UserRole, config.identifier());
+
+ QFont font = item->font(1);
+ font.setBold((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active);
+ item->setFont(0, font);
+}
+
+void BearerMonitor::configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent)
+{
+ QTreeWidgetItem *item = new QTreeWidgetItem;
+ updateItem(item, config);
+
+ if (parent)
+ parent->addChild(item);
+ else
+ treeWidget->addTopLevelItem(item);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork) {
+ foreach (const QNetworkConfiguration &child, config.children())
+ configurationAdded(child, item);
+ }
+}
+
+void BearerMonitor::configurationRemoved(const QNetworkConfiguration &config)
+{
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = treeWidget->topLevelItem(i);
+
+ if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
+ delete item;
+ break;
+ }
+ }
+}
+
+void BearerMonitor::configurationChanged(const QNetworkConfiguration &config)
+{
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = treeWidget->topLevelItem(i);
+
+ if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
+ updateItem(item, config);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork)
+ updateSnapConfiguration(item, config);
+
+ if (item == treeWidget->currentItem())
+ showConfigurationFor(item);
+
+ break;
+ }
+ }
+}
+
+void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap)
+{
+ QMap<QString, QTreeWidgetItem *> itemMap;
+ for (int i = 0; i < parent->childCount(); ++i) {
+ QTreeWidgetItem *item = parent->child(i);
+ itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
+ }
+
+ QList<QNetworkConfiguration> allConfigurations = snap.children();
+
+ while (!allConfigurations.isEmpty()) {
+ QNetworkConfiguration config = allConfigurations.takeFirst();
+
+ QTreeWidgetItem *item = itemMap.take(config.identifier());
+ if (item) {
+ updateItem(item, config);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork)
+ updateSnapConfiguration(item, config);
+ } else {
+ configurationAdded(config, parent);
+ }
+ }
+
+ foreach (const QString &id, itemMap.keys())
+ delete itemMap.value(id);
+
+ itemMap.clear();
+}
+
+void BearerMonitor::updateConfigurations()
+{
+ progressBar->hide();
+ scanButton->show();
+
+ QList<QTreeWidgetItem *> items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard);
+ QMap<QString, QTreeWidgetItem *> itemMap;
+ while (!items.isEmpty()) {
+ QTreeWidgetItem *item = items.takeFirst();
+ itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
+ }
+
+ QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
+
+ while (!allConfigurations.isEmpty()) {
+ QNetworkConfiguration config = allConfigurations.takeFirst();
+
+ QTreeWidgetItem *item = itemMap.take(config.identifier());
+ if (item) {
+ updateItem(item, config);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork)
+ updateSnapConfiguration(item, config);
+ } else {
+ configurationAdded(config);
+ }
+ }
+
+ foreach (const QString &id, itemMap.keys())
+ delete itemMap.value(id);
+}
+
+void BearerMonitor::onlineStateChanged(bool isOnline)
+{
+ if (isOnline)
+ onlineState->setText(tr("Online"));
+ else
+ onlineState->setText(tr("Offline"));
+}
+
+#ifdef Q_OS_WIN
+void BearerMonitor::registerNetwork()
+{
+ QTreeWidgetItem *item = treeWidget->currentItem();
+
+ QNetworkConfiguration configuration =
+ manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
+
+ const QString name = configuration.name();
+
+ qDebug() << "Registering" << name << "with system";
+
+ WSAQUERYSET networkInfo;
+ memset(&networkInfo, 0, sizeof(networkInfo));
+ networkInfo.dwSize = sizeof(networkInfo);
+ networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
+ networkInfo.dwNameSpace = NS_NLA;
+
+ if (WSASetService(&networkInfo, RNRSERVICE_REGISTER, 0) == SOCKET_ERROR)
+ qDebug() << "WSASetService(RNRSERVICE_REGISTER) returned" << WSAGetLastError();
+}
+
+void BearerMonitor::unregisterNetwork()
+{
+ QTreeWidgetItem *item = treeWidget->currentItem();
+
+ QNetworkConfiguration configuration =
+ manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
+
+ const QString name = configuration.name();
+
+ qDebug() << "Unregistering" << name << "with system";
+
+ WSAQUERYSET networkInfo;
+ memset(&networkInfo, 0, sizeof(networkInfo));
+ networkInfo.dwSize = sizeof(networkInfo);
+ networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
+ networkInfo.dwNameSpace = NS_NLA;
+
+ if (WSASetService(&networkInfo, RNRSERVICE_DELETE, 0) == SOCKET_ERROR)
+ qDebug() << "WSASetService(RNRSERVICE_DELETE) returned" << WSAGetLastError();
+}
+#endif
+
+void BearerMonitor::showConfigurationFor(QTreeWidgetItem *item)
+{
+ QString identifier;
+
+ if (item)
+ identifier = item->data(0, Qt::UserRole).toString();
+
+ QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
+
+ switch (conf.state()) {
+ case QNetworkConfiguration::Active:
+ configurationState->setText(tr("Active"));
+ break;
+ case QNetworkConfiguration::Discovered:
+ configurationState->setText(tr("Discovered"));
+ break;
+ case QNetworkConfiguration::Defined:
+ configurationState->setText(tr("Defined"));
+ break;
+ case QNetworkConfiguration::Undefined:
+ configurationState->setText(tr("Undefined"));
+ break;
+ default:
+ configurationState->setText(QString());
+ }
+
+ switch (conf.type()) {
+ case QNetworkConfiguration::InternetAccessPoint:
+ configurationType->setText(tr("Internet Access Point"));
+ break;
+ case QNetworkConfiguration::ServiceNetwork:
+ configurationType->setText(tr("Service Network"));
+ break;
+ case QNetworkConfiguration::UserChoice:
+ configurationType->setText(tr("User Choice"));
+ break;
+ case QNetworkConfiguration::Invalid:
+ configurationType->setText(tr("Invalid"));
+ break;
+ default:
+ configurationType->setText(QString());
+ }
+
+ switch (conf.purpose()) {
+ case QNetworkConfiguration::UnknownPurpose:
+ configurationPurpose->setText(tr("Unknown"));
+ break;
+ case QNetworkConfiguration::PublicPurpose:
+ configurationPurpose->setText(tr("Public"));
+ break;
+ case QNetworkConfiguration::PrivatePurpose:
+ configurationPurpose->setText(tr("Private"));
+ break;
+ case QNetworkConfiguration::ServiceSpecificPurpose:
+ configurationPurpose->setText(tr("Service Specific"));
+ break;
+ default:
+ configurationPurpose->setText(QString());
+ }
+
+ configurationIdentifier->setText(conf.identifier());
+
+ configurationRoaming->setText(conf.isRoamingAvailable() ? tr("Available") : tr("Not available"));
+
+ configurationChildren->setText(QString::number(conf.children().count()));
+
+ configurationName->setText(conf.name());
+}
+
+void BearerMonitor::createSessionFor(QTreeWidgetItem *item)
+{
+ const QString identifier = item->data(0, Qt::UserRole).toString();
+
+ QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
+
+ SessionWidget *session = new SessionWidget(conf);
+
+ tabWidget->addTab(session, conf.name());
+
+ sessionGroup->show();
+
+ sessionWidgets.append(session);
+}
+
+void BearerMonitor::createNewSession()
+{
+ QTreeWidgetItem *item = treeWidget->currentItem();
+
+ createSessionFor(item);
+}
+
+void BearerMonitor::deleteSession()
+{
+ SessionWidget *session = qobject_cast<SessionWidget *>(tabWidget->currentWidget());
+ if (session) {
+ sessionWidgets.removeAll(session);
+
+ delete session;
+
+ if (tabWidget->count() == 0)
+ sessionGroup->hide();
+ }
+}
+
+void BearerMonitor::performScan()
+{
+ scanButton->hide();
+ progressBar->show();
+ manager.updateConfigurations();
+}
diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h
new file mode 100644
index 0000000..d7025dd
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BEARERMONITOR_H
+#define BEARERMONITOR_H
+
+#include <qnetworkconfigmanager.h>
+#include <qnetworksession.h>
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#include "ui_bearermonitor_240_320.h"
+#else
+#include "ui_bearermonitor_640_480.h"
+#endif
+
+QT_USE_NAMESPACE
+
+class SessionWidget;
+
+class BearerMonitor : public QWidget, public Ui_BearerMonitor
+{
+ Q_OBJECT
+
+public:
+ BearerMonitor(QWidget *parent = 0);
+ ~BearerMonitor();
+
+private slots:
+ void configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent = 0);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
+ void updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap);
+ void updateConfigurations();
+
+ void onlineStateChanged(bool isOnline);
+
+#ifdef Q_OS_WIN
+ void registerNetwork();
+ void unregisterNetwork();
+#endif
+
+ void showConfigurationFor(QTreeWidgetItem *item);
+
+ void createSessionFor(QTreeWidgetItem *item);
+ void createNewSession();
+ void deleteSession();
+
+ void performScan();
+
+private:
+ QNetworkConfigurationManager manager;
+ QList<SessionWidget *> sessionWidgets;
+};
+
+#endif //BEARERMONITOR_H
diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro
new file mode 100644
index 0000000..4b86187
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor.pro
@@ -0,0 +1,26 @@
+HEADERS = sessionwidget.h \
+ bearermonitor.h
+
+SOURCES = main.cpp \
+ bearermonitor.cpp \
+ sessionwidget.cpp
+
+FORMS = bearermonitor_240_320.ui \
+ bearermonitor_640_480.ui \
+ sessionwidget.ui
+
+TARGET = bearermonitor
+
+QT = core gui network
+
+win32 {
+ !wince* {
+ LIBS += -lWs2_32
+ } else {
+ LIBS += -lWs2
+ }
+}
+
+CONFIG += console
+
+symbian:TARGET.CAPABILITY = NetworkServices ReadUserData
diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui
new file mode 100644
index 0000000..ce9c2d1
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor_240_320.ui
@@ -0,0 +1,420 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BearerMonitor</class>
+ <widget class="QWidget" name="BearerMonitor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>240</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>-274</y>
+ <width>206</width>
+ <height>576</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="systemState">
+ <property name="title">
+ <string>System State</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="onlineStateLayout">
+ <item>
+ <widget class="QLabel" name="onlineStateLabel">
+ <property name="text">
+ <string>Online State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="onlineState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Configurations</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="configurationNameLayout">
+ <item>
+ <widget class="QLabel" name="configurationNameLabel">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationStateLayout">
+ <item>
+ <widget class="QLabel" name="configurationStateLabel">
+ <property name="text">
+ <string>State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationTypeLayout">
+ <item>
+ <widget class="QLabel" name="configurationTypeLabel">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Invalid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationPurposeLayout">
+ <item>
+ <widget class="QLabel" name="configurationPurposeLabel">
+ <property name="text">
+ <string>Purpose:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationPurpose">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Unknown</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationIdentifierLayout">
+ <item>
+ <widget class="QLabel" name="configurationIdentifierLabel">
+ <property name="text">
+ <string>Identifier:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationIdentifier">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationRoamingLayout">
+ <item>
+ <widget class="QLabel" name="configurationRoamingLabel">
+ <property name="text">
+ <string>Roaming:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationRoaming">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationChildrenLayout">
+ <item>
+ <widget class="QLabel" name="configurationChildrenLabel">
+ <property name="text">
+ <string>Children:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationChildren">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="nlaGroup">
+ <property name="title">
+ <string>Network Location Awareness</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="registerButton">
+ <property name="text">
+ <string>Register</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="unregisterButton">
+ <property name="text">
+ <string>Unregister</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="newSessionButton">
+ <property name="text">
+ <string>New Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deleteSessionButton">
+ <property name="text">
+ <string>Delete Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="scanButton">
+ <property name="text">
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ <property name="format">
+ <string>%p%</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="sessionGroup">
+ <property name="title">
+ <string>Sessions</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Session 1</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui
new file mode 100644
index 0000000..941eaa0
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor_640_480.ui
@@ -0,0 +1,386 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BearerMonitor</class>
+ <widget class="QWidget" name="BearerMonitor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>640</width>
+ <height>515</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="systemState">
+ <property name="title">
+ <string>System State</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="onlineStateLayout">
+ <item>
+ <widget class="QLabel" name="onlineStateLabel">
+ <property name="text">
+ <string>Online State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="onlineState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Configurations</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="configurationNameLayout">
+ <item>
+ <widget class="QLabel" name="configurationNameLabel">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationStateLayout">
+ <item>
+ <widget class="QLabel" name="configurationStateLabel">
+ <property name="text">
+ <string>State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationTypeLayout">
+ <item>
+ <widget class="QLabel" name="configurationTypeLabel">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Invalid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationPurposeLayout">
+ <item>
+ <widget class="QLabel" name="configurationPurposeLabel">
+ <property name="text">
+ <string>Purpose:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationPurpose">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Unknown</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationIdentifierLayout">
+ <item>
+ <widget class="QLabel" name="configurationIdentifierLabel">
+ <property name="text">
+ <string>Identifier:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationIdentifier">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationRoamingLayout">
+ <item>
+ <widget class="QLabel" name="configurationRoamingLabel">
+ <property name="text">
+ <string>Roaming:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationRoaming">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationChildrenLayout">
+ <item>
+ <widget class="QLabel" name="configurationChildrenLabel">
+ <property name="text">
+ <string>Children:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationChildren">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="nlaGroup">
+ <property name="title">
+ <string>Network Location Awareness</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="registerButton">
+ <property name="text">
+ <string>Register</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="unregisterButton">
+ <property name="text">
+ <string>Unregister</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="newSessionButton">
+ <property name="text">
+ <string>New Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deleteSessionButton">
+ <property name="text">
+ <string>Delete Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="scanButton">
+ <property name="text">
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ <property name="format">
+ <string>%p%</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="sessionGroup">
+ <property name="title">
+ <string>Sessions</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Session 1</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/assistant/simpletextviewer/main.cpp b/examples/network/bearermonitor/main.cpp
index 6e38406..b7ac4fe 100644
--- a/examples/assistant/simpletextviewer/main.cpp
+++ b/examples/network/bearermonitor/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -41,12 +41,15 @@
#include <QApplication>
-#include "mainwindow.h"
+#include "bearermonitor.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- MainWindow window;
- window.show();
+
+ BearerMonitor monitor;
+ monitor.show();
+
return app.exec();
}
+
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp
new file mode 100644
index 0000000..655c1ac
--- /dev/null
+++ b/examples/network/bearermonitor/sessionwidget.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sessionwidget.h"
+#include "qnetworkconfigmanager.h"
+
+SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent)
+: QWidget(parent), statsTimer(-1)
+{
+ setupUi(this);
+
+#ifdef QT_NO_NETWORKINTERFACE
+ interfaceName->setVisible(false);
+ interfaceNameLabel->setVisible(false);
+ interfaceGuid->setVisible(false);
+ interfaceGuidLabel->setVisible(false);
+#endif
+
+ session = new QNetworkSession(config, this);
+
+ connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
+ this, SLOT(updateSession()));
+ connect(session, SIGNAL(error(QNetworkSession::SessionError)),
+ this, SLOT(updateSession()));
+
+ updateSession();
+
+ sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0')));
+
+ configuration->setText(session->configuration().name());
+
+ connect(openSessionButton, SIGNAL(clicked()),
+ this, SLOT(openSession()));
+ connect(openSyncSessionButton, SIGNAL(clicked()),
+ this, SLOT(openSyncSession()));
+ connect(closeSessionButton, SIGNAL(clicked()),
+ this, SLOT(closeSession()));
+ connect(stopSessionButton, SIGNAL(clicked()),
+ this, SLOT(stopSession()));
+}
+
+SessionWidget::~SessionWidget()
+{
+ delete session;
+}
+
+void SessionWidget::timerEvent(QTimerEvent *e)
+{
+ if (e->timerId() == statsTimer) {
+ rxData->setText(QString::number(session->bytesReceived()));
+ txData->setText(QString::number(session->bytesWritten()));
+ activeTime->setText(QString::number(session->activeTime()));
+ }
+}
+
+void SessionWidget::updateSession()
+{
+ updateSessionState(session->state());
+ updateSessionError(session->error());
+
+ if (session->state() == QNetworkSession::Connected)
+ statsTimer = startTimer(1000);
+ else
+ killTimer(statsTimer);
+
+ if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint)
+ bearer->setText(session->configuration().bearerName());
+ else {
+ QNetworkConfigurationManager mgr;
+ QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString());
+ bearer->setText(c.bearerName());
+ }
+
+#ifndef QT_NO_NETWORKINTERFACE
+ interfaceName->setText(session->interface().humanReadableName());
+ interfaceGuid->setText(session->interface().name());
+#endif
+}
+
+void SessionWidget::openSession()
+{
+ session->open();
+ updateSession();
+}
+
+void SessionWidget::openSyncSession()
+{
+ session->open();
+ session->waitForOpened();
+ updateSession();
+}
+
+void SessionWidget::closeSession()
+{
+ session->close();
+ updateSession();
+}
+
+void SessionWidget::stopSession()
+{
+ session->stop();
+ updateSession();
+}
+
+void SessionWidget::updateSessionState(QNetworkSession::State state)
+{
+ QString s = tr("%1 (%2)");
+
+ switch (state) {
+ case QNetworkSession::Invalid:
+ s = s.arg(tr("Invalid"));
+ break;
+ case QNetworkSession::NotAvailable:
+ s = s.arg(tr("Not Available"));
+ break;
+ case QNetworkSession::Connecting:
+ s = s.arg(tr("Connecting"));
+ break;
+ case QNetworkSession::Connected:
+ s = s.arg(tr("Connected"));
+ break;
+ case QNetworkSession::Closing:
+ s = s.arg(tr("Closing"));
+ break;
+ case QNetworkSession::Disconnected:
+ s = s.arg(tr("Disconnected"));
+ break;
+ case QNetworkSession::Roaming:
+ s = s.arg(tr("Roaming"));
+ break;
+ default:
+ s = s.arg(tr("Unknown"));
+ }
+
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
+ else
+ s = s.arg(tr("Closed"));
+
+ sessionState->setText(s);
+}
+
+void SessionWidget::updateSessionError(QNetworkSession::SessionError error)
+{
+ lastError->setText(QString::number(error));
+ errorString->setText(session->errorString());
+}
+
diff --git a/examples/assistant/simpletextviewer/mainwindow.h b/examples/network/bearermonitor/sessionwidget.h
index 14f0679..ae5cc96 100644
--- a/examples/assistant/simpletextviewer/mainwindow.h
+++ b/examples/network/bearermonitor/sessionwidget.h
@@ -39,53 +39,40 @@
**
****************************************************************************/
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
+#ifndef SESSIONWIDGET_H
+#define SESSIONWIDGET_H
-#include <QAssistantClient>
-#include <QMainWindow>
-#include <QTextEdit>
+#include "ui_sessionwidget.h"
-class MainWindow : public QMainWindow
+#include <qnetworksession.h>
+
+QT_USE_NAMESPACE
+
+class SessionWidget : public QWidget, public Ui_SessionWidget
{
Q_OBJECT
public:
- MainWindow();
-
-private slots:
- void about();
-//! [0]
- void assistant();
-//! [0]
- void open();
+ explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
+ ~SessionWidget();
-protected:
-//! [1]
- void closeEvent(QCloseEvent *event);
-//! [1]
+ void timerEvent(QTimerEvent *);
private:
- void createActions();
- void createMenus();
-//! [2]
- void initializeAssistant();
-//! [2]
+ void updateSessionState(QNetworkSession::State state);
+ void updateSessionError(QNetworkSession::SessionError error);
-//! [3]
- QAssistantClient *assistantClient;
-//! [3]
- QTextEdit *textViewer;
+private Q_SLOTS:
+ void openSession();
+ void openSyncSession();
+ void closeSession();
+ void stopSession();
+ void updateSession();
- QMenu *fileMenu;
- QMenu *helpMenu;
-
- QAction *assistantAct;
- QAction *clearAct;
- QAction *openAct;
- QAction *exitAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
+private:
+ QNetworkSession *session;
+ int statsTimer;
};
#endif
+
diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui
new file mode 100644
index 0000000..45135f5
--- /dev/null
+++ b/examples/network/bearermonitor/sessionwidget.ui
@@ -0,0 +1,307 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SessionWidget</class>
+ <widget class="QWidget" name="SessionWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>340</width>
+ <height>276</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="sessionIdLayout">
+ <item>
+ <widget class="QLabel" name="sessionIdLabel">
+ <property name="text">
+ <string>Session ID:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="sessionId">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="sessionStateLayout">
+ <item>
+ <widget class="QLabel" name="sessionStateLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Session State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="sessionState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Invalid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationLayout">
+ <item>
+ <widget class="QLabel" name="configurationLabel">
+ <property name="text">
+ <string>Configuration:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configuration">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="bearerLayout">
+ <item>
+ <widget class="QLabel" name="bearerLabel">
+ <property name="text">
+ <string>Bearer:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="bearer">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="interfaceNameLayout">
+ <item>
+ <widget class="QLabel" name="interfaceNameLabel">
+ <property name="text">
+ <string>Interface Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="interfaceName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="interfaceGuidLayout">
+ <item>
+ <widget class="QLabel" name="interfaceGuidLabel">
+ <property name="text">
+ <string>Interface GUID:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="interfaceGuid">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="lastErrorLayout">
+ <item>
+ <widget class="QLabel" name="lastErrorLabel">
+ <property name="text">
+ <string>Last Error:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lastError">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="errorStringLayout">
+ <item>
+ <widget class="QLabel" name="errorStringLabel">
+ <property name="text">
+ <string>Error String</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="errorString">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="rxData">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="txData">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Active Time:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="activeTime">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>0 seconds</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="openSessionButton">
+ <property name="text">
+ <string>Open</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="openSyncSessionButton">
+ <property name="text">
+ <string>Blocking Open</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="closeSessionButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="stopSessionButton">
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/network/fortuneclient/fortuneclient.pro b/examples/network/fortuneclient/fortuneclient.pro
index 2b65f2f..edbf14d 100644
--- a/examples/network/fortuneclient/fortuneclient.pro
+++ b/examples/network/fortuneclient/fortuneclient.pro
@@ -11,7 +11,7 @@ INSTALLS += target sources
symbian {
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
- HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h
+ INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/
LIBS += -lesock -lcommdb -linsock # For IAP selection
TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData"
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
diff --git a/examples/network/fortuneserver/fortuneserver.pro b/examples/network/fortuneserver/fortuneserver.pro
index acb285b..29ba313 100644
--- a/examples/network/fortuneserver/fortuneserver.pro
+++ b/examples/network/fortuneserver/fortuneserver.pro
@@ -12,7 +12,7 @@ INSTALLS += target sources
symbian {
TARGET.UID3 = 0xA000CF71
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
- HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h
+ INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/
LIBS += -lesock -lcommdb -linsock # For IAP selection
TARGET.CAPABILITY = "All -TCB"
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro
index 7438641..1215aea 100644
--- a/examples/network/network-chat/network-chat.pro
+++ b/examples/network/network-chat/network-chat.pro
@@ -20,7 +20,7 @@ INSTALLS += target sources
symbian {
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
- HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h
+ INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/
LIBS += -lesock -lcommdb -linsock # For IAP selection
LIBS += -lcharconv
TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData"
diff --git a/examples/network/network.pro b/examples/network/network.pro
index c5a97fb..bd632b8 100644
--- a/examples/network/network.pro
+++ b/examples/network/network.pro
@@ -11,7 +11,9 @@ SUBDIRS = blockingfortuneclient \
loopback \
threadedfortuneserver \
googlesuggest \
- torrent
+ torrent \
+ bearercloud \
+ bearermonitor
# no QProcess
!vxworks:!qnx:SUBDIRS += network-chat
diff --git a/examples/opengl/hellogl_es/cl_helper.h b/examples/opengl/hellogl_es/cl_helper.h
deleted file mode 100644
index 4f4c2bd..0000000
--- a/examples/opengl/hellogl_es/cl_helper.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifdef QT_OPENGL_ES_1_CL
-
-//! [0]
-#define FLOAT2X(f) ((int) ( (f) * (65536)))
-#define X2FLOAT(x) ((float)(x) / 65536.0f)
-
-#define f2vt(f) FLOAT2X(f)
-#define vt2f(x) X2FLOAT(x)
-
-#define q_vertexType GLfixed
-#define q_vertexTypeEnum GL_FIXED
-
-#define q_glFog glFogx
-#define q_glFogv glFogxv
-//! [0]
-
-#define q_glLight glLightx
-#define q_glLightv glLightxv
-#define q_glLightModel glLightModelx
-#define q_glLightModelv glLightModelxv
-
-#define q_glAlphaFunc glAlphaFuncx
-
-#define q_glMaterial glMaterialx
-#define q_glMaterialv glMaterialxv
-#define q_glColor4 glColor4x
-
-#define q_glTexParameter glTexParameterx
-#define q_glTexEnv glTexEnvx
-
-#define q_glOrtho glOrthox
-#define q_glFrustum glFrustumx
-
-#define q_glTranslate glTranslatex
-#define q_glScale glScalex
-#define q_glRotate glRotatex
-#define q_glLoadMatrix glLoadMatrixx
-
-#define q_glClearColor glClearColorx
-
-#define q_glMultMatrix glMultMatrixx
-
-#define q_glNormal3 glNormal3x
-
-#define q_glPolygonOffset glPolygonOffsetx
-#define q_glPointSize glPointSizex
-
-//! [1]
-#else
-
-#define f2vt(f) (f)
-#define vt2f(x) (x)
-
-#define q_vertexType GLfloat
-#define q_vertexTypeEnum GL_FLOAT
-
-#define q_glFog glFogf
-#define q_glFogv glFogfv
-//! [1]
-
-#define q_glLight glLightf
-#define q_glLightv glLightfv
-#define q_glLightModel glLightModelf
-#define q_glLightModelv glLightModelfv
-
-#define q_glAlphaFunc glAlphaFuncf
-
-#define q_glMaterial glMaterialf
-#define q_glMaterialv glMaterialfv
-#define q_glColor4 glColor4f
-
-#define q_glTexParameter glTexParameterf
-#define q_glTexEnv glTexEnvf
-
-#define q_glOrtho glOrthof
-#define q_glFrustum glFrustumf
-
-#define q_glTranslate glTranslatef
-#define q_glScale glScalef
-#define q_glRotate glRotatef
-#define q_glLoadMatrix glLoadMatrixf
-
-#define q_glClearColor glClearColor
-
-#define q_glMultMatrix glMultMatrixf
-
-#define q_glNormal3 glNormal3f
-
-#define q_glPolygonOffset glPolygonOffsetf
-#define q_glPointSize glPointSizef
-
-#endif
diff --git a/examples/opengl/hellogl_es/glwidget.cpp b/examples/opengl/hellogl_es/glwidget.cpp
index 9a45a11..8a6543d 100644
--- a/examples/opengl/hellogl_es/glwidget.cpp
+++ b/examples/opengl/hellogl_es/glwidget.cpp
@@ -44,7 +44,6 @@
#include <math.h>
#include "bubble.h"
-#include "cl_helper.h"
const int bubbleNum = 8;
@@ -114,9 +113,9 @@ void GLWidget::paintQtLogo()
{
glDisable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3,q_vertexTypeEnum,0, createdVertices);
+ glVertexPointer(3,GL_FLOAT,0, createdVertices);
glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(q_vertexTypeEnum,0,createdNormals);
+ glNormalPointer(GL_FLOAT,0,createdNormals);
glDrawArrays(GL_TRIANGLES, 0, m_vertexNumber / 3);
}
//! [2]
@@ -125,83 +124,83 @@ void GLWidget::paintTexturedCube()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
- q_vertexType afVertices[] = {
- f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(0.5),
- f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(-0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),
- f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),
- f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),
-
- f2vt(0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(0.5),f2vt(0.5),f2vt(-0.5),
- f2vt(0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5),f2vt(0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(0.5),
- f2vt(-0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5),f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(-0.5),
- f2vt(-0.5), f2vt(-0.5), f2vt(0.5), f2vt(-0.5),f2vt(0.5),f2vt(-0.5),f2vt(-0.5),f2vt(0.5),f2vt(0.5),
-
- f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(-0.5),
- f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(0.5),
- f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5),
- f2vt(0.5), f2vt(-0.5), f2vt(0.5), f2vt(0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(-0.5), f2vt(0.5)
+ GLfloat afVertices[] = {
+ -0.5, 0.5, 0.5, 0.5,-0.5,0.5,-0.5,-0.5,0.5,
+ 0.5, -0.5, 0.5, -0.5,0.5,0.5,0.5,0.5,0.5,
+ -0.5, -0.5, -0.5, 0.5,-0.5,-0.5,-0.5,0.5,-0.5,
+ 0.5, 0.5, -0.5, -0.5,0.5,-0.5,0.5,-0.5,-0.5,
+
+ 0.5, -0.5, -0.5, 0.5,-0.5,0.5,0.5,0.5,-0.5,
+ 0.5, 0.5, 0.5, 0.5,0.5,-0.5,0.5,-0.5,0.5,
+ -0.5, 0.5, -0.5, -0.5,-0.5,0.5,-0.5,-0.5,-0.5,
+ -0.5, -0.5, 0.5, -0.5,0.5,-0.5,-0.5,0.5,0.5,
+
+ 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5,
+ -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5,
+ -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5,
+ 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5
};
glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3,q_vertexTypeEnum,0,afVertices);
-
- q_vertexType afTexCoord[] = {
- f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f),
- f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f),
- f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f),
- f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f),
-
- f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f),
- f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f),
- f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f),
- f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f),
-
- f2vt(0.0f),f2vt(1.0f), f2vt(1.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f),
- f2vt(1.0f),f2vt(0.0f), f2vt(0.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f),
- f2vt(1.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f),
- f2vt(0.0f),f2vt(1.0f), f2vt(0.0f),f2vt(0.0f), f2vt(1.0f),f2vt(1.0f)
+ glVertexPointer(3,GL_FLOAT,0,afVertices);
+
+ GLfloat afTexCoord[] = {
+ 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f,
+ 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f,
+ 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f,
+ 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f,
+
+ 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f,
+ 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f,
+ 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f,
+ 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f,
+
+ 0.0f,1.0f, 1.0f,0.0f, 1.0f,1.0f,
+ 1.0f,0.0f, 0.0f,1.0f, 0.0f,0.0f,
+ 1.0f,0.0f, 1.0f,1.0f, 0.0f,0.0f,
+ 0.0f,1.0f, 0.0f,0.0f, 1.0f,1.0f
};
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2,q_vertexTypeEnum,0,afTexCoord);
+ glTexCoordPointer(2,GL_FLOAT,0,afTexCoord);
- q_vertexType afNormals[] = {
+ GLfloat afNormals[] = {
- f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1),
- f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1), f2vt(0),f2vt(0),f2vt(-1),
- f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1),
- f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1), f2vt(0),f2vt(0),f2vt(1),
+ 0,0,-1, 0,0,-1, 0,0,-1,
+ 0,0,-1, 0,0,-1, 0,0,-1,
+ 0,0,1, 0,0,1, 0,0,1,
+ 0,0,1, 0,0,1, 0,0,1,
- f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0),
- f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0), f2vt(-1),f2vt(0),f2vt(0),
- f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0),
- f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0), f2vt(1),f2vt(0),f2vt(0),
+ -1,0,0, -1,0,0, -1,0,0,
+ -1,0,0, -1,0,0, -1,0,0,
+ 1,0,0, 1,0,0, 1,0,0,
+ 1,0,0, 1,0,0, 1,0,0,
- f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0),
- f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0), f2vt(0),f2vt(-1),f2vt(0),
- f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0),
- f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0), f2vt(0),f2vt(1),f2vt(0)
+ 0,-1,0, 0,-1,0, 0,-1,0,
+ 0,-1,0, 0,-1,0, 0,-1,0,
+ 0,1,0, 0,1,0, 0,1,0,
+ 0,1,0, 0,1,0, 0,1,0
};
glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(q_vertexTypeEnum,0,afNormals);
+ glNormalPointer(GL_FLOAT,0,afNormals);
glDrawArrays(GL_TRIANGLES, 0, 36);
}
void GLWidget::initializeGL ()
{
- q_glClearColor(f2vt(0.1f), f2vt(0.1f), f2vt(0.2f), f2vt(1.0f));
+ glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &m_uiTexture);
m_uiTexture = bindTexture(QImage(":/qt.png"));
- q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
- q_vertexType aLightPosition[] = {f2vt(0.0f),f2vt(0.3f),f2vt(1.0f),f2vt(0.0f)};
+ GLfloat aLightPosition[] = {0.0f,0.3f,1.0f,0.0f};
- q_glLightv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition);
+ glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition);
m_fAngle = 0;
m_fScale = 1;
createGeometry();
@@ -230,12 +229,12 @@ void GLWidget::paintGL()
//Since OpenGL ES does not support glPush/PopAttrib(GL_ALL_ATTRIB_BITS)
//we have to take care of the states ourselves
- q_glClearColor(f2vt(0.1f), f2vt(0.1f), f2vt(0.2f), f2vt(1.0f));
+ glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
- q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- q_glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
@@ -248,14 +247,14 @@ void GLWidget::paintGL()
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- q_glRotate(f2vt(m_fAngle), f2vt(0.0), f2vt(1.0), f2vt(0.0));
- q_glRotate(f2vt(m_fAngle), f2vt(1.0), f2vt(0.0), f2vt(0.0));
- q_glRotate(f2vt(m_fAngle), f2vt(0.0), f2vt(0.0), f2vt(1.0));
- q_glScale(f2vt(m_fScale), f2vt(m_fScale),f2vt(m_fScale));
- q_glTranslate(f2vt(0),f2vt(-0.2),f2vt(0));
+ glRotatef(m_fAngle, 0.0f, 1.0f, 0.0f);
+ glRotatef(m_fAngle, 1.0f, 0.0f, 0.0f);
+ glRotatef(m_fAngle, 0.0f, 0.0f, 1.0f);
+ glScalef(m_fScale, m_fScale,m_fScale);
+ glTranslatef(0.0f,-0.2f,0.0f);
- q_vertexType matDiff[] = {f2vt(0.40), f2vt(1.0), f2vt(0.0), f2vt(1.0)};
- q_glMaterialv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff);
+ GLfloat matDiff[] = {0.40f, 1.0f, 0.0f, 1.0f};
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff);
if (qtLogo)
paintQtLogo();
@@ -376,11 +375,11 @@ void GLWidget::createGeometry()
//! [1]
m_vertexNumber = vertices.size();
- createdVertices = new q_vertexType[m_vertexNumber];
- createdNormals = new q_vertexType[m_vertexNumber];
+ createdVertices = new GLfloat[m_vertexNumber];
+ createdNormals = new GLfloat[m_vertexNumber];
for (int i = 0;i < m_vertexNumber;i++) {
- createdVertices[i] = f2vt(vertices.at(i) * 2);
- createdNormals[i] = f2vt(normals.at(i));
+ createdVertices[i] = vertices.at(i) * 2;
+ createdNormals[i] = normals.at(i);
}
vertices.clear();
normals.clear();
diff --git a/examples/opengl/hellogl_es/glwidget.h b/examples/opengl/hellogl_es/glwidget.h
index 7a8df53..3b2b5d4 100644
--- a/examples/opengl/hellogl_es/glwidget.h
+++ b/examples/opengl/hellogl_es/glwidget.h
@@ -45,7 +45,6 @@
#include <QGLWidget>
#include <QTime>
-#include "cl_helper.h"
class Bubble;
@@ -76,8 +75,8 @@ private:
void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
QList<qreal> vertices;
QList<qreal> normals;
- q_vertexType *createdVertices;
- q_vertexType *createdNormals;
+ GLfloat *createdVertices;
+ GLfloat *createdNormals;
int m_vertexNumber;
bool qtLogo;
QList<Bubble*> bubbles;
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index eaac9b8..c3fbc77 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -1,14 +1,12 @@
TEMPLATE = subdirs
-contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONFIG, opengles2){
+contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2){
contains(QT_CONFIG, opengles2) {
SUBDIRS = hellogl_es2
} else {
SUBDIRS = hellogl_es
}
- !contains(QT_CONFIG, opengles1cl) {
- SUBDIRS += textures
- }
+ SUBDIRS += textures
contains(QT_CONFIG, opengles1) {
SUBDIRS += hellogl
}
diff --git a/examples/qtestlib/tutorial5/containers.cpp b/examples/qtestlib/tutorial5/containers.cpp
new file mode 100644
index 0000000..fe68c85
--- /dev/null
+++ b/examples/qtestlib/tutorial5/containers.cpp
@@ -0,0 +1,269 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+// This file contains benchmarks for comparing QVector against std::vector
+
+#include <QtCore>
+#include <QVector>
+#include <vector>
+
+#include <qtest.h>
+
+template <typename T> // T is the item type
+class UseCases {
+public:
+ virtual ~UseCases() {}
+
+ // Use case: Insert \a size items into the vector.
+ virtual void insert(int size) = 0;
+
+ // Use case: Lookup \a size items from the vector.
+ virtual void lookup(int size) = 0;
+};
+
+template <typename T>
+T * f(T *ts) // dummy function to prevent code from being optimized away by the compiler
+{
+ return ts;
+}
+
+// This subclass implements the use cases using QVector as efficiently as possible.
+template <typename T>
+class UseCases_QVector : public UseCases<T>
+{
+ void insert(int size)
+ {
+ QVector<T> v;
+ T t;
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i)
+ v.append(t);
+ }
+ }
+
+ void lookup(int size)
+ {
+ QVector<T> v;
+
+ T t;
+ for (int i = 0; i < size; ++i)
+ v.append(t);
+
+ T *ts = new T[size];
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i)
+ ts[i] = v.value(i);
+ }
+ f<T>(ts);
+ delete[] ts;
+ }
+};
+
+// This subclass implements the use cases using std::vector as efficiently as possible.
+template <typename T>
+class UseCases_stdvector : public UseCases<T>
+{
+ void insert(int size)
+ {
+ std::vector<T> v;
+ T t;
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i)
+ v.push_back(t);
+ }
+ }
+
+ void lookup(int size)
+ {
+ std::vector<T> v;
+
+ T t;
+ for (int i = 0; i < size; ++i)
+ v.push_back(t);
+
+ T *ts = new T[size];
+ QBENCHMARK {
+ for (int i = 0; i < size; ++i)
+ ts[i] = v[i];
+ }
+ f<T>(ts);
+ delete[] ts;
+ }
+};
+
+struct Large { // A "large" item type
+ int x[1000];
+};
+
+// Symbian devices typically have limited memory
+#ifdef Q_OS_SYMBIAN
+# define LARGE_MAX_SIZE 2000
+#else
+# define LARGE_MAX_SIZE 20000
+#endif
+
+class tst_vector_vs_std : public QObject
+{
+ Q_OBJECT
+public:
+ tst_vector_vs_std()
+ {
+ useCases_QVector_int = new UseCases_QVector<int>;
+ useCases_stdvector_int = new UseCases_stdvector<int>;
+
+ useCases_QVector_Large = new UseCases_QVector<Large>;
+ useCases_stdvector_Large = new UseCases_stdvector<Large>;
+ }
+
+private:
+ UseCases<int> *useCases_QVector_int;
+ UseCases<int> *useCases_stdvector_int;
+ UseCases<Large> *useCases_QVector_Large;
+ UseCases<Large> *useCases_stdvector_Large;
+
+private slots:
+ void insert_int_data();
+ void insert_int();
+ void insert_Large_data();
+ void insert_Large();
+ void lookup_int_data();
+ void lookup_int();
+ void lookup_Large_data();
+ void lookup_Large();
+};
+
+void tst_vector_vs_std::insert_int_data()
+{
+ QTest::addColumn<bool>("useStd");
+ QTest::addColumn<int>("size");
+
+ for (int size = 10; size < 20000; size += 100) {
+ const QByteArray sizeString = QByteArray::number(size);
+ QTest::newRow(("std::vector-int--" + sizeString).constData()) << true << size;
+ QTest::newRow(("QVector-int--" + sizeString).constData()) << false << size;
+ }
+}
+
+void tst_vector_vs_std::insert_int()
+{
+ QFETCH(bool, useStd);
+ QFETCH(int, size);
+
+ if (useStd)
+ useCases_stdvector_int->insert(size);
+ else
+ useCases_QVector_int->insert(size);
+}
+
+void tst_vector_vs_std::insert_Large_data()
+{
+ QTest::addColumn<bool>("useStd");
+ QTest::addColumn<int>("size");
+
+ for (int size = 10; size < LARGE_MAX_SIZE; size += 100) {
+ const QByteArray sizeString = QByteArray::number(size);
+ QTest::newRow(("std::vector-Large--" + sizeString).constData()) << true << size;
+ QTest::newRow(("QVector-Large--" + sizeString).constData()) << false << size;
+ }
+}
+
+void tst_vector_vs_std::insert_Large()
+{
+ QFETCH(bool, useStd);
+ QFETCH(int, size);
+
+ if (useStd)
+ useCases_stdvector_Large->insert(size);
+ else
+ useCases_QVector_Large->insert(size);
+}
+
+//! [1]
+void tst_vector_vs_std::lookup_int_data()
+{
+ QTest::addColumn<bool>("useStd");
+ QTest::addColumn<int>("size");
+
+ for (int size = 10; size < 20000; size += 100) {
+ const QByteArray sizeString = QByteArray::number(size);
+ QTest::newRow(("std::vector-int--" + sizeString).constData()) << true << size;
+ QTest::newRow(("QVector-int--" + sizeString).constData()) << false << size;
+ }
+}
+//! [1]
+
+//! [2]
+void tst_vector_vs_std::lookup_int()
+{
+ QFETCH(bool, useStd);
+ QFETCH(int, size);
+
+ if (useStd)
+ useCases_stdvector_int->lookup(size); // Create a std::vector and run the benchmark.
+ else
+ useCases_QVector_int->lookup(size); // Create a QVector and run the benchmark.
+}
+//! [2]
+
+void tst_vector_vs_std::lookup_Large_data()
+{
+ QTest::addColumn<bool>("useStd");
+ QTest::addColumn<int>("size");
+
+ for (int size = 10; size < LARGE_MAX_SIZE; size += 100) {
+ const QByteArray sizeString = QByteArray::number(size);
+ QTest::newRow(("std::vector-Large--" + sizeString).constData()) << true << size;
+ QTest::newRow(("QVector-Large--" + sizeString).constData()) << false << size;
+ }
+}
+
+void tst_vector_vs_std::lookup_Large()
+{
+ QFETCH(bool, useStd);
+ QFETCH(int, size);
+
+ if (useStd)
+ useCases_stdvector_Large->lookup(size);
+ else
+ useCases_QVector_Large->lookup(size);
+}
+
+QTEST_MAIN(tst_vector_vs_std)
+#include "main.moc"
diff --git a/examples/qws/svgalib/README b/examples/qws/svgalib/README
index 0b2831f..227c066 100644
--- a/examples/qws/svgalib/README
+++ b/examples/qws/svgalib/README
@@ -1,5 +1,9 @@
-This is the SVGA screen driver plugin example from Qt 4.4. The code does
-not compile with Qt 4.5, because the internal graphics engine has changed.
+This is the SVGA screen driver plugin example for QWS.
-This is unsupported code, provided for convenience in case there is
-interest in porting it to Qt 4.5.
+You may need to set the SVGALIB_DEFAULT_MODE environment
+variable. These values have been confirmed to work on one specific
+machine using svgalib 1.4.3: 18, 24, 34, 35, 36
+
+There is a bug in the example causing missing updates in 8-bit mode
+(e.g. modes 10 and 12). Fixing this bug is left as an exercise for the
+reader.
diff --git a/examples/qws/svgalib/svgalibpaintdevice.cpp b/examples/qws/svgalib/svgalibpaintdevice.cpp
index 090311f..86613d2 100644
--- a/examples/qws/svgalib/svgalibpaintdevice.cpp
+++ b/examples/qws/svgalib/svgalibpaintdevice.cpp
@@ -48,7 +48,7 @@
SvgalibPaintDevice::SvgalibPaintDevice(QWidget *w)
: QCustomRasterPaintDevice(w)
{
- pengine = new SvgalibPaintEngine;
+ pengine = new SvgalibPaintEngine(this);
}
SvgalibPaintDevice::~SvgalibPaintDevice()
diff --git a/examples/qws/svgalib/svgalibpaintengine.cpp b/examples/qws/svgalib/svgalibpaintengine.cpp
index 8713863..59740da 100644
--- a/examples/qws/svgalib/svgalibpaintengine.cpp
+++ b/examples/qws/svgalib/svgalibpaintengine.cpp
@@ -45,7 +45,8 @@
#include <vga.h>
#include <vgagl.h>
-SvgalibPaintEngine::SvgalibPaintEngine()
+SvgalibPaintEngine::SvgalibPaintEngine(QPaintDevice *device)
+ : QRasterPaintEngine(device)
{
}
@@ -61,7 +62,7 @@ bool SvgalibPaintEngine::begin(QPaintDevice *dev)
simplePen = true;
brush = Qt::NoBrush;
simpleBrush = true;
- matrix = QMatrix();
+ matrix = QTransform();
simpleMatrix = true;
setClip(QRect(0, 0, device->width(), device->height()));
opaque = true;
@@ -81,54 +82,52 @@ bool SvgalibPaintEngine::end()
//! [1]
//! [2]
-void SvgalibPaintEngine::updateState(const QPaintEngineState &state)
+void SvgalibPaintEngine::updateState()
{
- QPaintEngine::DirtyFlags flags = state.state();
+ QRasterPaintEngineState *s = state();
- if (flags & DirtyTransform) {
- matrix = state.matrix();
+ if (s->dirty & DirtyTransform) {
+ matrix = s->matrix;
simpleMatrix = (matrix.m12() == 0 && matrix.m21() == 0);
}
- if (flags & DirtyPen) {
- pen = state.pen();
+ if (s->dirty & DirtyPen) {
+ pen = s->pen;
simplePen = (pen.width() == 0 || pen.widthF() <= 1)
&& (pen.style() == Qt::NoPen || pen.style() == Qt::SolidLine)
&& (pen.color().alpha() == 255);
}
- if (flags & DirtyBrush) {
- brush = state.brush();
+ if (s->dirty & DirtyBrush) {
+ brush = s->brush;
simpleBrush = (brush.style() == Qt::SolidPattern
|| brush.style() == Qt::NoBrush)
&& (brush.color().alpha() == 255);
}
- if (flags & DirtyClipRegion)
- setClip(state.clipRegion());
+ if (s->dirty & DirtyClipRegion)
+ setClip(s->clipRegion);
- if (flags & DirtyClipEnabled) {
- clipEnabled = state.isClipEnabled();
+ if (s->dirty & DirtyClipEnabled) {
+ clipEnabled = s->isClipEnabled();
updateClip();
}
- if (flags & DirtyClipPath) {
+ if (s->dirty & DirtyClipPath) {
setClip(QRegion());
simpleClip = false;
}
- if (flags & DirtyCompositionMode) {
- const QPainter::CompositionMode m = state.compositionMode();
+ if (s->dirty & DirtyCompositionMode) {
+ const QPainter::CompositionMode m = s->composition_mode;
sourceOver = (m == QPainter::CompositionMode_SourceOver);
}
- if (flags & DirtyOpacity)
- opaque = (state.opacity() == 256);
+ if (s->dirty & DirtyOpacity)
+ opaque = (s->opacity == 256);
- if (flags & DirtyHints)
- aliased = !(state.renderHints() & QPainter::Antialiasing);
-
- QRasterPaintEngine::updateState(state);
+ if (s->dirty & DirtyHints)
+ aliased = !(s->flags.antialiased);
}
//! [2]
diff --git a/examples/qws/svgalib/svgalibpaintengine.h b/examples/qws/svgalib/svgalibpaintengine.h
index f43d201..27b77ee 100644
--- a/examples/qws/svgalib/svgalibpaintengine.h
+++ b/examples/qws/svgalib/svgalibpaintengine.h
@@ -48,12 +48,12 @@
class SvgalibPaintEngine : public QRasterPaintEngine
{
public:
- SvgalibPaintEngine();
+ SvgalibPaintEngine(QPaintDevice *device);
~SvgalibPaintEngine();
bool begin(QPaintDevice *device);
bool end();
- void updateState(const QPaintEngineState &state);
+ void updateState();
void drawRects(const QRect *rects, int rectCount);
private:
@@ -64,7 +64,7 @@ private:
bool simplePen;
QBrush brush;
bool simpleBrush;
- QMatrix matrix;
+ QTransform matrix;
bool simpleMatrix;
QRegion clip;
bool clipEnabled;
diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp
index 1dbf2d4..239b4b4 100644
--- a/examples/script/customclass/bytearrayclass.cpp
+++ b/examples/script/customclass/bytearrayclass.cpp
@@ -148,13 +148,13 @@ void ByteArrayClass::setProperty(QScriptValue &object,
if (!ba)
return;
if (name == length) {
- ba->resize(value.toInt32());
+ resize(*ba, value.toInt32());
} else {
qint32 pos = id;
if (pos < 0)
return;
if (ba->size() <= pos)
- ba->resize(pos + 1);
+ resize(*ba, pos + 1);
(*ba)[pos] = char(value.toInt32());
}
}
@@ -194,10 +194,13 @@ QScriptValue ByteArrayClass::constructor()
return ctor;
}
+//! [10]
QScriptValue ByteArrayClass::newInstance(int size)
{
+ engine()->reportAdditionalMemoryCost(size);
return newInstance(QByteArray(size, /*ch=*/0));
}
+//! [10]
//! [1]
QScriptValue ByteArrayClass::newInstance(const QByteArray &ba)
@@ -235,6 +238,16 @@ void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba)
ba = qvariant_cast<QByteArray>(obj.data().toVariant());
}
+//! [9]
+void ByteArrayClass::resize(QByteArray &ba, int newSize)
+{
+ int oldSize = ba.size();
+ ba.resize(newSize);
+ if (newSize > oldSize)
+ engine()->reportAdditionalMemoryCost(newSize - oldSize);
+}
+//! [9]
+
ByteArrayClassPropertyIterator::ByteArrayClassPropertyIterator(const QScriptValue &object)
diff --git a/examples/script/customclass/bytearrayclass.h b/examples/script/customclass/bytearrayclass.h
index f185754..3f7ce22 100644
--- a/examples/script/customclass/bytearrayclass.h
+++ b/examples/script/customclass/bytearrayclass.h
@@ -82,6 +82,8 @@ private:
static QScriptValue toScriptValue(QScriptEngine *eng, const QByteArray &ba);
static void fromScriptValue(const QScriptValue &obj, QByteArray &ba);
+ void resize(QByteArray &ba, int newSize);
+
QScriptString length;
QScriptValue proto;
QScriptValue ctor;
diff --git a/examples/script/qstetrix/tetrixboard.cpp b/examples/script/qstetrix/tetrixboard.cpp
index 7d44c4c..f35740d 100644
--- a/examples/script/qstetrix/tetrixboard.cpp
+++ b/examples/script/qstetrix/tetrixboard.cpp
@@ -54,7 +54,12 @@ TetrixBoard::TetrixBoard(QWidget *parent)
void TetrixBoard::setNextPieceLabel(QWidget *label)
{
- nextPieceLabel = qobject_cast<QLabel*>(label);
+ nextPieceLbl = qobject_cast<QLabel*>(label);
+}
+
+QLabel *TetrixBoard::nextPieceLabel() const
+{
+ return nextPieceLbl;
}
QObject *TetrixBoard::getTimer()
@@ -82,16 +87,16 @@ void TetrixBoard::keyPressEvent(QKeyEvent *event)
void TetrixBoard::showNextPiece(int width, int height)
{
- if (!nextPieceLabel)
+ if (!nextPieceLabel())
return;
QPixmap pixmap(width * squareWidth(), height * squareHeight());
QPainter painter(&pixmap);
- painter.fillRect(pixmap.rect(), nextPieceLabel->palette().background());
+ painter.fillRect(pixmap.rect(), nextPieceLabel()->palette().background());
emit paintNextPieceRequested(&painter);
- nextPieceLabel->setPixmap(pixmap);
+ nextPieceLabel()->setPixmap(pixmap);
}
void TetrixBoard::drawPauseScreen(QPainter *painter)
diff --git a/examples/script/qstetrix/tetrixboard.h b/examples/script/qstetrix/tetrixboard.h
index 7a04317..781ec39 100644
--- a/examples/script/qstetrix/tetrixboard.h
+++ b/examples/script/qstetrix/tetrixboard.h
@@ -45,21 +45,19 @@
#include <QTimer>
#include <QFrame>
#include <QPointer>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-QT_END_NAMESPACE
+#include <QLabel>
class TetrixBoard : public QFrame
{
Q_OBJECT
Q_PROPERTY(QObject* timer READ getTimer)
- Q_PROPERTY(QWidget* nextPieceLabel WRITE setNextPieceLabel)
+ Q_PROPERTY(QWidget* nextPieceLabel READ nextPieceLabel WRITE setNextPieceLabel)
public:
TetrixBoard(QWidget *parent = 0);
void setNextPieceLabel(QWidget *label);
+ QLabel *nextPieceLabel() const;
void setBoardWidth(int width);
void setBoardHeight(int height);
QSize minimumSizeHint() const;
@@ -95,7 +93,7 @@ private:
int squareHeight() { return contentsRect().height() / BoardHeight; }
QTimer *timer;
- QPointer<QLabel> nextPieceLabel;
+ QPointer<QLabel> nextPieceLbl;
QImage image;
};
diff --git a/examples/threads/waitconditions/waitconditions.pro b/examples/threads/waitconditions/waitconditions.pro
index b07b413..c2be6cd 100644
--- a/examples/threads/waitconditions/waitconditions.pro
+++ b/examples/threads/waitconditions/waitconditions.pro
@@ -10,8 +10,6 @@ INCLUDEPATH += .
# Input
SOURCES += waitconditions.cpp
CONFIG += qt warn_on create_prl link_prl console
-OBJECTS_DIR=obj/debug-shared
-MOC_DIR=moc/debug-shared
# install
target.path = $$[QT_INSTALL_EXAMPLES]/threads/waitconditions
diff --git a/examples/tools/completer/completer.pro b/examples/tools/completer/completer.pro
index 96d3734..14521b2 100644
--- a/examples/tools/completer/completer.pro
+++ b/examples/tools/completer/completer.pro
@@ -1,6 +1,6 @@
-HEADERS = dirmodel.h \
+HEADERS = fsmodel.h \
mainwindow.h
-SOURCES = dirmodel.cpp \
+SOURCES = fsmodel.cpp \
main.cpp \
mainwindow.cpp
RESOURCES = completer.qrc
diff --git a/examples/tools/completer/dirmodel.cpp b/examples/tools/completer/fsmodel.cpp
index 6279547..9a5a772 100644
--- a/examples/tools/completer/dirmodel.cpp
+++ b/examples/tools/completer/fsmodel.cpp
@@ -39,17 +39,17 @@
**
****************************************************************************/
-#include "dirmodel.h"
+#include "fsmodel.h"
//! [0]
-DirModel::DirModel(QObject *parent)
- : QDirModel(parent)
+FileSystemModel::FileSystemModel(QObject *parent)
+ : QFileSystemModel(parent)
{
}
//! [0]
//! [1]
-QVariant DirModel::data(const QModelIndex &index, int role) const
+QVariant FileSystemModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole && index.column() == 0) {
QString path = QDir::toNativeSeparators(filePath(index));
@@ -58,6 +58,7 @@ QVariant DirModel::data(const QModelIndex &index, int role) const
return path;
}
- return QDirModel::data(index, role);
+ return QFileSystemModel::data(index, role);
}
+
//! [1]
diff --git a/examples/tools/completer/dirmodel.h b/examples/tools/completer/fsmodel.h
index 5fbb4a2..0ec9ce9 100644
--- a/examples/tools/completer/dirmodel.h
+++ b/examples/tools/completer/fsmodel.h
@@ -39,21 +39,21 @@
**
****************************************************************************/
-#ifndef DIRMODEL_H
-#define DIRMODEL_H
+#ifndef FILESYSTEMMODEL_H
+#define FILESYSTEMMODEL_H
-#include <QDirModel>
+#include <QFileSystemModel>
-// With a QDirModel, set on a view, you will see "Program Files" in the view
+// With a QFileSystemModel, set on a view, you will see "Program Files" in the view
// But with this model, you will see "C:\Program Files" in the view.
// We acheive this, by having the data() return the entire file path for
// the display role. Note that the Qt::EditRole over which the QCompleter
// looks for matches is left unchanged
//! [0]
-class DirModel : public QDirModel
+class FileSystemModel : public QFileSystemModel
{
public:
- DirModel(QObject *parent = 0);
+ FileSystemModel(QObject *parent = 0);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
};
//! [0]
diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp
index f386497..b1f6759 100644
--- a/examples/tools/completer/mainwindow.cpp
+++ b/examples/tools/completer/mainwindow.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <QtGui>
-#include "dirmodel.h"
+#include "fsmodel.h"
#include "mainwindow.h"
//! [0]
@@ -55,8 +55,8 @@ MainWindow::MainWindow(QWidget *parent)
modelLabel->setText(tr("Model"));
modelCombo = new QComboBox;
- modelCombo->addItem(tr("QDirModel"));
- modelCombo->addItem(tr("QDirModel that shows full path"));
+ modelCombo->addItem(tr("QFileSytemModel"));
+ modelCombo->addItem(tr("QFileSytemModel that shows full path"));
modelCombo->addItem(tr("Country list"));
modelCombo->addItem(tr("Word list"));
modelCombo->setCurrentIndex(0);
@@ -218,17 +218,19 @@ void MainWindow::changeModel()
switch (modelCombo->currentIndex()) {
default:
case 0:
- { // Unsorted QDirModel
- QDirModel *dirModel = new QDirModel(completer);
- completer->setModel(dirModel);
+ { // Unsorted QFileSystemModel
+ QFileSystemModel *fsModel = new QFileSystemModel(completer);
+ fsModel->setRootPath("");
+ completer->setModel(fsModel);
contentsLabel->setText(tr("Enter file path"));
}
break;
//! [11] //! [12]
case 1:
- { // DirModel that shows full paths
- DirModel *dirModel = new DirModel(completer);
- completer->setModel(dirModel);
+ { // FileSystemModel that shows full paths
+ FileSystemModel *fsModel = new FileSystemModel(completer);
+ completer->setModel(fsModel);
+ fsModel->setRootPath("");
contentsLabel->setText(tr("Enter file path"));
}
break;
diff --git a/examples/tutorials/addressbook/part3/addressbook.cpp b/examples/tutorials/addressbook/part3/addressbook.cpp
index 59b297a..5b39159 100644
--- a/examples/tutorials/addressbook/part3/addressbook.cpp
+++ b/examples/tutorials/addressbook/part3/addressbook.cpp
@@ -91,7 +91,7 @@ AddressBook::AddressBook(QWidget *parent)
mainLayout->addWidget(addressText, 1, 1);
mainLayout->addLayout(buttonLayout1, 1, 2);
//! [adding navigation layout]
- mainLayout->addLayout(buttonLayout2, 3, 1);
+ mainLayout->addLayout(buttonLayout2, 2, 1);
//! [adding navigation layout]
setLayout(mainLayout);
setWindowTitle(tr("Simple Address Book"));
diff --git a/examples/tutorials/addressbook/part4/addressbook.cpp b/examples/tutorials/addressbook/part4/addressbook.cpp
index e4e451f..a4bf459 100644
--- a/examples/tutorials/addressbook/part4/addressbook.cpp
+++ b/examples/tutorials/addressbook/part4/addressbook.cpp
@@ -100,7 +100,7 @@ AddressBook::AddressBook(QWidget *parent)
mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
mainLayout->addWidget(addressText, 1, 1);
mainLayout->addLayout(buttonLayout1, 1, 2);
- mainLayout->addLayout(buttonLayout2, 3, 1);
+ mainLayout->addLayout(buttonLayout2, 2, 1);
setLayout(mainLayout);
setWindowTitle(tr("Simple Address Book"));
diff --git a/examples/webkit/fancybrowser/main.cpp b/examples/webkit/fancybrowser/main.cpp
index cf98b51..23f9713 100644
--- a/examples/webkit/fancybrowser/main.cpp
+++ b/examples/webkit/fancybrowser/main.cpp
@@ -45,7 +45,12 @@
int main(int argc, char * argv[])
{
QApplication app(argc, argv);
- MainWindow browser;
- browser.show();
+ QUrl url;
+ if (argc > 1)
+ url = QUrl(argv[1]);
+ else
+ url = QUrl("http://www.google.com/ncr");
+ MainWindow *browser = new MainWindow(url);
+ browser->show();
return app.exec();
}
diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp
index 852d981..6499831 100644
--- a/examples/webkit/fancybrowser/mainwindow.cpp
+++ b/examples/webkit/fancybrowser/mainwindow.cpp
@@ -45,7 +45,7 @@
//! [1]
-MainWindow::MainWindow()
+MainWindow::MainWindow(const QUrl& url)
{
progress = 0;
@@ -60,7 +60,7 @@ MainWindow::MainWindow()
//! [2]
view = new QWebView(this);
- view->load(QUrl("http://www.google.com/ncr"));
+ view->load(url);
connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
@@ -78,6 +78,11 @@ MainWindow::MainWindow()
toolBar->addWidget(locationEdit);
//! [2]
+ QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
+ QAction* viewSourceAction = new QAction("Page Source", this);
+ connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource()));
+ viewMenu->addAction(viewSourceAction);
+
//! [3]
QMenu *effectMenu = menuBar()->addMenu(tr("&Effect"));
effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks()));
@@ -100,6 +105,24 @@ MainWindow::MainWindow()
}
//! [3]
+void MainWindow::viewSource()
+{
+ QNetworkAccessManager* accessManager = view->page()->networkAccessManager();
+ QNetworkRequest request(view->url());
+ QNetworkReply* reply = accessManager->get(request);
+ connect(reply, SIGNAL(finished()), this, SLOT(slotSourceDownloaded()));
+}
+
+void MainWindow::slotSourceDownloaded()
+{
+ QNetworkReply* reply = qobject_cast<QNetworkReply*>(const_cast<QObject*>(sender()));
+ QTextEdit* textEdit = new QTextEdit(NULL);
+ textEdit->setAttribute(Qt::WA_DeleteOnClose);
+ textEdit->show();
+ textEdit->setPlainText(reply->readAll());
+ reply->deleteLater();
+}
+
//! [4]
void MainWindow::adjustLocation()
{
diff --git a/examples/webkit/fancybrowser/mainwindow.h b/examples/webkit/fancybrowser/mainwindow.h
index 08439c1..d3f8e7e 100644
--- a/examples/webkit/fancybrowser/mainwindow.h
+++ b/examples/webkit/fancybrowser/mainwindow.h
@@ -52,7 +52,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- MainWindow();
+ MainWindow(const QUrl& url);
protected slots:
@@ -62,6 +62,9 @@ protected slots:
void setProgress(int p);
void finishLoading(bool);
+ void viewSource();
+ void slotSourceDownloaded();
+
void highlightAllLinks();
void rotateImages(bool invert);
void removeGifImages();