From 82d0b03c4f81c2832975d548917c03dbaddeee72 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 14 May 2010 11:32:57 +1000 Subject: Restructure the examples. They are now organized into various subdirectories to make it easier to locate examples for certain features (e.g. animation) and to distinguish between different types of examples (e.g. very basic examples vs complex demo-like examples). --- doc/src/declarative/example-slideswitch.qdoc | 20 +- doc/src/declarative/examples.qdoc | 123 ++- doc/src/declarative/extending-examples.qdoc | 50 +- doc/src/declarative/extending.qdoc | 46 +- doc/src/declarative/globalobject.qdoc | 2 +- doc/src/declarative/integrating.qdoc | 2 +- doc/src/examples/qml-examples.qdoc | 184 +++-- doc/src/snippets/declarative/border-image.qml | 29 - doc/src/snippets/declarative/borderimage.qml | 29 + .../declarative/animation/animation.qmlproject | 16 + .../declarative/animation/basics/basics.qmlproject | 16 + .../animation/basics/color-animation.qml | 70 ++ .../animation/basics/images/face-smile.png | Bin 0 -> 15408 bytes .../declarative/animation/basics/images/moon.png | Bin 0 -> 2433 bytes .../declarative/animation/basics/images/shadow.png | Bin 0 -> 425 bytes .../declarative/animation/basics/images/star.png | Bin 0 -> 349 bytes .../declarative/animation/basics/images/sun.png | Bin 0 -> 8153 bytes .../animation/basics/property-animation.qml | 63 ++ .../declarative/animation/behaviors/SideRect.qml | 22 + .../animation/behaviors/behavior-example.qml | 79 ++ .../animation/behaviors/behaviors.qmlproject | 16 + examples/declarative/animation/easing/easing.qml | 105 +++ .../declarative/animation/easing/easing.qmlproject | 16 + examples/declarative/animation/states/states.qml | 61 ++ .../declarative/animation/states/states.qmlproject | 16 + .../declarative/animation/states/transitions.qml | 90 +++ examples/declarative/animation/states/user.png | Bin 0 -> 4886 bytes .../declarative/animations/animations.qmlproject | 16 - .../declarative/animations/color-animation.qml | 70 -- examples/declarative/animations/easing.qml | 105 --- .../declarative/animations/images/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/animations/images/moon.png | Bin 2433 -> 0 bytes examples/declarative/animations/images/shadow.png | Bin 425 -> 0 bytes examples/declarative/animations/images/star.png | Bin 349 -> 0 bytes examples/declarative/animations/images/sun.png | Bin 8153 -> 0 bytes .../declarative/animations/property-animation.qml | 63 -- .../declarative/aspectratio/aspectratio.qmlproject | 16 - examples/declarative/aspectratio/face_fit.qml | 26 - .../declarative/aspectratio/face_fit_animated.qml | 28 - examples/declarative/aspectratio/pics/face.png | Bin 15408 -> 0 bytes .../declarative/aspectratio/scale_and_crop.qml | 21 - .../aspectratio/scale_and_crop_simple.qml | 20 - .../declarative/aspectratio/scale_and_sidecrop.qml | 22 - examples/declarative/aspectratio/scale_to_fit.qml | 22 - .../aspectratio/scale_to_fit_simple.qml | 20 - examples/declarative/behaviors/SideRect.qml | 22 - .../declarative/behaviors/behavior-example.qml | 79 -- .../declarative/behaviors/behaviors.qmlproject | 16 - examples/declarative/border-image/border-image.qml | 57 -- .../border-image/border-image.qmlproject | 16 - .../border-image/content/MyBorderImage.qml | 50 -- .../border-image/content/ShadowRectangle.qml | 14 - examples/declarative/border-image/content/bw.png | Bin 1357 -> 0 bytes .../border-image/content/colors-round.sci | 7 - .../border-image/content/colors-stretch.sci | 5 - .../declarative/border-image/content/colors.png | Bin 1655 -> 0 bytes .../declarative/border-image/content/shadow.png | Bin 588 -> 0 bytes examples/declarative/border-image/shadows.qml | 24 - examples/declarative/clocks/clocks.qml | 14 - examples/declarative/clocks/clocks.qmlproject | 16 - examples/declarative/clocks/content/Clock.qml | 83 -- examples/declarative/clocks/content/background.png | Bin 46895 -> 0 bytes examples/declarative/clocks/content/center.png | Bin 765 -> 0 bytes .../declarative/clocks/content/clock-night.png | Bin 23359 -> 0 bytes examples/declarative/clocks/content/clock.png | Bin 20653 -> 0 bytes examples/declarative/clocks/content/hour.png | Bin 625 -> 0 bytes examples/declarative/clocks/content/minute.png | Bin 625 -> 0 bytes examples/declarative/clocks/content/second.png | Bin 303 -> 0 bytes .../connections/connections-example.qml | 37 - .../declarative/connections/connections.qmlproject | 16 - .../declarative/connections/content/Button.qml | 12 - examples/declarative/connections/content/bg1.jpg | Bin 23771 -> 0 bytes .../connections/content/rotate-left.png | Bin 3061 -> 0 bytes .../connections/content/rotate-right.png | Bin 3115 -> 0 bytes .../declarative/cppextensions/cppextensions.pro | 10 + .../cppextensions/cppextensions.qmlproject | 16 + .../imageprovider/ImageProviderCore/qmldir | 2 + .../imageprovider/imageprovider-example.qml | 25 + .../cppextensions/imageprovider/imageprovider.cpp | 118 +++ .../cppextensions/imageprovider/imageprovider.pro | 25 + .../imageprovider/imageprovider.qmlproject | 16 + examples/declarative/cppextensions/plugins/README | 9 + .../plugins/com/nokia/TimeExample/Clock.qml | 50 ++ .../plugins/com/nokia/TimeExample/center.png | Bin 0 -> 765 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 0 -> 20653 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 + .../declarative/cppextensions/plugins/plugin.cpp | 152 ++++ .../declarative/cppextensions/plugins/plugins.pro | 31 + .../declarative/cppextensions/plugins/plugins.qml | 11 + .../cppextensions/plugins/plugins.qmlproject | 16 + .../declarative/cppextensions/proxyviewer/main.cpp | 109 +++ .../cppextensions/proxyviewer/proxyviewer.pro | 9 + .../cppextensions/proxyviewer/proxyviewer.qrc | 5 + .../declarative/cppextensions/proxyviewer/view.qml | 7 + .../cppextensions/proxywidgets/ProxyWidgets/qmldir | 1 + .../declarative/cppextensions/proxywidgets/README | 4 + .../cppextensions/proxywidgets/proxywidgets.cpp | 97 +++ .../cppextensions/proxywidgets/proxywidgets.pro | 21 + .../cppextensions/proxywidgets/proxywidgets.qml | 70 ++ .../proxywidgets/proxywidgets.qmlproject | 16 + .../graphicsLayouts/graphicslayouts.cpp | 366 +++++++++ .../graphicsLayouts/graphicslayouts.pro | 13 + .../graphicsLayouts/graphicslayouts.qml | 77 ++ .../graphicsLayouts/graphicslayouts.qrc | 5 + .../graphicsLayouts/graphicslayouts_p.h | 303 +++++++ .../qgraphicslayouts/graphicsLayouts/main.cpp | 60 ++ .../qgraphicslayouts/layoutItem/layoutItem.pro | 13 + .../qgraphicslayouts/layoutItem/layoutItem.qml | 15 + .../qgraphicslayouts/layoutItem/layoutItem.qrc | 5 + .../qgraphicslayouts/layoutItem/main.cpp | 73 ++ .../qgraphicslayouts/qgraphicslayouts.qmlproject | 16 + .../referenceexamples/adding/adding.pro | 15 + .../referenceexamples/adding/adding.qrc | 5 + .../referenceexamples/adding/example.qml | 8 + .../referenceexamples/adding/main.cpp | 65 ++ .../referenceexamples/adding/person.cpp | 69 ++ .../referenceexamples/adding/person.h | 66 ++ .../referenceexamples/attached/attached.pro | 17 + .../referenceexamples/attached/attached.qrc | 5 + .../referenceexamples/attached/birthdayparty.cpp | 92 +++ .../referenceexamples/attached/birthdayparty.h | 87 +++ .../referenceexamples/attached/example.qml | 31 + .../referenceexamples/attached/main.cpp | 91 +++ .../referenceexamples/attached/person.cpp | 119 +++ .../referenceexamples/attached/person.h | 106 +++ .../referenceexamples/binding/binding.pro | 19 + .../referenceexamples/binding/binding.qrc | 5 + .../referenceexamples/binding/birthdayparty.cpp | 114 +++ .../referenceexamples/binding/birthdayparty.h | 103 +++ .../referenceexamples/binding/example.qml | 37 + .../binding/happybirthdaysong.cpp | 86 ++ .../referenceexamples/binding/happybirthdaysong.h | 75 ++ .../referenceexamples/binding/main.cpp | 93 +++ .../referenceexamples/binding/person.cpp | 139 ++++ .../referenceexamples/binding/person.h | 114 +++ .../referenceexamples/coercion/birthdayparty.cpp | 72 ++ .../referenceexamples/coercion/birthdayparty.h | 70 ++ .../referenceexamples/coercion/coercion.pro | 17 + .../referenceexamples/coercion/coercion.qrc | 5 + .../referenceexamples/coercion/example.qml | 15 + .../referenceexamples/coercion/main.cpp | 78 ++ .../referenceexamples/coercion/person.cpp | 80 ++ .../referenceexamples/coercion/person.h | 83 ++ .../referenceexamples/default/birthdayparty.cpp | 72 ++ .../referenceexamples/default/birthdayparty.h | 71 ++ .../referenceexamples/default/default.pro | 17 + .../referenceexamples/default/default.qrc | 5 + .../referenceexamples/default/example.qml | 14 + .../referenceexamples/default/main.cpp | 76 ++ .../referenceexamples/default/person.cpp | 79 ++ .../referenceexamples/default/person.h | 78 ++ .../referenceexamples/extended/example.qml | 7 + .../referenceexamples/extended/extended.pro | 15 + .../referenceexamples/extended/extended.qrc | 5 + .../referenceexamples/extended/lineedit.cpp | 105 +++ .../referenceexamples/extended/lineedit.h | 74 ++ .../referenceexamples/extended/main.cpp | 65 ++ .../referenceexamples/grouped/birthdayparty.cpp | 72 ++ .../referenceexamples/grouped/birthdayparty.h | 70 ++ .../referenceexamples/grouped/example.qml | 33 + .../referenceexamples/grouped/grouped.pro | 17 + .../referenceexamples/grouped/grouped.qrc | 5 + .../referenceexamples/grouped/main.cpp | 86 ++ .../referenceexamples/grouped/person.cpp | 119 +++ .../referenceexamples/grouped/person.h | 108 +++ .../referenceexamples/properties/birthdayparty.cpp | 74 ++ .../referenceexamples/properties/birthdayparty.h | 76 ++ .../referenceexamples/properties/example.qml | 15 + .../referenceexamples/properties/main.cpp | 69 ++ .../referenceexamples/properties/person.cpp | 67 ++ .../referenceexamples/properties/person.h | 64 ++ .../referenceexamples/properties/properties.pro | 18 + .../referenceexamples/properties/properties.qrc | 5 + .../referenceexamples/referenceexamples.pro | 13 + .../referenceexamples/referenceexamples.qmlproject | 16 + .../referenceexamples/signal/birthdayparty.cpp | 99 +++ .../referenceexamples/signal/birthdayparty.h | 93 +++ .../referenceexamples/signal/example.qml | 32 + .../referenceexamples/signal/main.cpp | 92 +++ .../referenceexamples/signal/person.cpp | 119 +++ .../referenceexamples/signal/person.h | 106 +++ .../referenceexamples/signal/signal.pro | 17 + .../referenceexamples/signal/signal.qrc | 5 + .../valuesource/birthdayparty.cpp | 109 +++ .../referenceexamples/valuesource/birthdayparty.h | 98 +++ .../referenceexamples/valuesource/example.qml | 36 + .../valuesource/happybirthdaysong.cpp | 81 ++ .../valuesource/happybirthdaysong.h | 80 ++ .../referenceexamples/valuesource/main.cpp | 94 +++ .../referenceexamples/valuesource/person.cpp | 119 +++ .../referenceexamples/valuesource/person.h | 106 +++ .../referenceexamples/valuesource/valuesource.pro | 19 + .../referenceexamples/valuesource/valuesource.qrc | 5 + examples/declarative/declarative.pro | 59 +- examples/declarative/dial/content/Dial.qml | 37 - examples/declarative/dial/content/background.png | Bin 35876 -> 0 bytes examples/declarative/dial/content/needle.png | Bin 342 -> 0 bytes .../declarative/dial/content/needle_shadow.png | Bin 632 -> 0 bytes examples/declarative/dial/content/overlay.png | Bin 3564 -> 0 bytes examples/declarative/dial/dial-example.qml | 44 -- examples/declarative/dial/dial.qmlproject | 16 - examples/declarative/dynamic/dynamic.qml | 176 ----- examples/declarative/dynamic/dynamic.qmlproject | 16 - examples/declarative/dynamic/images/NOTE | 1 - examples/declarative/dynamic/images/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/dynamic/images/moon.png | Bin 1757 -> 0 bytes .../declarative/dynamic/images/rabbit_brown.png | Bin 1245 -> 0 bytes examples/declarative/dynamic/images/rabbit_bw.png | Bin 1759 -> 0 bytes examples/declarative/dynamic/images/star.png | Bin 349 -> 0 bytes examples/declarative/dynamic/images/sun.png | Bin 8153 -> 0 bytes examples/declarative/dynamic/images/tree_s.png | Bin 3406 -> 0 bytes examples/declarative/dynamic/qml/Button.qml | 40 - examples/declarative/dynamic/qml/PaletteItem.qml | 19 - .../declarative/dynamic/qml/PerspectiveItem.qml | 25 - examples/declarative/dynamic/qml/Sun.qml | 38 - examples/declarative/dynamic/qml/itemCreation.js | 65 -- examples/declarative/extending/adding/adding.pro | 15 - examples/declarative/extending/adding/adding.qrc | 5 - examples/declarative/extending/adding/example.qml | 8 - examples/declarative/extending/adding/main.cpp | 65 -- examples/declarative/extending/adding/person.cpp | 69 -- examples/declarative/extending/adding/person.h | 66 -- .../declarative/extending/attached/attached.pro | 17 - .../declarative/extending/attached/attached.qrc | 5 - .../extending/attached/birthdayparty.cpp | 92 --- .../declarative/extending/attached/birthdayparty.h | 87 --- .../declarative/extending/attached/example.qml | 31 - examples/declarative/extending/attached/main.cpp | 91 --- examples/declarative/extending/attached/person.cpp | 119 --- examples/declarative/extending/attached/person.h | 106 --- examples/declarative/extending/binding/binding.pro | 19 - examples/declarative/extending/binding/binding.qrc | 5 - .../extending/binding/birthdayparty.cpp | 114 --- .../declarative/extending/binding/birthdayparty.h | 103 --- examples/declarative/extending/binding/example.qml | 37 - .../extending/binding/happybirthdaysong.cpp | 86 -- .../extending/binding/happybirthdaysong.h | 75 -- examples/declarative/extending/binding/main.cpp | 93 --- examples/declarative/extending/binding/person.cpp | 139 ---- examples/declarative/extending/binding/person.h | 114 --- .../extending/coercion/birthdayparty.cpp | 72 -- .../declarative/extending/coercion/birthdayparty.h | 70 -- .../declarative/extending/coercion/coercion.pro | 17 - .../declarative/extending/coercion/coercion.qrc | 5 - .../declarative/extending/coercion/example.qml | 15 - examples/declarative/extending/coercion/main.cpp | 78 -- examples/declarative/extending/coercion/person.cpp | 80 -- examples/declarative/extending/coercion/person.h | 83 -- .../extending/default/birthdayparty.cpp | 72 -- .../declarative/extending/default/birthdayparty.h | 71 -- examples/declarative/extending/default/default.pro | 17 - examples/declarative/extending/default/default.qrc | 5 - examples/declarative/extending/default/example.qml | 14 - examples/declarative/extending/default/main.cpp | 76 -- examples/declarative/extending/default/person.cpp | 79 -- examples/declarative/extending/default/person.h | 78 -- .../declarative/extending/extended/example.qml | 7 - .../declarative/extending/extended/extended.pro | 15 - .../declarative/extending/extended/extended.qrc | 5 - .../declarative/extending/extended/lineedit.cpp | 105 --- examples/declarative/extending/extended/lineedit.h | 74 -- examples/declarative/extending/extended/main.cpp | 65 -- examples/declarative/extending/extending.pro | 13 - .../declarative/extending/extending.qmlproject | 16 - .../extending/grouped/birthdayparty.cpp | 72 -- .../declarative/extending/grouped/birthdayparty.h | 70 -- examples/declarative/extending/grouped/example.qml | 33 - examples/declarative/extending/grouped/grouped.pro | 17 - examples/declarative/extending/grouped/grouped.qrc | 5 - examples/declarative/extending/grouped/main.cpp | 86 -- examples/declarative/extending/grouped/person.cpp | 119 --- examples/declarative/extending/grouped/person.h | 108 --- .../extending/properties/birthdayparty.cpp | 74 -- .../extending/properties/birthdayparty.h | 76 -- .../declarative/extending/properties/example.qml | 15 - examples/declarative/extending/properties/main.cpp | 69 -- .../declarative/extending/properties/person.cpp | 67 -- examples/declarative/extending/properties/person.h | 64 -- .../extending/properties/properties.pro | 18 - .../extending/properties/properties.qrc | 5 - .../declarative/extending/signal/birthdayparty.cpp | 99 --- .../declarative/extending/signal/birthdayparty.h | 93 --- examples/declarative/extending/signal/example.qml | 32 - examples/declarative/extending/signal/main.cpp | 92 --- examples/declarative/extending/signal/person.cpp | 119 --- examples/declarative/extending/signal/person.h | 106 --- examples/declarative/extending/signal/signal.pro | 17 - examples/declarative/extending/signal/signal.qrc | 5 - .../extending/valuesource/birthdayparty.cpp | 109 --- .../extending/valuesource/birthdayparty.h | 98 --- .../declarative/extending/valuesource/example.qml | 36 - .../extending/valuesource/happybirthdaysong.cpp | 81 -- .../extending/valuesource/happybirthdaysong.h | 80 -- .../declarative/extending/valuesource/main.cpp | 94 --- .../declarative/extending/valuesource/person.cpp | 119 --- .../declarative/extending/valuesource/person.h | 106 --- .../extending/valuesource/valuesource.pro | 19 - .../extending/valuesource/valuesource.qrc | 5 - examples/declarative/fillmode/content/QtLogo.qml | 30 - examples/declarative/fillmode/content/qt-logo.png | Bin 5149 -> 0 bytes examples/declarative/fillmode/fillmode.qml | 22 - examples/declarative/fillmode/fillmode.qmlproject | 16 - examples/declarative/flipable/content/5_heart.png | Bin 3872 -> 0 bytes examples/declarative/flipable/content/9_club.png | Bin 6135 -> 0 bytes examples/declarative/flipable/content/Card.qml | 38 - examples/declarative/flipable/content/back.png | Bin 1418 -> 0 bytes examples/declarative/flipable/flipable-example.qml | 15 - examples/declarative/flipable/flipable.qmlproject | 16 - examples/declarative/focus/Core/ContextMenu.qml | 18 - examples/declarative/focus/Core/GridMenu.qml | 61 -- .../declarative/focus/Core/ListViewDelegate.qml | 40 - examples/declarative/focus/Core/ListViews.qml | 62 -- examples/declarative/focus/Core/images/arrow.png | Bin 583 -> 0 bytes examples/declarative/focus/Core/images/qt-logo.png | Bin 5149 -> 0 bytes examples/declarative/focus/Core/qmldir | 4 - examples/declarative/focus/focus.qml | 69 -- examples/declarative/focus/focus.qmlproject | 16 - examples/declarative/fonts/availableFonts.qml | 17 - examples/declarative/fonts/banner.qml | 21 - examples/declarative/fonts/fonts.qml | 64 -- examples/declarative/fonts/fonts.qmlproject | 16 - examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf | Bin 24544 -> 0 bytes examples/declarative/fonts/hello.qml | 38 - .../declarative/gestures/experimental-gestures.qml | 36 - examples/declarative/gestures/gestures.qmlproject | 16 - examples/declarative/gridview/gridview-example.qml | 49 -- examples/declarative/gridview/gridview.qmlproject | 16 - .../declarative/gridview/pics/AddressBook_48.png | Bin 3350 -> 0 bytes .../declarative/gridview/pics/AudioPlayer_48.png | Bin 3806 -> 0 bytes examples/declarative/gridview/pics/Camera_48.png | Bin 3540 -> 0 bytes examples/declarative/gridview/pics/DateBook_48.png | Bin 2610 -> 0 bytes examples/declarative/gridview/pics/EMail_48.png | Bin 3655 -> 0 bytes examples/declarative/gridview/pics/TodoList_48.png | Bin 3429 -> 0 bytes .../declarative/gridview/pics/VideoPlayer_48.png | Bin 4151 -> 0 bytes examples/declarative/i18n/i18n.qmlproject | 16 + .../imageelements/borderimage/borderimage.qml | 57 ++ .../borderimage/borderimage.qmlproject | 16 + .../borderimage/content/MyBorderImage.qml | 50 ++ .../borderimage/content/ShadowRectangle.qml | 14 + .../imageelements/borderimage/content/bw.png | Bin 0 -> 1357 bytes .../borderimage/content/colors-round.sci | 7 + .../borderimage/content/colors-stretch.sci | 5 + .../imageelements/borderimage/content/colors.png | Bin 0 -> 1655 bytes .../imageelements/borderimage/content/shadow.png | Bin 0 -> 588 bytes .../imageelements/borderimage/shadows.qml | 24 + .../declarative/imageelements/image/face_fit.qml | 26 + .../imageelements/image/face_fit_animated.qml | 28 + .../imageelements/image/image.qmlproject | 16 + .../declarative/imageelements/image/pics/face.png | Bin 0 -> 15408 bytes .../imageelements/image/scale_and_crop.qml | 21 + .../imageelements/image/scale_and_crop_simple.qml | 20 + .../imageelements/image/scale_and_sidecrop.qml | 22 + .../imageelements/image/scale_to_fit.qml | 22 + .../imageelements/image/scale_to_fit_simple.qml | 20 + .../imageelements/imageelements.qmlproject | 16 + .../imageprovider/ImageProviderCore/qmldir | 2 - .../imageprovider/imageprovider-example.qml | 25 - .../declarative/imageprovider/imageprovider.cpp | 118 --- .../declarative/imageprovider/imageprovider.pro | 25 - .../imageprovider/imageprovider.qmlproject | 16 - examples/declarative/images/content/lemonade.jpg | Bin 6645 -> 0 bytes examples/declarative/images/images.qml | 72 -- examples/declarative/images/images.qmlproject | 16 - .../keyinteraction/focus/Core/ContextMenu.qml | 18 + .../keyinteraction/focus/Core/GridMenu.qml | 61 ++ .../keyinteraction/focus/Core/ListViewDelegate.qml | 40 + .../keyinteraction/focus/Core/ListViews.qml | 62 ++ .../keyinteraction/focus/Core/images/arrow.png | Bin 0 -> 583 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 0 -> 5149 bytes .../declarative/keyinteraction/focus/Core/qmldir | 4 + .../declarative/keyinteraction/focus/focus.qml | 69 ++ .../keyinteraction/focus/focus.qmlproject | 16 + .../keyinteraction/keyinteraction.qmlproject | 16 + .../layouts/graphicsLayouts/graphicslayouts.cpp | 366 --------- .../layouts/graphicsLayouts/graphicslayouts.pro | 13 - .../layouts/graphicsLayouts/graphicslayouts.qml | 77 -- .../layouts/graphicsLayouts/graphicslayouts.qrc | 5 - .../layouts/graphicsLayouts/graphicslayouts_p.h | 303 ------- .../declarative/layouts/graphicsLayouts/main.cpp | 60 -- .../declarative/layouts/layoutItem/layoutItem.pro | 13 - .../declarative/layouts/layoutItem/layoutItem.qml | 15 - .../declarative/layouts/layoutItem/layoutItem.qrc | 5 - examples/declarative/layouts/layoutItem/main.cpp | 73 -- .../declarative/layouts/positioners/Button.qml | 38 - examples/declarative/layouts/positioners/add.png | Bin 1577 -> 0 bytes examples/declarative/layouts/positioners/del.png | Bin 1661 -> 0 bytes .../layouts/positioners/positioners.qml | 213 ----- .../layouts/positioners/positioners.qmlproject | 18 - .../positioners/positioners.qmlproject.user | 41 - .../declarative/listmodel-threaded/dataloader.js | 9 - .../listmodel-threaded.qmlproject | 16 - .../declarative/listmodel-threaded/timedisplay.qml | 32 - .../listview/content/ClickAutoRepeating.qml | 31 - .../declarative/listview/content/MediaButton.qml | 35 - examples/declarative/listview/content/pics/add.png | Bin 1577 -> 0 bytes .../listview/content/pics/archive-insert.png | Bin 896 -> 0 bytes .../listview/content/pics/archive-remove.png | Bin 1074 -> 0 bytes .../listview/content/pics/button-pressed.png | Bin 571 -> 0 bytes .../declarative/listview/content/pics/button.png | Bin 564 -> 0 bytes examples/declarative/listview/content/pics/del.png | Bin 1661 -> 0 bytes .../listview/content/pics/fruit-salad.jpg | Bin 17952 -> 0 bytes .../declarative/listview/content/pics/go-down.png | Bin 892 -> 0 bytes .../declarative/listview/content/pics/go-up.png | Bin 929 -> 0 bytes .../listview/content/pics/hamburger.jpg | Bin 8572 -> 0 bytes .../declarative/listview/content/pics/lemonade.jpg | Bin 6645 -> 0 bytes .../declarative/listview/content/pics/list-add.png | Bin 907 -> 0 bytes .../listview/content/pics/list-remove.png | Bin 498 -> 0 bytes .../declarative/listview/content/pics/moreDown.png | Bin 217 -> 0 bytes .../declarative/listview/content/pics/moreUp.png | Bin 212 -> 0 bytes .../declarative/listview/content/pics/pancakes.jpg | Bin 9163 -> 0 bytes .../declarative/listview/content/pics/trash.png | Bin 989 -> 0 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 8639 -> 0 bytes .../declarative/listview/dummydata/MyPetsModel.qml | 61 -- .../declarative/listview/dummydata/Recipes.qml | 90 --- examples/declarative/listview/dynamic.qml | 208 ----- examples/declarative/listview/highlight.qml | 55 -- examples/declarative/listview/itemlist.qml | 67 -- examples/declarative/listview/listview-example.qml | 93 --- examples/declarative/listview/listview.qmlproject | 16 - examples/declarative/listview/recipes.qml | 160 ---- examples/declarative/listview/sections.qml | 71 -- .../modelviews/gridview/gridview-example.qml | 49 ++ .../modelviews/gridview/gridview.qmlproject | 16 + .../modelviews/gridview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/gridview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../modelviews/gridview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../modelviews/gridview/pics/DateBook_48.png | Bin 0 -> 2610 bytes .../modelviews/gridview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../modelviews/gridview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/gridview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes .../listview/content/ClickAutoRepeating.qml | 31 + .../modelviews/listview/content/MediaButton.qml | 35 + .../modelviews/listview/content/pics/add.png | Bin 0 -> 1577 bytes .../listview/content/pics/archive-insert.png | Bin 0 -> 896 bytes .../listview/content/pics/archive-remove.png | Bin 0 -> 1074 bytes .../listview/content/pics/button-pressed.png | Bin 0 -> 571 bytes .../modelviews/listview/content/pics/button.png | Bin 0 -> 564 bytes .../modelviews/listview/content/pics/del.png | Bin 0 -> 1661 bytes .../listview/content/pics/fruit-salad.jpg | Bin 0 -> 17952 bytes .../modelviews/listview/content/pics/go-down.png | Bin 0 -> 892 bytes .../modelviews/listview/content/pics/go-up.png | Bin 0 -> 929 bytes .../modelviews/listview/content/pics/hamburger.jpg | Bin 0 -> 8572 bytes .../modelviews/listview/content/pics/lemonade.jpg | Bin 0 -> 6645 bytes .../modelviews/listview/content/pics/list-add.png | Bin 0 -> 907 bytes .../listview/content/pics/list-remove.png | Bin 0 -> 498 bytes .../modelviews/listview/content/pics/moreDown.png | Bin 0 -> 217 bytes .../modelviews/listview/content/pics/moreUp.png | Bin 0 -> 212 bytes .../modelviews/listview/content/pics/pancakes.jpg | Bin 0 -> 9163 bytes .../modelviews/listview/content/pics/trash.png | Bin 0 -> 989 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 0 -> 8639 bytes .../modelviews/listview/dummydata/MyPetsModel.qml | 61 ++ .../modelviews/listview/dummydata/Recipes.qml | 90 +++ .../declarative/modelviews/listview/dynamic.qml | 208 +++++ .../declarative/modelviews/listview/highlight.qml | 55 ++ .../declarative/modelviews/listview/itemlist.qml | 67 ++ .../modelviews/listview/listview-example.qml | 93 +++ .../modelviews/listview/listview.qmlproject | 16 + .../declarative/modelviews/listview/recipes.qml | 160 ++++ .../declarative/modelviews/listview/sections.qml | 71 ++ examples/declarative/modelviews/modelviews.pro | 7 + .../declarative/modelviews/modelviews.qmlproject | 16 + .../modelviews/objectlistmodel/dataobject.cpp | 79 ++ .../modelviews/objectlistmodel/dataobject.h | 73 ++ .../modelviews/objectlistmodel/main.cpp | 77 ++ .../modelviews/objectlistmodel/objectlistmodel.pro | 18 + .../objectlistmodel/objectlistmodel.qmlproject | 16 + .../modelviews/objectlistmodel/objectlistmodel.qrc | 5 + .../modelviews/objectlistmodel/view.qml | 16 + .../declarative/modelviews/package/Delegate.qml | 48 ++ .../modelviews/package/package.qmlproject | 16 + examples/declarative/modelviews/package/view.qml | 35 + .../declarative/modelviews/parallax/parallax.qml | 41 + .../modelviews/parallax/parallax.qmlproject | 16 + .../modelviews/parallax/pics/background.jpg | Bin 0 -> 209814 bytes .../modelviews/parallax/pics/face-smile.png | Bin 0 -> 15408 bytes .../modelviews/parallax/pics/home-page.svg | 445 +++++++++++ .../modelviews/parallax/pics/shadow.png | Bin 0 -> 425 bytes .../modelviews/parallax/pics/yast-joystick.png | Bin 0 -> 2723 bytes .../modelviews/parallax/pics/yast-wol.png | Bin 0 -> 3769 bytes .../modelviews/parallax/qml/ParallaxView.qml | 83 ++ .../declarative/modelviews/parallax/qml/Smiley.qml | 46 ++ .../modelviews/stringlistmodel/main.cpp | 76 ++ .../modelviews/stringlistmodel/stringlistmodel.pro | 9 + .../modelviews/stringlistmodel/stringlistmodel.qrc | 5 + .../modelviews/stringlistmodel/view.qml | 15 + .../declarative/modelviews/webview/alerts.html | 5 + examples/declarative/modelviews/webview/alerts.qml | 58 ++ .../declarative/modelviews/webview/autosize.qml | 62 ++ .../modelviews/webview/content/FieldText.qml | 157 ++++ .../modelviews/webview/content/Mapping/Map.qml | 26 + .../modelviews/webview/content/Mapping/map.html | 52 ++ .../modelviews/webview/content/SpinSquare.qml | 25 + .../modelviews/webview/content/pics/cancel.png | Bin 0 -> 1038 bytes .../modelviews/webview/content/pics/ok.png | Bin 0 -> 655 bytes .../declarative/modelviews/webview/googleMaps.qml | 43 + .../declarative/modelviews/webview/inline-html.qml | 15 + .../declarative/modelviews/webview/newwindows.html | 3 + .../declarative/modelviews/webview/newwindows.qml | 31 + .../declarative/modelviews/webview/transparent.qml | 15 + .../modelviews/webview/webview.qmlproject | 16 + examples/declarative/mousearea/mouse.qml | 47 -- .../declarative/mousearea/mousearea.qmlproject | 16 - .../declarative/objectlistmodel/dataobject.cpp | 79 -- examples/declarative/objectlistmodel/dataobject.h | 73 -- examples/declarative/objectlistmodel/main.cpp | 77 -- .../objectlistmodel/objectlistmodel.pro | 18 - .../objectlistmodel/objectlistmodel.qmlproject | 16 - .../objectlistmodel/objectlistmodel.qrc | 5 - examples/declarative/objectlistmodel/view.qml | 16 - examples/declarative/package/Delegate.qml | 48 -- examples/declarative/package/package.qmlproject | 16 - examples/declarative/package/view.qml | 35 - examples/declarative/parallax/parallax.qml | 41 - examples/declarative/parallax/parallax.qmlproject | 16 - examples/declarative/parallax/pics/background.jpg | Bin 209814 -> 0 bytes examples/declarative/parallax/pics/face-smile.png | Bin 15408 -> 0 bytes examples/declarative/parallax/pics/home-page.svg | 445 ----------- examples/declarative/parallax/pics/shadow.png | Bin 425 -> 0 bytes .../declarative/parallax/pics/yast-joystick.png | Bin 2723 -> 0 bytes examples/declarative/parallax/pics/yast-wol.png | Bin 3769 -> 0 bytes examples/declarative/parallax/qml/ParallaxView.qml | 83 -- examples/declarative/parallax/qml/Smiley.qml | 46 -- examples/declarative/plugins/README | 9 - .../plugins/com/nokia/TimeExample/Clock.qml | 50 -- .../plugins/com/nokia/TimeExample/center.png | Bin 765 -> 0 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 20653 -> 0 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 - examples/declarative/plugins/plugin.cpp | 152 ---- examples/declarative/plugins/plugins.pro | 31 - examples/declarative/plugins/plugins.qml | 11 - examples/declarative/plugins/plugins.qmlproject | 16 - examples/declarative/positioners/Button.qml | 38 + examples/declarative/positioners/add.png | Bin 0 -> 1577 bytes examples/declarative/positioners/del.png | Bin 0 -> 1661 bytes examples/declarative/positioners/positioners.qml | 213 +++++ .../declarative/positioners/positioners.qmlproject | 18 + .../positioners/positioners.qmlproject.user | 41 + .../progressbar/content/ProgressBar.qml | 43 - .../declarative/progressbar/content/background.png | Bin 426 -> 0 bytes .../declarative/progressbar/progressbar.qmlproject | 16 - examples/declarative/progressbar/progressbars.qml | 33 - examples/declarative/proxyviewer/main.cpp | 109 --- examples/declarative/proxyviewer/proxyviewer.pro | 9 - examples/declarative/proxyviewer/proxyviewer.qrc | 5 - examples/declarative/proxyviewer/view.qml | 7 - .../declarative/proxywidgets/ProxyWidgets/qmldir | 1 - examples/declarative/proxywidgets/README | 4 - examples/declarative/proxywidgets/proxywidgets.cpp | 97 --- examples/declarative/proxywidgets/proxywidgets.pro | 21 - examples/declarative/proxywidgets/proxywidgets.qml | 70 -- .../proxywidgets/proxywidgets.qmlproject | 16 - examples/declarative/scrollbar/ScrollBar.qml | 33 - examples/declarative/scrollbar/display.qml | 54 -- .../declarative/scrollbar/pics/niagara_falls.jpg | Bin 604121 -> 0 bytes .../declarative/scrollbar/scrollbar.qmlproject | 16 - examples/declarative/searchbox/SearchBox.qml | 65 -- .../images/edit-clear-locationbar-rtl.png | Bin 429 -> 0 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 526 -> 0 bytes .../declarative/searchbox/images/lineedit-bg.png | Bin 426 -> 0 bytes examples/declarative/searchbox/main.qml | 15 - .../declarative/searchbox/searchbox.qmlproject | 16 - .../declarative/slideswitch/content/Switch.qml | 76 -- .../declarative/slideswitch/content/background.svg | 23 - examples/declarative/slideswitch/content/knob.svg | 867 --------------------- examples/declarative/slideswitch/slideswitch.qml | 11 - .../declarative/slideswitch/slideswitch.qmlproject | 16 - examples/declarative/spinner/content/Spinner.qml | 25 - .../declarative/spinner/content/spinner-bg.png | Bin 345 -> 0 bytes .../declarative/spinner/content/spinner-select.png | Bin 320 -> 0 bytes examples/declarative/spinner/main.qml | 18 - examples/declarative/spinner/spinner.qmlproject | 16 - examples/declarative/sql/hello.qml | 31 - examples/declarative/sql/sql.qmlproject | 16 - examples/declarative/sqllocalstorage/hello.qml | 31 + .../sqllocalstorage/sqllocalstorage.qmlproject | 16 + examples/declarative/states/states.qml | 61 -- examples/declarative/states/states.qmlproject | 16 - examples/declarative/states/transitions.qml | 90 --- examples/declarative/states/user.png | Bin 4886 -> 0 bytes examples/declarative/stringlistmodel/main.cpp | 76 -- .../stringlistmodel/stringlistmodel.pro | 9 - .../stringlistmodel/stringlistmodel.qrc | 5 - examples/declarative/stringlistmodel/view.qml | 15 - examples/declarative/tabwidget/TabWidget.qml | 57 -- examples/declarative/tabwidget/tab.png | Bin 507 -> 0 bytes examples/declarative/tabwidget/tabs.qml | 59 -- .../declarative/tabwidget/tabwidget.qmlproject | 16 - examples/declarative/text/fonts/availableFonts.qml | 17 + examples/declarative/text/fonts/banner.qml | 21 + examples/declarative/text/fonts/fonts.qml | 64 ++ examples/declarative/text/fonts/fonts.qmlproject | 16 + .../declarative/text/fonts/fonts/tarzeau_ocr_a.ttf | Bin 0 -> 24544 bytes examples/declarative/text/fonts/hello.qml | 38 + examples/declarative/text/text.qmlproject | 16 + .../threading/threadedlistmodel/dataloader.js | 9 + .../threadedlistmodel/threadedlistmodel.qmlproject | 16 + .../threading/threadedlistmodel/timedisplay.qml | 32 + .../declarative/threading/threading.qmlproject | 16 + .../threading/workerscript/workerscript.js | 15 + .../threading/workerscript/workerscript.qml | 43 + .../threading/workerscript/workerscript.qmlproject | 16 + .../declarative/tic-tac-toe/content/Button.qml | 37 - .../declarative/tic-tac-toe/content/TicTac.qml | 20 - .../declarative/tic-tac-toe/content/pics/board.png | Bin 12258 -> 0 bytes .../declarative/tic-tac-toe/content/pics/o.png | Bin 1470 -> 0 bytes .../declarative/tic-tac-toe/content/pics/x.png | Bin 1331 -> 0 bytes .../declarative/tic-tac-toe/content/tic-tac-toe.js | 145 ---- examples/declarative/tic-tac-toe/tic-tac-toe.qml | 77 -- .../declarative/tic-tac-toe/tic-tac-toe.qmlproject | 16 - .../gestures/experimental-gestures.qml | 36 + .../touchinteraction/gestures/gestures.qmlproject | 16 + .../touchinteraction/mousearea/mouse.qml | 47 ++ .../mousearea/mousearea.qmlproject | 16 + .../touchinteraction/touchinteraction.qmlproject | 16 + examples/declarative/toys/clocks/clocks.qml | 14 + examples/declarative/toys/clocks/clocks.qmlproject | 16 + examples/declarative/toys/clocks/content/Clock.qml | 83 ++ .../declarative/toys/clocks/content/background.png | Bin 0 -> 46895 bytes .../declarative/toys/clocks/content/center.png | Bin 0 -> 765 bytes .../toys/clocks/content/clock-night.png | Bin 0 -> 23359 bytes examples/declarative/toys/clocks/content/clock.png | Bin 0 -> 20653 bytes examples/declarative/toys/clocks/content/hour.png | Bin 0 -> 625 bytes .../declarative/toys/clocks/content/minute.png | Bin 0 -> 625 bytes .../declarative/toys/clocks/content/second.png | Bin 0 -> 303 bytes examples/declarative/toys/dial/content/Dial.qml | 37 + .../declarative/toys/dial/content/background.png | Bin 0 -> 35876 bytes examples/declarative/toys/dial/content/needle.png | Bin 0 -> 342 bytes .../toys/dial/content/needle_shadow.png | Bin 0 -> 632 bytes examples/declarative/toys/dial/content/overlay.png | Bin 0 -> 3564 bytes examples/declarative/toys/dial/dial-example.qml | 44 ++ examples/declarative/toys/dial/dial.qmlproject | 16 + examples/declarative/toys/dynamic/dynamic.qml | 176 +++++ .../declarative/toys/dynamic/dynamic.qmlproject | 16 + examples/declarative/toys/dynamic/images/NOTE | 1 + .../declarative/toys/dynamic/images/face-smile.png | Bin 0 -> 15408 bytes examples/declarative/toys/dynamic/images/moon.png | Bin 0 -> 1757 bytes .../toys/dynamic/images/rabbit_brown.png | Bin 0 -> 1245 bytes .../declarative/toys/dynamic/images/rabbit_bw.png | Bin 0 -> 1759 bytes examples/declarative/toys/dynamic/images/star.png | Bin 0 -> 349 bytes examples/declarative/toys/dynamic/images/sun.png | Bin 0 -> 8153 bytes .../declarative/toys/dynamic/images/tree_s.png | Bin 0 -> 3406 bytes examples/declarative/toys/dynamic/qml/Button.qml | 40 + .../declarative/toys/dynamic/qml/PaletteItem.qml | 19 + .../toys/dynamic/qml/PerspectiveItem.qml | 25 + examples/declarative/toys/dynamic/qml/Sun.qml | 38 + .../declarative/toys/dynamic/qml/itemCreation.js | 65 ++ .../toys/tic-tac-toe/content/Button.qml | 37 + .../toys/tic-tac-toe/content/TicTac.qml | 20 + .../toys/tic-tac-toe/content/pics/board.png | Bin 0 -> 12258 bytes .../toys/tic-tac-toe/content/pics/o.png | Bin 0 -> 1470 bytes .../toys/tic-tac-toe/content/pics/x.png | Bin 0 -> 1331 bytes .../toys/tic-tac-toe/content/tic-tac-toe.js | 145 ++++ .../declarative/toys/tic-tac-toe/tic-tac-toe.qml | 77 ++ .../toys/tic-tac-toe/tic-tac-toe.qmlproject | 16 + examples/declarative/toys/toys.qmlproject | 16 + examples/declarative/toys/tvtennis/tvtennis.qml | 71 ++ .../declarative/toys/tvtennis/tvtennis.qmlproject | 16 + examples/declarative/toys/velocity/Day.qml | 101 +++ examples/declarative/toys/velocity/cork.jpg | Bin 0 -> 149337 bytes examples/declarative/toys/velocity/note-yellow.png | Bin 0 -> 54559 bytes examples/declarative/toys/velocity/tack.png | Bin 0 -> 7282 bytes examples/declarative/toys/velocity/velocity.qml | 75 ++ .../declarative/toys/velocity/velocity.qmlproject | 16 + .../declarative/tutorials/extending/extending.pro | 9 + examples/declarative/tutorials/tutorials.pro | 5 + examples/declarative/tvtennis/tvtennis.qml | 71 -- examples/declarative/tvtennis/tvtennis.qmlproject | 16 - .../ui-components/flipable/content/5_heart.png | Bin 0 -> 3872 bytes .../ui-components/flipable/content/9_club.png | Bin 0 -> 6135 bytes .../ui-components/flipable/content/Card.qml | 38 + .../ui-components/flipable/content/back.png | Bin 0 -> 1418 bytes .../ui-components/flipable/flipable-example.qml | 15 + .../ui-components/flipable/flipable.qmlproject | 16 + .../progressbar/content/ProgressBar.qml | 43 + .../progressbar/content/background.png | Bin 0 -> 426 bytes .../progressbar/progressbar.qmlproject | 16 + .../ui-components/progressbar/progressbars.qml | 33 + .../ui-components/scrollbar/ScrollBar.qml | 33 + .../ui-components/scrollbar/display.qml | 54 ++ .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 0 -> 604121 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 + .../ui-components/searchbox/SearchBox.qml | 65 ++ .../images/edit-clear-locationbar-rtl.png | Bin 0 -> 429 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 0 -> 526 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 0 -> 426 bytes .../declarative/ui-components/searchbox/main.qml | 15 + .../ui-components/searchbox/searchbox.qmlproject | 16 + .../ui-components/slideswitch/content/Switch.qml | 76 ++ .../slideswitch/content/background.svg | 23 + .../ui-components/slideswitch/content/knob.svg | 867 +++++++++++++++++++++ .../ui-components/slideswitch/slideswitch.qml | 11 + .../slideswitch/slideswitch.qmlproject | 16 + .../ui-components/spinner/content/Spinner.qml | 25 + .../ui-components/spinner/content/spinner-bg.png | Bin 0 -> 345 bytes .../spinner/content/spinner-select.png | Bin 0 -> 320 bytes .../declarative/ui-components/spinner/main.qml | 18 + .../ui-components/spinner/spinner.qmlproject | 16 + .../ui-components/tabwidget/TabWidget.qml | 57 ++ .../declarative/ui-components/tabwidget/tab.png | Bin 0 -> 507 bytes .../declarative/ui-components/tabwidget/tabs.qml | 59 ++ .../ui-components/tabwidget/tabwidget.qmlproject | 16 + .../ui-components/ui-components.qmlproject | 16 + examples/declarative/velocity/Day.qml | 101 --- examples/declarative/velocity/cork.jpg | Bin 149337 -> 0 bytes examples/declarative/velocity/note-yellow.png | Bin 54559 -> 0 bytes examples/declarative/velocity/tack.png | Bin 7282 -> 0 bytes examples/declarative/velocity/velocity.qml | 75 -- examples/declarative/velocity/velocity.qmlproject | 16 - examples/declarative/webview/alerts.html | 5 - examples/declarative/webview/alerts.qml | 58 -- examples/declarative/webview/autosize.qml | 62 -- examples/declarative/webview/content/FieldText.qml | 157 ---- .../declarative/webview/content/Mapping/Map.qml | 26 - .../declarative/webview/content/Mapping/map.html | 52 -- .../declarative/webview/content/SpinSquare.qml | 25 - .../declarative/webview/content/pics/cancel.png | Bin 1038 -> 0 bytes examples/declarative/webview/content/pics/ok.png | Bin 655 -> 0 bytes examples/declarative/webview/googleMaps.qml | 43 - examples/declarative/webview/inline-html.qml | 15 - examples/declarative/webview/newwindows.html | 3 - examples/declarative/webview/newwindows.qml | 31 - examples/declarative/webview/transparent.qml | 15 - examples/declarative/webview/webview.qmlproject | 16 - examples/declarative/workerscript/workerscript.js | 15 - examples/declarative/workerscript/workerscript.qml | 43 - .../workerscript/workerscript.qmlproject | 16 - examples/declarative/xml/xml.qmlproject | 16 + .../declarative/xml/xmldata/daringfireball.qml | 47 ++ .../declarative/xml/xmldata/xmldata.qmlproject | 16 + examples/declarative/xml/xmldata/yahoonews.qml | 83 ++ examples/declarative/xml/xmlhttprequest/test.qml | 36 + examples/declarative/xml/xmlhttprequest/test.xml | 5 + .../xml/xmlhttprequest/xmlhttprequest.qmlproject | 16 + examples/declarative/xmldata/daringfireball.qml | 47 -- examples/declarative/xmldata/xmldata.qmlproject | 16 - examples/declarative/xmldata/yahoonews.qml | 83 -- examples/declarative/xmlhttprequest/test.qml | 36 - examples/declarative/xmlhttprequest/test.xml | 5 - .../xmlhttprequest/xmlhttprequest.qmlproject | 16 - .../graphicsitems/qdeclarativeborderimage.cpp | 4 +- .../graphicsitems/qdeclarativeflickable.cpp | 2 +- .../graphicsitems/qdeclarativelistview.cpp | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 4 +- .../qml/qdeclarativeextensionplugin.cpp | 2 +- src/declarative/util/qdeclarativelistmodel.cpp | 4 +- src/declarative/util/qdeclarativepackage.cpp | 4 +- src/declarative/util/qdeclarativexmllistmodel.cpp | 2 +- 751 files changed, 14589 insertions(+), 14519 deletions(-) delete mode 100644 doc/src/snippets/declarative/border-image.qml create mode 100644 doc/src/snippets/declarative/borderimage.qml create mode 100644 examples/declarative/animation/animation.qmlproject create mode 100644 examples/declarative/animation/basics/basics.qmlproject create mode 100644 examples/declarative/animation/basics/color-animation.qml create mode 100644 examples/declarative/animation/basics/images/face-smile.png create mode 100644 examples/declarative/animation/basics/images/moon.png create mode 100644 examples/declarative/animation/basics/images/shadow.png create mode 100644 examples/declarative/animation/basics/images/star.png create mode 100644 examples/declarative/animation/basics/images/sun.png create mode 100644 examples/declarative/animation/basics/property-animation.qml create mode 100644 examples/declarative/animation/behaviors/SideRect.qml create mode 100644 examples/declarative/animation/behaviors/behavior-example.qml create mode 100644 examples/declarative/animation/behaviors/behaviors.qmlproject create mode 100644 examples/declarative/animation/easing/easing.qml create mode 100644 examples/declarative/animation/easing/easing.qmlproject create mode 100644 examples/declarative/animation/states/states.qml create mode 100644 examples/declarative/animation/states/states.qmlproject create mode 100644 examples/declarative/animation/states/transitions.qml create mode 100644 examples/declarative/animation/states/user.png delete mode 100644 examples/declarative/animations/animations.qmlproject delete mode 100644 examples/declarative/animations/color-animation.qml delete mode 100644 examples/declarative/animations/easing.qml delete mode 100644 examples/declarative/animations/images/face-smile.png delete mode 100644 examples/declarative/animations/images/moon.png delete mode 100644 examples/declarative/animations/images/shadow.png delete mode 100644 examples/declarative/animations/images/star.png delete mode 100644 examples/declarative/animations/images/sun.png delete mode 100644 examples/declarative/animations/property-animation.qml delete mode 100644 examples/declarative/aspectratio/aspectratio.qmlproject delete mode 100644 examples/declarative/aspectratio/face_fit.qml delete mode 100644 examples/declarative/aspectratio/face_fit_animated.qml delete mode 100644 examples/declarative/aspectratio/pics/face.png delete mode 100644 examples/declarative/aspectratio/scale_and_crop.qml delete mode 100644 examples/declarative/aspectratio/scale_and_crop_simple.qml delete mode 100644 examples/declarative/aspectratio/scale_and_sidecrop.qml delete mode 100644 examples/declarative/aspectratio/scale_to_fit.qml delete mode 100644 examples/declarative/aspectratio/scale_to_fit_simple.qml delete mode 100644 examples/declarative/behaviors/SideRect.qml delete mode 100644 examples/declarative/behaviors/behavior-example.qml delete mode 100644 examples/declarative/behaviors/behaviors.qmlproject delete mode 100644 examples/declarative/border-image/border-image.qml delete mode 100644 examples/declarative/border-image/border-image.qmlproject delete mode 100644 examples/declarative/border-image/content/MyBorderImage.qml delete mode 100644 examples/declarative/border-image/content/ShadowRectangle.qml delete mode 100644 examples/declarative/border-image/content/bw.png delete mode 100644 examples/declarative/border-image/content/colors-round.sci delete mode 100644 examples/declarative/border-image/content/colors-stretch.sci delete mode 100644 examples/declarative/border-image/content/colors.png delete mode 100644 examples/declarative/border-image/content/shadow.png delete mode 100644 examples/declarative/border-image/shadows.qml delete mode 100644 examples/declarative/clocks/clocks.qml delete mode 100644 examples/declarative/clocks/clocks.qmlproject delete mode 100644 examples/declarative/clocks/content/Clock.qml delete mode 100644 examples/declarative/clocks/content/background.png delete mode 100755 examples/declarative/clocks/content/center.png delete mode 100755 examples/declarative/clocks/content/clock-night.png delete mode 100755 examples/declarative/clocks/content/clock.png delete mode 100755 examples/declarative/clocks/content/hour.png delete mode 100755 examples/declarative/clocks/content/minute.png delete mode 100755 examples/declarative/clocks/content/second.png delete mode 100644 examples/declarative/connections/connections-example.qml delete mode 100644 examples/declarative/connections/connections.qmlproject delete mode 100644 examples/declarative/connections/content/Button.qml delete mode 100644 examples/declarative/connections/content/bg1.jpg delete mode 100644 examples/declarative/connections/content/rotate-left.png delete mode 100644 examples/declarative/connections/content/rotate-right.png create mode 100644 examples/declarative/cppextensions/cppextensions.pro create mode 100644 examples/declarative/cppextensions/cppextensions.qmlproject create mode 100644 examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider-example.qml create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.cpp create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.pro create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject create mode 100644 examples/declarative/cppextensions/plugins/README create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png create mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir create mode 100644 examples/declarative/cppextensions/plugins/plugin.cpp create mode 100644 examples/declarative/cppextensions/plugins/plugins.pro create mode 100644 examples/declarative/cppextensions/plugins/plugins.qml create mode 100644 examples/declarative/cppextensions/plugins/plugins.qmlproject create mode 100644 examples/declarative/cppextensions/proxyviewer/main.cpp create mode 100644 examples/declarative/cppextensions/proxyviewer/proxyviewer.pro create mode 100644 examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc create mode 100644 examples/declarative/cppextensions/proxyviewer/view.qml create mode 100644 examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir create mode 100644 examples/declarative/cppextensions/proxywidgets/README create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.pro create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.qml create mode 100644 examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp create mode 100644 examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/default/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/default/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.h create mode 100644 examples/declarative/cppextensions/referenceexamples/extended/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.qrc create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/example.qml create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.h create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro create mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc delete mode 100644 examples/declarative/dial/content/Dial.qml delete mode 100644 examples/declarative/dial/content/background.png delete mode 100644 examples/declarative/dial/content/needle.png delete mode 100644 examples/declarative/dial/content/needle_shadow.png delete mode 100644 examples/declarative/dial/content/overlay.png delete mode 100644 examples/declarative/dial/dial-example.qml delete mode 100644 examples/declarative/dial/dial.qmlproject delete mode 100644 examples/declarative/dynamic/dynamic.qml delete mode 100644 examples/declarative/dynamic/dynamic.qmlproject delete mode 100644 examples/declarative/dynamic/images/NOTE delete mode 100644 examples/declarative/dynamic/images/face-smile.png delete mode 100644 examples/declarative/dynamic/images/moon.png delete mode 100644 examples/declarative/dynamic/images/rabbit_brown.png delete mode 100644 examples/declarative/dynamic/images/rabbit_bw.png delete mode 100644 examples/declarative/dynamic/images/star.png delete mode 100644 examples/declarative/dynamic/images/sun.png delete mode 100644 examples/declarative/dynamic/images/tree_s.png delete mode 100644 examples/declarative/dynamic/qml/Button.qml delete mode 100644 examples/declarative/dynamic/qml/PaletteItem.qml delete mode 100644 examples/declarative/dynamic/qml/PerspectiveItem.qml delete mode 100644 examples/declarative/dynamic/qml/Sun.qml delete mode 100644 examples/declarative/dynamic/qml/itemCreation.js delete mode 100644 examples/declarative/extending/adding/adding.pro delete mode 100644 examples/declarative/extending/adding/adding.qrc delete mode 100644 examples/declarative/extending/adding/example.qml delete mode 100644 examples/declarative/extending/adding/main.cpp delete mode 100644 examples/declarative/extending/adding/person.cpp delete mode 100644 examples/declarative/extending/adding/person.h delete mode 100644 examples/declarative/extending/attached/attached.pro delete mode 100644 examples/declarative/extending/attached/attached.qrc delete mode 100644 examples/declarative/extending/attached/birthdayparty.cpp delete mode 100644 examples/declarative/extending/attached/birthdayparty.h delete mode 100644 examples/declarative/extending/attached/example.qml delete mode 100644 examples/declarative/extending/attached/main.cpp delete mode 100644 examples/declarative/extending/attached/person.cpp delete mode 100644 examples/declarative/extending/attached/person.h delete mode 100644 examples/declarative/extending/binding/binding.pro delete mode 100644 examples/declarative/extending/binding/binding.qrc delete mode 100644 examples/declarative/extending/binding/birthdayparty.cpp delete mode 100644 examples/declarative/extending/binding/birthdayparty.h delete mode 100644 examples/declarative/extending/binding/example.qml delete mode 100644 examples/declarative/extending/binding/happybirthdaysong.cpp delete mode 100644 examples/declarative/extending/binding/happybirthdaysong.h delete mode 100644 examples/declarative/extending/binding/main.cpp delete mode 100644 examples/declarative/extending/binding/person.cpp delete mode 100644 examples/declarative/extending/binding/person.h delete mode 100644 examples/declarative/extending/coercion/birthdayparty.cpp delete mode 100644 examples/declarative/extending/coercion/birthdayparty.h delete mode 100644 examples/declarative/extending/coercion/coercion.pro delete mode 100644 examples/declarative/extending/coercion/coercion.qrc delete mode 100644 examples/declarative/extending/coercion/example.qml delete mode 100644 examples/declarative/extending/coercion/main.cpp delete mode 100644 examples/declarative/extending/coercion/person.cpp delete mode 100644 examples/declarative/extending/coercion/person.h delete mode 100644 examples/declarative/extending/default/birthdayparty.cpp delete mode 100644 examples/declarative/extending/default/birthdayparty.h delete mode 100644 examples/declarative/extending/default/default.pro delete mode 100644 examples/declarative/extending/default/default.qrc delete mode 100644 examples/declarative/extending/default/example.qml delete mode 100644 examples/declarative/extending/default/main.cpp delete mode 100644 examples/declarative/extending/default/person.cpp delete mode 100644 examples/declarative/extending/default/person.h delete mode 100644 examples/declarative/extending/extended/example.qml delete mode 100644 examples/declarative/extending/extended/extended.pro delete mode 100644 examples/declarative/extending/extended/extended.qrc delete mode 100644 examples/declarative/extending/extended/lineedit.cpp delete mode 100644 examples/declarative/extending/extended/lineedit.h delete mode 100644 examples/declarative/extending/extended/main.cpp delete mode 100644 examples/declarative/extending/extending.pro delete mode 100644 examples/declarative/extending/extending.qmlproject delete mode 100644 examples/declarative/extending/grouped/birthdayparty.cpp delete mode 100644 examples/declarative/extending/grouped/birthdayparty.h delete mode 100644 examples/declarative/extending/grouped/example.qml delete mode 100644 examples/declarative/extending/grouped/grouped.pro delete mode 100644 examples/declarative/extending/grouped/grouped.qrc delete mode 100644 examples/declarative/extending/grouped/main.cpp delete mode 100644 examples/declarative/extending/grouped/person.cpp delete mode 100644 examples/declarative/extending/grouped/person.h delete mode 100644 examples/declarative/extending/properties/birthdayparty.cpp delete mode 100644 examples/declarative/extending/properties/birthdayparty.h delete mode 100644 examples/declarative/extending/properties/example.qml delete mode 100644 examples/declarative/extending/properties/main.cpp delete mode 100644 examples/declarative/extending/properties/person.cpp delete mode 100644 examples/declarative/extending/properties/person.h delete mode 100644 examples/declarative/extending/properties/properties.pro delete mode 100644 examples/declarative/extending/properties/properties.qrc delete mode 100644 examples/declarative/extending/signal/birthdayparty.cpp delete mode 100644 examples/declarative/extending/signal/birthdayparty.h delete mode 100644 examples/declarative/extending/signal/example.qml delete mode 100644 examples/declarative/extending/signal/main.cpp delete mode 100644 examples/declarative/extending/signal/person.cpp delete mode 100644 examples/declarative/extending/signal/person.h delete mode 100644 examples/declarative/extending/signal/signal.pro delete mode 100644 examples/declarative/extending/signal/signal.qrc delete mode 100644 examples/declarative/extending/valuesource/birthdayparty.cpp delete mode 100644 examples/declarative/extending/valuesource/birthdayparty.h delete mode 100644 examples/declarative/extending/valuesource/example.qml delete mode 100644 examples/declarative/extending/valuesource/happybirthdaysong.cpp delete mode 100644 examples/declarative/extending/valuesource/happybirthdaysong.h delete mode 100644 examples/declarative/extending/valuesource/main.cpp delete mode 100644 examples/declarative/extending/valuesource/person.cpp delete mode 100644 examples/declarative/extending/valuesource/person.h delete mode 100644 examples/declarative/extending/valuesource/valuesource.pro delete mode 100644 examples/declarative/extending/valuesource/valuesource.qrc delete mode 100644 examples/declarative/fillmode/content/QtLogo.qml delete mode 100644 examples/declarative/fillmode/content/qt-logo.png delete mode 100644 examples/declarative/fillmode/fillmode.qml delete mode 100644 examples/declarative/fillmode/fillmode.qmlproject delete mode 100644 examples/declarative/flipable/content/5_heart.png delete mode 100644 examples/declarative/flipable/content/9_club.png delete mode 100644 examples/declarative/flipable/content/Card.qml delete mode 100644 examples/declarative/flipable/content/back.png delete mode 100644 examples/declarative/flipable/flipable-example.qml delete mode 100644 examples/declarative/flipable/flipable.qmlproject delete mode 100644 examples/declarative/focus/Core/ContextMenu.qml delete mode 100644 examples/declarative/focus/Core/GridMenu.qml delete mode 100644 examples/declarative/focus/Core/ListViewDelegate.qml delete mode 100644 examples/declarative/focus/Core/ListViews.qml delete mode 100644 examples/declarative/focus/Core/images/arrow.png delete mode 100644 examples/declarative/focus/Core/images/qt-logo.png delete mode 100644 examples/declarative/focus/Core/qmldir delete mode 100644 examples/declarative/focus/focus.qml delete mode 100644 examples/declarative/focus/focus.qmlproject delete mode 100644 examples/declarative/fonts/availableFonts.qml delete mode 100644 examples/declarative/fonts/banner.qml delete mode 100644 examples/declarative/fonts/fonts.qml delete mode 100644 examples/declarative/fonts/fonts.qmlproject delete mode 100644 examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf delete mode 100644 examples/declarative/fonts/hello.qml delete mode 100644 examples/declarative/gestures/experimental-gestures.qml delete mode 100644 examples/declarative/gestures/gestures.qmlproject delete mode 100644 examples/declarative/gridview/gridview-example.qml delete mode 100644 examples/declarative/gridview/gridview.qmlproject delete mode 100644 examples/declarative/gridview/pics/AddressBook_48.png delete mode 100644 examples/declarative/gridview/pics/AudioPlayer_48.png delete mode 100644 examples/declarative/gridview/pics/Camera_48.png delete mode 100644 examples/declarative/gridview/pics/DateBook_48.png delete mode 100644 examples/declarative/gridview/pics/EMail_48.png delete mode 100644 examples/declarative/gridview/pics/TodoList_48.png delete mode 100644 examples/declarative/gridview/pics/VideoPlayer_48.png create mode 100644 examples/declarative/i18n/i18n.qmlproject create mode 100644 examples/declarative/imageelements/borderimage/borderimage.qml create mode 100644 examples/declarative/imageelements/borderimage/borderimage.qmlproject create mode 100644 examples/declarative/imageelements/borderimage/content/MyBorderImage.qml create mode 100644 examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml create mode 100644 examples/declarative/imageelements/borderimage/content/bw.png create mode 100644 examples/declarative/imageelements/borderimage/content/colors-round.sci create mode 100644 examples/declarative/imageelements/borderimage/content/colors-stretch.sci create mode 100644 examples/declarative/imageelements/borderimage/content/colors.png create mode 100644 examples/declarative/imageelements/borderimage/content/shadow.png create mode 100644 examples/declarative/imageelements/borderimage/shadows.qml create mode 100644 examples/declarative/imageelements/image/face_fit.qml create mode 100644 examples/declarative/imageelements/image/face_fit_animated.qml create mode 100644 examples/declarative/imageelements/image/image.qmlproject create mode 100644 examples/declarative/imageelements/image/pics/face.png create mode 100644 examples/declarative/imageelements/image/scale_and_crop.qml create mode 100644 examples/declarative/imageelements/image/scale_and_crop_simple.qml create mode 100644 examples/declarative/imageelements/image/scale_and_sidecrop.qml create mode 100644 examples/declarative/imageelements/image/scale_to_fit.qml create mode 100644 examples/declarative/imageelements/image/scale_to_fit_simple.qml create mode 100644 examples/declarative/imageelements/imageelements.qmlproject delete mode 100644 examples/declarative/imageprovider/ImageProviderCore/qmldir delete mode 100644 examples/declarative/imageprovider/imageprovider-example.qml delete mode 100644 examples/declarative/imageprovider/imageprovider.cpp delete mode 100644 examples/declarative/imageprovider/imageprovider.pro delete mode 100644 examples/declarative/imageprovider/imageprovider.qmlproject delete mode 100644 examples/declarative/images/content/lemonade.jpg delete mode 100644 examples/declarative/images/images.qml delete mode 100644 examples/declarative/images/images.qmlproject create mode 100644 examples/declarative/keyinteraction/focus/Core/ContextMenu.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/GridMenu.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/ListViews.qml create mode 100644 examples/declarative/keyinteraction/focus/Core/images/arrow.png create mode 100644 examples/declarative/keyinteraction/focus/Core/images/qt-logo.png create mode 100644 examples/declarative/keyinteraction/focus/Core/qmldir create mode 100644 examples/declarative/keyinteraction/focus/focus.qml create mode 100644 examples/declarative/keyinteraction/focus/focus.qmlproject create mode 100644 examples/declarative/keyinteraction/keyinteraction.qmlproject delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc delete mode 100644 examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h delete mode 100644 examples/declarative/layouts/graphicsLayouts/main.cpp delete mode 100644 examples/declarative/layouts/layoutItem/layoutItem.pro delete mode 100644 examples/declarative/layouts/layoutItem/layoutItem.qml delete mode 100644 examples/declarative/layouts/layoutItem/layoutItem.qrc delete mode 100644 examples/declarative/layouts/layoutItem/main.cpp delete mode 100644 examples/declarative/layouts/positioners/Button.qml delete mode 100644 examples/declarative/layouts/positioners/add.png delete mode 100644 examples/declarative/layouts/positioners/del.png delete mode 100644 examples/declarative/layouts/positioners/positioners.qml delete mode 100644 examples/declarative/layouts/positioners/positioners.qmlproject delete mode 100644 examples/declarative/layouts/positioners/positioners.qmlproject.user delete mode 100644 examples/declarative/listmodel-threaded/dataloader.js delete mode 100644 examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject delete mode 100644 examples/declarative/listmodel-threaded/timedisplay.qml delete mode 100644 examples/declarative/listview/content/ClickAutoRepeating.qml delete mode 100644 examples/declarative/listview/content/MediaButton.qml delete mode 100644 examples/declarative/listview/content/pics/add.png delete mode 100644 examples/declarative/listview/content/pics/archive-insert.png delete mode 100644 examples/declarative/listview/content/pics/archive-remove.png delete mode 100644 examples/declarative/listview/content/pics/button-pressed.png delete mode 100644 examples/declarative/listview/content/pics/button.png delete mode 100644 examples/declarative/listview/content/pics/del.png delete mode 100644 examples/declarative/listview/content/pics/fruit-salad.jpg delete mode 100644 examples/declarative/listview/content/pics/go-down.png delete mode 100644 examples/declarative/listview/content/pics/go-up.png delete mode 100644 examples/declarative/listview/content/pics/hamburger.jpg delete mode 100644 examples/declarative/listview/content/pics/lemonade.jpg delete mode 100644 examples/declarative/listview/content/pics/list-add.png delete mode 100644 examples/declarative/listview/content/pics/list-remove.png delete mode 100644 examples/declarative/listview/content/pics/moreDown.png delete mode 100644 examples/declarative/listview/content/pics/moreUp.png delete mode 100644 examples/declarative/listview/content/pics/pancakes.jpg delete mode 100644 examples/declarative/listview/content/pics/trash.png delete mode 100644 examples/declarative/listview/content/pics/vegetable-soup.jpg delete mode 100644 examples/declarative/listview/dummydata/MyPetsModel.qml delete mode 100644 examples/declarative/listview/dummydata/Recipes.qml delete mode 100644 examples/declarative/listview/dynamic.qml delete mode 100644 examples/declarative/listview/highlight.qml delete mode 100644 examples/declarative/listview/itemlist.qml delete mode 100644 examples/declarative/listview/listview-example.qml delete mode 100644 examples/declarative/listview/listview.qmlproject delete mode 100644 examples/declarative/listview/recipes.qml delete mode 100644 examples/declarative/listview/sections.qml create mode 100644 examples/declarative/modelviews/gridview/gridview-example.qml create mode 100644 examples/declarative/modelviews/gridview/gridview.qmlproject create mode 100644 examples/declarative/modelviews/gridview/pics/AddressBook_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/Camera_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/DateBook_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/EMail_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/TodoList_48.png create mode 100644 examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png create mode 100644 examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml create mode 100644 examples/declarative/modelviews/listview/content/MediaButton.qml create mode 100644 examples/declarative/modelviews/listview/content/pics/add.png create mode 100644 examples/declarative/modelviews/listview/content/pics/archive-insert.png create mode 100644 examples/declarative/modelviews/listview/content/pics/archive-remove.png create mode 100644 examples/declarative/modelviews/listview/content/pics/button-pressed.png create mode 100644 examples/declarative/modelviews/listview/content/pics/button.png create mode 100644 examples/declarative/modelviews/listview/content/pics/del.png create mode 100644 examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/go-down.png create mode 100644 examples/declarative/modelviews/listview/content/pics/go-up.png create mode 100644 examples/declarative/modelviews/listview/content/pics/hamburger.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/lemonade.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/list-add.png create mode 100644 examples/declarative/modelviews/listview/content/pics/list-remove.png create mode 100644 examples/declarative/modelviews/listview/content/pics/moreDown.png create mode 100644 examples/declarative/modelviews/listview/content/pics/moreUp.png create mode 100644 examples/declarative/modelviews/listview/content/pics/pancakes.jpg create mode 100644 examples/declarative/modelviews/listview/content/pics/trash.png create mode 100644 examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg create mode 100644 examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml create mode 100644 examples/declarative/modelviews/listview/dummydata/Recipes.qml create mode 100644 examples/declarative/modelviews/listview/dynamic.qml create mode 100644 examples/declarative/modelviews/listview/highlight.qml create mode 100644 examples/declarative/modelviews/listview/itemlist.qml create mode 100644 examples/declarative/modelviews/listview/listview-example.qml create mode 100644 examples/declarative/modelviews/listview/listview.qmlproject create mode 100644 examples/declarative/modelviews/listview/recipes.qml create mode 100644 examples/declarative/modelviews/listview/sections.qml create mode 100644 examples/declarative/modelviews/modelviews.pro create mode 100644 examples/declarative/modelviews/modelviews.qmlproject create mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.cpp create mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.h create mode 100644 examples/declarative/modelviews/objectlistmodel/main.cpp create mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro create mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject create mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc create mode 100644 examples/declarative/modelviews/objectlistmodel/view.qml create mode 100644 examples/declarative/modelviews/package/Delegate.qml create mode 100644 examples/declarative/modelviews/package/package.qmlproject create mode 100644 examples/declarative/modelviews/package/view.qml create mode 100644 examples/declarative/modelviews/parallax/parallax.qml create mode 100644 examples/declarative/modelviews/parallax/parallax.qmlproject create mode 100644 examples/declarative/modelviews/parallax/pics/background.jpg create mode 100644 examples/declarative/modelviews/parallax/pics/face-smile.png create mode 100644 examples/declarative/modelviews/parallax/pics/home-page.svg create mode 100644 examples/declarative/modelviews/parallax/pics/shadow.png create mode 100644 examples/declarative/modelviews/parallax/pics/yast-joystick.png create mode 100644 examples/declarative/modelviews/parallax/pics/yast-wol.png create mode 100644 examples/declarative/modelviews/parallax/qml/ParallaxView.qml create mode 100644 examples/declarative/modelviews/parallax/qml/Smiley.qml create mode 100644 examples/declarative/modelviews/stringlistmodel/main.cpp create mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro create mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc create mode 100644 examples/declarative/modelviews/stringlistmodel/view.qml create mode 100644 examples/declarative/modelviews/webview/alerts.html create mode 100644 examples/declarative/modelviews/webview/alerts.qml create mode 100644 examples/declarative/modelviews/webview/autosize.qml create mode 100644 examples/declarative/modelviews/webview/content/FieldText.qml create mode 100644 examples/declarative/modelviews/webview/content/Mapping/Map.qml create mode 100755 examples/declarative/modelviews/webview/content/Mapping/map.html create mode 100644 examples/declarative/modelviews/webview/content/SpinSquare.qml create mode 100644 examples/declarative/modelviews/webview/content/pics/cancel.png create mode 100644 examples/declarative/modelviews/webview/content/pics/ok.png create mode 100644 examples/declarative/modelviews/webview/googleMaps.qml create mode 100644 examples/declarative/modelviews/webview/inline-html.qml create mode 100644 examples/declarative/modelviews/webview/newwindows.html create mode 100644 examples/declarative/modelviews/webview/newwindows.qml create mode 100644 examples/declarative/modelviews/webview/transparent.qml create mode 100644 examples/declarative/modelviews/webview/webview.qmlproject delete mode 100644 examples/declarative/mousearea/mouse.qml delete mode 100644 examples/declarative/mousearea/mousearea.qmlproject delete mode 100644 examples/declarative/objectlistmodel/dataobject.cpp delete mode 100644 examples/declarative/objectlistmodel/dataobject.h delete mode 100644 examples/declarative/objectlistmodel/main.cpp delete mode 100644 examples/declarative/objectlistmodel/objectlistmodel.pro delete mode 100644 examples/declarative/objectlistmodel/objectlistmodel.qmlproject delete mode 100644 examples/declarative/objectlistmodel/objectlistmodel.qrc delete mode 100644 examples/declarative/objectlistmodel/view.qml delete mode 100644 examples/declarative/package/Delegate.qml delete mode 100644 examples/declarative/package/package.qmlproject delete mode 100644 examples/declarative/package/view.qml delete mode 100644 examples/declarative/parallax/parallax.qml delete mode 100644 examples/declarative/parallax/parallax.qmlproject delete mode 100644 examples/declarative/parallax/pics/background.jpg delete mode 100644 examples/declarative/parallax/pics/face-smile.png delete mode 100644 examples/declarative/parallax/pics/home-page.svg delete mode 100644 examples/declarative/parallax/pics/shadow.png delete mode 100644 examples/declarative/parallax/pics/yast-joystick.png delete mode 100644 examples/declarative/parallax/pics/yast-wol.png delete mode 100644 examples/declarative/parallax/qml/ParallaxView.qml delete mode 100644 examples/declarative/parallax/qml/Smiley.qml delete mode 100644 examples/declarative/plugins/README delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/Clock.qml delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/center.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/clock.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/hour.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/minute.png delete mode 100644 examples/declarative/plugins/com/nokia/TimeExample/qmldir delete mode 100644 examples/declarative/plugins/plugin.cpp delete mode 100644 examples/declarative/plugins/plugins.pro delete mode 100644 examples/declarative/plugins/plugins.qml delete mode 100644 examples/declarative/plugins/plugins.qmlproject create mode 100644 examples/declarative/positioners/Button.qml create mode 100644 examples/declarative/positioners/add.png create mode 100644 examples/declarative/positioners/del.png create mode 100644 examples/declarative/positioners/positioners.qml create mode 100644 examples/declarative/positioners/positioners.qmlproject create mode 100644 examples/declarative/positioners/positioners.qmlproject.user delete mode 100644 examples/declarative/progressbar/content/ProgressBar.qml delete mode 100644 examples/declarative/progressbar/content/background.png delete mode 100644 examples/declarative/progressbar/progressbar.qmlproject delete mode 100644 examples/declarative/progressbar/progressbars.qml delete mode 100644 examples/declarative/proxyviewer/main.cpp delete mode 100644 examples/declarative/proxyviewer/proxyviewer.pro delete mode 100644 examples/declarative/proxyviewer/proxyviewer.qrc delete mode 100644 examples/declarative/proxyviewer/view.qml delete mode 100644 examples/declarative/proxywidgets/ProxyWidgets/qmldir delete mode 100644 examples/declarative/proxywidgets/README delete mode 100644 examples/declarative/proxywidgets/proxywidgets.cpp delete mode 100644 examples/declarative/proxywidgets/proxywidgets.pro delete mode 100644 examples/declarative/proxywidgets/proxywidgets.qml delete mode 100644 examples/declarative/proxywidgets/proxywidgets.qmlproject delete mode 100644 examples/declarative/scrollbar/ScrollBar.qml delete mode 100644 examples/declarative/scrollbar/display.qml delete mode 100644 examples/declarative/scrollbar/pics/niagara_falls.jpg delete mode 100644 examples/declarative/scrollbar/scrollbar.qmlproject delete mode 100644 examples/declarative/searchbox/SearchBox.qml delete mode 100644 examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png delete mode 100644 examples/declarative/searchbox/images/lineedit-bg-focus.png delete mode 100644 examples/declarative/searchbox/images/lineedit-bg.png delete mode 100644 examples/declarative/searchbox/main.qml delete mode 100644 examples/declarative/searchbox/searchbox.qmlproject delete mode 100644 examples/declarative/slideswitch/content/Switch.qml delete mode 100644 examples/declarative/slideswitch/content/background.svg delete mode 100644 examples/declarative/slideswitch/content/knob.svg delete mode 100644 examples/declarative/slideswitch/slideswitch.qml delete mode 100644 examples/declarative/slideswitch/slideswitch.qmlproject delete mode 100644 examples/declarative/spinner/content/Spinner.qml delete mode 100644 examples/declarative/spinner/content/spinner-bg.png delete mode 100644 examples/declarative/spinner/content/spinner-select.png delete mode 100644 examples/declarative/spinner/main.qml delete mode 100644 examples/declarative/spinner/spinner.qmlproject delete mode 100644 examples/declarative/sql/hello.qml delete mode 100644 examples/declarative/sql/sql.qmlproject create mode 100644 examples/declarative/sqllocalstorage/hello.qml create mode 100644 examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject delete mode 100644 examples/declarative/states/states.qml delete mode 100644 examples/declarative/states/states.qmlproject delete mode 100644 examples/declarative/states/transitions.qml delete mode 100644 examples/declarative/states/user.png delete mode 100644 examples/declarative/stringlistmodel/main.cpp delete mode 100644 examples/declarative/stringlistmodel/stringlistmodel.pro delete mode 100644 examples/declarative/stringlistmodel/stringlistmodel.qrc delete mode 100644 examples/declarative/stringlistmodel/view.qml delete mode 100644 examples/declarative/tabwidget/TabWidget.qml delete mode 100644 examples/declarative/tabwidget/tab.png delete mode 100644 examples/declarative/tabwidget/tabs.qml delete mode 100644 examples/declarative/tabwidget/tabwidget.qmlproject create mode 100644 examples/declarative/text/fonts/availableFonts.qml create mode 100644 examples/declarative/text/fonts/banner.qml create mode 100644 examples/declarative/text/fonts/fonts.qml create mode 100644 examples/declarative/text/fonts/fonts.qmlproject create mode 100644 examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf create mode 100644 examples/declarative/text/fonts/hello.qml create mode 100644 examples/declarative/text/text.qmlproject create mode 100644 examples/declarative/threading/threadedlistmodel/dataloader.js create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject create mode 100644 examples/declarative/threading/threadedlistmodel/timedisplay.qml create mode 100644 examples/declarative/threading/threading.qmlproject create mode 100644 examples/declarative/threading/workerscript/workerscript.js create mode 100644 examples/declarative/threading/workerscript/workerscript.qml create mode 100644 examples/declarative/threading/workerscript/workerscript.qmlproject delete mode 100644 examples/declarative/tic-tac-toe/content/Button.qml delete mode 100644 examples/declarative/tic-tac-toe/content/TicTac.qml delete mode 100644 examples/declarative/tic-tac-toe/content/pics/board.png delete mode 100644 examples/declarative/tic-tac-toe/content/pics/o.png delete mode 100644 examples/declarative/tic-tac-toe/content/pics/x.png delete mode 100644 examples/declarative/tic-tac-toe/content/tic-tac-toe.js delete mode 100644 examples/declarative/tic-tac-toe/tic-tac-toe.qml delete mode 100644 examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject create mode 100644 examples/declarative/touchinteraction/gestures/experimental-gestures.qml create mode 100644 examples/declarative/touchinteraction/gestures/gestures.qmlproject create mode 100644 examples/declarative/touchinteraction/mousearea/mouse.qml create mode 100644 examples/declarative/touchinteraction/mousearea/mousearea.qmlproject create mode 100644 examples/declarative/touchinteraction/touchinteraction.qmlproject create mode 100644 examples/declarative/toys/clocks/clocks.qml create mode 100644 examples/declarative/toys/clocks/clocks.qmlproject create mode 100644 examples/declarative/toys/clocks/content/Clock.qml create mode 100644 examples/declarative/toys/clocks/content/background.png create mode 100755 examples/declarative/toys/clocks/content/center.png create mode 100755 examples/declarative/toys/clocks/content/clock-night.png create mode 100755 examples/declarative/toys/clocks/content/clock.png create mode 100755 examples/declarative/toys/clocks/content/hour.png create mode 100755 examples/declarative/toys/clocks/content/minute.png create mode 100755 examples/declarative/toys/clocks/content/second.png create mode 100644 examples/declarative/toys/dial/content/Dial.qml create mode 100644 examples/declarative/toys/dial/content/background.png create mode 100644 examples/declarative/toys/dial/content/needle.png create mode 100644 examples/declarative/toys/dial/content/needle_shadow.png create mode 100644 examples/declarative/toys/dial/content/overlay.png create mode 100644 examples/declarative/toys/dial/dial-example.qml create mode 100644 examples/declarative/toys/dial/dial.qmlproject create mode 100644 examples/declarative/toys/dynamic/dynamic.qml create mode 100644 examples/declarative/toys/dynamic/dynamic.qmlproject create mode 100644 examples/declarative/toys/dynamic/images/NOTE create mode 100644 examples/declarative/toys/dynamic/images/face-smile.png create mode 100644 examples/declarative/toys/dynamic/images/moon.png create mode 100644 examples/declarative/toys/dynamic/images/rabbit_brown.png create mode 100644 examples/declarative/toys/dynamic/images/rabbit_bw.png create mode 100644 examples/declarative/toys/dynamic/images/star.png create mode 100644 examples/declarative/toys/dynamic/images/sun.png create mode 100644 examples/declarative/toys/dynamic/images/tree_s.png create mode 100644 examples/declarative/toys/dynamic/qml/Button.qml create mode 100644 examples/declarative/toys/dynamic/qml/PaletteItem.qml create mode 100644 examples/declarative/toys/dynamic/qml/PerspectiveItem.qml create mode 100644 examples/declarative/toys/dynamic/qml/Sun.qml create mode 100644 examples/declarative/toys/dynamic/qml/itemCreation.js create mode 100644 examples/declarative/toys/tic-tac-toe/content/Button.qml create mode 100644 examples/declarative/toys/tic-tac-toe/content/TicTac.qml create mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/board.png create mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/o.png create mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/x.png create mode 100644 examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js create mode 100644 examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml create mode 100644 examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject create mode 100644 examples/declarative/toys/toys.qmlproject create mode 100644 examples/declarative/toys/tvtennis/tvtennis.qml create mode 100644 examples/declarative/toys/tvtennis/tvtennis.qmlproject create mode 100644 examples/declarative/toys/velocity/Day.qml create mode 100644 examples/declarative/toys/velocity/cork.jpg create mode 100644 examples/declarative/toys/velocity/note-yellow.png create mode 100644 examples/declarative/toys/velocity/tack.png create mode 100644 examples/declarative/toys/velocity/velocity.qml create mode 100644 examples/declarative/toys/velocity/velocity.qmlproject create mode 100644 examples/declarative/tutorials/extending/extending.pro create mode 100644 examples/declarative/tutorials/tutorials.pro delete mode 100644 examples/declarative/tvtennis/tvtennis.qml delete mode 100644 examples/declarative/tvtennis/tvtennis.qmlproject create mode 100644 examples/declarative/ui-components/flipable/content/5_heart.png create mode 100644 examples/declarative/ui-components/flipable/content/9_club.png create mode 100644 examples/declarative/ui-components/flipable/content/Card.qml create mode 100644 examples/declarative/ui-components/flipable/content/back.png create mode 100644 examples/declarative/ui-components/flipable/flipable-example.qml create mode 100644 examples/declarative/ui-components/flipable/flipable.qmlproject create mode 100644 examples/declarative/ui-components/progressbar/content/ProgressBar.qml create mode 100644 examples/declarative/ui-components/progressbar/content/background.png create mode 100644 examples/declarative/ui-components/progressbar/progressbar.qmlproject create mode 100644 examples/declarative/ui-components/progressbar/progressbars.qml create mode 100644 examples/declarative/ui-components/scrollbar/ScrollBar.qml create mode 100644 examples/declarative/ui-components/scrollbar/display.qml create mode 100644 examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg create mode 100644 examples/declarative/ui-components/scrollbar/scrollbar.qmlproject create mode 100644 examples/declarative/ui-components/searchbox/SearchBox.qml create mode 100644 examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png create mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png create mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg.png create mode 100644 examples/declarative/ui-components/searchbox/main.qml create mode 100644 examples/declarative/ui-components/searchbox/searchbox.qmlproject create mode 100644 examples/declarative/ui-components/slideswitch/content/Switch.qml create mode 100644 examples/declarative/ui-components/slideswitch/content/background.svg create mode 100644 examples/declarative/ui-components/slideswitch/content/knob.svg create mode 100644 examples/declarative/ui-components/slideswitch/slideswitch.qml create mode 100644 examples/declarative/ui-components/slideswitch/slideswitch.qmlproject create mode 100644 examples/declarative/ui-components/spinner/content/Spinner.qml create mode 100644 examples/declarative/ui-components/spinner/content/spinner-bg.png create mode 100644 examples/declarative/ui-components/spinner/content/spinner-select.png create mode 100644 examples/declarative/ui-components/spinner/main.qml create mode 100644 examples/declarative/ui-components/spinner/spinner.qmlproject create mode 100644 examples/declarative/ui-components/tabwidget/TabWidget.qml create mode 100644 examples/declarative/ui-components/tabwidget/tab.png create mode 100644 examples/declarative/ui-components/tabwidget/tabs.qml create mode 100644 examples/declarative/ui-components/tabwidget/tabwidget.qmlproject create mode 100644 examples/declarative/ui-components/ui-components.qmlproject delete mode 100644 examples/declarative/velocity/Day.qml delete mode 100644 examples/declarative/velocity/cork.jpg delete mode 100644 examples/declarative/velocity/note-yellow.png delete mode 100644 examples/declarative/velocity/tack.png delete mode 100644 examples/declarative/velocity/velocity.qml delete mode 100644 examples/declarative/velocity/velocity.qmlproject delete mode 100644 examples/declarative/webview/alerts.html delete mode 100644 examples/declarative/webview/alerts.qml delete mode 100644 examples/declarative/webview/autosize.qml delete mode 100644 examples/declarative/webview/content/FieldText.qml delete mode 100644 examples/declarative/webview/content/Mapping/Map.qml delete mode 100755 examples/declarative/webview/content/Mapping/map.html delete mode 100644 examples/declarative/webview/content/SpinSquare.qml delete mode 100644 examples/declarative/webview/content/pics/cancel.png delete mode 100644 examples/declarative/webview/content/pics/ok.png delete mode 100644 examples/declarative/webview/googleMaps.qml delete mode 100644 examples/declarative/webview/inline-html.qml delete mode 100644 examples/declarative/webview/newwindows.html delete mode 100644 examples/declarative/webview/newwindows.qml delete mode 100644 examples/declarative/webview/transparent.qml delete mode 100644 examples/declarative/webview/webview.qmlproject delete mode 100644 examples/declarative/workerscript/workerscript.js delete mode 100644 examples/declarative/workerscript/workerscript.qml delete mode 100644 examples/declarative/workerscript/workerscript.qmlproject create mode 100644 examples/declarative/xml/xml.qmlproject create mode 100644 examples/declarative/xml/xmldata/daringfireball.qml create mode 100644 examples/declarative/xml/xmldata/xmldata.qmlproject create mode 100644 examples/declarative/xml/xmldata/yahoonews.qml create mode 100644 examples/declarative/xml/xmlhttprequest/test.qml create mode 100644 examples/declarative/xml/xmlhttprequest/test.xml create mode 100644 examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject delete mode 100644 examples/declarative/xmldata/daringfireball.qml delete mode 100644 examples/declarative/xmldata/xmldata.qmlproject delete mode 100644 examples/declarative/xmldata/yahoonews.qml delete mode 100644 examples/declarative/xmlhttprequest/test.qml delete mode 100644 examples/declarative/xmlhttprequest/test.xml delete mode 100644 examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc index c14208e..27b7f38 100644 --- a/doc/src/declarative/example-slideswitch.qdoc +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -45,7 +45,7 @@ This example shows how to create a reusable switch component in QML. -The code for this example can be found in the \c $QTDIR/examples/declarative/slideswitch directory. +The code for this example can be found in the \c $QTDIR/examples/declarative/ui-components/slideswitch directory. \section1 Overview @@ -61,12 +61,12 @@ The elements that composed the switch are: \endlist \section1 Switch.qml -\snippet examples/declarative/slideswitch/content/Switch.qml 0 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 0 \section1 Walkthrough \section2 Interface -\snippet examples/declarative/slideswitch/content/Switch.qml 1 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 1 This property is the interface of the switch. By default, the switch is off and this property is \c false. It can be used to activate/disactivate the switch or to query its current state. @@ -81,14 +81,14 @@ Text { text: "The switch is on"; visible: mySwitch.on == true } the text will only be visible when the switch is on. \section2 Images and user interaction -\snippet examples/declarative/slideswitch/content/Switch.qml 4 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 4 First, we create the background image of the switch. In order for the switch to toggle when the user clicks on the background, we add a \l{MouseArea} as a child item of the image. A \c MouseArea has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a \c toggle() function. We will see what this function does in a moment. -\snippet examples/declarative/slideswitch/content/Switch.qml 5 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 5 Then, we place the image of the knob on top of the background. The interaction here is a little more complex. We want the knob to move with the finger when it is clicked. That is what the \c drag @@ -96,7 +96,7 @@ property of the \c MouseArea is for. We also want to toggle the switch if the kn in the \c dorelease() function that is called in the \c onReleased property. \section2 States -\snippet examples/declarative/slideswitch/content/Switch.qml 6 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 6 We define the two states of the switch: \list @@ -110,13 +110,13 @@ For more information on states see \l{qmlstates}{QML States}. We add two JavaScript functions to our switch: -\snippet examples/declarative/slideswitch/content/Switch.qml 2 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 2 This first function is called when the background image or the knob are clicked. We simply want the switch to toggle between the two states (\e on and \e off). -\snippet examples/declarative/slideswitch/content/Switch.qml 3 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 3 This second function is called when the knob is released and we want to make sure that the knob does not end up between states (neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing. @@ -124,7 +124,7 @@ This second function is called when the knob is released and we want to make sur For more information on scripts see \l{Integrating JavaScript}. \section2 Transition -\snippet examples/declarative/slideswitch/content/Switch.qml 7 +\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 7 At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. In order for the the knob to move smoothly we add a transition that will animate the \c x property with an easing curve for a duration of 200ms. @@ -133,5 +133,5 @@ For more information on transitions see \l{state-transitions}{QML Transitions}. \section1 Usage The switch can be used in a QML file, like this: -\snippet examples/declarative/slideswitch/slideswitch.qml 0 +\snippet examples/declarative/ui-components/slideswitch/slideswitch.qml 0 */ diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 481617e..cdc308a 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -71,50 +71,92 @@ For example, from your build directory, run: \section1 Examples +\section2 Animation \list -\o \l{declarative/animations}{Animations} -\o \l{declarative/aspectratio}{Aspect Ratio} -\o \l{declarative/behaviors}{Behaviors} -\o \l{declarative/border-image}{Border Image} -\o \l{declarative/clocks}{Clocks} -\o \l{declarative/connections}{Connections} -\o \l{declarative/dial}{Dial} -\o \l{declarative/dynamic}{Dynamic} -\o \l{declarative/extending}{Extending} -\o \l{declarative/fillmode}{Fillmode} -\o \l{declarative/flipable}{Flipable} -\o \l{declarative/focus}{Focus} -\o \l{declarative/fonts}{Fonts} -\o \l{declarative/gridview}{GridView} -\o \l{declarative/imageprovider}{Image Provider} -\o \l{declarative/images}{Images} -\o \l{declarative/layouts}{Layouts} -\o \l{declarative/listmodel-threaded}{ListModel Threaded} -\o \l{declarative/listview}{ListView} -\o \l{declarative/mousearea}{Mouse Area} -\o \l{declarative/objectlistmodel}{Object ListModel} -\o \l{declarative/package}{Package} -\o \l{declarative/parallax}{Parallax} -\o \l{declarative/plugins}{Plugins} -\o \l{declarative/progressbar}{Progress Bars} -\o \l{declarative/proxywidgets}{Proxy Widgets} -\o \l{declarative/scrollbar}{Scrollbar} -\o \l{declarative/searchbox}{Search Box} -\o \l{declarative/slideswitch}{Slide Switch} -\o \l{declarative/sql}{SQL} -\o \l{declarative/states}{States} -\o \l{declarative/stringlistmodel}{String ListModel} -\o \l{declarative/tabwidget}{Tab Widget} -\o \l{declarative/tic-tac-toe}{Tic-Tac-Toe} -\o \l{declarative/tvtennis}{TV Tennis} -\o \l{declarative/velocity}{Velocity} -\o \l{declarative/webview}{WebView} -\o \l{declarative/workerscript}{WorkerScript} -\o \l{declarative/xmldata}{XML Data} -\o \l{declarative/xmlhttprequest}{XMLHttpRequest} +\o \l{declarative/animation/basics}{Basics} +\o \l{declarative/animation/behaviors}{Behaviors} +\o \l{declarative/animation/easing}{Easing} +\o \l{declarative/animation/states}{States} +\endlist + +\section2 Image Elements +\list +\o \l{declarative/imageelements/borderimage}{BorderImage} +\o \l{declarative/imageelements/image}{Image} +\endlist + +\section2 \l{declarative/positioners}{Positioners} + +\section2 Key Interaction +\list +\o \l{declarative/keyinteraction/focus}{Focus} +\endlist +\section2 Touch Interaction +\list +\o \l{declarative/touchinteraction/gestures}{Gestures} +\o \l{declarative/touchinteraction/mousearea}{MouseArea} +\endlist + +\section2 UI Components +\list +\o \l{declarative/ui-components/flipable}{Flipable} +\o \l{declarative/ui-components/progressbar}{Progress bar} +\o \l{declarative/ui-components/scrollbar}{Scroll bar} +\o \l{declarative/ui-components/searchbox}{Search box} +\o \l{declarative/ui-components/slideswitch}{Slide switch} +\o \l{declarative/ui-components/spinner}{Spinner} +\o \l{declarative/ui-components/tabwidget}{Tab widget} \endlist +\section2 Models and Views +\list +\o \l{declarative/modelviews/gridview}{GridView} +\o \l{declarative/modelviews/listview}{ListView} +\o \l{declarative/modelviews/objectlistmodel}{Object list model} +\o \l{declarative/modelviews/package}{Package} +\o \l{declarative/modelviews/parallax}{Parallax} +\o \l{declarative/modelviews/stringlistmodel}{String list model} +\o \l{declarative/modelviews/webview}{WebView} +\endlist + +\section2 XML +\list +\o \l{declarative/xml/xmldata}{XML data} +\o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} +\endlist + +\section2 \l{declarative/i18n}{Internationalization (i18n)} + +\section2 Threading +\list +\o \l{declarative/threading/threadedlistmodel}{Threaded ListModel} +\o \l{declarative/threading/workerscript}{WorkerScript} +\endlist + +\section2 \l{declarative/sqllocalstorage}{SQL Local Storage} + +\section2 C++ Extensions +\list +\o \l{declarative/cppextensions/referenceexamples}{Reference examples} (discussed in \l {Extending QML in C++}) +\o \l{declarative/cppextensions/plugins}{Plugins} +\o \l{declarative/cppextensions/proxywidgets}{QtWidgets} +\o \l{declarative/cppextensions/qgraphicslayouts}{QGraphicsLayouts} +\o \l{declarative/cppextensions/imageprovider}{Image provider} +\o \l{declarative/cppextensions/proxyviewer}{Network access manager factory} +\endlist + +\section2 Toys +\list +\o \l{declarative/toys/clocks}{Clocks} +\o \l{declarative/toys/dial}{Dial} +\o \l{declarative/toys/dynamic}{Dynamic} +\o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} +\o \l{declarative/toys/tvtennis}{TV Tennis} +\o \l{declarative/toys/velocity}{Velocity} +\endlist + + \section1 Demos \list @@ -127,3 +169,4 @@ For example, from your build directory, run: \endlist */ + diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/declarative/extending-examples.qdoc index 611dac1..577ab78 100644 --- a/doc/src/declarative/extending-examples.qdoc +++ b/doc/src/declarative/extending-examples.qdoc @@ -40,13 +40,13 @@ ****************************************************************************/ /*! -\example declarative/extending/adding +\example declarative/cppextensions/referenceexamples/adding \title Extending QML - Adding Types Example The Adding Types Example shows how to add a new element type, \c Person, to QML. The \c Person type can be used from QML like this: -\snippet examples/declarative/extending/adding/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/example.qml 0 \section1 Declare the Person class @@ -55,11 +55,11 @@ with the two properties we want accessible on the QML type - name and shoeSize. Although in this example we use the same name for the C++ class as the QML element, the C++ class can be named differently, or appear in a namespace. -\snippet examples/declarative/extending/adding/person.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/person.h 0 \section1 Define the Person class -\snippet examples/declarative/extending/adding/person.cpp 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/person.cpp 0 The Person class implementation is quite basic. The property accessors simply return members of the object instance. @@ -75,7 +75,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/properties +\example declarative/cppextensions/referenceexamples/properties \title Extending QML - Object and List Property Types Example This example builds on: @@ -88,16 +88,16 @@ properties in QML. This example adds a BirthdayParty element that specifies a birthday party, consisting of a celebrant and a list of guests. People are specified using the People QML type built in the previous example. -\snippet examples/declarative/extending/properties/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/example.qml 0 \section1 Declare the BirthdayParty The BirthdayParty class is declared like this: -\snippet examples/declarative/extending/properties/birthdayparty.h 0 -\snippet examples/declarative/extending/properties/birthdayparty.h 1 -\snippet examples/declarative/extending/properties/birthdayparty.h 2 -\snippet examples/declarative/extending/properties/birthdayparty.h 3 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 3 The class contains a member to store the celebrant object, and also a QList member. @@ -114,7 +114,7 @@ scenarios. The implementation of BirthdayParty property accessors is straight forward. -\snippet examples/declarative/extending/properties/birthdayparty.cpp 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp 0 \section1 Running the example @@ -123,7 +123,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/coercion +\example declarative/cppextensions/referenceexamples/coercion \title Extending QML - Inheritance and Coercion Example This example builds on: @@ -136,11 +136,11 @@ The Inheritance and Coercion Example shows how to use base classes to assign elements of more than one type to a property. It specializes the Person element developed in the previous examples into two elements - a \c Boy and a \c Girl. -\snippet examples/declarative/extending/coercion/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/example.qml 0 \section1 Declare Boy and Girl -\snippet examples/declarative/extending/coercion/person.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/person.h 0 The Person class remains unaltered in this example and the Boy and Girl C++ classes are trivial extensions of it. As an example, the inheritance used here @@ -155,7 +155,7 @@ previous example. However, as we have repurposed the People class as a common base for Boy and Girl, we want to prevent it from being instantiated from QML directly - an explicit Boy or Girl should be instantiated instead. -\snippet examples/declarative/extending/coercion/main.cpp 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/main.cpp 0 While we want to disallow instantiating Person from within QML, it still needs to be registered with the QML engine, so that it can be used as a property type @@ -165,7 +165,7 @@ and other types can be coerced to it. The implementation of Boy and Girl are trivial. -\snippet examples/declarative/extending/coercion/person.cpp 1 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/person.cpp 1 All that is necessary is to implement the constructor, and to register the types and their QML name with the QML engine. @@ -175,7 +175,7 @@ and their QML name with the QML engine. The BirthdayParty element has not changed since the previous example. The celebrant and guests property still use the People type. -\snippet examples/declarative/extending/coercion/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h 0 However, as all three types, Person, Boy and Girl, have been registered with the QML system, on assignment QML automatically (and type-safely) converts the Boy @@ -186,7 +186,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/default +\example declarative/cppextensions/referenceexamples/default \title Extending QML - Default Property Example This example builds on: @@ -200,14 +200,14 @@ The Default Property Example is a minor modification of the \l {Extending QML - Inheritance and Coercion Example} that simplifies the specification of a BirthdayParty through the use of a default property. -\snippet examples/declarative/extending/default/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/default/example.qml 0 \section1 Declaring the BirthdayParty class The only difference between this example and the last, is the addition of the \c DefaultProperty class info annotation. -\snippet examples/declarative/extending/default/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h 0 The default property specifies the property to assign to whenever an explicit property is not specified, in the case of the BirthdayParty element the guest @@ -222,7 +222,7 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! -\example declarative/extending/grouped +\example declarative/cppextensions/referenceexamples/grouped \title Extending QML - Grouped Properties Example This example builds on: @@ -236,7 +236,7 @@ This example builds on: */ /*! -\example declarative/extending/grouped +\example declarative/cppextensions/referenceexamples/grouped \title Extending QML - Attached Properties Example This example builds on: @@ -251,7 +251,7 @@ This example builds on: */ /*! -\example declarative/extending/signal +\example declarative/cppextensions/referenceexamples/signal \title Extending QML - Signal Support Example This example builds on: @@ -267,7 +267,7 @@ This example builds on: */ /*! -\example declarative/extending/valuesource +\example declarative/cppextensions/referenceexamples/valuesource \title Extending QML - Property Value Source Example This example builds on: @@ -284,7 +284,7 @@ This example builds on: */ /*! -\example declarative/extending/binding +\example declarative/cppextensions/referenceexamples/binding \title Extending QML - Binding Example This example builds on: diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 1c159e4..5b695f7 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -56,7 +56,7 @@ QML for their own independent use. \section1 Adding Types \target adding-types -\snippet examples/declarative/extending/adding/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/adding/example.qml 0 The QML snippet shown above instantiates one \c Person instance and sets the \c name and \c shoeSize properties on it. Everything in QML ultimately comes down @@ -121,7 +121,7 @@ the \c Person type. \section1 Object and List Property Types -\snippet examples/declarative/extending/properties/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/properties/example.qml 0 The QML snippet shown above assigns a \c Person object to the \c BirthdayParty's \c host property, and assigns three \c Person objects to the guests property. @@ -136,7 +136,7 @@ Properties that are pointers to objects or Qt interfaces are declared with the Q_PROPERTY() macro, just like other properties. The \c host property declaration looks like this: -\snippet examples/declarative/extending/properties/birthdayparty.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 1 As long as the property type, in this case \c Person, is registered with QML the property can be assigned. @@ -165,14 +165,14 @@ As with object properties, the type \a T must be registered with QML. The \c guest property declaration looks like this: -\snippet examples/declarative/extending/properties/birthdayparty.h 2 +\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 \l {Extending QML - Object and List Property Types Example} shows the complete code used to create the \c BirthdayParty type. \section1 Inheritance and Coercion -\snippet examples/declarative/extending/coercion/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/coercion/example.qml 0 The QML snippet shown above assigns a \c Boy object to the \c BirthdayParty's \c host property, and assigns three other objects to the \c guests property. @@ -214,7 +214,7 @@ code used to create the \c Boy and \c Girl types. \section1 Default Property -\snippet examples/declarative/extending/default/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/default/example.qml 0 The QML snippet shown above assigns a collection of objects to the \c BirthdayParty's default property. @@ -246,7 +246,7 @@ specify a default property. \section1 Grouped Properties -\snippet examples/declarative/extending/grouped/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/grouped/example.qml 1 The QML snippet shown above assigns a number of properties to the \c Boy object, including four properties using the grouped property syntax. @@ -259,7 +259,7 @@ different types through implementation reuse. A grouped property block is implemented as a read-only object property. The \c shoe property shown is declared like this: -\snippet examples/declarative/extending/grouped/person.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/grouped/person.h 1 The \c ShoeDescription type declares the properties available to the grouped property block - in this case the \c size, \c color, \c brand and \c price properties. @@ -271,7 +271,7 @@ implement the \c shoe property grouping. \section1 Attached Properties -\snippet examples/declarative/extending/attached/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/attached/example.qml 1 The QML snippet shown above assigns a date to the \c rsvp property using the attached property syntax. @@ -393,8 +393,8 @@ this situation, but it must not crash. \section1 Signal Support -\snippet examples/declarative/extending/signal/example.qml 0 -\snippet examples/declarative/extending/signal/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/signal/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/signal/example.qml 1 The QML snippet shown above associates the evaluation of a JavaScript expression with the emission of a Qt signal. @@ -406,7 +406,7 @@ signal name: "on" is prepended, and the first letter of the signal name upper cased. For example, the signal used in the example above has the following C++ signature: -\snippet examples/declarative/extending/signal/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h 0 In classes with multiple signals with the same name, only the final signal is accessible as a signal property. Note that signals with the same name @@ -424,8 +424,8 @@ implement the onPartyStarted signal property. \section1 Property Value Sources -\snippet examples/declarative/extending/valuesource/example.qml 0 -\snippet examples/declarative/extending/valuesource/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 1 The QML snippet shown above applies a property value source to the \c announcment property. A property value source generates a value for a property that changes over time. @@ -440,7 +440,7 @@ The example shown here is rather contrived: the \c announcment property of the the \c HappyBirthdaySong value source generates the lyrics of the song "Happy Birthday". -\snippet examples/declarative/extending/valuesource/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h 0 Normally, assigning an object to a string property would not be allowed. In the case of a property value source, rather than assigning the object instance @@ -453,9 +453,9 @@ QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when associating the property value source with a property. The relevant part of the \c HappyBirthdaySong type declaration looks like this: -\snippet examples/declarative/extending/valuesource/happybirthdaysong.h 0 -\snippet examples/declarative/extending/valuesource/happybirthdaysong.h 1 -\snippet examples/declarative/extending/valuesource/happybirthdaysong.h 2 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 1 +\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 2 In all other respects, property value sources are regular QML types. They must be registered with the QML engine using the same macros as other types, and can @@ -471,8 +471,8 @@ implement the \c HappyBirthdaySong property value source. \section1 Property Binding -\snippet examples/declarative/extending/binding/example.qml 0 -\snippet examples/declarative/extending/binding/example.qml 1 +\snippet examples/declarative/cppextensions/referenceexamples/binding/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/binding/example.qml 1 The QML snippet shown above uses a property binding to ensure the \c HappyBirthdaySong's \c name property remains up to date with the \c host. @@ -492,7 +492,7 @@ the property's value. QML relies on the presence of a Here is the \c host property declaration: -\snippet examples/declarative/extending/binding/birthdayparty.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h 0 The NOTIFY attribute is followed by a signal name. It is the responsibility of the class implementer to ensure that whenever the property's value changes, the @@ -531,7 +531,7 @@ subsequently change. The most common case of this is when a type uses only freed when the object is deleted. In these cases, the CONSTANT attribute may be added to the property declaration instead of a NOTIFY signal. -\snippet examples/declarative/extending/binding/person.h 0 +\snippet examples/declarative/cppextensions/referenceexamples/binding/person.h 0 Extreme care must be taken here or applications using your type may misbehave. The CONSTANT attribute should only be used for properties whose value is set, @@ -543,7 +543,7 @@ include NOTIFY signals for use in binding. \section1 Extension Objects -\snippet examples/declarative/extending/extended/example.qml 0 +\snippet examples/declarative/cppextensions/referenceexamples/extended/example.qml 0 The QML snippet shown above adds a new property to an existing C++ type without modifying its source code. diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index bc9830a..2a83e30 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -382,7 +382,7 @@ of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases. The API can be used from JavaScript functions in your QML: -\quotefile declarative/sql/hello.qml +\quotefile declarative/sqllocalstorage/hello.qml The API conforms to the Synchronous API of the HTML5 Web Database API, \link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index 972976f..83380a1 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -110,7 +110,7 @@ of QML UIs: \section2 Loading QGraphicsWidget objects in QML An alternative approach is to expose your existing QGraphicsWidget objects to -QML and construct your scene in QML instead. See the \l {declarative/layouts/graphicsLayouts}{graphics layouts example} +QML and construct your scene in QML instead. See the \l {declarative/cppextensions/qgraphicslayouts}{graphics layouts example} which shows how to expose Qt's graphics layout classes to QML in order to use QGraphicsWidget with classes like QGraphicsLinearLayout and QGraphicsGridLayout. diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 93e4a46..22113ee 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -40,79 +40,89 @@ ****************************************************************************/ /*! - \title Animations - \example declarative/animations + \title Animation basics + \example declarative/animation/basics This example shows how to use animations in QML. */ /*! - \title AspectRatio - \example declarative/aspectratio + \title Behaviors + \example declarative/animation/behaviors +*/ - This example shows how to implement different aspect ratios in QML. +/*! + \title Easing types + \example declarative/animation/easing + + This example shows the different easing modes available for animations. */ /*! - \example declarative/behaviors - \title Behaviors + \title States + \example declarative/animation/states */ /*! \title Border Image - \example declarative/border-image + \example declarative/imageelements/borderimage This example shows how to use a BorderImage in QML. */ /*! - \title Clocks - \example declarative/clocks + \title Image + \example declarative/imageelements/image - This example shows how to create a Clock component and reuse it in a grid. + This example shows uses of the \l Image element in QML. */ /*! - \title Connections - \example declarative/connections - - This example shows how to use a Connection element in QML. + \title Reference examples + \example declarative/cppextensions/referenceexamples */ /*! - \title Dial - \example declarative/dial + \title Plugins + \example declarative/cppextensions/plugins +*/ - This example shows how to implement a dial in QML. +/*! + \title QtWidgets + \example declarative/cppextensions/proxywidgets */ /*! - \title Dynamic - \example declarative/dynamic + \title QGraphicsLayouts + \example declarative/cppextensions/qgraphicslayouts +*/ - This example shows how to create dynamic objects QML. +/*! + \title Image Provider + \example declarative/cppextensions/imageprovider */ /*! - \example declarative/extending - \title Extending + \title Network access manager + \example declarative/cppextensions/proxyviewer */ /*! - \example declarative/fillmode - \title Fillmode + \title Internationlization + \example declarative/i18n */ /*! - \title Flipable - \example declarative/flipable + \title Positioners + \example declarative/positioners - This example shows how to use a Flipable element in QML. + This example shows how to use positioner elements such as Row, Column, + Grid and Flow. */ /*! \title Focus - \example declarative/focus + \example declarative/keyinteraction/focus This example shows how to handle keys and focus in QML. @@ -120,141 +130,149 @@ */ /*! - \example declarative/fonts - \title Fonts + \title GridView + \example declarative/modelviews/gridview */ /*! - \example declarative/gridview - \title GridView + \title ListView + \example declarative/modelviews/listview */ /*! - \example declarative/imageprovider - \title Image Provider + \title Object ListModel + \example declarative/modelviews/objectlistmodel */ /*! - \example declarative/images - \title Images + \title Package + \example declarative/modelviews/package */ /*! - \example declarative/layouts - \title Layouts + \title Parallax + \example declarative/modelviews/parallax */ /*! - \example declarative/listmodel-threaded - \title ListModel Threaded + \title String ListModel + \example declarative/modelviews/stringlistmodel */ /*! - \example declarative/listview - \title ListView + \title WebView + \example declarative/modelviews/webview */ /*! - \example declarative/mousearea - \title Mouse Area + \title SQL Local Storage + \example declarative/sqllocalstorage */ /*! - \example declarative/objectlistmodel - \title Object ListModel + \title Fonts + \example declarative/text/fonts */ /*! - \example declarative/package - \title Package + \title Threaded ListModel + \example declarative/threading/threadedlistmodel */ /*! - \example declarative/parallax - \title Parallax + \title WorkerScript + \example declarative/threading/workerscript */ /*! - \example declarative/plugins - \title Plugins + \title Clocks + \example declarative/toys/clocks + + This example shows how to create a Clock component and reuse it in a grid. */ /*! - \example declarative/progressbar - \title Progress Bars + \title Dial + \example declarative/toys/dial + + This example shows how to implement a dial in QML. */ /*! - \example declarative/proxywidgets - \title Proxy Widgets + \title Dynamic + \example declarative/toys/dynamic + + This example shows how to create dynamic objects QML. */ /*! - \example declarative/scrollbar - \title Scrollbar + \title Tic-Tac-Toe + \example declarative/toys/tic-tac-toe */ /*! - \example declarative/searchbox - \title Search Box + \title TV Tennis + \example declarative/toys/tvtennis */ /*! - \example declarative/slideswitch - \title Slide Switch + \title Velocity + \example declarative/toys/velocity */ /*! - \example declarative/sql - \title SQL + \title Gestures + \example declarative/touchinteraction/gestures */ /*! - \example declarative/states - \title States + \title Mouse Area + \example declarative/touchinteraction/mousearea */ /*! - \example declarative/stringlistmodel - \title String ListModel + \title Flipable + \example declarative/ui-components/flipable + + This example shows how to use a Flipable element in QML. */ /*! - \example declarative/tabwidget - \title Tab Widget + \title Progress Bars + \example declarative/ui-components/progressbar */ /*! - \example declarative/tic-tac-toe - \title Tic-Tac-Toe + \title Scrollbar + \example declarative/ui-components/scrollbar */ /*! - \example declarative/tvtennis - \title TV Tennis + \title Search Box + \example declarative/ui-components/searchbox */ /*! - \example declarative/velocity - \title Velocity + \title Slide Switch + \example declarative/ui-components/slideswitch */ /*! - \example declarative/webview - \title WebView + \title Spinner + \example declarative/ui-components/spinner */ /*! - \example declarative/workerscript - \title WorkerScript + \title Tab Widget + \example declarative/ui-components/tabwidget */ /*! - \example declarative/xmldata \title XML Data + \example declarative/xml/xmldata */ /*! - \example declarative/xmlhttprequest \title XMLHttpRequest + \example declarative/xml/xmlhttprequest */ diff --git a/doc/src/snippets/declarative/border-image.qml b/doc/src/snippets/declarative/border-image.qml deleted file mode 100644 index 9c4247e..0000000 --- a/doc/src/snippets/declarative/border-image.qml +++ /dev/null @@ -1,29 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - color: "white" - width: 520; height: 280 - - Row { - anchors.centerIn: parent - spacing: 50 -//! [0] -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Stretch - verticalTileMode: BorderImage.Stretch - source: "content/colors.png" -} - -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Round - verticalTileMode: BorderImage.Round - source: "content/colors.png" -} -//! [0] - } -} diff --git a/doc/src/snippets/declarative/borderimage.qml b/doc/src/snippets/declarative/borderimage.qml new file mode 100644 index 0000000..9c4247e --- /dev/null +++ b/doc/src/snippets/declarative/borderimage.qml @@ -0,0 +1,29 @@ +import Qt 4.7 + +Rectangle { + id: page + color: "white" + width: 520; height: 280 + + Row { + anchors.centerIn: parent + spacing: 50 +//! [0] +BorderImage { + width: 180; height: 180 + border { left: 30; top: 30; right: 30; bottom: 30 } + horizontalTileMode: BorderImage.Stretch + verticalTileMode: BorderImage.Stretch + source: "content/colors.png" +} + +BorderImage { + width: 180; height: 180 + border { left: 30; top: 30; right: 30; bottom: 30 } + horizontalTileMode: BorderImage.Round + verticalTileMode: BorderImage.Round + source: "content/colors.png" +} +//! [0] + } +} diff --git a/examples/declarative/animation/animation.qmlproject b/examples/declarative/animation/animation.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/animation.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/basics/basics.qmlproject b/examples/declarative/animation/basics/basics.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/basics/basics.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/basics/color-animation.qml b/examples/declarative/animation/basics/color-animation.qml new file mode 100644 index 0000000..61737e9 --- /dev/null +++ b/examples/declarative/animation/basics/color-animation.qml @@ -0,0 +1,70 @@ +import Qt 4.7 +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 + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } + Image { + source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter + rotation: -3 * parent.rotation + } + Image { + source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter + rotation: -parent.rotation + } + 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/animation/basics/images/face-smile.png b/examples/declarative/animation/basics/images/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/animation/basics/images/face-smile.png differ diff --git a/examples/declarative/animation/basics/images/moon.png b/examples/declarative/animation/basics/images/moon.png new file mode 100644 index 0000000..9407b2b Binary files /dev/null and b/examples/declarative/animation/basics/images/moon.png differ diff --git a/examples/declarative/animation/basics/images/shadow.png b/examples/declarative/animation/basics/images/shadow.png new file mode 100644 index 0000000..8270565 Binary files /dev/null and b/examples/declarative/animation/basics/images/shadow.png differ diff --git a/examples/declarative/animation/basics/images/star.png b/examples/declarative/animation/basics/images/star.png new file mode 100644 index 0000000..27ef924 Binary files /dev/null and b/examples/declarative/animation/basics/images/star.png differ diff --git a/examples/declarative/animation/basics/images/sun.png b/examples/declarative/animation/basics/images/sun.png new file mode 100644 index 0000000..7713ca5 Binary files /dev/null and b/examples/declarative/animation/basics/images/sun.png differ diff --git a/examples/declarative/animation/basics/property-animation.qml b/examples/declarative/animation/basics/property-animation.qml new file mode 100644 index 0000000..87ac8ec --- /dev/null +++ b/examples/declarative/animation/basics/property-animation.qml @@ -0,0 +1,63 @@ +import Qt 4.7 + +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 + + // 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 loops to Animation.Infinite makes the + // animation repeat indefinitely, otherwise it would only run once. + SequentialAnimation on y { + loops: Animation.Infinite + + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} diff --git a/examples/declarative/animation/behaviors/SideRect.qml b/examples/declarative/animation/behaviors/SideRect.qml new file mode 100644 index 0000000..d32bd7b --- /dev/null +++ b/examples/declarative/animation/behaviors/SideRect.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +Rectangle { + id: myRect + + property string text + + width: 75; height: 50 + radius: 6 + color: "#646464" + border.width: 4; border.color: "white" + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + focusRect.x = myRect.x; + focusRect.y = myRect.y; + focusRect.text = myRect.text; + } + } +} diff --git a/examples/declarative/animation/behaviors/behavior-example.qml b/examples/declarative/animation/behaviors/behavior-example.qml new file mode 100644 index 0000000..1f17b81 --- /dev/null +++ b/examples/declarative/animation/behaviors/behavior-example.qml @@ -0,0 +1,79 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 400 + color: "#343434" + + Rectangle { + anchors.centerIn: parent + width: 200; height: 200 + radius: 30 + color: "transparent" + border.width: 4; border.color: "white" + + + SideRect { + id: leftRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } + text: "Left" + } + + SideRect { + id: rightRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } + text: "Right" + } + + SideRect { + id: topRect + anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } + text: "Top" + } + + SideRect { + id: bottomRect + anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } + text: "Bottom" + } + + + Rectangle { + id: focusRect + + property string text + + x: 62.5; y: 75; width: 75; height: 50 + radius: 6 + border.width: 4; border.color: "white" + color: "firebrick" + + // Setting an 'elastic' behavior on the focusRect's x property. + Behavior on x { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + // Setting an 'elastic' behavior on the focusRect's y property. + Behavior on y { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + Text { + id: focusText + text: focusRect.text + anchors.centerIn: parent + color: "white" + font.pixelSize: 16; font.bold: true + + // Setting a behavior on the focusText's x property: + // Set the opacity to 0, set the new text value, then set the opacity back to 1. + Behavior on text { + SequentialAnimation { + NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } + PropertyAction { } + NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } + } + } + } + } + } +} diff --git a/examples/declarative/animation/behaviors/behaviors.qmlproject b/examples/declarative/animation/behaviors/behaviors.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/behaviors/behaviors.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/easing/easing.qml b/examples/declarative/animation/easing/easing.qml new file mode 100644 index 0000000..939d43b --- /dev/null +++ b/examples/declarative/animation/easing/easing.qml @@ -0,0 +1,105 @@ +import Qt 4.7 + +Rectangle { + id: window + width: 600; height: 460; color: "#232323" + + ListModel { + id: easingTypes + ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } + ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } + ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } + ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } + ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } + ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } + ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } + ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } + ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } + ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } + ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } + ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } + ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } + ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } + ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } + ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } + ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } + ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } + ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } + ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } + ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } + ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } + ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } + ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } + ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } + ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } + ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } + ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } + ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } + ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } + ListElement { name: "Easing.InElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } + ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } + ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } + ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } + ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } + ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } + ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } + ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } + ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } + ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } + ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } + } + + Component { + id: delegate + + Item { + height: 42; width: window.width + + Text { text: name; 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 { + 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/animation/easing/easing.qmlproject b/examples/declarative/animation/easing/easing.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/easing/easing.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/states/states.qml b/examples/declarative/animation/states/states.qml new file mode 100644 index 0000000..4429e78 --- /dev/null +++ b/examples/declarative/animation/states/states.qml @@ -0,0 +1,61 @@ +import Qt 4.7 + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "user.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] +} diff --git a/examples/declarative/animation/states/states.qmlproject b/examples/declarative/animation/states/states.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animation/states/states.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/animation/states/transitions.qml b/examples/declarative/animation/states/transitions.qml new file mode 100644 index 0000000..ccc7060 --- /dev/null +++ b/examples/declarative/animation/states/transitions.qml @@ -0,0 +1,90 @@ +import Qt 4.7 + +/* + This is exactly the same as states.qml, except that we have appended + a set of transitions to apply animations when the item changes + between each state. +*/ + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "user.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 64; height: 64 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] + + // Transitions define how the properties change when the item moves between each state + transitions: [ + + // When transitioning to 'middleRight' move x,y over a duration of 1 second, + // with OutBounce easing function. + Transition { + from: "*"; to: "middleRight" + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } + }, + + // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, + // with InOutQuad easing function. + Transition { + from: "*"; to: "bottomLeft" + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } + }, + + // For any other state changes move x,y linearly over duration of 200ms. + Transition { + NumberAnimation { properties: "x,y"; duration: 200 } + } + ] +} diff --git a/examples/declarative/animation/states/user.png b/examples/declarative/animation/states/user.png new file mode 100644 index 0000000..dd7d7a2 Binary files /dev/null and b/examples/declarative/animation/states/user.png differ diff --git a/examples/declarative/animations/animations.qmlproject b/examples/declarative/animations/animations.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/animations/animations.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml deleted file mode 100644 index 61737e9..0000000 --- a/examples/declarative/animations/color-animation.qml +++ /dev/null @@ -1,70 +0,0 @@ -import Qt 4.7 -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 - NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } - Image { - source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - rotation: -3 * parent.rotation - } - Image { - source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - rotation: -parent.rotation - } - 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 deleted file mode 100644 index 939d43b..0000000 --- a/examples/declarative/animations/easing.qml +++ /dev/null @@ -1,105 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: window - width: 600; height: 460; color: "#232323" - - ListModel { - id: easingTypes - ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } - ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } - ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } - ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } - ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } - ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } - ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } - ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } - ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } - ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } - ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } - ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } - ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } - ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } - ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } - ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } - ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } - ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } - ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } - ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } - ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } - ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } - ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } - ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } - ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } - ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } - ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } - ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } - ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } - ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } - ListElement { name: "Easing.InElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } - ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } - ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } - ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } - ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } - ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } - ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } - ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } - ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } - ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } - ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } - } - - Component { - id: delegate - - Item { - height: 42; width: window.width - - Text { text: name; 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 { - 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 deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/animations/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/animations/images/moon.png b/examples/declarative/animations/images/moon.png deleted file mode 100644 index 9407b2b..0000000 Binary files a/examples/declarative/animations/images/moon.png and /dev/null differ diff --git a/examples/declarative/animations/images/shadow.png b/examples/declarative/animations/images/shadow.png deleted file mode 100644 index 8270565..0000000 Binary files a/examples/declarative/animations/images/shadow.png and /dev/null differ diff --git a/examples/declarative/animations/images/star.png b/examples/declarative/animations/images/star.png deleted file mode 100644 index 27ef924..0000000 Binary files a/examples/declarative/animations/images/star.png and /dev/null differ diff --git a/examples/declarative/animations/images/sun.png b/examples/declarative/animations/images/sun.png deleted file mode 100644 index 7713ca5..0000000 Binary files a/examples/declarative/animations/images/sun.png and /dev/null differ diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml deleted file mode 100644 index 87ac8ec..0000000 --- a/examples/declarative/animations/property-animation.qml +++ /dev/null @@ -1,63 +0,0 @@ -import Qt 4.7 - -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 - - // 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 loops to Animation.Infinite makes the - // animation repeat indefinitely, otherwise it would only run once. - SequentialAnimation on y { - loops: Animation.Infinite - - // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} diff --git a/examples/declarative/aspectratio/aspectratio.qmlproject b/examples/declarative/aspectratio/aspectratio.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/aspectratio/aspectratio.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml deleted file mode 100644 index 52cd4c2..0000000 --- a/examples/declarative/aspectratio/face_fit.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 - -// 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 deleted file mode 100644 index 63fc9c6..0000000 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.7 - -// 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 { - to: 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 deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/aspectratio/pics/face.png and /dev/null differ diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml deleted file mode 100644 index a438104..0000000 --- a/examples/declarative/aspectratio/scale_and_crop.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.7 - -// 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 deleted file mode 100644 index 1160ec5..0000000 --- a/examples/declarative/aspectratio/scale_and_crop_simple.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -// 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 deleted file mode 100644 index 5593ab8..0000000 --- a/examples/declarative/aspectratio/scale_and_sidecrop.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -// 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 deleted file mode 100644 index 724a36e..0000000 --- a/examples/declarative/aspectratio/scale_to_fit.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -// 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 deleted file mode 100644 index 0e960b4..0000000 --- a/examples/declarative/aspectratio/scale_to_fit_simple.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -// 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/behaviors/SideRect.qml b/examples/declarative/behaviors/SideRect.qml deleted file mode 100644 index d32bd7b..0000000 --- a/examples/declarative/behaviors/SideRect.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: myRect - - property string text - - width: 75; height: 50 - radius: 6 - color: "#646464" - border.width: 4; border.color: "white" - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { - focusRect.x = myRect.x; - focusRect.y = myRect.y; - focusRect.text = myRect.text; - } - } -} diff --git a/examples/declarative/behaviors/behavior-example.qml b/examples/declarative/behaviors/behavior-example.qml deleted file mode 100644 index 1f17b81..0000000 --- a/examples/declarative/behaviors/behavior-example.qml +++ /dev/null @@ -1,79 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 400 - color: "#343434" - - Rectangle { - anchors.centerIn: parent - width: 200; height: 200 - radius: 30 - color: "transparent" - border.width: 4; border.color: "white" - - - SideRect { - id: leftRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } - text: "Left" - } - - SideRect { - id: rightRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } - text: "Right" - } - - SideRect { - id: topRect - anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } - text: "Top" - } - - SideRect { - id: bottomRect - anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } - text: "Bottom" - } - - - Rectangle { - id: focusRect - - property string text - - x: 62.5; y: 75; width: 75; height: 50 - radius: 6 - border.width: 4; border.color: "white" - color: "firebrick" - - // Setting an 'elastic' behavior on the focusRect's x property. - Behavior on x { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - // Setting an 'elastic' behavior on the focusRect's y property. - Behavior on y { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - Text { - id: focusText - text: focusRect.text - anchors.centerIn: parent - color: "white" - font.pixelSize: 16; font.bold: true - - // Setting a behavior on the focusText's x property: - // Set the opacity to 0, set the new text value, then set the opacity back to 1. - Behavior on text { - SequentialAnimation { - NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } - PropertyAction { } - NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } - } - } - } - } - } -} diff --git a/examples/declarative/behaviors/behaviors.qmlproject b/examples/declarative/behaviors/behaviors.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/behaviors/behaviors.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/border-image/border-image.qml b/examples/declarative/border-image/border-image.qml deleted file mode 100644 index c334cea..0000000 --- a/examples/declarative/border-image/border-image.qml +++ /dev/null @@ -1,57 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: page - width: 1030; height: 540 - - Grid { - anchors.centerIn: parent; spacing: 20 - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - } -} diff --git a/examples/declarative/border-image/border-image.qmlproject b/examples/declarative/border-image/border-image.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/border-image/border-image.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml deleted file mode 100644 index b47df7b..0000000 --- a/examples/declarative/border-image/content/MyBorderImage.qml +++ /dev/null @@ -1,50 +0,0 @@ -import Qt 4.7 - -Item { - id: container - - property alias horizontalMode: image.horizontalTileMode - property alias verticalMode: image.verticalTileMode - property alias source: image.source - - property int minWidth - property int minHeight - property int maxWidth - property int maxHeight - property int margin - - width: 240; height: 240 - - BorderImage { - id: image; anchors.centerIn: parent - - SequentialAnimation on width { - loops: Animation.Infinite - NumberAnimation { - from: container.minWidth; to: container.maxWidth - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxWidth; to: container.minWidth - duration: 2000; easing.type: Easing.InOutQuad - } - } - - SequentialAnimation on height { - loops: Animation.Infinite - NumberAnimation { - from: container.minHeight; to: container.maxHeight - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxHeight; to: container.minHeight - duration: 2000; easing.type: Easing.InOutQuad - } - } - - border.top: container.margin - border.left: container.margin - border.bottom: container.margin - border.right: container.margin - } -} diff --git a/examples/declarative/border-image/content/ShadowRectangle.qml b/examples/declarative/border-image/content/ShadowRectangle.qml deleted file mode 100644 index 629478b..0000000 --- a/examples/declarative/border-image/content/ShadowRectangle.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.7 - -Item { - property alias color : rectangle.color - - BorderImage { - anchors.fill: rectangle - anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - border { left: 10; top: 10; right: 10; bottom: 10 } - source: "shadow.png"; smooth: true - } - - Rectangle { id: rectangle; anchors.fill: parent } -} diff --git a/examples/declarative/border-image/content/bw.png b/examples/declarative/border-image/content/bw.png deleted file mode 100644 index 486eaae..0000000 Binary files a/examples/declarative/border-image/content/bw.png and /dev/null differ diff --git a/examples/declarative/border-image/content/colors-round.sci b/examples/declarative/border-image/content/colors-round.sci deleted file mode 100644 index 506f6f5..0000000 --- a/examples/declarative/border-image/content/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index e4989a7..0000000 --- a/examples/declarative/border-image/content/colors-stretch.sci +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index dfb62f3..0000000 Binary files a/examples/declarative/border-image/content/colors.png and /dev/null differ diff --git a/examples/declarative/border-image/content/shadow.png b/examples/declarative/border-image/content/shadow.png deleted file mode 100644 index 431af85..0000000 Binary files a/examples/declarative/border-image/content/shadow.png and /dev/null differ diff --git a/examples/declarative/border-image/shadows.qml b/examples/declarative/border-image/shadows.qml deleted file mode 100644 index a08d133..0000000 --- a/examples/declarative/border-image/shadows.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "gray" - - ShadowRectangle { - anchors.centerIn: parent; width: 250; height: 250 - color: "lightsteelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 200; height: 200 - color: "steelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 150; height: 150 - color: "thistle" - } -} diff --git a/examples/declarative/clocks/clocks.qml b/examples/declarative/clocks/clocks.qml deleted file mode 100644 index 22cf820..0000000 --- a/examples/declarative/clocks/clocks.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - width: 640; height: 240 - color: "#646464" - - Row { - anchors.centerIn: parent - Clock { city: "New York"; shift: -4 } - Clock { city: "Mumbai"; shift: 5.5 } - Clock { city: "Tokyo"; shift: 9 } - } -} diff --git a/examples/declarative/clocks/clocks.qmlproject b/examples/declarative/clocks/clocks.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/clocks/clocks.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml deleted file mode 100644 index 3426e6a..0000000 --- a/examples/declarative/clocks/content/Clock.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -Item { - id: clock - width: 200; height: 230 - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant seconds - property variant shift : 0 - property bool night: false - - function timeChanged() { - var date = new Date; - hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() - night = ( hours < 7 || hours > 19 ) - 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 - to: (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 - to: 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 - to: clock.seconds * 6 - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel - y: 200; anchors.horizontalCenter: parent.horizontalCenter - color: "white" - font.bold: true; font.pixelSize: 14 - style: Text.Raised; styleColor: "black" - } -} diff --git a/examples/declarative/clocks/content/background.png b/examples/declarative/clocks/content/background.png deleted file mode 100644 index a885950..0000000 Binary files a/examples/declarative/clocks/content/background.png and /dev/null differ diff --git a/examples/declarative/clocks/content/center.png b/examples/declarative/clocks/content/center.png deleted file mode 100755 index 7fbd802..0000000 Binary files a/examples/declarative/clocks/content/center.png and /dev/null differ diff --git a/examples/declarative/clocks/content/clock-night.png b/examples/declarative/clocks/content/clock-night.png deleted file mode 100755 index cc7151a..0000000 Binary files a/examples/declarative/clocks/content/clock-night.png and /dev/null differ diff --git a/examples/declarative/clocks/content/clock.png b/examples/declarative/clocks/content/clock.png deleted file mode 100755 index 462edac..0000000 Binary files a/examples/declarative/clocks/content/clock.png and /dev/null differ diff --git a/examples/declarative/clocks/content/hour.png b/examples/declarative/clocks/content/hour.png deleted file mode 100755 index f8061a1..0000000 Binary files a/examples/declarative/clocks/content/hour.png and /dev/null differ diff --git a/examples/declarative/clocks/content/minute.png b/examples/declarative/clocks/content/minute.png deleted file mode 100755 index 1297ec7..0000000 Binary files a/examples/declarative/clocks/content/minute.png and /dev/null differ diff --git a/examples/declarative/clocks/content/second.png b/examples/declarative/clocks/content/second.png deleted file mode 100755 index 4aa9fb5..0000000 Binary files a/examples/declarative/clocks/content/second.png and /dev/null differ diff --git a/examples/declarative/connections/connections-example.qml b/examples/declarative/connections/connections-example.qml deleted file mode 100644 index e65a280..0000000 --- a/examples/declarative/connections/connections-example.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - property int angle: 0 - - width: 640; height: 480 - color: "#646464" - - Image { - id: image - source: "content/bg1.jpg" - anchors.centerIn: parent - rotation: window.angle - - Behavior on rotation { - NumberAnimation { easing.type: Easing.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/connections.qmlproject b/examples/declarative/connections/connections.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/connections/connections.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/connections/content/Button.qml b/examples/declarative/connections/content/Button.qml deleted file mode 100644 index f95afbb..0000000 --- a/examples/declarative/connections/content/Button.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index dfc7cee..0000000 Binary files a/examples/declarative/connections/content/bg1.jpg and /dev/null differ diff --git a/examples/declarative/connections/content/rotate-left.png b/examples/declarative/connections/content/rotate-left.png deleted file mode 100644 index c30387e..0000000 Binary files a/examples/declarative/connections/content/rotate-left.png and /dev/null differ diff --git a/examples/declarative/connections/content/rotate-right.png b/examples/declarative/connections/content/rotate-right.png deleted file mode 100644 index 1b05674..0000000 Binary files a/examples/declarative/connections/content/rotate-right.png and /dev/null differ diff --git a/examples/declarative/cppextensions/cppextensions.pro b/examples/declarative/cppextensions/cppextensions.pro new file mode 100644 index 0000000..caa6092 --- /dev/null +++ b/examples/declarative/cppextensions/cppextensions.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + imageprovider \ + plugins \ + proxyviewer \ + proxywidgets \ + qgraphicslayouts \ + referenceexamples + diff --git a/examples/declarative/cppextensions/cppextensions.qmlproject b/examples/declarative/cppextensions/cppextensions.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/cppextensions.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir new file mode 100644 index 0000000..1028590 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir @@ -0,0 +1,2 @@ +plugin imageprovider + diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml b/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml new file mode 100644 index 0000000..d774112 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml @@ -0,0 +1,25 @@ +import Qt 4.7 +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/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp new file mode 100644 index 0000000..4c4aa94 --- /dev/null +++ b/examples/declarative/cppextensions/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 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + 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/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro new file mode 100644 index 0000000..945a301 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -0,0 +1,25 @@ +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 + +symbian:{ + TARGET.EPOCALLOWDLLDATA=1 +} + +INSTALLS = sources ImageProviderCore_sources target diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject b/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/plugins/README b/examples/declarative/cppextensions/plugins/README new file mode 100644 index 0000000..fe519f8 --- /dev/null +++ b/examples/declarative/cppextensions/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 -I . plugins.qml + diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml new file mode 100644 index 0000000..0048372 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml @@ -0,0 +1,50 @@ +import Qt 4.7 + +Rectangle { + id: clock + width: 200; height: 200; color: "gray" + + property alias city: cityLabel.text + property variant hours + property variant minutes + property variant 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 + to: (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 + to: 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/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png new file mode 100644 index 0000000..7fbd802 Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png new file mode 100644 index 0000000..462edac Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png new file mode 100644 index 0000000..f8061a1 Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png new file mode 100644 index 0000000..1297ec7 Binary files /dev/null and b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir new file mode 100644 index 0000000..e9ef115 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir @@ -0,0 +1,2 @@ +Clock 1.0 Clock.qml +plugin qtimeexampleqmlplugin diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp new file mode 100644 index 0000000..fb51b0c --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugin.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#include +#include +#include + +// Implements a "TimeModel" 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 TimeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(int hour READ hour NOTIFY timeChanged) + Q_PROPERTY(int minute READ minute NOTIFY timeChanged) + +public: + TimeModel(QObject *parent=0) : QObject(parent) + { + if (++instances == 1) { + if (!timer) + timer = new MinuteTimer(qApp); + connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); + timer->start(); + } + } + + ~TimeModel() + { + 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 TimeModel::instances=0; +MinuteTimer *TimeModel::timer=0; + +class QExampleQmlPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); + qmlRegisterType(uri, 1, 0, "Time"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qtimeexampleqmlplugin, QExampleQmlPlugin); diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro new file mode 100644 index 0000000..b501ae3 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugins.pro @@ -0,0 +1,31 @@ +TEMPLATE = lib +DESTDIR = com/nokia/TimeExample +TARGET = qtimeexampleqmlplugin +CONFIG += qt plugin +QT += declarative + +SOURCES += plugin.cpp + +qdeclarativesources.files += \ + com/nokia/TimeExample/qmldir \ + 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 + +symbian:{ + TARGET.EPOCALLOWDLLDATA=1 +} + + +INSTALLS += qdeclarativesources sources target + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/declarative/cppextensions/plugins/plugins.qml b/examples/declarative/cppextensions/plugins/plugins.qml new file mode 100644 index 0000000..449cd9a --- /dev/null +++ b/examples/declarative/cppextensions/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/cppextensions/plugins/plugins.qmlproject b/examples/declarative/cppextensions/plugins/plugins.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugins.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/proxyviewer/main.cpp b/examples/declarative/cppextensions/proxyviewer/main.cpp new file mode 100644 index 0000000..b82d2c9 --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/main.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 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 +#include +#include + +#include +#include +#include + + +/* + This example illustrates using a QNetworkAccessManagerFactory to + create a QNetworkAccessManager with a proxy. + + Usage: + proxyviewer [-host -port ] [file] +*/ + +static QString proxyHost; +static int proxyPort = 0; + +class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +{ +public: + virtual QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *nam = new QNetworkAccessManager(parent); + if (!proxyHost.isEmpty()) { + qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); + QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); + nam->setProxy(proxy); + } + + return nam; +} + +int main(int argc, char ** argv) +{ + QUrl source("qrc:view.qml"); + + QApplication app(argc, argv); + + for (int i = 1; i < argc; ++i) { + QString arg(argv[i]); + if (arg == "-host" && i < argc-1) { + proxyHost = argv[++i]; + } else if (arg == "-port" && i < argc-1) { + arg = argv[++i]; + proxyPort = arg.toInt(); + } else if (arg[0] != '-') { + source = QUrl::fromLocalFile(arg); + } else { + qWarning() << "Usage: proxyviewer [-host -port ] [file]"; + exit(1); + } + } + + QDeclarativeView view; + view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); + + view.setSource(source); + view.show(); + + return app.exec(); +} + diff --git a/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro b/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro new file mode 100644 index 0000000..b6bfa7f --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = proxyviewer +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative network + +# Input +SOURCES += main.cpp +RESOURCES += proxyviewer.qrc diff --git a/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc b/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/cppextensions/proxyviewer/view.qml b/examples/declarative/cppextensions/proxyviewer/view.qml new file mode 100644 index 0000000..7f1bdef --- /dev/null +++ b/examples/declarative/cppextensions/proxyviewer/view.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Image { + width: 100 + height: 100 + source: "http://qt.nokia.com/logo.png" +} diff --git a/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir b/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir new file mode 100644 index 0000000..e55267c --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir @@ -0,0 +1 @@ +plugin proxywidgetsplugin diff --git a/examples/declarative/cppextensions/proxywidgets/README b/examples/declarative/cppextensions/proxywidgets/README new file mode 100644 index 0000000..f50fa22 --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/README @@ -0,0 +1,4 @@ +To run: + + make install + qml proxywidgets.qml diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp b/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp new file mode 100644 index 0000000..067eb2c --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#include +#include + +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 ProxyWidgetsPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "MyPushButton"); + } +}; + +#include "proxywidgets.moc" + +Q_EXPORT_PLUGIN2(proxywidgetsplugin, ProxyWidgetsPlugin); diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro b/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro new file mode 100644 index 0000000..cb07d80 --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib +DESTDIR = ProxyWidgets +TARGET = proxywidgetsplugin +CONFIG += qt plugin +QT += declarative + +SOURCES += proxywidgets.cpp + +sources.files += proxywidgets.pro proxywidgets.cpp proxywidgets.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) + +symbian:{ + TARGET.EPOCALLOWDLLDATA = 1 +} \ No newline at end of file diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml new file mode 100644 index 0000000..88de37f --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml @@ -0,0 +1,70 @@ +import Qt 4.7 +import "ProxyWidgets" 1.0 + +Rectangle { + id: window + + property int margin: 30 + + width: 640; height: 480 + color: palette.window + + SystemPalette { id: palette } + + MyPushButton { + id: button1 + x: margin; y: margin + text: "Right" + transformOriginPoint: Qt.point(width / 2, height / 2) + + onClicked: window.state = "right" + } + + MyPushButton { + id: button2 + x: margin; y: margin + 30 + text: "Bottom" + transformOriginPoint: Qt.point(width / 2, height / 2) + + onClicked: window.state = "bottom" + } + + MyPushButton { + id: button3 + x: margin; y: margin + 60 + text: "Quit" + transformOriginPoint: Qt.point(width / 2, height / 2) + + onClicked: Qt.quit() + } + + 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: Easing.OutQuad } + ColorAnimation { target: window; duration: 600 } + } + } +} diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp new file mode 100644 index 0000000..25cf994 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.cpp @@ -0,0 +1,366 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "graphicslayouts_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +LinearLayoutAttached::LinearLayoutAttached(QObject *parent) +: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter), _spacing(0) +{ +} + +void LinearLayoutAttached::setStretchFactor(int f) +{ + if (_stretch == f) + return; + + _stretch = f; + emit stretchChanged(reinterpret_cast(parent()), _stretch); +} + +void LinearLayoutAttached::setSpacing(int s) +{ + if (_spacing == s) + return; + + _spacing = s; + emit spacingChanged(reinterpret_cast(parent()), _spacing); +} + +void LinearLayoutAttached::setAlignment(Qt::Alignment a) +{ + if (_alignment == a) + return; + + _alignment = a; + emit alignmentChanged(reinterpret_cast(parent()), _alignment); +} + +QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) + : QObject(parent) +{ +} + +QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ +Q_UNUSED(which); +Q_UNUSED(constraint); +return QSizeF(); +} + + +QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) +: QObject(parent) +{ +} + +QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() +{ +} + +void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) +{ +insertItem(index, item); + +//connect attached properties +if (LinearLayoutAttached *obj = attachedProperties.value(item)) { + setStretchFactor(item, obj->stretchFactor()); + setAlignment(item, obj->alignment()); + updateSpacing(item, obj->spacing()); + QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), + this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); + QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), + this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); + QObject::connect(obj, SIGNAL(spacingChanged(QGraphicsLayoutItem*,int)), + this, SLOT(updateSpacing(QGraphicsLayoutItem*,int))); + //### need to disconnect when widget is removed? +} +} + +//### is there a better way to do this? +void QGraphicsLinearLayoutObject::clearChildren() +{ +for (int i = 0; i < count(); ++i) + removeAt(i); +} + +qreal QGraphicsLinearLayoutObject::contentsMargin() const +{ + qreal a,b,c,d; + getContentsMargins(&a, &b, &c, &d); + if(a==b && a==c && a==d) + return a; + return -1; +} + +void QGraphicsLinearLayoutObject::setContentsMargin(qreal m) +{ + setContentsMargins(m,m,m,m); +} + +void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) +{ +QGraphicsLinearLayout::setStretchFactor(item, stretch); +} + +void QGraphicsLinearLayoutObject::updateSpacing(QGraphicsLayoutItem* item, int spacing) +{ + for(int i=0; i < count(); i++){ + if(itemAt(i) == item){ //I do not see the reverse function, which is why we must loop over all items + QGraphicsLinearLayout::setItemSpacing(i, spacing); + return; + } + } +} + +void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) +{ +QGraphicsLinearLayout::setAlignment(item, alignment); +} + +QHash QGraphicsLinearLayoutObject::attachedProperties; +LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) +{ +// ### This is not allowed - you must attach to any object +if (!qobject_cast(obj)) + return 0; +LinearLayoutAttached *rv = new LinearLayoutAttached(obj); +attachedProperties.insert(qobject_cast(obj), rv); +return rv; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// QGraphicsGridLayout-related classes +////////////////////////////////////////////////////////////////////////////////////////////////////// +GridLayoutAttached::GridLayoutAttached(QObject *parent) +: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1), _rowstretch(-1), + _colstretch(-1), _rowspacing(-1), _colspacing(-1), _rowprefheight(-1), _rowmaxheight(-1), _rowminheight(-1), + _rowfixheight(-1), _colprefwidth(-1), _colmaxwidth(-1), _colminwidth(-1), _colfixwidth(-1) +{ +} + +void GridLayoutAttached::setRow(int r) +{ + if (_row == r) + return; + + _row = r; + //emit rowChanged(reinterpret_cast(parent()), _row); +} + +void GridLayoutAttached::setColumn(int c) +{ + if (_column == c) + return; + + _column = c; + //emit columnChanged(reinterpret_cast(parent()), _column); +} + +void GridLayoutAttached::setRowSpan(int rs) +{ + if (_rowspan == rs) + return; + + _rowspan = rs; + //emit rowSpanChanged(reinterpret_cast(parent()), _rowSpan); +} + +void GridLayoutAttached::setColumnSpan(int cs) +{ + if (_colspan == cs) + return; + + _colspan = cs; + //emit columnSpanChanged(reinterpret_cast(parent()), _columnSpan); +} + +void GridLayoutAttached::setAlignment(Qt::Alignment a) +{ + if (_alignment == a) + return; + + _alignment = a; + emit alignmentChanged(reinterpret_cast(parent()), _alignment); +} + +void GridLayoutAttached::setRowStretchFactor(int f) +{ + _rowstretch = f; +} + +void GridLayoutAttached::setColumnStretchFactor(int f) +{ + _colstretch = f; +} + +void GridLayoutAttached::setRowSpacing(int s) +{ + _rowspacing = s; +} + +void GridLayoutAttached::setColumnSpacing(int s) +{ + _colspacing = s; +} + + +QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) +: QObject(parent) +{ +} + +QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() +{ +} + +void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) +{ +//use attached properties +if (QObject *obj = attachedProperties.value(qobject_cast(wid))) { + int row = static_cast(obj)->row(); + int column = static_cast(obj)->column(); + int rowSpan = static_cast(obj)->rowSpan(); + int columnSpan = static_cast(obj)->columnSpan(); + if (row == -1 || column == -1) { + qWarning() << "Must set row and column for an item in a grid layout"; + return; + } + addItem(wid, row, column, rowSpan, columnSpan); +} +} + +void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) +{ +//use attached properties +if (GridLayoutAttached *obj = attachedProperties.value(item)) { + int row = obj->row(); + int column = obj->column(); + int rowSpan = obj->rowSpan(); + int columnSpan = obj->columnSpan(); + Qt::Alignment alignment = obj->alignment(); + if (row == -1 || column == -1) { + qWarning() << "Must set row and column for an item in a grid layout"; + return; + } + if(obj->rowSpacing() != -1) + setRowSpacing(row, obj->rowSpacing()); + if(obj->columnSpacing() != -1) + setColumnSpacing(column, obj->columnSpacing()); + if(obj->rowStretchFactor() != -1) + setRowStretchFactor(row, obj->rowStretchFactor()); + if(obj->columnStretchFactor() != -1) + setColumnStretchFactor(column, obj->columnStretchFactor()); + if(obj->rowPreferredHeight() != -1) + setRowPreferredHeight(row, obj->rowPreferredHeight()); + if(obj->rowMaximumHeight() != -1) + setRowMaximumHeight(row, obj->rowMaximumHeight()); + if(obj->rowMinimumHeight() != -1) + setRowMinimumHeight(row, obj->rowMinimumHeight()); + if(obj->rowFixedHeight() != -1) + setRowFixedHeight(row, obj->rowFixedHeight()); + if(obj->columnPreferredWidth() != -1) + setColumnPreferredWidth(row, obj->columnPreferredWidth()); + if(obj->columnMaximumWidth() != -1) + setColumnMaximumWidth(row, obj->columnMaximumWidth()); + if(obj->columnMinimumWidth() != -1) + setColumnMinimumWidth(row, obj->columnMinimumWidth()); + if(obj->columnFixedWidth() != -1) + setColumnFixedWidth(row, obj->columnFixedWidth()); + addItem(item, row, column, rowSpan, columnSpan); + if (alignment != -1) + setAlignment(item,alignment); + QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), + this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); + //### need to disconnect when widget is removed? +} +} + +//### is there a better way to do this? +void QGraphicsGridLayoutObject::clearChildren() +{ +for (int i = 0; i < count(); ++i) + removeAt(i); +} + +qreal QGraphicsGridLayoutObject::spacing() const +{ +if (verticalSpacing() == horizontalSpacing()) + return verticalSpacing(); +return -1; //### +} + +qreal QGraphicsGridLayoutObject::contentsMargin() const +{ + qreal a,b,c,d; + getContentsMargins(&a, &b, &c, &d); + if(a==b && a==c && a==d) + return a; + return -1; +} + +void QGraphicsGridLayoutObject::setContentsMargin(qreal m) +{ + setContentsMargins(m,m,m,m); +} + + +void QGraphicsGridLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) +{ +QGraphicsGridLayout::setAlignment(item, alignment); +} + +QHash QGraphicsGridLayoutObject::attachedProperties; +GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) +{ +// ### This is not allowed - you must attach to any object +if (!qobject_cast(obj)) + return 0; +GridLayoutAttached *rv = new GridLayoutAttached(obj); +attachedProperties.insert(qobject_cast(obj), rv); +return rv; +} + +QT_END_NAMESPACE diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro new file mode 100644 index 0000000..e5d91b2 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +TARGET = graphicslayouts +QT += declarative + +SOURCES += \ + graphicslayouts.cpp \ + main.cpp + +HEADERS += \ + graphicslayouts_p.h + +RESOURCES += \ + graphicslayouts.qrc diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml new file mode 100644 index 0000000..fcd78d5 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qml @@ -0,0 +1,77 @@ +import Qt 4.7 +import GraphicsLayouts 4.7 + +Item { + id: resizable + + width: 800 + height: 400 + + QGraphicsWidget { + size.width: parent.width/2 + 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 } + } + } + } + QGraphicsWidget { + x: parent.width/2 + size.width: parent.width/2 + size.height: parent.height + + layout: QGraphicsGridLayout { + LayoutItem { + QGraphicsGridLayout.row: 0 + QGraphicsGridLayout.column: 0 + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { color: "red"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 1 + QGraphicsGridLayout.column: 0 + minimumSize: "100x100" + maximumSize: "200x200" + preferredSize: "100x100" + Rectangle { color: "orange"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 2 + QGraphicsGridLayout.column: 0 + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "200x200" + Rectangle { color: "yellow"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 0 + QGraphicsGridLayout.column: 1 + minimumSize: "100x100" + maximumSize: "200x200" + preferredSize: "200x200" + Rectangle { color: "green"; anchors.fill: parent } + } + LayoutItem { + QGraphicsGridLayout.row: 1 + QGraphicsGridLayout.column: 1 + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rectangle { color: "blue"; anchors.fill: parent } + } + } + } +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc new file mode 100644 index 0000000..a199f8d --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts.qrc @@ -0,0 +1,5 @@ + + + graphicslayouts.qml + + diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h new file mode 100644 index 0000000..ea9c614 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicslayouts_p.h @@ -0,0 +1,303 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPHICSLAYOUTS_H +#define GRAPHICSLAYOUTS_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayoutItem) +public: + QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); + + virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; +}; + +class LinearLayoutAttached; +class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) + + Q_PROPERTY(QDeclarativeListProperty children READ children) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) + Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsLinearLayoutObject(QObject * = 0); + ~QGraphicsLinearLayoutObject(); + + QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } + + static LinearLayoutAttached *qmlAttachedProperties(QObject *); + + qreal contentsMargin() const; + void setContentsMargin(qreal); + +private Q_SLOTS: + void updateStretch(QGraphicsLayoutItem*,int); + void updateSpacing(QGraphicsLayoutItem*,int); + void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); + +private: + friend class LinearLayoutAttached; + void clearChildren(); + void insertLayoutItem(int, QGraphicsLayoutItem *); + static QHash attachedProperties; + + static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { + static_cast(prop->object)->insertLayoutItem(-1, item); + } + + static void children_clear(QDeclarativeListProperty *prop) { + static_cast(prop->object)->clearChildren(); + } + + static int children_count(QDeclarativeListProperty *prop) { + return static_cast(prop->object)->count(); + } + + static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { + return static_cast(prop->object)->itemAt(index); + } +}; + +class GridLayoutAttached; +class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) + + Q_PROPERTY(QDeclarativeListProperty children READ children) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) + Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) + Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) + Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsGridLayoutObject(QObject * = 0); + ~QGraphicsGridLayoutObject(); + + QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } + + qreal spacing() const; + qreal contentsMargin() const; + void setContentsMargin(qreal); + + static GridLayoutAttached *qmlAttachedProperties(QObject *); + +private Q_SLOTS: + void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); + +private: + friend class GraphicsLayoutAttached; + void addWidget(QGraphicsWidget *); + void clearChildren(); + void addLayoutItem(QGraphicsLayoutItem *); + static QHash attachedProperties; + + static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { + static_cast(prop->object)->addLayoutItem(item); + } + + static void children_clear(QDeclarativeListProperty *prop) { + static_cast(prop->object)->clearChildren(); + } + + static int children_count(QDeclarativeListProperty *prop) { + return static_cast(prop->object)->count(); + } + + static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { + return static_cast(prop->object)->itemAt(index); + } +}; + +class LinearLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) + Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) +public: + LinearLayoutAttached(QObject *parent); + + int stretchFactor() const { return _stretch; } + void setStretchFactor(int f); + Qt::Alignment alignment() const { return _alignment; } + void setAlignment(Qt::Alignment a); + int spacing() const { return _spacing; } + void setSpacing(int s); + +Q_SIGNALS: + void stretchChanged(QGraphicsLayoutItem*,int); + void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); + void spacingChanged(QGraphicsLayoutItem*,int); + +private: + int _stretch; + Qt::Alignment _alignment; + int _spacing; +}; + +class GridLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int row READ row WRITE setRow) + Q_PROPERTY(int column READ column WRITE setColumn) + Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) + Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) + Q_PROPERTY(int rowStretchFactor READ rowStretchFactor WRITE setRowStretchFactor) + Q_PROPERTY(int columnStretchFactor READ columnStretchFactor WRITE setColumnStretchFactor) + Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) + Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) + Q_PROPERTY(int rowPreferredHeight READ rowPreferredHeight WRITE setRowPreferredHeight) + Q_PROPERTY(int rowMinimumHeight READ rowMinimumHeight WRITE setRowMinimumHeight) + Q_PROPERTY(int rowMaximumHeight READ rowMaximumHeight WRITE setRowMaximumHeight) + Q_PROPERTY(int rowFixedHeight READ rowFixedHeight WRITE setRowFixedHeight) + Q_PROPERTY(int columnPreferredWidth READ columnPreferredWidth WRITE setColumnPreferredWidth) + Q_PROPERTY(int columnMaximumWidth READ columnMaximumWidth WRITE setColumnMaximumWidth) + Q_PROPERTY(int columnMinimumWidth READ columnMinimumWidth WRITE setColumnMinimumWidth) + Q_PROPERTY(int columnFixedWidth READ columnFixedWidth WRITE setColumnFixedWidth) + +public: + GridLayoutAttached(QObject *parent); + + int row() const { return _row; } + void setRow(int r); + + int column() const { return _column; } + void setColumn(int c); + + int rowSpan() const { return _rowspan; } + void setRowSpan(int rs); + + int columnSpan() const { return _colspan; } + void setColumnSpan(int cs); + + Qt::Alignment alignment() const { return _alignment; } + void setAlignment(Qt::Alignment a); + + int rowStretchFactor() const { return _rowstretch; } + void setRowStretchFactor(int f); + int columnStretchFactor() const { return _colstretch; } + void setColumnStretchFactor(int f); + + int rowSpacing() const { return _rowspacing; } + void setRowSpacing(int s); + int columnSpacing() const { return _colspacing; } + void setColumnSpacing(int s); + + int rowPreferredHeight() const { return _rowprefheight; } + void setRowPreferredHeight(int s) { _rowprefheight = s; } + + int rowMaximumHeight() const { return _rowmaxheight; } + void setRowMaximumHeight(int s) { _rowmaxheight = s; } + + int rowMinimumHeight() const { return _rowminheight; } + void setRowMinimumHeight(int s) { _rowminheight = s; } + + int rowFixedHeight() const { return _rowfixheight; } + void setRowFixedHeight(int s) { _rowfixheight = s; } + + int columnPreferredWidth() const { return _colprefwidth; } + void setColumnPreferredWidth(int s) { _colprefwidth = s; } + + int columnMaximumWidth() const { return _colmaxwidth; } + void setColumnMaximumWidth(int s) { _colmaxwidth = s; } + + int columnMinimumWidth() const { return _colminwidth; } + void setColumnMinimumWidth(int s) { _colminwidth = s; } + + int columnFixedWidth() const { return _colfixwidth; } + void setColumnFixedWidth(int s) { _colfixwidth = s; } + +Q_SIGNALS: + void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); + +private: + int _row; + int _column; + int _rowspan; + int _colspan; + Qt::Alignment _alignment; + int _rowstretch; + int _colstretch; + int _rowspacing; + int _colspacing; + int _rowprefheight; + int _rowmaxheight; + int _rowminheight; + int _rowfixheight; + int _colprefwidth; + int _colmaxwidth; + int _colminwidth; + int _colfixwidth; +}; + +QT_END_NAMESPACE + +QML_DECLARE_INTERFACE(QGraphicsLayoutItem) +QML_DECLARE_INTERFACE(QGraphicsLayout) +QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) +QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) +QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QGraphicsGridLayoutObject) +QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif // GRAPHICSLAYOUTS_H diff --git a/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp new file mode 100644 index 0000000..89b69bf --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "graphicslayouts_p.h" +#include + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + QDeclarativeView view; + qmlRegisterInterface("QGraphicsLayoutItem"); + qmlRegisterInterface("QGraphicsLayout"); + qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayoutStretchItem"); + qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayout"); + qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsGridLayout"); + view.setSource(QUrl(":graphicslayouts.qml")); + view.show(); + return app.exec(); +}; + diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro new file mode 100644 index 0000000..4a3fc73 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.pro @@ -0,0 +1,13 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue May 4 13:36:26 2010 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += layoutItem.qrc diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml new file mode 100644 index 0000000..460c564 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +LayoutItem {//Sized by the layout + id: resizable + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rectangle { color: "yellow"; anchors.fill: parent } + Rectangle { + width: 100; height: 100; + anchors.top: parent.top; + anchors.right: parent.right; + color: "green"; + } +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc new file mode 100644 index 0000000..deb0fba --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qrc @@ -0,0 +1,5 @@ + + + layoutItem.qml + + diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.cpp new file mode 100644 index 0000000..a104251 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/main.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 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 +#include +#include +#include +#include +#include +#include + +/* This example demonstrates using a LayoutItem to let QML snippets integrate + nicely with existing QGraphicsView applications designed with GraphicsLayouts +*/ +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + //Set up a graphics scene with a QGraphicsWidget and Layout + QGraphicsView view; + QGraphicsScene scene; + QGraphicsWidget *widget = new QGraphicsWidget(); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); + widget->setLayout(layout); + scene.addItem(widget); + view.setScene(&scene); + //Add the QML snippet into the layout + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl(":layoutItem.qml")); + QGraphicsLayoutItem* obj = qobject_cast(c.create()); + layout->addItem(obj); + + widget->setGeometry(QRectF(0,0, 400,400)); + view.show(); + return app.exec(); +} diff --git a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.pro b/examples/declarative/cppextensions/referenceexamples/adding/adding.pro new file mode 100644 index 0000000..6072de4 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/adding/adding.qrc b/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/adding/example.qml b/examples/declarative/cppextensions/referenceexamples/adding/example.qml new file mode 100644 index 0000000..dc891e7 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/example.qml @@ -0,0 +1,8 @@ +// ![0] +import People 1.0 + +Person { + name: "Bob Jones" + shoeSize: 12 +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp new file mode 100644 index 0000000..7b33895 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/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 +#include +#include +#include +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); +//![0] + qmlRegisterType("People", 1,0, "Person"); +//![0] + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + Person *person = qobject_cast(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/cppextensions/referenceexamples/adding/person.cpp b/examples/declarative/cppextensions/referenceexamples/adding/person.cpp new file mode 100644 index 0000000..cdf08e0 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/adding/person.h b/examples/declarative/cppextensions/referenceexamples/adding/person.h new file mode 100644 index 0000000..d6de9a9 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/adding/person.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +// ![0] +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; +}; +// ![0] + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.pro b/examples/declarative/cppextensions/referenceexamples/attached/attached.pro new file mode 100644 index 0000000..f6d76ed --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/attached/attached.qrc b/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp new file mode 100644 index 0000000..7fa1748 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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/declarative/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h new file mode 100644 index 0000000..1c66f8c --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#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; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); +private: + Person *m_host; + QList m_guests; +}; + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/example.qml b/examples/declarative/cppextensions/referenceexamples/attached/example.qml new file mode 100644 index 0000000..50f0a32 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/example.qml @@ -0,0 +1,31 @@ +import People 1.0 + +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + // ![1] + Boy { + name: "Leo Hodges" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + + BirthdayParty.rsvp: "2009-07-06" + } + // ![1] + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + + BirthdayParty.rsvp: "2009-07-01" + } +} + diff --git a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp new file mode 100644 index 0000000..f1055ae --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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(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/cppextensions/referenceexamples/attached/person.cpp b/examples/declarative/cppextensions/referenceexamples/attached/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/attached/person.h b/examples/declarative/cppextensions/referenceexamples/attached/person.h new file mode 100644 index 0000000..2f444c5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/attached/person.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include + +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; +}; + +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; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.pro b/examples/declarative/cppextensions/referenceexamples/binding/binding.pro new file mode 100644 index 0000000..896ce25 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/binding.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET = binding +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.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/cppextensions/referenceexamples/binding/binding.qrc b/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp new file mode 100644 index 0000000..000bb1f --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + if (c == m_host) return; + m_host = c; + emit hostChanged(); +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h new file mode 100644 index 0000000..c3f033e --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#include +#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; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) +// ![0] + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + void hostChanged(); + +private: + Person *m_host; + QList m_guests; +}; + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/example.qml b/examples/declarative/cppextensions/referenceexamples/binding/example.qml new file mode 100644 index 0000000..82eb3be --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/example.qml @@ -0,0 +1,37 @@ +import People 1.0 + +// ![0] +BirthdayParty { + id: theParty + + HappyBirthdaySong on announcement { name: theParty.host.name } + + host: 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: "Leo 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/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp new file mode 100644 index 0000000..a40e7fb --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.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 "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(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 HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::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 HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h new file mode 100644 index 0000000..e825b86 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include + +#include + +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_INTERFACES(QDeclarativePropertyValueSource) +public: + HappyBirthdaySong(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; +}; + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp new file mode 100644 index 0000000..2495676 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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(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/cppextensions/referenceexamples/binding/person.cpp b/examples/declarative/cppextensions/referenceexamples/binding/person.cpp new file mode 100644 index 0000000..9a2248f --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/binding/person.h b/examples/declarative/cppextensions/referenceexamples/binding/person.h new file mode 100644 index 0000000..2a68da0 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/binding/person.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include + +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; +}; + +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; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp new file mode 100644 index 0000000..4f415a3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h new file mode 100644 index 0000000..ee77e9a --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/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 +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![0] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro new file mode 100644 index 0000000..c8daed8 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/example.qml b/examples/declarative/cppextensions/referenceexamples/coercion/example.qml new file mode 100644 index 0000000..7b45950 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/example.qml @@ -0,0 +1,15 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Boy { name: "Leo Hodges" }, + Boy { name: "Jack Smith" }, + Girl { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp new file mode 100644 index 0000000..2c7b545 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); +// ![0] + qmlRegisterType(); +// ![0] + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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/cppextensions/referenceexamples/coercion/person.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp new file mode 100644 index 0000000..5b5203a --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/coercion/person.h b/examples/declarative/cppextensions/referenceexamples/coercion/person.h new file mode 100644 index 0000000..1c95da7 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/coercion/person.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 + +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; +}; + + +// ![0] +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +// ![0] + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp new file mode 100644 index 0000000..4f415a3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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/cppextensions/referenceexamples/default/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h new file mode 100644 index 0000000..9741040 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/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 +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![0] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.pro b/examples/declarative/cppextensions/referenceexamples/default/default.pro new file mode 100644 index 0000000..32aff0b --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/default/default.qrc b/examples/declarative/cppextensions/referenceexamples/default/default.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/default.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/default/example.qml b/examples/declarative/cppextensions/referenceexamples/default/example.qml new file mode 100644 index 0000000..c0f3cbb --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/example.qml @@ -0,0 +1,14 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + + Boy { name: "Leo Hodges" } + Boy { name: "Jack Smith" } + Girl { name: "Anne Brown" } +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/default/main.cpp b/examples/declarative/cppextensions/referenceexamples/default/main.cpp new file mode 100644 index 0000000..2ffd180 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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/cppextensions/referenceexamples/default/person.cpp b/examples/declarative/cppextensions/referenceexamples/default/person.cpp new file mode 100644 index 0000000..69216d3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/default/person.h b/examples/declarative/cppextensions/referenceexamples/default/person.h new file mode 100644 index 0000000..3e56860 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/default/person.h @@ -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$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +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; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/example.qml b/examples/declarative/cppextensions/referenceexamples/extended/example.qml new file mode 100644 index 0000000..985ce20 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/example.qml @@ -0,0 +1,7 @@ +import People 1.0 + +// ![0] +QLineEdit { + leftMargin: 20 +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.pro b/examples/declarative/cppextensions/referenceexamples/extended/extended.pro new file mode 100644 index 0000000..97af286 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/extended/extended.qrc b/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp new file mode 100644 index 0000000..0e521ec --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 + +LineEditExtension::LineEditExtension(QObject *object) +: QObject(object), m_lineedit(static_cast(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); +} + + diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h new file mode 100644 index 0000000..3a464b0 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 + +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/cppextensions/referenceexamples/extended/main.cpp b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp new file mode 100644 index 0000000..ca7242d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include +#include "lineedit.h" + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterExtendedType("People", 1,0, "QLineEdit"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + QLineEdit *edit = qobject_cast(component.create()); + + if (edit) { + edit->show(); + return app.exec(); + } else { + qWarning() << "An error occured"; + return 0; + } +} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp new file mode 100644 index 0000000..4f415a3 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h new file mode 100644 index 0000000..31d21b2 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml new file mode 100644 index 0000000..91b7a06 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml @@ -0,0 +1,33 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo 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/cppextensions/referenceexamples/grouped/grouped.pro b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro new file mode 100644 index 0000000..576e1d2 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp new file mode 100644 index 0000000..baf32cf --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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/cppextensions/referenceexamples/grouped/person.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/grouped/person.h b/examples/declarative/cppextensions/referenceexamples/grouped/person.h new file mode 100644 index 0000000..a031e69 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/grouped/person.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include + +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; +}; + +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; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp new file mode 100644 index 0000000..27d17a1 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +// ![0] +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h new file mode 100644 index 0000000..39ce9ba --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.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 BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] +// ![1] + Q_PROPERTY(Person *host READ host WRITE setHost) +// ![1] +// ![2] + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![2] +// ![3] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![3] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/example.qml b/examples/declarative/cppextensions/referenceexamples/properties/example.qml new file mode 100644 index 0000000..35abdd6 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/example.qml @@ -0,0 +1,15 @@ +import People 1.0 + +// ![0] +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp new file mode 100644 index 0000000..85e9584 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->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/cppextensions/referenceexamples/properties/person.cpp b/examples/declarative/cppextensions/referenceexamples/properties/person.cpp new file mode 100644 index 0000000..92c54f5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/properties/person.h b/examples/declarative/cppextensions/referenceexamples/properties/person.h new file mode 100644 index 0000000..0029b09 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/person.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 + +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; +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.pro b/examples/declarative/cppextensions/referenceexamples/properties/properties.pro new file mode 100644 index 0000000..a8f4301 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/properties/properties.qrc b/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro new file mode 100644 index 0000000..169c7ab --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + adding \ + attached \ + binding \ + coercion \ + default \ + extended \ + grouped \ + properties \ + signal \ + valuesource diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp new file mode 100644 index 0000000..740c8c9 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h new file mode 100644 index 0000000..ae4dd39 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#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; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty 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_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/example.qml b/examples/declarative/cppextensions/referenceexamples/signal/example.qml new file mode 100644 index 0000000..83d6a23 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/example.qml @@ -0,0 +1,32 @@ +import People 1.0 + +// ![0] +BirthdayParty { + onPartyStarted: console.log("This party started rockin' at " + time); +// ![0] + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo 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/cppextensions/referenceexamples/signal/main.cpp b/examples/declarative/cppextensions/referenceexamples/signal/main.cpp new file mode 100644 index 0000000..453f688 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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(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/cppextensions/referenceexamples/signal/person.cpp b/examples/declarative/cppextensions/referenceexamples/signal/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/signal/person.h b/examples/declarative/cppextensions/referenceexamples/signal/person.h new file mode 100644 index 0000000..2f444c5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/person.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include + +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; +}; + +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; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.pro b/examples/declarative/cppextensions/referenceexamples/signal/signal.pro new file mode 100644 index 0000000..6367a38 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/signal/signal.qrc b/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp new file mode 100644 index 0000000..b915f4f --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(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::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h new file mode 100644 index 0000000..5f25781 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include +#include +#include +#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; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![0] + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) +// ![0] + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml b/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml new file mode 100644 index 0000000..5b8c8af --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml @@ -0,0 +1,36 @@ +import People 1.0 + +// ![0] +BirthdayParty { + HappyBirthdaySong on announcement { name: "Bob Jones" } +// ![0] + + onPartyStarted: console.log("This party started rockin' at " + time); + + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo 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/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp new file mode 100644 index 0000000..8ea5c2b --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.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 "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(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 HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::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 HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h new file mode 100644 index 0000000..3d07909 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.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 HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include +#include + +#include + +// ![0] +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QDeclarativePropertyValueSource) +// ![0] + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] +public: + HappyBirthdaySong(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] + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp new file mode 100644 index 0000000..00840ee --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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 +#include +#include +#include +#include "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + 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(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/cppextensions/referenceexamples/valuesource/person.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp new file mode 100644 index 0000000..0a9e508 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/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/cppextensions/referenceexamples/valuesource/person.h b/examples/declarative/cppextensions/referenceexamples/valuesource/person.h new file mode 100644 index 0000000..2f444c5 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/person.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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 +#include + +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; +}; + +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; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro new file mode 100644 index 0000000..0626c98 --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET = valuesource +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.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/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc new file mode 100644 index 0000000..e2fa01d --- /dev/null +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro index 913b2b0..e3d922c 100644 --- a/examples/declarative/declarative.pro +++ b/examples/declarative/declarative.pro @@ -2,53 +2,28 @@ TEMPLATE = subdirs # These examples contain some C++ and need to be built SUBDIRS = \ - extending \ - imageprovider \ - objectlistmodel \ - stringlistmodel \ - proxyviewer \ - plugins \ - proxywidgets + cppextensions \ + modelviews \ + tutorials # plugins uses a 'Time' class that conflicts with symbian e32std.h also defining a class of the same name symbian:SUBDIRS -= plugins # These examples contain no C++ and can simply be copied sources.files = \ - animations \ - aspectratio \ - behaviors \ - border-image \ - clocks \ - connections \ - dial \ - dynamic \ - effects \ - fillmode \ - focus \ - fonts \ - gridview \ - layouts \ - listview \ - mousearea \ - package \ - parallax \ - progressbar \ - scrollbar \ - searchbox \ - slideswitch \ - spinner \ - sql \ - states \ - tabwidget \ - tic-tac-toe \ - tutorials \ - tvtennis \ - velocity \ - webview \ - workerlistmodel \ - workerscript \ - xmldata \ - xmlhttprequest + animation \ + cppextensions \ + i18n \ + imageelements \ + keyinteraction \ + positioners \ + sqllocalstorage \ + text \ + threading \ + touchinteraction \ + toys \ + ui-components \ + xml + sources.path = $$[QT_INSTALL_EXAMPLES]/declarative INSTALLS += sources diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml deleted file mode 100644 index f9ab3e3..0000000 --- a/examples/declarative/dial/content/Dial.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.7 - -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 - to: 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 deleted file mode 100644 index 75d555d..0000000 Binary files a/examples/declarative/dial/content/background.png and /dev/null differ diff --git a/examples/declarative/dial/content/needle.png b/examples/declarative/dial/content/needle.png deleted file mode 100644 index 2d19f75..0000000 Binary files a/examples/declarative/dial/content/needle.png and /dev/null differ diff --git a/examples/declarative/dial/content/needle_shadow.png b/examples/declarative/dial/content/needle_shadow.png deleted file mode 100644 index 8d8a928..0000000 Binary files a/examples/declarative/dial/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/dial/content/overlay.png b/examples/declarative/dial/content/overlay.png deleted file mode 100644 index 3860a7b..0000000 Binary files a/examples/declarative/dial/content/overlay.png and /dev/null differ diff --git a/examples/declarative/dial/dial-example.qml b/examples/declarative/dial/dial-example.qml deleted file mode 100644 index 2e102b0..0000000 --- a/examples/declarative/dial/dial-example.qml +++ /dev/null @@ -1,44 +0,0 @@ -import Qt 4.7 -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; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - drag.target: parent; drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } -} diff --git a/examples/declarative/dial/dial.qmlproject b/examples/declarative/dial/dial.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/dial/dial.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml deleted file mode 100644 index 52c7c1e..0000000 --- a/examples/declarative/dynamic/dynamic.qml +++ /dev/null @@ -1,176 +0,0 @@ -import Qt 4.7 -import Qt.labs.particles 1.0 -import "qml" - -Item { - id: window - - property int activeSuns: 0 - - //This is a desktop-sized example - width: 1024; height: 512 - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - 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 - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - width: 480 - color: activePalette.window - anchors { right: parent.right; top: parent.top; bottom: parent.bottom } - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: childrenRect.width + 10; height: childrenRect.height + 10 - border.color: "black" - - Row { - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - image: "../images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - image: "../images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - - Rectangle { width: parent.width; height: 1; color: "black" } - - Text { text: "Arbitrary QML:" } - - Rectangle { - width: 460; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - focusOnPress: true - font.pixelSize: 14 - - text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - - Button { - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, window, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - -} diff --git a/examples/declarative/dynamic/dynamic.qmlproject b/examples/declarative/dynamic/dynamic.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/dynamic/dynamic.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/dynamic/images/NOTE b/examples/declarative/dynamic/images/NOTE deleted file mode 100644 index fcd87f9..0000000 --- a/examples/declarative/dynamic/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/dynamic/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/moon.png b/examples/declarative/dynamic/images/moon.png deleted file mode 100644 index 1c0d606..0000000 Binary files a/examples/declarative/dynamic/images/moon.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/rabbit_brown.png b/examples/declarative/dynamic/images/rabbit_brown.png deleted file mode 100644 index ebfdeed..0000000 Binary files a/examples/declarative/dynamic/images/rabbit_brown.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/rabbit_bw.png b/examples/declarative/dynamic/images/rabbit_bw.png deleted file mode 100644 index 7bff9b9..0000000 Binary files a/examples/declarative/dynamic/images/rabbit_bw.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/star.png b/examples/declarative/dynamic/images/star.png deleted file mode 100644 index 27ef924..0000000 Binary files a/examples/declarative/dynamic/images/star.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/sun.png b/examples/declarative/dynamic/images/sun.png deleted file mode 100644 index 7713ca5..0000000 Binary files a/examples/declarative/dynamic/images/sun.png and /dev/null differ diff --git a/examples/declarative/dynamic/images/tree_s.png b/examples/declarative/dynamic/images/tree_s.png deleted file mode 100644 index 6eac35a..0000000 Binary files a/examples/declarative/dynamic/images/tree_s.png and /dev/null differ diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml deleted file mode 100644 index 963a850..0000000 --- a/examples/declarative/dynamic/qml/Button.qml +++ /dev/null @@ -1,40 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml deleted file mode 100644 index dcb5cc3..0000000 --- a/examples/declarative/dynamic/qml/PaletteItem.qml +++ /dev/null @@ -1,19 +0,0 @@ -import Qt 4.7 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml deleted file mode 100644 index c04d3dc..0000000 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > window.height / 2 - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml deleted file mode 100644 index 43dcb9a..0000000 --- a/examples/declarative/dynamic/qml/Sun.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Image { - id: sun - - property bool created: false - property string image: "../images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: window.height / 2 - 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() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js deleted file mode 100644 index 59750f3..0000000 --- a/examples/declarative/dynamic/qml/itemCreation.js +++ /dev/null @@ -1,65 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(null, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window); - draggedItem.image = paletteItem.image; - draggedItem.x = posnInWindow.x; - draggedItem.y = posnInWindow.y; - draggedItem.z = 3; // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(component.errorsString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/extending/adding/adding.pro b/examples/declarative/extending/adding/adding.pro deleted file mode 100644 index 6072de4..0000000 --- a/examples/declarative/extending/adding/adding.pro +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/adding/adding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/adding/example.qml b/examples/declarative/extending/adding/example.qml deleted file mode 100644 index dc891e7..0000000 --- a/examples/declarative/extending/adding/example.qml +++ /dev/null @@ -1,8 +0,0 @@ -// ![0] -import People 1.0 - -Person { - name: "Bob Jones" - shoeSize: 12 -} -// ![0] diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp deleted file mode 100644 index 7b33895..0000000 --- a/examples/declarative/extending/adding/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); -//![0] - qmlRegisterType("People", 1,0, "Person"); -//![0] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - Person *person = qobject_cast(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 deleted file mode 100644 index cdf08e0..0000000 --- a/examples/declarative/extending/adding/person.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 deleted file mode 100644 index d6de9a9..0000000 --- a/examples/declarative/extending/adding/person.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -// ![0] -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; -}; -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/extending/attached/attached.pro b/examples/declarative/extending/attached/attached.pro deleted file mode 100644 index f6d76ed..0000000 --- a/examples/declarative/extending/attached/attached.pro +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/attached/attached.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp deleted file mode 100644 index 7fa1748..0000000 --- a/examples/declarative/extending/attached/birthdayparty.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h deleted file mode 100644 index 1c66f8c..0000000 --- a/examples/declarative/extending/attached/birthdayparty.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#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; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/attached/example.qml b/examples/declarative/extending/attached/example.qml deleted file mode 100644 index 50f0a32..0000000 --- a/examples/declarative/extending/attached/example.qml +++ /dev/null @@ -1,31 +0,0 @@ -import People 1.0 - -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - // ![1] - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - - BirthdayParty.rsvp: "2009-07-06" - } - // ![1] - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - - BirthdayParty.rsvp: "2009-07-01" - } -} - diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp deleted file mode 100644 index f1055ae..0000000 --- a/examples/declarative/extending/attached/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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(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 deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/attached/person.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 2f444c5..0000000 --- a/examples/declarative/extending/attached/person.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include - -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; -}; - -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; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/binding/binding.pro b/examples/declarative/extending/binding/binding.pro deleted file mode 100644 index 896ce25..0000000 --- a/examples/declarative/extending/binding/binding.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = binding -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/binding/binding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp deleted file mode 100644 index 000bb1f..0000000 --- a/examples/declarative/extending/binding/birthdayparty.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - if (c == m_host) return; - m_host = c; - emit hostChanged(); -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(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 deleted file mode 100644 index c3f033e..0000000 --- a/examples/declarative/extending/binding/birthdayparty.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#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; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) -// ![0] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - void hostChanged(); - -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml deleted file mode 100644 index 82eb3be..0000000 --- a/examples/declarative/extending/binding/example.qml +++ /dev/null @@ -1,37 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - id: theParty - - HappyBirthdaySong on announcement { name: theParty.host.name } - - host: 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: "Leo 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/happybirthdaysong.cpp b/examples/declarative/extending/binding/happybirthdaysong.cpp deleted file mode 100644 index a40e7fb..0000000 --- a/examples/declarative/extending/binding/happybirthdaysong.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(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 HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::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 HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/extending/binding/happybirthdaysong.h b/examples/declarative/extending/binding/happybirthdaysong.h deleted file mode 100644 index e825b86..0000000 --- a/examples/declarative/extending/binding/happybirthdaysong.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include - -#include - -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QDeclarativePropertyValueSource) -public: - HappyBirthdaySong(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; -}; - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp deleted file mode 100644 index 2495676..0000000 --- a/examples/declarative/extending/binding/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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(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 deleted file mode 100644 index 9a2248f..0000000 --- a/examples/declarative/extending/binding/person.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 2a68da0..0000000 --- a/examples/declarative/extending/binding/person.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include - -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; -}; - -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; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp deleted file mode 100644 index 4f415a3..0000000 --- a/examples/declarative/extending/coercion/birthdayparty.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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 deleted file mode 100644 index ee77e9a..0000000 --- a/examples/declarative/extending/coercion/birthdayparty.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/coercion/coercion.pro b/examples/declarative/extending/coercion/coercion.pro deleted file mode 100644 index c8daed8..0000000 --- a/examples/declarative/extending/coercion/coercion.pro +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/coercion/coercion.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/coercion/example.qml b/examples/declarative/extending/coercion/example.qml deleted file mode 100644 index 7b45950..0000000 --- a/examples/declarative/extending/coercion/example.qml +++ /dev/null @@ -1,15 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Boy { name: "Leo 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 deleted file mode 100644 index 2c7b545..0000000 --- a/examples/declarative/extending/coercion/main.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); -// ![0] - qmlRegisterType(); -// ![0] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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 deleted file mode 100644 index 5b5203a..0000000 --- a/examples/declarative/extending/coercion/person.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 1c95da7..0000000 --- a/examples/declarative/extending/coercion/person.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 - -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; -}; - - -// ![0] -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp deleted file mode 100644 index 4f415a3..0000000 --- a/examples/declarative/extending/default/birthdayparty.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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 deleted file mode 100644 index 9741040..0000000 --- a/examples/declarative/extending/default/birthdayparty.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![0] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/default/default.pro b/examples/declarative/extending/default/default.pro deleted file mode 100644 index 32aff0b..0000000 --- a/examples/declarative/extending/default/default.pro +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/default/default.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/default/example.qml b/examples/declarative/extending/default/example.qml deleted file mode 100644 index c0f3cbb..0000000 --- a/examples/declarative/extending/default/example.qml +++ /dev/null @@ -1,14 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - - Boy { name: "Leo 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 deleted file mode 100644 index 2ffd180..0000000 --- a/examples/declarative/extending/default/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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 deleted file mode 100644 index 69216d3..0000000 --- a/examples/declarative/extending/default/person.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 3e56860..0000000 --- a/examples/declarative/extending/default/person.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 - -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; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/extended/example.qml b/examples/declarative/extending/extended/example.qml deleted file mode 100644 index 985ce20..0000000 --- a/examples/declarative/extending/extended/example.qml +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 97af286..0000000 --- a/examples/declarative/extending/extended/extended.pro +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/extended/extended.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp deleted file mode 100644 index 0e521ec..0000000 --- a/examples/declarative/extending/extended/lineedit.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 - -LineEditExtension::LineEditExtension(QObject *object) -: QObject(object), m_lineedit(static_cast(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); -} - - diff --git a/examples/declarative/extending/extended/lineedit.h b/examples/declarative/extending/extended/lineedit.h deleted file mode 100644 index 3a464b0..0000000 --- a/examples/declarative/extending/extended/lineedit.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 - -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 deleted file mode 100644 index ca7242d..0000000 --- a/examples/declarative/extending/extended/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include -#include "lineedit.h" - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - QLineEdit *edit = qobject_cast(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 deleted file mode 100644 index 169c7ab..0000000 --- a/examples/declarative/extending/extending.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - adding \ - attached \ - binding \ - coercion \ - default \ - extended \ - grouped \ - properties \ - signal \ - valuesource diff --git a/examples/declarative/extending/extending.qmlproject b/examples/declarative/extending/extending.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/extending/extending.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp deleted file mode 100644 index 4f415a3..0000000 --- a/examples/declarative/extending/grouped/birthdayparty.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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 deleted file mode 100644 index 31d21b2..0000000 --- a/examples/declarative/extending/grouped/birthdayparty.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/grouped/example.qml b/examples/declarative/extending/grouped/example.qml deleted file mode 100644 index 91b7a06..0000000 --- a/examples/declarative/extending/grouped/example.qml +++ /dev/null @@ -1,33 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo 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 deleted file mode 100644 index 576e1d2..0000000 --- a/examples/declarative/extending/grouped/grouped.pro +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp deleted file mode 100644 index baf32cf..0000000 --- a/examples/declarative/extending/grouped/main.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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 deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/grouped/person.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index a031e69..0000000 --- a/examples/declarative/extending/grouped/person.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 -#include - -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; -}; - -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; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp deleted file mode 100644 index 27d17a1..0000000 --- a/examples/declarative/extending/properties/birthdayparty.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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 deleted file mode 100644 index 39ce9ba..0000000 --- a/examples/declarative/extending/properties/birthdayparty.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] -// ![1] - Q_PROPERTY(Person *host READ host WRITE setHost) -// ![1] -// ![2] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![2] -// ![3] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/properties/example.qml b/examples/declarative/extending/properties/example.qml deleted file mode 100644 index 35abdd6..0000000 --- a/examples/declarative/extending/properties/example.qml +++ /dev/null @@ -1,15 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo 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 deleted file mode 100644 index 85e9584..0000000 --- a/examples/declarative/extending/properties/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->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 deleted file mode 100644 index 92c54f5..0000000 --- a/examples/declarative/extending/properties/person.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 0029b09..0000000 --- a/examples/declarative/extending/properties/person.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 - -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; -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/properties/properties.pro b/examples/declarative/extending/properties/properties.pro deleted file mode 100644 index a8f4301..0000000 --- a/examples/declarative/extending/properties/properties.pro +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp deleted file mode 100644 index 740c8c9..0000000 --- a/examples/declarative/extending/signal/birthdayparty.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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 deleted file mode 100644 index ae4dd39..0000000 --- a/examples/declarative/extending/signal/birthdayparty.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#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; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty 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_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml deleted file mode 100644 index 83d6a23..0000000 --- a/examples/declarative/extending/signal/example.qml +++ /dev/null @@ -1,32 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - onPartyStarted: console.log("This party started rockin' at " + time); -// ![0] - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo 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 deleted file mode 100644 index 453f688..0000000 --- a/examples/declarative/extending/signal/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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(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 deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/signal/person.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 2f444c5..0000000 --- a/examples/declarative/extending/signal/person.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include - -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; -}; - -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; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/signal/signal.pro b/examples/declarative/extending/signal/signal.pro deleted file mode 100644 index 6367a38..0000000 --- a/examples/declarative/extending/signal/signal.pro +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/signal/signal.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp deleted file mode 100644 index b915f4f..0000000 --- a/examples/declarative/extending/valuesource/birthdayparty.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(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::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(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 deleted file mode 100644 index 5f25781..0000000 --- a/examples/declarative/extending/valuesource/birthdayparty.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 -#include -#include -#include -#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; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) -// ![0] - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml deleted file mode 100644 index 5b8c8af..0000000 --- a/examples/declarative/extending/valuesource/example.qml +++ /dev/null @@ -1,36 +0,0 @@ -import People 1.0 - -// ![0] -BirthdayParty { - HappyBirthdaySong on announcement { name: "Bob Jones" } -// ![0] - - onPartyStarted: console.log("This party started rockin' at " + time); - - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo 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/happybirthdaysong.cpp b/examples/declarative/extending/valuesource/happybirthdaysong.cpp deleted file mode 100644 index 8ea5c2b..0000000 --- a/examples/declarative/extending/valuesource/happybirthdaysong.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(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 HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::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 HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/extending/valuesource/happybirthdaysong.h b/examples/declarative/extending/valuesource/happybirthdaysong.h deleted file mode 100644 index 3d07909..0000000 --- a/examples/declarative/extending/valuesource/happybirthdaysong.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include -#include - -#include - -// ![0] -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_INTERFACES(QDeclarativePropertyValueSource) -// ![0] - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] -public: - HappyBirthdaySong(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] - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp deleted file mode 100644 index 00840ee..0000000 --- a/examples/declarative/extending/valuesource/main.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, ":example.qml"); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - 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(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 deleted file mode 100644 index 0a9e508..0000000 --- a/examples/declarative/extending/valuesource/person.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 deleted file mode 100644 index 2f444c5..0000000 --- a/examples/declarative/extending/valuesource/person.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include - -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; -}; - -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; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/extending/valuesource/valuesource.pro b/examples/declarative/extending/valuesource/valuesource.pro deleted file mode 100644 index 0626c98..0000000 --- a/examples/declarative/extending/valuesource/valuesource.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = valuesource -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.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 deleted file mode 100644 index e2fa01d..0000000 --- a/examples/declarative/extending/valuesource/valuesource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/fillmode/content/QtLogo.qml b/examples/declarative/fillmode/content/QtLogo.qml deleted file mode 100644 index 6dd714d..0000000 --- a/examples/declarative/fillmode/content/QtLogo.qml +++ /dev/null @@ -1,30 +0,0 @@ -import Qt 4.7 - -Item { - id: qtLogo - - property alias fillMode: image.fillMode - property alias label: labelText.text - - width: ((window.width - 20) - ((grid.columns - 1) * grid.spacing)) / grid.columns - height: ((window.height - 20) - ((grid.rows - 1) * grid.spacing)) / grid.rows - - Column { - anchors.fill: parent - - Rectangle { - height: qtLogo.height - 30; width: qtLogo.width - border.color: "black"; clip: true - - Image { - id: image - anchors.fill: parent; smooth: true; source: "qt-logo.png" - } - } - - Text { - id: labelText; anchors.horizontalCenter: parent.horizontalCenter - height: 30; verticalAlignment: Text.AlignVCenter - } - } -} diff --git a/examples/declarative/fillmode/content/qt-logo.png b/examples/declarative/fillmode/content/qt-logo.png deleted file mode 100644 index 14ddf2a..0000000 Binary files a/examples/declarative/fillmode/content/qt-logo.png and /dev/null differ diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml deleted file mode 100644 index e5b0336..0000000 --- a/examples/declarative/fillmode/fillmode.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#cdcdcd" - - Grid { - id: grid - anchors { fill: parent; topMargin: 10; leftMargin: 10; rightMargin: 10; bottomMargin: 10 } - columns: 3; rows: 2; spacing: 20 - - QtLogo { fillMode: Image.Stretch; label: "Stretch" } - QtLogo { fillMode: Image.PreserveAspectFit; label: "PreserveAspectFit" } - QtLogo { fillMode: Image.PreserveAspectCrop; label: "PreserveAspectCrop" } - QtLogo { fillMode: Image.Tile; label: "Tile" } - QtLogo { fillMode: Image.TileHorizontally; label: "TileHorizontally" } - QtLogo { fillMode: Image.TileVertically; label: "TileVertically" } - } -} diff --git a/examples/declarative/fillmode/fillmode.qmlproject b/examples/declarative/fillmode/fillmode.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/fillmode/fillmode.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/flipable/content/5_heart.png b/examples/declarative/flipable/content/5_heart.png deleted file mode 100644 index fb59d81..0000000 Binary files a/examples/declarative/flipable/content/5_heart.png and /dev/null differ diff --git a/examples/declarative/flipable/content/9_club.png b/examples/declarative/flipable/content/9_club.png deleted file mode 100644 index 2545001..0000000 Binary files a/examples/declarative/flipable/content/9_club.png and /dev/null differ diff --git a/examples/declarative/flipable/content/Card.qml b/examples/declarative/flipable/content/Card.qml deleted file mode 100644 index 2577d89..0000000 --- a/examples/declarative/flipable/content/Card.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Flipable { - id: container - - property alias image: frontImage.source - property bool flipped: true - property int xAxis: 0 - property int yAxis: 0 - property int angle: 0 - - width: front.width; height: front.height; state: "back" - - front: Image { id: frontImage; smooth: true } - back: Image { source: "back.png"; smooth: true } - - MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } - - transform: Rotation { - id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 - axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 - } - - states: State { - name: "back"; when: container.flipped - PropertyChanges { target: rotation; angle: container.angle } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { target: rotation; properties: "angle"; duration: 600 } - SequentialAnimation { - NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } - NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } - } - } - } -} diff --git a/examples/declarative/flipable/content/back.png b/examples/declarative/flipable/content/back.png deleted file mode 100644 index f715d74..0000000 Binary files a/examples/declarative/flipable/content/back.png and /dev/null differ diff --git a/examples/declarative/flipable/flipable-example.qml b/examples/declarative/flipable/flipable-example.qml deleted file mode 100644 index 4e09569..0000000 --- a/examples/declarative/flipable/flipable-example.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/declarative/flipable/flipable.qmlproject b/examples/declarative/flipable/flipable.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/flipable/flipable.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/focus/Core/ContextMenu.qml b/examples/declarative/focus/Core/ContextMenu.qml deleted file mode 100644 index 49a54bc..0000000 --- a/examples/declarative/focus/Core/ContextMenu.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index 3f727fd..0000000 --- a/examples/declarative/focus/Core/GridMenu.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 - -FocusScope { - property alias interactive: gridView.interactive - - onWantsFocusChanged: if (wantsFocus) mainView.state = "" - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - GridView { - id: gridView - x: 20; width: parent.width - 40; height: parent.height - cellWidth: 152; cellHeight: 152 - focus: true - 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.forceFocus() - } - } - - 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 deleted file mode 100644 index 14e2548..0000000 --- a/examples/declarative/focus/Core/ListViewDelegate.qml +++ /dev/null @@ -1,40 +0,0 @@ -import Qt 4.7 - -Item { - id: container - x: 5; width: ListView.view.width - 10; height: 60 - - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - smooth: true - 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.forceFocus() - } - } - - 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 deleted file mode 100644 index 32a5d4c..0000000 --- a/examples/declarative/focus/Core/ListViews.qml +++ /dev/null @@ -1,62 +0,0 @@ -import Qt 4.7 - -FocusScope { - clip: true - - onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews" - - ListView { - id: list1 - y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 - focus: true - KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list2 - y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list3 - y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } - - Rectangle { - y: 1; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 0.0; color: "#3E606F" } - GradientStop { position: 1.0; color: "transparent" } - } - } - - Rectangle { - y: parent.height - 10; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 1.0; color: "#3E606F" } - GradientStop { position: 0.0; color: "transparent" } - } - } -} diff --git a/examples/declarative/focus/Core/images/arrow.png b/examples/declarative/focus/Core/images/arrow.png deleted file mode 100644 index 14978c2..0000000 Binary files a/examples/declarative/focus/Core/images/arrow.png and /dev/null differ diff --git a/examples/declarative/focus/Core/images/qt-logo.png b/examples/declarative/focus/Core/images/qt-logo.png deleted file mode 100644 index 14ddf2a..0000000 Binary files a/examples/declarative/focus/Core/images/qt-logo.png and /dev/null differ diff --git a/examples/declarative/focus/Core/qmldir b/examples/declarative/focus/Core/qmldir deleted file mode 100644 index e25d63c..0000000 --- a/examples/declarative/focus/Core/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 8c992ae..0000000 --- a/examples/declarative/focus/focus.qml +++ /dev/null @@ -1,69 +0,0 @@ -import Qt 4.7 -import "Core" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#3E606F" - - FocusScope { - id: mainView - - width: parent.width; height: parent.height - focus: true - - GridMenu { - id: gridMenu - - width: parent.width; height: 320 - focus: true - interactive: parent.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: Easing.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: Easing.OutQuint } - } -} diff --git a/examples/declarative/focus/focus.qmlproject b/examples/declarative/focus/focus.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/focus/focus.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/fonts/availableFonts.qml b/examples/declarative/fonts/availableFonts.qml deleted file mode 100644 index defa4ce..0000000 --- a/examples/declarative/fonts/availableFonts.qml +++ /dev/null @@ -1,17 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 480; height: 640; color: "steelblue" - - ListView { - anchors.fill: parent; model: Qt.fontFamilies() - - delegate: Item { - height: 40; width: ListView.view.width - Text { - anchors.centerIn: parent - text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" - } - } - } -} diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml deleted file mode 100644 index 353354a..0000000 --- a/examples/declarative/fonts/banner.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: screen - - property int pixelSize: screen.height * 1.25 - property color textColor: "lightsteelblue" - property string text: "Hello world! " - - width: 640; height: 320 - color: "steelblue" - - Row { - y: -screen.height / 4.5 - - NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } - Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - } -} diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml deleted file mode 100644 index f3eac48..0000000 --- a/examples/declarative/fonts/fonts.qml +++ /dev/null @@ -1,64 +0,0 @@ -import Qt 4.7 - -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/tarzeau_ocr_a.ttf" } - FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } - - Column { - anchors { fill: parent; leftMargin: 10; rightMargin: 10 } - spacing: 15 - - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } - } - Text { - text: { - if (webFont.status == FontLoader.Ready) myText - else if (webFont.status == FontLoader.Loading) "Loading..." - else if (webFont.status == FontLoader.Error) "Error loading font" - } - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font.family: webFont.name; font.pointSize: 42 - } - } -} diff --git a/examples/declarative/fonts/fonts.qmlproject b/examples/declarative/fonts/fonts.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/fonts/fonts.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf b/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f96..0000000 Binary files a/examples/declarative/fonts/fonts/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml deleted file mode 100644 index 0d6f4cd..0000000 --- a/examples/declarative/fonts/hello.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: screen - - width: 800; height: 480 - color: "black" - - Item { - id: container - x: screen.width / 2; y: screen.height / 2 - - Text { - id: text - anchors.centerIn: parent - color: "white" - text: "Hello world!" - font.pixelSize: 60 - - SequentialAnimation on font.letterSpacing { - loops: Animation.Infinite; - NumberAnimation { from: 100; to: 300; easing.type: Easing.InQuad; duration: 3000 } - ScriptAction { - script: { - container.y = (screen.height / 4) + (Math.random() * screen.height / 2) - container.x = (screen.width / 4) + (Math.random() * screen.width / 2) - } - } - } - - SequentialAnimation on opacity { - loops: Animation.Infinite; - NumberAnimation { from: 1; to: 0; duration: 2600 } - PauseAnimation { duration: 400 } - } - } - } -} diff --git a/examples/declarative/gestures/experimental-gestures.qml b/examples/declarative/gestures/experimental-gestures.qml deleted file mode 100644 index cb190ea..0000000 --- a/examples/declarative/gestures/experimental-gestures.qml +++ /dev/null @@ -1,36 +0,0 @@ -import Qt 4.7 -import Qt.labs.gestures 1.0 - -// Only works on platforms with Touch support. - -Rectangle { - id: rect - width: 320 - height: 180 - - Text { - anchors.centerIn: parent - text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." - horizontalAlignment: Text.Center - } - - GestureArea { - anchors.fill: parent - focus: true - - // Only some of the many gesture properties are shown. See Gesture documentation. - - onTap: - console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")") - onTapAndHold: - console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") - onPan: - console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) - onPinch: - console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) - onSwipe: - console.log("swipe angle=",gesture.swipeAngle) - onGesture: - console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") - } -} diff --git a/examples/declarative/gestures/gestures.qmlproject b/examples/declarative/gestures/gestures.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/gestures/gestures.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/gridview/gridview-example.qml b/examples/declarative/gridview/gridview-example.qml deleted file mode 100644 index a5f41fb..0000000 --- a/examples/declarative/gridview/gridview-example.qml +++ /dev/null @@ -1,49 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 300; height: 400 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - - Item { - width: 100; height: 100 - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - GridView { - anchors.fill: parent - cellWidth: 100; cellHeight: 100 - highlight: appHighlight - focus: true - model: appModel - delegate: appDelegate - } -} diff --git a/examples/declarative/gridview/gridview.qmlproject b/examples/declarative/gridview/gridview.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/gridview/gridview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/gridview/pics/AddressBook_48.png b/examples/declarative/gridview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8e..0000000 Binary files a/examples/declarative/gridview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/AudioPlayer_48.png b/examples/declarative/gridview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689..0000000 Binary files a/examples/declarative/gridview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/Camera_48.png b/examples/declarative/gridview/pics/Camera_48.png deleted file mode 100644 index c76b524..0000000 Binary files a/examples/declarative/gridview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/DateBook_48.png b/examples/declarative/gridview/pics/DateBook_48.png deleted file mode 100644 index 58f5787..0000000 Binary files a/examples/declarative/gridview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/EMail_48.png b/examples/declarative/gridview/pics/EMail_48.png deleted file mode 100644 index d6d84a6..0000000 Binary files a/examples/declarative/gridview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/TodoList_48.png b/examples/declarative/gridview/pics/TodoList_48.png deleted file mode 100644 index 0988448..0000000 Binary files a/examples/declarative/gridview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/gridview/pics/VideoPlayer_48.png b/examples/declarative/gridview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c5..0000000 Binary files a/examples/declarative/gridview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/i18n/i18n.qmlproject b/examples/declarative/i18n/i18n.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/i18n/i18n.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/borderimage/borderimage.qml b/examples/declarative/imageelements/borderimage/borderimage.qml new file mode 100644 index 0000000..c334cea --- /dev/null +++ b/examples/declarative/imageelements/borderimage/borderimage.qml @@ -0,0 +1,57 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: page + width: 1030; height: 540 + + Grid { + anchors.centerIn: parent; spacing: 20 + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + } +} diff --git a/examples/declarative/imageelements/borderimage/borderimage.qmlproject b/examples/declarative/imageelements/borderimage/borderimage.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/borderimage.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/borderimage/content/MyBorderImage.qml b/examples/declarative/imageelements/borderimage/content/MyBorderImage.qml new file mode 100644 index 0000000..b47df7b --- /dev/null +++ b/examples/declarative/imageelements/borderimage/content/MyBorderImage.qml @@ -0,0 +1,50 @@ +import Qt 4.7 + +Item { + id: container + + property alias horizontalMode: image.horizontalTileMode + property alias verticalMode: image.verticalTileMode + property alias source: image.source + + property int minWidth + property int minHeight + property int maxWidth + property int maxHeight + property int margin + + width: 240; height: 240 + + BorderImage { + id: image; anchors.centerIn: parent + + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { + from: container.minWidth; to: container.maxWidth + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxWidth; to: container.minWidth + duration: 2000; easing.type: Easing.InOutQuad + } + } + + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { + from: container.minHeight; to: container.maxHeight + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxHeight; to: container.minHeight + duration: 2000; easing.type: Easing.InOutQuad + } + } + + border.top: container.margin + border.left: container.margin + border.bottom: container.margin + border.right: container.margin + } +} diff --git a/examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml b/examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml new file mode 100644 index 0000000..629478b --- /dev/null +++ b/examples/declarative/imageelements/borderimage/content/ShadowRectangle.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Item { + property alias color : rectangle.color + + BorderImage { + anchors.fill: rectangle + anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + border { left: 10; top: 10; right: 10; bottom: 10 } + source: "shadow.png"; smooth: true + } + + Rectangle { id: rectangle; anchors.fill: parent } +} diff --git a/examples/declarative/imageelements/borderimage/content/bw.png b/examples/declarative/imageelements/borderimage/content/bw.png new file mode 100644 index 0000000..486eaae Binary files /dev/null and b/examples/declarative/imageelements/borderimage/content/bw.png differ diff --git a/examples/declarative/imageelements/borderimage/content/colors-round.sci b/examples/declarative/imageelements/borderimage/content/colors-round.sci new file mode 100644 index 0000000..506f6f5 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/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/imageelements/borderimage/content/colors-stretch.sci b/examples/declarative/imageelements/borderimage/content/colors-stretch.sci new file mode 100644 index 0000000..e4989a7 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/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/imageelements/borderimage/content/colors.png b/examples/declarative/imageelements/borderimage/content/colors.png new file mode 100644 index 0000000..dfb62f3 Binary files /dev/null and b/examples/declarative/imageelements/borderimage/content/colors.png differ diff --git a/examples/declarative/imageelements/borderimage/content/shadow.png b/examples/declarative/imageelements/borderimage/content/shadow.png new file mode 100644 index 0000000..431af85 Binary files /dev/null and b/examples/declarative/imageelements/borderimage/content/shadow.png differ diff --git a/examples/declarative/imageelements/borderimage/shadows.qml b/examples/declarative/imageelements/borderimage/shadows.qml new file mode 100644 index 0000000..a08d133 --- /dev/null +++ b/examples/declarative/imageelements/borderimage/shadows.qml @@ -0,0 +1,24 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "gray" + + ShadowRectangle { + anchors.centerIn: parent; width: 250; height: 250 + color: "lightsteelblue" + } + + ShadowRectangle { + anchors.centerIn: parent; width: 200; height: 200 + color: "steelblue" + } + + ShadowRectangle { + anchors.centerIn: parent; width: 150; height: 150 + color: "thistle" + } +} diff --git a/examples/declarative/imageelements/image/face_fit.qml b/examples/declarative/imageelements/image/face_fit.qml new file mode 100644 index 0000000..52cd4c2 --- /dev/null +++ b/examples/declarative/imageelements/image/face_fit.qml @@ -0,0 +1,26 @@ +import Qt 4.7 + +// 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/imageelements/image/face_fit_animated.qml b/examples/declarative/imageelements/image/face_fit_animated.qml new file mode 100644 index 0000000..63fc9c6 --- /dev/null +++ b/examples/declarative/imageelements/image/face_fit_animated.qml @@ -0,0 +1,28 @@ +import Qt 4.7 + +// 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 { + to: 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/imageelements/image/image.qmlproject b/examples/declarative/imageelements/image/image.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/image/image.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/image/pics/face.png b/examples/declarative/imageelements/image/pics/face.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/imageelements/image/pics/face.png differ diff --git a/examples/declarative/imageelements/image/scale_and_crop.qml b/examples/declarative/imageelements/image/scale_and_crop.qml new file mode 100644 index 0000000..a438104 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_and_crop.qml @@ -0,0 +1,21 @@ +import Qt 4.7 + +// 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/imageelements/image/scale_and_crop_simple.qml b/examples/declarative/imageelements/image/scale_and_crop_simple.qml new file mode 100644 index 0000000..1160ec5 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_and_crop_simple.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +// 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/imageelements/image/scale_and_sidecrop.qml b/examples/declarative/imageelements/image/scale_and_sidecrop.qml new file mode 100644 index 0000000..5593ab8 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_and_sidecrop.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +// 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/imageelements/image/scale_to_fit.qml b/examples/declarative/imageelements/image/scale_to_fit.qml new file mode 100644 index 0000000..724a36e --- /dev/null +++ b/examples/declarative/imageelements/image/scale_to_fit.qml @@ -0,0 +1,22 @@ +import Qt 4.7 + +// 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/imageelements/image/scale_to_fit_simple.qml b/examples/declarative/imageelements/image/scale_to_fit_simple.qml new file mode 100644 index 0000000..0e960b4 --- /dev/null +++ b/examples/declarative/imageelements/image/scale_to_fit_simple.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +// 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/imageelements/imageelements.qmlproject b/examples/declarative/imageelements/imageelements.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageelements/imageelements.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageprovider/ImageProviderCore/qmldir b/examples/declarative/imageprovider/ImageProviderCore/qmldir deleted file mode 100644 index 1028590..0000000 --- a/examples/declarative/imageprovider/ImageProviderCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -plugin imageprovider - diff --git a/examples/declarative/imageprovider/imageprovider-example.qml b/examples/declarative/imageprovider/imageprovider-example.qml deleted file mode 100644 index d774112..0000000 --- a/examples/declarative/imageprovider/imageprovider-example.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 -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 deleted file mode 100644 index 4c4aa94..0000000 --- a/examples/declarative/imageprovider/imageprovider.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - 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 deleted file mode 100644 index 945a301..0000000 --- a/examples/declarative/imageprovider/imageprovider.pro +++ /dev/null @@ -1,25 +0,0 @@ -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 - -symbian:{ - TARGET.EPOCALLOWDLLDATA=1 -} - -INSTALLS = sources ImageProviderCore_sources target diff --git a/examples/declarative/imageprovider/imageprovider.qmlproject b/examples/declarative/imageprovider/imageprovider.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/imageprovider/imageprovider.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/images/content/lemonade.jpg b/examples/declarative/images/content/lemonade.jpg deleted file mode 100644 index db445c9..0000000 Binary files a/examples/declarative/images/content/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/images/images.qml b/examples/declarative/images/images.qml deleted file mode 100644 index e48ad50..0000000 --- a/examples/declarative/images/images.qml +++ /dev/null @@ -1,72 +0,0 @@ -import Qt 4.7 - -Rectangle { - color: "white" - width: grid.width + 50 - height: grid.height + 50 - - Grid { - id: grid - x: 25; y: 25 - 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/images/images.qmlproject b/examples/declarative/images/images.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/images/images.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml b/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml new file mode 100644 index 0000000..49a54bc --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml @@ -0,0 +1,18 @@ +import Qt 4.7 + +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/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml new file mode 100644 index 0000000..3f727fd --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml @@ -0,0 +1,61 @@ +import Qt 4.7 + +FocusScope { + property alias interactive: gridView.interactive + + onWantsFocusChanged: if (wantsFocus) mainView.state = "" + + Rectangle { + anchors.fill: parent + clip: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#193441" } + GradientStop { position: 1.0; color: Qt.darker("#193441") } + } + + GridView { + id: gridView + x: 20; width: parent.width - 40; height: parent.height + cellWidth: 152; cellHeight: 152 + focus: true + 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.forceFocus() + } + } + + 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/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml new file mode 100644 index 0000000..14e2548 --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml @@ -0,0 +1,40 @@ +import Qt 4.7 + +Item { + id: container + x: 5; width: ListView.view.width - 10; height: 60 + + Rectangle { + id: content + anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 + color: "transparent" + smooth: true + 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.forceFocus() + } + } + + 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/keyinteraction/focus/Core/ListViews.qml b/examples/declarative/keyinteraction/focus/Core/ListViews.qml new file mode 100644 index 0000000..32a5d4c --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/ListViews.qml @@ -0,0 +1,62 @@ +import Qt 4.7 + +FocusScope { + clip: true + + onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews" + + ListView { + id: list1 + y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 + focus: true + KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list2 + y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list3 + y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: gridMenu; KeyNavigation.left: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } + + Rectangle { + y: 1; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 0.0; color: "#3E606F" } + GradientStop { position: 1.0; color: "transparent" } + } + } + + Rectangle { + y: parent.height - 10; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 1.0; color: "#3E606F" } + GradientStop { position: 0.0; color: "transparent" } + } + } +} diff --git a/examples/declarative/keyinteraction/focus/Core/images/arrow.png b/examples/declarative/keyinteraction/focus/Core/images/arrow.png new file mode 100644 index 0000000..14978c2 Binary files /dev/null and b/examples/declarative/keyinteraction/focus/Core/images/arrow.png differ diff --git a/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png b/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png new file mode 100644 index 0000000..14ddf2a Binary files /dev/null and b/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png differ diff --git a/examples/declarative/keyinteraction/focus/Core/qmldir b/examples/declarative/keyinteraction/focus/Core/qmldir new file mode 100644 index 0000000..e25d63c --- /dev/null +++ b/examples/declarative/keyinteraction/focus/Core/qmldir @@ -0,0 +1,4 @@ +ContextMenu ContextMenu.qml +GridMenu GridMenu.qml +ListViews ListViews.qml +ListViewDelegate ListViewDelegate.qml diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml new file mode 100644 index 0000000..8c992ae --- /dev/null +++ b/examples/declarative/keyinteraction/focus/focus.qml @@ -0,0 +1,69 @@ +import Qt 4.7 +import "Core" + +Rectangle { + id: window + + width: 800; height: 480 + color: "#3E606F" + + FocusScope { + id: mainView + + width: parent.width; height: parent.height + focus: true + + GridMenu { + id: gridMenu + + width: parent.width; height: 320 + focus: true + interactive: parent.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: Easing.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: Easing.OutQuint } + } +} diff --git a/examples/declarative/keyinteraction/focus/focus.qmlproject b/examples/declarative/keyinteraction/focus/focus.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/keyinteraction/focus/focus.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/keyinteraction/keyinteraction.qmlproject b/examples/declarative/keyinteraction/keyinteraction.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/keyinteraction/keyinteraction.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp deleted file mode 100644 index 25cf994..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "graphicslayouts_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -LinearLayoutAttached::LinearLayoutAttached(QObject *parent) -: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter), _spacing(0) -{ -} - -void LinearLayoutAttached::setStretchFactor(int f) -{ - if (_stretch == f) - return; - - _stretch = f; - emit stretchChanged(reinterpret_cast(parent()), _stretch); -} - -void LinearLayoutAttached::setSpacing(int s) -{ - if (_spacing == s) - return; - - _spacing = s; - emit spacingChanged(reinterpret_cast(parent()), _spacing); -} - -void LinearLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), _alignment); -} - -QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) - : QObject(parent) -{ -} - -QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ -Q_UNUSED(which); -Q_UNUSED(constraint); -return QSizeF(); -} - - -QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() -{ -} - -void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) -{ -insertItem(index, item); - -//connect attached properties -if (LinearLayoutAttached *obj = attachedProperties.value(item)) { - setStretchFactor(item, obj->stretchFactor()); - setAlignment(item, obj->alignment()); - updateSpacing(item, obj->spacing()); - QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - QObject::connect(obj, SIGNAL(spacingChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateSpacing(QGraphicsLayoutItem*,int))); - //### need to disconnect when widget is removed? -} -} - -//### is there a better way to do this? -void QGraphicsLinearLayoutObject::clearChildren() -{ -for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsLinearLayoutObject::contentsMargin() const -{ - qreal a,b,c,d; - getContentsMargins(&a, &b, &c, &d); - if(a==b && a==c && a==d) - return a; - return -1; -} - -void QGraphicsLinearLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m,m,m,m); -} - -void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) -{ -QGraphicsLinearLayout::setStretchFactor(item, stretch); -} - -void QGraphicsLinearLayoutObject::updateSpacing(QGraphicsLayoutItem* item, int spacing) -{ - for(int i=0; i < count(); i++){ - if(itemAt(i) == item){ //I do not see the reverse function, which is why we must loop over all items - QGraphicsLinearLayout::setItemSpacing(i, spacing); - return; - } - } -} - -void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ -QGraphicsLinearLayout::setAlignment(item, alignment); -} - -QHash QGraphicsLinearLayoutObject::attachedProperties; -LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) -{ -// ### This is not allowed - you must attach to any object -if (!qobject_cast(obj)) - return 0; -LinearLayoutAttached *rv = new LinearLayoutAttached(obj); -attachedProperties.insert(qobject_cast(obj), rv); -return rv; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////// -// QGraphicsGridLayout-related classes -////////////////////////////////////////////////////////////////////////////////////////////////////// -GridLayoutAttached::GridLayoutAttached(QObject *parent) -: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1), _rowstretch(-1), - _colstretch(-1), _rowspacing(-1), _colspacing(-1), _rowprefheight(-1), _rowmaxheight(-1), _rowminheight(-1), - _rowfixheight(-1), _colprefwidth(-1), _colmaxwidth(-1), _colminwidth(-1), _colfixwidth(-1) -{ -} - -void GridLayoutAttached::setRow(int r) -{ - if (_row == r) - return; - - _row = r; - //emit rowChanged(reinterpret_cast(parent()), _row); -} - -void GridLayoutAttached::setColumn(int c) -{ - if (_column == c) - return; - - _column = c; - //emit columnChanged(reinterpret_cast(parent()), _column); -} - -void GridLayoutAttached::setRowSpan(int rs) -{ - if (_rowspan == rs) - return; - - _rowspan = rs; - //emit rowSpanChanged(reinterpret_cast(parent()), _rowSpan); -} - -void GridLayoutAttached::setColumnSpan(int cs) -{ - if (_colspan == cs) - return; - - _colspan = cs; - //emit columnSpanChanged(reinterpret_cast(parent()), _columnSpan); -} - -void GridLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), _alignment); -} - -void GridLayoutAttached::setRowStretchFactor(int f) -{ - _rowstretch = f; -} - -void GridLayoutAttached::setColumnStretchFactor(int f) -{ - _colstretch = f; -} - -void GridLayoutAttached::setRowSpacing(int s) -{ - _rowspacing = s; -} - -void GridLayoutAttached::setColumnSpacing(int s) -{ - _colspacing = s; -} - - -QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() -{ -} - -void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) -{ -//use attached properties -if (QObject *obj = attachedProperties.value(qobject_cast(wid))) { - int row = static_cast(obj)->row(); - int column = static_cast(obj)->column(); - int rowSpan = static_cast(obj)->rowSpan(); - int columnSpan = static_cast(obj)->columnSpan(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - addItem(wid, row, column, rowSpan, columnSpan); -} -} - -void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) -{ -//use attached properties -if (GridLayoutAttached *obj = attachedProperties.value(item)) { - int row = obj->row(); - int column = obj->column(); - int rowSpan = obj->rowSpan(); - int columnSpan = obj->columnSpan(); - Qt::Alignment alignment = obj->alignment(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - if(obj->rowSpacing() != -1) - setRowSpacing(row, obj->rowSpacing()); - if(obj->columnSpacing() != -1) - setColumnSpacing(column, obj->columnSpacing()); - if(obj->rowStretchFactor() != -1) - setRowStretchFactor(row, obj->rowStretchFactor()); - if(obj->columnStretchFactor() != -1) - setColumnStretchFactor(column, obj->columnStretchFactor()); - if(obj->rowPreferredHeight() != -1) - setRowPreferredHeight(row, obj->rowPreferredHeight()); - if(obj->rowMaximumHeight() != -1) - setRowMaximumHeight(row, obj->rowMaximumHeight()); - if(obj->rowMinimumHeight() != -1) - setRowMinimumHeight(row, obj->rowMinimumHeight()); - if(obj->rowFixedHeight() != -1) - setRowFixedHeight(row, obj->rowFixedHeight()); - if(obj->columnPreferredWidth() != -1) - setColumnPreferredWidth(row, obj->columnPreferredWidth()); - if(obj->columnMaximumWidth() != -1) - setColumnMaximumWidth(row, obj->columnMaximumWidth()); - if(obj->columnMinimumWidth() != -1) - setColumnMinimumWidth(row, obj->columnMinimumWidth()); - if(obj->columnFixedWidth() != -1) - setColumnFixedWidth(row, obj->columnFixedWidth()); - addItem(item, row, column, rowSpan, columnSpan); - if (alignment != -1) - setAlignment(item,alignment); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - //### need to disconnect when widget is removed? -} -} - -//### is there a better way to do this? -void QGraphicsGridLayoutObject::clearChildren() -{ -for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsGridLayoutObject::spacing() const -{ -if (verticalSpacing() == horizontalSpacing()) - return verticalSpacing(); -return -1; //### -} - -qreal QGraphicsGridLayoutObject::contentsMargin() const -{ - qreal a,b,c,d; - getContentsMargins(&a, &b, &c, &d); - if(a==b && a==c && a==d) - return a; - return -1; -} - -void QGraphicsGridLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m,m,m,m); -} - - -void QGraphicsGridLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ -QGraphicsGridLayout::setAlignment(item, alignment); -} - -QHash QGraphicsGridLayoutObject::attachedProperties; -GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) -{ -// ### This is not allowed - you must attach to any object -if (!qobject_cast(obj)) - return 0; -GridLayoutAttached *rv = new GridLayoutAttached(obj); -attachedProperties.insert(qobject_cast(obj), rv); -return rv; -} - -QT_END_NAMESPACE diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro deleted file mode 100644 index e5d91b2..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -TARGET = graphicslayouts -QT += declarative - -SOURCES += \ - graphicslayouts.cpp \ - main.cpp - -HEADERS += \ - graphicslayouts_p.h - -RESOURCES += \ - graphicslayouts.qrc diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml deleted file mode 100644 index fcd78d5..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml +++ /dev/null @@ -1,77 +0,0 @@ -import Qt 4.7 -import GraphicsLayouts 4.7 - -Item { - id: resizable - - width: 800 - height: 400 - - QGraphicsWidget { - size.width: parent.width/2 - 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 } - } - } - } - QGraphicsWidget { - x: parent.width/2 - size.width: parent.width/2 - size.height: parent.height - - layout: QGraphicsGridLayout { - LayoutItem { - QGraphicsGridLayout.row: 0 - QGraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { color: "red"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 1 - QGraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "200x200" - preferredSize: "100x100" - Rectangle { color: "orange"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 2 - QGraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "200x200" - Rectangle { color: "yellow"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 0 - QGraphicsGridLayout.column: 1 - minimumSize: "100x100" - maximumSize: "200x200" - preferredSize: "200x200" - Rectangle { color: "green"; anchors.fill: parent } - } - LayoutItem { - QGraphicsGridLayout.row: 1 - QGraphicsGridLayout.column: 1 - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rectangle { color: "blue"; anchors.fill: parent } - } - } - } -} diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc deleted file mode 100644 index a199f8d..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - graphicslayouts.qml - - diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h b/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h deleted file mode 100644 index ea9c614..0000000 --- a/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h +++ /dev/null @@ -1,303 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRAPHICSLAYOUTS_H -#define GRAPHICSLAYOUTS_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) -public: - QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); - - virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; -}; - -class LinearLayoutAttached; -class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty children READ children) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsLinearLayoutObject(QObject * = 0); - ~QGraphicsLinearLayoutObject(); - - QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - static LinearLayoutAttached *qmlAttachedProperties(QObject *); - - qreal contentsMargin() const; - void setContentsMargin(qreal); - -private Q_SLOTS: - void updateStretch(QGraphicsLayoutItem*,int); - void updateSpacing(QGraphicsLayoutItem*,int); - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class LinearLayoutAttached; - void clearChildren(); - void insertLayoutItem(int, QGraphicsLayoutItem *); - static QHash attachedProperties; - - static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->insertLayoutItem(-1, item); - } - - static void children_clear(QDeclarativeListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } -}; - -class GridLayoutAttached; -class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty children READ children) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) - Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsGridLayoutObject(QObject * = 0); - ~QGraphicsGridLayoutObject(); - - QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - qreal spacing() const; - qreal contentsMargin() const; - void setContentsMargin(qreal); - - static GridLayoutAttached *qmlAttachedProperties(QObject *); - -private Q_SLOTS: - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class GraphicsLayoutAttached; - void addWidget(QGraphicsWidget *); - void clearChildren(); - void addLayoutItem(QGraphicsLayoutItem *); - static QHash attachedProperties; - - static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->addLayoutItem(item); - } - - static void children_clear(QDeclarativeListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } -}; - -class LinearLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) -public: - LinearLayoutAttached(QObject *parent); - - int stretchFactor() const { return _stretch; } - void setStretchFactor(int f); - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a); - int spacing() const { return _spacing; } - void setSpacing(int s); - -Q_SIGNALS: - void stretchChanged(QGraphicsLayoutItem*,int); - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - void spacingChanged(QGraphicsLayoutItem*,int); - -private: - int _stretch; - Qt::Alignment _alignment; - int _spacing; -}; - -class GridLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int row READ row WRITE setRow) - Q_PROPERTY(int column READ column WRITE setColumn) - Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) - Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) - Q_PROPERTY(int rowStretchFactor READ rowStretchFactor WRITE setRowStretchFactor) - Q_PROPERTY(int columnStretchFactor READ columnStretchFactor WRITE setColumnStretchFactor) - Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) - Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) - Q_PROPERTY(int rowPreferredHeight READ rowPreferredHeight WRITE setRowPreferredHeight) - Q_PROPERTY(int rowMinimumHeight READ rowMinimumHeight WRITE setRowMinimumHeight) - Q_PROPERTY(int rowMaximumHeight READ rowMaximumHeight WRITE setRowMaximumHeight) - Q_PROPERTY(int rowFixedHeight READ rowFixedHeight WRITE setRowFixedHeight) - Q_PROPERTY(int columnPreferredWidth READ columnPreferredWidth WRITE setColumnPreferredWidth) - Q_PROPERTY(int columnMaximumWidth READ columnMaximumWidth WRITE setColumnMaximumWidth) - Q_PROPERTY(int columnMinimumWidth READ columnMinimumWidth WRITE setColumnMinimumWidth) - Q_PROPERTY(int columnFixedWidth READ columnFixedWidth WRITE setColumnFixedWidth) - -public: - GridLayoutAttached(QObject *parent); - - int row() const { return _row; } - void setRow(int r); - - int column() const { return _column; } - void setColumn(int c); - - int rowSpan() const { return _rowspan; } - void setRowSpan(int rs); - - int columnSpan() const { return _colspan; } - void setColumnSpan(int cs); - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a); - - int rowStretchFactor() const { return _rowstretch; } - void setRowStretchFactor(int f); - int columnStretchFactor() const { return _colstretch; } - void setColumnStretchFactor(int f); - - int rowSpacing() const { return _rowspacing; } - void setRowSpacing(int s); - int columnSpacing() const { return _colspacing; } - void setColumnSpacing(int s); - - int rowPreferredHeight() const { return _rowprefheight; } - void setRowPreferredHeight(int s) { _rowprefheight = s; } - - int rowMaximumHeight() const { return _rowmaxheight; } - void setRowMaximumHeight(int s) { _rowmaxheight = s; } - - int rowMinimumHeight() const { return _rowminheight; } - void setRowMinimumHeight(int s) { _rowminheight = s; } - - int rowFixedHeight() const { return _rowfixheight; } - void setRowFixedHeight(int s) { _rowfixheight = s; } - - int columnPreferredWidth() const { return _colprefwidth; } - void setColumnPreferredWidth(int s) { _colprefwidth = s; } - - int columnMaximumWidth() const { return _colmaxwidth; } - void setColumnMaximumWidth(int s) { _colmaxwidth = s; } - - int columnMinimumWidth() const { return _colminwidth; } - void setColumnMinimumWidth(int s) { _colminwidth = s; } - - int columnFixedWidth() const { return _colfixwidth; } - void setColumnFixedWidth(int s) { _colfixwidth = s; } - -Q_SIGNALS: - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - -private: - int _row; - int _column; - int _rowspan; - int _colspan; - Qt::Alignment _alignment; - int _rowstretch; - int _colstretch; - int _rowspacing; - int _colspacing; - int _rowprefheight; - int _rowmaxheight; - int _rowminheight; - int _rowfixheight; - int _colprefwidth; - int _colmaxwidth; - int _colminwidth; - int _colfixwidth; -}; - -QT_END_NAMESPACE - -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) -QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) -QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QGraphicsGridLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // GRAPHICSLAYOUTS_H diff --git a/examples/declarative/layouts/graphicsLayouts/main.cpp b/examples/declarative/layouts/graphicsLayouts/main.cpp deleted file mode 100644 index 89b69bf..0000000 --- a/examples/declarative/layouts/graphicsLayouts/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "graphicslayouts_p.h" -#include - -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - QDeclarativeView view; - qmlRegisterInterface("QGraphicsLayoutItem"); - qmlRegisterInterface("QGraphicsLayout"); - qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayoutStretchItem"); - qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsLinearLayout"); - qmlRegisterType("GraphicsLayouts",4,7,"QGraphicsGridLayout"); - view.setSource(QUrl(":graphicslayouts.qml")); - view.show(); - return app.exec(); -}; - diff --git a/examples/declarative/layouts/layoutItem/layoutItem.pro b/examples/declarative/layouts/layoutItem/layoutItem.pro deleted file mode 100644 index 4a3fc73..0000000 --- a/examples/declarative/layouts/layoutItem/layoutItem.pro +++ /dev/null @@ -1,13 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue May 4 13:36:26 2010 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp -RESOURCES += layoutItem.qrc diff --git a/examples/declarative/layouts/layoutItem/layoutItem.qml b/examples/declarative/layouts/layoutItem/layoutItem.qml deleted file mode 100644 index 460c564..0000000 --- a/examples/declarative/layouts/layoutItem/layoutItem.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 - -LayoutItem {//Sized by the layout - id: resizable - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - Rectangle { - width: 100; height: 100; - anchors.top: parent.top; - anchors.right: parent.right; - color: "green"; - } -} diff --git a/examples/declarative/layouts/layoutItem/layoutItem.qrc b/examples/declarative/layouts/layoutItem/layoutItem.qrc deleted file mode 100644 index deb0fba..0000000 --- a/examples/declarative/layouts/layoutItem/layoutItem.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - layoutItem.qml - - diff --git a/examples/declarative/layouts/layoutItem/main.cpp b/examples/declarative/layouts/layoutItem/main.cpp deleted file mode 100644 index a104251..0000000 --- a/examples/declarative/layouts/layoutItem/main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 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 -#include -#include -#include -#include -#include -#include - -/* This example demonstrates using a LayoutItem to let QML snippets integrate - nicely with existing QGraphicsView applications designed with GraphicsLayouts -*/ -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - //Set up a graphics scene with a QGraphicsWidget and Layout - QGraphicsView view; - QGraphicsScene scene; - QGraphicsWidget *widget = new QGraphicsWidget(); - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); - widget->setLayout(layout); - scene.addItem(widget); - view.setScene(&scene); - //Add the QML snippet into the layout - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl(":layoutItem.qml")); - QGraphicsLayoutItem* obj = qobject_cast(c.create()); - layout->addItem(obj); - - widget->setGeometry(QRectF(0,0, 400,400)); - view.show(); - return app.exec(); -} diff --git a/examples/declarative/layouts/positioners/Button.qml b/examples/declarative/layouts/positioners/Button.qml deleted file mode 100644 index d03eeb5..0000000 --- a/examples/declarative/layouts/positioners/Button.qml +++ /dev/null @@ -1,38 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - - property string text - property string icon - signal clicked - - border.color: "black"; color: "steelblue"; radius: 5 - width: pix.width + textelement.width + 13 - height: pix.height + 10 - - Image { id: pix; x: 5; y:5; source: parent.icon } - - Text { - id: textelement - text: page.text; color: "white" - x: pix.width + pix.x + 3 - anchors.verticalCenter: pix.verticalCenter - } - - MouseArea { - id: mr - anchors.fill: parent - onClicked: { parent.focus = true; page.clicked() } - } - - states: State { - name: "pressed"; when: mr.pressed - PropertyChanges { target: textelement; x: 5 } - PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } - } - - transitions: Transition { - NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } - } -} diff --git a/examples/declarative/layouts/positioners/add.png b/examples/declarative/layouts/positioners/add.png deleted file mode 100644 index f29d84b..0000000 Binary files a/examples/declarative/layouts/positioners/add.png and /dev/null differ diff --git a/examples/declarative/layouts/positioners/del.png b/examples/declarative/layouts/positioners/del.png deleted file mode 100644 index 1d753a3..0000000 Binary files a/examples/declarative/layouts/positioners/del.png and /dev/null differ diff --git a/examples/declarative/layouts/positioners/positioners.qml b/examples/declarative/layouts/positioners/positioners.qml deleted file mode 100644 index 2cb0b8b..0000000 --- a/examples/declarative/layouts/positioners/positioners.qml +++ /dev/null @@ -1,213 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - width: 420; height: 420 - - Column { - id: layout1 - y: 0 - move: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV1 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV2 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } - } - - Row { - id: layout2 - y: 300 - move: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH1 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH2 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } - } - - Button { - x: 135; y: 90 - text: "Remove" - icon: "del.png" - - onClicked: { - blueH2.opacity = 0 - blueH1.opacity = 0 - blueV1.opacity = 0 - blueV2.opacity = 0 - blueG1.opacity = 0 - blueG2.opacity = 0 - blueG3.opacity = 0 - blueF1.opacity = 0 - blueF2.opacity = 0 - blueF3.opacity = 0 - } - } - - Button { - x: 145; y: 140 - text: "Add" - icon: "add.png" - - onClicked: { - blueH2.opacity = 1 - blueH1.opacity = 1 - blueV1.opacity = 1 - blueV2.opacity = 1 - blueG1.opacity = 1 - blueG2.opacity = 1 - blueG3.opacity = 1 - blueF1.opacity = 1 - blueF2.opacity = 1 - blueF3.opacity = 1 - } - } - - Grid { - x: 260; y: 0 - columns: 3 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG1 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG2 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG3 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - } - - Flow { - id: layout4 - x: 260; y: 250; width: 150 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF1 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF2 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF3 - width: 40; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } - } - -} diff --git a/examples/declarative/layouts/positioners/positioners.qmlproject b/examples/declarative/layouts/positioners/positioners.qmlproject deleted file mode 100644 index e526217..0000000 --- a/examples/declarative/layouts/positioners/positioners.qmlproject +++ /dev/null @@ -1,18 +0,0 @@ -/* File generated by QtCreator */ - -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/layouts/positioners/positioners.qmlproject.user b/examples/declarative/layouts/positioners/positioners.qmlproject.user deleted file mode 100644 index 593479d..0000000 --- a/examples/declarative/layouts/positioners/positioners.qmlproject.user +++ /dev/null @@ -1,41 +0,0 @@ - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - UTF-8 - - - - ProjectExplorer.Project.Target.0 - - QML Runtime - QmlProjectManager.QmlTarget - -1 - 0 - 0 - - QML Runtime - QmlProjectManager.QmlRunConfiguration - 127.0.0.1 - 3768 - positioners.qml - - - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 4 - - diff --git a/examples/declarative/listmodel-threaded/dataloader.js b/examples/declarative/listmodel-threaded/dataloader.js deleted file mode 100644 index d720f09..0000000 --- a/examples/declarative/listmodel-threaded/dataloader.js +++ /dev/null @@ -1,9 +0,0 @@ -// ![0] -WorkerScript.onMessage = function(msg) { - if (msg.action == 'appendCurrentTime') { - var data = {'time': new Date().toTimeString()}; - msg.model.append(data); - msg.model.sync(); // updates the changes to the list - } -} -// ![0] diff --git a/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject b/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml deleted file mode 100644 index bad7010..0000000 --- a/examples/declarative/listmodel-threaded/timedisplay.qml +++ /dev/null @@ -1,32 +0,0 @@ -// ![0] -import Qt 4.7 - -ListView { - width: 200 - height: 300 - - model: listModel - delegate: Component { - Text { text: time } - } - - ListModel { id: listModel } - - WorkerScript { - id: worker - source: "dataloader.js" - } - - Timer { - id: timer - interval: 2000; repeat: true - running: true - triggeredOnStart: true - - onTriggered: { - var msg = {'action': 'appendCurrentTime', 'model': listModel}; - worker.sendMessage(msg); - } - } -} -// ![0] diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml deleted file mode 100644 index f65c2b3..0000000 --- a/examples/declarative/listview/content/ClickAutoRepeating.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index a625b4c..0000000 --- a/examples/declarative/listview/content/MediaButton.qml +++ /dev/null @@ -1,35 +0,0 @@ -import Qt 4.7 - -Item { - property variant 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 deleted file mode 100644 index f29d84b..0000000 Binary files a/examples/declarative/listview/content/pics/add.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/archive-insert.png b/examples/declarative/listview/content/pics/archive-insert.png deleted file mode 100644 index b706248..0000000 Binary files a/examples/declarative/listview/content/pics/archive-insert.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/archive-remove.png b/examples/declarative/listview/content/pics/archive-remove.png deleted file mode 100644 index 9640f6b..0000000 Binary files a/examples/declarative/listview/content/pics/archive-remove.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/button-pressed.png b/examples/declarative/listview/content/pics/button-pressed.png deleted file mode 100644 index e434d32..0000000 Binary files a/examples/declarative/listview/content/pics/button-pressed.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/button.png b/examples/declarative/listview/content/pics/button.png deleted file mode 100644 index 56a63ce..0000000 Binary files a/examples/declarative/listview/content/pics/button.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/del.png b/examples/declarative/listview/content/pics/del.png deleted file mode 100644 index 1d753a3..0000000 Binary files a/examples/declarative/listview/content/pics/del.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/fruit-salad.jpg b/examples/declarative/listview/content/pics/fruit-salad.jpg deleted file mode 100644 index da5a6b1..0000000 Binary files a/examples/declarative/listview/content/pics/fruit-salad.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/go-down.png b/examples/declarative/listview/content/pics/go-down.png deleted file mode 100644 index 63331a5..0000000 Binary files a/examples/declarative/listview/content/pics/go-down.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/go-up.png b/examples/declarative/listview/content/pics/go-up.png deleted file mode 100644 index 4459024..0000000 Binary files a/examples/declarative/listview/content/pics/go-up.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/hamburger.jpg b/examples/declarative/listview/content/pics/hamburger.jpg deleted file mode 100644 index d0a15be..0000000 Binary files a/examples/declarative/listview/content/pics/hamburger.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/lemonade.jpg b/examples/declarative/listview/content/pics/lemonade.jpg deleted file mode 100644 index db445c9..0000000 Binary files a/examples/declarative/listview/content/pics/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/list-add.png b/examples/declarative/listview/content/pics/list-add.png deleted file mode 100644 index e029787..0000000 Binary files a/examples/declarative/listview/content/pics/list-add.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/list-remove.png b/examples/declarative/listview/content/pics/list-remove.png deleted file mode 100644 index 2bb1a59..0000000 Binary files a/examples/declarative/listview/content/pics/list-remove.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/moreDown.png b/examples/declarative/listview/content/pics/moreDown.png deleted file mode 100644 index 31a35d5..0000000 Binary files a/examples/declarative/listview/content/pics/moreDown.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/moreUp.png b/examples/declarative/listview/content/pics/moreUp.png deleted file mode 100644 index fefb9c9..0000000 Binary files a/examples/declarative/listview/content/pics/moreUp.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/pancakes.jpg b/examples/declarative/listview/content/pics/pancakes.jpg deleted file mode 100644 index 60c4396..0000000 Binary files a/examples/declarative/listview/content/pics/pancakes.jpg and /dev/null differ diff --git a/examples/declarative/listview/content/pics/trash.png b/examples/declarative/listview/content/pics/trash.png deleted file mode 100644 index 2042595..0000000 Binary files a/examples/declarative/listview/content/pics/trash.png and /dev/null differ diff --git a/examples/declarative/listview/content/pics/vegetable-soup.jpg b/examples/declarative/listview/content/pics/vegetable-soup.jpg deleted file mode 100644 index 9dce332..0000000 Binary files a/examples/declarative/listview/content/pics/vegetable-soup.jpg and /dev/null differ diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml deleted file mode 100644 index f15dda3..0000000 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 - -// 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 deleted file mode 100644 index f707c82..0000000 --- a/examples/declarative/listview/dummydata/Recipes.qml +++ /dev/null @@ -1,90 +0,0 @@ -import Qt 4.7 - -ListModel { - id: recipesModel - ListElement { - title: "Pancakes" - picture: "content/pics/pancakes.jpg" - ingredients: " -
    -
  • 1 cup (150g) self-raising flour -
  • 1 tbs caster sugar -
  • 3/4 cup (185ml) milk -
  • 1 egg -
- " - method: " -
    -
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
  4. Turn over and cook other side until golden. -
- " - } - 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: " -
    -
  • 1 onion -
  • 1 turnip -
  • 1 potato -
  • 1 carrot -
  • 1 head of celery -
  • 1 1/2 litres of water -
- " - method: " -
    -
  1. Chop vegetables. -
  2. Boil in water until vegetables soften. -
  3. Season with salt and pepper to taste. -
- " - } - ListElement { - title: "Hamburger" - picture: "content/pics/hamburger.jpg" - ingredients: " -
    -
  • 500g minced beef -
  • Seasoning -
  • lettuce, tomato, onion, cheese -
  • 1 hamburger bun for each burger -
- " - method: " -
    -
  1. Mix the beef, together with seasoning, in a food processor. -
  2. Shape the beef into burgers. -
  3. Grill the burgers for about 5 mins on each side (until cooked through) -
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
- " - } - ListElement { - title: "Lemonade" - picture: "content/pics/lemonade.jpg" - ingredients: " -
    -
  • 1 cup Lemon Juice -
  • 1 cup Sugar -
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
- " - method: " -
    -
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
  3. Chill or serve over ice cubes. -
- " - } -} diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml deleted file mode 100644 index 64f324e..0000000 --- a/examples/declarative/listview/dynamic.qml +++ /dev/null @@ -1,208 +0,0 @@ -import Qt 4.7 -import "content" -import "../scrollbar" - -Rectangle { - id: container - 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: container.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 - width: parent.width - color: "White" - font.bold: true; font.pixelSize: 15 - text: name; elide: Text.ElideRight - } - Row { - spacing: 5 - Repeater { - model: attributes - Component { - Text { text: description; color: "White" } - } - } - } - } - - Row { - id: itemButtons - - anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } - width: childrenRect.width - spacing: 10 - - Image { - source: "content/pics/list-add.png" - scale: clickUp.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickUp - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost+0.25) - } - } - - Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } - - Image { - source: "content/pics/list-remove.png" - scale: clickDown.isPressed ? 0.9 : 1 - - ClickAutoRepeating { - id: clickDown - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } - } - } - Image { - id: removeButton - anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } - source: "content/pics/archive-remove.png" - - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } - } - } - } - - ListView { - id: view - anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } - model: fruitModel - delegate: fruitDelegate - } - - // Attach scrollbar to the right edge of the view. - ScrollBar { - id: verticalScrollBar - - width: 8; height: view.height; anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - - // Only show the scrollbar when the view is moving. - states: State { - name: "ShowBars"; when: view.movingVertically - PropertyChanges { target: verticalScrollBar; opacity: 1 } - } - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - Row { - id: buttons - - x: 8; width: childrenRect.width; height: childrenRect.height - anchors { bottom: parent.bottom; bottomMargin: 8 } - spacing: 8 - - 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 deleted file mode 100644 index ade355d..0000000 --- a/examples/declarative/listview/highlight.qml +++ /dev/null @@ -1,55 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 400; height: 300 - - // MyPets model is defined in dummydata/MyPetsModel.qml - // The launcher 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 { to: 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 deleted file mode 100644 index b73b3a3..0000000 --- a/examples/declarative/listview/itemlist.qml +++ /dev/null @@ -1,67 +0,0 @@ -// This example demonstrates placing items in a view using -// a VisualItemModel - -import Qt 4.7 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - } - - Rectangle { - width: 240; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} diff --git a/examples/declarative/listview/listview-example.qml b/examples/declarative/listview/listview-example.qml deleted file mode 100644 index 2e8cdda..0000000 --- a/examples/declarative/listview/listview-example.qml +++ /dev/null @@ -1,93 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 300 - - // 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 - currentIndex: list1.currentIndex - preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: ListView.ApplyRange - } - - ListView { - id: list3 - x: 400; width: 200; height: parent.height - model: MyPetsModel - delegate: petDelegate - - highlight: Rectangle { color: "lightsteelblue" } - currentIndex: list1.currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: ListView.StrictlyEnforceRange - flickDeceleration: 1000 - } -} diff --git a/examples/declarative/listview/listview.qmlproject b/examples/declarative/listview/listview.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/listview/listview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml deleted file mode 100644 index 990e272..0000000 --- a/examples/declarative/listview/recipes.qml +++ /dev/null @@ -1,160 +0,0 @@ -import Qt 4.7 -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 - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - width: list.width - - // 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 { - width: background.width-recipePic.width-20; height: recipePic.height; - 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 - wrapMode: Text.WordWrap - width: parent.width - opacity: wrapper.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width-20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: wrapper.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height; clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - MediaButton { - y: 10; anchors { right: background.right; rightMargin: 5 } - opacity: wrapper.detailsOpacity - text: "Close" - - onClicked: wrapper.state = ''; - } - - // Set the default height to the height of the picture, plus margin. - height: 68 - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger - PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view - - // 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 - anchors.fill: parent - clip: true - model: Recipes - delegate: recipeDelegate - } -} diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml deleted file mode 100644 index 21f9f03..0000000 --- a/examples/declarative/listview/sections.qml +++ /dev/null @@ -1,71 +0,0 @@ -import Qt 4.7 - -//! [0] -Rectangle { - width: 200 - height: 240 - - // 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 - height: desc.height // height is the combined height of the description and the section separator - - 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 - focus: true - - // 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 { - x: 2; height: parent.height - verticalAlignment: Text.AlignVCenter - text: section - font.bold: true - } - } - } -} -//! [0] diff --git a/examples/declarative/modelviews/gridview/gridview-example.qml b/examples/declarative/modelviews/gridview/gridview-example.qml new file mode 100644 index 0000000..a5f41fb --- /dev/null +++ b/examples/declarative/modelviews/gridview/gridview-example.qml @@ -0,0 +1,49 @@ +import Qt 4.7 + +Rectangle { + width: 300; height: 400 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + GridView { + anchors.fill: parent + cellWidth: 100; cellHeight: 100 + highlight: appHighlight + focus: true + model: appModel + delegate: appDelegate + } +} diff --git a/examples/declarative/modelviews/gridview/gridview.qmlproject b/examples/declarative/modelviews/gridview/gridview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/gridview/gridview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/gridview/pics/AddressBook_48.png b/examples/declarative/modelviews/gridview/pics/AddressBook_48.png new file mode 100644 index 0000000..1ab7c8e Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/AddressBook_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png new file mode 100644 index 0000000..f4b8689 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/Camera_48.png b/examples/declarative/modelviews/gridview/pics/Camera_48.png new file mode 100644 index 0000000..c76b524 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/Camera_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/DateBook_48.png b/examples/declarative/modelviews/gridview/pics/DateBook_48.png new file mode 100644 index 0000000..58f5787 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/DateBook_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/EMail_48.png b/examples/declarative/modelviews/gridview/pics/EMail_48.png new file mode 100644 index 0000000..d6d84a6 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/EMail_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/TodoList_48.png b/examples/declarative/modelviews/gridview/pics/TodoList_48.png new file mode 100644 index 0000000..0988448 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/TodoList_48.png differ diff --git a/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png new file mode 100644 index 0000000..52638c5 Binary files /dev/null and b/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png differ diff --git a/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml b/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml new file mode 100644 index 0000000..f65c2b3 --- /dev/null +++ b/examples/declarative/modelviews/listview/content/ClickAutoRepeating.qml @@ -0,0 +1,31 @@ +import Qt 4.7 + +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/modelviews/listview/content/MediaButton.qml b/examples/declarative/modelviews/listview/content/MediaButton.qml new file mode 100644 index 0000000..a625b4c --- /dev/null +++ b/examples/declarative/modelviews/listview/content/MediaButton.qml @@ -0,0 +1,35 @@ +import Qt 4.7 + +Item { + property variant 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/modelviews/listview/content/pics/add.png b/examples/declarative/modelviews/listview/content/pics/add.png new file mode 100644 index 0000000..f29d84b Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/add.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/archive-insert.png b/examples/declarative/modelviews/listview/content/pics/archive-insert.png new file mode 100644 index 0000000..b706248 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/archive-insert.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/archive-remove.png b/examples/declarative/modelviews/listview/content/pics/archive-remove.png new file mode 100644 index 0000000..9640f6b Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/archive-remove.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/button-pressed.png b/examples/declarative/modelviews/listview/content/pics/button-pressed.png new file mode 100644 index 0000000..e434d32 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/button-pressed.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/button.png b/examples/declarative/modelviews/listview/content/pics/button.png new file mode 100644 index 0000000..56a63ce Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/button.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/del.png b/examples/declarative/modelviews/listview/content/pics/del.png new file mode 100644 index 0000000..1d753a3 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/del.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg b/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg new file mode 100644 index 0000000..da5a6b1 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/go-down.png b/examples/declarative/modelviews/listview/content/pics/go-down.png new file mode 100644 index 0000000..63331a5 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/go-down.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/go-up.png b/examples/declarative/modelviews/listview/content/pics/go-up.png new file mode 100644 index 0000000..4459024 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/go-up.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/hamburger.jpg b/examples/declarative/modelviews/listview/content/pics/hamburger.jpg new file mode 100644 index 0000000..d0a15be Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/hamburger.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/lemonade.jpg b/examples/declarative/modelviews/listview/content/pics/lemonade.jpg new file mode 100644 index 0000000..db445c9 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/lemonade.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-add.png b/examples/declarative/modelviews/listview/content/pics/list-add.png new file mode 100644 index 0000000..e029787 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/list-add.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-remove.png b/examples/declarative/modelviews/listview/content/pics/list-remove.png new file mode 100644 index 0000000..2bb1a59 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/list-remove.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreDown.png b/examples/declarative/modelviews/listview/content/pics/moreDown.png new file mode 100644 index 0000000..31a35d5 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/moreDown.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreUp.png b/examples/declarative/modelviews/listview/content/pics/moreUp.png new file mode 100644 index 0000000..fefb9c9 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/moreUp.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/pancakes.jpg b/examples/declarative/modelviews/listview/content/pics/pancakes.jpg new file mode 100644 index 0000000..60c4396 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/pancakes.jpg differ diff --git a/examples/declarative/modelviews/listview/content/pics/trash.png b/examples/declarative/modelviews/listview/content/pics/trash.png new file mode 100644 index 0000000..2042595 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/trash.png differ diff --git a/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg new file mode 100644 index 0000000..9dce332 Binary files /dev/null and b/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg differ diff --git a/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml b/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml new file mode 100644 index 0000000..f15dda3 --- /dev/null +++ b/examples/declarative/modelviews/listview/dummydata/MyPetsModel.qml @@ -0,0 +1,61 @@ +import Qt 4.7 + +// 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/modelviews/listview/dummydata/Recipes.qml b/examples/declarative/modelviews/listview/dummydata/Recipes.qml new file mode 100644 index 0000000..f707c82 --- /dev/null +++ b/examples/declarative/modelviews/listview/dummydata/Recipes.qml @@ -0,0 +1,90 @@ +import Qt 4.7 + +ListModel { + id: recipesModel + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " +
    +
  • 1 cup (150g) self-raising flour +
  • 1 tbs caster sugar +
  • 3/4 cup (185ml) milk +
  • 1 egg +
+ " + method: " +
    +
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
  4. Turn over and cook other side until golden. +
+ " + } + 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: " +
    +
  • 1 onion +
  • 1 turnip +
  • 1 potato +
  • 1 carrot +
  • 1 head of celery +
  • 1 1/2 litres of water +
+ " + method: " +
    +
  1. Chop vegetables. +
  2. Boil in water until vegetables soften. +
  3. Season with salt and pepper to taste. +
+ " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " +
    +
  • 500g minced beef +
  • Seasoning +
  • lettuce, tomato, onion, cheese +
  • 1 hamburger bun for each burger +
+ " + method: " +
    +
  1. Mix the beef, together with seasoning, in a food processor. +
  2. Shape the beef into burgers. +
  3. Grill the burgers for about 5 mins on each side (until cooked through) +
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
+ " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " +
    +
  • 1 cup Lemon Juice +
  • 1 cup Sugar +
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
+ " + method: " +
    +
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
  3. Chill or serve over ice cubes. +
+ " + } +} diff --git a/examples/declarative/modelviews/listview/dynamic.qml b/examples/declarative/modelviews/listview/dynamic.qml new file mode 100644 index 0000000..693e88a --- /dev/null +++ b/examples/declarative/modelviews/listview/dynamic.qml @@ -0,0 +1,208 @@ +import Qt 4.7 +import "content" +import "../../ui-components/scrollbar" + +Rectangle { + id: container + 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: container.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 + width: parent.width + color: "White" + font.bold: true; font.pixelSize: 15 + text: name; elide: Text.ElideRight + } + Row { + spacing: 5 + Repeater { + model: attributes + Component { + Text { text: description; color: "White" } + } + } + } + } + + Row { + id: itemButtons + + anchors { right: removeButton.left; rightMargin: 35; verticalCenter: parent.verticalCenter } + width: childrenRect.width + spacing: 10 + + Image { + source: "content/pics/list-add.png" + scale: clickUp.isPressed ? 0.9 : 1 + + ClickAutoRepeating { + id: clickUp + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost+0.25) + } + } + + Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } + + Image { + source: "content/pics/list-remove.png" + scale: clickDown.isPressed ? 0.9 : 1 + + ClickAutoRepeating { + id: clickDown + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + } + } + Image { + id: removeButton + anchors { verticalCenter: parent.verticalCenter; right: parent.right; rightMargin: 10 } + source: "content/pics/archive-remove.png" + + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } + } + } + + ListView { + id: view + anchors { top: parent.top; left: parent.left; right: parent.right; bottom: buttons.top } + model: fruitModel + delegate: fruitDelegate + } + + // Attach scrollbar to the right edge of the view. + ScrollBar { + id: verticalScrollBar + + width: 8; height: view.height; anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + + // Only show the scrollbar when the view is moving. + states: State { + name: "ShowBars"; when: view.movingVertically + PropertyChanges { target: verticalScrollBar; opacity: 1 } + } + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + Row { + id: buttons + + x: 8; width: childrenRect.width; height: childrenRect.height + anchors { bottom: parent.bottom; bottomMargin: 8 } + spacing: 8 + + 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/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml new file mode 100644 index 0000000..ade355d --- /dev/null +++ b/examples/declarative/modelviews/listview/highlight.qml @@ -0,0 +1,55 @@ +import Qt 4.7 + +Rectangle { + width: 400; height: 300 + + // MyPets model is defined in dummydata/MyPetsModel.qml + // The launcher 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 { to: 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/modelviews/listview/itemlist.qml b/examples/declarative/modelviews/listview/itemlist.qml new file mode 100644 index 0000000..b73b3a3 --- /dev/null +++ b/examples/declarative/modelviews/listview/itemlist.qml @@ -0,0 +1,67 @@ +// This example demonstrates placing items in a view using +// a VisualItemModel + +import Qt 4.7 + +Rectangle { + color: "lightgray" + width: 240 + height: 320 + + VisualItemModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + } + + Rectangle { + width: 240; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/declarative/modelviews/listview/listview-example.qml b/examples/declarative/modelviews/listview/listview-example.qml new file mode 100644 index 0000000..2e8cdda --- /dev/null +++ b/examples/declarative/modelviews/listview/listview-example.qml @@ -0,0 +1,93 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 300 + + // 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 + currentIndex: list1.currentIndex + preferredHighlightBegin: 80; preferredHighlightEnd: 220 + highlightRangeMode: ListView.ApplyRange + } + + ListView { + id: list3 + x: 400; width: 200; height: parent.height + model: MyPetsModel + delegate: petDelegate + + highlight: Rectangle { color: "lightsteelblue" } + currentIndex: list1.currentIndex + preferredHighlightBegin: 125; preferredHighlightEnd: 125 + highlightRangeMode: ListView.StrictlyEnforceRange + flickDeceleration: 1000 + } +} diff --git a/examples/declarative/modelviews/listview/listview.qmlproject b/examples/declarative/modelviews/listview/listview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/listview/listview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/listview/recipes.qml b/examples/declarative/modelviews/listview/recipes.qml new file mode 100644 index 0000000..990e272 --- /dev/null +++ b/examples/declarative/modelviews/listview/recipes.qml @@ -0,0 +1,160 @@ +import Qt 4.7 +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 + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + width: list.width + + // 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 { + width: background.width-recipePic.width-20; height: recipePic.height; + 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 + wrapMode: Text.WordWrap + width: parent.width + opacity: wrapper.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width-20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: wrapper.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height; clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + MediaButton { + y: 10; anchors { right: background.right; rightMargin: 5 } + opacity: wrapper.detailsOpacity + text: "Close" + + onClicked: wrapper.state = ''; + } + + // Set the default height to the height of the picture, plus margin. + height: 68 + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipePic; width: 128; height: 128 } // Make picture bigger + PropertyChanges { target: wrapper; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: wrapper; height: list.height } // Fill the entire list area with the detailed view + + // 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 + anchors.fill: parent + clip: true + model: Recipes + delegate: recipeDelegate + } +} diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml new file mode 100644 index 0000000..21f9f03 --- /dev/null +++ b/examples/declarative/modelviews/listview/sections.qml @@ -0,0 +1,71 @@ +import Qt 4.7 + +//! [0] +Rectangle { + width: 200 + height: 240 + + // 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 + height: desc.height // height is the combined height of the description and the section separator + + 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 + focus: true + + // 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 { + x: 2; height: parent.height + verticalAlignment: Text.AlignVCenter + text: section + font.bold: true + } + } + } +} +//! [0] diff --git a/examples/declarative/modelviews/modelviews.pro b/examples/declarative/modelviews/modelviews.pro new file mode 100644 index 0000000..b811e44 --- /dev/null +++ b/examples/declarative/modelviews/modelviews.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + objectlistmodel \ + stringlistmodel + + diff --git a/examples/declarative/modelviews/modelviews.qmlproject b/examples/declarative/modelviews/modelviews.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/modelviews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.cpp b/examples/declarative/modelviews/objectlistmodel/dataobject.cpp new file mode 100644 index 0000000..14be1b9 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/dataobject.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "dataobject.h" + +DataObject::DataObject(QObject *parent) + : QObject(parent) +{ +} + +DataObject::DataObject(const QString &name, const QString &color, QObject *parent) + : QObject(parent), m_name(name), m_color(color) +{ +} + +QString DataObject::name() const +{ + return m_name; +} + +void DataObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +QString DataObject::color() const +{ + return m_color; +} + +void DataObject::setColor(const QString &color) +{ + if (color != m_color) { + m_color = color; + emit colorChanged(); + } +} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.h b/examples/declarative/modelviews/objectlistmodel/dataobject.h new file mode 100644 index 0000000..852110d --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/dataobject.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATAOBJECT_H +#define DATAOBJECT_H + +#include + +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) + +public: + DataObject(QObject *parent=0); + DataObject(const QString &name, const QString &color, QObject *parent=0); + + QString name() const; + void setName(const QString &name); + + QString color() const; + void setColor(const QString &color); + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; +}; + +#endif // DATAOBJECT_H diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp new file mode 100644 index 0000000..b210570 --- /dev/null +++ b/examples/declarative/modelviews/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 + +#include +#include +#include +#include +#include + +#include "dataobject.h" + +/* + This example illustrates exposing a QList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QDeclarativeView view; + + QList 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/modelviews/objectlistmodel/objectlistmodel.pro b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000..869cde3 --- /dev/null +++ b/examples/declarative/modelviews/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/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml new file mode 100644 index 0000000..2b8383f --- /dev/null +++ b/examples/declarative/modelviews/objectlistmodel/view.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { text: name } + } + } +} diff --git a/examples/declarative/modelviews/package/Delegate.qml b/examples/declarative/modelviews/package/Delegate.qml new file mode 100644 index 0000000..785fde6 --- /dev/null +++ b/examples/declarative/modelviews/package/Delegate.qml @@ -0,0 +1,48 @@ +import Qt 4.7 + +//![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/modelviews/package/package.qmlproject b/examples/declarative/modelviews/package/package.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/package/package.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml new file mode 100644 index 0000000..67f896b --- /dev/null +++ b/examples/declarative/modelviews/package/view.qml @@ -0,0 +1,35 @@ +import Qt 4.7 + +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/modelviews/parallax/parallax.qml b/examples/declarative/modelviews/parallax/parallax.qml new file mode 100644 index 0000000..110f17e --- /dev/null +++ b/examples/declarative/modelviews/parallax/parallax.qml @@ -0,0 +1,41 @@ +import Qt 4.7 +import "../../toys/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; + source: "../../../../demos/declarative/samegame/samegame.qml" + } + } + + currentIndex: root.currentIndex + } +} diff --git a/examples/declarative/modelviews/parallax/parallax.qmlproject b/examples/declarative/modelviews/parallax/parallax.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/parallax/parallax.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/modelviews/parallax/pics/background.jpg b/examples/declarative/modelviews/parallax/pics/background.jpg new file mode 100644 index 0000000..61cca2f Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/background.jpg differ diff --git a/examples/declarative/modelviews/parallax/pics/face-smile.png b/examples/declarative/modelviews/parallax/pics/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/face-smile.png differ diff --git a/examples/declarative/modelviews/parallax/pics/home-page.svg b/examples/declarative/modelviews/parallax/pics/home-page.svg new file mode 100644 index 0000000..4f16958 --- /dev/null +++ b/examples/declarative/modelviews/parallax/pics/home-page.svg @@ -0,0 +1,445 @@ + +image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/modelviews/parallax/pics/shadow.png b/examples/declarative/modelviews/parallax/pics/shadow.png new file mode 100644 index 0000000..8270565 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/shadow.png differ diff --git a/examples/declarative/modelviews/parallax/pics/yast-joystick.png b/examples/declarative/modelviews/parallax/pics/yast-joystick.png new file mode 100644 index 0000000..858cea0 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/yast-joystick.png differ diff --git a/examples/declarative/modelviews/parallax/pics/yast-wol.png b/examples/declarative/modelviews/parallax/pics/yast-wol.png new file mode 100644 index 0000000..7712180 Binary files /dev/null and b/examples/declarative/modelviews/parallax/pics/yast-wol.png differ diff --git a/examples/declarative/modelviews/parallax/qml/ParallaxView.qml b/examples/declarative/modelviews/parallax/qml/ParallaxView.qml new file mode 100644 index 0000000..e869a21 --- /dev/null +++ b/examples/declarative/modelviews/parallax/qml/ParallaxView.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +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: Qt.Horizontal + boundsBehavior: Flickable.DragOverBounds + 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: Qt.Horizontal + + delegate: Item { + width: 50; height: 50 + id: delegateRoot + + Image { + id: image + source: modelData.icon + smooth: true + scale: 0.8 + } + + MouseArea { + anchors.fill: parent + onClicked: { root.currentIndex = index } + } + + states: State { + name: "Selected" + when: delegateRoot.ListView.isCurrentItem == true + PropertyChanges { + target: image + scale: 1 + y: -5 + } + } + transitions: Transition { + NumberAnimation { + properties: "scale,y" + } + } + } + model: visualModel.children + } +} diff --git a/examples/declarative/modelviews/parallax/qml/Smiley.qml b/examples/declarative/modelviews/parallax/qml/Smiley.qml new file mode 100644 index 0000000..662addc --- /dev/null +++ b/examples/declarative/modelviews/parallax/qml/Smiley.qml @@ -0,0 +1,46 @@ +import Qt 4.7 + +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 + + // 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: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} + diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp new file mode 100644 index 0000000..abbffa7 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/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 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 + +#include +#include +#include +#include +#include + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QDeclarativeView view; + + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + 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/modelviews/stringlistmodel/stringlistmodel.pro b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000..23dc481 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = stringlistmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml new file mode 100644 index 0000000..41c03d9 --- /dev/null +++ b/examples/declarative/modelviews/stringlistmodel/view.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } + } +} diff --git a/examples/declarative/modelviews/webview/alerts.html b/examples/declarative/modelviews/webview/alerts.html new file mode 100644 index 0000000..82caddf --- /dev/null +++ b/examples/declarative/modelviews/webview/alerts.html @@ -0,0 +1,5 @@ + + +

This is a web page. It fires an alert when clicked. + + diff --git a/examples/declarative/modelviews/webview/alerts.qml b/examples/declarative/modelviews/webview/alerts.qml new file mode 100644 index 0000000..7684c3e --- /dev/null +++ b/examples/declarative/modelviews/webview/alerts.qml @@ -0,0 +1,58 @@ +import Qt 4.7 +import org.webkit 1.0 + +WebView { + id: webView + width: 120 + height: 150 + url: "alerts.html" + + onAlert: popup.show(message) + + Rectangle { + id: popup + + color: "red" + border.color: "black"; border.width: 2 + radius: 4 + + y: parent.height // off "screen" + anchors.horizontalCenter: parent.horizontalCenter + width: label.width+5 + height: label.height+5 + + opacity: 0 + + function show(t) { + label.text = t + popup.state = "visible" + timer.start() + } + states: State { + name: "visible" + PropertyChanges { target: popup; opacity: 1 } + PropertyChanges { target: popup; y: (webView.height-popup.height)/2 } + } + + transitions: [ + Transition { from: ""; PropertyAnimation { properties: "opacity,y"; duration: 65 } }, + Transition { from: "visible"; PropertyAnimation { properties: "opacity,y"; duration: 500 } } + ] + + Timer { + id: timer + interval: 1000 + onTriggered: popup.state = "" + } + + Text { + id: label + anchors.centerIn: parent + color: "white" + font.pixelSize: 20 + width: webView.width*0.75 + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + } + } +} diff --git a/examples/declarative/modelviews/webview/autosize.qml b/examples/declarative/modelviews/webview/autosize.qml new file mode 100644 index 0000000..9632883 --- /dev/null +++ b/examples/declarative/modelviews/webview/autosize.qml @@ -0,0 +1,62 @@ +import Qt 4.7 +import org.webkit 1.0 + +// The WebView size is determined by the width, height, +// preferredWidth, and preferredHeight properties. +Rectangle { + id: rect + 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/modelviews/webview/content/FieldText.qml b/examples/declarative/modelviews/webview/content/FieldText.qml new file mode 100644 index 0000000..d1d003f --- /dev/null +++ b/examples/declarative/modelviews/webview/content/FieldText.qml @@ -0,0 +1,157 @@ +import Qt 4.7 + +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/modelviews/webview/content/Mapping/Map.qml b/examples/declarative/modelviews/webview/content/Mapping/Map.qml new file mode 100644 index 0000000..5d3ba81 --- /dev/null +++ b/examples/declarative/modelviews/webview/content/Mapping/Map.qml @@ -0,0 +1,26 @@ +import Qt 4.7 +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/modelviews/webview/content/Mapping/map.html b/examples/declarative/modelviews/webview/content/Mapping/map.html new file mode 100755 index 0000000..a8726fd --- /dev/null +++ b/examples/declarative/modelviews/webview/content/Mapping/map.html @@ -0,0 +1,52 @@ + + + + + + + +

+ + diff --git a/examples/declarative/modelviews/webview/content/SpinSquare.qml b/examples/declarative/modelviews/webview/content/SpinSquare.qml new file mode 100644 index 0000000..dba48d4 --- /dev/null +++ b/examples/declarative/modelviews/webview/content/SpinSquare.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Item { + property variant period : 250 + property variant 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/modelviews/webview/content/pics/cancel.png b/examples/declarative/modelviews/webview/content/pics/cancel.png new file mode 100644 index 0000000..ecc9533 Binary files /dev/null and b/examples/declarative/modelviews/webview/content/pics/cancel.png differ diff --git a/examples/declarative/modelviews/webview/content/pics/ok.png b/examples/declarative/modelviews/webview/content/pics/ok.png new file mode 100644 index 0000000..5795f04 Binary files /dev/null and b/examples/declarative/modelviews/webview/content/pics/ok.png differ diff --git a/examples/declarative/modelviews/webview/googleMaps.qml b/examples/declarative/modelviews/webview/googleMaps.qml new file mode 100644 index 0000000..5506012 --- /dev/null +++ b/examples/declarative/modelviews/webview/googleMaps.qml @@ -0,0 +1,43 @@ +// 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.7 +import org.webkit 1.0 +import "content/Mapping" + +Map { + id: map + width: 300 + height: 300 + address: "Paris" + + Rectangle { + x: 70 + width: input.width + 20 + height: input.height + 4 + anchors.bottom: parent.bottom; anchors.bottomMargin: 5 + radius: 5 + opacity: map.status == "Ready" ? 1 : 0 + + 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/modelviews/webview/inline-html.qml b/examples/declarative/modelviews/webview/inline-html.qml new file mode 100644 index 0000000..eec7fc6 --- /dev/null +++ b/examples/declarative/modelviews/webview/inline-html.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import org.webkit 1.0 + +// Inline HTML with loose formatting can be +// set on the html property. +WebView { + html:"\ + \ + \ +
OneTwoThree\ +
1X1X\ +
20X0\ +
3X1X\ +
" +} diff --git a/examples/declarative/modelviews/webview/newwindows.html b/examples/declarative/modelviews/webview/newwindows.html new file mode 100644 index 0000000..f169599 --- /dev/null +++ b/examples/declarative/modelviews/webview/newwindows.html @@ -0,0 +1,3 @@ +

Multiple windows...

+ +Popup! diff --git a/examples/declarative/modelviews/webview/newwindows.qml b/examples/declarative/modelviews/webview/newwindows.qml new file mode 100644 index 0000000..2e4a72e --- /dev/null +++ b/examples/declarative/modelviews/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.7 +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/modelviews/webview/transparent.qml b/examples/declarative/modelviews/webview/transparent.qml new file mode 100644 index 0000000..e4efc31 --- /dev/null +++ b/examples/declarative/modelviews/webview/transparent.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +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 World!" + } +} diff --git a/examples/declarative/modelviews/webview/webview.qmlproject b/examples/declarative/modelviews/webview/webview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/modelviews/webview/webview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/mousearea/mouse.qml b/examples/declarative/mousearea/mouse.qml deleted file mode 100644 index 06134b7..0000000 --- a/examples/declarative/mousearea/mouse.qml +++ /dev/null @@ -1,47 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 200; height: 200 - - Rectangle { - width: 50; height: 50 - color: "red" - - Text { text: "Click"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - 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) - } - } - - Rectangle { - y: 100; width: 50; height: 50 - color: "blue" - - Text { text: "Drag"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - drag.target: parent - drag.axis: Drag.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') - } - } -} diff --git a/examples/declarative/mousearea/mousearea.qmlproject b/examples/declarative/mousearea/mousearea.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/mousearea/mousearea.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/objectlistmodel/dataobject.cpp b/examples/declarative/objectlistmodel/dataobject.cpp deleted file mode 100644 index 14be1b9..0000000 --- a/examples/declarative/objectlistmodel/dataobject.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "dataobject.h" - -DataObject::DataObject(QObject *parent) - : QObject(parent) -{ -} - -DataObject::DataObject(const QString &name, const QString &color, QObject *parent) - : QObject(parent), m_name(name), m_color(color) -{ -} - -QString DataObject::name() const -{ - return m_name; -} - -void DataObject::setName(const QString &name) -{ - if (name != m_name) { - m_name = name; - emit nameChanged(); - } -} - -QString DataObject::color() const -{ - return m_color; -} - -void DataObject::setColor(const QString &color) -{ - if (color != m_color) { - m_color = color; - emit colorChanged(); - } -} diff --git a/examples/declarative/objectlistmodel/dataobject.h b/examples/declarative/objectlistmodel/dataobject.h deleted file mode 100644 index 852110d..0000000 --- a/examples/declarative/objectlistmodel/dataobject.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 - -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) - -public: - DataObject(QObject *parent=0); - DataObject(const QString &name, const QString &color, QObject *parent=0); - - QString name() const; - void setName(const QString &name); - - QString color() const; - void setColor(const QString &color); - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -}; - -#endif // DATAOBJECT_H diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp deleted file mode 100644 index b210570..0000000 --- a/examples/declarative/objectlistmodel/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 - -#include -#include -#include -#include -#include - -#include "dataobject.h" - -/* - This example illustrates exposing a QList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QList 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 deleted file mode 100644 index 869cde3..0000000 --- a/examples/declarative/objectlistmodel/objectlistmodel.pro +++ /dev/null @@ -1,18 +0,0 @@ -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.qmlproject b/examples/declarative/objectlistmodel/objectlistmodel.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/objectlistmodel/objectlistmodel.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/objectlistmodel/objectlistmodel.qrc b/examples/declarative/objectlistmodel/objectlistmodel.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/objectlistmodel/objectlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/objectlistmodel/view.qml b/examples/declarative/objectlistmodel/view.qml deleted file mode 100644 index 2b8383f..0000000 --- a/examples/declarative/objectlistmodel/view.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.7 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { text: name } - } - } -} diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml deleted file mode 100644 index 785fde6..0000000 --- a/examples/declarative/package/Delegate.qml +++ /dev/null @@ -1,48 +0,0 @@ -import Qt 4.7 - -//![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/package.qmlproject b/examples/declarative/package/package.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/package/package.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml deleted file mode 100644 index 67f896b..0000000 --- a/examples/declarative/package/view.qml +++ /dev/null @@ -1,35 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index ca00176..0000000 --- a/examples/declarative/parallax/parallax.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.7 -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; - source: "../../../demos/declarative/samegame/samegame.qml" - } - } - - currentIndex: root.currentIndex - } -} diff --git a/examples/declarative/parallax/parallax.qmlproject b/examples/declarative/parallax/parallax.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/parallax/parallax.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/parallax/pics/background.jpg b/examples/declarative/parallax/pics/background.jpg deleted file mode 100644 index 61cca2f..0000000 Binary files a/examples/declarative/parallax/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/parallax/pics/face-smile.png b/examples/declarative/parallax/pics/face-smile.png deleted file mode 100644 index 3d66d72..0000000 Binary files a/examples/declarative/parallax/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/parallax/pics/home-page.svg b/examples/declarative/parallax/pics/home-page.svg deleted file mode 100644 index 4f16958..0000000 --- a/examples/declarative/parallax/pics/home-page.svg +++ /dev/null @@ -1,445 +0,0 @@ - -image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/parallax/pics/shadow.png b/examples/declarative/parallax/pics/shadow.png deleted file mode 100644 index 8270565..0000000 Binary files a/examples/declarative/parallax/pics/shadow.png and /dev/null differ diff --git a/examples/declarative/parallax/pics/yast-joystick.png b/examples/declarative/parallax/pics/yast-joystick.png deleted file mode 100644 index 858cea0..0000000 Binary files a/examples/declarative/parallax/pics/yast-joystick.png and /dev/null differ diff --git a/examples/declarative/parallax/pics/yast-wol.png b/examples/declarative/parallax/pics/yast-wol.png deleted file mode 100644 index 7712180..0000000 Binary files a/examples/declarative/parallax/pics/yast-wol.png and /dev/null differ diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml deleted file mode 100644 index e869a21..0000000 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -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: Qt.Horizontal - boundsBehavior: Flickable.DragOverBounds - 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: Qt.Horizontal - - delegate: Item { - width: 50; height: 50 - id: delegateRoot - - Image { - id: image - source: modelData.icon - smooth: true - scale: 0.8 - } - - MouseArea { - anchors.fill: parent - onClicked: { root.currentIndex = index } - } - - states: State { - name: "Selected" - when: delegateRoot.ListView.isCurrentItem == true - PropertyChanges { - target: image - scale: 1 - y: -5 - } - } - transitions: Transition { - NumberAnimation { - properties: "scale,y" - } - } - } - model: visualModel.children - } -} diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml deleted file mode 100644 index 662addc..0000000 --- a/examples/declarative/parallax/qml/Smiley.qml +++ /dev/null @@ -1,46 +0,0 @@ -import Qt 4.7 - -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 - - // 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: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} - diff --git a/examples/declarative/plugins/README b/examples/declarative/plugins/README deleted file mode 100644 index fe519f8..0000000 --- a/examples/declarative/plugins/README +++ /dev/null @@ -1,9 +0,0 @@ -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 -I . plugins.qml - diff --git a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml deleted file mode 100644 index 0048372..0000000 --- a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml +++ /dev/null @@ -1,50 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: clock - width: 200; height: 200; color: "gray" - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant 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 - to: (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 - to: 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 deleted file mode 100644 index 7fbd802..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/center.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/plugins/com/nokia/TimeExample/clock.png deleted file mode 100644 index 462edac..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/clock.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/plugins/com/nokia/TimeExample/hour.png deleted file mode 100644 index f8061a1..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/hour.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/plugins/com/nokia/TimeExample/minute.png deleted file mode 100644 index 1297ec7..0000000 Binary files a/examples/declarative/plugins/com/nokia/TimeExample/minute.png and /dev/null differ diff --git a/examples/declarative/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/plugins/com/nokia/TimeExample/qmldir deleted file mode 100644 index e9ef115..0000000 --- a/examples/declarative/plugins/com/nokia/TimeExample/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Clock 1.0 Clock.qml -plugin qtimeexampleqmlplugin diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp deleted file mode 100644 index fb51b0c..0000000 --- a/examples/declarative/plugins/plugin.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include -#include - -// Implements a "TimeModel" 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 TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) - -public: - TimeModel(QObject *parent=0) : QObject(parent) - { - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(qApp); - connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); - timer->start(); - } - } - - ~TimeModel() - { - 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 TimeModel::instances=0; -MinuteTimer *TimeModel::timer=0; - -class QExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType(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 deleted file mode 100644 index b501ae3..0000000 --- a/examples/declarative/plugins/plugins.pro +++ /dev/null @@ -1,31 +0,0 @@ -TEMPLATE = lib -DESTDIR = com/nokia/TimeExample -TARGET = qtimeexampleqmlplugin -CONFIG += qt plugin -QT += declarative - -SOURCES += plugin.cpp - -qdeclarativesources.files += \ - com/nokia/TimeExample/qmldir \ - 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 - -symbian:{ - TARGET.EPOCALLOWDLLDATA=1 -} - - -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 deleted file mode 100644 index 449cd9a..0000000 --- a/examples/declarative/plugins/plugins.qml +++ /dev/null @@ -1,11 +0,0 @@ -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/plugins/plugins.qmlproject b/examples/declarative/plugins/plugins.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/plugins/plugins.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/positioners/Button.qml b/examples/declarative/positioners/Button.qml new file mode 100644 index 0000000..d03eeb5 --- /dev/null +++ b/examples/declarative/positioners/Button.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Rectangle { + id: page + + property string text + property string icon + signal clicked + + border.color: "black"; color: "steelblue"; radius: 5 + width: pix.width + textelement.width + 13 + height: pix.height + 10 + + Image { id: pix; x: 5; y:5; source: parent.icon } + + Text { + id: textelement + text: page.text; color: "white" + x: pix.width + pix.x + 3 + anchors.verticalCenter: pix.verticalCenter + } + + MouseArea { + id: mr + anchors.fill: parent + onClicked: { parent.focus = true; page.clicked() } + } + + states: State { + name: "pressed"; when: mr.pressed + PropertyChanges { target: textelement; x: 5 } + PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } + } + + transitions: Transition { + NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } + } +} diff --git a/examples/declarative/positioners/add.png b/examples/declarative/positioners/add.png new file mode 100644 index 0000000..f29d84b Binary files /dev/null and b/examples/declarative/positioners/add.png differ diff --git a/examples/declarative/positioners/del.png b/examples/declarative/positioners/del.png new file mode 100644 index 0000000..1d753a3 Binary files /dev/null and b/examples/declarative/positioners/del.png differ diff --git a/examples/declarative/positioners/positioners.qml b/examples/declarative/positioners/positioners.qml new file mode 100644 index 0000000..2cb0b8b --- /dev/null +++ b/examples/declarative/positioners/positioners.qml @@ -0,0 +1,213 @@ +import Qt 4.7 + +Rectangle { + id: page + width: 420; height: 420 + + Column { + id: layout1 + y: 0 + move: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV1 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV2 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } + } + + Row { + id: layout2 + y: 300 + move: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH1 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH2 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } + + Button { + x: 135; y: 90 + text: "Remove" + icon: "del.png" + + onClicked: { + blueH2.opacity = 0 + blueH1.opacity = 0 + blueV1.opacity = 0 + blueV2.opacity = 0 + blueG1.opacity = 0 + blueG2.opacity = 0 + blueG3.opacity = 0 + blueF1.opacity = 0 + blueF2.opacity = 0 + blueF3.opacity = 0 + } + } + + Button { + x: 145; y: 140 + text: "Add" + icon: "add.png" + + onClicked: { + blueH2.opacity = 1 + blueH1.opacity = 1 + blueV1.opacity = 1 + blueV2.opacity = 1 + blueG1.opacity = 1 + blueG2.opacity = 1 + blueG3.opacity = 1 + blueF1.opacity = 1 + blueF2.opacity = 1 + blueF3.opacity = 1 + } + } + + Grid { + x: 260; y: 0 + columns: 3 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG1 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG2 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG3 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + } + + Flow { + id: layout4 + x: 260; y: 250; width: 150 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF1 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF2 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF3 + width: 40; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } + } + +} diff --git a/examples/declarative/positioners/positioners.qmlproject b/examples/declarative/positioners/positioners.qmlproject new file mode 100644 index 0000000..e526217 --- /dev/null +++ b/examples/declarative/positioners/positioners.qmlproject @@ -0,0 +1,18 @@ +/* File generated by QtCreator */ + +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/positioners/positioners.qmlproject.user b/examples/declarative/positioners/positioners.qmlproject.user new file mode 100644 index 0000000..593479d --- /dev/null +++ b/examples/declarative/positioners/positioners.qmlproject.user @@ -0,0 +1,41 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + UTF-8 + + + + ProjectExplorer.Project.Target.0 + + QML Runtime + QmlProjectManager.QmlTarget + -1 + 0 + 0 + + QML Runtime + QmlProjectManager.QmlRunConfiguration + 127.0.0.1 + 3768 + positioners.qml + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml deleted file mode 100644 index bc36df5..0000000 --- a/examples/declarative/progressbar/content/ProgressBar.qml +++ /dev/null @@ -1,43 +0,0 @@ -import Qt 4.7 - -Item { - id: progressbar - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: gradient1.color - property alias secondColor: gradient2.color - - width: 250; height: 23 - clip: true - - BorderImage { - source: "background.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Rectangle { - id: highlight - - property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) - - width: highlight.widthDest - Behavior on width { SmoothedAnimation { velocity: 1200 } } - - anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 } - radius: 1 - gradient: Gradient { - GradientStop { id: gradient1; position: 0.0 } - GradientStop { id: gradient2; position: 1.0 } - } - - } - Text { - anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } - color: "white" - font.bold: true - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/declarative/progressbar/content/background.png b/examples/declarative/progressbar/content/background.png deleted file mode 100644 index 9044226..0000000 Binary files a/examples/declarative/progressbar/content/background.png and /dev/null differ diff --git a/examples/declarative/progressbar/progressbar.qmlproject b/examples/declarative/progressbar/progressbar.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/progressbar/progressbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml deleted file mode 100644 index 55fd682..0000000 --- a/examples/declarative/progressbar/progressbars.qml +++ /dev/null @@ -1,33 +0,0 @@ -import Qt 4.7 -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/proxyviewer/main.cpp b/examples/declarative/proxyviewer/main.cpp deleted file mode 100644 index b82d2c9..0000000 --- a/examples/declarative/proxyviewer/main.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include - -#include -#include -#include - - -/* - This example illustrates using a QNetworkAccessManagerFactory to - create a QNetworkAccessManager with a proxy. - - Usage: - proxyviewer [-host -port ] [file] -*/ - -static QString proxyHost; -static int proxyPort = 0; - -class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - virtual QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *nam = new QNetworkAccessManager(parent); - if (!proxyHost.isEmpty()) { - qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); - QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); - nam->setProxy(proxy); - } - - return nam; -} - -int main(int argc, char ** argv) -{ - QUrl source("qrc:view.qml"); - - QApplication app(argc, argv); - - for (int i = 1; i < argc; ++i) { - QString arg(argv[i]); - if (arg == "-host" && i < argc-1) { - proxyHost = argv[++i]; - } else if (arg == "-port" && i < argc-1) { - arg = argv[++i]; - proxyPort = arg.toInt(); - } else if (arg[0] != '-') { - source = QUrl::fromLocalFile(arg); - } else { - qWarning() << "Usage: proxyviewer [-host -port ] [file]"; - exit(1); - } - } - - QDeclarativeView view; - view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); - - view.setSource(source); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/proxyviewer/proxyviewer.pro b/examples/declarative/proxyviewer/proxyviewer.pro deleted file mode 100644 index b6bfa7f..0000000 --- a/examples/declarative/proxyviewer/proxyviewer.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -TARGET = proxyviewer -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative network - -# Input -SOURCES += main.cpp -RESOURCES += proxyviewer.qrc diff --git a/examples/declarative/proxyviewer/proxyviewer.qrc b/examples/declarative/proxyviewer/proxyviewer.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/proxyviewer/proxyviewer.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/proxyviewer/view.qml b/examples/declarative/proxyviewer/view.qml deleted file mode 100644 index 7f1bdef..0000000 --- a/examples/declarative/proxyviewer/view.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.7 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/examples/declarative/proxywidgets/ProxyWidgets/qmldir b/examples/declarative/proxywidgets/ProxyWidgets/qmldir deleted file mode 100644 index e55267c..0000000 --- a/examples/declarative/proxywidgets/ProxyWidgets/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin proxywidgetsplugin diff --git a/examples/declarative/proxywidgets/README b/examples/declarative/proxywidgets/README deleted file mode 100644 index f50fa22..0000000 --- a/examples/declarative/proxywidgets/README +++ /dev/null @@ -1,4 +0,0 @@ -To run: - - make install - qml proxywidgets.qml diff --git a/examples/declarative/proxywidgets/proxywidgets.cpp b/examples/declarative/proxywidgets/proxywidgets.cpp deleted file mode 100644 index 067eb2c..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 -#include -#include -#include -#include - -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 ProxyWidgetsPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "MyPushButton"); - } -}; - -#include "proxywidgets.moc" - -Q_EXPORT_PLUGIN2(proxywidgetsplugin, ProxyWidgetsPlugin); diff --git a/examples/declarative/proxywidgets/proxywidgets.pro b/examples/declarative/proxywidgets/proxywidgets.pro deleted file mode 100644 index cb07d80..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.pro +++ /dev/null @@ -1,21 +0,0 @@ -TEMPLATE = lib -DESTDIR = ProxyWidgets -TARGET = proxywidgetsplugin -CONFIG += qt plugin -QT += declarative - -SOURCES += proxywidgets.cpp - -sources.files += proxywidgets.pro proxywidgets.cpp proxywidgets.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) - -symbian:{ - TARGET.EPOCALLOWDLLDATA = 1 -} \ No newline at end of file diff --git a/examples/declarative/proxywidgets/proxywidgets.qml b/examples/declarative/proxywidgets/proxywidgets.qml deleted file mode 100644 index 88de37f..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.qml +++ /dev/null @@ -1,70 +0,0 @@ -import Qt 4.7 -import "ProxyWidgets" 1.0 - -Rectangle { - id: window - - property int margin: 30 - - width: 640; height: 480 - color: palette.window - - SystemPalette { id: palette } - - MyPushButton { - id: button1 - x: margin; y: margin - text: "Right" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: window.state = "right" - } - - MyPushButton { - id: button2 - x: margin; y: margin + 30 - text: "Bottom" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: window.state = "bottom" - } - - MyPushButton { - id: button3 - x: margin; y: margin + 60 - text: "Quit" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: Qt.quit() - } - - 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: Easing.OutQuad } - ColorAnimation { target: window; duration: 600 } - } - } -} diff --git a/examples/declarative/proxywidgets/proxywidgets.qmlproject b/examples/declarative/proxywidgets/proxywidgets.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/proxywidgets/proxywidgets.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml deleted file mode 100644 index c628a20..0000000 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ /dev/null @@ -1,33 +0,0 @@ -import Qt 4.7 - -Item { - id: scrollBar - - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } -} diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml deleted file mode 100644 index 6b12d85..0000000 --- a/examples/declarative/scrollbar/display.qml +++ /dev/null @@ -1,54 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - from: "*"; to: "*" - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/declarative/scrollbar/pics/niagara_falls.jpg b/examples/declarative/scrollbar/pics/niagara_falls.jpg deleted file mode 100644 index 618d808..0000000 Binary files a/examples/declarative/scrollbar/pics/niagara_falls.jpg and /dev/null differ diff --git a/examples/declarative/scrollbar/scrollbar.qmlproject b/examples/declarative/scrollbar/scrollbar.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/scrollbar/scrollbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml deleted file mode 100644 index aae7ee9..0000000 --- a/examples/declarative/searchbox/SearchBox.qml +++ /dev/null @@ -1,65 +0,0 @@ -import Qt 4.7 - -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; leftMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; 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 deleted file mode 100644 index 91eb270..0000000 Binary files a/examples/declarative/searchbox/images/edit-clear-locationbar-rtl.png and /dev/null differ diff --git a/examples/declarative/searchbox/images/lineedit-bg-focus.png b/examples/declarative/searchbox/images/lineedit-bg-focus.png deleted file mode 100644 index bbfac38..0000000 Binary files a/examples/declarative/searchbox/images/lineedit-bg-focus.png and /dev/null differ diff --git a/examples/declarative/searchbox/images/lineedit-bg.png b/examples/declarative/searchbox/images/lineedit-bg.png deleted file mode 100644 index 9044226..0000000 Binary files a/examples/declarative/searchbox/images/lineedit-bg.png and /dev/null differ diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml deleted file mode 100644 index 9f73473..0000000 --- a/examples/declarative/searchbox/main.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 500; height: 250 - color: "#edecec" - - Column { - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - spacing: 10 - - SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } - SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } - SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } - } -} diff --git a/examples/declarative/searchbox/searchbox.qmlproject b/examples/declarative/searchbox/searchbox.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/searchbox/searchbox.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml deleted file mode 100644 index 526a171..0000000 --- a/examples/declarative/slideswitch/content/Switch.qml +++ /dev/null @@ -1,76 +0,0 @@ -//![0] -import Qt 4.7 - -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 - x: 1; y: 2 - source: "knob.svg" - - MouseArea { - anchors.fill: parent - drag.target: knob; drag.axis: Drag.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: Easing.InOutQuad; duration: 200 } - } -//![7] -} -//![0] diff --git a/examples/declarative/slideswitch/content/background.svg b/examples/declarative/slideswitch/content/background.svg deleted file mode 100644 index f920d3e..0000000 --- a/examples/declarative/slideswitch/content/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/declarative/slideswitch/content/knob.svg b/examples/declarative/slideswitch/content/knob.svg deleted file mode 100644 index fb69337..0000000 --- a/examples/declarative/slideswitch/content/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml deleted file mode 100644 index 51c3c77..0000000 --- a/examples/declarative/slideswitch/slideswitch.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - color: "white" - width: 400; height: 250 - -//![0] - Switch { anchors.centerIn: parent; on: false } -//![0] -} diff --git a/examples/declarative/slideswitch/slideswitch.qmlproject b/examples/declarative/slideswitch/slideswitch.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/slideswitch/slideswitch.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/spinner/content/Spinner.qml b/examples/declarative/spinner/content/Spinner.qml deleted file mode 100644 index 8145a28..0000000 --- a/examples/declarative/spinner/content/Spinner.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 - -Image { - property alias model: view.model - property alias delegate: view.delegate - property alias currentIndex: view.currentIndex - property real itemHeight: 30 - source: "spinner-bg.png" - clip: true - PathView { - id: view - anchors.fill: parent - pathItemCount: height/itemHeight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } - dragMargin: view.width/2 - path: Path { - startX: view.width/2; startY: -itemHeight/2 - PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } - } - } - Keys.onDownPressed: view.incrementCurrentIndex() - Keys.onUpPressed: view.decrementCurrentIndex() -} diff --git a/examples/declarative/spinner/content/spinner-bg.png b/examples/declarative/spinner/content/spinner-bg.png deleted file mode 100644 index b3556f1..0000000 Binary files a/examples/declarative/spinner/content/spinner-bg.png and /dev/null differ diff --git a/examples/declarative/spinner/content/spinner-select.png b/examples/declarative/spinner/content/spinner-select.png deleted file mode 100644 index 95a17a1..0000000 Binary files a/examples/declarative/spinner/content/spinner-select.png and /dev/null differ diff --git a/examples/declarative/spinner/main.qml b/examples/declarative/spinner/main.qml deleted file mode 100644 index 6be567a..0000000 --- a/examples/declarative/spinner/main.qml +++ /dev/null @@ -1,18 +0,0 @@ -import Qt 4.7 -import "content" - -Rectangle { - width: 240; height: 320 - Column { - y: 20; x: 20; spacing: 20 - Spinner { - id: spinner - width: 200; height: 240 - focus: true - model: 20 - itemHeight: 30 - delegate: Text { font.pixelSize: 25; text: index; height: 30 } - } - Text { text: "Current item index: " + spinner.currentIndex } - } -} diff --git a/examples/declarative/spinner/spinner.qmlproject b/examples/declarative/spinner/spinner.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/spinner/spinner.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml deleted file mode 100644 index 8b021b7..0000000 --- a/examples/declarative/sql/hello.qml +++ /dev/null @@ -1,31 +0,0 @@ -import Qt 4.7 - -Text { - 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 - } - ) - } - - Component.onCompleted: findGreetings() -} - diff --git a/examples/declarative/sql/sql.qmlproject b/examples/declarative/sql/sql.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/sql/sql.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml new file mode 100644 index 0000000..8b021b7 --- /dev/null +++ b/examples/declarative/sqllocalstorage/hello.qml @@ -0,0 +1,31 @@ +import Qt 4.7 + +Text { + 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 + } + ) + } + + Component.onCompleted: findGreetings() +} + diff --git a/examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject b/examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/sqllocalstorage/sqllocalstorage.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml deleted file mode 100644 index 4429e78..0000000 --- a/examples/declarative/states/states.qml +++ /dev/null @@ -1,61 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "user.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] -} diff --git a/examples/declarative/states/states.qmlproject b/examples/declarative/states/states.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/states/states.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml deleted file mode 100644 index ccc7060..0000000 --- a/examples/declarative/states/transitions.qml +++ /dev/null @@ -1,90 +0,0 @@ -import Qt 4.7 - -/* - This is exactly the same as states.qml, except that we have appended - a set of transitions to apply animations when the item changes - between each state. -*/ - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "user.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 64; height: 64 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] - - // Transitions define how the properties change when the item moves between each state - transitions: [ - - // When transitioning to 'middleRight' move x,y over a duration of 1 second, - // with OutBounce easing function. - Transition { - from: "*"; to: "middleRight" - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } - }, - - // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, - // with InOutQuad easing function. - Transition { - from: "*"; to: "bottomLeft" - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } - }, - - // For any other state changes move x,y linearly over duration of 200ms. - Transition { - NumberAnimation { properties: "x,y"; duration: 200 } - } - ] -} diff --git a/examples/declarative/states/user.png b/examples/declarative/states/user.png deleted file mode 100644 index dd7d7a2..0000000 Binary files a/examples/declarative/states/user.png and /dev/null differ diff --git a/examples/declarative/stringlistmodel/main.cpp b/examples/declarative/stringlistmodel/main.cpp deleted file mode 100644 index abbffa7..0000000 --- a/examples/declarative/stringlistmodel/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 - -#include -#include -#include -#include -#include - - -/* - This example illustrates exposing a QStringList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QStringList dataList; - dataList.append("Item 1"); - dataList.append("Item 2"); - dataList.append("Item 3"); - dataList.append("Item 4"); - - 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/stringlistmodel/stringlistmodel.pro b/examples/declarative/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 23dc481..0000000 --- a/examples/declarative/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -TARGET = stringlistmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp -RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/stringlistmodel/stringlistmodel.qrc b/examples/declarative/stringlistmodel/stringlistmodel.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/stringlistmodel/stringlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/stringlistmodel/view.qml b/examples/declarative/stringlistmodel/view.qml deleted file mode 100644 index 41c03d9..0000000 --- a/examples/declarative/stringlistmodel/view.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } - } -} diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml deleted file mode 100644 index 26d25b4..0000000 --- a/examples/declarative/tabwidget/TabWidget.qml +++ /dev/null @@ -1,57 +0,0 @@ -import Qt 4.7 - -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 { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - model: stack.children.length - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} diff --git a/examples/declarative/tabwidget/tab.png b/examples/declarative/tabwidget/tab.png deleted file mode 100644 index ad80216..0000000 Binary files a/examples/declarative/tabwidget/tab.png and /dev/null differ diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml deleted file mode 100644 index fba203c..0000000 --- a/examples/declarative/tabwidget/tabs.qml +++ /dev/null @@ -1,59 +0,0 @@ -import Qt 4.7 - -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 { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} diff --git a/examples/declarative/tabwidget/tabwidget.qmlproject b/examples/declarative/tabwidget/tabwidget.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/tabwidget/tabwidget.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/text/fonts/availableFonts.qml b/examples/declarative/text/fonts/availableFonts.qml new file mode 100644 index 0000000..defa4ce --- /dev/null +++ b/examples/declarative/text/fonts/availableFonts.qml @@ -0,0 +1,17 @@ +import Qt 4.7 + +Rectangle { + width: 480; height: 640; color: "steelblue" + + ListView { + anchors.fill: parent; model: Qt.fontFamilies() + + delegate: Item { + height: 40; width: ListView.view.width + Text { + anchors.centerIn: parent + text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" + } + } + } +} diff --git a/examples/declarative/text/fonts/banner.qml b/examples/declarative/text/fonts/banner.qml new file mode 100644 index 0000000..353354a --- /dev/null +++ b/examples/declarative/text/fonts/banner.qml @@ -0,0 +1,21 @@ +import Qt 4.7 + +Rectangle { + id: screen + + property int pixelSize: screen.height * 1.25 + property color textColor: "lightsteelblue" + property string text: "Hello world! " + + width: 640; height: 320 + color: "steelblue" + + Row { + y: -screen.height / 4.5 + + NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } + Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + } +} diff --git a/examples/declarative/text/fonts/fonts.qml b/examples/declarative/text/fonts/fonts.qml new file mode 100644 index 0000000..f3eac48 --- /dev/null +++ b/examples/declarative/text/fonts/fonts.qml @@ -0,0 +1,64 @@ +import Qt 4.7 + +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/tarzeau_ocr_a.ttf" } + FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + + Column { + anchors { fill: parent; leftMargin: 10; rightMargin: 10 } + spacing: 15 + + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font.family: "Times"; font.pointSize: 42 + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } + } + Text { + text: { + if (webFont.status == FontLoader.Ready) myText + else if (webFont.status == FontLoader.Loading) "Loading..." + else if (webFont.status == FontLoader.Error) "Error loading font" + } + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font.family: webFont.name; font.pointSize: 42 + } + } +} diff --git a/examples/declarative/text/fonts/fonts.qmlproject b/examples/declarative/text/fonts/fonts.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/text/fonts/fonts.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf b/examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf new file mode 100644 index 0000000..cf93f96 Binary files /dev/null and b/examples/declarative/text/fonts/fonts/tarzeau_ocr_a.ttf differ diff --git a/examples/declarative/text/fonts/hello.qml b/examples/declarative/text/fonts/hello.qml new file mode 100644 index 0000000..0d6f4cd --- /dev/null +++ b/examples/declarative/text/fonts/hello.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Rectangle { + id: screen + + width: 800; height: 480 + color: "black" + + Item { + id: container + x: screen.width / 2; y: screen.height / 2 + + Text { + id: text + anchors.centerIn: parent + color: "white" + text: "Hello world!" + font.pixelSize: 60 + + SequentialAnimation on font.letterSpacing { + loops: Animation.Infinite; + NumberAnimation { from: 100; to: 300; easing.type: Easing.InQuad; duration: 3000 } + ScriptAction { + script: { + container.y = (screen.height / 4) + (Math.random() * screen.height / 2) + container.x = (screen.width / 4) + (Math.random() * screen.width / 2) + } + } + } + + SequentialAnimation on opacity { + loops: Animation.Infinite; + NumberAnimation { from: 1; to: 0; duration: 2600 } + PauseAnimation { duration: 400 } + } + } + } +} diff --git a/examples/declarative/text/text.qmlproject b/examples/declarative/text/text.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/text/text.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/threading/threadedlistmodel/dataloader.js b/examples/declarative/threading/threadedlistmodel/dataloader.js new file mode 100644 index 0000000..d720f09 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/dataloader.js @@ -0,0 +1,9 @@ +// ![0] +WorkerScript.onMessage = function(msg) { + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + } +} +// ![0] diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml new file mode 100644 index 0000000..bad7010 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/timedisplay.qml @@ -0,0 +1,32 @@ +// ![0] +import Qt 4.7 + +ListView { + width: 200 + height: 300 + + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } + + Timer { + id: timer + interval: 2000; repeat: true + running: true + triggeredOnStart: true + + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } + } +} +// ![0] diff --git a/examples/declarative/threading/threading.qmlproject b/examples/declarative/threading/threading.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/threading/threading.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/threading/workerscript/workerscript.js b/examples/declarative/threading/workerscript/workerscript.js new file mode 100644 index 0000000..f76471f --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.js @@ -0,0 +1,15 @@ +var lastx = 0; +var lasty = 0; + +WorkerScript.onMessage = function(message) { + var ydiff = message.y - lasty; + var xdiff = message.x - lastx; + + var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); + + lastx = message.x; + lasty = message.y; + + WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +} + diff --git a/examples/declarative/threading/workerscript/workerscript.qml b/examples/declarative/threading/workerscript/workerscript.qml new file mode 100644 index 0000000..2294a81 --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.qml @@ -0,0 +1,43 @@ +import Qt 4.7 + +Rectangle { + width: 480; height: 320 + + WorkerScript { + id: myWorker + source: "workerscript.js" + + onMessage: { + console.log("Moved " + messageObject.xmove + " along the X axis."); + console.log("Moved " + messageObject.ymove + " along the Y axis."); + console.log("Moved " + messageObject.move + " pixels."); + } + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left; anchors.leftMargin: 20 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right; anchors.rightMargin: 20 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} diff --git a/examples/declarative/threading/workerscript/workerscript.qmlproject b/examples/declarative/threading/workerscript/workerscript.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tic-tac-toe/content/Button.qml b/examples/declarative/tic-tac-toe/content/Button.qml deleted file mode 100644 index ecf18cd..0000000 --- a/examples/declarative/tic-tac-toe/content/Button.qml +++ /dev/null @@ -1,37 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: container - - property string text: "Button" - property bool down: false - property string mainCol: "lightgray" - property string darkCol: "darkgray" - property string lightCol: "white" - - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - border { width: 1; color: Qt.darker(mainCol) } - radius: 8; - color: mainCol - smooth: true - - gradient: Gradient { - GradientStop { - id: topGrad; position: 0.0 - color: if (container.down) { darkCol } else { lightCol } - } - GradientStop { position: 1.0; color: mainCol } - } - - signal clicked - - MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } - - Text { - id: buttonLabel - - anchors.centerIn: container - text: container.text; - font.pixelSize: 14 - } -} diff --git a/examples/declarative/tic-tac-toe/content/TicTac.qml b/examples/declarative/tic-tac-toe/content/TicTac.qml deleted file mode 100644 index d247943..0000000 --- a/examples/declarative/tic-tac-toe/content/TicTac.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index 7e5b7ba..0000000 Binary files a/examples/declarative/tic-tac-toe/content/pics/board.png and /dev/null differ diff --git a/examples/declarative/tic-tac-toe/content/pics/o.png b/examples/declarative/tic-tac-toe/content/pics/o.png deleted file mode 100644 index abc7ee0..0000000 Binary files a/examples/declarative/tic-tac-toe/content/pics/o.png and /dev/null differ diff --git a/examples/declarative/tic-tac-toe/content/pics/x.png b/examples/declarative/tic-tac-toe/content/pics/x.png deleted file mode 100644 index ddc65c8..0000000 Binary files a/examples/declarative/tic-tac-toe/content/pics/x.png and /dev/null differ diff --git a/examples/declarative/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/tic-tac-toe/content/tic-tac-toe.js deleted file mode 100644 index f8d6d9f..0000000 --- a/examples/declarative/tic-tac-toe/content/tic-tac-toe.js +++ /dev/null @@ -1,145 +0,0 @@ -function winner(board) -{ - for (var i=0; i<3; ++i) { - if (board.children[i].state!="" - && board.children[i].state==board.children[i+3].state - && board.children[i].state==board.children[i+6].state) - return true - - if (board.children[i*3].state!="" - && board.children[i*3].state==board.children[i*3+1].state - && board.children[i*3].state==board.children[i*3+2].state) - return true - } - - if (board.children[0].state!="" - && board.children[0].state==board.children[4].state!="" - && board.children[0].state==board.children[8].state!="") - return true - - if (board.children[2].state!="" - && board.children[2].state==board.children[4].state!="" - && board.children[2].state==board.children[6].state!="") - return true - - return false -} - -function restart() -{ - // No moves left - start again - for (var i=0; i<9; ++i) - board.children[i].state = "" -} - -function makeMove(pos,player) -{ - board.children[pos].state = player - if (winner(board)) { - win(player + " wins") - return true - } else { - return false - } -} - -function computerTurn() -{ - var r = Math.random(); - if(r < game.difficulty){ - smartAI(); - }else{ - randAI(); - } -} - -function smartAI() -{ - function boardCopy(a){ - var ret = new Object; - ret.children = new Array(9); - for(var i = 0; i<9; i++){ - ret.children[i] = new Object; - ret.children[i].state = a.children[i].state; - } - return ret; - } - for(var i=0; i<9; i++){ - var simpleBoard = boardCopy(board); - if (board.children[i].state == "") { - simpleBoard.children[i].state = "O"; - if(winner(simpleBoard)){ - makeMove(i,"O") - return - } - } - } - for(var i=0; i<9; i++){ - var simpleBoard = boardCopy(board); - if (board.children[i].state == "") { - simpleBoard.children[i].state = "X"; - if(winner(simpleBoard)){ - makeMove(i,"O") - return - } - } - } - function thwart(a,b,c){//If they are at a, try b or c - if (board.children[a].state == "X") { - if (board.children[b].state == "") { - makeMove(b,"O") - return true - }else if (board.children[c].state == "") { - makeMove(c,"O") - return true - } - } - return false; - } - if(thwart(4,0,2)) return; - if(thwart(0,4,3)) return; - if(thwart(2,4,1)) return; - if(thwart(6,4,7)) return; - if(thwart(8,4,5)) return; - if(thwart(1,4,2)) return; - if(thwart(3,4,0)) return; - if(thwart(5,4,8)) return; - if(thwart(7,4,6)) return; - for(var i =0; i<9; i++){//Backup - if (board.children[i].state == "") { - makeMove(i,"O") - return - } - } - restart(); -} - -function randAI() -{ - var open = 0; - for (var i=0; i<9; ++i) - if (board.children[i].state == "") { - open += 1; - } - if(open == 0){ - restart(); - return; - } - var openA = new Array(open);//JS doesn't have lists I can append to (i think) - var acc = 0; - for (var i=0; i<9; ++i) - if (board.children[i].state == "") { - openA[acc] = i; - acc += 1; - } - var choice = openA[Math.floor(Math.random() * open)]; - makeMove(choice, "O"); -} - -function win(s) -{ - msg.text = s - msg.opacity = 1 - endtimer.running = true -} - diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml deleted file mode 100644 index dd13052..0000000 --- a/examples/declarative/tic-tac-toe/tic-tac-toe.qml +++ /dev/null @@ -1,77 +0,0 @@ -import Qt 4.7 -import "content" -import "content/tic-tac-toe.js" as Logic - -Item { - id: game - - property bool show: false - property real difficulty: 1.0 //chance it will actually think - - width: 440 - height: 480 - anchors.fill: parent - - Image { - id: boardimage - anchors { verticalCenter: parent.verticalCenter; 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; 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 - - anchors.centerIn: parent - opacity: 0 - color: "blue" - style: Text.Outline; styleColor: "white" - font.pixelSize: 50; font.bold: true - } -} diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/touchinteraction/gestures/experimental-gestures.qml b/examples/declarative/touchinteraction/gestures/experimental-gestures.qml new file mode 100644 index 0000000..cb190ea --- /dev/null +++ b/examples/declarative/touchinteraction/gestures/experimental-gestures.qml @@ -0,0 +1,36 @@ +import Qt 4.7 +import Qt.labs.gestures 1.0 + +// Only works on platforms with Touch support. + +Rectangle { + id: rect + width: 320 + height: 180 + + Text { + anchors.centerIn: parent + text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." + horizontalAlignment: Text.Center + } + + GestureArea { + anchors.fill: parent + focus: true + + // Only some of the many gesture properties are shown. See Gesture documentation. + + onTap: + console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")") + onTapAndHold: + console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") + onPan: + console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) + onPinch: + console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) + onSwipe: + console.log("swipe angle=",gesture.swipeAngle) + onGesture: + console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") + } +} diff --git a/examples/declarative/touchinteraction/gestures/gestures.qmlproject b/examples/declarative/touchinteraction/gestures/gestures.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/touchinteraction/gestures/gestures.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/touchinteraction/mousearea/mouse.qml b/examples/declarative/touchinteraction/mousearea/mouse.qml new file mode 100644 index 0000000..06134b7 --- /dev/null +++ b/examples/declarative/touchinteraction/mousearea/mouse.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Rectangle { + width: 200; height: 200 + + Rectangle { + width: 50; height: 50 + color: "red" + + Text { text: "Click"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + 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) + } + } + + Rectangle { + y: 100; width: 50; height: 50 + color: "blue" + + Text { text: "Drag"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.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') + } + } +} diff --git a/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject b/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/touchinteraction/mousearea/mousearea.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/touchinteraction/touchinteraction.qmlproject b/examples/declarative/touchinteraction/touchinteraction.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/touchinteraction/touchinteraction.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/clocks/clocks.qml b/examples/declarative/toys/clocks/clocks.qml new file mode 100644 index 0000000..22cf820 --- /dev/null +++ b/examples/declarative/toys/clocks/clocks.qml @@ -0,0 +1,14 @@ +import Qt 4.7 +import "content" + +Rectangle { + width: 640; height: 240 + color: "#646464" + + Row { + anchors.centerIn: parent + Clock { city: "New York"; shift: -4 } + Clock { city: "Mumbai"; shift: 5.5 } + Clock { city: "Tokyo"; shift: 9 } + } +} diff --git a/examples/declarative/toys/clocks/clocks.qmlproject b/examples/declarative/toys/clocks/clocks.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/clocks/clocks.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml new file mode 100644 index 0000000..3426e6a --- /dev/null +++ b/examples/declarative/toys/clocks/content/Clock.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +Item { + id: clock + width: 200; height: 230 + + property alias city: cityLabel.text + property variant hours + property variant minutes + property variant seconds + property variant shift : 0 + property bool night: false + + function timeChanged() { + var date = new Date; + hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + 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 + to: (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 + to: 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 + to: clock.seconds * 6 + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel + y: 200; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + font.bold: true; font.pixelSize: 14 + style: Text.Raised; styleColor: "black" + } +} diff --git a/examples/declarative/toys/clocks/content/background.png b/examples/declarative/toys/clocks/content/background.png new file mode 100644 index 0000000..a885950 Binary files /dev/null and b/examples/declarative/toys/clocks/content/background.png differ diff --git a/examples/declarative/toys/clocks/content/center.png b/examples/declarative/toys/clocks/content/center.png new file mode 100755 index 0000000..7fbd802 Binary files /dev/null and b/examples/declarative/toys/clocks/content/center.png differ diff --git a/examples/declarative/toys/clocks/content/clock-night.png b/examples/declarative/toys/clocks/content/clock-night.png new file mode 100755 index 0000000..cc7151a Binary files /dev/null and b/examples/declarative/toys/clocks/content/clock-night.png differ diff --git a/examples/declarative/toys/clocks/content/clock.png b/examples/declarative/toys/clocks/content/clock.png new file mode 100755 index 0000000..462edac Binary files /dev/null and b/examples/declarative/toys/clocks/content/clock.png differ diff --git a/examples/declarative/toys/clocks/content/hour.png b/examples/declarative/toys/clocks/content/hour.png new file mode 100755 index 0000000..f8061a1 Binary files /dev/null and b/examples/declarative/toys/clocks/content/hour.png differ diff --git a/examples/declarative/toys/clocks/content/minute.png b/examples/declarative/toys/clocks/content/minute.png new file mode 100755 index 0000000..1297ec7 Binary files /dev/null and b/examples/declarative/toys/clocks/content/minute.png differ diff --git a/examples/declarative/toys/clocks/content/second.png b/examples/declarative/toys/clocks/content/second.png new file mode 100755 index 0000000..4aa9fb5 Binary files /dev/null and b/examples/declarative/toys/clocks/content/second.png differ diff --git a/examples/declarative/toys/dial/content/Dial.qml b/examples/declarative/toys/dial/content/Dial.qml new file mode 100644 index 0000000..f9ab3e3 --- /dev/null +++ b/examples/declarative/toys/dial/content/Dial.qml @@ -0,0 +1,37 @@ +import Qt 4.7 + +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 + to: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + } + } + } + Image { x: 21; y: 18; source: "overlay.png" } +} diff --git a/examples/declarative/toys/dial/content/background.png b/examples/declarative/toys/dial/content/background.png new file mode 100644 index 0000000..75d555d Binary files /dev/null and b/examples/declarative/toys/dial/content/background.png differ diff --git a/examples/declarative/toys/dial/content/needle.png b/examples/declarative/toys/dial/content/needle.png new file mode 100644 index 0000000..2d19f75 Binary files /dev/null and b/examples/declarative/toys/dial/content/needle.png differ diff --git a/examples/declarative/toys/dial/content/needle_shadow.png b/examples/declarative/toys/dial/content/needle_shadow.png new file mode 100644 index 0000000..8d8a928 Binary files /dev/null and b/examples/declarative/toys/dial/content/needle_shadow.png differ diff --git a/examples/declarative/toys/dial/content/overlay.png b/examples/declarative/toys/dial/content/overlay.png new file mode 100644 index 0000000..3860a7b Binary files /dev/null and b/examples/declarative/toys/dial/content/overlay.png differ diff --git a/examples/declarative/toys/dial/dial-example.qml b/examples/declarative/toys/dial/dial-example.qml new file mode 100644 index 0000000..2e102b0 --- /dev/null +++ b/examples/declarative/toys/dial/dial-example.qml @@ -0,0 +1,44 @@ +import Qt 4.7 +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; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + drag.target: parent; drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } +} diff --git a/examples/declarative/toys/dial/dial.qmlproject b/examples/declarative/toys/dial/dial.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/dial/dial.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dynamic/dynamic.qml b/examples/declarative/toys/dynamic/dynamic.qml new file mode 100644 index 0000000..52c7c1e --- /dev/null +++ b/examples/declarative/toys/dynamic/dynamic.qml @@ -0,0 +1,176 @@ +import Qt 4.7 +import Qt.labs.particles 1.0 +import "qml" + +Item { + id: window + + property int activeSuns: 0 + + //This is a desktop-sized example + width: 1024; height: 512 + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + 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 + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + width: 480 + color: activePalette.window + anchors { right: parent.right; top: parent.top; bottom: parent.bottom } + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: childrenRect.width + 10; height: childrenRect.height + 10 + border.color: "black" + + Row { + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + image: "../images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + image: "../images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + image: "../images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + + Rectangle { width: parent.width; height: 1; color: "black" } + + Text { text: "Arbitrary QML:" } + + Rectangle { + width: 460; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + focusOnPress: true + font.pixelSize: 14 + + text: "import Qt 4.7\nImage {\n id: smile\n x: 500 * Math.random()\n y: 200 * Math.random() \n source: 'images/face-smile.png'\n\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + + Button { + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, window, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + +} diff --git a/examples/declarative/toys/dynamic/dynamic.qmlproject b/examples/declarative/toys/dynamic/dynamic.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/dynamic/dynamic.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dynamic/images/NOTE b/examples/declarative/toys/dynamic/images/NOTE new file mode 100644 index 0000000..fcd87f9 --- /dev/null +++ b/examples/declarative/toys/dynamic/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/declarative/toys/dynamic/images/face-smile.png b/examples/declarative/toys/dynamic/images/face-smile.png new file mode 100644 index 0000000..3d66d72 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/face-smile.png differ diff --git a/examples/declarative/toys/dynamic/images/moon.png b/examples/declarative/toys/dynamic/images/moon.png new file mode 100644 index 0000000..1c0d606 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/moon.png differ diff --git a/examples/declarative/toys/dynamic/images/rabbit_brown.png b/examples/declarative/toys/dynamic/images/rabbit_brown.png new file mode 100644 index 0000000..ebfdeed Binary files /dev/null and b/examples/declarative/toys/dynamic/images/rabbit_brown.png differ diff --git a/examples/declarative/toys/dynamic/images/rabbit_bw.png b/examples/declarative/toys/dynamic/images/rabbit_bw.png new file mode 100644 index 0000000..7bff9b9 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/rabbit_bw.png differ diff --git a/examples/declarative/toys/dynamic/images/star.png b/examples/declarative/toys/dynamic/images/star.png new file mode 100644 index 0000000..27ef924 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/star.png differ diff --git a/examples/declarative/toys/dynamic/images/sun.png b/examples/declarative/toys/dynamic/images/sun.png new file mode 100644 index 0000000..7713ca5 Binary files /dev/null and b/examples/declarative/toys/dynamic/images/sun.png differ diff --git a/examples/declarative/toys/dynamic/images/tree_s.png b/examples/declarative/toys/dynamic/images/tree_s.png new file mode 100644 index 0000000..6eac35a Binary files /dev/null and b/examples/declarative/toys/dynamic/images/tree_s.png differ diff --git a/examples/declarative/toys/dynamic/qml/Button.qml b/examples/declarative/toys/dynamic/qml/Button.qml new file mode 100644 index 0000000..963a850 --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/Button.qml @@ -0,0 +1,40 @@ +import Qt 4.7 + +Rectangle { + id: container + + property variant text + signal clicked + + height: text.height + 10; width: text.width + 20 + border.width: 1 + radius: 4 + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } +} diff --git a/examples/declarative/toys/dynamic/qml/PaletteItem.qml b/examples/declarative/toys/dynamic/qml/PaletteItem.qml new file mode 100644 index 0000000..dcb5cc3 --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/PaletteItem.qml @@ -0,0 +1,19 @@ +import Qt 4.7 +import "itemCreation.js" as Code + +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + + MouseArea { + anchors.fill: parent + + onPressed: Code.startDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); + onReleased: Code.endDrag(mouse); + } +} diff --git a/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml b/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml new file mode 100644 index 0000000..c04d3dc --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Image { + id: rootItem + + property bool created: false + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > window.height / 2 + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/declarative/toys/dynamic/qml/Sun.qml b/examples/declarative/toys/dynamic/qml/Sun.qml new file mode 100644 index 0000000..43dcb9a --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/Sun.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Image { + id: sun + + property bool created: false + property string image: "../images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: window.height / 2 + 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() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/declarative/toys/dynamic/qml/itemCreation.js b/examples/declarative/toys/dynamic/qml/itemCreation.js new file mode 100644 index 0000000..59750f3 --- /dev/null +++ b/examples/declarative/toys/dynamic/qml/itemCreation.js @@ -0,0 +1,65 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(null, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window); + draggedItem.image = paletteItem.image; + draggedItem.x = posnInWindow.x; + draggedItem.y = posnInWindow.y; + draggedItem.z = 3; // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(component.errorsString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/declarative/toys/tic-tac-toe/content/Button.qml b/examples/declarative/toys/tic-tac-toe/content/Button.qml new file mode 100644 index 0000000..ecf18cd --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/content/Button.qml @@ -0,0 +1,37 @@ +import Qt 4.7 + +Rectangle { + id: container + + property string text: "Button" + property bool down: false + property string mainCol: "lightgray" + property string darkCol: "darkgray" + property string lightCol: "white" + + width: buttonLabel.width + 20; height: buttonLabel.height + 6 + border { width: 1; color: Qt.darker(mainCol) } + radius: 8; + color: mainCol + smooth: true + + gradient: Gradient { + GradientStop { + id: topGrad; position: 0.0 + color: if (container.down) { darkCol } else { lightCol } + } + GradientStop { position: 1.0; color: mainCol } + } + + signal clicked + + MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: buttonLabel + + anchors.centerIn: container + text: container.text; + font.pixelSize: 14 + } +} diff --git a/examples/declarative/toys/tic-tac-toe/content/TicTac.qml b/examples/declarative/toys/tic-tac-toe/content/TicTac.qml new file mode 100644 index 0000000..d247943 --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/content/TicTac.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +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/toys/tic-tac-toe/content/pics/board.png b/examples/declarative/toys/tic-tac-toe/content/pics/board.png new file mode 100644 index 0000000..7e5b7ba Binary files /dev/null and b/examples/declarative/toys/tic-tac-toe/content/pics/board.png differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/o.png b/examples/declarative/toys/tic-tac-toe/content/pics/o.png new file mode 100644 index 0000000..abc7ee0 Binary files /dev/null and b/examples/declarative/toys/tic-tac-toe/content/pics/o.png differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/x.png b/examples/declarative/toys/tic-tac-toe/content/pics/x.png new file mode 100644 index 0000000..ddc65c8 Binary files /dev/null and b/examples/declarative/toys/tic-tac-toe/content/pics/x.png differ diff --git a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js new file mode 100644 index 0000000..f8d6d9f --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js @@ -0,0 +1,145 @@ +function winner(board) +{ + for (var i=0; i<3; ++i) { + if (board.children[i].state!="" + && board.children[i].state==board.children[i+3].state + && board.children[i].state==board.children[i+6].state) + return true + + if (board.children[i*3].state!="" + && board.children[i*3].state==board.children[i*3+1].state + && board.children[i*3].state==board.children[i*3+2].state) + return true + } + + if (board.children[0].state!="" + && board.children[0].state==board.children[4].state!="" + && board.children[0].state==board.children[8].state!="") + return true + + if (board.children[2].state!="" + && board.children[2].state==board.children[4].state!="" + && board.children[2].state==board.children[6].state!="") + return true + + return false +} + +function restart() +{ + // No moves left - start again + for (var i=0; i<9; ++i) + board.children[i].state = "" +} + +function makeMove(pos,player) +{ + board.children[pos].state = player + if (winner(board)) { + win(player + " wins") + return true + } else { + return false + } +} + +function computerTurn() +{ + var r = Math.random(); + if(r < game.difficulty){ + smartAI(); + }else{ + randAI(); + } +} + +function smartAI() +{ + function boardCopy(a){ + var ret = new Object; + ret.children = new Array(9); + for(var i = 0; i<9; i++){ + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "O"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "X"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + function thwart(a,b,c){//If they are at a, try b or c + if (board.children[a].state == "X") { + if (board.children[b].state == "") { + makeMove(b,"O") + return true + }else if (board.children[c].state == "") { + makeMove(c,"O") + return true + } + } + return false; + } + if(thwart(4,0,2)) return; + if(thwart(0,4,3)) return; + if(thwart(2,4,1)) return; + if(thwart(6,4,7)) return; + if(thwart(8,4,5)) return; + if(thwart(1,4,2)) return; + if(thwart(3,4,0)) return; + if(thwart(5,4,8)) return; + if(thwart(7,4,6)) return; + for(var i =0; i<9; i++){//Backup + if (board.children[i].state == "") { + makeMove(i,"O") + return + } + } + restart(); +} + +function randAI() +{ + var open = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + open += 1; + } + if(open == 0){ + restart(); + return; + } + var openA = new Array(open);//JS doesn't have lists I can append to (i think) + var acc = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + openA[acc] = i; + acc += 1; + } + var choice = openA[Math.floor(Math.random() * open)]; + makeMove(choice, "O"); +} + +function win(s) +{ + msg.text = s + msg.opacity = 1 + endtimer.running = true +} + diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml new file mode 100644 index 0000000..dd13052 --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml @@ -0,0 +1,77 @@ +import Qt 4.7 +import "content" +import "content/tic-tac-toe.js" as Logic + +Item { + id: game + + property bool show: false + property real difficulty: 1.0 //chance it will actually think + + width: 440 + height: 480 + anchors.fill: parent + + Image { + id: boardimage + anchors { verticalCenter: parent.verticalCenter; 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; 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 + + anchors.centerIn: parent + opacity: 0 + color: "blue" + style: Text.Outline; styleColor: "white" + font.pixelSize: 50; font.bold: true + } +} diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/toys.qmlproject b/examples/declarative/toys/toys.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/toys.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml new file mode 100644 index 0000000..c90d9c5 --- /dev/null +++ b/examples/declarative/toys/tvtennis/tvtennis.qml @@ -0,0 +1,71 @@ +import Qt 4.7 + +Rectangle { + id: page + width: 640; height: 480 + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property int targetY : page.height - 10 + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y follow the target y coordinate, with a velocity of 200 + SpringFollow on y { to: ball.targetY; velocity: 200 } + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + targetY = page.height - 20; + } else if (y >= page.height - 20) { + targetY = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + SpringFollow on y { + to: 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 { + to: 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/toys/tvtennis/tvtennis.qmlproject b/examples/declarative/toys/tvtennis/tvtennis.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/tvtennis/tvtennis.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/velocity/Day.qml b/examples/declarative/toys/velocity/Day.qml new file mode 100644 index 0000000..350c1c4 --- /dev/null +++ b/examples/declarative/toys/velocity/Day.qml @@ -0,0 +1,101 @@ +import Qt 4.7 + +Component { + Item { + property variant stickies + + id: page + width: 840; height: 480 + + Image { source: "cork.jpg" } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * 500 + 100 + property int randomY: Math.random() * 200 + 50 + + x: randomX; y: randomY + + SpringFollow on rotation { + to: -flickable.horizontalVelocity / 100 + spring: 2.0; damping: 0.15 + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/declarative/toys/velocity/cork.jpg b/examples/declarative/toys/velocity/cork.jpg new file mode 100644 index 0000000..160bc00 Binary files /dev/null and b/examples/declarative/toys/velocity/cork.jpg differ diff --git a/examples/declarative/toys/velocity/note-yellow.png b/examples/declarative/toys/velocity/note-yellow.png new file mode 100644 index 0000000..8ddecc8 Binary files /dev/null and b/examples/declarative/toys/velocity/note-yellow.png differ diff --git a/examples/declarative/toys/velocity/tack.png b/examples/declarative/toys/velocity/tack.png new file mode 100644 index 0000000..cef2d1c Binary files /dev/null and b/examples/declarative/toys/velocity/tack.png differ diff --git a/examples/declarative/toys/velocity/velocity.qml b/examples/declarative/toys/velocity/velocity.qml new file mode 100644 index 0000000..871bafc --- /dev/null +++ b/examples/declarative/toys/velocity/velocity.qml @@ -0,0 +1,75 @@ +import Qt 4.7 + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} diff --git a/examples/declarative/toys/velocity/velocity.qmlproject b/examples/declarative/toys/velocity/velocity.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/velocity/velocity.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tutorials/extending/extending.pro b/examples/declarative/tutorials/extending/extending.pro new file mode 100644 index 0000000..0c86fed --- /dev/null +++ b/examples/declarative/tutorials/extending/extending.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + chapter1-basics \ + chapter2-methods \ + chapter3-bindings \ + chapter4-customPropertyTypes \ + chapter5-plugins + diff --git a/examples/declarative/tutorials/tutorials.pro b/examples/declarative/tutorials/tutorials.pro new file mode 100644 index 0000000..0a82c1e --- /dev/null +++ b/examples/declarative/tutorials/tutorials.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + extending + diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml deleted file mode 100644 index c90d9c5..0000000 --- a/examples/declarative/tvtennis/tvtennis.qml +++ /dev/null @@ -1,71 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property int targetY : page.height - 10 - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y follow the target y coordinate, with a velocity of 200 - SpringFollow on y { to: ball.targetY; velocity: 200 } - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - targetY = page.height - 20; - } else if (y >= page.height - 20) { - targetY = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - SpringFollow on y { - to: 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 { - to: 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/tvtennis/tvtennis.qmlproject b/examples/declarative/tvtennis/tvtennis.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/tvtennis/tvtennis.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/ui-components/flipable/content/5_heart.png b/examples/declarative/ui-components/flipable/content/5_heart.png new file mode 100644 index 0000000..fb59d81 Binary files /dev/null and b/examples/declarative/ui-components/flipable/content/5_heart.png differ diff --git a/examples/declarative/ui-components/flipable/content/9_club.png b/examples/declarative/ui-components/flipable/content/9_club.png new file mode 100644 index 0000000..2545001 Binary files /dev/null and b/examples/declarative/ui-components/flipable/content/9_club.png differ diff --git a/examples/declarative/ui-components/flipable/content/Card.qml b/examples/declarative/ui-components/flipable/content/Card.qml new file mode 100644 index 0000000..2577d89 --- /dev/null +++ b/examples/declarative/ui-components/flipable/content/Card.qml @@ -0,0 +1,38 @@ +import Qt 4.7 + +Flipable { + id: container + + property alias image: frontImage.source + property bool flipped: true + property int xAxis: 0 + property int yAxis: 0 + property int angle: 0 + + width: front.width; height: front.height; state: "back" + + front: Image { id: frontImage; smooth: true } + back: Image { source: "back.png"; smooth: true } + + MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } + + transform: Rotation { + id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 + axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 + } + + states: State { + name: "back"; when: container.flipped + PropertyChanges { target: rotation; angle: container.angle } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: rotation; properties: "angle"; duration: 600 } + SequentialAnimation { + NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } + NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } + } + } + } +} diff --git a/examples/declarative/ui-components/flipable/content/back.png b/examples/declarative/ui-components/flipable/content/back.png new file mode 100644 index 0000000..f715d74 Binary files /dev/null and b/examples/declarative/ui-components/flipable/content/back.png differ diff --git a/examples/declarative/ui-components/flipable/flipable-example.qml b/examples/declarative/ui-components/flipable/flipable-example.qml new file mode 100644 index 0000000..4e09569 --- /dev/null +++ b/examples/declarative/ui-components/flipable/flipable-example.qml @@ -0,0 +1,15 @@ +import Qt 4.7 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/declarative/ui-components/flipable/flipable.qmlproject b/examples/declarative/ui-components/flipable/flipable.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/flipable/flipable.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000..bc36df5 --- /dev/null +++ b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml @@ -0,0 +1,43 @@ +import Qt 4.7 + +Item { + id: progressbar + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: gradient1.color + property alias secondColor: gradient2.color + + width: 250; height: 23 + clip: true + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + Rectangle { + id: highlight + + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + + width: highlight.widthDest + Behavior on width { SmoothedAnimation { velocity: 1200 } } + + anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 } + radius: 1 + gradient: Gradient { + GradientStop { id: gradient1; position: 0.0 } + GradientStop { id: gradient2; position: 1.0 } + } + + } + Text { + anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } + color: "white" + font.bold: true + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/declarative/ui-components/progressbar/content/background.png b/examples/declarative/ui-components/progressbar/content/background.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/ui-components/progressbar/content/background.png differ diff --git a/examples/declarative/ui-components/progressbar/progressbar.qmlproject b/examples/declarative/ui-components/progressbar/progressbar.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/progressbar/progressbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/progressbar/progressbars.qml b/examples/declarative/ui-components/progressbar/progressbars.qml new file mode 100644 index 0000000..55fd682 --- /dev/null +++ b/examples/declarative/ui-components/progressbar/progressbars.qml @@ -0,0 +1,33 @@ +import Qt 4.7 +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/ui-components/scrollbar/ScrollBar.qml b/examples/declarative/ui-components/scrollbar/ScrollBar.qml new file mode 100644 index 0000000..c628a20 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/ScrollBar.qml @@ -0,0 +1,33 @@ +import Qt 4.7 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either Qt.Vertical or Qt.Horizontal + property real position + property real pageSize + property variant orientation : Qt.Vertical + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "white" + opacity: 0.3 + } + // Size the bar to the required size, depending upon the orientation. + Rectangle { + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "black" + opacity: 0.7 + } +} diff --git a/examples/declarative/ui-components/scrollbar/display.qml b/examples/declarative/ui-components/scrollbar/display.qml new file mode 100644 index 0000000..6b12d85 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/display.qml @@ -0,0 +1,54 @@ +import Qt 4.7 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + from: "*"; to: "*" + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000..618d808 Binary files /dev/null and b/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject b/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml new file mode 100644 index 0000000..aae7ee9 --- /dev/null +++ b/examples/declarative/ui-components/searchbox/SearchBox.qml @@ -0,0 +1,65 @@ +import Qt 4.7 + +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; leftMargin: 8; verticalCenter: parent.verticalCenter } + focus: true + } + + Image { + id: clear + anchors { right: parent.right; rightMargin: 8; 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/ui-components/searchbox/images/edit-clear-locationbar-rtl.png b/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png new file mode 100644 index 0000000..91eb270 Binary files /dev/null and b/examples/declarative/ui-components/searchbox/images/edit-clear-locationbar-rtl.png differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000..bbfac38 Binary files /dev/null and b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png differ diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml new file mode 100644 index 0000000..9f73473 --- /dev/null +++ b/examples/declarative/ui-components/searchbox/main.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +Rectangle { + width: 500; height: 250 + color: "#edecec" + + Column { + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + spacing: 10 + + SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } + SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } + SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } + } +} diff --git a/examples/declarative/ui-components/searchbox/searchbox.qmlproject b/examples/declarative/ui-components/searchbox/searchbox.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/slideswitch/content/Switch.qml b/examples/declarative/ui-components/slideswitch/content/Switch.qml new file mode 100644 index 0000000..526a171 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/content/Switch.qml @@ -0,0 +1,76 @@ +//![0] +import Qt 4.7 + +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 + x: 1; y: 2 + source: "knob.svg" + + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.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: Easing.InOutQuad; duration: 200 } + } +//![7] +} +//![0] diff --git a/examples/declarative/ui-components/slideswitch/content/background.svg b/examples/declarative/ui-components/slideswitch/content/background.svg new file mode 100644 index 0000000..f920d3e --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/declarative/ui-components/slideswitch/content/knob.svg b/examples/declarative/ui-components/slideswitch/content/knob.svg new file mode 100644 index 0000000..fb69337 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/ui-components/slideswitch/slideswitch.qml b/examples/declarative/ui-components/slideswitch/slideswitch.qml new file mode 100644 index 0000000..51c3c77 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/slideswitch.qml @@ -0,0 +1,11 @@ +import Qt 4.7 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] +} diff --git a/examples/declarative/ui-components/slideswitch/slideswitch.qmlproject b/examples/declarative/ui-components/slideswitch/slideswitch.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/slideswitch/slideswitch.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/spinner/content/Spinner.qml b/examples/declarative/ui-components/spinner/content/Spinner.qml new file mode 100644 index 0000000..8145a28 --- /dev/null +++ b/examples/declarative/ui-components/spinner/content/Spinner.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + source: "spinner-bg.png" + clip: true + PathView { + id: view + anchors.fill: parent + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/declarative/ui-components/spinner/content/spinner-bg.png b/examples/declarative/ui-components/spinner/content/spinner-bg.png new file mode 100644 index 0000000..b3556f1 Binary files /dev/null and b/examples/declarative/ui-components/spinner/content/spinner-bg.png differ diff --git a/examples/declarative/ui-components/spinner/content/spinner-select.png b/examples/declarative/ui-components/spinner/content/spinner-select.png new file mode 100644 index 0000000..95a17a1 Binary files /dev/null and b/examples/declarative/ui-components/spinner/content/spinner-select.png differ diff --git a/examples/declarative/ui-components/spinner/main.qml b/examples/declarative/ui-components/spinner/main.qml new file mode 100644 index 0000000..6be567a --- /dev/null +++ b/examples/declarative/ui-components/spinner/main.qml @@ -0,0 +1,18 @@ +import Qt 4.7 +import "content" + +Rectangle { + width: 240; height: 320 + Column { + y: 20; x: 20; spacing: 20 + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/declarative/ui-components/spinner/spinner.qmlproject b/examples/declarative/ui-components/spinner/spinner.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/tabwidget/TabWidget.qml b/examples/declarative/ui-components/tabwidget/TabWidget.qml new file mode 100644 index 0000000..26d25b4 --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/TabWidget.qml @@ -0,0 +1,57 @@ +import Qt 4.7 + +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 { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + model: stack.children.length + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/declarative/ui-components/tabwidget/tab.png b/examples/declarative/ui-components/tabwidget/tab.png new file mode 100644 index 0000000..ad80216 Binary files /dev/null and b/examples/declarative/ui-components/tabwidget/tab.png differ diff --git a/examples/declarative/ui-components/tabwidget/tabs.qml b/examples/declarative/ui-components/tabwidget/tabs.qml new file mode 100644 index 0000000..fba203c --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/tabs.qml @@ -0,0 +1,59 @@ +import Qt 4.7 + +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 { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 } + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject b/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/ui-components/ui-components.qmlproject b/examples/declarative/ui-components/ui-components.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/ui-components/ui-components.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml deleted file mode 100644 index 350c1c4..0000000 --- a/examples/declarative/velocity/Day.qml +++ /dev/null @@ -1,101 +0,0 @@ -import Qt 4.7 - -Component { - Item { - property variant stickies - - id: page - width: 840; height: 480 - - Image { source: "cork.jpg" } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * 500 + 100 - property int randomY: Math.random() * 200 + 50 - - x: randomX; y: randomY - - SpringFollow on rotation { - to: -flickable.horizontalVelocity / 100 - spring: 2.0; damping: 0.15 - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/declarative/velocity/cork.jpg b/examples/declarative/velocity/cork.jpg deleted file mode 100644 index 160bc00..0000000 Binary files a/examples/declarative/velocity/cork.jpg and /dev/null differ diff --git a/examples/declarative/velocity/note-yellow.png b/examples/declarative/velocity/note-yellow.png deleted file mode 100644 index 8ddecc8..0000000 Binary files a/examples/declarative/velocity/note-yellow.png and /dev/null differ diff --git a/examples/declarative/velocity/tack.png b/examples/declarative/velocity/tack.png deleted file mode 100644 index cef2d1c..0000000 Binary files a/examples/declarative/velocity/tack.png and /dev/null differ diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml deleted file mode 100644 index 871bafc..0000000 --- a/examples/declarative/velocity/velocity.qml +++ /dev/null @@ -1,75 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/declarative/velocity/velocity.qmlproject b/examples/declarative/velocity/velocity.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/velocity/velocity.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/webview/alerts.html b/examples/declarative/webview/alerts.html deleted file mode 100644 index 82caddf..0000000 --- a/examples/declarative/webview/alerts.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

This is a web page. It fires an alert when clicked. - - diff --git a/examples/declarative/webview/alerts.qml b/examples/declarative/webview/alerts.qml deleted file mode 100644 index 7684c3e..0000000 --- a/examples/declarative/webview/alerts.qml +++ /dev/null @@ -1,58 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -WebView { - id: webView - width: 120 - height: 150 - url: "alerts.html" - - onAlert: popup.show(message) - - Rectangle { - id: popup - - color: "red" - border.color: "black"; border.width: 2 - radius: 4 - - y: parent.height // off "screen" - anchors.horizontalCenter: parent.horizontalCenter - width: label.width+5 - height: label.height+5 - - opacity: 0 - - function show(t) { - label.text = t - popup.state = "visible" - timer.start() - } - states: State { - name: "visible" - PropertyChanges { target: popup; opacity: 1 } - PropertyChanges { target: popup; y: (webView.height-popup.height)/2 } - } - - transitions: [ - Transition { from: ""; PropertyAnimation { properties: "opacity,y"; duration: 65 } }, - Transition { from: "visible"; PropertyAnimation { properties: "opacity,y"; duration: 500 } } - ] - - Timer { - id: timer - interval: 1000 - onTriggered: popup.state = "" - } - - Text { - id: label - anchors.centerIn: parent - color: "white" - font.pixelSize: 20 - width: webView.width*0.75 - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - } - } -} diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml deleted file mode 100644 index 9632883..0000000 --- a/examples/declarative/webview/autosize.qml +++ /dev/null @@ -1,62 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -// The WebView size is determined by the width, height, -// preferredWidth, and preferredHeight properties. -Rectangle { - id: rect - 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 deleted file mode 100644 index d1d003f..0000000 --- a/examples/declarative/webview/content/FieldText.qml +++ /dev/null @@ -1,157 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index 5d3ba81..0000000 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 -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 deleted file mode 100755 index a8726fd..0000000 --- a/examples/declarative/webview/content/Mapping/map.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - -

- - diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml deleted file mode 100644 index dba48d4..0000000 --- a/examples/declarative/webview/content/SpinSquare.qml +++ /dev/null @@ -1,25 +0,0 @@ -import Qt 4.7 - -Item { - property variant period : 250 - property variant 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 deleted file mode 100644 index ecc9533..0000000 Binary files a/examples/declarative/webview/content/pics/cancel.png and /dev/null differ diff --git a/examples/declarative/webview/content/pics/ok.png b/examples/declarative/webview/content/pics/ok.png deleted file mode 100644 index 5795f04..0000000 Binary files a/examples/declarative/webview/content/pics/ok.png and /dev/null differ diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml deleted file mode 100644 index 5506012..0000000 --- a/examples/declarative/webview/googleMaps.qml +++ /dev/null @@ -1,43 +0,0 @@ -// 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.7 -import org.webkit 1.0 -import "content/Mapping" - -Map { - id: map - width: 300 - height: 300 - address: "Paris" - - Rectangle { - x: 70 - width: input.width + 20 - height: input.height + 4 - anchors.bottom: parent.bottom; anchors.bottomMargin: 5 - radius: 5 - opacity: map.status == "Ready" ? 1 : 0 - - 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 deleted file mode 100644 index eec7fc6..0000000 --- a/examples/declarative/webview/inline-html.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 -import org.webkit 1.0 - -// Inline HTML with loose formatting can be -// set on the html property. -WebView { - html:"\ - \ - \ -
OneTwoThree\ -
1X1X\ -
20X0\ -
3X1X\ -
" -} diff --git a/examples/declarative/webview/newwindows.html b/examples/declarative/webview/newwindows.html deleted file mode 100644 index f169599..0000000 --- a/examples/declarative/webview/newwindows.html +++ /dev/null @@ -1,3 +0,0 @@ -

Multiple windows...

- -Popup! diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml deleted file mode 100644 index 2e4a72e..0000000 --- a/examples/declarative/webview/newwindows.qml +++ /dev/null @@ -1,31 +0,0 @@ -// 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.7 -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 deleted file mode 100644 index e4efc31..0000000 --- a/examples/declarative/webview/transparent.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.7 -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 World!" - } -} diff --git a/examples/declarative/webview/webview.qmlproject b/examples/declarative/webview/webview.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/webview/webview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/workerscript/workerscript.js b/examples/declarative/workerscript/workerscript.js deleted file mode 100644 index f76471f..0000000 --- a/examples/declarative/workerscript/workerscript.js +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 2294a81..0000000 --- a/examples/declarative/workerscript/workerscript.qml +++ /dev/null @@ -1,43 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 480; height: 320 - - WorkerScript { - id: myWorker - source: "workerscript.js" - - onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); - } - } - - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); - } - } - - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } - } - - Text { - text: "Click a Rectangle!" - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } - } -} diff --git a/examples/declarative/workerscript/workerscript.qmlproject b/examples/declarative/workerscript/workerscript.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/workerscript/workerscript.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/xml/xml.qmlproject b/examples/declarative/xml/xml.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xml.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xml/xmldata/daringfireball.qml b/examples/declarative/xml/xmldata/daringfireball.qml new file mode 100644 index 0000000..480b13c --- /dev/null +++ b/examples/declarative/xml/xmldata/daringfireball.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Rectangle { + 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 { + anchors { left: titleText.right; leftMargin: 10 } + text: 'by ' + tagline + font.italic: true + } + Text { + x: 10 + width: 580 + anchors.top: titleText.bottom + text: content + wrapMode: Text.WordWrap + + onLinkActivated: { console.log('link clicked: ' + link) } + } + } + } + + ListView { + anchors.fill: parent + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xml/xmldata/xmldata.qmlproject b/examples/declarative/xml/xmldata/xmldata.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xmldata/xmldata.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xml/xmldata/yahoonews.qml b/examples/declarative/xml/xmldata/yahoonews.qml new file mode 100644 index 0000000..5bab463 --- /dev/null +++ b/examples/declarative/xml/xmldata/yahoonews.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 600 + + gradient: Gradient { + GradientStop { position: 0; color: "black" } + GradientStop { position: 1.0; color: "#AAAAAA" } + } + + 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 + + width: 580; y: 5; height: titleText.height + 10 + color: "#F0F0F0" + radius: 5 + + Text { + id: titleText + x: 10; y: 5 + text: '' + title + '' + font { bold: true; family: "Helvetica"; pointSize: 14 } + + onLinkActivated: { console.log('link clicked: ' + link) } + } + + Text { + id: descriptionText + x: 10; width: 560 + anchors.top: titleText.bottom; anchors.topMargin: 5 + text: description + wrapMode: Text.WordWrap + font.family: "Helvetica" + 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: Easing.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/xml/xmlhttprequest/test.qml b/examples/declarative/xml/xmlhttprequest/test.qml new file mode 100644 index 0000000..c7e7e6d --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/test.qml @@ -0,0 +1,36 @@ +import Qt 4.7 + +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/xml/xmlhttprequest/test.xml b/examples/declarative/xml/xmlhttprequest/test.xml new file mode 100644 index 0000000..8b7f1e1 --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/test.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml deleted file mode 100644 index 480b13c..0000000 --- a/examples/declarative/xmldata/daringfireball.qml +++ /dev/null @@ -1,47 +0,0 @@ -import Qt 4.7 - -Rectangle { - 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 { - anchors { left: titleText.right; leftMargin: 10 } - text: 'by ' + tagline - font.italic: true - } - Text { - x: 10 - width: 580 - anchors.top: titleText.bottom - text: content - wrapMode: Text.WordWrap - - onLinkActivated: { console.log('link clicked: ' + link) } - } - } - } - - ListView { - anchors.fill: parent - model: feedModel - delegate: feedDelegate - } -} diff --git a/examples/declarative/xmldata/xmldata.qmlproject b/examples/declarative/xmldata/xmldata.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/xmldata/xmldata.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml deleted file mode 100644 index 5bab463..0000000 --- a/examples/declarative/xmldata/yahoonews.qml +++ /dev/null @@ -1,83 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 600; height: 600 - - gradient: Gradient { - GradientStop { position: 0; color: "black" } - GradientStop { position: 1.0; color: "#AAAAAA" } - } - - 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 - - width: 580; y: 5; height: titleText.height + 10 - color: "#F0F0F0" - radius: 5 - - Text { - id: titleText - x: 10; y: 5 - text: '' + title + '' - font { bold: true; family: "Helvetica"; pointSize: 14 } - - onLinkActivated: { console.log('link clicked: ' + link) } - } - - Text { - id: descriptionText - x: 10; width: 560 - anchors.top: titleText.bottom; anchors.topMargin: 5 - text: description - wrapMode: Text.WordWrap - font.family: "Helvetica" - 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: Easing.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 deleted file mode 100644 index c7e7e6d..0000000 --- a/examples/declarative/xmlhttprequest/test.qml +++ /dev/null @@ -1,36 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index 8b7f1e1..0000000 --- a/examples/declarative/xmlhttprequest/test.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject deleted file mode 100644 index d4909f8..0000000 --- a/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 018bd55..229e15b 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -70,11 +70,11 @@ QT_BEGIN_NAMESPACE \endlist Examples: - \snippet snippets/declarative/border-image.qml 0 + \snippet snippets/declarative/borderimage.qml 0 \image BorderImage.png - The \l{declarative/border-image}{BorderImage example} shows how a BorderImage can be used to simulate a shadow effect on a + The \l{declarative/imageelements/borderimage}{BorderImage example} shows how a BorderImage can be used to simulate a shadow effect on a rectangular item. */ diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index a03a51d..3c0f5a2 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -418,7 +418,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() \dots 4 \snippet doc/src/snippets/declarative/flickableScrollbar.qml 1 - \sa {declarative/scrollbar}{scrollbar example} + \sa {declarative/ui-components/scrollbar}{scrollbar example} */ QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 46e9ce3..b71bb7e 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1908,7 +1908,7 @@ void QDeclarativeListView::setCacheBuffer(int b) pet. The section expression is the size property. If \c ListView.section and \c ListView.prevSection differ, the item will display a section header. - \snippet examples/declarative/listview/sections.qml 0 + \snippet examples/declarative/modelviews/listview/sections.qml 0 \image ListViewSections.png */ diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 2c89abd..79f8a17 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -562,9 +562,9 @@ QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const This example creates a provider with id \e colors: - \snippet examples/declarative/imageprovider/imageprovider.cpp 0 + \snippet examples/declarative/cppextensions/imageprovider/imageprovider.cpp 0 - \snippet examples/declarative/imageprovider/imageprovider-example.qml 0 + \snippet examples/declarative/cppextensions/imageprovider/imageprovider-example.qml 0 \sa removeImageProvider() */ diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp index 2c15385..c2e8300 100644 --- a/src/declarative/qml/qdeclarativeextensionplugin.cpp +++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE See \l {Tutorial: Writing QML extensions with C++} for details on creating QML extensions, including how to build a plugin with with QDeclarativeExtensionPlugin. - For a simple overview, see the \l{declarative/plugins}{plugins} example. + For a simple overview, see the \l{declarative/cppextensions/plugins}{plugins} example. Also see \l {How to Create Qt Plugins} for general Qt plugin documentation. diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index a8e1be8..6223548 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -207,11 +207,11 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM Here is an example that uses WorkerScript to periodically append the current time to a list model: - \snippet examples/declarative/listmodel-threaded/timedisplay.qml 0 + \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0 The included file, \tt dataloader.js, looks like this: - \snippet examples/declarative/listmodel-threaded/dataloader.js 0 + \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0 The application's \tt Timer object periodically sends a message to the worker script by calling \tt WorkerScript::sendMessage(). When this message diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp index 20e9907..9617b86 100644 --- a/src/declarative/util/qdeclarativepackage.cpp +++ b/src/declarative/util/qdeclarativepackage.cpp @@ -62,13 +62,13 @@ QT_BEGIN_NAMESPACE delegate it should appear in. This allows an item to move between views. - \snippet examples/declarative/package/Delegate.qml 0 + \snippet examples/declarative/modelviews/package/Delegate.qml 0 These named items are used as the delegates by the two views who reference the special VisualDataModel.parts property to select a model which provides the chosen delegate. - \snippet examples/declarative/package/view.qml 0 + \snippet examples/declarative/modelviews/package/view.qml 0 \sa QtDeclarative */ diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index f1a00989..4a374a5 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -536,7 +536,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty